From 5ede19c58a1ec274b28e03a76b855c3c55ab6f11 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 8 Dec 2014 11:23:11 +0100 Subject: ASoC: wm8750: Make VREF a VMID instead of OUTPUT widget Commit 04489eeb02a4 ("ALSA: wm8750: add missing VREF output") added the previously missing VREF widget. And while adding the widget as OUTPUT widget silences the error of the missing widget it should have rather been a VMID widget. The VREF widget is only used internally as a source for the VREF input of the Out3 Mux. Selecting that input means that the path should be kept powered up at the VREF/VMID voltage, but that there is no actual audio signal. Using a VMID widget will do this, whereas using a OUTPUT widget will simply cause the path to completely power down. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8750.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 67653a2db223..d9e262657887 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -323,7 +323,7 @@ static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = { SND_SOC_DAPM_OUTPUT("ROUT2"), SND_SOC_DAPM_OUTPUT("MONO1"), SND_SOC_DAPM_OUTPUT("OUT3"), - SND_SOC_DAPM_OUTPUT("VREF"), + SND_SOC_DAPM_VMID("VREF"), SND_SOC_DAPM_INPUT("LINPUT1"), SND_SOC_DAPM_INPUT("LINPUT2"), -- cgit From a380acb88611e1ee90dcb3da39e05991cadc6682 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 23 Nov 2014 13:37:26 +0100 Subject: ASoC: wm8750: Cleanup manual bias level transitions Set the CODEC driver's suspend_bias_off flag rather than manually going to SND_SOC_BIAS_OFF in suspend and SND_SOC_BIAS_STANDBY in resume. This makes the code a bit shorter and cleaner. Since the ASoC core now takes care of setting the bias level to SND_SOC_BIAS_OFF when removing the CODEC there is no need to do it manually anymore either. The manual transition to SND_SOC_BIAS_STANDBY at the end of CODEC probe() can also be removed as the core will automatically do this after the CODEC has been probed. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8750.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index d9e262657887..eb0a1644ba11 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -686,18 +686,6 @@ static struct snd_soc_dai_driver wm8750_dai = { .ops = &wm8750_dai_ops, }; -static int wm8750_suspend(struct snd_soc_codec *codec) -{ - wm8750_set_bias_level(codec, SND_SOC_BIAS_OFF); - return 0; -} - -static int wm8750_resume(struct snd_soc_codec *codec) -{ - wm8750_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - return 0; -} - static int wm8750_probe(struct snd_soc_codec *codec) { int ret; @@ -708,9 +696,6 @@ static int wm8750_probe(struct snd_soc_codec *codec) return ret; } - /* charge output caps */ - wm8750_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - /* set the update bits */ snd_soc_update_bits(codec, WM8750_LDAC, 0x0100, 0x0100); snd_soc_update_bits(codec, WM8750_RDAC, 0x0100, 0x0100); @@ -724,18 +709,10 @@ static int wm8750_probe(struct snd_soc_codec *codec) return ret; } -static int wm8750_remove(struct snd_soc_codec *codec) -{ - wm8750_set_bias_level(codec, SND_SOC_BIAS_OFF); - return 0; -} - static struct snd_soc_codec_driver soc_codec_dev_wm8750 = { .probe = wm8750_probe, - .remove = wm8750_remove, - .suspend = wm8750_suspend, - .resume = wm8750_resume, .set_bias_level = wm8750_set_bias_level, + .suspend_bias_off = true, .controls = wm8750_snd_controls, .num_controls = ARRAY_SIZE(wm8750_snd_controls), -- cgit From eca80394abc50abae9847b264b0a3120336f590a Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Sun, 21 Dec 2014 22:40:43 +0800 Subject: ASoC: Intel: fix platform_no_drv_owner.cocci warnings sound/soc/intel/cht_bsw_rt5672.c:273:3-8: No need to set .owner here. The core will do it. Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Signed-off-by: Fengguang Wu Signed-off-by: Mark Brown --- sound/soc/intel/cht_bsw_rt5672.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/cht_bsw_rt5672.c b/sound/soc/intel/cht_bsw_rt5672.c index 9b8b561171b7..a406c6104897 100644 --- a/sound/soc/intel/cht_bsw_rt5672.c +++ b/sound/soc/intel/cht_bsw_rt5672.c @@ -270,7 +270,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev) static struct platform_driver snd_cht_mc_driver = { .driver = { - .owner = THIS_MODULE, .name = "cht-bsw-rt5672", .pm = &snd_soc_pm_ops, }, -- cgit From 602129c8d1da0b2d43f2afae2ff7f1f2919f6eaa Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Sun, 21 Dec 2014 22:34:50 +0800 Subject: ASoC: Intel: fix platform_no_drv_owner.cocci warnings sound/soc/intel/bytcr_dpcm_rt5640.c:218:3-8: No need to set .owner here. The core will do it. Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci CC: Subhransu S. Prusty Signed-off-by: Fengguang Wu Signed-off-by: Mark Brown --- sound/soc/intel/bytcr_dpcm_rt5640.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/bytcr_dpcm_rt5640.c b/sound/soc/intel/bytcr_dpcm_rt5640.c index f5d0fc1ab10c..9277f2baefb1 100644 --- a/sound/soc/intel/bytcr_dpcm_rt5640.c +++ b/sound/soc/intel/bytcr_dpcm_rt5640.c @@ -215,7 +215,6 @@ static int snd_byt_mc_probe(struct platform_device *pdev) static struct platform_driver snd_byt_mc_driver = { .driver = { - .owner = THIS_MODULE, .name = "bytt100_rt5640", .pm = &snd_soc_pm_ops, }, -- cgit From 676ebf68873f97c0e2a386ce979529573e0a8931 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sun, 21 Dec 2014 22:14:45 +0100 Subject: ASoC: intel: sst: drop owner assignment from platform_drivers This platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang Signed-off-by: Mark Brown --- sound/soc/intel/sst/sst_acpi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/sst/sst_acpi.c b/sound/soc/intel/sst/sst_acpi.c index 3abc29e8a928..f1180ffdc393 100644 --- a/sound/soc/intel/sst/sst_acpi.c +++ b/sound/soc/intel/sst/sst_acpi.c @@ -366,7 +366,6 @@ MODULE_DEVICE_TABLE(acpi, sst_acpi_ids); static struct platform_driver sst_acpi_driver = { .driver = { .name = "intel_sst_acpi", - .owner = THIS_MODULE, .acpi_match_table = ACPI_PTR(sst_acpi_ids), .pm = &intel_sst_pm, }, -- cgit From 97d62a3096355168db71bdcbc618cbf2c3b7c2a0 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sun, 21 Dec 2014 22:14:46 +0100 Subject: ASoC: omap: drop owner assignment from platform_drivers This platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang Signed-off-by: Mark Brown --- sound/soc/omap/omap-hdmi-audio.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/omap/omap-hdmi-audio.c b/sound/soc/omap/omap-hdmi-audio.c index 3f9ac7dbdc80..ccfb41c22e53 100644 --- a/sound/soc/omap/omap-hdmi-audio.c +++ b/sound/soc/omap/omap-hdmi-audio.c @@ -393,7 +393,6 @@ static int omap_hdmi_audio_remove(struct platform_device *pdev) static struct platform_driver hdmi_audio_driver = { .driver = { .name = DRV_NAME, - .owner = THIS_MODULE, }, .probe = omap_hdmi_audio_probe, .remove = omap_hdmi_audio_remove, -- cgit From 7e0fc116c41f0ca93c4d3de6d26c223c92182857 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sun, 21 Dec 2014 22:14:47 +0100 Subject: ASoC: pxa: drop owner assignment from platform_drivers This platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang Signed-off-by: Mark Brown --- sound/soc/pxa/spitz.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c index d7d5fb20ea6f..a6d680acd907 100644 --- a/sound/soc/pxa/spitz.c +++ b/sound/soc/pxa/spitz.c @@ -352,7 +352,6 @@ static int spitz_remove(struct platform_device *pdev) static struct platform_driver spitz_driver = { .driver = { .name = "spitz-audio", - .owner = THIS_MODULE, .pm = &snd_soc_pm_ops, }, .probe = spitz_probe, -- cgit From 03da09a02de2ffd15df89b9ddef17dd7af195f32 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sun, 21 Dec 2014 22:14:48 +0100 Subject: ASoC: samsung: drop owner assignment from platform_drivers This platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang Signed-off-by: Mark Brown --- sound/soc/samsung/arndale_rt5631.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/arndale_rt5631.c b/sound/soc/samsung/arndale_rt5631.c index 1e2b61ca8db2..8bf2e2c4bafb 100644 --- a/sound/soc/samsung/arndale_rt5631.c +++ b/sound/soc/samsung/arndale_rt5631.c @@ -135,7 +135,6 @@ MODULE_DEVICE_TABLE(of, samsung_arndale_rt5631_of_match); static struct platform_driver arndale_audio_driver = { .driver = { .name = "arndale-audio", - .owner = THIS_MODULE, .pm = &snd_soc_pm_ops, .of_match_table = of_match_ptr(samsung_arndale_rt5631_of_match), }, -- cgit From 34084a4367037b5bb3de71dfa7cdcd8e998d153a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 10 Dec 2014 11:53:47 +0100 Subject: ASoC: intel: Remove superfluous backslash in Kconfig The line continuation in Kconfig should be a '\' instead of '\\'. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/intel/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig index e989ecf046c9..f06fcf1e21a5 100644 --- a/sound/soc/intel/Kconfig +++ b/sound/soc/intel/Kconfig @@ -46,7 +46,7 @@ config SND_SOC_INTEL_BAYTRAIL config SND_SOC_INTEL_HASWELL_MACH tristate "ASoC Audio DSP support for Intel Haswell Lynxpoint" - depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C && \\ + depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && I2C && \ I2C_DESIGNWARE_PLATFORM select SND_SOC_INTEL_HASWELL select SND_SOC_RT5640 @@ -76,7 +76,7 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH config SND_SOC_INTEL_BROADWELL_MACH tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint" - depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && DW_DMAC && \\ + depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && DW_DMAC && \ I2C_DESIGNWARE_PLATFORM select SND_SOC_INTEL_HASWELL select SND_COMPRESS_OFFLOAD -- cgit From 768c0564439bce179e3f0f2ffafe8dcab6a08f40 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 21 Dec 2014 11:05:43 +0100 Subject: ASoC: dapm: Don't mark MICBIAS widgets as auto non-connected The connected flag of a widget only affects widgets that are either a source or a sink. The MICBIAS widget is a simple pass-through widget though and hence its behavior is the same regardless of whether the connected flag is set or not. Hence there is not much point in trying to automatically mark MICBIAS widgets as non-connected, so just remove it. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index c5136bb1f982..b8eba93b5faf 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3880,7 +3880,6 @@ void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card) switch (w->id) { case snd_soc_dapm_input: case snd_soc_dapm_output: - case snd_soc_dapm_micbias: dev_dbg(card->dev, "ASoC: Auto NC: Checking widget %s\n", w->name); if (!snd_soc_dapm_widget_in_card_paths(card, w)) { -- cgit From 86d7500326ea71ea72aeaf0da78671eef28be2af Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 21 Dec 2014 11:05:44 +0100 Subject: ASoC: dapm: Simplify fully route card handling For legacy reasons the ASoC framework assumes that a CODEC INPUT or OUTPUT widget that is not explicitly connected to a external source or sink is potentially connected to a source or a sink and hence the framework treats the widget itself as source (for INPUT) or sink (for OUTPUT). For this reason a INPUT or OUTPUT widget that is really not connected needs to be explicitly marked as so. Setting the card's fully_routed flag will cause the ASoC core, once that all widgets and routes have been registered, to go through the list of all widgets and mark all INPUT and OUTPUT that are not externally connected as non-connected. This essentially negates the default behaviour of treating INPUT or OUTPUT widgets without external routes as sources or sinks. This patch takes a different approach while getting the same result. Instead of first marking INPUT and OUTPUT widgets as sinks/sources and then later marking them as non-connected, just never mark them as a sink or a source if the fully_routed flag is set on a card. This requires a lot less code and also results in a slightly faster card initialization since there is no need to iterate over all widgets and check whether the INPUT and OUTPUT widgets are connected or not. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 3 -- sound/soc/soc-dapm.c | 104 ++++++++------------------------------------------- 2 files changed, 16 insertions(+), 91 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 985052b3fbed..89aa6717f26a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1626,9 +1626,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) } } - if (card->fully_routed) - snd_soc_dapm_auto_nc_pins(card); - snd_soc_dapm_new_widgets(card); ret = snd_card_register(card->snd_card); diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index b8eba93b5faf..ea496842ee83 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2279,6 +2279,9 @@ static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w) switch (w->id) { case snd_soc_dapm_input: + /* On a fully routed card a input is never a source */ + if (w->dapm->card->fully_routed) + break; w->is_source = 1; list_for_each_entry(p, &w->sources, list_sink) { if (p->source->id == snd_soc_dapm_micbias || @@ -2291,6 +2294,9 @@ static void dapm_update_widget_flags(struct snd_soc_dapm_widget *w) } break; case snd_soc_dapm_output: + /* On a fully routed card a output is never a sink */ + if (w->dapm->card->fully_routed) + break; w->is_sink = 1; list_for_each_entry(p, &w->sinks, list_source) { if (p->sink->id == snd_soc_dapm_spk || @@ -3085,16 +3091,24 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, switch (w->id) { case snd_soc_dapm_mic: - case snd_soc_dapm_input: w->is_source = 1; w->power_check = dapm_generic_check_power; break; + case snd_soc_dapm_input: + if (!dapm->card->fully_routed) + w->is_source = 1; + w->power_check = dapm_generic_check_power; + break; case snd_soc_dapm_spk: case snd_soc_dapm_hp: - case snd_soc_dapm_output: w->is_sink = 1; w->power_check = dapm_generic_check_power; break; + case snd_soc_dapm_output: + if (!dapm->card->fully_routed) + w->is_sink = 1; + w->power_check = dapm_generic_check_power; + break; case snd_soc_dapm_vmid: case snd_soc_dapm_siggen: w->is_source = 1; @@ -3808,92 +3822,6 @@ int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, } EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend); -/** - * dapm_is_external_path() - Checks if a path is a external path - * @card: The card the path belongs to - * @path: The path to check - * - * Returns true if the path is either between two different DAPM contexts or - * between two external pins of the same DAPM context. Otherwise returns - * false. - */ -static bool dapm_is_external_path(struct snd_soc_card *card, - struct snd_soc_dapm_path *path) -{ - dev_dbg(card->dev, - "... Path %s(id:%d dapm:%p) - %s(id:%d dapm:%p)\n", - path->source->name, path->source->id, path->source->dapm, - path->sink->name, path->sink->id, path->sink->dapm); - - /* Connection between two different DAPM contexts */ - if (path->source->dapm != path->sink->dapm) - return true; - - /* Loopback connection from external pin to external pin */ - if (path->sink->id == snd_soc_dapm_input) { - switch (path->source->id) { - case snd_soc_dapm_output: - case snd_soc_dapm_micbias: - return true; - default: - break; - } - } - - return false; -} - -static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card, - struct snd_soc_dapm_widget *w) -{ - struct snd_soc_dapm_path *p; - - list_for_each_entry(p, &w->sources, list_sink) { - if (dapm_is_external_path(card, p)) - return true; - } - - list_for_each_entry(p, &w->sinks, list_source) { - if (dapm_is_external_path(card, p)) - return true; - } - - return false; -} - -/** - * snd_soc_dapm_auto_nc_pins - call snd_soc_dapm_nc_pin for unused pins - * @card: The card whose pins should be processed - * - * Automatically call snd_soc_dapm_nc_pin() for any external pins in the card - * which are unused. Pins are used if they are connected externally to a - * component, whether that be to some other device, or a loop-back connection to - * the component itself. - */ -void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card) -{ - struct snd_soc_dapm_widget *w; - - dev_dbg(card->dev, "ASoC: Auto NC: DAPMs: card:%p\n", &card->dapm); - - list_for_each_entry(w, &card->widgets, list) { - switch (w->id) { - case snd_soc_dapm_input: - case snd_soc_dapm_output: - dev_dbg(card->dev, "ASoC: Auto NC: Checking widget %s\n", - w->name); - if (!snd_soc_dapm_widget_in_card_paths(card, w)) { - dev_dbg(card->dev, - "... Not in map; disabling\n"); - snd_soc_dapm_nc_pin(w->dapm, w->name); - } - break; - default: - break; - } - } -} - /** * snd_soc_dapm_free - free dapm resources * @dapm: DAPM context -- cgit From a5a41645d0096f4c9ffd7154270b43daebcb4386 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 18 Dec 2014 11:32:52 +0800 Subject: ASoC: rt5670: set platform data by dmi This patch set specific data according to dmi data. Signed-off-by: Jin, Yao Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 8a0833de1665..cd47ef1f5561 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -2549,6 +2550,17 @@ static struct acpi_device_id rt5670_acpi_match[] = { MODULE_DEVICE_TABLE(acpi, rt5670_acpi_match); #endif +static const struct dmi_system_id dmi_platform_intel_braswell[] = { + { + .ident = "Intel Braswell", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), + DMI_MATCH(DMI_BOARD_NAME, "Braswell CRB"), + }, + }, + {} +}; + static int rt5670_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -2568,6 +2580,12 @@ static int rt5670_i2c_probe(struct i2c_client *i2c, if (pdata) rt5670->pdata = *pdata; + if (dmi_check_system(dmi_platform_intel_braswell)) { + rt5670->pdata.dmic_en = true; + rt5670->pdata.dmic1_data_pin = RT5670_DMIC_DATA_IN2P; + rt5670->pdata.jd_mode = 1; + } + rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); if (IS_ERR(rt5670->regmap)) { ret = PTR_ERR(rt5670->regmap); -- cgit From be33465e58ab3a3300c5182844d45c67e73b15e0 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Fri, 12 Dec 2014 09:25:00 +0000 Subject: ASoC: dwc: Remove unnecessary debug messages and tests The devm_XXX allocation functions print a message on failure, so additional messages are not required. Signed-off-by: Andrew Jackson Signed-off-by: Mark Brown --- sound/soc/dwc/designware_i2s.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index b93168d4f648..f81e747c1c12 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c @@ -345,26 +345,17 @@ static int dw_i2s_probe(struct platform_device *pdev) } dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL); - if (!dw_i2s_dai) { - dev_err(&pdev->dev, "mem allocation failed for dai driver\n"); + if (!dw_i2s_dai) 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); - if (!res) { - dev_err(&pdev->dev, "no i2s resource defined\n"); - return -ENODEV; - } - dev->i2s_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(dev->i2s_base)) { - dev_err(&pdev->dev, "ioremap fail for i2s_region\n"); + if (IS_ERR(dev->i2s_base)) return PTR_ERR(dev->i2s_base); - } cap = pdata->cap; dev->capability = cap; -- cgit From afa8603c6253204bf96c88739f711e89c2b00cd5 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Fri, 19 Dec 2014 16:18:07 +0000 Subject: ASoC: dwc: Reorder code in preparation for DT support Move code that configures the DAI and DMA into a separate function. This reduces the size of the dw_i2s_probe function and will make it easier to add support for device tree to the driver. Signed-off-by: Andrew Jackson Signed-off-by: Mark Brown --- sound/soc/dwc/designware_i2s.c | 73 ++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 34 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index f81e747c1c12..23a7c13b914f 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c @@ -324,13 +324,47 @@ static int dw_i2s_resume(struct snd_soc_dai *dai) #define dw_i2s_resume NULL #endif +static void dw_configure_dai_by_pd(struct dw_i2s_dev *dev, + struct snd_soc_dai_driver *dw_i2s_dai, + struct resource *res, + const struct i2s_platform_data *pdata) +{ + /* Set DMA slaves info */ + + dev->play_dma_data.data = pdata->play_dma_data; + dev->capture_dma_data.data = pdata->capture_dma_data; + dev->play_dma_data.addr = res->start + I2S_TXDMA; + dev->capture_dma_data.addr = res->start + I2S_RXDMA; + dev->play_dma_data.max_burst = 16; + dev->capture_dma_data.max_burst = 16; + dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; + dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; + dev->play_dma_data.filter = pdata->filter; + dev->capture_dma_data.filter = pdata->filter; + + if (pdata->cap & DWC_I2S_PLAY) { + dev_dbg(dev->dev, " designware: play supported\n"); + dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM; + dw_i2s_dai->playback.channels_max = pdata->channel; + dw_i2s_dai->playback.formats = pdata->snd_fmts; + dw_i2s_dai->playback.rates = pdata->snd_rates; + } + + if (pdata->cap & DWC_I2S_RECORD) { + dev_dbg(dev->dev, "designware: record supported\n"); + dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM; + dw_i2s_dai->capture.channels_max = pdata->channel; + dw_i2s_dai->capture.formats = pdata->snd_fmts; + dw_i2s_dai->capture.rates = pdata->snd_rates; + } +} + static int dw_i2s_probe(struct platform_device *pdev) { const struct i2s_platform_data *pdata = pdev->dev.platform_data; struct dw_i2s_dev *dev; struct resource *res; int ret; - unsigned int cap; struct snd_soc_dai_driver *dw_i2s_dai; if (!pdata) { @@ -357,23 +391,11 @@ static int dw_i2s_probe(struct platform_device *pdev) if (IS_ERR(dev->i2s_base)) return PTR_ERR(dev->i2s_base); - cap = pdata->cap; - dev->capability = cap; - dev->i2s_clk_cfg = pdata->i2s_clk_cfg; - - /* Set DMA slaves info */ - - dev->play_dma_data.data = pdata->play_dma_data; - dev->capture_dma_data.data = pdata->capture_dma_data; - dev->play_dma_data.addr = res->start + I2S_TXDMA; - dev->capture_dma_data.addr = res->start + I2S_RXDMA; - dev->play_dma_data.max_burst = 16; - dev->capture_dma_data.max_burst = 16; - dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; - dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; - dev->play_dma_data.filter = pdata->filter; - dev->capture_dma_data.filter = pdata->filter; + dev->dev = &pdev->dev; + dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata); + dev->capability = pdata->cap; + dev->i2s_clk_cfg = pdata->i2s_clk_cfg; dev->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(dev->clk)) return PTR_ERR(dev->clk); @@ -382,23 +404,6 @@ static int dw_i2s_probe(struct platform_device *pdev) if (ret < 0) goto err_clk_put; - if (cap & DWC_I2S_PLAY) { - dev_dbg(&pdev->dev, " designware: play supported\n"); - dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM; - dw_i2s_dai->playback.channels_max = pdata->channel; - dw_i2s_dai->playback.formats = pdata->snd_fmts; - dw_i2s_dai->playback.rates = pdata->snd_rates; - } - - if (cap & DWC_I2S_RECORD) { - dev_dbg(&pdev->dev, "designware: record supported\n"); - dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM; - dw_i2s_dai->capture.channels_max = pdata->channel; - dw_i2s_dai->capture.formats = pdata->snd_fmts; - dw_i2s_dai->capture.rates = pdata->snd_rates; - } - - dev->dev = &pdev->dev; dev_set_drvdata(&pdev->dev, dev); ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, dw_i2s_dai, 1); -- cgit From ba5295e55dd941425b10924f4f5c7af6eac4a1cb Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Tue, 9 Dec 2014 09:28:09 +0100 Subject: ASoC: pcm512x: Also support PCM514x devices Signed-off-by: Peter Rosin Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x-i2c.c | 4 ++++ sound/soc/codecs/pcm512x-spi.c | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/pcm512x-i2c.c b/sound/soc/codecs/pcm512x-i2c.c index d0547fa275fc..dcdfac0ffeb1 100644 --- a/sound/soc/codecs/pcm512x-i2c.c +++ b/sound/soc/codecs/pcm512x-i2c.c @@ -46,6 +46,8 @@ static int pcm512x_i2c_remove(struct i2c_client *i2c) static const struct i2c_device_id pcm512x_i2c_id[] = { { "pcm5121", }, { "pcm5122", }, + { "pcm5141", }, + { "pcm5142", }, { } }; MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); @@ -53,6 +55,8 @@ MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); static const struct of_device_id pcm512x_of_match[] = { { .compatible = "ti,pcm5121", }, { .compatible = "ti,pcm5122", }, + { .compatible = "ti,pcm5141", }, + { .compatible = "ti,pcm5142", }, { } }; MODULE_DEVICE_TABLE(of, pcm512x_of_match); diff --git a/sound/soc/codecs/pcm512x-spi.c b/sound/soc/codecs/pcm512x-spi.c index f297058c0038..7b64a9cef704 100644 --- a/sound/soc/codecs/pcm512x-spi.c +++ b/sound/soc/codecs/pcm512x-spi.c @@ -43,6 +43,8 @@ static int pcm512x_spi_remove(struct spi_device *spi) static const struct spi_device_id pcm512x_spi_id[] = { { "pcm5121", }, { "pcm5122", }, + { "pcm5141", }, + { "pcm5142", }, { }, }; MODULE_DEVICE_TABLE(spi, pcm512x_spi_id); @@ -50,6 +52,8 @@ MODULE_DEVICE_TABLE(spi, pcm512x_spi_id); static const struct of_device_id pcm512x_of_match[] = { { .compatible = "ti,pcm5121", }, { .compatible = "ti,pcm5122", }, + { .compatible = "ti,pcm5141", }, + { .compatible = "ti,pcm5142", }, { } }; MODULE_DEVICE_TABLE(of, pcm512x_of_match); -- cgit From 5129ad6e4e699924f7bc77d3d70ffc011a9024b8 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 9 Dec 2014 09:10:44 +0800 Subject: ASoC: Intel: fix sparse non static symbol warnings Fixes the following sparse warnings: sound/soc/intel/sst/sst_acpi.c:248:5: warning: symbol 'sst_acpi_probe' was not declared. Should it be static? sound/soc/intel/sst/sst_acpi.c:335:5: warning: symbol 'sst_acpi_remove' was not declared. Should it be static? Signed-off-by: Wei Yongjun Signed-off-by: Mark Brown --- sound/soc/intel/sst/sst_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst/sst_acpi.c b/sound/soc/intel/sst/sst_acpi.c index f1180ffdc393..df2b5cc23766 100644 --- a/sound/soc/intel/sst/sst_acpi.c +++ b/sound/soc/intel/sst/sst_acpi.c @@ -245,7 +245,7 @@ static struct sst_machines *sst_acpi_find_machine( return NULL; } -int sst_acpi_probe(struct platform_device *pdev) +static int sst_acpi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; int ret = 0; @@ -332,7 +332,7 @@ do_sst_cleanup: * This function is called by OS when a device is unloaded * This frees the interrupt etc */ -int sst_acpi_remove(struct platform_device *pdev) +static int sst_acpi_remove(struct platform_device *pdev) { struct intel_sst_drv *ctx; -- cgit From f2ecf2ef59b57bd495c40d8a3e9d03e80f66afa4 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 15 Dec 2014 15:42:33 +0800 Subject: ASoC: rt5670: Add runtime PM support This patch adds runtime PM support on rt5670 codec. Signed-off-by: Lin Mengdong Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index cd47ef1f5561..78d85de8af6f 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -2734,18 +2735,26 @@ static int rt5670_i2c_probe(struct i2c_client *i2c, } + pm_runtime_enable(&i2c->dev); + pm_request_idle(&i2c->dev); + ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5670, rt5670_dai, ARRAY_SIZE(rt5670_dai)); if (ret < 0) goto err; + pm_runtime_put(&i2c->dev); + return 0; err: + pm_runtime_disable(&i2c->dev); + return ret; } static int rt5670_i2c_remove(struct i2c_client *i2c) { + pm_runtime_disable(&i2c->dev); snd_soc_unregister_codec(&i2c->dev); return 0; -- cgit From 026e73683ad5665a45b01ca1a221fa87e0e8e6fb Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 15 Dec 2014 15:42:34 +0800 Subject: ASoC: rt5670: Keep sysclk on if JD func is used System clock is necessary for rt5670 JD function. We assume system clock source will be set in machine driver. So there are two things left we should do in codec driver. 1. Set sysclk to codec internal clock in probe since machine driver may not do that before JD function is registered. 2. Power up PLL once sysclk source is switched to PLL. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 78d85de8af6f..0a027bc94399 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -2190,6 +2190,13 @@ static int rt5670_set_dai_sysclk(struct snd_soc_dai *dai, if (freq == rt5670->sysclk && clk_id == rt5670->sysclk_src) return 0; + if (rt5670->pdata.jd_mode) { + if (clk_id == RT5670_SCLK_S_PLL1) + snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL1"); + else + snd_soc_dapm_disable_pin(&codec->dapm, "PLL1"); + snd_soc_dapm_sync(&codec->dapm); + } switch (clk_id) { case RT5670_SCLK_S_MCLK: reg_val |= RT5670_SCLK_SRC_MCLK; @@ -2628,6 +2635,10 @@ static int rt5670_i2c_probe(struct i2c_client *i2c, } if (rt5670->pdata.jd_mode) { + regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK, + RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_RCCLK); + rt5670->sysclk = 0; + rt5670->sysclk_src = RT5670_SCLK_S_RCCLK; regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, RT5670_PWR_MB, RT5670_PWR_MB); regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2, -- cgit From 90cc7f1cbbde49c0919953928c225c036ece0d9c Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Tue, 23 Dec 2014 11:04:41 +0200 Subject: ASoC: pcm: Fix vague codec and cpu DAI prepare error messages Both codec and cpu DAI prepare print the same error message making it a bit more difficult to grep quickly from sources. Fix this by telling it explicitly. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index eb87d96e2cf0..0ae0e2a9eed7 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -746,7 +746,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) codec_dai); if (ret < 0) { dev_err(codec_dai->dev, - "ASoC: DAI prepare error: %d\n", ret); + "ASoC: codec DAI prepare error: %d\n", + ret); goto out; } } @@ -755,8 +756,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) if (cpu_dai->driver->ops && cpu_dai->driver->ops->prepare) { ret = cpu_dai->driver->ops->prepare(substream, cpu_dai); if (ret < 0) { - dev_err(cpu_dai->dev, "ASoC: DAI prepare error: %d\n", - ret); + dev_err(cpu_dai->dev, + "ASoC: cpu DAI prepare error: %d\n", ret); goto out; } } -- cgit From 85b88a8dd0c758464f31a9758deb27b31c0d5de7 Mon Sep 17 00:00:00 2001 From: Jie Yang Date: Tue, 23 Dec 2014 09:24:50 +0800 Subject: ASoC: Intel: Store the entry_point read from FW file To enable some modules from other than base FW, according to FW interface spec, we need pass the correct entry point param to FW, so here store the entry_point read from FW file for later usage. Signed-off-by: Jie Yang Signed-off-by: Mark Brown --- sound/soc/intel/sst-firmware.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c index 4a5bde9c686b..cad6ea179cea 100644 --- a/sound/soc/intel/sst-firmware.c +++ b/sound/soc/intel/sst-firmware.c @@ -497,6 +497,7 @@ struct sst_module *sst_module_new(struct sst_fw *sst_fw, sst_module->sst_fw = sst_fw; sst_module->scratch_size = template->scratch_size; sst_module->persistent_size = template->persistent_size; + sst_module->entry = template->entry; INIT_LIST_HEAD(&sst_module->block_list); INIT_LIST_HEAD(&sst_module->runtime_list); -- cgit From 6800b5ba154df5666f123b7d78161e1a9e6ad8ef Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Tue, 23 Dec 2014 10:27:54 +0800 Subject: ASoC: rt5677: Revise the filter powers Add the filter powers of the dac mono3 and mono4, and remove the connection of dac stereo1 filter that connect to DAC1 MIX. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 81fe1464d268..a15e39dd8e17 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -2645,10 +2645,18 @@ static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = { /* DAC Mixer */ SND_SOC_DAPM_SUPPLY("dac stereo1 filter", RT5677_PWR_DIG2, RT5677_PWR_DAC_S1F_BIT, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("dac mono left filter", RT5677_PWR_DIG2, + SND_SOC_DAPM_SUPPLY("dac mono2 left filter", RT5677_PWR_DIG2, RT5677_PWR_DAC_M2F_L_BIT, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("dac mono right filter", RT5677_PWR_DIG2, + SND_SOC_DAPM_SUPPLY("dac mono2 right filter", RT5677_PWR_DIG2, RT5677_PWR_DAC_M2F_R_BIT, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("dac mono3 left filter", RT5677_PWR_DIG2, + RT5677_PWR_DAC_M3F_L_BIT, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("dac mono3 right filter", RT5677_PWR_DIG2, + RT5677_PWR_DAC_M3F_R_BIT, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("dac mono4 left filter", RT5677_PWR_DIG2, + RT5677_PWR_DAC_M4F_L_BIT, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("dac mono4 right filter", RT5677_PWR_DIG2, + RT5677_PWR_DAC_M4F_R_BIT, 0, NULL, 0), SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, rt5677_sto1_dac_l_mix, ARRAY_SIZE(rt5677_sto1_dac_l_mix)), @@ -3455,10 +3463,8 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { { "DAC1 MIXL", "Stereo ADC Switch", "ADDA1 Mux" }, { "DAC1 MIXL", "DAC1 Switch", "DAC1 Mux" }, - { "DAC1 MIXL", NULL, "dac stereo1 filter" }, { "DAC1 MIXR", "Stereo ADC Switch", "ADDA1 Mux" }, { "DAC1 MIXR", "DAC1 Switch", "DAC1 Mux" }, - { "DAC1 MIXR", NULL, "dac stereo1 filter" }, { "DAC1 FS", NULL, "DAC1 MIXL" }, { "DAC1 FS", NULL, "DAC1 MIXR" }, @@ -3530,30 +3536,34 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" }, { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" }, { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" }, - { "Mono DAC MIXL", NULL, "dac mono left filter" }, + { "Mono DAC MIXL", NULL, "dac mono2 left filter" }, { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" }, { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" }, { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" }, - { "Mono DAC MIXR", NULL, "dac mono right filter" }, + { "Mono DAC MIXR", NULL, "dac mono2 right filter" }, { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" }, { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" }, + { "DD1 MIXL", NULL, "dac mono3 left filter" }, { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" }, { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" }, + { "DD1 MIXR", NULL, "dac mono3 right filter" }, { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" }, { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" }, + { "DD2 MIXL", NULL, "dac mono4 left filter" }, { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" }, { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" }, + { "DD2 MIXR", NULL, "dac mono4 right filter" }, { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" }, { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" }, -- cgit From 5a8c7c2628f8d12e9bca6ab24f6718fc57728991 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Tue, 23 Dec 2014 10:27:55 +0800 Subject: ASoC: rt5677: Add the ASRC support Add the ASRC support Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index a15e39dd8e17..66abfa3bbb95 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -921,6 +921,97 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, return 0; } +static int is_using_asrc(struct snd_soc_dapm_widget *source, + struct snd_soc_dapm_widget *sink) +{ + unsigned int reg, shift, val; + + if (source->reg == RT5677_ASRC_1) { + switch (source->shift) { + case 12: + reg = RT5677_ASRC_4; + shift = 0; + break; + case 13: + reg = RT5677_ASRC_4; + shift = 4; + break; + case 14: + reg = RT5677_ASRC_4; + shift = 8; + break; + case 15: + reg = RT5677_ASRC_4; + shift = 12; + break; + default: + return 0; + } + } else { + switch (source->shift) { + case 0: + reg = RT5677_ASRC_6; + shift = 8; + break; + case 1: + reg = RT5677_ASRC_6; + shift = 12; + break; + case 2: + reg = RT5677_ASRC_5; + shift = 0; + break; + case 3: + reg = RT5677_ASRC_5; + shift = 4; + break; + case 4: + reg = RT5677_ASRC_5; + shift = 8; + break; + case 5: + reg = RT5677_ASRC_5; + shift = 12; + break; + case 12: + reg = RT5677_ASRC_3; + shift = 0; + break; + case 13: + reg = RT5677_ASRC_3; + shift = 4; + break; + case 14: + reg = RT5677_ASRC_3; + shift = 12; + break; + default: + return 0; + } + } + + val = (snd_soc_read(source->codec, reg) >> shift) & 0xf; + switch (val) { + case 1 ... 6: + return 1; + default: + return 0; + } + +} + +static int can_use_asrc(struct snd_soc_dapm_widget *source, + struct snd_soc_dapm_widget *sink) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + + if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384) + return 1; + + return 0; +} + /* Digital Mixer */ static const struct snd_kcontrol_new rt5677_sto1_adc_l_mix[] = { SOC_DAPM_SINGLE("ADC1 Switch", RT5677_STO1_ADC_MIXER, @@ -2215,6 +2306,45 @@ static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("PLL2", RT5677_PWR_ANLG2, RT5677_PWR_PLL2_BIT, 0, rt5677_set_pll2_event, SND_SOC_DAPM_POST_PMU), + /* ASRC */ + SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5677_ASRC_1, 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5677_ASRC_1, 1, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("I2S3 ASRC", 1, RT5677_ASRC_1, 2, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("I2S4 ASRC", 1, RT5677_ASRC_1, 3, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5677_ASRC_2, 14, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("DAC MONO2 L ASRC", 1, RT5677_ASRC_2, 13, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DAC MONO2 R ASRC", 1, RT5677_ASRC_2, 12, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DAC MONO3 L ASRC", 1, RT5677_ASRC_1, 15, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DAC MONO3 R ASRC", 1, RT5677_ASRC_1, 14, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DAC MONO4 L ASRC", 1, RT5677_ASRC_1, 13, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DAC MONO4 R ASRC", 1, RT5677_ASRC_1, 12, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5677_ASRC_2, 11, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5677_ASRC_2, 10, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DMIC STO3 ASRC", 1, RT5677_ASRC_2, 9, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DMIC STO4 ASRC", 1, RT5677_ASRC_2, 8, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5677_ASRC_2, 7, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5677_ASRC_2, 6, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5677_ASRC_2, 5, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5677_ASRC_2, 4, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("ADC STO3 ASRC", 1, RT5677_ASRC_2, 3, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("ADC STO4 ASRC", 1, RT5677_ASRC_2, 2, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5677_ASRC_2, 1, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5677_ASRC_2, 0, 0, NULL, + 0), + /* Input Side */ /* micbias */ SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT, @@ -2729,6 +2859,31 @@ static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = { }; static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { + { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", can_use_asrc }, + { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", can_use_asrc }, + { "Stereo3 DMIC Mux", NULL, "DMIC STO3 ASRC", can_use_asrc }, + { "Stereo4 DMIC Mux", NULL, "DMIC STO4 ASRC", can_use_asrc }, + { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc }, + { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc }, + { "I2S1", NULL, "I2S1 ASRC", can_use_asrc}, + { "I2S2", NULL, "I2S2 ASRC", can_use_asrc}, + { "I2S3", NULL, "I2S3 ASRC", can_use_asrc}, + { "I2S4", NULL, "I2S4 ASRC", can_use_asrc}, + + { "dac stereo1 filter", NULL, "DAC STO ASRC", is_using_asrc }, + { "dac mono2 left filter", NULL, "DAC MONO2 L ASRC", is_using_asrc }, + { "dac mono2 right filter", NULL, "DAC MONO2 R ASRC", is_using_asrc }, + { "dac mono3 left filter", NULL, "DAC MONO3 L ASRC", is_using_asrc }, + { "dac mono3 right filter", NULL, "DAC MONO3 R ASRC", is_using_asrc }, + { "dac mono4 left filter", NULL, "DAC MONO4 L ASRC", is_using_asrc }, + { "dac mono4 right filter", NULL, "DAC MONO4 R ASRC", is_using_asrc }, + { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc }, + { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc }, + { "adc stereo3 filter", NULL, "ADC STO3 ASRC", is_using_asrc }, + { "adc stereo4 filter", NULL, "ADC STO4 ASRC", is_using_asrc }, + { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc }, + { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc }, + { "DMIC1", NULL, "DMIC L1" }, { "DMIC1", NULL, "DMIC R1" }, { "DMIC2", NULL, "DMIC L2" }, -- cgit From 38d595e2e09ede17712b2d4909339e691fff3f85 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Tue, 23 Dec 2014 10:27:56 +0800 Subject: ASoC: rt5677: Adjust the routing of "PLL1" Remove the duplicated PLL1 connections of the adc stereo filters, and remove the PLL1 connections of the DACs because the PLL1 should be connected to dac filters. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 66abfa3bbb95..cf39fe6d0601 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -3014,8 +3014,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" }, { "Stereo1 ADC MIXL", NULL, "adc stereo1 filter" }, - { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, - { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" }, { "Stereo1 ADC MIXR", NULL, "adc stereo1 filter" }, { "adc stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, @@ -3036,8 +3034,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" }, { "Stereo2 ADC MIXL", NULL, "adc stereo2 filter" }, - { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll }, - { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" }, { "Stereo2 ADC MIXR", NULL, "adc stereo2 filter" }, { "adc stereo2 filter", NULL, "PLL1", is_sys_clk_from_pll }, @@ -3052,8 +3048,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { { "Stereo3 ADC MIXL", NULL, "Sto3 ADC MIXL" }, { "Stereo3 ADC MIXL", NULL, "adc stereo3 filter" }, - { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll }, - { "Stereo3 ADC MIXR", NULL, "Sto3 ADC MIXR" }, { "Stereo3 ADC MIXR", NULL, "adc stereo3 filter" }, { "adc stereo3 filter", NULL, "PLL1", is_sys_clk_from_pll }, @@ -3068,8 +3062,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { { "Stereo4 ADC MIXL", NULL, "Sto4 ADC MIXL" }, { "Stereo4 ADC MIXL", NULL, "adc stereo4 filter" }, - { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll }, - { "Stereo4 ADC MIXR", NULL, "Sto4 ADC MIXR" }, { "Stereo4 ADC MIXR", NULL, "adc stereo4 filter" }, { "adc stereo4 filter", NULL, "PLL1", is_sys_clk_from_pll }, @@ -3686,39 +3678,46 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { { "Stereo DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, { "Stereo DAC MIXR", "DAC1 L Switch", "DAC1 MIXL" }, { "Stereo DAC MIXR", NULL, "dac stereo1 filter" }, + { "dac stereo1 filter", NULL, "PLL1", is_sys_clk_from_pll }, { "Mono DAC MIXL", "ST L Switch", "Sidetone Mux" }, { "Mono DAC MIXL", "DAC1 L Switch", "DAC1 MIXL" }, { "Mono DAC MIXL", "DAC2 L Switch", "DAC2 L Mux" }, { "Mono DAC MIXL", "DAC2 R Switch", "DAC2 R Mux" }, { "Mono DAC MIXL", NULL, "dac mono2 left filter" }, + { "dac mono2 left filter", NULL, "PLL1", is_sys_clk_from_pll }, { "Mono DAC MIXR", "ST R Switch", "Sidetone Mux" }, { "Mono DAC MIXR", "DAC1 R Switch", "DAC1 MIXR" }, { "Mono DAC MIXR", "DAC2 R Switch", "DAC2 R Mux" }, { "Mono DAC MIXR", "DAC2 L Switch", "DAC2 L Mux" }, { "Mono DAC MIXR", NULL, "dac mono2 right filter" }, + { "dac mono2 right filter", NULL, "PLL1", is_sys_clk_from_pll }, { "DD1 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, { "DD1 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, { "DD1 MIXL", "DAC3 L Switch", "DAC3 L Mux" }, { "DD1 MIXL", "DAC3 R Switch", "DAC3 R Mux" }, { "DD1 MIXL", NULL, "dac mono3 left filter" }, + { "dac mono3 left filter", NULL, "PLL1", is_sys_clk_from_pll }, { "DD1 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, { "DD1 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, { "DD1 MIXR", "DAC3 L Switch", "DAC3 L Mux" }, { "DD1 MIXR", "DAC3 R Switch", "DAC3 R Mux" }, { "DD1 MIXR", NULL, "dac mono3 right filter" }, + { "dac mono3 right filter", NULL, "PLL1", is_sys_clk_from_pll }, { "DD2 MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, { "DD2 MIXL", "Mono DAC Mix L Switch", "Mono DAC MIXL" }, { "DD2 MIXL", "DAC4 L Switch", "DAC4 L Mux" }, { "DD2 MIXL", "DAC4 R Switch", "DAC4 R Mux" }, { "DD2 MIXL", NULL, "dac mono4 left filter" }, + { "dac mono4 left filter", NULL, "PLL1", is_sys_clk_from_pll }, { "DD2 MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, { "DD2 MIXR", "Mono DAC Mix R Switch", "Mono DAC MIXR" }, { "DD2 MIXR", "DAC4 L Switch", "DAC4 L Mux" }, { "DD2 MIXR", "DAC4 R Switch", "DAC4 R Mux" }, { "DD2 MIXR", NULL, "dac mono4 right filter" }, + { "dac mono4 right filter", NULL, "PLL1", is_sys_clk_from_pll }, { "Stereo DAC MIX", NULL, "Stereo DAC MIXL" }, { "Stereo DAC MIX", NULL, "Stereo DAC MIXR" }, @@ -3740,11 +3739,8 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { { "DAC3 SRC Mux", "DD MIX2L", "DD2 MIXL" }, { "DAC 1", NULL, "DAC12 SRC Mux" }, - { "DAC 1", NULL, "PLL1", is_sys_clk_from_pll }, { "DAC 2", NULL, "DAC12 SRC Mux" }, - { "DAC 2", NULL, "PLL1", is_sys_clk_from_pll }, { "DAC 3", NULL, "DAC3 SRC Mux" }, - { "DAC 3", NULL, "PLL1", is_sys_clk_from_pll }, { "PDM1 L Mux", "STO1 DAC MIX", "Stereo DAC MIXL" }, { "PDM1 L Mux", "MONO DAC MIX", "Mono DAC MIXL" }, -- cgit From bba1431211e6fdc56680d98d2bdabaab1fd13b79 Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Wed, 24 Dec 2014 17:37:01 +0800 Subject: ASoC: rockchip: i2s: set TDL and RDL to 16 samples Set Transmit Data Level(TDL) and Receive Data Level(RDL) to 16 samples. Without this setting, the TDL is default to be 0x00 (means 0 sample), and the RDL is default to be 0x1f (means 32 samples). Signed-off-by: Jianqun Xu Signed-off-by: Mark Brown --- sound/soc/rockchip/rockchip_i2s.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 26ec5117b35c..dac0002aad6a 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -247,6 +247,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val); + regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK, + I2S_DMACR_TDL(16)); + regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK, + I2S_DMACR_RDL(16)); return 0; } -- cgit From ebd8146bba4d1716e2e47cbd5583f6836eeafb48 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Sat, 20 Dec 2014 17:46:02 +0100 Subject: ALSA: ice1712: wm8776.c: Remove some unused functions Removes some functions that are not used anywhere: snd_wm8776_set_master_mode() snd_wm8776_set_adc_if() snd_wm8776_set_dac_if() This was partially found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist Signed-off-by: Takashi Iwai --- sound/pci/ice1712/wm8776.c | 15 --------------- sound/pci/ice1712/wm8776.h | 3 --- 2 files changed, 18 deletions(-) (limited to 'sound') diff --git a/sound/pci/ice1712/wm8776.c b/sound/pci/ice1712/wm8776.c index e66c0da62014..ebd2fe4b4a57 100644 --- a/sound/pci/ice1712/wm8776.c +++ b/sound/pci/ice1712/wm8776.c @@ -452,21 +452,6 @@ void snd_wm8776_resume(struct snd_wm8776 *wm) snd_wm8776_write(wm, i, wm->regs[i]); } -void snd_wm8776_set_dac_if(struct snd_wm8776 *wm, u16 dac) -{ - snd_wm8776_write(wm, WM8776_REG_DACIFCTRL, dac); -} - -void snd_wm8776_set_adc_if(struct snd_wm8776 *wm, u16 adc) -{ - snd_wm8776_write(wm, WM8776_REG_ADCIFCTRL, adc); -} - -void snd_wm8776_set_master_mode(struct snd_wm8776 *wm, u16 mode) -{ - snd_wm8776_write(wm, WM8776_REG_MSTRCTRL, mode); -} - void snd_wm8776_set_power(struct snd_wm8776 *wm, u16 power) { snd_wm8776_write(wm, WM8776_REG_PWRDOWN, power); diff --git a/sound/pci/ice1712/wm8776.h b/sound/pci/ice1712/wm8776.h index 93a2d6971154..42acef05540c 100644 --- a/sound/pci/ice1712/wm8776.h +++ b/sound/pci/ice1712/wm8776.h @@ -216,9 +216,6 @@ struct snd_wm8776 { void snd_wm8776_init(struct snd_wm8776 *wm); void snd_wm8776_resume(struct snd_wm8776 *wm); -void snd_wm8776_set_dac_if(struct snd_wm8776 *wm, u16 dac); -void snd_wm8776_set_adc_if(struct snd_wm8776 *wm, u16 adc); -void snd_wm8776_set_master_mode(struct snd_wm8776 *wm, u16 mode); void snd_wm8776_set_power(struct snd_wm8776 *wm, u16 power); void snd_wm8776_volume_restore(struct snd_wm8776 *wm); int snd_wm8776_build_controls(struct snd_wm8776 *wm); -- cgit From 57da6bdd4823ad70ac58c5cd968943a4be95d739 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Sun, 21 Dec 2014 13:35:12 +0100 Subject: ALSA: hda - patch_analog.c: Remove some unused functions Removes some functions that are not used anywhere: ad198x_ch_mode_get() ad198x_ch_mode_info() ad198x_ch_mode_info() This was partially found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index a9d78e275138..d285904cdb64 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -739,39 +739,6 @@ static int patch_ad1981(struct hda_codec *codec) * E/F quad mic array */ -#ifdef ENABLE_AD_STATIC_QUIRKS -static int ad198x_ch_mode_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; - return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, - spec->num_channel_mode); -} - -static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - struct ad198x_spec *spec = codec->spec; - return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, - spec->num_channel_mode, spec->multiout.max_channels); -} - -static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - struct ad198x_spec *spec = codec->spec; - int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, - spec->num_channel_mode, - &spec->multiout.max_channels); - if (err >= 0 && spec->need_dac_fix) - spec->multiout.num_dacs = spec->multiout.max_channels / 2; - return err; -} -#endif /* ENABLE_AD_STATIC_QUIRKS */ - static int ad1988_auto_smux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { -- cgit From eb58d4844b4ee797bbefa6a75db3a999b71209b1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 26 Dec 2014 12:22:35 +0100 Subject: ALSA: gus: Remove unused gus_instr.c The instrument layer codes have been dropped years ago, but this file was left intentionally with a slight hope for the new implementations. But, looking at the reality, the probability we'll have a new code for ISA GUS board is very low, and I won't bet it. So, rather clean this legacy stuff up. Developers can still refer to the old code via git history. Reported-by: Rickard Strandqvist Signed-off-by: Takashi Iwai --- sound/isa/gus/gus_instr.c | 172 ---------------------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 sound/isa/gus/gus_instr.c (limited to 'sound') diff --git a/sound/isa/gus/gus_instr.c b/sound/isa/gus/gus_instr.c deleted file mode 100644 index 4dc9caf8ddcf..000000000000 --- a/sound/isa/gus/gus_instr.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Routines for Gravis UltraSound soundcards - Synthesizer - * Copyright (c) by Jaroslav Kysela - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include - -/* - * - */ - -int snd_gus_iwffff_put_sample(void *private_data, struct iwffff_wave *wave, - char __user *data, long len, int atomic) -{ - struct snd_gus_card *gus = private_data; - struct snd_gf1_mem_block *block; - int err; - - if (wave->format & IWFFFF_WAVE_ROM) - return 0; /* it's probably ok - verify the address? */ - if (wave->format & IWFFFF_WAVE_STEREO) - return -EINVAL; /* not supported */ - block = snd_gf1_mem_alloc(&gus->gf1.mem_alloc, - SNDRV_GF1_MEM_OWNER_WAVE_IWFFFF, - NULL, wave->size, - wave->format & IWFFFF_WAVE_16BIT, 1, - wave->share_id); - if (block == NULL) - return -ENOMEM; - err = snd_gus_dram_write(gus, data, - block->ptr, wave->size); - if (err < 0) { - snd_gf1_mem_lock(&gus->gf1.mem_alloc, 0); - snd_gf1_mem_xfree(&gus->gf1.mem_alloc, block); - snd_gf1_mem_lock(&gus->gf1.mem_alloc, 1); - return err; - } - wave->address.memory = block->ptr; - return 0; -} - -int snd_gus_iwffff_get_sample(void *private_data, struct iwffff_wave *wave, - char __user *data, long len, int atomic) -{ - struct snd_gus_card *gus = private_data; - - return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, - wave->format & IWFFFF_WAVE_ROM ? 1 : 0); -} - -int snd_gus_iwffff_remove_sample(void *private_data, struct iwffff_wave *wave, - int atomic) -{ - struct snd_gus_card *gus = private_data; - - if (wave->format & IWFFFF_WAVE_ROM) - return 0; /* it's probably ok - verify the address? */ - return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory); -} - -/* - * - */ - -int snd_gus_gf1_put_sample(void *private_data, struct gf1_wave *wave, - char __user *data, long len, int atomic) -{ - struct snd_gus_card *gus = private_data; - struct snd_gf1_mem_block *block; - int err; - - if (wave->format & GF1_WAVE_STEREO) - return -EINVAL; /* not supported */ - block = snd_gf1_mem_alloc(&gus->gf1.mem_alloc, - SNDRV_GF1_MEM_OWNER_WAVE_GF1, - NULL, wave->size, - wave->format & GF1_WAVE_16BIT, 1, - wave->share_id); - if (block == NULL) - return -ENOMEM; - err = snd_gus_dram_write(gus, data, - block->ptr, wave->size); - if (err < 0) { - snd_gf1_mem_lock(&gus->gf1.mem_alloc, 0); - snd_gf1_mem_xfree(&gus->gf1.mem_alloc, block); - snd_gf1_mem_lock(&gus->gf1.mem_alloc, 1); - return err; - } - wave->address.memory = block->ptr; - return 0; -} - -int snd_gus_gf1_get_sample(void *private_data, struct gf1_wave *wave, - char __user *data, long len, int atomic) -{ - struct snd_gus_card *gus = private_data; - - return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, 0); -} - -int snd_gus_gf1_remove_sample(void *private_data, struct gf1_wave *wave, - int atomic) -{ - struct snd_gus_card *gus = private_data; - - return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory); -} - -/* - * - */ - -int snd_gus_simple_put_sample(void *private_data, struct simple_instrument *instr, - char __user *data, long len, int atomic) -{ - struct snd_gus_card *gus = private_data; - struct snd_gf1_mem_block *block; - int err; - - if (instr->format & SIMPLE_WAVE_STEREO) - return -EINVAL; /* not supported */ - block = snd_gf1_mem_alloc(&gus->gf1.mem_alloc, - SNDRV_GF1_MEM_OWNER_WAVE_SIMPLE, - NULL, instr->size, - instr->format & SIMPLE_WAVE_16BIT, 1, - instr->share_id); - if (block == NULL) - return -ENOMEM; - err = snd_gus_dram_write(gus, data, block->ptr, instr->size); - if (err < 0) { - snd_gf1_mem_lock(&gus->gf1.mem_alloc, 0); - snd_gf1_mem_xfree(&gus->gf1.mem_alloc, block); - snd_gf1_mem_lock(&gus->gf1.mem_alloc, 1); - return err; - } - instr->address.memory = block->ptr; - return 0; -} - -int snd_gus_simple_get_sample(void *private_data, struct simple_instrument *instr, - char __user *data, long len, int atomic) -{ - struct snd_gus_card *gus = private_data; - - return snd_gus_dram_read(gus, data, instr->address.memory, instr->size, 0); -} - -int snd_gus_simple_remove_sample(void *private_data, struct simple_instrument *instr, - int atomic) -{ - struct snd_gus_card *gus = private_data; - - return snd_gf1_mem_free(&gus->gf1.mem_alloc, instr->address.memory); -} -- cgit From 270384ccfc2ba3849b9d02f7a37c395987c30ed2 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 26 Dec 2014 14:27:58 +0100 Subject: ALSA: atmel: fix building the ac97 driver for at91-multiplatform at91 will no longer export the mach/cpu.h and mach/hardware.h header files in the future, which would break building the atmel ac97c driver. Since the cpu_is_* check is only used to find out whether we are running on avr32 or arm/at91, we can hardcode that check in the ARM case. Signed-off-by: Arnd Bergmann Link: http://www.spinics.net/lists/arm-kernel/msg382068.html Signed-off-by: Alexandre Belloni Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 4f6b14d704f3..5e6a1db70948 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -34,10 +34,10 @@ #include #include +#ifdef CONFIG_AVR32 #include - -#ifdef CONFIG_ARCH_AT91 -#include +#else +#define cpu_is_at32ap7000() 0 #endif #include "ac97c.h" -- cgit From 7c27ba46792d3596a83f28243e235a92cba80d45 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 29 Dec 2014 23:52:35 -0200 Subject: ASoC: fsl_spdif: Use dev_name() for registering the irq The 'name' array is currently stored inside the fsl_spdif_priv private structure only for registering the interrupt name. This can be simplified by registering it with dev_name() instead. Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_spdif.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index af0429421fc8..73da1f0f8786 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -90,7 +90,6 @@ struct spdif_mixer_control { * @sysclk: system clock for rx clock rate measurement * @dma_params_tx: DMA parameters for transmit channel * @dma_params_rx: DMA parameters for receive channel - * @name: driver name */ struct fsl_spdif_priv { struct spdif_mixer_control fsl_spdif_control; @@ -109,12 +108,8 @@ struct fsl_spdif_priv { struct clk *sysclk; struct snd_dmaengine_dai_dma_data dma_params_tx; struct snd_dmaengine_dai_dma_data dma_params_rx; - - /* The name space will be allocated dynamically */ - char name[0]; }; - /* DPLL locked and lock loss interrupt handler */ static void spdif_irq_dpll_lock(struct fsl_spdif_priv *spdif_priv) { @@ -1169,19 +1164,15 @@ static int fsl_spdif_probe(struct platform_device *pdev) if (!np) return -ENODEV; - spdif_priv = devm_kzalloc(&pdev->dev, - sizeof(struct fsl_spdif_priv) + strlen(np->name) + 1, - GFP_KERNEL); + spdif_priv = devm_kzalloc(&pdev->dev, sizeof(*spdif_priv), GFP_KERNEL); if (!spdif_priv) return -ENOMEM; - strcpy(spdif_priv->name, np->name); - spdif_priv->pdev = pdev; /* Initialize this copy of the CPU DAI driver structure */ memcpy(&spdif_priv->cpu_dai_drv, &fsl_spdif_dai, sizeof(fsl_spdif_dai)); - spdif_priv->cpu_dai_drv.name = spdif_priv->name; + spdif_priv->cpu_dai_drv.name = dev_name(&pdev->dev); /* Get the addresses and IRQ */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1203,7 +1194,7 @@ static int fsl_spdif_probe(struct platform_device *pdev) } ret = devm_request_irq(&pdev->dev, irq, spdif_isr, 0, - spdif_priv->name, spdif_priv); + dev_name(&pdev->dev), spdif_priv); if (ret) { dev_err(&pdev->dev, "could not claim irq %u\n", irq); return ret; -- cgit From 888c819d0feb9975216978c797ca7f8dfd48ed08 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 29 Dec 2014 23:52:36 -0200 Subject: ASoC: fsl_asrc: Use dev_name() for registering the irq The 'name' array is currently stored inside the fsl_asrc private structure only for registering the interrupt name. This can be simplified by registering it with dev_name() instead. Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc.c | 3 +-- sound/soc/fsl/fsl_asrc.h | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 026a80117540..5326ca7529cd 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -818,7 +818,6 @@ static int fsl_asrc_probe(struct platform_device *pdev) return -ENOMEM; asrc_priv->pdev = pdev; - strncpy(asrc_priv->name, np->name, sizeof(asrc_priv->name) - 1); /* Get the addresses and IRQ */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -842,7 +841,7 @@ static int fsl_asrc_probe(struct platform_device *pdev) } ret = devm_request_irq(&pdev->dev, irq, fsl_asrc_isr, 0, - asrc_priv->name, asrc_priv); + dev_name(&pdev->dev), asrc_priv); if (ret) { dev_err(&pdev->dev, "failed to claim irq %u: %d\n", irq, ret); return ret; diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h index a3f211f53c23..4aed63c4b431 100644 --- a/sound/soc/fsl/fsl_asrc.h +++ b/sound/soc/fsl/fsl_asrc.h @@ -433,7 +433,6 @@ struct fsl_asrc_pair { * @channel_avail: non-occupied channel numbers * @asrc_rate: default sample rate for ASoC Back-Ends * @asrc_width: default sample width for ASoC Back-Ends - * @name: driver name */ struct fsl_asrc { struct snd_dmaengine_dai_dma_data dma_params_rx; @@ -452,8 +451,6 @@ struct fsl_asrc { int asrc_rate; int asrc_width; - - char name[32]; }; extern struct snd_soc_platform_driver fsl_asrc_platform; -- cgit From 19f52fae5adb7f2fd5b75251f9bd761f43a36476 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 29 Dec 2014 18:43:36 +0100 Subject: ALSA: Fix handling of multiple msbits constraints on the same runtime If the sound card is made up of discrete components, each with their own driver (e.g. like in the ASoC case), we might end up with multiple msbits constraint rules installed. Currently this will result in msbits being set to whatever the last rule set it to. This patch updates the behavior of the rule to choose the minimum (other than zero) of all the installed rules. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/core/pcm_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index ec9e7866177f..b0c153534a29 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1300,7 +1300,7 @@ static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params, unsigned int msbits = l >> 16; struct snd_interval *i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); if (snd_interval_single(i) && snd_interval_value(i) == width) - params->msbits = msbits; + params->msbits = min_not_zero(params->msbits, msbits); return 0; } -- cgit From 8ef9df55a72425e269575fa74cbbedec4672bdc4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 29 Dec 2014 18:43:37 +0100 Subject: ALSA: Add support for wildcard msbits constraints Currently the msbits constraints requires to specify a specific sample format width for which the constraint should be applied. But often the number of most significant bits is not sample format specific, but rather a absolute limit. E.g. the PCM interface might accept 32-bit and 24-bit samples, but the DAC has a 16-bit resolution and throws away the LSBs. In this case for both 32-bit and 24-bit format msbits should be set to 16. This patch extends snd_pcm_hw_constraint_msbits() so that a wildcard constraint can be setup that is applied for all formats with a sample width larger than the specified msbits. Choosing the wildcard constraint is done by setting the sample width parameter of the function to 0. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/core/pcm_lib.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index b0c153534a29..db05e04d0070 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1299,8 +1299,14 @@ static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params, int width = l & 0xffff; unsigned int msbits = l >> 16; struct snd_interval *i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); - if (snd_interval_single(i) && snd_interval_value(i) == width) + + if (!snd_interval_single(i)) + return 0; + + if ((snd_interval_value(i) == width) || + (width == 0 && snd_interval_value(i) > msbits)) params->msbits = min_not_zero(params->msbits, msbits); + return 0; } @@ -1311,6 +1317,11 @@ static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params, * @width: sample bits width * @msbits: msbits width * + * This constraint will set the number of most significant bits (msbits) if a + * sample format with the specified width has been select. If width is set to 0 + * the msbits will be set for any sample format with a width larger than the + * specified msbits. + * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, -- cgit From 0e2a37513a1fafa0b9829e992633a80861c3b4b5 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 29 Dec 2014 18:43:38 +0100 Subject: ASoC: pcm: Use wildcard msbits constraints Use the new wildcard msbits constraints instead of installing a constraint for each available sample format width. Signed-off-by: Lars-Peter Clausen Acked-by: Mark Brown Signed-off-by: Takashi Iwai --- sound/soc/soc-pcm.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index eb87d96e2cf0..d62d6a5340a8 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -301,15 +301,6 @@ static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream) return symmetry; } -/* - * List of sample sizes that might go over the bus for parameter - * application. There ought to be a wildcard sample size for things - * like the DAC/ADC resolution to use but there isn't right now. - */ -static int sample_sizes[] = { - 24, 32, -}; - static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -318,17 +309,10 @@ static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits) if (!bits) return; - for (i = 0; i < ARRAY_SIZE(sample_sizes); i++) { - if (bits >= sample_sizes[i]) - continue; - - ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0, - sample_sizes[i], bits); - if (ret != 0) - dev_warn(rtd->dev, - "ASoC: Failed to set MSB %d/%d: %d\n", - bits, sample_sizes[i], ret); - } + ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 0, bits); + if (ret != 0) + dev_warn(rtd->dev, "ASoC: Failed to set MSB %d: %d\n", + bits, ret); } static void soc_pcm_apply_msb(struct snd_pcm_substream *substream) -- cgit From f6dbe1bee59741cd7699e7da3019e67c77d9bd6f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 29 Dec 2014 19:41:45 +0100 Subject: ALSA: snd_pcm_oss_period_size: Use round{up,down}_pow_of_two() Instead of opencoding them use the standard roundup_pow_of_two() and rounddown_pow_of_two() helper functions. This gets rids one of the few users of the custom ld2() function and also makes it a bit more obvious what the code does. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/core/oss/pcm_oss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index ada69d7a8d70..80423a4ccab6 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -719,7 +719,7 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream, oss_buffer_size = snd_pcm_plug_client_size(substream, snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, NULL)) * oss_frame_size; - oss_buffer_size = 1 << ld2(oss_buffer_size); + oss_buffer_size = rounddown_pow_of_two(oss_buffer_size); if (atomic_read(&substream->mmap_count)) { if (oss_buffer_size > runtime->oss.mmap_bytes) oss_buffer_size = runtime->oss.mmap_bytes; @@ -755,14 +755,14 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream, min_period_size = snd_pcm_plug_client_size(substream, snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL)); min_period_size *= oss_frame_size; - min_period_size = 1 << (ld2(min_period_size - 1) + 1); + min_period_size = roundup_pow_of_two(min_period_size); if (oss_period_size < min_period_size) oss_period_size = min_period_size; max_period_size = snd_pcm_plug_client_size(substream, snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL)); max_period_size *= oss_frame_size; - max_period_size = 1 << ld2(max_period_size); + max_period_size = rounddown_pow_of_two(max_period_size); if (oss_period_size > max_period_size) oss_period_size = max_period_size; -- cgit From 5a1b8a80daa15e5b1920735133b80dd46975765f Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 30 Dec 2014 16:10:32 +0200 Subject: ASoC: davinci-mcasp: Support for combined tx/rx interrupt line Some SoC, like da850/OMAP-L138 uses one common interrupt request for TX/RX events. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'sound') diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 30b94d4f9c5d..95eef582331b 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -364,6 +364,20 @@ static irqreturn_t davinci_mcasp_rx_irq_handler(int irq, void *data) return IRQ_RETVAL(handled_mask); } +static irqreturn_t davinci_mcasp_common_irq_handler(int irq, void *data) +{ + struct davinci_mcasp *mcasp = (struct davinci_mcasp *)data; + irqreturn_t ret = IRQ_NONE; + + if (mcasp->substreams[SNDRV_PCM_STREAM_PLAYBACK]) + ret = davinci_mcasp_tx_irq_handler(irq, data); + + if (mcasp->substreams[SNDRV_PCM_STREAM_CAPTURE]) + ret |= davinci_mcasp_rx_irq_handler(irq, data); + + return ret; +} + static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { @@ -1441,6 +1455,22 @@ static int davinci_mcasp_probe(struct platform_device *pdev) mcasp->dev = &pdev->dev; + irq = platform_get_irq_byname(pdev, "common"); + if (irq >= 0) { + irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_common\n", + dev_name(&pdev->dev)); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + davinci_mcasp_common_irq_handler, + IRQF_ONESHOT, irq_name, mcasp); + if (ret) { + dev_err(&pdev->dev, "common IRQ request failed\n"); + goto err; + } + + mcasp->irq_request[SNDRV_PCM_STREAM_PLAYBACK] = XUNDRN; + mcasp->irq_request[SNDRV_PCM_STREAM_CAPTURE] = ROVRN; + } + irq = platform_get_irq_byname(pdev, "rx"); if (irq >= 0) { irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_rx\n", -- cgit From 5396ecf7b1920595deec83b902502bd3d2da184e Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 30 Dec 2014 12:11:36 -0200 Subject: ASoC: mxs-saif: Do not store the irq number in the private structure The irq number is only used inside the probe function, so there is really no need to store it in the private structure. Use a local 'irq' variable to hold the the irq number instead. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/mxs/mxs-saif.c | 10 +++++----- sound/soc/mxs/mxs-saif.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index d9865082160c..c866ade28ad0 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -710,7 +710,7 @@ static int mxs_saif_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct resource *iores; struct mxs_saif *saif; - int ret = 0; + int irq, ret = 0; struct device_node *master; if (!np) @@ -763,16 +763,16 @@ static int mxs_saif_probe(struct platform_device *pdev) if (IS_ERR(saif->base)) return PTR_ERR(saif->base); - saif->irq = platform_get_irq(pdev, 0); - if (saif->irq < 0) { - ret = saif->irq; + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + ret = irq; dev_err(&pdev->dev, "failed to get irq resource: %d\n", ret); return ret; } saif->dev = &pdev->dev; - ret = devm_request_irq(&pdev->dev, saif->irq, mxs_saif_irq, 0, + ret = devm_request_irq(&pdev->dev, irq, mxs_saif_irq, 0, dev_name(&pdev->dev), saif); if (ret) { dev_err(&pdev->dev, "failed to request irq\n"); diff --git a/sound/soc/mxs/mxs-saif.h b/sound/soc/mxs/mxs-saif.h index fbaf7badfdfb..9a4c0b291b9e 100644 --- a/sound/soc/mxs/mxs-saif.h +++ b/sound/soc/mxs/mxs-saif.h @@ -116,7 +116,6 @@ struct mxs_saif { unsigned int mclk; unsigned int mclk_in_use; void __iomem *base; - int irq; unsigned int id; unsigned int master_id; unsigned int cur_rate; -- cgit From a56257c657eab392d579e6be70e2f8430eef1aa3 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 30 Dec 2014 10:55:43 +0000 Subject: ASoC: dwc: Switch to managed clock resource Simplify error handling during probe by using managed clock resources. Signed-off-by: Andrew Jackson Signed-off-by: Mark Brown --- sound/soc/dwc/designware_i2s.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index 23a7c13b914f..10219b5be436 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c @@ -396,13 +396,13 @@ static int dw_i2s_probe(struct platform_device *pdev) dev->capability = pdata->cap; dev->i2s_clk_cfg = pdata->i2s_clk_cfg; - dev->clk = clk_get(&pdev->dev, NULL); + dev->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(dev->clk)) return PTR_ERR(dev->clk); ret = clk_enable(dev->clk); if (ret < 0) - goto err_clk_put; + return ret; dev_set_drvdata(&pdev->dev, dev); ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, @@ -416,19 +416,13 @@ static int dw_i2s_probe(struct platform_device *pdev) err_clk_disable: clk_disable(dev->clk); -err_clk_put: - clk_put(dev->clk); return ret; } static int dw_i2s_remove(struct platform_device *pdev) { - struct dw_i2s_dev *dev = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - clk_put(dev->clk); - return 0; } -- cgit From b226efe5818bf01cecc8a3e0fbd0def4ebbcedaa Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 30 Dec 2014 10:55:45 +0000 Subject: ASoC: dwc: Read I2S block configuration from registers The I2S block provides component parameter registers which describe how the block is instantiated. Use these registers to extract the block's configuration rather than relying on platform data. Signed-off-by: Andrew Jackson Signed-off-by: Mark Brown --- sound/soc/dwc/designware_i2s.c | 96 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index 10219b5be436..d3bdc6890eb5 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c @@ -54,6 +54,31 @@ #define I2S_COMP_VERSION 0x01F8 #define I2S_COMP_TYPE 0x01FC +/* + * Component parameter register fields - define the I2S block's + * configuration. + */ +#define COMP1_TX_WORDSIZE_3(r) (((r) & GENMASK(27, 25)) >> 25) +#define COMP1_TX_WORDSIZE_2(r) (((r) & GENMASK(24, 22)) >> 22) +#define COMP1_TX_WORDSIZE_1(r) (((r) & GENMASK(21, 19)) >> 19) +#define COMP1_TX_WORDSIZE_0(r) (((r) & GENMASK(18, 16)) >> 16) +#define COMP1_TX_CHANNELS(r) (((r) & GENMASK(10, 9)) >> 9) +#define COMP1_RX_CHANNELS(r) (((r) & GENMASK(8, 7)) >> 7) +#define COMP1_RX_ENABLED(r) (((r) & BIT(6)) >> 6) +#define COMP1_TX_ENABLED(r) (((r) & BIT(5)) >> 5) +#define COMP1_MODE_EN(r) (((r) & BIT(4)) >> 4) +#define COMP1_FIFO_DEPTH_GLOBAL(r) (((r) & GENMASK(3, 2)) >> 2) +#define COMP1_APB_DATA_WIDTH(r) (((r) & GENMASK(1, 0)) >> 0) + +#define COMP2_RX_WORDSIZE_3(r) (((r) & GENMASK(12, 10)) >> 10) +#define COMP2_RX_WORDSIZE_2(r) (((r) & GENMASK(9, 7)) >> 7) +#define COMP2_RX_WORDSIZE_1(r) (((r) & GENMASK(5, 3)) >> 3) +#define COMP2_RX_WORDSIZE_0(r) (((r) & GENMASK(2, 0)) >> 0) + +/* Number of entries in WORDSIZE and DATA_WIDTH parameter registers */ +#define COMP_MAX_WORDSIZE (1 << 3) +#define COMP_MAX_DATA_WIDTH (1 << 2) + #define MAX_CHANNEL_NUM 8 #define MIN_CHANNEL_NUM 2 @@ -324,11 +349,50 @@ static int dw_i2s_resume(struct snd_soc_dai *dai) #define dw_i2s_resume NULL #endif -static void dw_configure_dai_by_pd(struct dw_i2s_dev *dev, +/* + * The following tables allow a direct lookup of various parameters + * defined in the I2S block's configuration in terms of sound system + * parameters. Each table is sized to the number of entries possible + * according to the number of configuration bits describing an I2S + * block parameter. + */ + +/* Width of (DMA) bus */ +static const u32 bus_widths[COMP_MAX_DATA_WIDTH] = { + DMA_SLAVE_BUSWIDTH_1_BYTE, + DMA_SLAVE_BUSWIDTH_2_BYTES, + DMA_SLAVE_BUSWIDTH_4_BYTES, + DMA_SLAVE_BUSWIDTH_UNDEFINED +}; + +/* PCM format to support channel resolution */ +static const u32 formats[COMP_MAX_WORDSIZE] = { + SNDRV_PCM_FMTBIT_S16_LE, + SNDRV_PCM_FMTBIT_S16_LE, + SNDRV_PCM_FMTBIT_S24_LE, + SNDRV_PCM_FMTBIT_S24_LE, + SNDRV_PCM_FMTBIT_S32_LE, + 0, + 0, + 0 +}; + +static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev, struct snd_soc_dai_driver *dw_i2s_dai, struct resource *res, const struct i2s_platform_data *pdata) { + /* + * Read component parameter registers to extract + * the I2S block's configuration. + */ + u32 comp1 = i2s_read_reg(dev->i2s_base, I2S_COMP_PARAM_1); + u32 comp2 = i2s_read_reg(dev->i2s_base, I2S_COMP_PARAM_2); + u32 idx = COMP1_APB_DATA_WIDTH(comp1); + + if (WARN_ON(idx >= ARRAY_SIZE(bus_widths))) + return -EINVAL; + /* Set DMA slaves info */ dev->play_dma_data.data = pdata->play_dma_data; @@ -337,26 +401,36 @@ static void dw_configure_dai_by_pd(struct dw_i2s_dev *dev, dev->capture_dma_data.addr = res->start + I2S_RXDMA; dev->play_dma_data.max_burst = 16; dev->capture_dma_data.max_burst = 16; - dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; - dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; + dev->play_dma_data.addr_width = bus_widths[idx]; + dev->capture_dma_data.addr_width = bus_widths[idx]; dev->play_dma_data.filter = pdata->filter; dev->capture_dma_data.filter = pdata->filter; - if (pdata->cap & DWC_I2S_PLAY) { + if (COMP1_TX_ENABLED(comp1)) { dev_dbg(dev->dev, " designware: play supported\n"); + idx = COMP1_TX_WORDSIZE_0(comp1); + if (WARN_ON(idx >= ARRAY_SIZE(formats))) + return -EINVAL; dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM; - dw_i2s_dai->playback.channels_max = pdata->channel; - dw_i2s_dai->playback.formats = pdata->snd_fmts; + dw_i2s_dai->playback.channels_max = + 1 << (COMP1_TX_CHANNELS(comp1) + 1); + dw_i2s_dai->playback.formats = formats[idx]; dw_i2s_dai->playback.rates = pdata->snd_rates; } - if (pdata->cap & DWC_I2S_RECORD) { + if (COMP1_RX_ENABLED(comp1)) { dev_dbg(dev->dev, "designware: record supported\n"); + idx = COMP2_RX_WORDSIZE_0(comp2); + if (WARN_ON(idx >= ARRAY_SIZE(formats))) + return -EINVAL; dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM; - dw_i2s_dai->capture.channels_max = pdata->channel; - dw_i2s_dai->capture.formats = pdata->snd_fmts; + dw_i2s_dai->capture.channels_max = + 1 << (COMP1_RX_CHANNELS(comp1) + 1); + dw_i2s_dai->capture.formats = formats[idx]; dw_i2s_dai->capture.rates = pdata->snd_rates; } + + return 0; } static int dw_i2s_probe(struct platform_device *pdev) @@ -392,7 +466,9 @@ static int dw_i2s_probe(struct platform_device *pdev) return PTR_ERR(dev->i2s_base); dev->dev = &pdev->dev; - dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata); + ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata); + if (ret < 0) + return ret; dev->capability = pdata->cap; dev->i2s_clk_cfg = pdata->i2s_clk_cfg; -- cgit From 3a19272a507cd5ad214e0082c3ff7355dfe71329 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 30 Dec 2014 10:55:44 +0000 Subject: ASoC: dwc: Prepare clock before use Some I2S clocks may require some time to get the clock ready for operation and so need to be prepared before they are enabled. So, prepare the clock as well as enabling it, but combine the two through clk_prepare_enable. Signed-off-by: Andrew Jackson Signed-off-by: Mark Brown --- sound/soc/dwc/designware_i2s.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index d3bdc6890eb5..a6327cc086c0 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c @@ -476,7 +476,7 @@ static int dw_i2s_probe(struct platform_device *pdev) if (IS_ERR(dev->clk)) return PTR_ERR(dev->clk); - ret = clk_enable(dev->clk); + ret = clk_prepare_enable(dev->clk); if (ret < 0) return ret; @@ -491,13 +491,16 @@ static int dw_i2s_probe(struct platform_device *pdev) return 0; err_clk_disable: - clk_disable(dev->clk); + clk_disable_unprepare(dev->clk); return ret; } static int dw_i2s_remove(struct platform_device *pdev) { + struct dw_i2s_dev *dev = dev_get_drvdata(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); + clk_disable_unprepare(dev->clk); return 0; } -- cgit From 758c2debcbf1a4ba6a787d276ca0fb3333105b06 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 30 Dec 2014 10:55:46 +0000 Subject: ASoC: dwc: Register components with managed interface Register SOC component using managed interface to simplify error handling and future introduction of device tree. Signed-off-by: Andrew Jackson Signed-off-by: Mark Brown --- sound/soc/dwc/designware_i2s.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index a6327cc086c0..1b9b18b79047 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c @@ -481,7 +481,7 @@ static int dw_i2s_probe(struct platform_device *pdev) return ret; dev_set_drvdata(&pdev->dev, dev); - ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, + ret = devm_snd_soc_register_component(&pdev->dev, &dw_i2s_component, dw_i2s_dai, 1); if (ret != 0) { dev_err(&pdev->dev, "not able to register dai\n"); @@ -499,7 +499,6 @@ static int dw_i2s_remove(struct platform_device *pdev) { struct dw_i2s_dev *dev = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); clk_disable_unprepare(dev->clk); return 0; -- cgit From 0d274544bfee721b22b484a10b1480e237c0e258 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 30 Dec 2014 10:55:48 +0000 Subject: ASoC: dwc: Add devicetree support for Designware I2S Allow the driver to be configured through a device tree rather than platform data. Signed-off-by: Andrew Jackson Signed-off-by: Mark Brown --- sound/soc/dwc/Kconfig | 1 + sound/soc/dwc/designware_i2s.c | 193 ++++++++++++++++++++++++++++++++--------- 2 files changed, 151 insertions(+), 43 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/Kconfig b/sound/soc/dwc/Kconfig index e334900cf0b8..d50e08517dce 100644 --- a/sound/soc/dwc/Kconfig +++ b/sound/soc/dwc/Kconfig @@ -1,6 +1,7 @@ config SND_DESIGNWARE_I2S tristate "Synopsys I2S Device Driver" depends on CLKDEV_LOOKUP + select SND_SOC_GENERIC_DMAENGINE_PCM help Say Y or M if you want to add support for I2S driver for Synopsys desigwnware I2S device. The device supports upto diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index 1b9b18b79047..adefdf0e01f1 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c @@ -22,6 +22,7 @@ #include #include #include +#include /* common register for all channel */ #define IER 0x000 @@ -82,6 +83,11 @@ #define MAX_CHANNEL_NUM 8 #define MIN_CHANNEL_NUM 2 +union dw_i2s_snd_dma_data { + struct i2s_dma_data pd; + struct snd_dmaengine_dai_dma_data dt; +}; + struct dw_i2s_dev { void __iomem *i2s_base; struct clk *clk; @@ -90,8 +96,8 @@ struct dw_i2s_dev { struct device *dev; /* data related to DMA transfers b/w i2s and DMAC */ - struct i2s_dma_data play_dma_data; - struct i2s_dma_data capture_dma_data; + union dw_i2s_snd_dma_data play_dma_data; + union dw_i2s_snd_dma_data capture_dma_data; struct i2s_clk_config_data config; int (*i2s_clk_cfg)(struct i2s_clk_config_data *config); }; @@ -178,7 +184,7 @@ static int dw_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); - struct i2s_dma_data *dma_data = NULL; + union dw_i2s_snd_dma_data *dma_data = NULL; if (!(dev->capability & DWC_I2S_RECORD) && (substream->stream == SNDRV_PCM_STREAM_CAPTURE)) @@ -270,13 +276,21 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream, config->sample_rate = params_rate(params); - if (!dev->i2s_clk_cfg) - return -EINVAL; + if (dev->i2s_clk_cfg) { + ret = dev->i2s_clk_cfg(config); + if (ret < 0) { + dev_err(dev->dev, "runtime audio clk config fail\n"); + return ret; + } + } else { + u32 bitclk = config->sample_rate * config->data_width * 2; - ret = dev->i2s_clk_cfg(config); - if (ret < 0) { - dev_err(dev->dev, "runtime audio clk config fail\n"); - return ret; + ret = clk_set_rate(dev->clk, bitclk); + if (ret) { + dev_err(dev->dev, "Can't set I2S clock rate: %d\n", + ret); + return ret; + } } return 0; @@ -357,6 +371,11 @@ static int dw_i2s_resume(struct snd_soc_dai *dai) * block parameter. */ +/* Maximum bit resolution of a channel - not uniformly spaced */ +static const u32 fifo_width[COMP_MAX_WORDSIZE] = { + 12, 16, 20, 24, 32, 0, 0, 0 +}; + /* Width of (DMA) bus */ static const u32 bus_widths[COMP_MAX_DATA_WIDTH] = { DMA_SLAVE_BUSWIDTH_1_BYTE, @@ -377,10 +396,9 @@ static const u32 formats[COMP_MAX_WORDSIZE] = { 0 }; -static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev, +static int dw_configure_dai(struct dw_i2s_dev *dev, struct snd_soc_dai_driver *dw_i2s_dai, - struct resource *res, - const struct i2s_platform_data *pdata) + unsigned int rates) { /* * Read component parameter registers to extract @@ -388,23 +406,7 @@ static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev, */ u32 comp1 = i2s_read_reg(dev->i2s_base, I2S_COMP_PARAM_1); u32 comp2 = i2s_read_reg(dev->i2s_base, I2S_COMP_PARAM_2); - u32 idx = COMP1_APB_DATA_WIDTH(comp1); - - if (WARN_ON(idx >= ARRAY_SIZE(bus_widths))) - return -EINVAL; - - /* Set DMA slaves info */ - - dev->play_dma_data.data = pdata->play_dma_data; - dev->capture_dma_data.data = pdata->capture_dma_data; - dev->play_dma_data.addr = res->start + I2S_TXDMA; - dev->capture_dma_data.addr = res->start + I2S_RXDMA; - dev->play_dma_data.max_burst = 16; - dev->capture_dma_data.max_burst = 16; - dev->play_dma_data.addr_width = bus_widths[idx]; - dev->capture_dma_data.addr_width = bus_widths[idx]; - dev->play_dma_data.filter = pdata->filter; - dev->capture_dma_data.filter = pdata->filter; + u32 idx; if (COMP1_TX_ENABLED(comp1)) { dev_dbg(dev->dev, " designware: play supported\n"); @@ -415,7 +417,7 @@ static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev, dw_i2s_dai->playback.channels_max = 1 << (COMP1_TX_CHANNELS(comp1) + 1); dw_i2s_dai->playback.formats = formats[idx]; - dw_i2s_dai->playback.rates = pdata->snd_rates; + dw_i2s_dai->playback.rates = rates; } if (COMP1_RX_ENABLED(comp1)) { @@ -427,10 +429,86 @@ static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev, dw_i2s_dai->capture.channels_max = 1 << (COMP1_RX_CHANNELS(comp1) + 1); dw_i2s_dai->capture.formats = formats[idx]; - dw_i2s_dai->capture.rates = pdata->snd_rates; + dw_i2s_dai->capture.rates = rates; + } + + return 0; +} + +static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev, + struct snd_soc_dai_driver *dw_i2s_dai, + struct resource *res, + const struct i2s_platform_data *pdata) +{ + u32 comp1 = i2s_read_reg(dev->i2s_base, I2S_COMP_PARAM_1); + u32 idx = COMP1_APB_DATA_WIDTH(comp1); + int ret; + + if (WARN_ON(idx >= ARRAY_SIZE(bus_widths))) + return -EINVAL; + + ret = dw_configure_dai(dev, dw_i2s_dai, pdata->snd_rates); + if (ret < 0) + return ret; + + /* Set DMA slaves info */ + dev->play_dma_data.pd.data = pdata->play_dma_data; + dev->capture_dma_data.pd.data = pdata->capture_dma_data; + dev->play_dma_data.pd.addr = res->start + I2S_TXDMA; + dev->capture_dma_data.pd.addr = res->start + I2S_RXDMA; + dev->play_dma_data.pd.max_burst = 16; + dev->capture_dma_data.pd.max_burst = 16; + dev->play_dma_data.pd.addr_width = bus_widths[idx]; + dev->capture_dma_data.pd.addr_width = bus_widths[idx]; + dev->play_dma_data.pd.filter = pdata->filter; + dev->capture_dma_data.pd.filter = pdata->filter; + + return 0; +} + +static int dw_configure_dai_by_dt(struct dw_i2s_dev *dev, + struct snd_soc_dai_driver *dw_i2s_dai, + struct resource *res) +{ + u32 comp1 = i2s_read_reg(dev->i2s_base, I2S_COMP_PARAM_1); + u32 comp2 = i2s_read_reg(dev->i2s_base, I2S_COMP_PARAM_2); + u32 fifo_depth = 1 << (1 + COMP1_FIFO_DEPTH_GLOBAL(comp1)); + u32 idx = COMP1_APB_DATA_WIDTH(comp1); + u32 idx2; + int ret; + + if (WARN_ON(idx >= ARRAY_SIZE(bus_widths))) + return -EINVAL; + + ret = dw_configure_dai(dev, dw_i2s_dai, SNDRV_PCM_RATE_8000_192000); + if (ret < 0) + return ret; + + if (COMP1_TX_ENABLED(comp1)) { + idx2 = COMP1_TX_WORDSIZE_0(comp1); + + dev->capability |= DWC_I2S_PLAY; + dev->play_dma_data.dt.addr = res->start + I2S_TXDMA; + dev->play_dma_data.dt.addr_width = bus_widths[idx]; + dev->play_dma_data.dt.chan_name = "TX"; + dev->play_dma_data.dt.fifo_size = fifo_depth * + (fifo_width[idx2]) >> 8; + dev->play_dma_data.dt.maxburst = 16; + } + if (COMP1_RX_ENABLED(comp1)) { + idx2 = COMP2_RX_WORDSIZE_0(comp2); + + dev->capability |= DWC_I2S_RECORD; + dev->capture_dma_data.dt.addr = res->start + I2S_RXDMA; + dev->capture_dma_data.dt.addr_width = bus_widths[idx]; + dev->capture_dma_data.dt.chan_name = "RX"; + dev->capture_dma_data.dt.fifo_size = fifo_depth * + (fifo_width[idx2] >> 8); + dev->capture_dma_data.dt.maxburst = 16; } return 0; + } static int dw_i2s_probe(struct platform_device *pdev) @@ -441,11 +519,6 @@ static int dw_i2s_probe(struct platform_device *pdev) int ret; struct snd_soc_dai_driver *dw_i2s_dai; - if (!pdata) { - dev_err(&pdev->dev, "Invalid platform data\n"); - return -EINVAL; - } - dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) { dev_warn(&pdev->dev, "kzalloc fail\n"); @@ -466,15 +539,28 @@ static int dw_i2s_probe(struct platform_device *pdev) return PTR_ERR(dev->i2s_base); dev->dev = &pdev->dev; - ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata); - if (ret < 0) - return ret; + if (pdata) { + ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata); + if (ret < 0) + return ret; + + dev->capability = pdata->cap; + dev->i2s_clk_cfg = pdata->i2s_clk_cfg; + if (!dev->i2s_clk_cfg) { + dev_err(&pdev->dev, "no clock configure method\n"); + return -ENODEV; + } + + dev->clk = devm_clk_get(&pdev->dev, NULL); + } else { + ret = dw_configure_dai_by_dt(dev, dw_i2s_dai, res); + if (ret < 0) + return ret; - dev->capability = pdata->cap; - dev->i2s_clk_cfg = pdata->i2s_clk_cfg; - dev->clk = devm_clk_get(&pdev->dev, NULL); + dev->clk = devm_clk_get(&pdev->dev, "i2sclk"); + } if (IS_ERR(dev->clk)) - return PTR_ERR(dev->clk); + return PTR_ERR(dev->clk); ret = clk_prepare_enable(dev->clk); if (ret < 0) @@ -488,6 +574,15 @@ static int dw_i2s_probe(struct platform_device *pdev) goto err_clk_disable; } + if (!pdata) { + ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); + if (ret) { + dev_err(&pdev->dev, + "Could not register PCM: %d\n", ret); + goto err_clk_disable; + } + } + return 0; err_clk_disable: @@ -504,11 +599,23 @@ static int dw_i2s_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id dw_i2s_of_match[] = { + { .compatible = "snps,designware-i2s", }, + {}, +}; + +MODULE_DEVICE_TABLE(of, dw_i2s_of_match); +#endif + static struct platform_driver dw_i2s_driver = { .probe = dw_i2s_probe, .remove = dw_i2s_remove, .driver = { .name = "designware-i2s", +#ifdef CONFIG_OF + .of_match_table = of_match_ptr(dw_i2s_of_match), +#endif }, }; -- cgit From 0d02e1292715d00674a49626146e3a854b504cb1 Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Wed, 31 Dec 2014 23:48:32 +1300 Subject: ALSA: asihpi: fix an information leak in asihpi_hpi_ioctl() Add missing limits to keep copied data within allocated buffer. Reported-by: Dan Carpenter Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpi6000.c | 7 +++++-- sound/pci/asihpi/hpioctl.c | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c index 2414d7a2239d..2d6364825d4d 100644 --- a/sound/pci/asihpi/hpi6000.c +++ b/sound/pci/asihpi/hpi6000.c @@ -47,7 +47,7 @@ /* operational/messaging errors */ #define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901 - +#define HPI6000_ERROR_RESP_GET_LEN 902 #define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903 #define HPI6000_ERROR_MSG_GET_ADR 904 #define HPI6000_ERROR_RESP_GET_ADR 905 @@ -1365,7 +1365,10 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, length = hpi_read_word(pdo, HPI_HIF_ADDR(length)); } while (hpi6000_check_PCI2040_error_flag(pao, H6READ) && --timeout); if (!timeout) - length = sizeof(struct hpi_response); + return HPI6000_ERROR_RESP_GET_LEN; + + if (length > phr->size) + return HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; /* get the response */ p_data = (u32 *)phr; diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index 6aa677e60555..72af66bdf714 100644 --- a/sound/pci/asihpi/hpioctl.c +++ b/sound/pci/asihpi/hpioctl.c @@ -153,6 +153,8 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) goto out; } + res_max_size = min_t(size_t, res_max_size, sizeof(*hr)); + switch (hm->h.function) { case HPI_SUBSYS_CREATE_ADAPTER: case HPI_ADAPTER_DELETE: -- cgit From 48d882978eb0a15547093b4542a82b5c22548041 Mon Sep 17 00:00:00 2001 From: Libin Yang Date: Wed, 31 Dec 2014 22:09:54 +0800 Subject: ALSA: pcm: add SNDRV_PCM_TRIGGER_DRAIN trigger Add SNDRV_PCM_TRIGGER_DRAIN trigger for pcm drain. Some audio devices require notification of drain events in order to properly drain and shutdown an audio stream. Signed-off-by: Libin Yang Signed-off-by: Takashi Iwai --- sound/core/pcm_native.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 095d9572ad2b..ff3abc3b4ff5 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -420,7 +420,8 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream, hw = &substream->runtime->hw; if (!params->info) { - params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES; + params->info = hw->info & ~(SNDRV_PCM_INFO_FIFO_IN_FRAMES | + SNDRV_PCM_INFO_DRAIN_TRIGGER); if (!hw_support_mmap(substream)) params->info &= ~(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID); @@ -1566,6 +1567,13 @@ static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) snd_pcm_post_stop(substream, new_state); } } + + if (runtime->status->state == SNDRV_PCM_STATE_DRAINING && + runtime->trigger_master == substream && + (runtime->hw.info & SNDRV_PCM_INFO_DRAIN_TRIGGER)) + return substream->ops->trigger(substream, + SNDRV_PCM_TRIGGER_DRAIN); + return 0; } -- cgit From c6068d3a7b408554a832181b98091ee5a00d8b85 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 31 Dec 2014 17:10:34 +0100 Subject: ASoC: pcm: Fix unused variable warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sound/soc/soc-pcm.c: In function ‘soc_pcm_set_msb’: sound/soc/soc-pcm.c:307:11: warning: unused variable ‘i’ [-Wunused-variable] Fixes: 0e2a37513a1f ('ASoC: pcm: Use wildcard msbits constraints') Signed-off-by: Takashi Iwai --- sound/soc/soc-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index d62d6a5340a8..c076993a20d0 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -304,7 +304,7 @@ static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream) static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - int ret, i; + int ret; if (!bits) return; -- cgit From e9dd86267f2571a9649399c9e268266ca5aa6152 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:35 +0100 Subject: ALSA: ml403-ac97cr: Remove always NULL parameter snd_ml403_ac97cr_pcm() takes a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/drivers/ml403-ac97cr.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index bcca825a1c8d..ec01de1cb23b 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -1238,14 +1238,11 @@ snd_ml403_ac97cr_mixer(struct snd_ml403_ac97cr *ml403_ac97cr) } static int -snd_ml403_ac97cr_pcm(struct snd_ml403_ac97cr *ml403_ac97cr, int device, - struct snd_pcm **rpcm) +snd_ml403_ac97cr_pcm(struct snd_ml403_ac97cr *ml403_ac97cr, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(ml403_ac97cr->card, "ML403AC97CR/1", device, 1, 1, &pcm); if (err < 0) @@ -1263,8 +1260,6 @@ snd_ml403_ac97cr_pcm(struct snd_ml403_ac97cr *ml403_ac97cr, int device, snd_dma_continuous_data(GFP_KERNEL), 64 * 1024, 128 * 1024); - if (rpcm) - *rpcm = pcm; return 0; } @@ -1298,7 +1293,7 @@ static int snd_ml403_ac97cr_probe(struct platform_device *pfdev) return err; } PDEBUG(INIT_INFO, "probe(): mixer done\n"); - err = snd_ml403_ac97cr_pcm(ml403_ac97cr, 0, NULL); + err = snd_ml403_ac97cr_pcm(ml403_ac97cr, 0); if (err < 0) { snd_card_free(card); return err; -- cgit From 7f605418837add961466dc66f7370332d44c1a92 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:36 +0100 Subject: ALSA: ad1816a: Remove always NULL parameters snd_ad1816a_pcm() and snd_ad1816a_timer() take a pointer to a pointer of a PCM/timer where if this parameter is provided the newly allocated object is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a.c | 5 ++--- sound/isa/ad1816a/ad1816a_lib.c | 9 ++------- 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index f481a41e027e..769226515f0d 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -142,7 +142,6 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard, struct snd_card *card; struct snd_ad1816a *chip; struct snd_opl3 *opl3; - struct snd_timer *timer; error = snd_card_new(&pcard->card->dev, index[dev], id[dev], THIS_MODULE, @@ -172,7 +171,7 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard, sprintf(card->longname, "%s, SS at 0x%lx, irq %d, dma %d&%d", card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]); - if ((error = snd_ad1816a_pcm(chip, 0, NULL)) < 0) { + if ((error = snd_ad1816a_pcm(chip, 0)) < 0) { snd_card_free(card); return error; } @@ -182,7 +181,7 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard, return error; } - error = snd_ad1816a_timer(chip, 0, &timer); + error = snd_ad1816a_timer(chip, 0); if (error < 0) { snd_card_free(card); return error; diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 01a07986f4a3..5f99102cc0c1 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -675,7 +675,7 @@ static struct snd_pcm_ops snd_ad1816a_capture_ops = { .pointer = snd_ad1816a_capture_pointer, }; -int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm) +int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device) { int error; struct snd_pcm *pcm; @@ -697,13 +697,10 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm) 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); chip->pcm = pcm; - if (rpcm) - *rpcm = pcm; return 0; } -int snd_ad1816a_timer(struct snd_ad1816a *chip, int device, - struct snd_timer **rtimer) +int snd_ad1816a_timer(struct snd_ad1816a *chip, int device) { struct snd_timer *timer; struct snd_timer_id tid; @@ -720,8 +717,6 @@ int snd_ad1816a_timer(struct snd_ad1816a *chip, int device, timer->private_data = chip; chip->timer = timer; timer->hw = snd_ad1816a_timer_table; - if (rtimer) - *rtimer = timer; return 0; } -- cgit From 4b8ab88518726197c8659bc9aca96c6af01dab57 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:37 +0100 Subject: ALSA: es1688: Remove almost always NULL parameter snd_es1688_pcm() takes a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. This PCM is also available from the pcm field of the snd_es1688 struct that got passed to the same function. This patch updates all callers which passed a pointer to use that field instead and then removes the parameter from the function. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688.c | 7 +++---- sound/isa/es1688/es1688_lib.c | 6 +----- sound/isa/gus/gusextreme.c | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 76001fe0579d..1901c2bb6c3b 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -138,10 +138,9 @@ static int snd_es1688_probe(struct snd_card *card, unsigned int n) { struct snd_es1688 *chip = card->private_data; struct snd_opl3 *opl3; - struct snd_pcm *pcm; int error; - error = snd_es1688_pcm(card, chip, 0, &pcm); + error = snd_es1688_pcm(card, chip, 0); if (error < 0) return error; @@ -150,9 +149,9 @@ static int snd_es1688_probe(struct snd_card *card, unsigned int n) return error; strlcpy(card->driver, "ES1688", sizeof(card->driver)); - strlcpy(card->shortname, pcm->name, sizeof(card->shortname)); + strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname)); snprintf(card->longname, sizeof(card->longname), - "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, + "%s at 0x%lx, irq %i, dma %i", chip->pcm->name, chip->port, chip->irq, chip->dma8); if (fm_port[n] == SNDRV_AUTO_PORT) diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index b5450143407b..52aac8467178 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -728,8 +728,7 @@ static struct snd_pcm_ops snd_es1688_capture_ops = { .pointer = snd_es1688_capture_pointer, }; -int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, - int device, struct snd_pcm **rpcm) +int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device) { struct snd_pcm *pcm; int err; @@ -749,9 +748,6 @@ int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), 64*1024, 64*1024); - - if (rpcm) - *rpcm = pcm; return 0; } diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 28a16936a397..acc655284a9c 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -284,7 +284,7 @@ static int snd_gusextreme_probe(struct device *dev, unsigned int n) } gus->codec_flag = 1; - error = snd_es1688_pcm(card, es1688, 0, NULL); + error = snd_es1688_pcm(card, es1688, 0); if (error < 0) goto out; -- cgit From 1a2515ac94bbb1c409dea2e4a7b011592569b239 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:38 +0100 Subject: ALSA: es18xx: Remove always NULL parameter snd_es18xx_pcm() takes a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/isa/es18xx.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index b481bb8c31bc..6cc2d2bbde6a 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1687,16 +1687,13 @@ static struct snd_pcm_ops snd_es18xx_capture_ops = { .pointer = snd_es18xx_capture_pointer, }; -static int snd_es18xx_pcm(struct snd_card *card, int device, - struct snd_pcm **rpcm) +static int snd_es18xx_pcm(struct snd_card *card, int device) { struct snd_es18xx *chip = card->private_data; struct snd_pcm *pcm; char str[16]; int err; - if (rpcm) - *rpcm = NULL; sprintf(str, "ES%x", chip->version); if (chip->caps & ES18XX_PCM2) err = snd_pcm_new(card, str, device, 2, 1, &pcm); @@ -1722,9 +1719,6 @@ static int snd_es18xx_pcm(struct snd_card *card, int device, snd_dma_isa_data(), 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); - - if (rpcm) - *rpcm = pcm; return 0; } @@ -2154,7 +2148,7 @@ static int snd_audiodrive_probe(struct snd_card *card, int dev) chip->port, irq[dev], dma1[dev]); - err = snd_es18xx_pcm(card, 0, NULL); + err = snd_es18xx_pcm(card, 0); if (err < 0) return err; -- cgit From db5abb3c499e553a8afedee1417d6a6308dda7bd Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:39 +0100 Subject: ALSA: gus: Remove always NULL parameters snd_gf1_pcm_new() and snd_gf1_rawmidi_new() take a pointer to a pointer of a PCM/MIDI where if this parameter is provided the newly allocated object is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/isa/gus/gus_pcm.c | 6 +----- sound/isa/gus/gus_uart.c | 6 +----- sound/isa/gus/gusclassic.c | 4 ++-- sound/isa/gus/gusextreme.c | 2 +- sound/isa/gus/gusmax.c | 4 ++-- sound/isa/gus/interwave.c | 4 ++-- 6 files changed, 9 insertions(+), 17 deletions(-) (limited to 'sound') diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 2dcf45bf7293..25f6788ccef3 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -849,7 +849,7 @@ static struct snd_pcm_ops snd_gf1_pcm_capture_ops = { .pointer = snd_gf1_pcm_capture_pointer, }; -int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm) +int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index) { struct snd_card *card; struct snd_kcontrol *kctl; @@ -857,8 +857,6 @@ int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, s struct snd_pcm_substream *substream; int capture, err; - if (rpcm) - *rpcm = NULL; card = gus->card; capture = !gus->interwave && !gus->ess_flag && !gus->ace_flag ? 1 : 0; err = snd_pcm_new(card, @@ -903,8 +901,6 @@ int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, s return err; kctl->id.index = control_index; - if (rpcm) - *rpcm = pcm; return 0; } diff --git a/sound/isa/gus/gus_uart.c b/sound/isa/gus/gus_uart.c index 21cc42e4c4be..3992912743f5 100644 --- a/sound/isa/gus/gus_uart.c +++ b/sound/isa/gus/gus_uart.c @@ -241,13 +241,11 @@ static struct snd_rawmidi_ops snd_gf1_uart_input = .trigger = snd_gf1_uart_input_trigger, }; -int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi ** rrawmidi) +int snd_gf1_rawmidi_new(struct snd_gus_card *gus, int device) { struct snd_rawmidi *rmidi; int err; - if (rrawmidi) - *rrawmidi = NULL; if ((err = snd_rawmidi_new(gus->card, "GF1", device, 1, 1, &rmidi)) < 0) return err; strcpy(rmidi->name, gus->interwave ? "AMD InterWave" : "GF1"); @@ -256,7 +254,5 @@ int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmid rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; rmidi->private_data = gus; gus->midi_uart = rmidi; - if (rrawmidi) - *rrawmidi = rmidi; return err; } diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 7ce29ffa1af9..f0019715d82e 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -181,12 +181,12 @@ static int snd_gusclassic_probe(struct device *dev, unsigned int n) if (error < 0) goto out; - error = snd_gf1_pcm_new(gus, 0, 0, NULL); + error = snd_gf1_pcm_new(gus, 0, 0); if (error < 0) goto out; if (!gus->ace_flag) { - error = snd_gf1_rawmidi_new(gus, 0, NULL); + error = snd_gf1_rawmidi_new(gus, 0); if (error < 0) goto out; } diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index acc655284a9c..693d95f46804 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -295,7 +295,7 @@ static int snd_gusextreme_probe(struct device *dev, unsigned int n) snd_component_add(card, "ES1688"); if (pcm_channels[n] > 0) { - error = snd_gf1_pcm_new(gus, 1, 1, NULL); + error = snd_gf1_pcm_new(gus, 1, 1); if (error < 0) goto out; } diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 39df36ca3acb..b2b3734a8e72 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -322,14 +322,14 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) goto _err; if (pcm_channels[dev] > 0) { - if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) + if ((err = snd_gf1_pcm_new(gus, 1, 1)) < 0) goto _err; } err = snd_gusmax_mixer(wss); if (err < 0) goto _err; - err = snd_gf1_rawmidi_new(gus, 0, NULL); + err = snd_gf1_rawmidi_new(gus, 0); if (err < 0) goto _err; diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index ad55e5cb8e94..8ea54a7f78d2 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -711,7 +711,7 @@ static int snd_interwave_probe(struct snd_card *card, int dev) return err; if (pcm_channels[dev] > 0) { - err = snd_gf1_pcm_new(gus, 1, 1, NULL); + err = snd_gf1_pcm_new(gus, 1, 1); if (err < 0) return err; } @@ -740,7 +740,7 @@ static int snd_interwave_probe(struct snd_card *card, int dev) #endif gus->uart_enable = midi[dev]; - if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) + if ((err = snd_gf1_rawmidi_new(gus, 0)) < 0) return err; #ifndef SNDRV_STB -- cgit From f6be4e624aa26699a9a89bc24089e88a227141c1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:40 +0100 Subject: ALSA: msnd: Remove always NULL parameter snd_msnd_pcm() takes a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/isa/msnd/msnd.c | 6 +----- sound/isa/msnd/msnd.h | 2 +- sound/isa/msnd/msnd_pinnacle.c | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/isa/msnd/msnd.c b/sound/isa/msnd/msnd.c index 1cee18fb28a8..835d4aa26761 100644 --- a/sound/isa/msnd/msnd.c +++ b/sound/isa/msnd/msnd.c @@ -679,8 +679,7 @@ static struct snd_pcm_ops snd_msnd_capture_ops = { }; -int snd_msnd_pcm(struct snd_card *card, int device, - struct snd_pcm **rpcm) +int snd_msnd_pcm(struct snd_card *card, int device) { struct snd_msnd *chip = card->private_data; struct snd_pcm *pcm; @@ -696,9 +695,6 @@ int snd_msnd_pcm(struct snd_card *card, int device, pcm->private_data = chip; strcpy(pcm->name, "Hurricane"); - - if (rpcm) - *rpcm = pcm; return 0; } EXPORT_SYMBOL(snd_msnd_pcm); diff --git a/sound/isa/msnd/msnd.h b/sound/isa/msnd/msnd.h index dbac3a42347b..5f3c7dcd9f9d 100644 --- a/sound/isa/msnd/msnd.h +++ b/sound/isa/msnd/msnd.h @@ -297,7 +297,7 @@ int snd_msnd_disable_irq(struct snd_msnd *chip); void snd_msnd_dsp_halt(struct snd_msnd *chip, struct file *file); int snd_msnd_DAPQ(struct snd_msnd *chip, int start); int snd_msnd_DARQ(struct snd_msnd *chip, int start); -int snd_msnd_pcm(struct snd_card *card, int device, struct snd_pcm **rpcm); +int snd_msnd_pcm(struct snd_card *card, int device); int snd_msndmidi_new(struct snd_card *card, int device); void snd_msndmidi_input_read(void *mpu); diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c index 5016bf957f51..65b36825d194 100644 --- a/sound/isa/msnd/msnd_pinnacle.c +++ b/sound/isa/msnd/msnd_pinnacle.c @@ -582,7 +582,7 @@ static int snd_msnd_attach(struct snd_card *card) if (err < 0) goto err_release_region; - err = snd_msnd_pcm(card, 0, NULL); + err = snd_msnd_pcm(card, 0); if (err < 0) { printk(KERN_ERR LOGNAME ": error creating new PCM device\n"); goto err_release_region; -- cgit From 8c77629996cbabee1d5b6d9b0d1e97cbca197ba1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:41 +0100 Subject: ALSA: sb8: Remove always NULL parameters snd_sb8dsp_pcm() and snd_sb8dsp_midi() take a pointer to a pointer of a PCM/MIDI where if this parameter is provided the newly allocated object is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/isa/sb/jazz16.c | 2 +- sound/isa/sb/sb8.c | 4 ++-- sound/isa/sb/sb8_main.c | 6 +----- sound/isa/sb/sb8_midi.c | 6 +----- 4 files changed, 5 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/isa/sb/jazz16.c b/sound/isa/sb/jazz16.c index 90d2eba549e9..6b4884d052a5 100644 --- a/sound/isa/sb/jazz16.c +++ b/sound/isa/sb/jazz16.c @@ -297,7 +297,7 @@ static int snd_jazz16_probe(struct device *devptr, unsigned int dev) "Media Vision Jazz16 at 0x%lx, irq %d, dma8 %d, dma16 %d", port[dev], xirq, xdma8, xdma16); - err = snd_sb8dsp_pcm(chip, 0, NULL); + err = snd_sb8dsp_pcm(chip, 0); if (err < 0) goto err_free; err = snd_sbmixer_new(chip); diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 6c32b3aa34af..b8e2391c33ff 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -157,7 +157,7 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev) goto _err; } - if ((err = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) + if ((err = snd_sb8dsp_pcm(chip, 0)) < 0) goto _err; if ((err = snd_sbmixer_new(chip)) < 0) @@ -182,7 +182,7 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev) goto _err; } - if ((err = snd_sb8dsp_midi(chip, 0, NULL)) < 0) + if ((err = snd_sb8dsp_midi(chip, 0)) < 0) goto _err; strcpy(card->driver, chip->hardware == SB_HW_PRO ? "SB Pro" : "SB8"); diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 24d4121ab0e0..d4d8b0e604ee 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -594,15 +594,13 @@ static struct snd_pcm_ops snd_sb8_capture_ops = { .pointer = snd_sb8_capture_pointer, }; -int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) +int snd_sb8dsp_pcm(struct snd_sb *chip, int device) { struct snd_card *card = chip->card; struct snd_pcm *pcm; int err; size_t max_prealloc = 64 * 1024; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(card, "SB8 DSP", device, 1, 1, &pcm)) < 0) return err; sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff); @@ -618,8 +616,6 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) snd_dma_isa_data(), 64*1024, max_prealloc); - if (rpcm) - *rpcm = pcm; return 0; } diff --git a/sound/isa/sb/sb8_midi.c b/sound/isa/sb/sb8_midi.c index 988a8b73475f..ffc71f0267df 100644 --- a/sound/isa/sb/sb8_midi.c +++ b/sound/isa/sb/sb8_midi.c @@ -263,13 +263,11 @@ static struct snd_rawmidi_ops snd_sb8dsp_midi_input = .trigger = snd_sb8dsp_midi_input_trigger, }; -int snd_sb8dsp_midi(struct snd_sb *chip, int device, struct snd_rawmidi ** rrawmidi) +int snd_sb8dsp_midi(struct snd_sb *chip, int device) { struct snd_rawmidi *rmidi; int err; - if (rrawmidi) - *rrawmidi = NULL; if ((err = snd_rawmidi_new(chip->card, "SB8 MIDI", device, 1, 1, &rmidi)) < 0) return err; strcpy(rmidi->name, "SB8 MIDI"); @@ -280,7 +278,5 @@ int snd_sb8dsp_midi(struct snd_sb *chip, int device, struct snd_rawmidi ** rrawm rmidi->info_flags |= SNDRV_RAWMIDI_INFO_DUPLEX; rmidi->private_data = chip; chip->rmidi = rmidi; - if (rrawmidi) - *rrawmidi = rmidi; return 0; } -- cgit From 92533f188862fbefe357ada4e4af67b8e730e680 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:42 +0100 Subject: ASoC: sb16: Simplify snd_sb16dsp_pcm() All callers of snd_sb16dsp_pcm() always pass the pcm field of the first parameter as the last parameter. Simplify the function by moving this inside the function itself. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/isa/als100.c | 2 +- sound/isa/sb/sb16.c | 2 +- sound/isa/sb/sb16_main.c | 8 ++------ sound/pci/cs5530.c | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/isa/als100.c b/sound/isa/als100.c index 32d01525211d..bc9ea306ee02 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -233,7 +233,7 @@ static int snd_card_als100_probe(int dev, irq[dev], dma8[dev], dma16[dev]); } - if ((error = snd_sb16dsp_pcm(chip, 0, &chip->pcm)) < 0) { + if ((error = snd_sb16dsp_pcm(chip, 0)) < 0) { snd_card_free(card); return error; } diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 3f694543a7ea..4a7d7c89808f 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -374,7 +374,7 @@ static int snd_sb16_probe(struct snd_card *card, int dev) if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0) return err; - if ((err = snd_sb16dsp_pcm(chip, 0, &chip->pcm)) < 0) + if ((err = snd_sb16dsp_pcm(chip, 0)) < 0) return err; strcpy(card->driver, diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 72b10f4f3e70..63d11b7b9fe8 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -860,19 +860,18 @@ static struct snd_pcm_ops snd_sb16_capture_ops = { .pointer = snd_sb16_capture_pointer, }; -int snd_sb16dsp_pcm(struct snd_sb * chip, int device, struct snd_pcm ** rpcm) +int snd_sb16dsp_pcm(struct snd_sb *chip, int device) { struct snd_card *card = chip->card; struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(card, "SB16 DSP", device, 1, 1, &pcm)) < 0) return err; sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff); pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; pcm->private_data = chip; + chip->pcm = pcm; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops); @@ -885,9 +884,6 @@ int snd_sb16dsp_pcm(struct snd_sb * chip, int device, struct snd_pcm ** rpcm) snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), 64*1024, 128*1024); - - if (rpcm) - *rpcm = pcm; return 0; } diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c index b1025507a467..0a8cf94c4858 100644 --- a/sound/pci/cs5530.c +++ b/sound/pci/cs5530.c @@ -223,7 +223,7 @@ static int snd_cs5530_create(struct snd_card *card, return err; } - err = snd_sb16dsp_pcm(chip->sb, 0, &chip->sb->pcm); + err = snd_sb16dsp_pcm(chip->sb, 0); if (err < 0) { dev_err(card->dev, "Could not create PCM\n"); snd_cs5530_free(chip); -- cgit From fa60c065694a81e534c61809ab7dd419366e9335 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:43 +0100 Subject: ALSA: wss: Remove (almost) always NULL parameters Most callers of snd_wss_pcm(), snd_wss_timer() and snd_cs4236_pcm() pass NULL as the last parameter, some callers pass a pointer but never use it after the function has been called and only a few callers pass a pointer and actually use it. The later is only the case for snd_wss_pcm() for snd_cs4236_pcm() and it is possible to get the same PCM object by accessing the pcm field of the snd_wss struct that was passed as the first parameter. This function removes the last parameters from the functions mentioned above and updates the callers which used it to use chip->pcm instead. This allows us to slightly simplify the functions since they don't have to check and set the last parameter anymore which makes the code slightly shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/isa/ad1848/ad1848.c | 7 +++---- sound/isa/azt2320.c | 4 ++-- sound/isa/cmi8328.c | 4 ++-- sound/isa/cs423x/cs4231.c | 9 ++++----- sound/isa/cs423x/cs4236.c | 13 ++++++------- sound/isa/cs423x/cs4236_lib.c | 9 +++------ sound/isa/galaxy/galaxy.c | 4 ++-- sound/isa/gus/gusmax.c | 4 ++-- sound/isa/gus/interwave.c | 10 +++++----- sound/isa/opl3sa2.c | 4 ++-- sound/isa/opti9xx/miro.c | 12 +++++------- sound/isa/opti9xx/opti92x-ad1848.c | 13 +++++-------- sound/isa/sc6000.c | 2 +- sound/isa/sscape.c | 5 ++--- sound/isa/wavefront/wavefront.c | 4 ++-- sound/isa/wss/wss_lib.c | 8 ++------ 16 files changed, 48 insertions(+), 64 deletions(-) (limited to 'sound') diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 093f22a464d7..f159da4ec890 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -88,7 +88,6 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n) { struct snd_card *card; struct snd_wss *chip; - struct snd_pcm *pcm; int error; error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); @@ -103,7 +102,7 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n) card->private_data = chip; - error = snd_wss_pcm(chip, 0, &pcm); + error = snd_wss_pcm(chip, 0); if (error < 0) goto out; @@ -112,10 +111,10 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n) goto out; strcpy(card->driver, "AD1848"); - strcpy(card->shortname, pcm->name); + strcpy(card->shortname, chip->pcm->name); sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", - pcm->name, chip->port, irq[n], dma1[n]); + chip->pcm->name, chip->port, irq[n], dma1[n]); if (thinkpad[n]) strcat(card->longname, " [Thinkpad]"); diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c index 0ea75fc62072..b8e768e5ce80 100644 --- a/sound/isa/azt2320.c +++ b/sound/isa/azt2320.c @@ -215,7 +215,7 @@ static int snd_card_azt2320_probe(int dev, sprintf(card->longname, "%s, WSS at 0x%lx, irq %i, dma %i&%i", card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]); - error = snd_wss_pcm(chip, 0, NULL); + error = snd_wss_pcm(chip, 0); if (error < 0) { snd_card_free(card); return error; @@ -225,7 +225,7 @@ static int snd_card_azt2320_probe(int dev, snd_card_free(card); return error; } - error = snd_wss_timer(chip, 0, NULL); + error = snd_wss_timer(chip, 0); if (error < 0) { snd_card_free(card); return error; diff --git a/sound/isa/cmi8328.c b/sound/isa/cmi8328.c index 4778852a1201..2c89d95da674 100644 --- a/sound/isa/cmi8328.c +++ b/sound/isa/cmi8328.c @@ -307,7 +307,7 @@ static int snd_cmi8328_probe(struct device *pdev, unsigned int ndev) if (err < 0) goto error; - err = snd_wss_pcm(cmi->wss, 0, NULL); + err = snd_wss_pcm(cmi->wss, 0); if (err < 0) goto error; @@ -318,7 +318,7 @@ static int snd_cmi8328_probe(struct device *pdev, unsigned int ndev) if (err < 0) goto error; - if (snd_wss_timer(cmi->wss, 0, NULL) < 0) + if (snd_wss_timer(cmi->wss, 0) < 0) snd_printk(KERN_WARNING "error initializing WSS timer\n"); if (mpuport[ndev] == SNDRV_AUTO_PORT) { diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index 7dba07a4343a..282cd75d2235 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -92,7 +92,6 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n) { struct snd_card *card; struct snd_wss *chip; - struct snd_pcm *pcm; int error; error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); @@ -106,15 +105,15 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n) card->private_data = chip; - error = snd_wss_pcm(chip, 0, &pcm); + error = snd_wss_pcm(chip, 0); if (error < 0) goto out; strcpy(card->driver, "CS4231"); - strcpy(card->shortname, pcm->name); + strcpy(card->shortname, chip->pcm->name); sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", - pcm->name, chip->port, irq[n], dma1[n]); + chip->pcm->name, chip->port, irq[n], dma1[n]); if (dma2[n] >= 0) sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]); @@ -122,7 +121,7 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n) if (error < 0) goto out; - error = snd_wss_timer(chip, 0, NULL); + error = snd_wss_timer(chip, 0); if (error < 0) goto out; diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 750f51c904fc..9d7582c90a95 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -382,7 +382,6 @@ static int snd_cs423x_card_new(struct device *pdev, int dev, static int snd_cs423x_probe(struct snd_card *card, int dev) { struct snd_card_cs4236 *acard; - struct snd_pcm *pcm; struct snd_wss *chip; struct snd_opl3 *opl3; int err; @@ -404,7 +403,7 @@ static int snd_cs423x_probe(struct snd_card *card, int dev) acard->chip = chip; if (chip->hardware & WSS_HW_CS4236B_MASK) { - err = snd_cs4236_pcm(chip, 0, &pcm); + err = snd_cs4236_pcm(chip, 0); if (err < 0) return err; @@ -412,7 +411,7 @@ static int snd_cs423x_probe(struct snd_card *card, int dev) if (err < 0) return err; } else { - err = snd_wss_pcm(chip, 0, &pcm); + err = snd_wss_pcm(chip, 0); if (err < 0) return err; @@ -420,17 +419,17 @@ static int snd_cs423x_probe(struct snd_card *card, int dev) if (err < 0) return err; } - strcpy(card->driver, pcm->name); - strcpy(card->shortname, pcm->name); + strcpy(card->driver, chip->pcm->name); + strcpy(card->shortname, chip->pcm->name); sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", - pcm->name, + chip->pcm->name, chip->port, irq[dev], dma1[dev]); if (dma2[dev] >= 0) sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); - err = snd_wss_timer(chip, 0, NULL); + err = snd_wss_timer(chip, 0); if (err < 0) return err; diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index c5adca300632..add7ffc072c5 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c @@ -376,17 +376,14 @@ int snd_cs4236_create(struct snd_card *card, return 0; } -int snd_cs4236_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm) +int snd_cs4236_pcm(struct snd_wss *chip, int device) { - struct snd_pcm *pcm; int err; - err = snd_wss_pcm(chip, device, &pcm); + err = snd_wss_pcm(chip, device); if (err < 0) return err; - pcm->info_flags &= ~SNDRV_PCM_INFO_JOINT_DUPLEX; - if (rpcm) - *rpcm = pcm; + chip->pcm->info_flags &= ~SNDRV_PCM_INFO_JOINT_DUPLEX; return 0; } diff --git a/sound/isa/galaxy/galaxy.c b/sound/isa/galaxy/galaxy.c index 1eb2b1ec0fd9..32278847884f 100644 --- a/sound/isa/galaxy/galaxy.c +++ b/sound/isa/galaxy/galaxy.c @@ -569,7 +569,7 @@ static int snd_galaxy_probe(struct device *dev, unsigned int n) if (err < 0) goto error; - err = snd_wss_pcm(chip, 0, NULL); + err = snd_wss_pcm(chip, 0); if (err < 0) goto error; @@ -577,7 +577,7 @@ static int snd_galaxy_probe(struct device *dev, unsigned int n) if (err < 0) goto error; - err = snd_wss_timer(chip, 0, NULL); + err = snd_wss_timer(chip, 0); if (err < 0) goto error; diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index b2b3734a8e72..8216e8d8f017 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -309,7 +309,7 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) if (err < 0) goto _err; - err = snd_wss_pcm(wss, 0, NULL); + err = snd_wss_pcm(wss, 0); if (err < 0) goto _err; @@ -317,7 +317,7 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) if (err < 0) goto _err; - err = snd_wss_timer(wss, 2, NULL); + err = snd_wss_timer(wss, 2); if (err < 0) goto _err; diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 8ea54a7f78d2..70d0040484c8 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -647,7 +647,6 @@ static int snd_interwave_probe(struct snd_card *card, int dev) #ifdef SNDRV_STB struct snd_i2c_bus *i2c_bus; #endif - struct snd_pcm *pcm; char *str; int err; @@ -695,14 +694,15 @@ static int snd_interwave_probe(struct snd_card *card, int dev) if (err < 0) return err; - err = snd_wss_pcm(wss, 0, &pcm); + err = snd_wss_pcm(wss, 0); if (err < 0) return err; - sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); - strcat(pcm->name, " (codec)"); + sprintf(wss->pcm->name + strlen(wss->pcm->name), " rev %c", + gus->revision + 'A'); + strcat(wss->pcm->name, " (codec)"); - err = snd_wss_timer(wss, 2, NULL); + err = snd_wss_timer(wss, 2); if (err < 0) return err; diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index a219bc37816b..d7aff527da88 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -684,7 +684,7 @@ static int snd_opl3sa2_probe(struct snd_card *card, int dev) return err; } chip->wss = wss; - err = snd_wss_pcm(wss, 0, NULL); + err = snd_wss_pcm(wss, 0); if (err < 0) return err; err = snd_wss_mixer(wss); @@ -693,7 +693,7 @@ static int snd_opl3sa2_probe(struct snd_card *card, int dev) err = snd_opl3sa2_mixer(card); if (err < 0) return err; - err = snd_wss_timer(wss, 0, NULL); + err = snd_wss_timer(wss, 0); if (err < 0) return err; if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) { diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index c2ca681ac51b..546452888aed 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -1270,8 +1270,6 @@ static int snd_miro_probe(struct snd_card *card) int error; struct snd_miro *miro = card->private_data; struct snd_wss *codec; - struct snd_timer *timer; - struct snd_pcm *pcm; struct snd_rawmidi *rmidi; if (!miro->res_mc_base) { @@ -1310,7 +1308,7 @@ static int snd_miro_probe(struct snd_card *card) if (error < 0) return error; - error = snd_wss_pcm(codec, 0, &pcm); + error = snd_wss_pcm(codec, 0); if (error < 0) return error; @@ -1318,11 +1316,11 @@ static int snd_miro_probe(struct snd_card *card) if (error < 0) return error; - error = snd_wss_timer(codec, 0, &timer); + error = snd_wss_timer(codec, 0); if (error < 0) return error; - miro->pcm = pcm; + miro->pcm = codec->pcm; error = snd_miro_mixer(card, miro); if (error < 0) @@ -1356,8 +1354,8 @@ static int snd_miro_probe(struct snd_card *card) strcpy(card->driver, "miro"); sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, miro->name, pcm->name, miro->wss_base + 4, - miro->irq, miro->dma1, miro->dma2); + card->shortname, miro->name, codec->pcm->name, + miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2); if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) rmidi = NULL; diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index c9b582848603..840831f1dd4e 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -820,10 +820,6 @@ static int snd_opti9xx_probe(struct snd_card *card) int xdma2; struct snd_opti9xx *chip = card->private_data; struct snd_wss *codec; -#ifdef CS4231 - struct snd_timer *timer; -#endif - struct snd_pcm *pcm; struct snd_rawmidi *rmidi; struct snd_hwdep *synth; @@ -855,7 +851,7 @@ static int snd_opti9xx_probe(struct snd_card *card) if (error < 0) return error; chip->codec = codec; - error = snd_wss_pcm(codec, 0, &pcm); + error = snd_wss_pcm(codec, 0); if (error < 0) return error; error = snd_wss_mixer(codec); @@ -867,7 +863,7 @@ static int snd_opti9xx_probe(struct snd_card *card) return error; #endif #ifdef CS4231 - error = snd_wss_timer(codec, 0, &timer); + error = snd_wss_timer(codec, 0); if (error < 0) return error; #endif @@ -884,11 +880,12 @@ static int snd_opti9xx_probe(struct snd_card *card) sprintf(card->shortname, "OPTi %s", card->driver); #if defined(CS4231) || defined(OPTi93X) sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, pcm->name, + card->shortname, codec->pcm->name, chip->wss_base + 4, irq, dma1, xdma2); #else sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", - card->shortname, pcm->name, chip->wss_base + 4, irq, dma1); + card->shortname, codec->pcm->name, chip->wss_base + 4, irq, + dma1); #endif /* CS4231 || OPTi93X */ if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) diff --git a/sound/isa/sc6000.c b/sound/isa/sc6000.c index 15a152eaa2e8..51cfa7615f72 100644 --- a/sound/isa/sc6000.c +++ b/sound/isa/sc6000.c @@ -625,7 +625,7 @@ static int snd_sc6000_probe(struct device *devptr, unsigned int dev) if (err < 0) goto err_unmap2; - err = snd_wss_pcm(chip, 0, NULL); + err = snd_wss_pcm(chip, 0); if (err < 0) { snd_printk(KERN_ERR PFX "error creating new WSS PCM device\n"); diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 44405df7d4be..018ab140c2be 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -877,7 +877,6 @@ static int create_ad1845(struct snd_card *card, unsigned port, codec_type, WSS_HWSHARE_DMA1, &chip); if (!err) { unsigned long flags; - struct snd_pcm *pcm; if (sscape->type != SSCAPE_VIVO) { /* @@ -893,7 +892,7 @@ static int create_ad1845(struct snd_card *card, unsigned port, } - err = snd_wss_pcm(chip, 0, &pcm); + err = snd_wss_pcm(chip, 0); if (err < 0) { snd_printk(KERN_ERR "sscape: No PCM device " "for AD1845 chip\n"); @@ -907,7 +906,7 @@ static int create_ad1845(struct snd_card *card, unsigned port, goto _error; } if (chip->hardware != WSS_HW_AD1848) { - err = snd_wss_timer(chip, 0, NULL); + err = snd_wss_timer(chip, 0); if (err < 0) { snd_printk(KERN_ERR "sscape: No timer device " "for AD1845 chip\n"); diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index bfbf38cf9841..a0987a57c8a9 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -380,11 +380,11 @@ snd_wavefront_probe (struct snd_card *card, int dev) return err; } - err = snd_wss_pcm(chip, 0, NULL); + err = snd_wss_pcm(chip, 0); if (err < 0) return err; - err = snd_wss_timer(chip, 0, NULL); + err = snd_wss_timer(chip, 0); if (err < 0) return err; diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 347bb1bda110..6530d32901b9 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -1923,7 +1923,7 @@ static struct snd_pcm_ops snd_wss_capture_ops = { .pointer = snd_wss_capture_pointer, }; -int snd_wss_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm) +int snd_wss_pcm(struct snd_wss *chip, int device) { struct snd_pcm *pcm; int err; @@ -1949,8 +1949,6 @@ int snd_wss_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm) 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); chip->pcm = pcm; - if (rpcm) - *rpcm = pcm; return 0; } EXPORT_SYMBOL(snd_wss_pcm); @@ -1961,7 +1959,7 @@ static void snd_wss_timer_free(struct snd_timer *timer) chip->timer = NULL; } -int snd_wss_timer(struct snd_wss *chip, int device, struct snd_timer **rtimer) +int snd_wss_timer(struct snd_wss *chip, int device) { struct snd_timer *timer; struct snd_timer_id tid; @@ -1980,8 +1978,6 @@ int snd_wss_timer(struct snd_wss *chip, int device, struct snd_timer **rtimer) timer->private_free = snd_wss_timer_free; timer->hw = snd_wss_timer_table; chip->timer = timer; - if (rtimer) - *rtimer = timer; return 0; } EXPORT_SYMBOL(snd_wss_timer); -- cgit From a08800940f72bb5502a8b6afb675231cef0b3a62 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:44 +0100 Subject: ASLA: ad1889: Remove always NULL parameter snd_ad1889_pcm_init() takes a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/ad1889.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 1610c38337af..547ee30540a0 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -623,14 +623,11 @@ snd_ad1889_interrupt(int irq, void *dev_id) } static int -snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, struct snd_pcm **rpcm) +snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device) { int err; struct snd_pcm *pcm; - if (rpcm) - *rpcm = NULL; - err = snd_pcm_new(chip->card, chip->card->driver, device, 1, 1, &pcm); if (err < 0) return err; @@ -658,9 +655,6 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, struct snd_pcm **rpcm) return err; } - if (rpcm) - *rpcm = pcm; - return 0; } @@ -1016,7 +1010,7 @@ snd_ad1889_probe(struct pci_dev *pci, if (err < 0) goto free_and_ret; - err = snd_ad1889_pcm_init(chip, 0, NULL); + err = snd_ad1889_pcm_init(chip, 0); if (err < 0) goto free_and_ret; -- cgit From d18132aa15d2bf7a5f227b590175b73aa3591a91 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:45 +0100 Subject: ALSA: asihpi: Remove always NULL parameter snd_asihpi_hpi_new() takes a pointer to a pointer of a hwdep where if this parameter is provided the newly allocated hwdep is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index e9273fb2a505..7a55fefed5c4 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -2832,14 +2832,11 @@ static int snd_asihpi_hpi_ioctl(struct snd_hwdep *hw, struct file *file, /* results in /dev/snd/hwC#D0 file for each card with index # also /proc/asound/hwdep will contain '#-00: asihpi (HPI) for each card' */ -static int snd_asihpi_hpi_new(struct snd_card_asihpi *asihpi, - int device, struct snd_hwdep **rhwdep) +static int snd_asihpi_hpi_new(struct snd_card_asihpi *asihpi, int device) { struct snd_hwdep *hw; int err; - if (rhwdep) - *rhwdep = NULL; err = snd_hwdep_new(asihpi->card, "HPI", device, &hw); if (err < 0) return err; @@ -2849,8 +2846,6 @@ static int snd_asihpi_hpi_new(struct snd_card_asihpi *asihpi, hw->ops.ioctl = snd_asihpi_hpi_ioctl; hw->ops.release = snd_asihpi_hpi_release; hw->private_data = asihpi; - if (rhwdep) - *rhwdep = hw; return 0; } @@ -2993,7 +2988,7 @@ static int snd_asihpi_probe(struct pci_dev *pci_dev, /* always create, can be enabled or disabled dynamically by enable_hwdep module param*/ - snd_asihpi_hpi_new(asihpi, 0, NULL); + snd_asihpi_hpi_new(asihpi, 0); strcpy(card->driver, "ASIHPI"); -- cgit From 3e4f4776f427ddeeba6972f34cca04df478a67b4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:46 +0100 Subject: ALSA: cs4281: Remove always NULL parameters snd_cs4281_pcm() and snd_cs4281_midi() take a pointer to a pointer of a PCM/MIDI object where if this parameter is provided the newly allocated object is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/cs4281.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 4c49b5c8a7b3..05a4337f8116 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -973,14 +973,11 @@ static struct snd_pcm_ops snd_cs4281_capture_ops = { .pointer = snd_cs4281_pointer, }; -static int snd_cs4281_pcm(struct cs4281 *chip, int device, - struct snd_pcm **rpcm) +static int snd_cs4281_pcm(struct cs4281 *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(chip->card, "CS4281", device, 1, 1, &pcm); if (err < 0) return err; @@ -996,8 +993,6 @@ static int snd_cs4281_pcm(struct cs4281 *chip, int device, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 512*1024); - if (rpcm) - *rpcm = pcm; return 0; } @@ -1788,14 +1783,11 @@ static struct snd_rawmidi_ops snd_cs4281_midi_input = .trigger = snd_cs4281_midi_input_trigger, }; -static int snd_cs4281_midi(struct cs4281 *chip, int device, - struct snd_rawmidi **rrawmidi) +static int snd_cs4281_midi(struct cs4281 *chip, int device) { struct snd_rawmidi *rmidi; int err; - if (rrawmidi) - *rrawmidi = NULL; if ((err = snd_rawmidi_new(chip->card, "CS4281", device, 1, 1, &rmidi)) < 0) return err; strcpy(rmidi->name, "CS4281"); @@ -1804,8 +1796,6 @@ static int snd_cs4281_midi(struct cs4281 *chip, int device, rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; rmidi->private_data = chip; chip->rmidi = rmidi; - if (rrawmidi) - *rrawmidi = rmidi; return 0; } @@ -1941,11 +1931,11 @@ static int snd_cs4281_probe(struct pci_dev *pci, snd_card_free(card); return err; } - if ((err = snd_cs4281_pcm(chip, 0, NULL)) < 0) { + if ((err = snd_cs4281_pcm(chip, 0)) < 0) { snd_card_free(card); return err; } - if ((err = snd_cs4281_midi(chip, 0, NULL)) < 0) { + if ((err = snd_cs4281_midi(chip, 0)) < 0) { snd_card_free(card); return err; } -- cgit From 72134c4d9e97bcde376a8746510408da3fe039cc Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:47 +0100 Subject: ALSA: cs46xx: Remove always NULL parameters The various PCM and MIDI allocation functions in this driver take a pointer to a pointer of a PCM/MIDI object where if this parameter is provided the newly allocated object is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/cs46xx/cs46xx.c | 10 +++++----- sound/pci/cs46xx/cs46xx.h | 10 +++++----- sound/pci/cs46xx/cs46xx_lib.c | 40 +++++----------------------------------- 3 files changed, 15 insertions(+), 45 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index 6a6858c07826..655fbea1692c 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c @@ -100,16 +100,16 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci, } card->private_data = chip; chip->accept_valid = mmap_valid[dev]; - if ((err = snd_cs46xx_pcm(chip, 0, NULL)) < 0) { + if ((err = snd_cs46xx_pcm(chip, 0)) < 0) { snd_card_free(card); return err; } #ifdef CONFIG_SND_CS46XX_NEW_DSP - if ((err = snd_cs46xx_pcm_rear(chip,1, NULL)) < 0) { + if ((err = snd_cs46xx_pcm_rear(chip, 1)) < 0) { snd_card_free(card); return err; } - if ((err = snd_cs46xx_pcm_iec958(chip,2,NULL)) < 0) { + if ((err = snd_cs46xx_pcm_iec958(chip, 2)) < 0) { snd_card_free(card); return err; } @@ -120,13 +120,13 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci, } #ifdef CONFIG_SND_CS46XX_NEW_DSP if (chip->nr_ac97_codecs ==2) { - if ((err = snd_cs46xx_pcm_center_lfe(chip,3,NULL)) < 0) { + if ((err = snd_cs46xx_pcm_center_lfe(chip, 3)) < 0) { snd_card_free(card); return err; } } #endif - if ((err = snd_cs46xx_midi(chip, 0, NULL)) < 0) { + if ((err = snd_cs46xx_midi(chip, 0)) < 0) { snd_card_free(card); return err; } diff --git a/sound/pci/cs46xx/cs46xx.h b/sound/pci/cs46xx/cs46xx.h index c49a082c378b..9c9f89a8be5f 100644 --- a/sound/pci/cs46xx/cs46xx.h +++ b/sound/pci/cs46xx/cs46xx.h @@ -1737,12 +1737,12 @@ int snd_cs46xx_create(struct snd_card *card, struct snd_cs46xx **rcodec); extern const struct dev_pm_ops snd_cs46xx_pm; -int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); -int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); -int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); -int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); +int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device); +int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device); +int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device); +int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device); int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device); -int snd_cs46xx_midi(struct snd_cs46xx *chip, int device, struct snd_rawmidi **rmidi); +int snd_cs46xx_midi(struct snd_cs46xx *chip, int device); int snd_cs46xx_start_dsp(struct snd_cs46xx *chip); int snd_cs46xx_gameport(struct snd_cs46xx *chip); diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 32b44f25b5c8..dfec84e1a575 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -1778,13 +1778,11 @@ static struct snd_pcm_ops snd_cs46xx_capture_indirect_ops = { #define MAX_PLAYBACK_CHANNELS 1 #endif -int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm) +int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(chip->card, "CS46xx", device, MAX_PLAYBACK_CHANNELS, 1, &pcm)) < 0) return err; @@ -1801,23 +1799,16 @@ int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm) snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); - if (rpcm) - *rpcm = pcm; - return 0; } #ifdef CONFIG_SND_CS46XX_NEW_DSP -int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, - struct snd_pcm **rpcm) +int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; - if ((err = snd_pcm_new(chip->card, "CS46xx - Rear", device, MAX_PLAYBACK_CHANNELS, 0, &pcm)) < 0) return err; @@ -1833,21 +1824,14 @@ int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); - if (rpcm) - *rpcm = pcm; - return 0; } -int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device, - struct snd_pcm **rpcm) +int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; - if ((err = snd_pcm_new(chip->card, "CS46xx - Center LFE", device, MAX_PLAYBACK_CHANNELS, 0, &pcm)) < 0) return err; @@ -1863,21 +1847,14 @@ int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); - if (rpcm) - *rpcm = pcm; - return 0; } -int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device, - struct snd_pcm **rpcm) +int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; - if ((err = snd_pcm_new(chip->card, "CS46xx - IEC958", device, 1, 0, &pcm)) < 0) return err; @@ -1893,9 +1870,6 @@ int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); - if (rpcm) - *rpcm = pcm; - return 0; } #endif @@ -2724,13 +2698,11 @@ static struct snd_rawmidi_ops snd_cs46xx_midi_input = .trigger = snd_cs46xx_midi_input_trigger, }; -int snd_cs46xx_midi(struct snd_cs46xx *chip, int device, struct snd_rawmidi **rrawmidi) +int snd_cs46xx_midi(struct snd_cs46xx *chip, int device) { struct snd_rawmidi *rmidi; int err; - if (rrawmidi) - *rrawmidi = NULL; if ((err = snd_rawmidi_new(chip->card, "CS46XX", device, 1, 1, &rmidi)) < 0) return err; strcpy(rmidi->name, "CS46XX"); @@ -2739,8 +2711,6 @@ int snd_cs46xx_midi(struct snd_cs46xx *chip, int device, struct snd_rawmidi **rr rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; rmidi->private_data = chip; chip->rmidi = rmidi; - if (rrawmidi) - *rrawmidi = NULL; return 0; } -- cgit From 50b8d94e1819768e8eccae4d24698a17b8940776 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:48 +0100 Subject: ALSA: ens1370: Remove always NULL parameters The various PCM and MIDI allocation functions in this driver take a pointer to a pointer of a PCM/MIDI object where if this parameter is provided the newly allocated object is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/ens1370.c | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) (limited to 'sound') diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index d94cb3ca7a64..bb1f4d22df5f 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1268,14 +1268,11 @@ static const struct snd_pcm_chmap_elem surround_map[] = { { } }; -static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device, - struct snd_pcm **rpcm) +static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(ensoniq->card, CHIP_NAME "/1", device, 1, 1, &pcm); if (err < 0) return err; @@ -1302,22 +1299,14 @@ static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device, err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_std_chmaps, 2, 0, NULL); #endif - if (err < 0) - return err; - - if (rpcm) - *rpcm = pcm; - return 0; + return err; } -static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device, - struct snd_pcm **rpcm) +static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(ensoniq->card, CHIP_NAME "/2", device, 1, 0, &pcm); if (err < 0) return err; @@ -1342,12 +1331,7 @@ static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device, err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, surround_map, 2, 0, NULL); #endif - if (err < 0) - return err; - - if (rpcm) - *rpcm = pcm; - return 0; + return err; } /* @@ -2362,14 +2346,11 @@ static struct snd_rawmidi_ops snd_ensoniq_midi_input = .trigger = snd_ensoniq_midi_input_trigger, }; -static int snd_ensoniq_midi(struct ensoniq *ensoniq, int device, - struct snd_rawmidi **rrawmidi) +static int snd_ensoniq_midi(struct ensoniq *ensoniq, int device) { struct snd_rawmidi *rmidi; int err; - if (rrawmidi) - *rrawmidi = NULL; if ((err = snd_rawmidi_new(ensoniq->card, "ES1370/1", device, 1, 1, &rmidi)) < 0) return err; strcpy(rmidi->name, CHIP_NAME); @@ -2379,8 +2360,6 @@ static int snd_ensoniq_midi(struct ensoniq *ensoniq, int device, SNDRV_RAWMIDI_INFO_DUPLEX; rmidi->private_data = ensoniq; ensoniq->rmidi = rmidi; - if (rrawmidi) - *rrawmidi = rmidi; return 0; } @@ -2462,15 +2441,15 @@ static int snd_audiopci_probe(struct pci_dev *pci, return err; } #endif - if ((err = snd_ensoniq_pcm(ensoniq, 0, NULL)) < 0) { + if ((err = snd_ensoniq_pcm(ensoniq, 0)) < 0) { snd_card_free(card); return err; } - if ((err = snd_ensoniq_pcm2(ensoniq, 1, NULL)) < 0) { + if ((err = snd_ensoniq_pcm2(ensoniq, 1)) < 0) { snd_card_free(card); return err; } - if ((err = snd_ensoniq_midi(ensoniq, 0, NULL)) < 0) { + if ((err = snd_ensoniq_midi(ensoniq, 0)) < 0) { snd_card_free(card); return err; } -- cgit From bb814c396af777c31ed168ce57f620967dd133f1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:49 +0100 Subject: ALSA: emu10k1: Remove always NULL parameters The various PCM and hwdep allocation functions in this driver take a pointer to a pointer of a PCM/hwdep where if this parameter is provided the newly allocated object is stored. All callers pass NULL though, so remove the parameter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1.c | 12 ++++++------ sound/pci/emu10k1/emu10k1x.c | 19 +++++-------------- sound/pci/emu10k1/emufx.c | 7 +------ sound/pci/emu10k1/emupcm.c | 33 ++++----------------------------- sound/pci/emu10k1/p16v.c | 7 +------ 5 files changed, 17 insertions(+), 61 deletions(-) (limited to 'sound') diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 4c171636efcd..a3c00a668268 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -132,11 +132,11 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci, goto error; card->private_data = emu; emu->delay_pcm_irq = delay_pcm_irq[dev] & 0x1f; - if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) + if ((err = snd_emu10k1_pcm(emu, 0)) < 0) goto error; - if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) + if ((err = snd_emu10k1_pcm_mic(emu, 1)) < 0) goto error; - if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) + if ((err = snd_emu10k1_pcm_efx(emu, 2)) < 0) goto error; /* This stores the periods table. */ if (emu->card_capabilities->ca0151_chip) { /* P16V */ @@ -151,10 +151,10 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci, if ((err = snd_emu10k1_timer(emu, 0)) < 0) goto error; - if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0) + if ((err = snd_emu10k1_pcm_multi(emu, 3)) < 0) goto error; if (emu->card_capabilities->ca0151_chip) { /* P16V */ - if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) + if ((err = snd_p16v_pcm(emu, 4)) < 0) goto error; } if (emu->audigy) { @@ -164,7 +164,7 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci, if ((err = snd_emu10k1_midi(emu)) < 0) goto error; } - if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) + if ((err = snd_emu10k1_fx8010_new(emu, 0)) < 0) goto error; #ifdef ENABLE_SYNTH if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 15933f92f63a..6d1b98d14327 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -847,15 +847,13 @@ static const struct snd_pcm_chmap_elem clfe_map[] = { { } }; -static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) +static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device) { struct snd_pcm *pcm; const struct snd_pcm_chmap_elem *map = NULL; int err; int capture = 0; - if (rpcm) - *rpcm = NULL; if (device == 0) capture = 1; @@ -896,15 +894,8 @@ static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **r snd_dma_pci_data(emu->pci), 32*1024, 32*1024); - err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, + return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, 1 << 2, NULL); - if (err < 0) - return err; - - if (rpcm) - *rpcm = pcm; - - return 0; } static int snd_emu10k1x_create(struct snd_card *card, @@ -1583,15 +1574,15 @@ static int snd_emu10k1x_probe(struct pci_dev *pci, return err; } - if ((err = snd_emu10k1x_pcm(chip, 0, NULL)) < 0) { + if ((err = snd_emu10k1x_pcm(chip, 0)) < 0) { snd_card_free(card); return err; } - if ((err = snd_emu10k1x_pcm(chip, 1, NULL)) < 0) { + if ((err = snd_emu10k1x_pcm(chip, 1)) < 0) { snd_card_free(card); return err; } - if ((err = snd_emu10k1x_pcm(chip, 2, NULL)) < 0) { + if ((err = snd_emu10k1x_pcm(chip, 2)) < 0) { snd_card_free(card); return err; } diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index eb5c0aba41c1..56fc47bd6dba 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -2641,14 +2641,11 @@ static int snd_emu10k1_fx8010_release(struct snd_hwdep * hw, struct file *file) return 0; } -int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, - struct snd_hwdep **rhwdep) +int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device) { struct snd_hwdep *hw; int err; - if (rhwdep) - *rhwdep = NULL; if ((err = snd_hwdep_new(emu->card, "FX8010", device, &hw)) < 0) return err; strcpy(hw->name, "EMU10K1 (FX8010)"); @@ -2657,8 +2654,6 @@ int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, hw->ops.ioctl = snd_emu10k1_fx8010_ioctl; hw->ops.release = snd_emu10k1_fx8010_release; hw->private_data = emu; - if (rhwdep) - *rhwdep = hw; return 0; } diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index f82481bd2542..0dc07385af0e 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -1400,15 +1400,12 @@ static struct snd_pcm_ops snd_emu10k1_efx_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) +int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device) { struct snd_pcm *pcm; struct snd_pcm_substream *substream; int err; - if (rpcm) - *rpcm = NULL; - if ((err = snd_pcm_new(emu->card, "emu10k1", device, 32, 1, &pcm)) < 0) return err; @@ -1429,22 +1426,15 @@ int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); - if (rpcm) - *rpcm = pcm; - return 0; } -int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device, - struct snd_pcm **rpcm) +int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device) { struct snd_pcm *pcm; struct snd_pcm_substream *substream; int err; - if (rpcm) - *rpcm = NULL; - if ((err = snd_pcm_new(emu->card, "emu10k1", device, 1, 0, &pcm)) < 0) return err; @@ -1461,9 +1451,6 @@ int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device, if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) return err; - if (rpcm) - *rpcm = pcm; - return 0; } @@ -1479,15 +1466,11 @@ static struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { .pointer = snd_emu10k1_capture_pointer, }; -int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device, - struct snd_pcm **rpcm) +int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; - if ((err = snd_pcm_new(emu->card, "emu10k1 mic", device, 0, 1, &pcm)) < 0) return err; @@ -1501,8 +1484,6 @@ int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); - if (rpcm) - *rpcm = pcm; return 0; } @@ -1822,16 +1803,12 @@ static struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = { .ack = snd_emu10k1_fx8010_playback_transfer, }; -int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device, - struct snd_pcm **rpcm) +int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device) { struct snd_pcm *pcm; struct snd_kcontrol *kctl; int err; - if (rpcm) - *rpcm = NULL; - if ((err = snd_pcm_new(emu->card, "emu10k1 efx", device, 8, 1, &pcm)) < 0) return err; @@ -1843,8 +1820,6 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device, pcm->info_flags = 0; strcpy(pcm->name, "Multichannel Capture/PT Playback"); emu->pcm_efx = pcm; - if (rpcm) - *rpcm = pcm; /* EFX capture - record the "FXBUS2" channels, by default we connect the EXTINs * to these diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 7ef3898a7806..b672755815e1 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -640,7 +640,7 @@ int snd_p16v_free(struct snd_emu10k1 *chip) return 0; } -int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) +int snd_p16v_pcm(struct snd_emu10k1 *emu, int device) { struct snd_pcm *pcm; struct snd_pcm_substream *substream; @@ -649,8 +649,6 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) /* dev_dbg(emu->card->dev, "snd_p16v_pcm called. device=%d\n", device); */ emu->p16v_device_offset = device; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(emu->card, "p16v", device, 1, capture, &pcm)) < 0) return err; @@ -694,9 +692,6 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) */ } - if (rpcm) - *rpcm = pcm; - return 0; } -- cgit From 483337f903dd39a10d4d6617cf6f30feeead061c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:50 +0100 Subject: ALSA: fm801: Remove always NULL parameter snd_fm801_pcm() takes a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index d167afffce5f..9a2122fd3a8e 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -704,13 +704,11 @@ static struct snd_pcm_ops snd_fm801_capture_ops = { .pointer = snd_fm801_capture_pointer, }; -static int snd_fm801_pcm(struct fm801 *chip, int device, struct snd_pcm **rpcm) +static int snd_fm801_pcm(struct fm801 *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(chip->card, "FM801", device, 1, 1, &pcm)) < 0) return err; @@ -726,16 +724,10 @@ static int snd_fm801_pcm(struct fm801 *chip, int device, struct snd_pcm **rpcm) snd_dma_pci_data(chip->pci), chip->multichannel ? 128*1024 : 64*1024, 128*1024); - err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, chip->multichannel ? 6 : 2, 0, NULL); - if (err < 0) - return err; - - if (rpcm) - *rpcm = pcm; - return 0; } /* @@ -1340,7 +1332,7 @@ static int snd_card_fm801_probe(struct pci_dev *pci, if (chip->tea575x_tuner & TUNER_ONLY) goto __fm801_tuner_only; - if ((err = snd_fm801_pcm(chip, 0, NULL)) < 0) { + if ((err = snd_fm801_pcm(chip, 0)) < 0) { snd_card_free(card); return err; } -- cgit From 08a4c10b58d6403ca9fe8c872e22ecad47924fec Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:51 +0100 Subject: ALSA: ice1712: Remove always NULL parameters The various PCM allocation functions in this driver take a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ice1712.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index b039b46152c6..a2ee29826d0d 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -880,13 +880,11 @@ static struct snd_pcm_ops snd_ice1712_capture_ops = { .pointer = snd_ice1712_capture_pointer, }; -static int snd_ice1712_pcm(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm) +static int snd_ice1712_pcm(struct snd_ice1712 *ice, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(ice->card, "ICE1712 consumer", device, 1, 1, &pcm); if (err < 0) return err; @@ -902,22 +900,17 @@ static int snd_ice1712_pcm(struct snd_ice1712 *ice, int device, struct snd_pcm * snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(ice->pci), 64*1024, 64*1024); - if (rpcm) - *rpcm = pcm; - dev_warn(ice->card->dev, "Consumer PCM code does not work well at the moment --jk\n"); return 0; } -static int snd_ice1712_pcm_ds(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm) +static int snd_ice1712_pcm_ds(struct snd_ice1712 *ice, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(ice->card, "ICE1712 consumer (DS)", device, 6, 0, &pcm); if (err < 0) return err; @@ -932,9 +925,6 @@ static int snd_ice1712_pcm_ds(struct snd_ice1712 *ice, int device, struct snd_pc snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(ice->pci), 64*1024, 128*1024); - if (rpcm) - *rpcm = pcm; - return 0; } @@ -1260,13 +1250,11 @@ static struct snd_pcm_ops snd_ice1712_capture_pro_ops = { .pointer = snd_ice1712_capture_pro_pointer, }; -static int snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device, struct snd_pcm **rpcm) +static int snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(ice->card, "ICE1712 multi", device, 1, 1, &pcm); if (err < 0) return err; @@ -1282,8 +1270,6 @@ static int snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device, struct snd snd_dma_pci_data(ice->pci), 256*1024, 256*1024); ice->pcm_pro = pcm; - if (rpcm) - *rpcm = pcm; if (ice->cs8427) { /* assign channels to iec958 */ @@ -2691,14 +2677,14 @@ static int snd_ice1712_probe(struct pci_dev *pci, c = &no_matched; __found: - err = snd_ice1712_pcm_profi(ice, pcm_dev++, NULL); + err = snd_ice1712_pcm_profi(ice, pcm_dev++); if (err < 0) { snd_card_free(card); return err; } if (ice_has_con_ac97(ice)) { - err = snd_ice1712_pcm(ice, pcm_dev++, NULL); + err = snd_ice1712_pcm(ice, pcm_dev++); if (err < 0) { snd_card_free(card); return err; @@ -2726,7 +2712,7 @@ static int snd_ice1712_probe(struct pci_dev *pci, } if (ice_has_con_ac97(ice)) { - err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL); + err = snd_ice1712_pcm_ds(ice, pcm_dev++); if (err < 0) { snd_card_free(card); return err; -- cgit From 15aded4c924ae149a38e639f421f5313125eea89 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:52 +0100 Subject: ALSA: riptide: Remove always NULL parameter snd_riptide_pcm() takes a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 6abc2ac8fffb..121f2c09d7a7 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1706,14 +1706,11 @@ static struct snd_pcm_ops snd_riptide_capture_ops = { .pointer = snd_riptide_pointer, }; -static int -snd_riptide_pcm(struct snd_riptide *chip, int device, struct snd_pcm **rpcm) +static int snd_riptide_pcm(struct snd_riptide *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(chip->card, "RIPTIDE", device, PLAYBACK_SUBSTREAMS, 1, &pcm)) < 0) @@ -1729,8 +1726,6 @@ snd_riptide_pcm(struct snd_riptide *chip, int device, struct snd_pcm **rpcm) snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(chip->pci), 64 * 1024, 128 * 1024); - if (rpcm) - *rpcm = pcm; return 0; } @@ -2092,7 +2087,7 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) if (err < 0) goto error; card->private_data = chip; - err = snd_riptide_pcm(chip, 0, NULL); + err = snd_riptide_pcm(chip, 0); if (err < 0) goto error; err = snd_riptide_mixer(chip); -- cgit From 0f33991dd2811cb5458b1a2bc19c6aa6ff64c00b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:53 +0100 Subject: ALSA: sonicvibes: Remove always NULL parameter snd_sonicvibes_pcm() take a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/sonicvibes.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 313a7328bf9c..34cee5c1abd8 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -880,8 +880,7 @@ static struct snd_pcm_ops snd_sonicvibes_capture_ops = { .pointer = snd_sonicvibes_capture_pointer, }; -static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device, - struct snd_pcm **rpcm) +static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device) { struct snd_pcm *pcm; int err; @@ -902,8 +901,6 @@ static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(sonic->pci), 64*1024, 128*1024); - if (rpcm) - *rpcm = pcm; return 0; } @@ -1491,7 +1488,7 @@ static int snd_sonic_probe(struct pci_dev *pci, (unsigned long long)pci_resource_start(pci, 1), sonic->irq); - if ((err = snd_sonicvibes_pcm(sonic, 0, NULL)) < 0) { + if ((err = snd_sonicvibes_pcm(sonic, 0)) < 0) { snd_card_free(card); return err; } -- cgit From 1b16416fda21a8c5704bce809e0d7387bbfb097d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:54 +0100 Subject: ALSA: trident: Remove always NULL parameters The various PCM allocation functions in this driver take a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/trident/trident.c | 6 +++--- sound/pci/trident/trident.h | 6 +++--- sound/pci/trident/trident_main.c | 21 +++------------------ 3 files changed, 9 insertions(+), 24 deletions(-) (limited to 'sound') diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index a54cd6879b31..cedf13b64803 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c @@ -127,21 +127,21 @@ static int snd_trident_probe(struct pci_dev *pci, sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d", card->shortname, trident->port, trident->irq); - if ((err = snd_trident_pcm(trident, pcm_dev++, NULL)) < 0) { + if ((err = snd_trident_pcm(trident, pcm_dev++)) < 0) { snd_card_free(card); return err; } switch (trident->device) { case TRIDENT_DEVICE_ID_DX: case TRIDENT_DEVICE_ID_NX: - if ((err = snd_trident_foldback_pcm(trident, pcm_dev++, NULL)) < 0) { + if ((err = snd_trident_foldback_pcm(trident, pcm_dev++)) < 0) { snd_card_free(card); return err; } break; } if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) { - if ((err = snd_trident_spdif_pcm(trident, pcm_dev++, NULL)) < 0) { + if ((err = snd_trident_spdif_pcm(trident, pcm_dev++)) < 0) { snd_card_free(card); return err; } diff --git a/sound/pci/trident/trident.h b/sound/pci/trident/trident.h index 5f110eb56e47..9624e5937719 100644 --- a/sound/pci/trident/trident.h +++ b/sound/pci/trident/trident.h @@ -420,9 +420,9 @@ int snd_trident_create(struct snd_card *card, struct snd_trident ** rtrident); int snd_trident_create_gameport(struct snd_trident *trident); -int snd_trident_pcm(struct snd_trident * trident, int device, struct snd_pcm **rpcm); -int snd_trident_foldback_pcm(struct snd_trident * trident, int device, struct snd_pcm **rpcm); -int snd_trident_spdif_pcm(struct snd_trident * trident, int device, struct snd_pcm **rpcm); +int snd_trident_pcm(struct snd_trident *trident, int device); +int snd_trident_foldback_pcm(struct snd_trident *trident, int device); +int snd_trident_spdif_pcm(struct snd_trident *trident, int device); int snd_trident_attach_synthesizer(struct snd_trident * trident); struct snd_trident_voice *snd_trident_alloc_voice(struct snd_trident * trident, int type, int client, int port); diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 57cd757acfe7..c380c99407c0 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -2172,14 +2172,11 @@ static struct snd_pcm_ops snd_trident_spdif_7018_ops = { ---------------------------------------------------------------------------*/ -int snd_trident_pcm(struct snd_trident *trident, - int device, struct snd_pcm **rpcm) +int snd_trident_pcm(struct snd_trident *trident, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, trident->ChanPCM, 1, &pcm)) < 0) return err; @@ -2214,8 +2211,6 @@ int snd_trident_pcm(struct snd_trident *trident, snd_dma_pci_data(trident->pci), 64*1024, 128*1024); } - if (rpcm) - *rpcm = pcm; return 0; } @@ -2230,16 +2225,13 @@ int snd_trident_pcm(struct snd_trident *trident, ---------------------------------------------------------------------------*/ -int snd_trident_foldback_pcm(struct snd_trident *trident, - int device, struct snd_pcm **rpcm) +int snd_trident_foldback_pcm(struct snd_trident *trident, int device) { struct snd_pcm *foldback; int err; int num_chan = 3; struct snd_pcm_substream *substream; - if (rpcm) - *rpcm = NULL; if (trident->device == TRIDENT_DEVICE_ID_NX) num_chan = 4; if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, 0, num_chan, &foldback)) < 0) @@ -2271,8 +2263,6 @@ int snd_trident_foldback_pcm(struct snd_trident *trident, snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), 64*1024, 128*1024); - if (rpcm) - *rpcm = foldback; return 0; } @@ -2287,14 +2277,11 @@ int snd_trident_foldback_pcm(struct snd_trident *trident, ---------------------------------------------------------------------------*/ -int snd_trident_spdif_pcm(struct snd_trident *trident, - int device, struct snd_pcm **rpcm) +int snd_trident_spdif_pcm(struct snd_trident *trident, int device) { struct snd_pcm *spdif; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(trident->card, "trident_dx_nx IEC958", device, 1, 0, &spdif)) < 0) return err; @@ -2310,8 +2297,6 @@ int snd_trident_spdif_pcm(struct snd_trident *trident, snd_pcm_lib_preallocate_pages_for_all(spdif, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), 64*1024, 128*1024); - if (rpcm) - *rpcm = spdif; return 0; } -- cgit From 38c4718121804317e00a3a905612d17485f754c0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 12:24:55 +0100 Subject: ALSA: ymfpci: Remove always NULL parameters The various PCM allocation functions in this driver take a pointer to a pointer of a PCM where if this parameter is provided the newly allocated PCM is stored. All callers pass NULL though, so remove the parameter. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/ymfpci/ymfpci.c | 8 ++++---- sound/pci/ymfpci/ymfpci.h | 8 ++++---- sound/pci/ymfpci/ymfpci_main.c | 38 ++++++-------------------------------- 3 files changed, 14 insertions(+), 40 deletions(-) (limited to 'sound') diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 47a192369e8f..812e27a1bcbc 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -283,11 +283,11 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci, card->shortname, chip->reg_area_phys, chip->irq); - if ((err = snd_ymfpci_pcm(chip, 0, NULL)) < 0) { + if ((err = snd_ymfpci_pcm(chip, 0)) < 0) { snd_card_free(card); return err; } - if ((err = snd_ymfpci_pcm_spdif(chip, 1, NULL)) < 0) { + if ((err = snd_ymfpci_pcm_spdif(chip, 1)) < 0) { snd_card_free(card); return err; } @@ -297,12 +297,12 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci, return err; } if (chip->ac97->ext_id & AC97_EI_SDAC) { - err = snd_ymfpci_pcm_4ch(chip, 2, NULL); + err = snd_ymfpci_pcm_4ch(chip, 2); if (err < 0) { snd_card_free(card); return err; } - err = snd_ymfpci_pcm2(chip, 3, NULL); + err = snd_ymfpci_pcm2(chip, 3); if (err < 0) { snd_card_free(card); return err; diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h index 4631a2348915..149d4cb46998 100644 --- a/sound/pci/ymfpci/ymfpci.h +++ b/sound/pci/ymfpci/ymfpci.h @@ -379,10 +379,10 @@ void snd_ymfpci_free_gameport(struct snd_ymfpci *chip); extern const struct dev_pm_ops snd_ymfpci_pm; -int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); -int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); -int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); -int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); +int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device); +int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device); +int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device); +int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device); int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch); int snd_ymfpci_timer(struct snd_ymfpci *chip, int device); diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 81c916a5eb96..f5581a97d391 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -1145,13 +1145,11 @@ static struct snd_pcm_ops snd_ymfpci_capture_rec_ops = { .pointer = snd_ymfpci_capture_pointer, }; -int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm) +int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm)) < 0) return err; pcm->private_data = chip; @@ -1167,14 +1165,8 @@ int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm) snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); - err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_std_chmaps, 2, 0, NULL); - if (err < 0) - return err; - - if (rpcm) - *rpcm = pcm; - return 0; } static struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { @@ -1188,13 +1180,11 @@ static struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { .pointer = snd_ymfpci_capture_pointer, }; -int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm) +int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm)) < 0) return err; pcm->private_data = chip; @@ -1210,8 +1200,6 @@ int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm) snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); - if (rpcm) - *rpcm = pcm; return 0; } @@ -1226,14 +1214,11 @@ static struct snd_pcm_ops snd_ymfpci_playback_spdif_ops = { .pointer = snd_ymfpci_playback_pointer, }; -int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, - struct snd_pcm **rpcm) +int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm)) < 0) return err; pcm->private_data = chip; @@ -1248,8 +1233,6 @@ int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); - if (rpcm) - *rpcm = pcm; return 0; } @@ -1272,14 +1255,11 @@ static const struct snd_pcm_chmap_elem surround_map[] = { { } }; -int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, - struct snd_pcm **rpcm) +int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; if ((err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm)) < 0) return err; pcm->private_data = chip; @@ -1294,14 +1274,8 @@ int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 64*1024, 256*1024); - err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, + return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, surround_map, 2, 0, NULL); - if (err < 0) - return err; - - if (rpcm) - *rpcm = pcm; - return 0; } static int snd_ymfpci_spdif_default_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) -- cgit From ef394acb45e232e940367053896708375da1ff92 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 15:03:42 +0100 Subject: ALSA: oxygen: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the PCM itself is freed. There is no need to do this manually in the driver. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_pcm.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 02828240ba15..af22a74311d7 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c @@ -676,11 +676,6 @@ static struct snd_pcm_ops oxygen_ac97_ops = { .pointer = oxygen_pointer, }; -static void oxygen_pcm_free(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int oxygen_pcm_init(struct oxygen *chip) { struct snd_pcm *pcm; @@ -705,7 +700,6 @@ int oxygen_pcm_init(struct oxygen *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_b_ops); pcm->private_data = chip; - pcm->private_free = oxygen_pcm_free; strcpy(pcm->name, "Multichannel"); if (outs) snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, @@ -734,7 +728,6 @@ int oxygen_pcm_init(struct oxygen *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_c_ops); pcm->private_data = chip; - pcm->private_free = oxygen_pcm_free; strcpy(pcm->name, "Digital"); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), @@ -765,7 +758,6 @@ int oxygen_pcm_init(struct oxygen *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_b_ops); pcm->private_data = chip; - pcm->private_free = oxygen_pcm_free; strcpy(pcm->name, outs ? "Front Panel" : "Analog 2"); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), -- cgit From a14e7eb59bb7ce10766d4778d382ca52b235147f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 15:03:43 +0100 Subject: ALSA: ps3: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the card (and the PCM) itself is freed. There is no need to do this manually in the driver. Signed-off-by: Lars-Peter Clausen Signed-off-by: Takashi Iwai --- sound/ppc/snd_ps3.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index 58f292a87f98..368242519279 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -1044,7 +1044,7 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev) if (!the_card.null_buffer_start_vaddr) { pr_info("%s: nullbuffer alloc failed\n", __func__); ret = -ENOMEM; - goto clean_preallocate; + goto clean_card; } pr_debug("%s: null vaddr=%p dma=%#llx\n", __func__, the_card.null_buffer_start_vaddr, @@ -1066,8 +1066,6 @@ clean_dma_map: PAGE_SIZE, the_card.null_buffer_start_vaddr, the_card.null_buffer_start_dma_addr); -clean_preallocate: - snd_pcm_lib_preallocate_free_for_all(the_card.pcm); clean_card: snd_card_free(the_card.card); clean_irq: -- cgit From 57dca36ee25bcab20a71705175c00b6f114cdab4 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 14:54:56 +0100 Subject: ALSA: seq: Deletion of unnecessary checks before the function call "snd_midi_event_free" The snd_midi_event_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/core/seq/oss/seq_oss_midi.c | 6 ++---- sound/core/seq/seq_midi.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index 3a4569669efa..e79cc44b1394 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c @@ -237,8 +237,7 @@ snd_seq_oss_midi_check_exit_port(int client, int port) spin_unlock_irqrestore(®ister_lock, flags); snd_use_lock_free(&mdev->use_lock); snd_use_lock_sync(&mdev->use_lock); - if (mdev->coder) - snd_midi_event_free(mdev->coder); + snd_midi_event_free(mdev->coder); kfree(mdev); } spin_lock_irqsave(®ister_lock, flags); @@ -265,8 +264,7 @@ snd_seq_oss_midi_clear_all(void) spin_lock_irqsave(®ister_lock, flags); for (i = 0; i < max_midi_devs; i++) { if ((mdev = midi_devs[i]) != NULL) { - if (mdev->coder) - snd_midi_event_free(mdev->coder); + snd_midi_event_free(mdev->coder); kfree(mdev); midi_devs[i] = NULL; } diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index a1fd77af6059..68fec776da26 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -268,8 +268,7 @@ static void snd_seq_midisynth_delete(struct seq_midisynth *msynth) snd_seq_event_port_detach(msynth->seq_client, msynth->seq_port); } - if (msynth->parser) - snd_midi_event_free(msynth->parser); + snd_midi_event_free(msynth->parser); } /* register new midi synth port */ -- cgit From d1f45e6037f1195d10cf363e94a08ee2f10f9b41 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 15:10:52 +0100 Subject: sound: oss: Deletion of unnecessary checks before the function call "vfree" The vfree() function performs also input parameter validation. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/oss/pss.c | 2 +- sound/oss/trix.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/oss/pss.c b/sound/oss/pss.c index ca0d6e9f49f5..81314f9e2ccb 100644 --- a/sound/oss/pss.c +++ b/sound/oss/pss.c @@ -1228,7 +1228,7 @@ static void __exit cleanup_pss(void) { if(!pss_no_sound) { - if(fw_load && pss_synth) + if (fw_load) vfree(pss_synth); if(pssmss) unload_pss_mss(&cfg2); diff --git a/sound/oss/trix.c b/sound/oss/trix.c index 944e0c015485..3c494dc93b93 100644 --- a/sound/oss/trix.c +++ b/sound/oss/trix.c @@ -487,7 +487,7 @@ static int __init init_trix(void) static void __exit cleanup_trix(void) { - if (fw_load && trix_boot) + if (fw_load) vfree(trix_boot); if (sb) unload_trix_sb(&cfg2); -- cgit From a827977ac31cb5d1f4720efede9bbbf241789993 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 17:06:04 +0100 Subject: ALSA: emu10k1: Delete an unnecessary check before the function call "kfree" The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/p16v.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index b672755815e1..3c60b433de9f 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -166,11 +166,8 @@ static struct snd_pcm_hardware snd_p16v_capture_hw = { static void snd_p16v_pcm_free_substream(struct snd_pcm_runtime *runtime) { struct snd_emu10k1_pcm *epcm = runtime->private_data; - - if (epcm) { - /* dev_dbg(emu->card->dev, "epcm free: %p\n", epcm); */ - kfree(epcm); - } + + kfree(epcm); } /* open_playback callback */ -- cgit From 1fac1686377410169952db63d282490bc0554662 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 17:37:28 +0100 Subject: ALSA: oxygen: Delete an unnecessary check before the function call "snd_pcm_suspend" The snd_pcm_suspend() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_lib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index b67e30602473..61a62c0d3488 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -736,8 +736,7 @@ static int oxygen_pci_suspend(struct device *dev) snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < PCM_COUNT; ++i) - if (chip->streams[i]) - snd_pcm_suspend(chip->streams[i]); + snd_pcm_suspend(chip->streams[i]); if (chip->model.suspend) chip->model.suspend(chip); -- cgit From b172e0aae6d14baf646a36052d03b301535f4ef5 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 18:28:21 +0100 Subject: ALSA: emux: Delete an unnecessary check before the function call "snd_sf_free" The snd_sf_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/synth/emux/emux.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index 93522072bc87..f27a1c85f81b 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -160,12 +160,8 @@ int snd_emux_free(struct snd_emux *emu) snd_emux_detach_seq_oss(emu); #endif snd_emux_detach_seq(emu); - snd_emux_delete_hwdep(emu); - - if (emu->sflist) - snd_sf_free(emu->sflist); - + snd_sf_free(emu->sflist); kfree(emu->voices); kfree(emu->name); kfree(emu); -- cgit From aa57b93b27eae1156c9a66a4ea85076f9a38d135 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 20:43:01 +0100 Subject: ALSA: aoa: Delete an unnecessary check before the function call "snd_pcm_suspend_all" The snd_pcm_suspend_all() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/aoa/soundbus/i2sbus/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c index 4e2b4fbf2496..837ba99a7524 100644 --- a/sound/aoa/soundbus/i2sbus/core.c +++ b/sound/aoa/soundbus/i2sbus/core.c @@ -381,10 +381,8 @@ static int i2sbus_suspend(struct macio_dev* dev, pm_message_t state) list_for_each_entry(i2sdev, &control->list, item) { /* Notify Alsa */ - if (i2sdev->sound.pcm) { - /* Suspend PCM streams */ - snd_pcm_suspend_all(i2sdev->sound.pcm); - } + /* Suspend PCM streams */ + snd_pcm_suspend_all(i2sdev->sound.pcm); /* Notify codecs */ list_for_each_entry(cii, &i2sdev->sound.codec_list, list) { -- cgit From b76c0e95ab0f535e210df588b8ac42dd75b31c75 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 21:02:32 +0100 Subject: ALSA: sb: Delete an unnecessary check before the function call "snd_emux_free" The snd_emux_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000_synth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c index 95b39beb61c1..72332dfada9a 100644 --- a/sound/isa/sb/emu8000_synth.c +++ b/sound/isa/sb/emu8000_synth.c @@ -103,8 +103,7 @@ static int snd_emu8000_delete_device(struct snd_seq_device *dev) hw = dev->driver_data; if (hw->pcm) snd_device_free(dev->card, hw->pcm); - if (hw->emu) - snd_emux_free(hw->emu); + snd_emux_free(hw->emu); snd_util_memhdr_free(hw->memhdr); hw->emu = NULL; hw->memhdr = NULL; -- cgit From ff6defa6a8fae12205d64f55db395b1fcf35af8e Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 22:55:54 +0100 Subject: ALSA: Deletion of checks before the function call "iounmap" The iounmap() function performs also input parameter validation. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/aoa/soundbus/i2sbus/core.c | 13 ++++++------- sound/arm/aaci.c | 4 ++-- sound/drivers/ml403-ac97cr.c | 3 +-- sound/isa/msnd/msnd_pinnacle.c | 3 +-- sound/parisc/harmony.c | 4 +--- sound/pci/ad1889.c | 5 +---- sound/pci/asihpi/hpioctl.c | 6 ++---- sound/pci/atiixp.c | 3 +-- sound/pci/atiixp_modem.c | 3 +-- sound/pci/aw2/aw2-alsa.c | 4 +--- sound/pci/bt87x.c | 3 +-- sound/pci/cs4281.c | 6 ++---- sound/pci/cs46xx/cs46xx_lib.c | 4 ++-- sound/pci/ctxfi/cthw20k1.c | 5 +---- sound/pci/ctxfi/cthw20k2.c | 5 +---- sound/pci/echoaudio/echoaudio.c | 6 +----- sound/pci/hda/hda_intel.c | 3 +-- sound/pci/lola/lola.c | 6 ++---- sound/pci/mixart/mixart.c | 7 +++---- sound/pci/nm256/nm256.c | 6 ++---- sound/pci/rme9652/hdsp.c | 4 +--- sound/pci/rme9652/hdspm.c | 4 +--- sound/pci/rme9652/rme9652.c | 3 +-- sound/pci/sis7019.c | 5 +---- sound/pci/ymfpci/ymfpci_main.c | 3 +-- sound/ppc/pmac.c | 15 +++++---------- 26 files changed, 43 insertions(+), 90 deletions(-) (limited to 'sound') diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c index 837ba99a7524..b9737fae656a 100644 --- a/sound/aoa/soundbus/i2sbus/core.c +++ b/sound/aoa/soundbus/i2sbus/core.c @@ -74,10 +74,9 @@ static void i2sbus_release_dev(struct device *dev) int i; i2sdev = container_of(dev, struct i2sbus_dev, sound.ofdev.dev); - - if (i2sdev->intfregs) iounmap(i2sdev->intfregs); - if (i2sdev->out.dbdma) iounmap(i2sdev->out.dbdma); - if (i2sdev->in.dbdma) iounmap(i2sdev->in.dbdma); + iounmap(i2sdev->intfregs); + iounmap(i2sdev->out.dbdma); + iounmap(i2sdev->in.dbdma); for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) release_and_free_resource(i2sdev->allocated_resource[i]); free_dbdma_descriptor_ring(i2sdev, &i2sdev->out.dbdma_ring); @@ -318,9 +317,9 @@ static int i2sbus_add_dev(struct macio_dev *macio, free_irq(dev->interrupts[i], dev); free_dbdma_descriptor_ring(dev, &dev->out.dbdma_ring); free_dbdma_descriptor_ring(dev, &dev->in.dbdma_ring); - if (dev->intfregs) iounmap(dev->intfregs); - if (dev->out.dbdma) iounmap(dev->out.dbdma); - if (dev->in.dbdma) iounmap(dev->in.dbdma); + iounmap(dev->intfregs); + iounmap(dev->out.dbdma); + iounmap(dev->in.dbdma); for (i=0;i<3;i++) release_and_free_resource(dev->allocated_resource[i]); mutex_destroy(&dev->lock); diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 0e83a73efb16..4140b1b95054 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -889,8 +889,8 @@ static int aaci_probe_ac97(struct aaci *aaci) static void aaci_free_card(struct snd_card *card) { struct aaci *aaci = card->private_data; - if (aaci->base) - iounmap(aaci->base); + + iounmap(aaci->base); } static struct aaci *aaci_init_card(struct amba_device *dev) diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index ec01de1cb23b..bdcb5721393b 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -1094,8 +1094,7 @@ static int snd_ml403_ac97cr_free(struct snd_ml403_ac97cr *ml403_ac97cr) if (ml403_ac97cr->capture_irq >= 0) free_irq(ml403_ac97cr->capture_irq, ml403_ac97cr); /* give back "port" */ - if (ml403_ac97cr->port != NULL) - iounmap(ml403_ac97cr->port); + iounmap(ml403_ac97cr->port); kfree(ml403_ac97cr); PDEBUG(INIT_INFO, "free(): (done)\n"); return 0; diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c index 65b36825d194..4c072666115d 100644 --- a/sound/isa/msnd/msnd_pinnacle.c +++ b/sound/isa/msnd/msnd_pinnacle.c @@ -627,8 +627,7 @@ static int snd_msnd_attach(struct snd_card *card) return 0; err_release_region: - if (chip->mappedbase) - iounmap(chip->mappedbase); + iounmap(chip->mappedbase); release_mem_region(chip->base, BUFFSIZE); release_region(chip->io, DSP_NUMIO); free_irq(chip->irq, chip); diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index 29604a239c44..f2350c1d6ee8 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -893,9 +893,7 @@ snd_harmony_free(struct snd_harmony *h) if (h->irq >= 0) free_irq(h->irq, h); - if (h->iobase) - iounmap(h->iobase); - + iounmap(h->iobase); kfree(h); return 0; } diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 547ee30540a0..0de31290411c 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -853,12 +853,9 @@ snd_ad1889_free(struct snd_ad1889 *chip) free_irq(chip->irq, chip); skip_hw: - if (chip->iobase) - iounmap(chip->iobase); - + iounmap(chip->iobase); pci_release_regions(chip->pci); pci_disable_device(chip->pci); - kfree(chip); return 0; } diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index 72af66bdf714..67d113356971 100644 --- a/sound/pci/asihpi/hpioctl.c +++ b/sound/pci/asihpi/hpioctl.c @@ -541,10 +541,8 @@ void asihpi_adapter_remove(struct pci_dev *pci_dev) hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL); /* unmap PCI memory space, mapped during device init. */ - for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) { - if (pci.ap_mem_base[idx]) - iounmap(pci.ap_mem_base[idx]); - } + for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; ++idx) + iounmap(pci.ap_mem_base[idx]); if (pa->irq) free_irq(pa->irq, pa); diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 9c1c4452a8ee..d24188fea4b6 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1585,8 +1585,7 @@ static int snd_atiixp_free(struct atiixp *chip) __hw_end: if (chip->irq >= 0) free_irq(chip->irq, chip); - if (chip->remap_addr) - iounmap(chip->remap_addr); + iounmap(chip->remap_addr); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index b2f63e0727de..c321a97b4344 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1211,8 +1211,7 @@ static int snd_atiixp_free(struct atiixp_modem *chip) __hw_end: if (chip->irq >= 0) free_irq(chip->irq, chip); - if (chip->remap_addr) - iounmap(chip->remap_addr); + iounmap(chip->remap_addr); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index e1cf01949fda..8d2fee7b33bd 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c @@ -229,9 +229,7 @@ static int snd_aw2_dev_free(struct snd_device *device) if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); /* release the i/o ports & memory */ - if (chip->iobase_virt) - iounmap(chip->iobase_virt); - + iounmap(chip->iobase_virt); pci_release_regions(chip->pci); /* disable the PCI entry */ pci_disable_device(chip->pci); diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 058b9973c09c..e82ceacbe64f 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -690,8 +690,7 @@ static int snd_bt87x_free(struct snd_bt87x *chip) snd_bt87x_stop(chip); if (chip->irq >= 0) free_irq(chip->irq, chip); - if (chip->mmio) - iounmap(chip->mmio); + iounmap(chip->mmio); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 05a4337f8116..ea339111c59f 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1316,10 +1316,8 @@ static int snd_cs4281_free(struct cs4281 *chip) if (chip->irq >= 0) free_irq(chip->irq, chip); - if (chip->ba0) - iounmap(chip->ba0); - if (chip->ba1) - iounmap(chip->ba1); + iounmap(chip->ba0); + iounmap(chip->ba1); pci_release_regions(chip->pci); pci_disable_device(chip->pci); diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index dfec84e1a575..128bbfe80aa7 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -2949,8 +2949,8 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip) for (idx = 0; idx < 5; idx++) { struct snd_cs46xx_region *region = &chip->region.idx[idx]; - if (region->remap_addr) - iounmap(region->remap_addr); + + iounmap(region->remap_addr); release_and_free_resource(region->resource); } diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index b425aa8ee578..b8b0d8ef9319 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c @@ -1985,10 +1985,7 @@ static int hw_card_shutdown(struct hw *hw) free_irq(hw->irq, hw); hw->irq = -1; - - if (hw->mem_base) - iounmap(hw->mem_base); - + iounmap(hw->mem_base); hw->mem_base = NULL; if (hw->io_base) diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 253899d13790..4e16b4d05eed 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -2110,10 +2110,7 @@ static int hw_card_shutdown(struct hw *hw) free_irq(hw->irq, hw); hw->irq = -1; - - if (hw->mem_base) - iounmap(hw->mem_base); - + iounmap(hw->mem_base); hw->mem_base = NULL; if (hw->io_base) diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 21228adaa70c..98d4f35cff2e 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -1872,12 +1872,8 @@ static int snd_echo_free(struct echoaudio *chip) if (chip->comm_page) snd_dma_free_pages(&chip->commpage_dma_buf); - if (chip->dsp_registers) - iounmap(chip->dsp_registers); - + iounmap(chip->dsp_registers); release_and_free_resource(chip->iores); - - pci_disable_device(chip->pci); /* release chip data */ diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index d426a0bd6a5f..a9714251b159 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1138,8 +1138,7 @@ static int azx_free(struct azx *chip) free_irq(chip->irq, (void*)chip); if (chip->msi) pci_disable_msi(chip->pci); - if (chip->remap_addr) - iounmap(chip->remap_addr); + iounmap(chip->remap_addr); azx_free_stream_pages(chip); if (chip->region_requested) diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c index 4cf4be5ef82a..9ff600084973 100644 --- a/sound/pci/lola/lola.c +++ b/sound/pci/lola/lola.c @@ -551,10 +551,8 @@ static void lola_free(struct lola *chip) lola_free_mixer(chip); if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); - if (chip->bar[0].remap_addr) - iounmap(chip->bar[0].remap_addr); - if (chip->bar[1].remap_addr) - iounmap(chip->bar[1].remap_addr); + iounmap(chip->bar[0].remap_addr); + iounmap(chip->bar[1].remap_addr); if (chip->rb.area) snd_dma_free_pages(&chip->rb); pci_release_regions(chip->pci); diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 1faf47e81570..c3a9f39f8d61 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1114,10 +1114,9 @@ static int snd_mixart_free(struct mixart_mgr *mgr) } /* release the i/o ports */ - for (i = 0; i < 2; i++) { - if (mgr->mem[i].virt) - iounmap(mgr->mem[i].virt); - } + for (i = 0; i < 2; ++i) + iounmap(mgr->mem[i].virt); + pci_release_regions(mgr->pci); /* free flowarray */ diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 4e41a4e29a1e..3f52a44143a5 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1460,10 +1460,8 @@ static int snd_nm256_free(struct nm256 *chip) if (chip->irq >= 0) free_irq(chip->irq, chip); - if (chip->cport) - iounmap(chip->cport); - if (chip->buffer) - iounmap(chip->buffer); + iounmap(chip->cport); + iounmap(chip->buffer); release_and_free_resource(chip->res_cport); release_and_free_resource(chip->res_buffer); diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index cf5a6c8b9a63..fe66bcb21475 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -5309,9 +5309,7 @@ static int snd_hdsp_free(struct hdsp *hdsp) release_firmware(hdsp->firmware); vfree(hdsp->fw_uploaded); - - if (hdsp->iobase) - iounmap(hdsp->iobase); + iounmap(hdsp->iobase); if (hdsp->port) pci_release_regions(hdsp->pci); diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 3342705a5715..8109b8e5f6ef 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -6965,9 +6965,7 @@ static int snd_hdspm_free(struct hdspm * hdspm) free_irq(hdspm->irq, (void *) hdspm); kfree(hdspm->mixer); - - if (hdspm->iobase) - iounmap(hdspm->iobase); + iounmap(hdspm->iobase); if (hdspm->port) pci_release_regions(hdspm->pci); diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 6521521853b8..648911c1a226 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -1756,8 +1756,7 @@ static int snd_rme9652_free(struct snd_rme9652 *rme9652) if (rme9652->irq >= 0) free_irq(rme9652->irq, (void *)rme9652); - if (rme9652->iobase) - iounmap(rme9652->iobase); + iounmap(rme9652->iobase); if (rme9652->port) pci_release_regions(rme9652->pci); diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 7f6a0a0d115a..5e9437ba6eec 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -1064,12 +1064,9 @@ static int sis_chip_free(struct sis7019 *sis) if (sis->irq >= 0) free_irq(sis->irq, sis); - if (sis->ioaddr) - iounmap(sis->ioaddr); - + iounmap(sis->ioaddr); pci_release_regions(sis->pci); pci_disable_device(sis->pci); - sis_free_suspend(sis); return 0; } diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index f5581a97d391..de7f06fb3f92 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2246,8 +2246,7 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip) release_and_free_resource(chip->mpu_res); release_and_free_resource(chip->fm_res); snd_ymfpci_free_gameport(chip); - if (chip->reg_area_virt) - iounmap(chip->reg_area_virt); + iounmap(chip->reg_area_virt); if (chip->work_ptr.area) snd_dma_free_pages(&chip->work_ptr); diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 5a13b22748b2..d399df473896 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -867,16 +867,11 @@ static int snd_pmac_free(struct snd_pmac *chip) snd_pmac_dbdma_free(chip, &chip->capture.cmd); snd_pmac_dbdma_free(chip, &chip->extra_dma); snd_pmac_dbdma_free(chip, &emergency_dbdma); - if (chip->macio_base) - iounmap(chip->macio_base); - if (chip->latch_base) - iounmap(chip->latch_base); - if (chip->awacs) - iounmap(chip->awacs); - if (chip->playback.dma) - iounmap(chip->playback.dma); - if (chip->capture.dma) - iounmap(chip->capture.dma); + iounmap(chip->macio_base); + iounmap(chip->latch_base); + iounmap(chip->awacs); + iounmap(chip->playback.dma); + iounmap(chip->capture.dma); if (chip->node) { int i; -- cgit From 544c55c810a55dcfd2febbc33105642923be9192 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 19:03:55 +0100 Subject: ASoC: Intel: Delete an unnecessary check before the function call "sst_dma_free" The sst_dma_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/intel/sst-dsp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst-dsp.c b/sound/soc/intel/sst-dsp.c index 86e410845670..64e94212d2d2 100644 --- a/sound/soc/intel/sst-dsp.c +++ b/sound/soc/intel/sst-dsp.c @@ -410,8 +410,7 @@ void sst_dsp_free(struct sst_dsp *sst) if (sst->ops->free) sst->ops->free(sst); - if (sst->dma) - sst_dma_free(sst->dma); + sst_dma_free(sst->dma); } EXPORT_SYMBOL_GPL(sst_dsp_free); -- cgit From 180cf794d4f5e0e82a4df30b8bacd9b472f80f44 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 19:25:55 +0100 Subject: ASoC: fsi: Deletion of unnecessary checks before the function call "clk_enable" The clk_enable() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/sh/fsi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 8869971d7884..d49f25f9efd3 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -820,12 +820,9 @@ static int fsi_clk_enable(struct device *dev, return ret; } - if (clock->xck) - clk_enable(clock->xck); - if (clock->ick) - clk_enable(clock->ick); - if (clock->div) - clk_enable(clock->div); + clk_enable(clock->xck); + clk_enable(clock->ick); + clk_enable(clock->div); clock->count++; } -- cgit From 4e3461d34f4cd632b403342ea1df33135e5e3ad3 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 3 Jan 2015 19:49:37 +0100 Subject: ASoC: Intel: Delete an unnecessary check before the function call "release_firmware" The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/intel/sst/sst_loader.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst/sst_loader.c b/sound/soc/intel/sst/sst_loader.c index b580f96e25e5..7888cd707853 100644 --- a/sound/soc/intel/sst/sst_loader.c +++ b/sound/soc/intel/sst/sst_loader.c @@ -324,8 +324,7 @@ void sst_firmware_load_cb(const struct firmware *fw, void *context) if (ctx->sst_state != SST_RESET || ctx->fw_in_mem != NULL) { - if (fw != NULL) - release_firmware(fw); + release_firmware(fw); mutex_unlock(&ctx->sst_lock); return; } -- cgit From 2b730cc38d3ca592b4f9f71989e7f0c79b37b3b3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 5 Jan 2015 10:18:21 +0100 Subject: ASoC: alc5632: Constify struct regmap_config and snd_soc_codec_driver The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make struct snd_soc_codec_driver const as well (snd_soc_register_codec() accepts pointer to const). Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/codecs/alc5632.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c index d1fdbc266631..07630260e1ba 100644 --- a/sound/soc/codecs/alc5632.c +++ b/sound/soc/codecs/alc5632.c @@ -1066,7 +1066,7 @@ static int alc5632_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_device_alc5632 = { +static const struct snd_soc_codec_driver soc_codec_device_alc5632 = { .probe = alc5632_probe, .resume = alc5632_resume, .set_bias_level = alc5632_set_bias_level, @@ -1080,7 +1080,7 @@ static struct snd_soc_codec_driver soc_codec_device_alc5632 = { .num_dapm_routes = ARRAY_SIZE(alc5632_dapm_routes), }; -static struct regmap_config alc5632_regmap = { +static const struct regmap_config alc5632_regmap = { .reg_bits = 8, .val_bits = 16, -- cgit From d883641f87a42cffcdbbdc664fce1def20ed02b6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 5 Jan 2015 10:18:22 +0100 Subject: ASoC: cs35l32: Constify struct regmap_config and snd_soc_codec_driver The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make struct snd_soc_codec_driver const as well (snd_soc_register_codec() accepts pointer to const). Signed-off-by: Krzysztof Kozlowski Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/cs35l32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c index ec55c590afd0..f2b8aad21274 100644 --- a/sound/soc/codecs/cs35l32.c +++ b/sound/soc/codecs/cs35l32.c @@ -264,7 +264,7 @@ static int cs35l32_codec_set_sysclk(struct snd_soc_codec *codec, CS35L32_MCLK_DIV2_MASK | CS35L32_MCLK_RATIO_MASK, val); } -static struct snd_soc_codec_driver soc_codec_dev_cs35l32 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs35l32 = { .set_sysclk = cs35l32_codec_set_sysclk, .dapm_widgets = cs35l32_dapm_widgets, @@ -288,7 +288,7 @@ static const struct reg_default cs35l32_monitor_patch[] = { { 0x00, 0x00 }, }; -static struct regmap_config cs35l32_regmap = { +static const struct regmap_config cs35l32_regmap = { .reg_bits = 8, .val_bits = 8, -- cgit From b5fbcbab50b4f8065666d3633f47722bf8969b34 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 5 Jan 2015 10:18:23 +0100 Subject: ASoC: cs42l52: Constify struct regmap_config and snd_soc_codec_driver The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make struct snd_soc_codec_driver const as well (snd_soc_register_codec() accepts pointer to const). Signed-off-by: Krzysztof Kozlowski Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l52.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c index 35fbef743fbe..1589e7a881d8 100644 --- a/sound/soc/codecs/cs42l52.c +++ b/sound/soc/codecs/cs42l52.c @@ -1103,7 +1103,7 @@ static int cs42l52_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_cs42l52 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs42l52 = { .probe = cs42l52_probe, .remove = cs42l52_remove, .set_bias_level = cs42l52_set_bias_level, @@ -1130,7 +1130,7 @@ static const struct reg_default cs42l52_threshold_patch[] = { }; -static struct regmap_config cs42l52_regmap = { +static const struct regmap_config cs42l52_regmap = { .reg_bits = 8, .val_bits = 8, -- cgit From cf0efa1c71c86b3ba731b9f3bad37ea4ceee6fbe Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 5 Jan 2015 10:18:24 +0100 Subject: ASoC: cs42l56: Constify struct regmap_config and snd_soc_codec_driver The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make struct snd_soc_codec_driver const as well (snd_soc_register_codec() accepts pointer to const). Signed-off-by: Krzysztof Kozlowski Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l56.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c index 2ddc7ac10ad7..cbc654fe48c7 100644 --- a/sound/soc/codecs/cs42l56.c +++ b/sound/soc/codecs/cs42l56.c @@ -1164,7 +1164,7 @@ static int cs42l56_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_cs42l56 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs42l56 = { .probe = cs42l56_probe, .remove = cs42l56_remove, .set_bias_level = cs42l56_set_bias_level, @@ -1179,7 +1179,7 @@ static struct snd_soc_codec_driver soc_codec_dev_cs42l56 = { .num_controls = ARRAY_SIZE(cs42l56_snd_controls), }; -static struct regmap_config cs42l56_regmap = { +static const struct regmap_config cs42l56_regmap = { .reg_bits = 8, .val_bits = 8, -- cgit From cd2ee8ad55a1728f291a760cece9ceac11462b9e Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 5 Jan 2015 10:18:25 +0100 Subject: ASoC: cs42l73: Constify struct regmap_config and snd_soc_codec_driver The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make struct snd_soc_codec_driver const as well (snd_soc_register_codec() accepts pointer to const). Signed-off-by: Krzysztof Kozlowski Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l73.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c index 7c55537c69cf..8ecedba79606 100644 --- a/sound/soc/codecs/cs42l73.c +++ b/sound/soc/codecs/cs42l73.c @@ -1347,7 +1347,7 @@ static int cs42l73_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_cs42l73 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs42l73 = { .probe = cs42l73_probe, .set_bias_level = cs42l73_set_bias_level, .suspend_bias_off = true, @@ -1361,7 +1361,7 @@ static struct snd_soc_codec_driver soc_codec_dev_cs42l73 = { .num_controls = ARRAY_SIZE(cs42l73_snd_controls), }; -static struct regmap_config cs42l73_regmap = { +static const struct regmap_config cs42l73_regmap = { .reg_bits = 8, .val_bits = 8, -- cgit From c0b363891816ea60d95a7dfcfc72f9955a7f1d32 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 5 Jan 2015 10:18:26 +0100 Subject: ASoC: wm8804: Constify struct regmap_config and snd_soc_codec_driver The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make struct snd_soc_codec_driver const as well (snd_soc_register_codec() accepts pointer to const). Signed-off-by: Krzysztof Kozlowski Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/wm8804.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index 1315f7642503..b2b0e68f707e 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -648,7 +648,7 @@ static struct snd_soc_dai_driver wm8804_dai = { .symmetric_rates = 1 }; -static struct snd_soc_codec_driver soc_codec_dev_wm8804 = { +static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = { .probe = wm8804_probe, .remove = wm8804_remove, .set_bias_level = wm8804_set_bias_level, @@ -664,7 +664,7 @@ static const struct of_device_id wm8804_of_match[] = { }; MODULE_DEVICE_TABLE(of, wm8804_of_match); -static struct regmap_config wm8804_regmap_config = { +static const struct regmap_config wm8804_regmap_config = { .reg_bits = 8, .val_bits = 8, -- cgit From b682d7baf11ab0d29d511632eb0195b5fa004295 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 5 Jan 2015 10:18:27 +0100 Subject: ASoC: wm8988: Constify struct regmap_config and snd_soc_codec_driver The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make struct snd_soc_codec_driver const as well (snd_soc_register_codec() accepts pointer to const). Signed-off-by: Krzysztof Kozlowski Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/wm8988.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index e418199155a8..d320c5251856 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c @@ -813,7 +813,7 @@ static int wm8988_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_wm8988 = { +static const struct snd_soc_codec_driver soc_codec_dev_wm8988 = { .probe = wm8988_probe, .set_bias_level = wm8988_set_bias_level, .suspend_bias_off = true, @@ -826,7 +826,7 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8988 = { .num_dapm_routes = ARRAY_SIZE(wm8988_dapm_routes), }; -static struct regmap_config wm8988_regmap = { +static const struct regmap_config wm8988_regmap = { .reg_bits = 7, .val_bits = 9, -- cgit From 27ad02f3b6452e0b650835438eb10ba76cb7dfaf Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 5 Jan 2015 10:18:28 +0100 Subject: ASoC: wm8804: Constify struct regmap_config and snd_soc_codec_driver The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make struct snd_soc_codec_driver (snd_soc_register_codec() accepts pointer to const) and array of default register values const as well. Signed-off-by: Krzysztof Kozlowski Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/wm8995.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index c280f0a3a424..120228b6b596 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c @@ -44,7 +44,7 @@ static const char *wm8995_supply_names[WM8995_NUM_SUPPLIES] = { "MICVDD" }; -static struct reg_default wm8995_reg_defaults[] = { +static const struct reg_default wm8995_reg_defaults[] = { { 0, 0x8995 }, { 5, 0x0100 }, { 16, 0x000b }, @@ -2190,7 +2190,7 @@ static struct snd_soc_dai_driver wm8995_dai[] = { } }; -static struct snd_soc_codec_driver soc_codec_dev_wm8995 = { +static const struct snd_soc_codec_driver soc_codec_dev_wm8995 = { .probe = wm8995_probe, .remove = wm8995_remove, .set_bias_level = wm8995_set_bias_level, @@ -2204,7 +2204,7 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8995 = { .num_dapm_routes = ARRAY_SIZE(wm8995_intercon), }; -static struct regmap_config wm8995_regmap = { +static const struct regmap_config wm8995_regmap = { .reg_bits = 16, .val_bits = 16, -- cgit From de7621e870d527e949b5b2351e599398e5fac9ee Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 13:56:07 +0100 Subject: ASoC: dmaengine: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the PCM itself is freed. There is no need to do this manually in the driver. Similarly there is also no need to do it on the pcm_new() error path as the PCM will be freed if a error is returned. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-generic-dmaengine-pcm.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index b329b84bc5af..4864392bfcba 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -200,11 +200,6 @@ static int dmaengine_pcm_open(struct snd_pcm_substream *substream) return snd_dmaengine_pcm_open(substream, chan); } -static void dmaengine_pcm_free(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static struct dma_chan *dmaengine_pcm_compat_request_channel( struct snd_soc_pcm_runtime *rtd, struct snd_pcm_substream *substream) @@ -283,8 +278,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) if (!pcm->chan[i]) { dev_err(rtd->platform->dev, "Missing dma channel for stream: %d\n", i); - ret = -EINVAL; - goto err_free; + return -EINVAL; } ret = snd_pcm_lib_preallocate_pages(substream, @@ -293,7 +287,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) prealloc_buffer_size, max_buffer_size); if (ret) - goto err_free; + return ret; /* * This will only return false if we know for sure that at least @@ -307,10 +301,6 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) } return 0; - -err_free: - dmaengine_pcm_free(rtd->pcm); - return ret; } static snd_pcm_uframes_t dmaengine_pcm_pointer( @@ -341,7 +331,6 @@ static const struct snd_soc_platform_driver dmaengine_pcm_platform = { }, .ops = &dmaengine_pcm_ops, .pcm_new = dmaengine_pcm_new, - .pcm_free = dmaengine_pcm_free, }; static const char * const dmaengine_pcm_dma_channel_names[] = { -- cgit From 12e29a075d4c0c9767261068cdcbfa4b346a451b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 13:56:08 +0100 Subject: ASoC: au1x: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the PCM itself is freed. There is no need to do this manually in the driver. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/au1x/dbdma2.c | 6 ------ sound/soc/au1x/dma.c | 6 ------ 2 files changed, 12 deletions(-) (limited to 'sound') diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index b06b8d8128c6..dd94fea72d5d 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -315,11 +315,6 @@ static struct snd_pcm_ops au1xpsc_pcm_ops = { .pointer = au1xpsc_pcm_pointer, }; -static void au1xpsc_pcm_free_dma_buffers(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; @@ -335,7 +330,6 @@ static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd) static struct snd_soc_platform_driver au1xpsc_soc_platform = { .ops = &au1xpsc_pcm_ops, .pcm_new = au1xpsc_pcm_new, - .pcm_free = au1xpsc_pcm_free_dma_buffers, }; static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c index 6ffaaff469c7..24cc7f40d87a 100644 --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c @@ -287,11 +287,6 @@ static struct snd_pcm_ops alchemy_pcm_ops = { .pointer = alchemy_pcm_pointer, }; -static void alchemy_pcm_free_dma_buffers(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; @@ -305,7 +300,6 @@ static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd) static struct snd_soc_platform_driver alchemy_pcm_soc_platform = { .ops = &alchemy_pcm_ops, .pcm_new = alchemy_pcm_new, - .pcm_free = alchemy_pcm_free_dma_buffers, }; static int alchemy_pcm_drvprobe(struct platform_device *pdev) -- cgit From 3a96878e6d01b70836cbf8a0e968619ef2e2aceb Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 13:56:10 +0100 Subject: ASoC: nuc900: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the PCM itself is freed. There is no need to do this manually in the driver. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/nuc900/nuc900-pcm.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c index b779a3d9b5dd..b809fa909e4d 100644 --- a/sound/soc/nuc900/nuc900-pcm.c +++ b/sound/soc/nuc900/nuc900-pcm.c @@ -306,11 +306,6 @@ static struct snd_pcm_ops nuc900_dma_ops = { .mmap = nuc900_dma_mmap, }; -static void nuc900_dma_free_dma_buffers(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; @@ -330,7 +325,6 @@ static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd) static struct snd_soc_platform_driver nuc900_soc_platform = { .ops = &nuc900_dma_ops, .pcm_new = nuc900_dma_new, - .pcm_free = nuc900_dma_free_dma_buffers, }; static int nuc900_soc_platform_probe(struct platform_device *pdev) -- cgit From ddf3335b3e716ab2161e4db5b70984aef35075a3 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 13:56:11 +0100 Subject: ASoC: rcar: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the PCM itself is freed. There is no need to do this manually in the driver. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 75308bbc2ce8..d9c81cda09f7 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1140,15 +1140,9 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); } -static void rsnd_pcm_free(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static struct snd_soc_platform_driver rsnd_soc_platform = { .ops = &rsnd_pcm_ops, .pcm_new = rsnd_pcm_new, - .pcm_free = rsnd_pcm_free, }; static const struct snd_soc_component_driver rsnd_soc_component = { -- cgit From 0db54e74a9e44afb92bc547277827258dbf5dc8f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 13:56:12 +0100 Subject: ASoC: sh: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the PCM itself is freed. There is no need to do this manually in the driver. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/sh/dma-sh7760.c | 6 ------ sound/soc/sh/fsi.c | 6 ------ sound/soc/sh/siu_pcm.c | 1 - 3 files changed, 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index a5b2c4ea90d9..fd11404a3bc7 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -305,11 +305,6 @@ static struct snd_pcm_ops camelot_pcm_ops = { .pointer = camelot_pos, }; -static void camelot_pcm_free(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int camelot_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; @@ -328,7 +323,6 @@ static int camelot_pcm_new(struct snd_soc_pcm_runtime *rtd) static struct snd_soc_platform_driver sh7760_soc_platform = { .ops = &camelot_pcm_ops, .pcm_new = camelot_pcm_new, - .pcm_free = camelot_pcm_free, }; static int sh7760_soc_platform_probe(struct platform_device *pdev) diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 8869971d7884..422faa93972b 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1765,11 +1765,6 @@ static struct snd_pcm_ops fsi_pcm_ops = { #define PREALLOC_BUFFER (32 * 1024) #define PREALLOC_BUFFER_MAX (32 * 1024) -static void fsi_pcm_free(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd) { return snd_pcm_lib_preallocate_pages_for_all( @@ -1821,7 +1816,6 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = { static struct snd_soc_platform_driver fsi_soc_platform = { .ops = &fsi_pcm_ops, .pcm_new = fsi_pcm_new, - .pcm_free = fsi_pcm_free, }; static const struct snd_soc_component_driver fsi_soc_component = { diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index 32eb6da2d2bd..82902f56e82f 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -589,7 +589,6 @@ static void siu_pcm_free(struct snd_pcm *pcm) tasklet_kill(&port_info->playback.tasklet); siu_free_port(port_info); - snd_pcm_lib_preallocate_free_for_all(pcm); dev_dbg(pcm->card->dev, "%s\n", __func__); } -- cgit From 691384503426f97f647e98eed85410eae71c2754 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 13:56:13 +0100 Subject: ASoC: txx9: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the PCM itself is freed. There is no need to do this manually in the driver. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/txx9/txx9aclc.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index 070e44e251ce..88eacfd83da6 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -282,11 +282,6 @@ static struct snd_pcm_ops txx9aclc_pcm_ops = { .pointer = txx9aclc_pcm_pointer, }; -static void txx9aclc_pcm_free_dma_buffers(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int txx9aclc_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; @@ -412,7 +407,6 @@ static struct snd_soc_platform_driver txx9aclc_soc_platform = { .remove = txx9aclc_pcm_remove, .ops = &txx9aclc_pcm_ops, .pcm_new = txx9aclc_pcm_new, - .pcm_free = txx9aclc_pcm_free_dma_buffers, }; static int txx9aclc_soc_platform_probe(struct platform_device *pdev) -- cgit From 057a1573fd1309a6b3a039f9cd75b4e90f7f6cf4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 11:30:35 +0100 Subject: ASoC: broadwell: Drop unnecessary snd_soc_dapm_enable() calls DAPM widgets are enabled by default, there is no need to enable them unless they have previously been explicitly disabled. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/intel/broadwell.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c index 7cf95d5d5d80..9cf7d01479ad 100644 --- a/sound/soc/intel/broadwell.c +++ b/sound/soc/intel/broadwell.c @@ -140,8 +140,6 @@ static struct snd_soc_ops broadwell_rt286_ops = { static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; @@ -155,14 +153,6 @@ static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd) return ret; } - /* always connected - check HP for jack detect */ - snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); - snd_soc_dapm_enable_pin(dapm, "Speaker"); - snd_soc_dapm_enable_pin(dapm, "Mic Jack"); - snd_soc_dapm_enable_pin(dapm, "Line Jack"); - snd_soc_dapm_enable_pin(dapm, "DMIC1"); - snd_soc_dapm_enable_pin(dapm, "DMIC2"); - return 0; } -- cgit From 7a81140b0ead01fcb27e6167b1015b06c36acbd0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 11:23:44 +0100 Subject: ASoC: byt-rt5640: Fix snd_soc_dapm_ignore_suspend() calls To work properly snd_soc_dapm_ignore_suspend() needs to be called on endpoint widgets. In this case those are the board level Speaker and Headphone widgets and not the CODEC output widgets that are connected to them. Signed-off-by: Lars-Peter Clausen Acked-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/intel/byt-rt5640.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/byt-rt5640.c b/sound/soc/intel/byt-rt5640.c index 0cba7830c5e9..a51856e91826 100644 --- a/sound/soc/intel/byt-rt5640.c +++ b/sound/soc/intel/byt-rt5640.c @@ -171,13 +171,8 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) return ret; } - snd_soc_dapm_ignore_suspend(dapm, "HPOL"); - snd_soc_dapm_ignore_suspend(dapm, "HPOR"); - - snd_soc_dapm_ignore_suspend(dapm, "SPOLP"); - snd_soc_dapm_ignore_suspend(dapm, "SPOLN"); - snd_soc_dapm_ignore_suspend(dapm, "SPORP"); - snd_soc_dapm_ignore_suspend(dapm, "SPORN"); + snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone"); + snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker"); return ret; } -- cgit From b93673be48cef887551d109683922bcc15f40d27 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 11:23:45 +0100 Subject: ASoC: byt-rt5640: Register microphone routes with the card DAPM context Board level DAPM elements should be registered with the card's DAPM context rather than the CODEC's DAPM context. Signed-off-by: Lars-Peter Clausen Acked-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/intel/byt-rt5640.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/byt-rt5640.c b/sound/soc/intel/byt-rt5640.c index a51856e91826..354eaad886e1 100644 --- a/sound/soc/intel/byt-rt5640.c +++ b/sound/soc/intel/byt-rt5640.c @@ -132,7 +132,6 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) { int ret; struct snd_soc_codec *codec = runtime->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_card *card = runtime->card; const struct snd_soc_dapm_route *custom_map; int num_routes; @@ -161,7 +160,7 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map); } - ret = snd_soc_dapm_add_routes(dapm, custom_map, num_routes); + ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); if (ret) return ret; -- cgit From 8686f251e4823a4196bae86f22dab8cfd3b454cc Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 2 Jan 2015 13:56:09 +0100 Subject: ASoC: intel: Remove unnecessary snd_pcm_lib_preallocate_free_for_all() The ALSA core takes care that all preallocated memory is freed when the PCM itself is freed. There is no need to do this manually in the driver. Signed-off-by: Lars-Peter Clausen Acked-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/intel/sst-baytrail-pcm.c | 6 ------ sound/soc/intel/sst-haswell-pcm.c | 6 ------ sound/soc/intel/sst-mfld-platform-pcm.c | 7 ------- 3 files changed, 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst-baytrail-pcm.c b/sound/soc/intel/sst-baytrail-pcm.c index 3bb6288d8b4d..224c49c9f135 100644 --- a/sound/soc/intel/sst-baytrail-pcm.c +++ b/sound/soc/intel/sst-baytrail-pcm.c @@ -320,11 +320,6 @@ static struct snd_pcm_ops sst_byt_pcm_ops = { .mmap = sst_byt_pcm_mmap, }; -static void sst_byt_pcm_free(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; @@ -403,7 +398,6 @@ static struct snd_soc_platform_driver byt_soc_platform = { .remove = sst_byt_pcm_remove, .ops = &sst_byt_pcm_ops, .pcm_new = sst_byt_pcm_new, - .pcm_free = sst_byt_pcm_free, }; static const struct snd_soc_component_driver byt_dai_component = { diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index 619525200705..13f156b4a612 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c @@ -735,11 +735,6 @@ static void hsw_pcm_free_modules(struct hsw_priv_data *pdata) } } -static void hsw_pcm_free(struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; @@ -936,7 +931,6 @@ static struct snd_soc_platform_driver hsw_soc_platform = { .remove = hsw_pcm_remove, .ops = &hsw_pcm_ops, .pcm_new = hsw_pcm_new, - .pcm_free = hsw_pcm_free, }; static const struct snd_soc_component_driver hsw_dai_component = { diff --git a/sound/soc/intel/sst-mfld-platform-pcm.c b/sound/soc/intel/sst-mfld-platform-pcm.c index a1a8d9d91539..7523cbef8780 100644 --- a/sound/soc/intel/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/sst-mfld-platform-pcm.c @@ -643,12 +643,6 @@ static struct snd_pcm_ops sst_platform_ops = { .pointer = sst_platform_pcm_pointer, }; -static void sst_pcm_free(struct snd_pcm *pcm) -{ - dev_dbg(pcm->dev, "sst_pcm_free called\n"); - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *dai = rtd->cpu_dai; @@ -679,7 +673,6 @@ static struct snd_soc_platform_driver sst_soc_platform_drv = { .ops = &sst_platform_ops, .compr_ops = &sst_platform_compr_ops, .pcm_new = sst_pcm_new, - .pcm_free = sst_pcm_free, }; static const struct snd_soc_component_driver sst_component = { -- cgit From 059d3dc6e5e8d4a62803eb3ad01b34fa3f714675 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:10 +0100 Subject: ASoC: sam9g20_wm8731: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Acked-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/atmel/sam9g20_wm8731.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'sound') diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index 66b66d0e7514..98ca6341147b 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -64,33 +64,6 @@ static struct clk *mclk; -static int at91sam9g20ek_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; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret; - - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - - /* set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - - return 0; -} - -static struct snd_soc_ops at91sam9g20ek_ops = { - .hw_params = at91sam9g20ek_hw_params, -}; - static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card, struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level) @@ -173,7 +146,8 @@ static struct snd_soc_dai_link at91sam9g20ek_dai = { .init = at91sam9g20ek_wm8731_init, .platform_name = "at91rm9200_ssc.0", .codec_name = "wm8731.0-001b", - .ops = &at91sam9g20ek_ops, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, }; static struct snd_soc_card snd_soc_at91sam9g20ek = { -- cgit From b4508d0f95fa4aaed889549e31391641d675d4bb Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:11 +0100 Subject: ASoC: db1200: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/au1x/db1200.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/soc/au1x/db1200.c b/sound/soc/au1x/db1200.c index a747ac0b399f..c75995f2779c 100644 --- a/sound/soc/au1x/db1200.c +++ b/sound/soc/au1x/db1200.c @@ -91,27 +91,12 @@ static int db1200_i2s_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret; /* WM8731 has its own 12MHz crystal */ snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, 12000000, SND_SOC_CLOCK_IN); - /* codec is bitclock and lrclk master */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - goto out; - - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - goto out; - - ret = 0; -out: - return ret; + return 0; } static struct snd_soc_ops db1200_i2s_wm8731_ops = { @@ -125,6 +110,8 @@ static struct snd_soc_dai_link db1200_i2s_dai = { .cpu_dai_name = "au1xpsc_i2s.1", .platform_name = "au1xpsc-pcm.1", .codec_name = "wm8731.0-001b", + .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &db1200_i2s_wm8731_ops, }; -- cgit From 4de59dbd28565ad1074d2bcf294a0a4b41c64e07 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:12 +0100 Subject: ASoC: eureka-tlv320: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/fsl/eukrea-tlv320.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c index 9ce70fc67b09..8c9e9006dd84 100644 --- a/sound/soc/fsl/eukrea-tlv320.c +++ b/sound/soc/fsl/eukrea-tlv320.c @@ -42,25 +42,6 @@ static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int ret; - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); - /* fsl_ssi lacks the set_fmt ops. */ - if (ret && ret != -ENOTSUPP) { - dev_err(cpu_dai->dev, - "Failed to set the cpu dai format.\n"); - return ret; - } - - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); - if (ret) { - dev_err(cpu_dai->dev, - "Failed to set the codec format.\n"); - return ret; - } - ret = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK, SND_SOC_CLOCK_OUT); if (ret) { @@ -91,6 +72,8 @@ static struct snd_soc_dai_link eukrea_tlv320_dai = { .name = "tlv320aic23", .stream_name = "TLV320AIC23", .codec_dai_name = "tlv320aic23-hifi", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &eukrea_tlv320_snd_ops, }; -- cgit From dea53bd36811d6b117a497eb91b2e4a54ef73548 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:13 +0100 Subject: ASoC: mx27vis-aci32x4: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/fsl/mx27vis-aic32x4.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/mx27vis-aic32x4.c b/sound/soc/fsl/mx27vis-aic32x4.c index b1ced7b8d80c..198eeb3f3f7a 100644 --- a/sound/soc/fsl/mx27vis-aic32x4.c +++ b/sound/soc/fsl/mx27vis-aic32x4.c @@ -55,16 +55,6 @@ static int mx27vis_aic32x4_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int ret; - u32 dai_format; - - dai_format = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM; - - /* set codec DAI configuration */ - snd_soc_dai_set_fmt(codec_dai, dai_format); - - /* set cpu DAI configuration */ - snd_soc_dai_set_fmt(cpu_dai, dai_format); ret = snd_soc_dai_set_sysclk(codec_dai, 0, 25000000, SND_SOC_CLOCK_OUT); @@ -164,6 +154,8 @@ static struct snd_soc_dai_link mx27vis_aic32x4_dai = { .platform_name = "imx-ssi.0", .codec_name = "tlv320aic32x4.0-0018", .cpu_dai_name = "imx-ssi.0", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &mx27vis_aic32x4_snd_ops, }; -- cgit From 734890a6c99ee81b935164963c03fc8bbf3f821b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:14 +0100 Subject: ASoC: wm1133-ev1: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/fsl/wm1133-ev1.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c index 804749a6c61e..d072bd13db09 100644 --- a/sound/soc/fsl/wm1133-ev1.c +++ b/sound/soc/fsl/wm1133-ev1.c @@ -87,7 +87,6 @@ static int wm1133_ev1_hw_params(struct snd_pcm_substream *substream, snd_pcm_format_t format = params_format(params); unsigned int rate = params_rate(params); unsigned int channels = params_channels(params); - u32 dai_format; /* find the correct audio parameters */ for (i = 0; i < ARRAY_SIZE(wm8350_audio); i++) { @@ -104,15 +103,6 @@ static int wm1133_ev1_hw_params(struct snd_pcm_substream *substream, /* codec FLL input is 14.75 MHz from MCLK */ snd_soc_dai_set_pll(codec_dai, 0, 0, 14750000, wm8350_audio[i].sysclk); - dai_format = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM; - - /* set codec DAI configuration */ - snd_soc_dai_set_fmt(codec_dai, dai_format); - - /* set cpu DAI configuration */ - snd_soc_dai_set_fmt(cpu_dai, dai_format); - /* TODO: The SSI driver should figure this out for us */ switch (channels) { case 2: @@ -244,6 +234,8 @@ static struct snd_soc_dai_link wm1133_ev1_dai = { .init = wm1133_ev1_init, .ops = &wm1133_ev1_ops, .symmetric_rates = 1, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, }; static struct snd_soc_card wm1133_ev1 = { -- cgit From bc6a5d649bda56c579853bfe710db88bf38da522 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:15 +0100 Subject: ASoC: mxs-sgtl5000: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/mxs/mxs-sgtl5000.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'sound') diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c index 6f1916b71815..6e6fce6a14ba 100644 --- a/sound/soc/mxs/mxs-sgtl5000.c +++ b/sound/soc/mxs/mxs-sgtl5000.c @@ -36,7 +36,7 @@ static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; unsigned int rate = params_rate(params); - u32 dai_format, mclk; + u32 mclk; int ret; /* sgtl5000 does not support 512*rate when in 96000 fs */ @@ -65,26 +65,6 @@ static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream, return ret; } - /* set codec to slave mode */ - dai_format = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS; - - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, dai_format); - if (ret) { - dev_err(codec_dai->dev, "Failed to set dai format to %08x\n", - dai_format); - return ret; - } - - /* set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, dai_format); - if (ret) { - dev_err(cpu_dai->dev, "Failed to set dai format to %08x\n", - dai_format); - return ret; - } - return 0; } @@ -92,17 +72,22 @@ static struct snd_soc_ops mxs_sgtl5000_hifi_ops = { .hw_params = mxs_sgtl5000_hw_params, }; +#define MXS_SGTL5000_DAI_FMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | \ + SND_SOC_DAIFMT_CBS_CFS) + static struct snd_soc_dai_link mxs_sgtl5000_dai[] = { { .name = "HiFi Tx", .stream_name = "HiFi Playback", .codec_dai_name = "sgtl5000", + .dai_fmt = MXS_SGTL5000_DAI_FMT, .ops = &mxs_sgtl5000_hifi_ops, .playback_only = true, }, { .name = "HiFi Rx", .stream_name = "HiFi Capture", .codec_dai_name = "sgtl5000", + .dai_fmt = MXS_SGTL5000_DAI_FMT, .ops = &mxs_sgtl5000_hifi_ops, .capture_only = true, }, -- cgit From 3aa273e3f65455066aa7338845e11910ba2bae12 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:16 +0100 Subject: ASoC: ams-delta: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/ams-delta.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 4c6afb75eea6..706613077c15 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -412,21 +412,7 @@ static struct tty_ldisc_ops cx81801_ops = { * over the modem port. */ -static int ams_delta_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - /* Set cpu DAI configuration */ - return snd_soc_dai_set_fmt(rtd->cpu_dai, - SND_SOC_DAIFMT_DSP_A | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); -} - -static struct snd_soc_ops ams_delta_ops = { - .hw_params = ams_delta_hw_params, -}; +static struct snd_soc_ops ams_delta_ops; /* Digital mute implemented using modem/CPU multiplexer. @@ -546,6 +532,8 @@ static struct snd_soc_dai_link ams_delta_dai_link = { .platform_name = "omap-mcbsp.1", .codec_name = "cx20442-codec", .ops = &ams_delta_ops, + .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, }; /* Audio card driver */ -- cgit From a8bd0ee5587148cd1a23302ef37bf3f236fe6705 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:17 +0100 Subject: ASoC: raumfeld: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/raumfeld.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/raumfeld.c b/sound/soc/pxa/raumfeld.c index 083706595495..552b763005ed 100644 --- a/sound/soc/pxa/raumfeld.c +++ b/sound/soc/pxa/raumfeld.c @@ -88,7 +88,7 @@ static int raumfeld_cs4270_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int fmt, clk = 0; + unsigned int clk = 0; int ret = 0; switch (params_rate(params)) { @@ -112,15 +112,6 @@ static int raumfeld_cs4270_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - fmt = SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS; - - /* setup the CODEC DAI */ - ret = snd_soc_dai_set_fmt(codec_dai, fmt); - if (ret < 0) - return ret; - ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk, 0); if (ret < 0) return ret; @@ -130,10 +121,6 @@ static int raumfeld_cs4270_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) - return ret; - ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_DIV_SCR, 4); if (ret < 0) return ret; @@ -169,9 +156,8 @@ static int raumfeld_ak4104_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; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int fmt, ret = 0, clk = 0; + int ret = 0, clk = 0; switch (params_rate(params)) { case 44100: @@ -194,22 +180,11 @@ static int raumfeld_ak4104_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF; - - /* setup the CODEC DAI */ - ret = snd_soc_dai_set_fmt(codec_dai, fmt | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - /* setup the CPU DAI */ ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, 0, clk); if (ret < 0) return ret; - ret = snd_soc_dai_set_fmt(cpu_dai, fmt | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_DIV_SCR, 4); if (ret < 0) return ret; @@ -233,6 +208,9 @@ static struct snd_soc_ops raumfeld_ak4104_ops = { .platform_name = "pxa-pcm-audio", \ .codec_dai_name = "cs4270-hifi", \ .codec_name = "cs4270.0-0048", \ + .dai_fmt = SND_SOC_DAIFMT_I2S | \ + SND_SOC_DAIFMT_NB_NF | \ + SND_SOC_DAIFMT_CBS_CFS, \ .ops = &raumfeld_cs4270_ops, \ } @@ -243,6 +221,9 @@ static struct snd_soc_ops raumfeld_ak4104_ops = { .cpu_dai_name = "pxa-ssp-dai.1", \ .codec_dai_name = "ak4104-hifi", \ .platform_name = "pxa-pcm-audio", \ + .dai_fmt = SND_SOC_DAIFMT_I2S | \ + SND_SOC_DAIFMT_NB_NF | \ + SND_SOC_DAIFMT_CBS_CFS, \ .ops = &raumfeld_ak4104_ops, \ .codec_name = "spi0.0", \ } -- cgit From 132c30969b9346a628f597804d2343b6df493693 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:18 +0100 Subject: ASoC: zylonite: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/zylonite.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c index 23bf991e95d5..8f301c72ee5e 100644 --- a/sound/soc/pxa/zylonite.c +++ b/sound/soc/pxa/zylonite.c @@ -130,16 +130,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - return 0; } @@ -172,6 +162,8 @@ static struct snd_soc_dai_link zylonite_dai[] = { .platform_name = "pxa-pcm-audio", .cpu_dai_name = "pxa-ssp-dai.2", .codec_dai_name = "wm9713-voice", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &zylonite_voice_ops, }, }; -- cgit From 0af76f918adb8487a911bc136a6f1b12c46cd056 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:19 +0100 Subject: ASoC: goni_wm8994: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/goni_wm8994.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/goni_wm8994.c b/sound/soc/samsung/goni_wm8994.c index 3b527dcfc0aa..fad56b9e7369 100644 --- a/sound/soc/samsung/goni_wm8994.c +++ b/sound/soc/samsung/goni_wm8994.c @@ -136,22 +136,9 @@ static int goni_hifi_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; unsigned int pll_out = 24000000; int ret = 0; - /* set the cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - /* set the codec FLL */ ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, 0, pll_out, params_rate(params) * 256); @@ -182,12 +169,6 @@ static int goni_voice_hw_params(struct snd_pcm_substream *substream, if (params_rate(params) != 8000) return -EINVAL; - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J | - SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - /* set the codec FLL */ ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL2, 0, pll_out, params_rate(params) * 256); @@ -234,6 +215,8 @@ static struct snd_soc_dai_link goni_dai[] = { .codec_dai_name = "wm8994-aif1", .platform_name = "samsung-i2s.0", .codec_name = "wm8994-codec.0-001a", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .init = goni_wm8994_init, .ops = &goni_hifi_ops, }, { @@ -242,6 +225,8 @@ static struct snd_soc_dai_link goni_dai[] = { .cpu_dai_name = "goni-voice-dai", .codec_dai_name = "wm8994-aif2", .codec_name = "wm8994-codec.0-001a", + .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_IB_IF | + SND_SOC_DAIFMT_CBM_CFM, .ops = &goni_voice_ops, }, }; -- cgit From 5cc10b9b77c234e89e7c4aca56d8a3c571111955 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:20 +0100 Subject: ASoC: h1940_uda1380: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/h1940_uda1380.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c index f2d7980d7ddc..59b044255b78 100644 --- a/sound/soc/samsung/h1940_uda1380.c +++ b/sound/soc/samsung/h1940_uda1380.c @@ -76,7 +76,6 @@ static int h1940_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai = rtd->codec_dai; int div; int ret; unsigned int rate = params_rate(params); @@ -95,18 +94,6 @@ static int h1940_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - /* set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - /* select clock source */ ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate, SND_SOC_CLOCK_OUT); @@ -207,6 +194,8 @@ static struct snd_soc_dai_link h1940_uda1380_dai[] = { .init = h1940_uda1380_init, .platform_name = "s3c24xx-iis", .codec_name = "uda1380-codec.0-001a", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &h1940_ops, }, }; -- cgit From 72303cafcb5cc9fd1227d0edd458f62bef1a397e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:21 +0100 Subject: ASoC: jive_wm8750: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/jive_wm8750.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/jive_wm8750.c b/sound/soc/samsung/jive_wm8750.c index b5f6abd9d221..6c3b359bb4c1 100644 --- a/sound/soc/samsung/jive_wm8750.c +++ b/sound/soc/samsung/jive_wm8750.c @@ -61,20 +61,6 @@ static int jive_hw_params(struct snd_pcm_substream *substream, s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params), s3c_i2sv2_get_clock(cpu_dai)); - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - /* set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - /* set the codec system clock for DAC and ADC */ ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk, SND_SOC_CLOCK_IN); @@ -121,6 +107,8 @@ static struct snd_soc_dai_link jive_dai = { .platform_name = "s3c2412-i2s", .codec_name = "wm8750.0-001a", .init = jive_wm8750_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &jive_ops, }; -- cgit From e16514d931635640906ab2810c98f6a9047cb87a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:22 +0100 Subject: ASoC: neo1973_wm8753: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/neo1973_wm8753.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/neo1973_wm8753.c b/sound/soc/samsung/neo1973_wm8753.c index 9b4a09f14b6c..65602b935377 100644 --- a/sound/soc/samsung/neo1973_wm8753.c +++ b/sound/soc/samsung/neo1973_wm8753.c @@ -70,20 +70,6 @@ static int neo1973_hifi_hw_params(struct snd_pcm_substream *substream, break; } - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, - SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - - /* set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, - SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - /* set the codec system clock for DAC and ADC */ ret = snd_soc_dai_set_sysclk(codec_dai, WM8753_MCLK, pll_out, SND_SOC_CLOCK_IN); @@ -151,13 +137,6 @@ static int neo1973_voice_hw_params(struct snd_pcm_substream *substream, pcmdiv = WM8753_PCM_DIV_6; /* 2.048 MHz */ - /* todo: gg check mode (DSP_B) against CSR datasheet */ - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - /* set the codec system clock for DAC and ADC */ ret = snd_soc_dai_set_sysclk(codec_dai, WM8753_PCMCLK, 12288000, SND_SOC_CLOCK_IN); @@ -300,6 +279,8 @@ static struct snd_soc_dai_link neo1973_dai[] = { .cpu_dai_name = "s3c24xx-iis", .codec_dai_name = "wm8753-hifi", .codec_name = "wm8753.0-001a", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, .init = neo1973_wm8753_init, .ops = &neo1973_hifi_ops, }, @@ -309,6 +290,8 @@ static struct snd_soc_dai_link neo1973_dai[] = { .cpu_dai_name = "bt-sco-pcm", .codec_dai_name = "wm8753-voice", .codec_name = "wm8753.0-001a", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &neo1973_voice_ops, }, }; -- cgit From 5f0acedddf533c086edf29eefdc743dc1e756b5d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:23 +0100 Subject: ASoC: rx1950_uda1380: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/rx1950_uda1380.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c index 37688ebbb2b4..873f2cb4bebe 100644 --- a/sound/soc/samsung/rx1950_uda1380.c +++ b/sound/soc/samsung/rx1950_uda1380.c @@ -89,6 +89,8 @@ static struct snd_soc_dai_link rx1950_uda1380_dai[] = { .init = rx1950_uda1380_init, .platform_name = "s3c24xx-iis", .codec_name = "uda1380-codec.0-001a", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &rx1950_ops, }, }; @@ -154,7 +156,6 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai = rtd->codec_dai; int div; int ret; unsigned int rate = params_rate(params); @@ -181,18 +182,6 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - /* set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - /* select clock source */ ret = snd_soc_dai_set_sysclk(cpu_dai, clk_source, rate, SND_SOC_CLOCK_OUT); -- cgit From d27e51dade482acdf67021c12d692041a35bea77 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:24 +0100 Subject: ASoC: s3c24xx_simtec: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/s3c24xx_simtec.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c24xx_simtec.c b/sound/soc/samsung/s3c24xx_simtec.c index 2c015f62ead6..dcc008d1e1ab 100644 --- a/sound/soc/samsung/s3c24xx_simtec.c +++ b/sound/soc/samsung/s3c24xx_simtec.c @@ -169,24 +169,6 @@ static int simtec_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int ret; - /* Set the CODEC as the bus clock master, I2S */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); - if (ret) { - pr_err("%s: failed set cpu dai format\n", __func__); - return ret; - } - - /* Set the CODEC as the bus clock master */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); - if (ret) { - pr_err("%s: failed set codec dai format\n", __func__); - return ret; - } - ret = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK, SND_SOC_CLOCK_IN); if (ret) { @@ -320,6 +302,8 @@ int simtec_audio_core_probe(struct platform_device *pdev, int ret; card->dai_link->ops = &simtec_snd_ops; + card->dai_link->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM; pdata = pdev->dev.platform_data; if (!pdata) { -- cgit From 517b9a2a90676aeeefc7e2b8508fe4260e02c432 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:25 +0100 Subject: ASoC: s3c24xx_uda134x: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/s3c24xx_uda134x.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c24xx_uda134x.c b/sound/soc/samsung/s3c24xx_uda134x.c index 9c6f7db56f60..50849e137fc0 100644 --- a/sound/soc/samsung/s3c24xx_uda134x.c +++ b/sound/soc/samsung/s3c24xx_uda134x.c @@ -173,16 +173,6 @@ static int s3c24xx_uda134x_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - ret = snd_soc_dai_set_sysclk(cpu_dai, clk_source , clk, SND_SOC_CLOCK_IN); if (ret < 0) @@ -223,6 +213,8 @@ static struct snd_soc_dai_link s3c24xx_uda134x_dai_link = { .codec_name = "uda134x-codec", .codec_dai_name = "uda134x-hifi", .cpu_dai_name = "s3c24xx-iis", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &s3c24xx_uda134x_ops, .platform_name = "s3c24xx-iis", }; -- cgit From 10756c2770d7f4758e36d2a9e37ff2637001d610 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:26 +0100 Subject: ASoC: smartq_wm8987: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/smartq_wm8987.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c index 9b0ffacab790..8291d2a5f152 100644 --- a/sound/soc/samsung/smartq_wm8987.c +++ b/sound/soc/samsung/smartq_wm8987.c @@ -56,20 +56,6 @@ static int smartq_hifi_hw_params(struct snd_pcm_substream *substream, break; } - /* set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - /* set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - /* Use PCLK for I2S signal generation */ ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_RCLKSRC_0, 0, SND_SOC_CLOCK_IN); @@ -199,6 +185,8 @@ static struct snd_soc_dai_link smartq_dai[] = { .platform_name = "samsung-i2s.0", .codec_name = "wm8750.0-0x1a", .init = smartq_wm8987_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &smartq_hifi_ops, }, }; -- cgit From 7a57ca2362a55c34b96d90539dd8b7cb6c1c09a1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:27 +0100 Subject: ASoC: smdk_wm8580: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/smdk_wm8580.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/smdk_wm8580.c b/sound/soc/samsung/smdk_wm8580.c index b1a519f83b29..17a2f717ec02 100644 --- a/sound/soc/samsung/smdk_wm8580.c +++ b/sound/soc/samsung/smdk_wm8580.c @@ -32,7 +32,6 @@ static int smdk_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 *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; unsigned int pll_out; int bfs, rfs, ret; @@ -77,20 +76,6 @@ static int smdk_hw_params(struct snd_pcm_substream *substream, } pll_out = params_rate(params) * rfs; - /* Set the Codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S - | SND_SOC_DAIFMT_NB_NF - | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - - /* Set the AP DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S - | SND_SOC_DAIFMT_NB_NF - | SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - return ret; - /* Set WM8580 to drive MCLK from its PLLA */ ret = snd_soc_dai_set_clkdiv(codec_dai, WM8580_MCLK, WM8580_CLKSRC_PLLA); @@ -168,6 +153,9 @@ enum { SEC_PLAYBACK, }; +#define SMDK_DAI_FMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | \ + SND_SOC_DAIFMT_CBM_CFM) + static struct snd_soc_dai_link smdk_dai[] = { [PRI_PLAYBACK] = { /* Primary Playback i/f */ .name = "WM8580 PAIF RX", @@ -176,6 +164,7 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8580-hifi-playback", .platform_name = "samsung-i2s.0", .codec_name = "wm8580.0-001b", + .dai_fmt = SMDK_DAI_FMT, .ops = &smdk_ops, }, [PRI_CAPTURE] = { /* Primary Capture i/f */ @@ -185,6 +174,7 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8580-hifi-capture", .platform_name = "samsung-i2s.0", .codec_name = "wm8580.0-001b", + .dai_fmt = SMDK_DAI_FMT, .init = smdk_wm8580_init_paiftx, .ops = &smdk_ops, }, @@ -195,6 +185,7 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8580-hifi-playback", .platform_name = "samsung-i2s-sec", .codec_name = "wm8580.0-001b", + .dai_fmt = SMDK_DAI_FMT, .ops = &smdk_ops, }, }; -- cgit From 6a5794f2c653e78127123b3cd266b3c4d4c50606 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:28 +0100 Subject: ASoC: smdk_wm8570pcm: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/smdk_wm8580pcm.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/smdk_wm8580pcm.c b/sound/soc/samsung/smdk_wm8580pcm.c index 05c609c62de9..6deec5234c92 100644 --- a/sound/soc/samsung/smdk_wm8580pcm.c +++ b/sound/soc/samsung/smdk_wm8580pcm.c @@ -62,20 +62,6 @@ static int smdk_wm8580_pcm_hw_params(struct snd_pcm_substream *substream, rfs = mclk_freq / params_rate(params) / 2; - /* Set the codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B - | SND_SOC_DAIFMT_IB_NF - | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - /* Set the cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_B - | SND_SOC_DAIFMT_IB_NF - | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - if (mclk_freq == xtal_freq) { ret = snd_soc_dai_set_sysclk(codec_dai, WM8580_CLKSRC_MCLK, mclk_freq, SND_SOC_CLOCK_IN); @@ -121,6 +107,9 @@ static struct snd_soc_ops smdk_wm8580_pcm_ops = { .hw_params = smdk_wm8580_pcm_hw_params, }; +#define SMDK_DAI_FMT (SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF | \ + SND_SOC_DAIFMT_CBS_CFS) + static struct snd_soc_dai_link smdk_dai[] = { { .name = "WM8580 PAIF PCM RX", @@ -129,6 +118,7 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8580-hifi-playback", .platform_name = "samsung-audio", .codec_name = "wm8580.0-001b", + .dai_fmt = SMDK_DAI_FMT, .ops = &smdk_wm8580_pcm_ops, }, { .name = "WM8580 PAIF PCM TX", @@ -137,6 +127,7 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8580-hifi-capture", .platform_name = "samsung-pcm.0", .codec_name = "wm8580.0-001b", + .dai_fmt = SMDK_DAI_FMT, .ops = &smdk_wm8580_pcm_ops, }, }; -- cgit From fce20bf879dd5ce309c593c91bbb7b5e6ffd22e7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:29 +0100 Subject: ASoC: smdk_wm8994pcm: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/smdk_wm8994pcm.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/smdk_wm8994pcm.c b/sound/soc/samsung/smdk_wm8994pcm.c index c470e8eed6e1..b1c89ec2d999 100644 --- a/sound/soc/samsung/smdk_wm8994pcm.c +++ b/sound/soc/samsung/smdk_wm8994pcm.c @@ -68,20 +68,6 @@ static int smdk_wm8994_pcm_hw_params(struct snd_pcm_substream *substream, mclk_freq = params_rate(params) * rfs; - /* Set the codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B - | SND_SOC_DAIFMT_IB_NF - | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - /* Set the cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_B - | SND_SOC_DAIFMT_IB_NF - | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, mclk_freq, SND_SOC_CLOCK_IN); if (ret < 0) @@ -118,6 +104,8 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8994-aif1", .platform_name = "samsung-pcm.0", .codec_name = "wm8994-codec", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF | + SND_SOC_DAIFMT_CBS_CFS, .ops = &smdk_wm8994_pcm_ops, }, }; -- cgit From 9cb2a25ce68aec15d5d940f5d3040bd66ca688c7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 1 Jan 2015 17:16:30 +0100 Subject: ASoC: migor: Use static DAI format setup Set the dai_fmt field in the dai_link struct instead of manually calling snd_soc_dai_fmt(). This makes the code cleaner and shorter. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/sh/migor.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/migor.c b/sound/soc/sh/migor.c index c58c2529f103..82f582344fe7 100644 --- a/sound/soc/sh/migor.c +++ b/sound/soc/sh/migor.c @@ -63,16 +63,6 @@ static int migor_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_NB_IF | - SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_fmt(rtd->cpu_dai, SND_SOC_DAIFMT_NB_IF | - SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - return ret; - codec_freq = rate * 512; /* * This propagates the parent frequency change to children and @@ -144,6 +134,8 @@ static struct snd_soc_dai_link migor_dai = { .codec_dai_name = "wm8978-hifi", .platform_name = "siu-pcm-audio", .codec_name = "wm8978.0-001a", + .dai_fmt = SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_CBS_CFS, .ops = &migor_dai_ops, }; -- cgit From 7491831f4f034e2d76326518145da9525dd90932 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Tue, 6 Jan 2015 10:21:20 +0100 Subject: ASoC: atmel: sam9g20_wm8731: remove useless include A mach/ header is included but never used. Simply remove it. Signed-off-by: Alexandre Belloni Acked-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/atmel/sam9g20_wm8731.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index 66b66d0e7514..531728975bbb 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -47,7 +47,6 @@ #include #include -#include #include "../codecs/wm8731.h" #include "atmel-pcm.h" -- cgit From fcf6c5ea7abd42cfc2dde0ff0451b209951de9b4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 15 Dec 2014 13:08:48 +0000 Subject: ASoC: dapm: Don't use async I/O The only user of the async I/O support in ASoC is SPI which was using it to avoid needless context thrashing and minimise controller runtime PM bounces. The SPI framework has now been enhanced so that even normal spi_sync() calls won't suffer these effects so we don't need to handle this in ASoC and in fact it can be more efficient not to since we don't need to set up and tear down the buffers needed to manage asynchronous I/O. The async completions that DAPM does are left in place so drivers can use them, they are very cheap if there is no asynchronous work queued. Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index ea496842ee83..0be3ca52eff3 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -517,8 +517,8 @@ static int soc_dapm_update_bits(struct snd_soc_dapm_context *dapm, { if (!dapm->component) return -EIO; - return snd_soc_component_update_bits_async(dapm->component, reg, - mask, value); + return snd_soc_component_update_bits(dapm->component, reg, + mask, value); } static int soc_dapm_test_bits(struct snd_soc_dapm_context *dapm, -- cgit From fce091ee0a7f25108c7ab3eb06b9e436b7aeac11 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 19 Dec 2014 14:55:21 +0100 Subject: ASoC: samsung: i2s: Remove unused gpios field from struct i2s The 'gpios' field in 'struct i2s' is now unused, this change seems to be missing in commit 0429ffeff460c4302bd1520e6 ("ASoC: samsung: Remove obsolete GPIO based DT pinmuxing"). Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index b5a80c528d86..86491c9f121f 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -95,7 +95,6 @@ struct i2s_dai { u32 suspend_i2smod; u32 suspend_i2scon; u32 suspend_i2spsr; - unsigned long gpios[7]; /* i2s gpio line numbers */ const struct samsung_i2s_variant_regs *variant_regs; }; -- cgit From b2d8957f288e2e51085e7c468a05d5d98f0a785f Mon Sep 17 00:00:00 2001 From: Alexander Stein Date: Mon, 29 Dec 2014 13:08:39 +0100 Subject: ALSA: sound/atmel/ac97c.c: Add device tree support This adds device tree support for the AC97 controller. It uses the soc-ac97link bindings, but actually only ac97-reset is used. Signed-off-by: Alexander Stein Acked-by: Alexandre Belloni Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 5e6a1db70948..cf4cedf2b420 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #include #include @@ -902,6 +905,40 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip) } } +#ifdef CONFIG_OF +static const struct of_device_id atmel_ac97c_dt_ids[] = { + { .compatible = "atmel,at91sam9263-ac97c", }, + { } +}; +MODULE_DEVICE_TABLE(of, atmel_ac97c_dt_ids); + +static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev) +{ + struct ac97c_platform_data *pdata; + struct device_node *node = dev->of_node; + const struct of_device_id *match; + + if (!node) { + dev_err(dev, "Device does not have associated DT data\n"); + return ERR_PTR(-EINVAL); + } + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->reset_pin = of_get_named_gpio(dev->of_node, "ac97-gpios", 2); + + return pdata; +} +#else +static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev) +{ + dev_err(dev, "no platform data defined\n"); + return ERR_PTR(-ENXIO); +} +#endif + static int atmel_ac97c_probe(struct platform_device *pdev) { struct snd_card *card; @@ -922,10 +959,11 @@ static int atmel_ac97c_probe(struct platform_device *pdev) return -ENXIO; } - pdata = pdev->dev.platform_data; + pdata = dev_get_platdata(&pdev->dev); if (!pdata) { - dev_dbg(&pdev->dev, "no platform data\n"); - return -ENXIO; + pdata = atmel_ac97c_probe_dt(&pdev->dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); } irq = platform_get_irq(pdev, 0); @@ -1204,6 +1242,7 @@ static struct platform_driver atmel_ac97c_driver = { .driver = { .name = "atmel_ac97c", .pm = ATMEL_AC97C_PM_OPS, + .of_match_table = of_match_ptr(atmel_ac97c_dt_ids), }, }; module_platform_driver(atmel_ac97c_driver); -- cgit From 322b8af16f267a2bc027297ffa9b3b681325ed37 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Wed, 7 Jan 2015 14:41:58 +0100 Subject: ALSA: hda - Print codec->chip_name in autoconfig This will help end users figure out what HDA codec they have. Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_auto_parser.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index 1ede82200ee5..6ec3775699b2 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -409,10 +409,10 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, /* * debug prints of the parsed results */ - codec_info(codec, "autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", - cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1], - cfg->line_out_pins[2], cfg->line_out_pins[3], - cfg->line_out_pins[4], + codec_info(codec, "autoconfig for %s: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", + codec->chip_name, cfg->line_outs, cfg->line_out_pins[0], + cfg->line_out_pins[1], cfg->line_out_pins[2], + cfg->line_out_pins[3], cfg->line_out_pins[4], cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" : (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ? "speaker" : "line")); -- cgit From 4f7946eca787baa0f66b4a508595b768a4772f3f Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Wed, 7 Jan 2015 14:41:59 +0100 Subject: ALSA: hda - Debug output which type of fixup was selected Our fixup system is becoming increasingly complex, so it's becoming time consuming to figure out which way the fix was applied. This patch adds a few debug prints to aid when debugging why a specific fixup was selected. Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_auto_parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index 6ec3775699b2..3f8706bb3d16 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -920,6 +920,8 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec, codec->fixup_id = pq->value; #ifdef CONFIG_SND_DEBUG_VERBOSE codec->fixup_name = pq->name; + codec_dbg(codec, "%s: picked fixup %s (pin match)\n", + codec->chip_name, codec->fixup_name); #endif codec->fixup_list = fixlist; return; @@ -960,6 +962,8 @@ void snd_hda_pick_fixup(struct hda_codec *codec, codec->fixup_list = NULL; codec->fixup_name = NULL; codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP; + codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n", + codec->chip_name); return; } @@ -969,6 +973,8 @@ void snd_hda_pick_fixup(struct hda_codec *codec, codec->fixup_id = models->id; codec->fixup_name = models->name; codec->fixup_list = fixlist; + codec_dbg(codec, "%s: picked fixup %s (model specified)\n", + codec->chip_name, codec->fixup_name); return; } models++; @@ -980,6 +986,8 @@ void snd_hda_pick_fixup(struct hda_codec *codec, id = q->value; #ifdef CONFIG_SND_DEBUG_VERBOSE name = q->name; + codec_dbg(codec, "%s: picked fixup %s (PCI SSID%s)\n", + codec->chip_name, name, q->subdevice_mask ? "" : " - vendor generic"); #endif } } @@ -992,6 +1000,8 @@ void snd_hda_pick_fixup(struct hda_codec *codec, id = q->value; #ifdef CONFIG_SND_DEBUG_VERBOSE name = q->name; + codec_dbg(codec, "%s: picked fixup %s (codec SSID)\n", + codec->chip_name, name); #endif break; } -- cgit From 5618955c4269b07c8177f88a8075d4879e74cd27 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 7 Jan 2015 01:40:17 +0200 Subject: ALSA: fm801: move to pcim_* and devm_* functions The managed functions allow to get ->probe() and ->remove() simplier. This patch converts code to use managed functions. While here remove the dead code and fix the value printed in error message. [removed pci_release_regions() as it's managed in pcim_release(), too -- tiwai] Signed-off-by: Andy Shevchenko Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'sound') diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index d167afffce5f..dd6f23fbbdf9 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1186,12 +1186,6 @@ static int snd_fm801_free(struct fm801 *chip) v4l2_device_unregister(&chip->v4l2_dev); } #endif - if (chip->irq >= 0) - free_irq(chip->irq, chip); - pci_release_regions(chip->pci); - pci_disable_device(chip->pci); - - kfree(chip); return 0; } @@ -1214,28 +1208,23 @@ static int snd_fm801_create(struct snd_card *card, }; *rchip = NULL; - if ((err = pci_enable_device(pci)) < 0) + if ((err = pcim_enable_device(pci)) < 0) return err; - chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (chip == NULL) { - pci_disable_device(pci); + chip = devm_kzalloc(&pci->dev, sizeof(*chip), GFP_KERNEL); + if (chip == NULL) return -ENOMEM; - } spin_lock_init(&chip->reg_lock); chip->card = card; chip->pci = pci; chip->irq = -1; chip->tea575x_tuner = tea575x_tuner; - if ((err = pci_request_regions(pci, "FM801")) < 0) { - kfree(chip); - pci_disable_device(pci); + if ((err = pci_request_regions(pci, "FM801")) < 0) return err; - } chip->port = pci_resource_start(pci, 0); if ((tea575x_tuner & TUNER_ONLY) == 0) { - if (request_irq(pci->irq, snd_fm801_interrupt, IRQF_SHARED, - KBUILD_MODNAME, chip)) { - dev_err(card->dev, "unable to grab IRQ %d\n", chip->irq); + if (devm_request_irq(&pci->dev, pci->irq, snd_fm801_interrupt, + IRQF_SHARED, KBUILD_MODNAME, chip)) { + dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); snd_fm801_free(chip); return -EBUSY; } @@ -1250,12 +1239,6 @@ static int snd_fm801_create(struct snd_card *card, /* init might set tuner access method */ tea575x_tuner = chip->tea575x_tuner; - if (chip->irq >= 0 && (tea575x_tuner & TUNER_ONLY)) { - pci_clear_master(pci); - free_irq(chip->irq, chip); - chip->irq = -1; - } - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_fm801_free(chip); return err; -- cgit From 33f4acd3b214fee9662cbaf569a4876b8604f152 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Wed, 7 Jan 2015 15:50:13 +0100 Subject: ALSA: hda - Enable mic mute hotkey and LEDs for an HP machine On this machine, the mic mute hotkey is connected to GPIO2. We therefore create an extra input device for this key. Also enable LEDs connected to GPIO3 and GPIO4. (Note: if this patch is backported to older kernels, where KEY_MIC_MUTE is not available, change the KEY_MIC_MUTE to KEY_F20, which was previously used for mic mute keys.) BugLink: https://bugs.launchpad.net/bugs/1408295 Tested-by: Keng-Yu Lin Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 88 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 65f1f4e18ea5..09d213142633 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include "hda_codec.h" @@ -120,6 +121,9 @@ struct alc_spec { hda_nid_t pll_nid; unsigned int pll_coef_idx, pll_coef_bit; unsigned int coef0; +#if IS_ENABLED(CONFIG_INPUT) + struct input_dev *kb_dev; +#endif }; /* @@ -3472,6 +3476,84 @@ static void alc280_fixup_hp_gpio4(struct hda_codec *codec, } } +#if IS_ENABLED(CONFIG_INPUT) +static void gpio2_mic_hotkey_event(struct hda_codec *codec, + struct hda_jack_callback *event) +{ + struct alc_spec *spec = codec->spec; + + /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore + send both key on and key off event for every interrupt. */ + input_report_key(spec->kb_dev, KEY_MICMUTE, 1); + input_sync(spec->kb_dev); + input_report_key(spec->kb_dev, KEY_MICMUTE, 0); + input_sync(spec->kb_dev); +} +#endif + +static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ +#if IS_ENABLED(CONFIG_INPUT) + /* GPIO1 = set according to SKU external amp + GPIO2 = mic mute hotkey + GPIO3 = mute LED + GPIO4 = mic mute LED */ + static const struct hda_verb gpio_init[] = { + { 0x01, AC_VERB_SET_GPIO_MASK, 0x1e }, + { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x1a }, + { 0x01, AC_VERB_SET_GPIO_DATA, 0x02 }, + {} + }; + + struct alc_spec *spec = codec->spec; + + if (action == HDA_FIXUP_ACT_PRE_PROBE) { + spec->kb_dev = input_allocate_device(); + if (!spec->kb_dev) { + codec_err(codec, "Out of memory (input_allocate_device)\n"); + return; + } + spec->kb_dev->name = "Microphone Mute Button"; + spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY); + spec->kb_dev->keybit[BIT_WORD(KEY_MICMUTE)] = BIT_MASK(KEY_MICMUTE); + if (input_register_device(spec->kb_dev)) { + codec_err(codec, "input_register_device failed\n"); + input_free_device(spec->kb_dev); + spec->kb_dev = NULL; + return; + } + + snd_hda_add_verbs(codec, gpio_init); + snd_hda_codec_write_cache(codec, codec->afg, 0, + AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04); + snd_hda_jack_detect_enable_callback(codec, codec->afg, + gpio2_mic_hotkey_event); + + spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook; + spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook; + spec->gpio_led = 0; + spec->mute_led_polarity = 0; + spec->gpio_mute_led_mask = 0x08; + spec->gpio_mic_led_mask = 0x10; + return; + } + + if (!spec->kb_dev) + return; + + switch (action) { + case HDA_FIXUP_ACT_PROBE: + spec->init_amp = ALC_INIT_DEFAULT; + break; + case HDA_FIXUP_ACT_FREE: + input_unregister_device(spec->kb_dev); + input_free_device(spec->kb_dev); + spec->kb_dev = NULL; + } +#endif +} + static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, const struct hda_fixup *fix, int action) { @@ -4341,6 +4423,7 @@ enum { ALC282_FIXUP_ASPIRE_V5_PINS, ALC280_FIXUP_HP_GPIO4, ALC286_FIXUP_HP_GPIO_LED, + ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, }; static const struct hda_fixup alc269_fixups[] = { @@ -4814,6 +4897,10 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc286_fixup_hp_gpio_led, }, + [ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc280_fixup_hp_gpio2_mic_hotkey, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = { @@ -4843,6 +4930,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED), + SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY), /* ALC282 */ SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), -- cgit From b7ed9f1d26f04272127a98248338177e5bac233e Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 7 Jan 2015 10:19:06 +0800 Subject: ASoC: rt5670: redefine ASRC control registers 0x84 and 0x85 The previous definition of registers 0x84 and 0x85 doesn't match the datasheet. So this patch removes the wrong definition and writes a new one for the two registers. Signed-off-by: Bard Liao Signed-off-by: Mengdong Lin Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.h | 65 +++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 41 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h index d11b9c207e26..ec38d8f173e7 100644 --- a/sound/soc/codecs/rt5670.h +++ b/sound/soc/codecs/rt5670.h @@ -1023,50 +1023,33 @@ #define RT5670_DMIC_2_M_NOR (0x0 << 8) #define RT5670_DMIC_2_M_ASYN (0x1 << 8) +/* ASRC clock source selection (0x84, 0x85) */ +#define RT5670_CLK_SEL_SYS (0x0) +#define RT5670_CLK_SEL_I2S1_ASRC (0x1) +#define RT5670_CLK_SEL_I2S2_ASRC (0x2) +#define RT5670_CLK_SEL_I2S3_ASRC (0x3) +#define RT5670_CLK_SEL_SYS2 (0x5) +#define RT5670_CLK_SEL_SYS3 (0x6) + /* ASRC Control 2 (0x84) */ -#define RT5670_MDA_L_M_MASK (0x1 << 15) -#define RT5670_MDA_L_M_SFT 15 -#define RT5670_MDA_L_M_NOR (0x0 << 15) -#define RT5670_MDA_L_M_ASYN (0x1 << 15) -#define RT5670_MDA_R_M_MASK (0x1 << 14) -#define RT5670_MDA_R_M_SFT 14 -#define RT5670_MDA_R_M_NOR (0x0 << 14) -#define RT5670_MDA_R_M_ASYN (0x1 << 14) -#define RT5670_MAD_L_M_MASK (0x1 << 13) -#define RT5670_MAD_L_M_SFT 13 -#define RT5670_MAD_L_M_NOR (0x0 << 13) -#define RT5670_MAD_L_M_ASYN (0x1 << 13) -#define RT5670_MAD_R_M_MASK (0x1 << 12) -#define RT5670_MAD_R_M_SFT 12 -#define RT5670_MAD_R_M_NOR (0x0 << 12) -#define RT5670_MAD_R_M_ASYN (0x1 << 12) -#define RT5670_ADC_M_MASK (0x1 << 11) -#define RT5670_ADC_M_SFT 11 -#define RT5670_ADC_M_NOR (0x0 << 11) -#define RT5670_ADC_M_ASYN (0x1 << 11) -#define RT5670_STO_DAC_M_MASK (0x1 << 5) -#define RT5670_STO_DAC_M_SFT 5 -#define RT5670_STO_DAC_M_NOR (0x0 << 5) -#define RT5670_STO_DAC_M_ASYN (0x1 << 5) -#define RT5670_I2S1_R_D_MASK (0x1 << 4) -#define RT5670_I2S1_R_D_SFT 4 -#define RT5670_I2S1_R_D_DIS (0x0 << 4) -#define RT5670_I2S1_R_D_EN (0x1 << 4) -#define RT5670_I2S2_R_D_MASK (0x1 << 3) -#define RT5670_I2S2_R_D_SFT 3 -#define RT5670_I2S2_R_D_DIS (0x0 << 3) -#define RT5670_I2S2_R_D_EN (0x1 << 3) -#define RT5670_PRE_SCLK_MASK (0x3) -#define RT5670_PRE_SCLK_SFT 0 -#define RT5670_PRE_SCLK_512 (0x0) -#define RT5670_PRE_SCLK_1024 (0x1) -#define RT5670_PRE_SCLK_2048 (0x2) +#define RT5670_DA_STO_CLK_SEL_MASK (0xf << 12) +#define RT5670_DA_STO_CLK_SEL_SFT 12 +#define RT5670_DA_MONOL_CLK_SEL_MASK (0xf << 8) +#define RT5670_DA_MONOL_CLK_SEL_SFT 8 +#define RT5670_DA_MONOR_CLK_SEL_MASK (0xf << 4) +#define RT5670_DA_MONOR_CLK_SEL_SFT 4 +#define RT5670_AD_STO1_CLK_SEL_MASK (0xf << 0) +#define RT5670_AD_STO1_CLK_SEL_SFT 0 /* ASRC Control 3 (0x85) */ -#define RT5670_I2S1_RATE_MASK (0xf << 12) -#define RT5670_I2S1_RATE_SFT 12 -#define RT5670_I2S2_RATE_MASK (0xf << 8) -#define RT5670_I2S2_RATE_SFT 8 +#define RT5670_UP_CLK_SEL_MASK (0xf << 12) +#define RT5670_UP_CLK_SEL_SFT 12 +#define RT5670_DOWN_CLK_SEL_MASK (0xf << 8) +#define RT5670_DOWN_CLK_SEL_SFT 8 +#define RT5670_AD_MONOL_CLK_SEL_MASK (0xf << 4) +#define RT5670_AD_MONOL_CLK_SEL_SFT 4 +#define RT5670_AD_MONOR_CLK_SEL_MASK (0xf << 0) +#define RT5670_AD_MONOR_CLK_SEL_SFT 0 /* ASRC Control 4 (0x89) */ #define RT5670_I2S1_PD_MASK (0x7 << 12) -- cgit From e8c47ba3cadcc3649f18e4710804bb6c3791eac2 Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Wed, 7 Jan 2015 10:19:12 +0800 Subject: ASoC: rt5670: add API to select ASRC clock source When codec is in slave mode, ASRC can suppress noise for asynchronous MCLK and LRCLK or special I2S format. This patch defines an API to select the clock source for specified filters. And the codec driver will turn on ASRC for these filters if ASRC is selected as their clock source. Signed-off-by: Bard Liao Signed-off-by: Mengdong Lin Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt5670.h | 15 +++++++++ 2 files changed, 98 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 0a027bc94399..0632b7458a53 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -590,6 +590,89 @@ static int can_use_asrc(struct snd_soc_dapm_widget *source, return 0; } + +/** + * rt5670_sel_asrc_clk_src - select ASRC clock source for a set of filters + * @codec: SoC audio codec device. + * @filter_mask: mask of filters. + * @clk_src: clock source + * + * The ASRC function is for asynchronous MCLK and LRCK. Also, since RT5670 can + * only support standard 32fs or 64fs i2s format, ASRC should be enabled to + * support special i2s clock format such as Intel's 100fs(100 * sampling rate). + * ASRC function will track i2s clock and generate a corresponding system clock + * for codec. This function provides an API to select the clock source for a + * set of filters specified by the mask. And the codec driver will turn on ASRC + * for these filters if ASRC is selected as their clock source. + */ +int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, + unsigned int filter_mask, unsigned int clk_src) +{ + unsigned int asrc2_mask = 0, asrc2_value = 0; + unsigned int asrc3_mask = 0, asrc3_value = 0; + + if (clk_src > RT5670_CLK_SEL_SYS3) + return -EINVAL; + + if (filter_mask & RT5670_DA_STEREO_FILTER) { + asrc2_mask |= RT5670_DA_STO_CLK_SEL_MASK; + asrc2_value = (asrc2_value & ~RT5670_DA_STO_CLK_SEL_MASK) + | (clk_src << RT5670_DA_STO_CLK_SEL_SFT); + } + + if (filter_mask & RT5670_DA_MONO_L_FILTER) { + asrc2_mask |= RT5670_DA_MONOL_CLK_SEL_MASK; + asrc2_value = (asrc2_value & ~RT5670_DA_MONOL_CLK_SEL_MASK) + | (clk_src << RT5670_DA_MONOL_CLK_SEL_SFT); + } + + if (filter_mask & RT5670_DA_MONO_R_FILTER) { + asrc2_mask |= RT5670_DA_MONOR_CLK_SEL_MASK; + asrc2_value = (asrc2_value & ~RT5670_DA_MONOR_CLK_SEL_MASK) + | (clk_src << RT5670_DA_MONOR_CLK_SEL_SFT); + } + + if (filter_mask & RT5670_AD_STEREO_FILTER) { + asrc2_mask |= RT5670_AD_STO1_CLK_SEL_MASK; + asrc2_value = (asrc2_value & ~RT5670_AD_STO1_CLK_SEL_MASK) + | (clk_src << RT5670_AD_STO1_CLK_SEL_SFT); + } + + if (filter_mask & RT5670_AD_MONO_L_FILTER) { + asrc3_mask |= RT5670_AD_MONOL_CLK_SEL_MASK; + asrc3_value = (asrc3_value & ~RT5670_AD_MONOL_CLK_SEL_MASK) + | (clk_src << RT5670_AD_MONOL_CLK_SEL_SFT); + } + + if (filter_mask & RT5670_AD_MONO_R_FILTER) { + asrc3_mask |= RT5670_AD_MONOR_CLK_SEL_MASK; + asrc3_value = (asrc3_value & ~RT5670_AD_MONOR_CLK_SEL_MASK) + | (clk_src << RT5670_AD_MONOR_CLK_SEL_SFT); + } + + if (filter_mask & RT5670_UP_RATE_FILTER) { + asrc3_mask |= RT5670_UP_CLK_SEL_MASK; + asrc3_value = (asrc3_value & ~RT5670_UP_CLK_SEL_MASK) + | (clk_src << RT5670_UP_CLK_SEL_SFT); + } + + if (filter_mask & RT5670_DOWN_RATE_FILTER) { + asrc3_mask |= RT5670_DOWN_CLK_SEL_MASK; + asrc3_value = (asrc3_value & ~RT5670_DOWN_CLK_SEL_MASK) + | (clk_src << RT5670_DOWN_CLK_SEL_SFT); + } + + if (asrc2_mask) + snd_soc_update_bits(codec, RT5670_ASRC_2, + asrc2_mask, asrc2_value); + + if (asrc3_mask) + snd_soc_update_bits(codec, RT5670_ASRC_3, + asrc3_mask, asrc3_value); + return 0; +} +EXPORT_SYMBOL_GPL(rt5670_sel_asrc_clk_src); + /* Digital Mixer */ static const struct snd_kcontrol_new rt5670_sto1_adc_l_mix[] = { SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO1_ADC_MIXER, diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h index ec38d8f173e7..21f8e18c13c4 100644 --- a/sound/soc/codecs/rt5670.h +++ b/sound/soc/codecs/rt5670.h @@ -1966,6 +1966,21 @@ enum { RT5670_DMIC_DATA_GPIO5, }; +/* filter mask */ +enum { + RT5670_DA_STEREO_FILTER = 0x1, + RT5670_DA_MONO_L_FILTER = (0x1 << 1), + RT5670_DA_MONO_R_FILTER = (0x1 << 2), + RT5670_AD_STEREO_FILTER = (0x1 << 3), + RT5670_AD_MONO_L_FILTER = (0x1 << 4), + RT5670_AD_MONO_R_FILTER = (0x1 << 5), + RT5670_UP_RATE_FILTER = (0x1 << 6), + RT5670_DOWN_RATE_FILTER = (0x1 << 7), +}; + +int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, + unsigned int filter_mask, unsigned int clk_src); + struct rt5670_priv { struct snd_soc_codec *codec; struct rt5670_platform_data pdata; -- cgit From eb55fab997c0bf1b1ddf0a7199da0ceb18432b96 Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Wed, 7 Jan 2015 10:19:23 +0800 Subject: ASoC: Intel: Select RT5672 ASRC clock source on Cherrytrail and Braswell On Cherrytrail and Braswell, the I2S BCLK is 100FS which cannot be supported by RT5672 in slave mode and can cause noise. This patch selects codec ASRC clock source to track I2S1 clock so that codec ASRC can be enabled to suppress the noise. Signed-off-by: Mengdong Lin Reviewed-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/intel/cht_bsw_rt5672.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/cht_bsw_rt5672.c b/sound/soc/intel/cht_bsw_rt5672.c index a406c6104897..ff016621583a 100644 --- a/sound/soc/intel/cht_bsw_rt5672.c +++ b/sound/soc/intel/cht_bsw_rt5672.c @@ -140,6 +140,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) { int ret; struct snd_soc_dai *codec_dai = runtime->codec_dai; + struct snd_soc_codec *codec = codec_dai->codec; /* 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); @@ -148,6 +149,19 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) return ret; } + /* Select codec ASRC clock source to track I2S1 clock, because codec + * is in slave mode and 100fs I2S format (BCLK = 100 * LRCLK) cannot + * be supported by RT5672. Otherwise, ASRC will be disabled and cause + * noise. + */ + rt5670_sel_asrc_clk_src(codec, + RT5670_DA_STEREO_FILTER + | RT5670_DA_MONO_L_FILTER + | RT5670_DA_MONO_R_FILTER + | RT5670_AD_STEREO_FILTER + | RT5670_AD_MONO_L_FILTER + | RT5670_AD_MONO_R_FILTER, + RT5670_CLK_SEL_I2S1_ASRC); return 0; } -- cgit From ce64c8b9cf5be2a93508af4667110dbe90904557 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 6 Jan 2015 15:17:20 +0100 Subject: ASoC: Add helper function for changing the DAI link format For some setups it is necessary to change the DAI link format at runtime. This patch factors out the code that does the initial static DAI link format configuration into a separate helper function which can be used board drivers as well. This allows board drivers that have to change the DAI link format at runtime to reuse it instead of having to manually change the format on all DAIs. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 125 ++++++++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 56 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 985052b3fbed..80ea358d3ad7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1427,11 +1427,75 @@ static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) return 0; } +/** + * snd_soc_runtime_set_dai_fmt() - Change DAI link format for a ASoC runtime + * @rtd: The runtime for which the DAI link format should be changed + * @dai_fmt: The new DAI link format + * + * This function updates the DAI link format for all DAIs connected to the DAI + * link for the specified runtime. + * + * Note: For setups with a static format set the dai_fmt field in the + * corresponding snd_dai_link struct instead of using this function. + * + * Returns 0 on success, otherwise a negative error code. + */ +int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, + unsigned int dai_fmt) +{ + struct snd_soc_dai **codec_dais = rtd->codec_dais; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + unsigned int i; + int ret; + + for (i = 0; i < rtd->num_codecs; i++) { + struct snd_soc_dai *codec_dai = codec_dais[i]; + + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret != 0 && ret != -ENOTSUPP) { + dev_warn(codec_dai->dev, + "ASoC: Failed to set DAI format: %d\n", ret); + return ret; + } + } + + /* Flip the polarity for the "CPU" end of a CODEC<->CODEC link */ + if (cpu_dai->codec) { + unsigned int inv_dai_fmt; + + inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK; + switch (dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; + break; + case SND_SOC_DAIFMT_CBM_CFS: + inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFM; + break; + case SND_SOC_DAIFMT_CBS_CFM: + inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFS; + break; + case SND_SOC_DAIFMT_CBS_CFS: + inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; + break; + } + + dai_fmt = inv_dai_fmt; + } + + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret != 0 && ret != -ENOTSUPP) { + dev_warn(cpu_dai->dev, + "ASoC: Failed to set DAI format: %d\n", ret); + return ret; + } + + return 0; +} + static int snd_soc_instantiate_card(struct snd_soc_card *card) { struct snd_soc_codec *codec; - struct snd_soc_dai_link *dai_link; - int ret, i, order, dai_fmt; + int ret, i, order; mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); @@ -1542,60 +1606,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) card->num_dapm_routes); for (i = 0; i < card->num_links; i++) { - struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; - dai_link = &card->dai_link[i]; - dai_fmt = dai_link->dai_fmt; - - if (dai_fmt) { - struct snd_soc_dai **codec_dais = rtd->codec_dais; - int j; - - for (j = 0; j < rtd->num_codecs; j++) { - struct snd_soc_dai *codec_dai = codec_dais[j]; - - ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); - if (ret != 0 && ret != -ENOTSUPP) - dev_warn(codec_dai->dev, - "ASoC: Failed to set DAI format: %d\n", - ret); - } - } - - /* If this is a regular CPU link there will be a platform */ - if (dai_fmt && - (dai_link->platform_name || dai_link->platform_of_node)) { - ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai, - dai_fmt); - if (ret != 0 && ret != -ENOTSUPP) - dev_warn(card->rtd[i].cpu_dai->dev, - "ASoC: Failed to set DAI format: %d\n", - ret); - } else if (dai_fmt) { - /* Flip the polarity for the "CPU" end */ - dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK; - switch (dai_link->dai_fmt & - SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBM_CFM: - dai_fmt |= SND_SOC_DAIFMT_CBS_CFS; - break; - case SND_SOC_DAIFMT_CBM_CFS: - dai_fmt |= SND_SOC_DAIFMT_CBS_CFM; - break; - case SND_SOC_DAIFMT_CBS_CFM: - dai_fmt |= SND_SOC_DAIFMT_CBM_CFS; - break; - case SND_SOC_DAIFMT_CBS_CFS: - dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; - break; - } - - ret = snd_soc_dai_set_fmt(card->rtd[i].cpu_dai, - dai_fmt); - if (ret != 0 && ret != -ENOTSUPP) - dev_warn(card->rtd[i].cpu_dai->dev, - "ASoC: Failed to set DAI format: %d\n", - ret); - } + if (card->dai_link[i].dai_fmt) + snd_soc_runtime_set_dai_fmt(&card->rtd[i], + card->dai_link[i].dai_fmt); } snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname), -- cgit From dc1b36b24990b9d87c6de88819c112c4db91dbc8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 6 Jan 2015 15:17:21 +0100 Subject: ASoC: omap-twl4030: Use snd_soc_runtime_set_dai_fmt() Use snd_soc_runtime_set_dai_fmt() to configure the format for the DAI link rather than configuring each DAI individually. Signed-off-by: Lars-Peter Clausen Acked-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-twl4030.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index 5e551c762b7a..fb1f6bb87cd4 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c @@ -53,11 +53,7 @@ static int omap_twl4030_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; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_card *card = rtd->card; unsigned int fmt; - int ret; switch (params_channels(params)) { case 2: /* Stereo I2S mode */ @@ -74,21 +70,7 @@ static int omap_twl4030_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - /* Set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, fmt); - if (ret < 0) { - dev_err(card->dev, "can't set codec DAI configuration\n"); - return ret; - } - - /* Set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - dev_err(card->dev, "can't set cpu DAI configuration\n"); - return ret; - } - - return 0; + return snd_soc_runtime_set_dai_fmt(rtd, fmt); } static struct snd_soc_ops omap_twl4030_ops = { -- cgit From c853679a51b9bb76a3e06e64a0b4c6276f391921 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 6 Jan 2015 15:17:22 +0100 Subject: ASoC: mop500_ab8500: Use snd_soc_runtime_set_dai_fmt() Use snd_soc_runtime_set_dai_fmt() to configure the format for the DAI link rather than configuring each DAI individually. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/ux500/mop500_ab8500.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/ux500/mop500_ab8500.c b/sound/soc/ux500/mop500_ab8500.c index be4f1ac7cd5e..aa65370db82a 100644 --- a/sound/soc/ux500/mop500_ab8500.c +++ b/sound/soc/ux500/mop500_ab8500.c @@ -290,21 +290,9 @@ static int mop500_ab8500_hw_params(struct snd_pcm_substream *substream, SND_SOC_DAIFMT_GATED; } - ret = snd_soc_dai_set_fmt(codec_dai, fmt); - if (ret < 0) { - dev_err(dev, - "%s: ERROR: snd_soc_dai_set_fmt failed for codec_dai (ret = %d)!\n", - __func__, ret); - return ret; - } - - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) { - dev_err(dev, - "%s: ERROR: snd_soc_dai_set_fmt failed for cpu_dai (ret = %d)!\n", - __func__, ret); + ret = snd_soc_runtime_set_dai_fmt(rtd, fmt); + if (ret) return ret; - } /* Setup TDM-slots */ -- cgit From a37f1b8fdc912600c24f9d0d45d7046e50a031e4 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Tue, 30 Dec 2014 11:12:35 -0800 Subject: ASoC: tegra: Add platform driver for rt5677 audio codec The driver supports NVIDIA Tegra Ryu board Sponsored: Google ChromeOS Signed-off-by: Anatol Pomozov Signed-off-by: Mark Brown --- sound/soc/tegra/Kconfig | 10 ++ sound/soc/tegra/Makefile | 2 + sound/soc/tegra/tegra_rt5677.c | 347 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 359 insertions(+) create mode 100644 sound/soc/tegra/tegra_rt5677.c (limited to 'sound') diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index 31198cf7f88d..a6768f832c6f 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -128,3 +128,13 @@ config SND_SOC_TEGRA_MAX98090 help Say Y or M here if you want to add support for SoC audio on Tegra boards using the MAX98090 codec, such as Venice2. + +config SND_SOC_TEGRA_RT5677 + tristate "SoC Audio support for Tegra boards using a RT5677 codec" + depends on SND_SOC_TEGRA && I2C && GPIOLIB + select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC + select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC + select SND_SOC_RT5677 + help + Say Y or M here if you want to add support for SoC audio on Tegra + boards using the RT5677 codec, such as Ryu. diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile index 5ae588cd96c4..9171655ad843 100644 --- a/sound/soc/tegra/Makefile +++ b/sound/soc/tegra/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_SND_SOC_TEGRA30_I2S) += snd-soc-tegra30-i2s.o # Tegra machine Support snd-soc-tegra-rt5640-objs := tegra_rt5640.o +snd-soc-tegra-rt5677-objs := tegra_rt5677.o snd-soc-tegra-wm8753-objs := tegra_wm8753.o snd-soc-tegra-wm8903-objs := tegra_wm8903.o snd-soc-tegra-wm9712-objs := tegra_wm9712.o @@ -27,6 +28,7 @@ snd-soc-tegra-alc5632-objs := tegra_alc5632.o snd-soc-tegra-max98090-objs := tegra_max98090.o obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o +obj-$(CONFIG_SND_SOC_TEGRA_RT5677) += snd-soc-tegra-rt5677.o obj-$(CONFIG_SND_SOC_TEGRA_WM8753) += snd-soc-tegra-wm8753.o obj-$(CONFIG_SND_SOC_TEGRA_WM8903) += snd-soc-tegra-wm8903.o obj-$(CONFIG_SND_SOC_TEGRA_WM9712) += snd-soc-tegra-wm9712.o diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c new file mode 100644 index 000000000000..e4cf978a6e3a --- /dev/null +++ b/sound/soc/tegra/tegra_rt5677.c @@ -0,0 +1,347 @@ +/* +* tegra_rt5677.c - Tegra machine ASoC driver for boards using RT5677 codec. + * + * Copyright (c) 2014, The Chromium OS Authors. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Based on code copyright/by: + * + * Copyright (C) 2010-2012 - NVIDIA, Inc. + * Copyright (C) 2011 The AC100 Kernel Team + * (c) 2009, 2010 Nvidia Graphics Pvt. Ltd. + * Copyright 2007 Wolfson Microelectronics PLC. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "../codecs/rt5677.h" + +#include "tegra_asoc_utils.h" + +#define DRV_NAME "tegra-snd-rt5677" + +struct tegra_rt5677 { + struct tegra_asoc_utils_data util_data; + int gpio_hp_det; + int gpio_hp_en; + int gpio_mic_present; + int gpio_dmic_clk_en; +}; + +static int tegra_rt5677_asoc_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; + struct snd_soc_card *card = rtd->card; + struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); + int srate, mclk, err; + + srate = params_rate(params); + mclk = 256 * srate; + + err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk); + if (err < 0) { + dev_err(card->dev, "Can't configure clocks\n"); + return err; + } + + err = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_MCLK, mclk, + SND_SOC_CLOCK_IN); + if (err < 0) { + dev_err(card->dev, "codec_dai clock not set\n"); + return err; + } + + return 0; +} + +static int tegra_rt5677_event_hp(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 tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); + + if (!gpio_is_valid(machine->gpio_hp_en)) + return 0; + + gpio_set_value_cansleep(machine->gpio_hp_en, + SND_SOC_DAPM_EVENT_ON(event)); + + return 0; +} + +static struct snd_soc_ops tegra_rt5677_ops = { + .hw_params = tegra_rt5677_asoc_hw_params, +}; + +static struct snd_soc_jack tegra_rt5677_hp_jack; + +static struct snd_soc_jack_pin tegra_rt5677_hp_jack_pins = { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, +}; +static struct snd_soc_jack_gpio tegra_rt5677_hp_jack_gpio = { + .name = "Headphone detection", + .report = SND_JACK_HEADPHONE, + .debounce_time = 150, +}; + +static struct snd_soc_jack tegra_rt5677_mic_jack; + +static struct snd_soc_jack_pin tegra_rt5677_mic_jack_pins = { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, +}; + +static struct snd_soc_jack_gpio tegra_rt5677_mic_jack_gpio = { + .name = "Headset Mic detection", + .report = SND_JACK_MICROPHONE, + .debounce_time = 150, + .invert = 1 +}; + +static const struct snd_soc_dapm_widget tegra_rt5677_dapm_widgets[] = { + SND_SOC_DAPM_SPK("Speaker", NULL), + SND_SOC_DAPM_HP("Headphone", tegra_rt5677_event_hp), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Internal Mic 1", NULL), + SND_SOC_DAPM_MIC("Internal Mic 2", NULL), +}; + +static const struct snd_kcontrol_new tegra_rt5677_controls[] = { + SOC_DAPM_PIN_SWITCH("Speaker"), + SOC_DAPM_PIN_SWITCH("Headphone"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Internal Mic 1"), + SOC_DAPM_PIN_SWITCH("Internal Mic 2"), +}; + +static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_dapm_context *dapm = &codec->dapm; + struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card); + + snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, + &tegra_rt5677_hp_jack); + snd_soc_jack_add_pins(&tegra_rt5677_hp_jack, 1, + &tegra_rt5677_hp_jack_pins); + + if (gpio_is_valid(machine->gpio_hp_det)) { + tegra_rt5677_hp_jack_gpio.gpio = machine->gpio_hp_det; + snd_soc_jack_add_gpios(&tegra_rt5677_hp_jack, 1, + &tegra_rt5677_hp_jack_gpio); + } + + + snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, + &tegra_rt5677_mic_jack); + snd_soc_jack_add_pins(&tegra_rt5677_mic_jack, 1, + &tegra_rt5677_mic_jack_pins); + + if (gpio_is_valid(machine->gpio_mic_present)) { + tegra_rt5677_mic_jack_gpio.gpio = machine->gpio_mic_present; + snd_soc_jack_add_gpios(&tegra_rt5677_mic_jack, 1, + &tegra_rt5677_mic_jack_gpio); + } + + snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); + + return 0; +} + +static int tegra_rt5677_card_remove(struct snd_soc_card *card) +{ + struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); + + if (gpio_is_valid(machine->gpio_hp_det)) { + snd_soc_jack_free_gpios(&tegra_rt5677_hp_jack, 1, + &tegra_rt5677_hp_jack_gpio); + } + + if (gpio_is_valid(machine->gpio_mic_present)) { + snd_soc_jack_free_gpios(&tegra_rt5677_mic_jack, 1, + &tegra_rt5677_mic_jack_gpio); + } + + return 0; +} + +static struct snd_soc_dai_link tegra_rt5677_dai = { + .name = "RT5677", + .stream_name = "RT5677 PCM", + .codec_dai_name = "rt5677-aif1", + .init = tegra_rt5677_asoc_init, + .ops = &tegra_rt5677_ops, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, +}; + +static struct snd_soc_card snd_soc_tegra_rt5677 = { + .name = "tegra-rt5677", + .owner = THIS_MODULE, + .remove = tegra_rt5677_card_remove, + .dai_link = &tegra_rt5677_dai, + .num_links = 1, + .controls = tegra_rt5677_controls, + .num_controls = ARRAY_SIZE(tegra_rt5677_controls), + .dapm_widgets = tegra_rt5677_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tegra_rt5677_dapm_widgets), + .fully_routed = true, +}; + +static int tegra_rt5677_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct snd_soc_card *card = &snd_soc_tegra_rt5677; + struct tegra_rt5677 *machine; + int ret; + + machine = devm_kzalloc(&pdev->dev, + sizeof(struct tegra_rt5677), GFP_KERNEL); + if (!machine) + return -ENOMEM; + + card->dev = &pdev->dev; + platform_set_drvdata(pdev, card); + snd_soc_card_set_drvdata(card, machine); + + machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0); + if (machine->gpio_hp_det == -EPROBE_DEFER) + return -EPROBE_DEFER; + + machine->gpio_mic_present = of_get_named_gpio(np, + "nvidia,mic-present-gpios", 0); + if (machine->gpio_mic_present == -EPROBE_DEFER) + return -EPROBE_DEFER; + + machine->gpio_hp_en = of_get_named_gpio(np, "nvidia,hp-en-gpios", 0); + if (machine->gpio_hp_en == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (gpio_is_valid(machine->gpio_hp_en)) { + ret = devm_gpio_request_one(&pdev->dev, machine->gpio_hp_en, + GPIOF_OUT_INIT_LOW, "hp_en"); + if (ret) { + dev_err(card->dev, "cannot get hp_en gpio\n"); + return ret; + } + } + + machine->gpio_dmic_clk_en = of_get_named_gpio(np, + "nvidia,dmic-clk-en-gpios", 0); + if (machine->gpio_dmic_clk_en == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (gpio_is_valid(machine->gpio_dmic_clk_en)) { + ret = devm_gpio_request_one(&pdev->dev, + machine->gpio_dmic_clk_en, + GPIOF_OUT_INIT_HIGH, "dmic_clk_en"); + if (ret) { + dev_err(card->dev, "cannot get dmic_clk_en gpio\n"); + return ret; + } + } + + ret = snd_soc_of_parse_card_name(card, "nvidia,model"); + if (ret) + goto err; + + ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); + if (ret) + goto err; + + tegra_rt5677_dai.codec_of_node = of_parse_phandle(np, + "nvidia,audio-codec", 0); + if (!tegra_rt5677_dai.codec_of_node) { + dev_err(&pdev->dev, + "Property 'nvidia,audio-codec' missing or invalid\n"); + ret = -EINVAL; + goto err; + } + + tegra_rt5677_dai.cpu_of_node = of_parse_phandle(np, + "nvidia,i2s-controller", 0); + if (!tegra_rt5677_dai.cpu_of_node) { + dev_err(&pdev->dev, + "Property 'nvidia,i2s-controller' missing or invalid\n"); + ret = -EINVAL; + goto err; + } + tegra_rt5677_dai.platform_of_node = tegra_rt5677_dai.cpu_of_node; + + ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); + if (ret) + goto err; + + ret = snd_soc_register_card(card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", + ret); + goto err_fini_utils; + } + + return 0; + +err_fini_utils: + tegra_asoc_utils_fini(&machine->util_data); +err: + return ret; +} + +static int tegra_rt5677_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); + + snd_soc_unregister_card(card); + + tegra_asoc_utils_fini(&machine->util_data); + + return 0; +} + +static const struct of_device_id tegra_rt5677_of_match[] = { + { .compatible = "nvidia,tegra-audio-rt5677", }, + {}, +}; + +static struct platform_driver tegra_rt5677_driver = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + .pm = &snd_soc_pm_ops, + .of_match_table = tegra_rt5677_of_match, + }, + .probe = tegra_rt5677_probe, + .remove = tegra_rt5677_remove, +}; +module_platform_driver(tegra_rt5677_driver); + +MODULE_AUTHOR("Anatol Pomozov "); +MODULE_DESCRIPTION("Tegra+RT5677 machine ASoC driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); +MODULE_DEVICE_TABLE(of, tegra_rt5677_of_match); -- cgit From 3db084fd0af5407eebeb9b7ebd5d0425b362c519 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 8 Jan 2015 00:39:17 +0200 Subject: ALSA: fm801: PCI core handles power state for us There is no need to repeat the work that is already done in the PCI driver core. The patch removes excerpts from suspend and resume callbacks. Note that there is no more calls performed to enable or disable a PCI device during suspend-resume cycle. Nowadays they seems to be superflous. Someone can read more in [1]. [1] https://www.kernel.org/doc/ols/2009/ols2009-pages-319-330.pdf Signed-off-by: Andy Shevchenko Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index dd6f23fbbdf9..1a0494eff0c6 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1375,7 +1375,6 @@ static unsigned char saved_regs[] = { static int snd_fm801_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct fm801 *chip = card->private_data; int i; @@ -1387,29 +1386,15 @@ static int snd_fm801_suspend(struct device *dev) for (i = 0; i < ARRAY_SIZE(saved_regs); i++) chip->saved_regs[i] = inw(chip->port + saved_regs[i]); /* FIXME: tea575x suspend */ - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_fm801_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct fm801 *chip = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_fm801_chip_init(chip, 1); snd_ac97_resume(chip->ac97); snd_ac97_resume(chip->ac97_sec); -- cgit From e9f49369722bd7dd53f90467196df4b952eac1b6 Mon Sep 17 00:00:00 2001 From: Paul Bonser Date: Wed, 7 Jan 2015 23:34:16 -0600 Subject: ALSA: usb-audio: Add support for Akai MPC Element USB MIDI controller The Akai MPC Element incorrectly reports its bInterfaceClass as 255, but otherwise implements the USB MIDI spec correctly. This adds a quirks-table.h entry which allows the device to be recognized as a standard USB MIDI device. Signed-off-by: Paul Bonser Signed-off-by: Takashi Iwai --- sound/usb/quirks-table.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sound') diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index 0a598af9b38b..67d476548dcf 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -2486,6 +2486,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, +{ + /* Akai MPC Element */ + USB_DEVICE(0x09e8, 0x0021), + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { + .ifnum = QUIRK_ANY_INTERFACE, + .type = QUIRK_COMPOSITE, + .data = & (const struct snd_usb_audio_quirk[]) { + { + .ifnum = 0, + .type = QUIRK_IGNORE_INTERFACE + }, + { + .ifnum = 1, + .type = QUIRK_MIDI_STANDARD_INTERFACE + }, + { + .ifnum = -1 + } + } + } +}, + /* TerraTec devices */ { USB_DEVICE_VENDOR_SPEC(0x0ccd, 0x0012), -- cgit From ddaca25aa4dade234163290f6a9e091e7f57b36a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 8 Jan 2015 12:23:05 +0100 Subject: ASoC: Export snd_soc_runtime_set_dai_fmt() Export snd_soc_runtime_set_dai_fmt() so it can be used in modules. Fixes: ce64c8b9cf5b ("ASoC: Add helper function for changing the DAI link format") Reported-by: kbuild test robot Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 80ea358d3ad7..d342ee2ce28b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1491,6 +1491,7 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, return 0; } +EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt); static int snd_soc_instantiate_card(struct snd_soc_card *card) { -- cgit From a6b3db2c837a2db359bf7f846346680883dbb032 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Thu, 8 Jan 2015 08:59:39 +0530 Subject: ASoC: wm5102: Use put_unaligned_be16 This patch introduces the use of function put_unaligned_be16. This is done using Coccinelle and semantic patch used is as follows: @a@ typedef u16, __be16, uint16_t; {u16,__be16,uint16_t} e16; identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_be16(y); <+... when != tmp ( - memcpy(ptr, (T)&tmp, \(2\|sizeof(u16)\|sizeof(__be16)\|sizeof(uint16_t)\|sizeof(e16)\)); + put_unaligned_be16(y,ptr); | - memcpy(ptr, (T)&tmp, ...); + put_unaligned_be16(y,ptr); ) ...+> ? tmp = e @@ type T; identifier a.tmp; @@ - T tmp; ...when != tmp Signed-off-by: Vaishali Thakkar Acked-by: Charles Keepax -- Changes Since v2: Make the patch compatible for current code sound/soc/codecs/wm5102.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Signed-off-by: Mark Brown --- sound/soc/codecs/wm5102.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index f439ae052128..7dbac8a98f6d 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -28,6 +28,7 @@ #include #include +#include #include "arizona.h" #include "wm5102.h" @@ -617,11 +618,10 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct arizona *arizona = dev_get_drvdata(codec->dev->parent); - uint16_t data; mutex_lock(&arizona->dac_comp_lock); - data = cpu_to_be16(arizona->dac_comp_coeff); - memcpy(ucontrol->value.bytes.data, &data, sizeof(data)); + put_unaligned_be16(arizona->dac_comp_coeff, + ucontrol->value.bytes.data); mutex_unlock(&arizona->dac_comp_lock); return 0; -- cgit From 69067f9d52aa325baa0d113c1f35eb98fe486bfc Mon Sep 17 00:00:00 2001 From: Jie Yang Date: Thu, 8 Jan 2015 20:12:52 +0800 Subject: ASoC: Intel: Always enable DRAM block for FW dump The first 512 bytes of data DRAM memory is used for FW dump, and this first data SRAM block should be never power gated (always on), here always enable the block(DSRAM[0]) for D0 stage. Signed-off-by: Jie Yang Signed-off-by: Mark Brown --- sound/soc/intel/sst-haswell-dsp.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c index 57039b00efc2..c42ffae5fe9f 100644 --- a/sound/soc/intel/sst-haswell-dsp.c +++ b/sound/soc/intel/sst-haswell-dsp.c @@ -306,7 +306,7 @@ static void hsw_reset(struct sst_dsp *sst) static int hsw_set_dsp_D0(struct sst_dsp *sst) { int tries = 10; - u32 reg; + u32 reg, fw_dump_bit; /* Disable core clock gating (VDRTCTL2.DCLCGE = 0) */ reg = readl(sst->addr.pci_cfg + SST_VDRTCTL2); @@ -368,7 +368,9 @@ finish: can't be accessed, please enable each block before accessing. */ reg = readl(sst->addr.pci_cfg + SST_VDRTCTL0); reg |= SST_VDRTCL0_DSRAMPGE_MASK | SST_VDRTCL0_ISRAMPGE_MASK; - writel(reg, sst->addr.pci_cfg + SST_VDRTCTL0); + /* for D0, always enable the block(DSRAM[0]) used for FW dump */ + fw_dump_bit = 1 << SST_VDRTCL0_DSRAMPGE_SHIFT; + writel(reg & ~fw_dump_bit, sst->addr.pci_cfg + SST_VDRTCTL0); /* disable DMA finish function for SSP0 & SSP1 */ @@ -491,6 +493,7 @@ static const struct sst_sram_shift sram_shift[] = { {SST_DEV_ID_LYNX_POINT, 6, 16}, /* lp */ {SST_DEV_ID_WILDCAT_POINT, 2, 12}, /* wpt */ }; + static u32 hsw_block_get_bit(struct sst_mem_block *block) { u32 bit = 0, shift = 0, index; @@ -587,7 +590,9 @@ static int hsw_block_disable(struct sst_mem_block *block) val = readl(sst->addr.pci_cfg + SST_VDRTCTL0); bit = hsw_block_get_bit(block); - writel(val | bit, sst->addr.pci_cfg + SST_VDRTCTL0); + /* don't disable DSRAM[0], keep it always enable for FW dump*/ + if (bit != (1 << SST_VDRTCL0_DSRAMPGE_SHIFT)) + writel(val | bit, sst->addr.pci_cfg + SST_VDRTCTL0); /* wait 18 DSP clock ticks */ udelay(10); @@ -612,7 +617,7 @@ static int hsw_init(struct sst_dsp *sst, struct sst_pdata *pdata) const struct sst_adsp_memregion *region; struct device *dev; int ret = -ENODEV, i, j, region_count; - u32 offset, size; + u32 offset, size, fw_dump_bit; dev = sst->dma_dev; @@ -669,9 +674,11 @@ static int hsw_init(struct sst_dsp *sst, struct sst_pdata *pdata) } } + /* always enable the block(DSRAM[0]) used for FW dump */ + fw_dump_bit = 1 << SST_VDRTCL0_DSRAMPGE_SHIFT; /* set default power gating control, enable power gating control for all blocks. that is, can't be accessed, please enable each block before accessing. */ - writel(0xffffffff, sst->addr.pci_cfg + SST_VDRTCTL0); + writel(0xffffffff & ~fw_dump_bit, sst->addr.pci_cfg + SST_VDRTCTL0); return 0; } -- cgit From 98b9c1d2ce59d98d5921bbdca5a6d7fe40b4a384 Mon Sep 17 00:00:00 2001 From: Jie Yang Date: Thu, 8 Jan 2015 14:32:20 +0800 Subject: ASoC: Intel: Add stream direction for pcm-module map A DAI may have 2 streams(playback/capture) and different modules may be needed for them respectively, so we need add a stream direction here, the combination(dai_id + stream) can tell us which module we really need here. Signed-off-by: Jie Yang Signed-off-by: Mark Brown --- sound/soc/intel/sst-haswell-pcm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index 13f156b4a612..5448f79283b7 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c @@ -78,7 +78,6 @@ static const u32 volume_map[] = { #define HSW_PCM_DAI_ID_OFFLOAD0 1 #define HSW_PCM_DAI_ID_OFFLOAD1 2 #define HSW_PCM_DAI_ID_LOOPBACK 3 -#define HSW_PCM_DAI_ID_CAPTURE 4 static const struct snd_pcm_hardware hsw_pcm_hardware = { @@ -99,6 +98,7 @@ static const struct snd_pcm_hardware hsw_pcm_hardware = { struct hsw_pcm_module_map { int dai_id; + int stream; enum sst_hsw_module_id mod_id; }; @@ -687,11 +687,11 @@ static struct snd_pcm_ops hsw_pcm_ops = { /* static mappings between PCMs and modules - may be dynamic in future */ static struct hsw_pcm_module_map mod_map[] = { - {HSW_PCM_DAI_ID_SYSTEM, SST_HSW_MODULE_PCM_SYSTEM}, - {HSW_PCM_DAI_ID_OFFLOAD0, SST_HSW_MODULE_PCM}, - {HSW_PCM_DAI_ID_OFFLOAD1, SST_HSW_MODULE_PCM}, - {HSW_PCM_DAI_ID_LOOPBACK, SST_HSW_MODULE_PCM_REFERENCE}, - {HSW_PCM_DAI_ID_CAPTURE, SST_HSW_MODULE_PCM_CAPTURE}, + {HSW_PCM_DAI_ID_SYSTEM, 0, SST_HSW_MODULE_PCM_SYSTEM}, + {HSW_PCM_DAI_ID_OFFLOAD0, 0, SST_HSW_MODULE_PCM}, + {HSW_PCM_DAI_ID_OFFLOAD1, 0, SST_HSW_MODULE_PCM}, + {HSW_PCM_DAI_ID_LOOPBACK, 1, SST_HSW_MODULE_PCM_REFERENCE}, + {HSW_PCM_DAI_ID_SYSTEM, 1, SST_HSW_MODULE_PCM_CAPTURE}, }; static int hsw_pcm_create_modules(struct hsw_priv_data *pdata) @@ -1075,7 +1075,7 @@ static void hsw_pcm_complete(struct device *dev) return; } - for (i = 0; i < HSW_PCM_DAI_ID_CAPTURE + 1; i++) { + for (i = 0; i < ARRAY_SIZE(mod_map); i++) { pcm_data = &pdata->pcm[i]; if (!pcm_data->substream) @@ -1109,7 +1109,7 @@ static int hsw_pcm_prepare(struct device *dev) if (pdata->pm_state == HSW_PM_STATE_D3) return 0; /* suspend all active streams */ - for (i = 0; i < HSW_PCM_DAI_ID_CAPTURE + 1; i++) { + for (i = 0; i < ARRAY_SIZE(mod_map); i++) { pcm_data = &pdata->pcm[i]; if (!pcm_data->substream) @@ -1128,7 +1128,7 @@ static int hsw_pcm_prepare(struct device *dev) sst_hsw_dsp_runtime_suspend(hsw); /* preserve persistent memory */ - for (i = 0; i < HSW_PCM_DAI_ID_CAPTURE + 1; i++) { + for (i = 0; i < ARRAY_SIZE(mod_map); i++) { pcm_data = &pdata->pcm[i]; if (!pcm_data->substream) -- cgit From 0c1232503ae5e792a5bef182c64daeb5cf52498d Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 7 Jan 2015 13:44:32 -0200 Subject: ASoC: fsl_ssi: Make error message concise Currently the error message uses 'np->full_name' which leads to a very verbose log as: fsl-ssi-dai 202c000.ssi: no irq for node /soc/aips-bus@02000000/spba-bus@02000000/ssi@0202c000 We can have a concise log by using pdev->name instead: fsl-ssi-dai 202c000.ssi: no irq for node 202c000.ssi Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index a65f17d57ffb..fa19507ca4e6 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -1363,7 +1363,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) ssi_private->irq = platform_get_irq(pdev, 0); if (!ssi_private->irq) { - dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); + dev_err(&pdev->dev, "no irq for node %s\n", pdev->name); return -ENXIO; } -- cgit From f03038e570728036cf6784a435e11ae1d24a5cf0 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 7 Jan 2015 13:44:33 -0200 Subject: ASoC: fsl_asrc: Make error message concise Currently the error message uses 'np->full_name' which leads to a very verbose log that contains the full path of the node. We can have a concise log by using pdev->name instead. Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 026a80117540..633ffff8d4d6 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -837,7 +837,7 @@ static int fsl_asrc_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); + dev_err(&pdev->dev, "no irq for node %s\n", pdev->name); return irq; } -- cgit From 0954237f22d808df4918ced2995ff758358881c0 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 7 Jan 2015 13:44:34 -0200 Subject: ASoC: fsl_sai: Make error message concise Currently the error message uses 'np->full_name' which leads to a very verbose log that contains the full path of the node. We can have a concise log by using pdev->name instead. Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_sai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 032d2d33619c..ec79c3d5e65e 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -612,7 +612,7 @@ static int fsl_sai_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); + dev_err(&pdev->dev, "no irq for node %s\n", pdev->name); return irq; } -- cgit From da2d45249af55f4fe7186b5aca76e8cb8e7f8a1a Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 7 Jan 2015 13:44:35 -0200 Subject: ASoC: fsl_esai: Make error message concise Currently the error message uses 'np->full_name' which leads to a very verbose log that contains the full path of the node. We can have a concise log by using pdev->name instead. Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_esai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 1c08ab13637c..5c7597191e3f 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -774,7 +774,7 @@ static int fsl_esai_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); + dev_err(&pdev->dev, "no irq for node %s\n", pdev->name); return irq; } -- cgit From b968d83f09d8a4af1c178f504bc0414bbb37651d Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 7 Jan 2015 13:44:36 -0200 Subject: ASoC: fsl_spdif: Make error message concise Currently the error message uses 'np->full_name' which leads to a very verbose log that contains the full path of the node. We can have a concise log by using pdev->name instead. Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_spdif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index af0429421fc8..735e2eec52f7 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -1198,7 +1198,7 @@ static int fsl_spdif_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); + dev_err(&pdev->dev, "no irq for node %s\n", pdev->name); return irq; } -- cgit From 277880a356c10adcb43604f6ab9ec9b2d64db8b2 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Thu, 8 Jan 2015 10:31:06 +0800 Subject: ASoC: rt5677: Add the MICBIAS VDD setting in the platform data The patch adds the MICBIAS VDD setting in the platform data. It can be set to 1V8 or 3V3 in the MICBIAS VDD. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index cf39fe6d0601..3b32c3ecbe05 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4912,6 +4912,11 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, RT5677_GPIO5_DIR_OUT); } + if (rt5677->pdata.micbias1_vdd_3v3) + regmap_update_bits(rt5677->regmap, RT5677_MICBIAS, + RT5677_MICBIAS1_CTRL_VDD_MASK, + RT5677_MICBIAS1_CTRL_VDD_3_3V); + rt5677_init_gpio(i2c); rt5677_init_irq(i2c); -- cgit From 57b7068de5d0cca8ac6e21085b843c1bbd49d3f4 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 26 Dec 2014 20:19:38 +0300 Subject: ASoC: add xtensa xtfpga I2S interface and platform XTFPGA boards provides an audio subsystem that consists of TI CDCE706 clock synthesizer, I2S transmitter and TLV320AIC23 audio codec. I2S transmitter has MMIO-based interface that resembles that of the OpenCores I2S transmitter. I2S transmitter is always a master on I2S bus. There's no specialized audio DMA, sample data are transferred to I2S transmitter FIFO by CPU through memory-mapped queue interface. Signed-off-by: Max Filippov Signed-off-by: Mark Brown --- sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/xtensa/Kconfig | 7 + sound/soc/xtensa/Makefile | 3 + sound/soc/xtensa/xtfpga-i2s.c | 675 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 687 insertions(+) create mode 100644 sound/soc/xtensa/Kconfig create mode 100644 sound/soc/xtensa/Makefile create mode 100644 sound/soc/xtensa/xtfpga-i2s.c (limited to 'sound') diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 7d5d6444a837..dcc79aa0236b 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig @@ -55,6 +55,7 @@ source "sound/soc/spear/Kconfig" source "sound/soc/tegra/Kconfig" source "sound/soc/txx9/Kconfig" source "sound/soc/ux500/Kconfig" +source "sound/soc/xtensa/Kconfig" # Supported codecs source "sound/soc/codecs/Kconfig" diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 865e090c8061..5b3c8f67c8db 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -36,3 +36,4 @@ obj-$(CONFIG_SND_SOC) += spear/ obj-$(CONFIG_SND_SOC) += tegra/ obj-$(CONFIG_SND_SOC) += txx9/ obj-$(CONFIG_SND_SOC) += ux500/ +obj-$(CONFIG_SND_SOC) += xtensa/ diff --git a/sound/soc/xtensa/Kconfig b/sound/soc/xtensa/Kconfig new file mode 100644 index 000000000000..c201beb36de6 --- /dev/null +++ b/sound/soc/xtensa/Kconfig @@ -0,0 +1,7 @@ +config SND_SOC_XTFPGA_I2S + tristate "XTFPGA I2S master" + select REGMAP_MMIO + help + Say Y or M if you want to add support for codecs attached to the + I2S interface on XTFPGA daughter board. You will also need to select + the drivers for the rest of XTFPGA audio subsystem. diff --git a/sound/soc/xtensa/Makefile b/sound/soc/xtensa/Makefile new file mode 100644 index 000000000000..15efbf914226 --- /dev/null +++ b/sound/soc/xtensa/Makefile @@ -0,0 +1,3 @@ +snd-soc-xtfpga-i2s-objs := xtfpga-i2s.o + +obj-$(CONFIG_SND_SOC_XTFPGA_I2S) += snd-soc-xtfpga-i2s.o diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c new file mode 100644 index 000000000000..1cfb19e12949 --- /dev/null +++ b/sound/soc/xtensa/xtfpga-i2s.c @@ -0,0 +1,675 @@ +/* + * Xtfpga I2S controller driver + * + * Copyright (c) 2014 Cadence Design Systems Inc. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRV_NAME "xtfpga-i2s" + +#define XTFPGA_I2S_VERSION 0x00 +#define XTFPGA_I2S_CONFIG 0x04 +#define XTFPGA_I2S_INT_MASK 0x08 +#define XTFPGA_I2S_INT_STATUS 0x0c +#define XTFPGA_I2S_CHAN0_DATA 0x10 +#define XTFPGA_I2S_CHAN1_DATA 0x14 +#define XTFPGA_I2S_CHAN2_DATA 0x18 +#define XTFPGA_I2S_CHAN3_DATA 0x1c + +#define XTFPGA_I2S_CONFIG_TX_ENABLE 0x1 +#define XTFPGA_I2S_CONFIG_INT_ENABLE 0x2 +#define XTFPGA_I2S_CONFIG_LEFT 0x4 +#define XTFPGA_I2S_CONFIG_RATIO_BASE 8 +#define XTFPGA_I2S_CONFIG_RATIO_MASK 0x0000ff00 +#define XTFPGA_I2S_CONFIG_RES_BASE 16 +#define XTFPGA_I2S_CONFIG_RES_MASK 0x003f0000 +#define XTFPGA_I2S_CONFIG_LEVEL_BASE 24 +#define XTFPGA_I2S_CONFIG_LEVEL_MASK 0x0f000000 +#define XTFPGA_I2S_CONFIG_CHANNEL_BASE 28 + +#define XTFPGA_I2S_INT_UNDERRUN 0x1 +#define XTFPGA_I2S_INT_LEVEL 0x2 +#define XTFPGA_I2S_INT_VALID 0x3 + +#define XTFPGA_I2S_FIFO_SIZE 8192 + +/* + * I2S controller operation: + * + * Enabling TX: output 1 period of zeros (starting with left channel) + * and then queued data. + * + * Level status and interrupt: whenever FIFO level is below FIFO trigger, + * level status is 1 and an IRQ is asserted (if enabled). + * + * Underrun status and interrupt: whenever FIFO is empty, underrun status + * is 1 and an IRQ is asserted (if enabled). + */ +struct xtfpga_i2s { + struct device *dev; + struct clk *clk; + struct regmap *regmap; + void __iomem *regs; + + /* current playback substream. NULL if not playing. + * + * Access to that field is synchronized between the interrupt handler + * and userspace through RCU. + * + * Interrupt handler (threaded part) does PIO on substream data in RCU + * read-side critical section. Trigger callback sets and clears the + * pointer when the playback is started and stopped with + * rcu_assign_pointer. When userspace is about to free the playback + * stream in the pcm_close callback it synchronizes with the interrupt + * handler by means of synchronize_rcu call. + */ + struct snd_pcm_substream *tx_substream; + unsigned (*tx_fn)(struct xtfpga_i2s *i2s, + struct snd_pcm_runtime *runtime, + unsigned tx_ptr); + unsigned tx_ptr; /* next frame index in the sample buffer */ + + /* current fifo level estimate. + * Doesn't have to be perfectly accurate, but must be not less than + * the actual FIFO level in order to avoid stall on push attempt. + */ + unsigned tx_fifo_level; + + /* FIFO level at which level interrupt occurs */ + unsigned tx_fifo_low; + + /* maximal FIFO level */ + unsigned tx_fifo_high; +}; + +static bool xtfpga_i2s_wr_reg(struct device *dev, unsigned int reg) +{ + return reg >= XTFPGA_I2S_CONFIG; +} + +static bool xtfpga_i2s_rd_reg(struct device *dev, unsigned int reg) +{ + return reg < XTFPGA_I2S_CHAN0_DATA; +} + +static bool xtfpga_i2s_volatile_reg(struct device *dev, unsigned int reg) +{ + return reg == XTFPGA_I2S_INT_STATUS; +} + +static const struct regmap_config xtfpga_i2s_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = XTFPGA_I2S_CHAN3_DATA, + .writeable_reg = xtfpga_i2s_wr_reg, + .readable_reg = xtfpga_i2s_rd_reg, + .volatile_reg = xtfpga_i2s_volatile_reg, + .cache_type = REGCACHE_FLAT, +}; + +/* Generate functions that do PIO from TX DMA area to FIFO for all supported + * stream formats. + * Functions will be called xtfpga_pcm_tx_x, e.g. + * xtfpga_pcm_tx_2x16 for 16-bit stereo. + * + * FIFO consists of 32-bit words, one word per channel, always 2 channels. + * If I2S interface is configured with smaller sample resolution, only + * the LSB of each word is used. + */ +#define xtfpga_pcm_tx_fn(channels, sample_bits) \ +static unsigned xtfpga_pcm_tx_##channels##x##sample_bits( \ + struct xtfpga_i2s *i2s, struct snd_pcm_runtime *runtime, \ + unsigned tx_ptr) \ +{ \ + const u##sample_bits (*p)[channels] = \ + (void *)runtime->dma_area; \ +\ + for (; i2s->tx_fifo_level < i2s->tx_fifo_high; \ + i2s->tx_fifo_level += 2) { \ + iowrite32(p[tx_ptr][0], \ + i2s->regs + XTFPGA_I2S_CHAN0_DATA); \ + iowrite32(p[tx_ptr][channels - 1], \ + i2s->regs + XTFPGA_I2S_CHAN0_DATA); \ + if (++tx_ptr >= runtime->buffer_size) \ + tx_ptr = 0; \ + } \ + return tx_ptr; \ +} + +xtfpga_pcm_tx_fn(1, 16) +xtfpga_pcm_tx_fn(2, 16) +xtfpga_pcm_tx_fn(1, 32) +xtfpga_pcm_tx_fn(2, 32) + +#undef xtfpga_pcm_tx_fn + +static bool xtfpga_pcm_push_tx(struct xtfpga_i2s *i2s) +{ + struct snd_pcm_substream *tx_substream; + bool tx_active; + + rcu_read_lock(); + tx_substream = rcu_dereference(i2s->tx_substream); + tx_active = tx_substream && snd_pcm_running(tx_substream); + if (tx_active) { + unsigned tx_ptr = ACCESS_ONCE(i2s->tx_ptr); + unsigned new_tx_ptr = i2s->tx_fn(i2s, tx_substream->runtime, + tx_ptr); + + cmpxchg(&i2s->tx_ptr, tx_ptr, new_tx_ptr); + } + rcu_read_unlock(); + + return tx_active; +} + +static void xtfpga_pcm_refill_fifo(struct xtfpga_i2s *i2s) +{ + unsigned int_status; + unsigned i; + + regmap_read(i2s->regmap, XTFPGA_I2S_INT_STATUS, + &int_status); + + for (i = 0; i < 2; ++i) { + bool tx_active = xtfpga_pcm_push_tx(i2s); + + regmap_write(i2s->regmap, XTFPGA_I2S_INT_STATUS, + XTFPGA_I2S_INT_VALID); + if (tx_active) + regmap_read(i2s->regmap, XTFPGA_I2S_INT_STATUS, + &int_status); + + if (!tx_active || + !(int_status & XTFPGA_I2S_INT_LEVEL)) + break; + + /* After the push the level IRQ is still asserted, + * means FIFO level is below tx_fifo_low. Estimate + * it as tx_fifo_low. + */ + i2s->tx_fifo_level = i2s->tx_fifo_low; + } + + if (!(int_status & XTFPGA_I2S_INT_LEVEL)) + regmap_write(i2s->regmap, XTFPGA_I2S_INT_MASK, + XTFPGA_I2S_INT_VALID); + else if (!(int_status & XTFPGA_I2S_INT_UNDERRUN)) + regmap_write(i2s->regmap, XTFPGA_I2S_INT_MASK, + XTFPGA_I2S_INT_UNDERRUN); + + if (!(int_status & XTFPGA_I2S_INT_UNDERRUN)) + regmap_update_bits(i2s->regmap, XTFPGA_I2S_CONFIG, + XTFPGA_I2S_CONFIG_INT_ENABLE | + XTFPGA_I2S_CONFIG_TX_ENABLE, + XTFPGA_I2S_CONFIG_INT_ENABLE | + XTFPGA_I2S_CONFIG_TX_ENABLE); + else + regmap_update_bits(i2s->regmap, XTFPGA_I2S_CONFIG, + XTFPGA_I2S_CONFIG_INT_ENABLE | + XTFPGA_I2S_CONFIG_TX_ENABLE, 0); +} + +static irqreturn_t xtfpga_i2s_threaded_irq_handler(int irq, void *dev_id) +{ + struct xtfpga_i2s *i2s = dev_id; + struct snd_pcm_substream *tx_substream; + unsigned config, int_status, int_mask; + + regmap_read(i2s->regmap, XTFPGA_I2S_CONFIG, &config); + regmap_read(i2s->regmap, XTFPGA_I2S_INT_MASK, &int_mask); + regmap_read(i2s->regmap, XTFPGA_I2S_INT_STATUS, &int_status); + + if (!(config & XTFPGA_I2S_CONFIG_INT_ENABLE) || + !(int_status & int_mask & XTFPGA_I2S_INT_VALID)) + return IRQ_NONE; + + /* Update FIFO level estimate in accordance with interrupt status + * register. + */ + if (int_status & XTFPGA_I2S_INT_UNDERRUN) { + i2s->tx_fifo_level = 0; + regmap_update_bits(i2s->regmap, XTFPGA_I2S_CONFIG, + XTFPGA_I2S_CONFIG_TX_ENABLE, 0); + } else { + /* The FIFO isn't empty, but is below tx_fifo_low. Estimate + * it as tx_fifo_low. + */ + i2s->tx_fifo_level = i2s->tx_fifo_low; + } + + rcu_read_lock(); + tx_substream = rcu_dereference(i2s->tx_substream); + + if (tx_substream && snd_pcm_running(tx_substream)) { + snd_pcm_period_elapsed(tx_substream); + if (int_status & XTFPGA_I2S_INT_UNDERRUN) + dev_dbg_ratelimited(i2s->dev, "%s: underrun\n", + __func__); + } + rcu_read_unlock(); + + /* Refill FIFO, update allowed IRQ reasons, enable IRQ if FIFO is + * not empty. + */ + xtfpga_pcm_refill_fifo(i2s); + + return IRQ_HANDLED; +} + +static int xtfpga_i2s_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct xtfpga_i2s *i2s = snd_soc_dai_get_drvdata(dai); + + snd_soc_dai_set_dma_data(dai, substream, i2s); + return 0; +} + +static int xtfpga_i2s_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct xtfpga_i2s *i2s = snd_soc_dai_get_drvdata(dai); + unsigned srate = params_rate(params); + unsigned channels = params_channels(params); + unsigned period_size = params_period_size(params); + unsigned sample_size = snd_pcm_format_width(params_format(params)); + unsigned freq, ratio, level; + int err; + + regmap_update_bits(i2s->regmap, XTFPGA_I2S_CONFIG, + XTFPGA_I2S_CONFIG_RES_MASK, + sample_size << XTFPGA_I2S_CONFIG_RES_BASE); + + freq = 256 * srate; + err = clk_set_rate(i2s->clk, freq); + if (err < 0) + return err; + + /* ratio field of the config register controls MCLK->I2S clock + * derivation: I2S clock = MCLK / (2 * (ratio + 2)). + * + * So with MCLK = 256 * sample rate ratio is 0 for 32 bit stereo + * and 2 for 16 bit stereo. + */ + ratio = (freq - (srate * sample_size * 8)) / + (srate * sample_size * 4); + + regmap_update_bits(i2s->regmap, XTFPGA_I2S_CONFIG, + XTFPGA_I2S_CONFIG_RATIO_MASK, + ratio << XTFPGA_I2S_CONFIG_RATIO_BASE); + + i2s->tx_fifo_low = XTFPGA_I2S_FIFO_SIZE / 2; + + /* period_size * 2: FIFO always gets 2 samples per frame */ + for (level = 1; + i2s->tx_fifo_low / 2 >= period_size * 2 && + level < (XTFPGA_I2S_CONFIG_LEVEL_MASK >> + XTFPGA_I2S_CONFIG_LEVEL_BASE); ++level) + i2s->tx_fifo_low /= 2; + + i2s->tx_fifo_high = 2 * i2s->tx_fifo_low; + + regmap_update_bits(i2s->regmap, XTFPGA_I2S_CONFIG, + XTFPGA_I2S_CONFIG_LEVEL_MASK, + level << XTFPGA_I2S_CONFIG_LEVEL_BASE); + + dev_dbg(i2s->dev, + "%s srate: %u, channels: %u, sample_size: %u, period_size: %u\n", + __func__, srate, channels, sample_size, period_size); + dev_dbg(i2s->dev, "%s freq: %u, ratio: %u, level: %u\n", + __func__, freq, ratio, level); + + return 0; +} + +static int xtfpga_i2s_set_fmt(struct snd_soc_dai *cpu_dai, + unsigned int fmt) +{ + if ((fmt & SND_SOC_DAIFMT_INV_MASK) != SND_SOC_DAIFMT_NB_NF) + return -EINVAL; + if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) + return -EINVAL; + if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_I2S) + return -EINVAL; + + return 0; +} + +/* PCM */ + +static const struct snd_pcm_hardware xtfpga_pcm_hardware = { + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_BLOCK_TRANSFER, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 1, + .channels_max = 2, + .period_bytes_min = 2, + .period_bytes_max = XTFPGA_I2S_FIFO_SIZE / 2 * 8, + .periods_min = 2, + .periods_max = XTFPGA_I2S_FIFO_SIZE * 8 / 2, + .buffer_bytes_max = XTFPGA_I2S_FIFO_SIZE * 8, + .fifo_size = 16, +}; + +static int xtfpga_pcm_open(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + void *p; + + snd_soc_set_runtime_hwparams(substream, &xtfpga_pcm_hardware); + p = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); + runtime->private_data = p; + + return 0; +} + +static int xtfpga_pcm_close(struct snd_pcm_substream *substream) +{ + synchronize_rcu(); + return 0; +} + +static int xtfpga_pcm_hw_params(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); + + switch (channels) { + case 1: + case 2: + break; + + default: + return -EINVAL; + + } + + switch (params_format(hw_params)) { + case SNDRV_PCM_FORMAT_S16_LE: + i2s->tx_fn = (channels == 1) ? + xtfpga_pcm_tx_1x16 : + xtfpga_pcm_tx_2x16; + break; + + case SNDRV_PCM_FORMAT_S32_LE: + i2s->tx_fn = (channels == 1) ? + xtfpga_pcm_tx_1x32 : + xtfpga_pcm_tx_2x32; + break; + + default: + return -EINVAL; + } + + ret = snd_pcm_lib_malloc_pages(substream, + params_buffer_bytes(hw_params)); + return ret; +} + +static int xtfpga_pcm_trigger(struct snd_pcm_substream *substream, int cmd) +{ + int ret = 0; + struct snd_pcm_runtime *runtime = substream->runtime; + struct xtfpga_i2s *i2s = runtime->private_data; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + ACCESS_ONCE(i2s->tx_ptr) = 0; + rcu_assign_pointer(i2s->tx_substream, substream); + xtfpga_pcm_refill_fifo(i2s); + break; + + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + rcu_assign_pointer(i2s->tx_substream, NULL); + break; + + default: + ret = -EINVAL; + break; + } + return ret; +} + +static snd_pcm_uframes_t xtfpga_pcm_pointer(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct xtfpga_i2s *i2s = runtime->private_data; + snd_pcm_uframes_t pos = ACCESS_ONCE(i2s->tx_ptr); + + return pos < runtime->buffer_size ? pos : 0; +} + +static int xtfpga_pcm_new(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_card *card = rtd->card->snd_card; + size_t size = xtfpga_pcm_hardware.buffer_bytes_max; + + return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, + SNDRV_DMA_TYPE_DEV, + card->dev, size, size); +} + +static void xtfpga_pcm_free(struct snd_pcm *pcm) +{ + snd_pcm_lib_preallocate_free_for_all(pcm); +} + +static const struct snd_pcm_ops xtfpga_pcm_ops = { + .open = xtfpga_pcm_open, + .close = xtfpga_pcm_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = xtfpga_pcm_hw_params, + .trigger = xtfpga_pcm_trigger, + .pointer = xtfpga_pcm_pointer, +}; + +static const struct snd_soc_platform_driver xtfpga_soc_platform = { + .pcm_new = xtfpga_pcm_new, + .pcm_free = xtfpga_pcm_free, + .ops = &xtfpga_pcm_ops, +}; + +static const struct snd_soc_component_driver xtfpga_i2s_component = { + .name = DRV_NAME, +}; + +static const struct snd_soc_dai_ops xtfpga_i2s_dai_ops = { + .startup = xtfpga_i2s_startup, + .hw_params = xtfpga_i2s_hw_params, + .set_fmt = xtfpga_i2s_set_fmt, +}; + +static struct snd_soc_dai_driver xtfpga_i2s_dai[] = { + { + .name = "xtfpga-i2s", + .id = 0, + .playback = { + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_96000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S32_LE, + }, + .ops = &xtfpga_i2s_dai_ops, + }, +}; + +static int xtfpga_i2s_runtime_suspend(struct device *dev) +{ + struct xtfpga_i2s *i2s = dev_get_drvdata(dev); + + clk_disable_unprepare(i2s->clk); + return 0; +} + +static int xtfpga_i2s_runtime_resume(struct device *dev) +{ + struct xtfpga_i2s *i2s = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(i2s->clk); + if (ret) { + dev_err(dev, "clk_prepare_enable failed: %d\n", ret); + return ret; + } + return 0; +} + +static int xtfpga_i2s_probe(struct platform_device *pdev) +{ + struct xtfpga_i2s *i2s; + struct resource *mem; + int err, irq; + + i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); + if (!i2s) { + err = -ENOMEM; + goto err; + } + platform_set_drvdata(pdev, i2s); + i2s->dev = &pdev->dev; + dev_dbg(&pdev->dev, "dev: %p, i2s: %p\n", &pdev->dev, i2s); + + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + i2s->regs = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(i2s->regs)) { + err = PTR_ERR(i2s->regs); + goto err; + } + + i2s->regmap = devm_regmap_init_mmio(&pdev->dev, i2s->regs, + &xtfpga_i2s_regmap_config); + if (IS_ERR(i2s->regmap)) { + dev_err(&pdev->dev, "regmap init failed\n"); + err = PTR_ERR(i2s->regmap); + goto err; + } + + i2s->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(i2s->clk)) { + dev_err(&pdev->dev, "couldn't get clock\n"); + err = PTR_ERR(i2s->clk); + goto err; + } + + regmap_write(i2s->regmap, XTFPGA_I2S_CONFIG, + (0x1 << XTFPGA_I2S_CONFIG_CHANNEL_BASE)); + regmap_write(i2s->regmap, XTFPGA_I2S_INT_STATUS, XTFPGA_I2S_INT_VALID); + regmap_write(i2s->regmap, XTFPGA_I2S_INT_MASK, XTFPGA_I2S_INT_UNDERRUN); + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(&pdev->dev, "No IRQ resource\n"); + err = irq; + goto err; + } + err = devm_request_threaded_irq(&pdev->dev, irq, NULL, + xtfpga_i2s_threaded_irq_handler, + IRQF_SHARED | IRQF_ONESHOT, + pdev->name, i2s); + if (err < 0) { + dev_err(&pdev->dev, "request_irq failed\n"); + goto err; + } + + err = snd_soc_register_platform(&pdev->dev, &xtfpga_soc_platform); + if (err < 0) { + dev_err(&pdev->dev, "couldn't register platform\n"); + goto err; + } + err = devm_snd_soc_register_component(&pdev->dev, + &xtfpga_i2s_component, + xtfpga_i2s_dai, + ARRAY_SIZE(xtfpga_i2s_dai)); + if (err < 0) { + dev_err(&pdev->dev, "couldn't register component\n"); + goto err_unregister_platform; + } + + pm_runtime_enable(&pdev->dev); + if (!pm_runtime_enabled(&pdev->dev)) { + err = xtfpga_i2s_runtime_resume(&pdev->dev); + if (err) + goto err_pm_disable; + } + return 0; + +err_pm_disable: + pm_runtime_disable(&pdev->dev); +err_unregister_platform: + snd_soc_unregister_platform(&pdev->dev); +err: + dev_err(&pdev->dev, "%s: err = %d\n", __func__, err); + return err; +} + +static int xtfpga_i2s_remove(struct platform_device *pdev) +{ + struct xtfpga_i2s *i2s = dev_get_drvdata(&pdev->dev); + + snd_soc_unregister_platform(&pdev->dev); + if (i2s->regmap && !IS_ERR(i2s->regmap)) { + regmap_write(i2s->regmap, XTFPGA_I2S_CONFIG, 0); + regmap_write(i2s->regmap, XTFPGA_I2S_INT_MASK, 0); + regmap_write(i2s->regmap, XTFPGA_I2S_INT_STATUS, + XTFPGA_I2S_INT_VALID); + } + pm_runtime_disable(&pdev->dev); + if (!pm_runtime_status_suspended(&pdev->dev)) + xtfpga_i2s_runtime_suspend(&pdev->dev); + return 0; +} + +#ifdef CONFIG_OF +static const struct of_device_id xtfpga_i2s_of_match[] = { + { .compatible = "cdns,xtfpga-i2s", }, + {}, +}; +MODULE_DEVICE_TABLE(of, xtfpga_i2s_of_match); +#endif + +static const struct dev_pm_ops xtfpga_i2s_pm_ops = { + SET_RUNTIME_PM_OPS(xtfpga_i2s_runtime_suspend, + xtfpga_i2s_runtime_resume, NULL) +}; + +static struct platform_driver xtfpga_i2s_driver = { + .probe = xtfpga_i2s_probe, + .remove = xtfpga_i2s_remove, + .driver = { + .name = "xtfpga-i2s", + .of_match_table = of_match_ptr(xtfpga_i2s_of_match), + .pm = &xtfpga_i2s_pm_ops, + }, +}; + +module_platform_driver(xtfpga_i2s_driver); + +MODULE_AUTHOR("Max Filippov "); +MODULE_DESCRIPTION("xtfpga I2S controller driver"); +MODULE_LICENSE("GPL v2"); -- cgit From c4eaa62fdac3cdbf358e19625477ffc9a15d4c7b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:40:23 +0100 Subject: ALSA: ali5451: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/ali5451/ali5451.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index af89e42b2160..4cd2210fd95c 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1873,7 +1873,6 @@ static int snd_ali_mixer(struct snd_ali *codec) #ifdef CONFIG_PM_SLEEP static int ali_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ali *chip = card->private_data; struct snd_ali_image *im; @@ -1914,16 +1913,11 @@ static int ali_suspend(struct device *dev) outl(0xffffffff, ALI_REG(chip, ALI_STOP)); spin_unlock_irq(&chip->reg_lock); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int ali_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ali *chip = card->private_data; struct snd_ali_image *im; @@ -1933,15 +1927,6 @@ static int ali_resume(struct device *dev) if (!im) return 0; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - spin_lock_irq(&chip->reg_lock); for (i = 0; i < ALI_CHANNELS; i++) { -- cgit From 08aa0e34305059a80f38e039f085fe91a7587cca Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:43:46 +0100 Subject: ALSA: als300: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/als300.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 7bb6ac565107..bd01113de39a 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -728,35 +728,20 @@ static int snd_als300_create(struct snd_card *card, #ifdef CONFIG_PM_SLEEP static int snd_als300_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_als300 *chip = card->private_data; snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_als300_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_als300 *chip = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_als300_init(chip); snd_ac97_resume(chip->ac97); -- cgit From dc3b10eb64edd977fb5173f72fc66cc8687e61be Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:44:01 +0100 Subject: ALSA: als4000: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/als4000.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index d3e6424ee656..94608524f3cc 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -988,7 +988,6 @@ static void snd_card_als4000_remove(struct pci_dev *pci) #ifdef CONFIG_PM_SLEEP static int snd_als4000_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_card_als4000 *acard = card->private_data; struct snd_sb *chip = acard->chip; @@ -997,29 +996,15 @@ static int snd_als4000_suspend(struct device *dev) snd_pcm_suspend_all(chip->pcm); snd_sbmixer_suspend(chip); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_als4000_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_card_als4000 *acard = card->private_data; struct snd_sb *chip = acard->chip; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_als4000_configure(chip); snd_sbdsp_reset(chip); snd_sbmixer_resume(chip); -- cgit From 94af14691d3783629f5d186acfb1f700fb68ff03 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:44:18 +0100 Subject: ALSA: atiixp: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 9c1c4452a8ee..f41de00d974c 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1474,7 +1474,6 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock, */ static int snd_atiixp_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct atiixp *chip = card->private_data; int i; @@ -1492,29 +1491,15 @@ static int snd_atiixp_suspend(struct device *dev) snd_ac97_suspend(chip->ac97[i]); snd_atiixp_aclink_down(chip); snd_atiixp_chip_stop(chip); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_atiixp_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct atiixp *chip = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_atiixp_aclink_reset(chip); snd_atiixp_chip_start(chip); -- cgit From 2b5d0891ba8555c8edc21098715324d90a4d5de0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:44:30 +0100 Subject: ALSA: atiixp-modem: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/atiixp_modem.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index b2f63e0727de..7cf419786b6e 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1120,7 +1120,6 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) */ static int snd_atiixp_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct atiixp_modem *chip = card->private_data; int i; @@ -1132,29 +1131,15 @@ static int snd_atiixp_suspend(struct device *dev) snd_ac97_suspend(chip->ac97[i]); snd_atiixp_aclink_down(chip); snd_atiixp_chip_stop(chip); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_atiixp_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct atiixp_modem *chip = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_atiixp_aclink_reset(chip); snd_atiixp_chip_start(chip); -- cgit From 3a7ed36909a6c4aee677100ff1a45869a5873a12 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:44:47 +0100 Subject: ALSA: azt3328: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/azt3328.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index fdbb9c05c77b..bbacc75c902a 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -2694,7 +2694,6 @@ snd_azf3328_resume_ac97(const struct snd_azf3328 *chip) static int snd_azf3328_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_azf3328 *chip = card->private_data; u16 *saved_regs_ctrl_u16; @@ -2720,29 +2719,15 @@ snd_azf3328_suspend(struct device *dev) ARRAY_SIZE(chip->saved_regs_mpu), chip->saved_regs_mpu); snd_azf3328_suspend_regs(chip, chip->opl3_io, ARRAY_SIZE(chip->saved_regs_opl3), chip->saved_regs_opl3); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_azf3328_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); const struct snd_azf3328 *chip = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_azf3328_resume_regs(chip, chip->saved_regs_game, chip->game_io, ARRAY_SIZE(chip->saved_regs_game)); snd_azf3328_resume_regs(chip, chip->saved_regs_mpu, chip->mpu_io, -- cgit From 11afa6426c4ff69cc58f0b91e85cf17f31c0a442 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:44:59 +0100 Subject: ALSA: ca0106: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'sound') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 96af33965b51..dd75b7536fa2 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1910,7 +1910,6 @@ static void snd_ca0106_remove(struct pci_dev *pci) #ifdef CONFIG_PM_SLEEP static int snd_ca0106_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ca0106 *chip = card->private_data; int i; @@ -1923,30 +1922,15 @@ static int snd_ca0106_suspend(struct device *dev) snd_ca0106_mixer_suspend(chip); ca0106_stop_chip(chip); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_ca0106_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ca0106 *chip = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - - if (pci_enable_device(pci) < 0) { - snd_card_disconnect(card); - return -EIO; - } - - pci_set_master(pci); - ca0106_init_chip(chip, 1); if (chip->details->ac97) -- cgit From 5762fdb5f9b18a5bf8cdbdfbc0c735ad1d88a478 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:45:12 +0100 Subject: ALSA: cmipci: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/cmipci.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 85ed40339db9..63d2c8236ec6 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -3347,7 +3347,6 @@ static unsigned char saved_mixers[] = { static int snd_cmipci_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct cmipci *cm = card->private_data; int i; @@ -3366,29 +3365,15 @@ static int snd_cmipci_suspend(struct device *dev) /* disable ints */ snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_cmipci_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct cmipci *cm = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - /* reset / initialize to a sane state */ snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); snd_cmipci_ch_reset(cm, CM_CH_PLAY); -- cgit From faab5223930114b0a33f8c712c14799967342e8c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:45:22 +0100 Subject: ALSA: cs4281: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/cs4281.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 4c49b5c8a7b3..80bb1d11da12 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -2008,7 +2008,6 @@ static int saved_regs[SUSPEND_REGISTERS] = { static int cs4281_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct cs4281 *chip = card->private_data; u32 ulCLK; @@ -2047,30 +2046,16 @@ static int cs4281_suspend(struct device *dev) ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); ulCLK &= ~CLKCR1_CKRA; snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int cs4281_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct cs4281 *chip = card->private_data; unsigned int i; u32 ulCLK; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); ulCLK |= CLKCR1_CKRA; snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK); -- cgit From 319184680d7ecbea5718fa1ab73105ef8abb478f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:45:32 +0100 Subject: ALSA: cs46xx: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/cs46xx/cs46xx_lib.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 32b44f25b5c8..ba97aba8d87e 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -3804,7 +3804,6 @@ static unsigned int saved_regs[] = { static int snd_cs46xx_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_cs46xx *chip = card->private_data; int i, amp_saved; @@ -3829,16 +3828,11 @@ static int snd_cs46xx_suspend(struct device *dev) /* disable CLKRUN */ chip->active_ctrl(chip, -chip->amplifier); chip->amplifier = amp_saved; /* restore the status */ - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_cs46xx_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_cs46xx *chip = card->private_data; int amp_saved; @@ -3847,15 +3841,6 @@ static int snd_cs46xx_resume(struct device *dev) #endif unsigned int tmp; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - amp_saved = chip->amplifier; chip->amplifier = 0; chip->active_ctrl(chip, 1); /* force to on */ -- cgit From b8375122b59b1362e94ccd8502cff3cfef4cf168 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:45:43 +0100 Subject: ALSA: cs5535audio: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_pm.c | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_pm.c b/sound/pci/cs5535audio/cs5535audio_pm.c index 34cc60057d0c..06ac5d8da362 100644 --- a/sound/pci/cs5535audio/cs5535audio_pm.c +++ b/sound/pci/cs5535audio/cs5535audio_pm.c @@ -57,7 +57,6 @@ static void snd_cs5535audio_stop_hardware(struct cs5535audio *cs5535au) static int snd_cs5535audio_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct cs5535audio *cs5535au = card->private_data; int i; @@ -72,34 +71,17 @@ static int snd_cs5535audio_suspend(struct device *dev) } /* save important regs, then disable aclink in hw */ snd_cs5535audio_stop_hardware(cs5535au); - - if (pci_save_state(pci)) { - dev_err(dev, "pci_save_state failed!\n"); - return -EIO; - } - pci_disable_device(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_cs5535audio_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct cs5535audio *cs5535au = card->private_data; u32 tmp; int timeout; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - /* set LNK_WRM_RST to reset AC link */ cs_writel(cs5535au, ACC_CODEC_CNTL, ACC_CODEC_CNTL_LNK_WRM_RST); -- cgit From 7247aabd5ace16677681f815cc34f84ef0278261 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:45:55 +0100 Subject: ALSA: ctxfi: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/cthw20k1.c | 9 --------- sound/pci/ctxfi/cthw20k2.c | 12 ------------ 2 files changed, 21 deletions(-) (limited to 'sound') diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index b425aa8ee578..f16bec129c0a 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c @@ -2099,20 +2099,11 @@ static int hw_suspend(struct hw *hw) pci_write_config_dword(pci, UAA_CFG_SPACE_FLAG, 0x0); } - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); - return 0; } static int hw_resume(struct hw *hw, struct card_conf *info) { - struct pci_dev *pci = hw->pci; - - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - /* Re-initialize card hardware. */ return hw_card_init(hw, info); } diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 253899d13790..613671d330b1 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -2209,24 +2209,12 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) #ifdef CONFIG_PM_SLEEP static int hw_suspend(struct hw *hw) { - struct pci_dev *pci = hw->pci; - hw_card_stop(hw); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); - return 0; } static int hw_resume(struct hw *hw, struct card_conf *info) { - struct pci_dev *pci = hw->pci; - - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - /* Re-initialize card hardware. */ return hw_card_init(hw, info); } -- cgit From f84edab4b59bd004853224703acb03628af6c2ce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:46:07 +0100 Subject: ALSA: echoaudio: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/echoaudio.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 21228adaa70c..58960841ae7c 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -2162,7 +2162,6 @@ ctl_error: static int snd_echo_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct echoaudio *chip = dev_get_drvdata(dev); snd_pcm_suspend_all(chip->analog_pcm); @@ -2188,9 +2187,6 @@ static int snd_echo_suspend(struct device *dev) chip->dsp_code = NULL; free_irq(chip->irq, chip); chip->irq = -1; - pci_save_state(pci); - pci_disable_device(pci); - return 0; } @@ -2204,7 +2200,6 @@ static int snd_echo_resume(struct device *dev) u32 pipe_alloc_mask; int err; - pci_restore_state(pci); commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL); if (commpage_bak == NULL) return -ENOMEM; -- cgit From 1aa1813b2c29b25de798dc465dffd56124f94e60 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:46:58 +0100 Subject: ALSA: emu10k1: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 4c171636efcd..1d262ba2a44a 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -210,7 +210,6 @@ static void snd_card_emu10k1_remove(struct pci_dev *pci) #ifdef CONFIG_PM_SLEEP static int snd_emu10k1_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_emu10k1 *emu = card->private_data; @@ -232,28 +231,14 @@ static int snd_emu10k1_suspend(struct device *dev) snd_p16v_suspend(emu); snd_emu10k1_done(emu); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_emu10k1_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_emu10k1 *emu = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_emu10k1_resume_init(emu); snd_emu10k1_efx_resume(emu); snd_ac97_resume(emu->ac97); -- cgit From 943cf2839637231bdb2710753b457651ea1b7204 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:47:10 +0100 Subject: ALSA: ens137x: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/ens1370.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index d94cb3ca7a64..1badd91f6283 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -2049,7 +2049,6 @@ static void snd_ensoniq_chip_init(struct ensoniq *ensoniq) #ifdef CONFIG_PM_SLEEP static int snd_ensoniq_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct ensoniq *ensoniq = card->private_data; @@ -2070,28 +2069,14 @@ static int snd_ensoniq_suspend(struct device *dev) udelay(100); snd_ak4531_suspend(ensoniq->u.es1370.ak4531); #endif - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_ensoniq_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct ensoniq *ensoniq = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_ensoniq_chip_init(ensoniq); #ifdef CHIP1371 -- cgit From 8c3698219119612c239e387e423aa9d90040bc64 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:47:21 +0100 Subject: ALSA: es1938: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/es1938.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'sound') diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 0fc46eb4e251..a01454b545a0 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1454,7 +1454,6 @@ static unsigned char saved_regs[SAVED_REG_SIZE+1] = { static int es1938_suspend(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; @@ -1471,9 +1470,6 @@ static int es1938_suspend(struct device *dev) free_irq(chip->irq, chip); chip->irq = -1; } - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } @@ -1484,14 +1480,6 @@ static int es1938_resume(struct device *dev) struct es1938 *chip = card->private_data; unsigned char *s, *d; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { dev_err(dev, "unable to grab IRQ %d, disabling device\n", -- cgit From 8b1db4df201b9ad1f5a329438b823e120d463a96 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:47:31 +0100 Subject: ALSA: es1968: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/es1968.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'sound') diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 6039700f8579..631be029f8c0 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2383,7 +2383,6 @@ static void snd_es1968_start_irq(struct es1968 *chip) */ static int es1968_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct es1968 *chip = card->private_data; @@ -2396,16 +2395,11 @@ static int es1968_suspend(struct device *dev) snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); snd_es1968_bob_stop(chip); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int es1968_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct es1968 *chip = card->private_data; struct esschan *es; @@ -2413,16 +2407,6 @@ static int es1968_resume(struct device *dev) if (! chip->do_pm) return 0; - /* restore all our config */ - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_es1968_chip_init(chip); /* need to restore the base pointers.. */ -- cgit From e2a711f1b59d59e95f58d1e32e5fbcb7a7a28217 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:47:42 +0100 Subject: ALSA: hda: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index d426a0bd6a5f..99ae4e0d9c07 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -795,7 +795,6 @@ static int param_set_xint(const char *val, const struct kernel_param *kp) */ static int azx_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct azx *chip; struct hda_intel *hda; @@ -824,9 +823,6 @@ static int azx_suspend(struct device *dev) if (chip->msi) pci_disable_msi(chip->pci); - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) hda_display_power(false); return 0; @@ -851,15 +847,6 @@ static int azx_resume(struct device *dev) hda_display_power(true); haswell_set_bclk(chip); } - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(chip->card->dev, - "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); if (chip->msi) if (pci_enable_msi(pci) < 0) chip->msi = 0; -- cgit From b60dc62f5b078222e895aae21b71da968ae101a8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:47:55 +0100 Subject: ALSA: ice1712: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ice1712.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'sound') diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index b039b46152c6..e1560bf0d26a 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -2798,7 +2798,6 @@ static void snd_ice1712_remove(struct pci_dev *pci) #ifdef CONFIG_PM_SLEEP static int snd_ice1712_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ice1712 *ice = card->private_data; @@ -2820,16 +2819,11 @@ static int snd_ice1712_suspend(struct device *dev) if (ice->pm_suspend) ice->pm_suspend(ice); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_ice1712_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ice1712 *ice = card->private_data; int rate; @@ -2837,16 +2831,6 @@ static int snd_ice1712_resume(struct device *dev) if (!ice->pm_suspend_enabled) return 0; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - - if (pci_enable_device(pci) < 0) { - snd_card_disconnect(card); - return -EIO; - } - - pci_set_master(pci); - if (ice->cur_rate) rate = ice->cur_rate; else -- cgit From 88942503538c7ef9636858851abbe50a96db3800 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:48:05 +0100 Subject: ALSA: ice1724: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ice1724.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'sound') diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index d73da157ea14..0b22c00642bb 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2798,7 +2798,6 @@ static void snd_vt1724_remove(struct pci_dev *pci) #ifdef CONFIG_PM_SLEEP static int snd_vt1724_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ice1712 *ice = card->private_data; @@ -2821,32 +2820,17 @@ static int snd_vt1724_suspend(struct device *dev) if (ice->pm_suspend) ice->pm_suspend(ice); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_vt1724_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ice1712 *ice = card->private_data; if (!ice->pm_suspend_enabled) return 0; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - - if (pci_enable_device(pci) < 0) { - snd_card_disconnect(card); - return -EIO; - } - - pci_set_master(pci); - snd_vt1724_chip_reset(ice); if (snd_vt1724_chip_init(ice) < 0) { -- cgit From 3c5a03d490d7b6494f3ec028718770a44520ba29 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:48:15 +0100 Subject: ALSA: intel8x0: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 4a28252a42b9..67f9e8b77385 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2654,7 +2654,6 @@ static int snd_intel8x0_free(struct intel8x0 *chip) */ static int intel8x0_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct intel8x0 *chip = card->private_data; int i; @@ -2682,12 +2681,6 @@ static int intel8x0_suspend(struct device *dev) free_irq(chip->irq, chip); chip->irq = -1; } - pci_disable_device(pci); - pci_save_state(pci); - /* The call below may disable built-in speaker on some laptops - * after S2RAM. So, don't touch it. - */ - /* pci_set_power_state(pci, PCI_D3hot); */ return 0; } @@ -2698,14 +2691,6 @@ static int intel8x0_resume(struct device *dev) struct intel8x0 *chip = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); snd_intel8x0_chip_init(chip, 0); if (request_irq(pci->irq, snd_intel8x0_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { -- cgit From 65fe5b946e5c0dffb7554cccaff3ab075eec7146 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:48:27 +0100 Subject: ALSA: intel8x0m: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/intel8x0m.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'sound') diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 6b40235be13c..748f6f67c982 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1023,7 +1023,6 @@ static int snd_intel8x0m_free(struct intel8x0m *chip) */ static int intel8x0m_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct intel8x0m *chip = card->private_data; int i; @@ -1036,9 +1035,6 @@ static int intel8x0m_suspend(struct device *dev) free_irq(chip->irq, chip); chip->irq = -1; } - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } @@ -1048,14 +1044,6 @@ static int intel8x0m_resume(struct device *dev) struct snd_card *card = dev_get_drvdata(dev); struct intel8x0m *chip = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); if (request_irq(pci->irq, snd_intel8x0m_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { dev_err(dev, "unable to grab IRQ %d, disabling device\n", -- cgit From cd86f4593db6ca0256b23a33af5577d5239e78ce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:48:50 +0100 Subject: ALSA: maestro3: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/maestro3.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 98823d11d485..18a60be63266 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2395,7 +2395,6 @@ static int snd_m3_free(struct snd_m3 *chip) #ifdef CONFIG_PM_SLEEP static int m3_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_m3 *chip = card->private_data; int i, dsp_index; @@ -2421,16 +2420,11 @@ static int m3_suspend(struct device *dev) for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++) chip->suspend_mem[dsp_index++] = snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int m3_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_m3 *chip = card->private_data; int i, dsp_index; @@ -2438,15 +2432,6 @@ static int m3_resume(struct device *dev) if (chip->suspend_mem == NULL) return 0; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - /* first lets just bring everything back. .*/ snd_m3_outw(chip, 0, 0x54); snd_m3_outw(chip, 0, 0x56); -- cgit From fc9b6061cf9c42460e482f7a5947ee8120ff0960 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:49:03 +0100 Subject: ALSA: nm256: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/nm256/nm256.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'sound') diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 4e41a4e29a1e..8598f2b47eb3 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1392,7 +1392,6 @@ snd_nm256_peek_for_sig(struct nm256 *chip) */ static int nm256_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct nm256 *chip = card->private_data; @@ -1400,15 +1399,11 @@ static int nm256_suspend(struct device *dev) snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); chip->coeffs_current = 0; - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int nm256_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct nm256 *chip = card->private_data; int i; @@ -1416,15 +1411,6 @@ static int nm256_resume(struct device *dev) /* Perform a full reset on the hardware */ chip->in_resume = 1; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_nm256_init_chip(chip); /* restore ac97 */ -- cgit From 2d6b2e59eda2d77c16f9189073adb0484503d168 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:49:13 +0100 Subject: ALSA: oxygen: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Acked-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_lib.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index b67e30602473..366723cf6d7a 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -728,7 +728,6 @@ EXPORT_SYMBOL(oxygen_pci_remove); #ifdef CONFIG_PM_SLEEP static int oxygen_pci_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct oxygen *chip = card->private_data; unsigned int i, saved_interrupt_mask; @@ -753,10 +752,6 @@ static int oxygen_pci_suspend(struct device *dev) flush_work(&chip->spdif_input_bits_work); flush_work(&chip->gpio_work); chip->interrupt_mask = saved_interrupt_mask; - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } @@ -788,20 +783,10 @@ static void oxygen_restore_ac97(struct oxygen *chip, unsigned int codec) static int oxygen_pci_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct oxygen *chip = card->private_data; unsigned int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "cannot reenable device"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - oxygen_write16(chip, OXYGEN_DMA_STATUS, 0); oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); for (i = 0; i < OXYGEN_IO_SIZE; ++i) -- cgit From e066d85cc0f87c6e67bbbb7665de8b30e5ce11e4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:49:42 +0100 Subject: ALSA: riptide: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'sound') diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 6abc2ac8fffb..7e922fa24de5 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1153,7 +1153,6 @@ static void riptide_handleirq(unsigned long dev_id) #ifdef CONFIG_PM_SLEEP static int riptide_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_riptide *chip = card->private_data; @@ -1161,27 +1160,14 @@ static int riptide_suspend(struct device *dev) snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int riptide_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_riptide *chip = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - printk(KERN_ERR "riptide: pci_enable_device failed, " - "disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); snd_riptide_initialize(chip); snd_ac97_resume(chip->ac97); snd_power_change_state(card, SNDRV_CTL_POWER_D0); -- cgit From a0044463da8a20052b23eb2cd38edbe3e611942e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:49:59 +0100 Subject: ALSA: rme96: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/rme96.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 2f1a85185a16..e33e79eadf83 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -2358,7 +2358,6 @@ snd_rme96_create_switches(struct snd_card *card, static int rme96_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct rme96 *rme96 = card->private_data; @@ -2381,26 +2380,14 @@ static int rme96_suspend(struct device *dev) /* disable the DAC */ rme96->areg &= ~RME96_AR_DAC_EN; writel(rme96->areg, rme96->iobase + RME96_IO_ADDITIONAL_REG); - - pci_disable_device(pci); - pci_save_state(pci); - return 0; } static int rme96_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct rme96 *rme96 = card->private_data; - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - /* reset playback and record buffer pointers */ writel(0, rme96->iobase + RME96_IO_SET_PLAY_POS + rme96->playback_pointer); -- cgit From 5b3985ecdc6beab7db96a259fce0d8befd99ff07 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:50:09 +0100 Subject: ALSA: sis7019: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/sis7019.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'sound') diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 7f6a0a0d115a..be8952f6804d 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -1211,7 +1211,6 @@ static int sis_chip_init(struct sis7019 *sis) #ifdef CONFIG_PM_SLEEP static int sis_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct sis7019 *sis = card->private_data; void __iomem *ioaddr = sis->ioaddr; @@ -1240,9 +1239,6 @@ static int sis_suspend(struct device *dev) ioaddr += 4096; } - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } @@ -1254,14 +1250,6 @@ static int sis_resume(struct device *dev) void __iomem *ioaddr = sis->ioaddr; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - - if (pci_enable_device(pci) < 0) { - dev_err(&pci->dev, "unable to re-enable device\n"); - goto error; - } - if (sis_chip_init(sis)) { dev_err(&pci->dev, "unable to re-init controller\n"); goto error; @@ -1284,7 +1272,6 @@ static int sis_resume(struct device *dev) memset(sis->suspend_state[0], 0, 4096); sis->irq = pci->irq; - pci_set_master(pci); if (sis->codecs_present & SIS_PRIMARY_CODEC_PRESENT) snd_ac97_resume(sis->ac97[0]); -- cgit From 6f9eb021f776e7765a054090932cc9834d99c242 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:50:18 +0100 Subject: ALSA: trident: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/trident/trident_main.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 57cd757acfe7..072824982ff8 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -3926,7 +3926,6 @@ static void snd_trident_clear_voices(struct snd_trident * trident, unsigned shor #ifdef CONFIG_PM_SLEEP static int snd_trident_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_trident *trident = card->private_data; @@ -3938,28 +3937,14 @@ static int snd_trident_suspend(struct device *dev) snd_ac97_suspend(trident->ac97); snd_ac97_suspend(trident->ac97_sec); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_trident_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_trident *trident = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - switch (trident->device) { case TRIDENT_DEVICE_ID_DX: snd_trident_4d_dx_init(trident); -- cgit From e909bfdfa9cde50099b5eef5bd4b87d92ddffc86 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:50:27 +0100 Subject: ALSA: via82xx: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'sound') diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index e088467fb736..120fccbb2461 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2271,7 +2271,6 @@ static int snd_via82xx_chip_init(struct via82xx *chip) */ static int snd_via82xx_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct via82xx *chip = card->private_data; int i; @@ -2291,28 +2290,15 @@ static int snd_via82xx_suspend(struct device *dev) chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); } - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_via82xx_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct via82xx *chip = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_via82xx_chip_init(chip); if (chip->chip_type == TYPE_VIA686) { -- cgit From c11b4c68f4e9b92536fae1f000cb734609633c63 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:50:36 +0100 Subject: ALSA: via82xx-modem: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/via82xx_modem.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index fd46ffe12e4f..884f49eea495 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1031,7 +1031,6 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip) */ static int snd_via82xx_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct via82xx_modem *chip = card->private_data; int i; @@ -1043,29 +1042,15 @@ static int snd_via82xx_suspend(struct device *dev) snd_via82xx_channel_reset(chip, &chip->devs[i]); synchronize_irq(chip->irq); snd_ac97_suspend(chip->ac97); - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_via82xx_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct via82xx_modem *chip = card->private_data; int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_via82xx_chip_init(chip); snd_ac97_resume(chip->ac97); -- cgit From de0c869c8369db671d165d89d56ea561bea48bd9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:50:48 +0100 Subject: ALSA: vx222: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/vx222/vx222.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index c5a25e39e3a8..ecbaf473fc1e 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -259,32 +259,17 @@ static void snd_vx222_remove(struct pci_dev *pci) #ifdef CONFIG_PM_SLEEP static int snd_vx222_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_vx222 *vx = card->private_data; - int err; - err = snd_vx_suspend(&vx->core); - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); - return err; + return snd_vx_suspend(&vx->core); } static int snd_vx222_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_vx222 *vx = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); return snd_vx_resume(&vx->core); } -- cgit From 3e41c9b5a1ca2acfd9306a918fe3903f02eb89ca Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jan 2015 12:50:57 +0100 Subject: ALSA: ymfpci: Simplify PM callbacks This is a similar cleanup like the commit [3db084fd0af5: ALSA: fm801: PCI core handles power state for us]. Since pci_set_power_state(), pci_save_state() and pci_restore_state() are already done in the PCI core side, so we don't need to it doubly. Also, pci_enable_device(), pci_disable_device() and pci_set_master() calls in PM callbacks are superfluous nowadays, too, so get rid of them as well. Signed-off-by: Takashi Iwai --- sound/pci/ymfpci/ymfpci_main.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'sound') diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 81c916a5eb96..2b0b8f559ab3 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2326,7 +2326,6 @@ static int saved_regs_index[] = { static int snd_ymfpci_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct snd_ymfpci *chip = card->private_data; unsigned int i; @@ -2347,9 +2346,6 @@ static int snd_ymfpci_suspend(struct device *dev) snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0); snd_ymfpci_disable_dsp(chip); - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } @@ -2360,14 +2356,6 @@ static int snd_ymfpci_resume(struct device *dev) struct snd_ymfpci *chip = card->private_data; unsigned int i; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(dev, "pci_enable_device failed, disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); snd_ymfpci_aclink_reset(pci); snd_ymfpci_codec_ready(chip, 0); snd_ymfpci_download_image(chip); -- cgit From 7ff9d6714a5c97fb448c53aae801af3d529ecb56 Mon Sep 17 00:00:00 2001 From: Jie Yang Date: Fri, 9 Jan 2015 14:36:36 +0800 Subject: ASoC: Intel: Split hsw_pcm_data for playback and capture There may be 2 pcm streams for a same DAI at most, and these 2 streams should have different hsw_pcm_data, e.g. they have different persistent data, so here we need split hsw_pcm_data for playback and capture, to make sure they won't be mixed and keep cleaned. Signed-off-by: Jie Yang Reviewed-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/intel/sst-haswell-pcm.c | 91 ++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 30 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index 5448f79283b7..ad7f4a51e138 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c @@ -135,7 +135,17 @@ struct hsw_priv_data { struct snd_dma_buffer dmab[HSW_PCM_COUNT][2]; /* DAI data */ - struct hsw_pcm_data pcm[HSW_PCM_COUNT]; + struct hsw_pcm_data pcm[HSW_PCM_COUNT][2]; +}; + + +/* static mappings between PCMs and modules - may be dynamic in future */ +static struct hsw_pcm_module_map mod_map[] = { + {HSW_PCM_DAI_ID_SYSTEM, 0, SST_HSW_MODULE_PCM_SYSTEM}, + {HSW_PCM_DAI_ID_OFFLOAD0, 0, SST_HSW_MODULE_PCM}, + {HSW_PCM_DAI_ID_OFFLOAD1, 0, SST_HSW_MODULE_PCM}, + {HSW_PCM_DAI_ID_LOOPBACK, 1, SST_HSW_MODULE_PCM_REFERENCE}, + {HSW_PCM_DAI_ID_SYSTEM, 1, SST_HSW_MODULE_PCM_CAPTURE}, }; static u32 hsw_notify_pointer(struct sst_hsw_stream *stream, void *data); @@ -168,9 +178,14 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); - struct hsw_pcm_data *pcm_data = &pdata->pcm[mc->reg]; + struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; + int dai, stream; + + dai = mod_map[mc->reg].dai_id; + stream = mod_map[mc->reg].stream; + pcm_data = &pdata->pcm[dai][stream]; mutex_lock(&pcm_data->mutex); pm_runtime_get_sync(pdata->dev); @@ -212,9 +227,14 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); - struct hsw_pcm_data *pcm_data = &pdata->pcm[mc->reg]; + struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; + int dai, stream; + + dai = mod_map[mc->reg].dai_id; + stream = mod_map[mc->reg].stream; + pcm_data = &pdata->pcm[dai][stream]; mutex_lock(&pcm_data->mutex); pm_runtime_get_sync(pdata->dev); @@ -309,7 +329,7 @@ static const struct snd_kcontrol_new hsw_volume_controls[] = { ARRAY_SIZE(volume_map) - 1, 0, hsw_stream_volume_get, hsw_stream_volume_put, hsw_vol_tlv), /* Mic Capture volume */ - SOC_DOUBLE_EXT_TLV("Mic Capture Volume", 0, 0, 8, + SOC_DOUBLE_EXT_TLV("Mic Capture Volume", 4, 0, 8, ARRAY_SIZE(volume_map) - 1, 0, hsw_stream_volume_get, hsw_stream_volume_put, hsw_vol_tlv), }; @@ -353,7 +373,7 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(rtd->platform); - struct hsw_pcm_data *pcm_data = snd_soc_pcm_get_drvdata(rtd); + struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; struct sst_module *module_data; struct sst_dsp *dsp; @@ -362,7 +382,10 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream, enum sst_hsw_stream_path_id path_id; u32 rate, bits, map, pages, module_id; u8 channels; - int ret; + int ret, dai; + + dai = mod_map[rtd->cpu_dai->id].dai_id; + pcm_data = &pdata->pcm[dai][substream->stream]; /* check if we are being called a subsequent time */ if (pcm_data->allocated) { @@ -552,8 +575,12 @@ static int hsw_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(rtd->platform); - struct hsw_pcm_data *pcm_data = snd_soc_pcm_get_drvdata(rtd); + struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; + int dai; + + dai = mod_map[rtd->cpu_dai->id].dai_id; + pcm_data = &pdata->pcm[dai][substream->stream]; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -597,11 +624,16 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(rtd->platform); - struct hsw_pcm_data *pcm_data = snd_soc_pcm_get_drvdata(rtd); + struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; snd_pcm_uframes_t offset; uint64_t ppos; - u32 position = sst_hsw_get_dsp_position(hsw, pcm_data->stream); + u32 position; + int dai; + + dai = mod_map[rtd->cpu_dai->id].dai_id; + pcm_data = &pdata->pcm[dai][substream->stream]; + position = sst_hsw_get_dsp_position(hsw, pcm_data->stream); offset = bytes_to_frames(runtime, position); ppos = sst_hsw_get_dsp_presentation_position(hsw, pcm_data->stream); @@ -618,8 +650,10 @@ static int hsw_pcm_open(struct snd_pcm_substream *substream) snd_soc_platform_get_drvdata(rtd->platform); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; + int dai; - pcm_data = &pdata->pcm[rtd->cpu_dai->id]; + dai = mod_map[rtd->cpu_dai->id].dai_id; + pcm_data = &pdata->pcm[dai][substream->stream]; mutex_lock(&pcm_data->mutex); pm_runtime_get_sync(pdata->dev); @@ -648,9 +682,12 @@ static int hsw_pcm_close(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(rtd->platform); - struct hsw_pcm_data *pcm_data = snd_soc_pcm_get_drvdata(rtd); + struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; - int ret; + int ret, dai; + + dai = mod_map[rtd->cpu_dai->id].dai_id; + pcm_data = &pdata->pcm[dai][substream->stream]; mutex_lock(&pcm_data->mutex); ret = sst_hsw_stream_reset(hsw, pcm_data->stream); @@ -685,15 +722,6 @@ static struct snd_pcm_ops hsw_pcm_ops = { .page = snd_pcm_sgbuf_ops_page, }; -/* static mappings between PCMs and modules - may be dynamic in future */ -static struct hsw_pcm_module_map mod_map[] = { - {HSW_PCM_DAI_ID_SYSTEM, 0, SST_HSW_MODULE_PCM_SYSTEM}, - {HSW_PCM_DAI_ID_OFFLOAD0, 0, SST_HSW_MODULE_PCM}, - {HSW_PCM_DAI_ID_OFFLOAD1, 0, SST_HSW_MODULE_PCM}, - {HSW_PCM_DAI_ID_LOOPBACK, 1, SST_HSW_MODULE_PCM_REFERENCE}, - {HSW_PCM_DAI_ID_SYSTEM, 1, SST_HSW_MODULE_PCM_CAPTURE}, -}; - static int hsw_pcm_create_modules(struct hsw_priv_data *pdata) { struct sst_hsw *hsw = pdata->hsw; @@ -701,7 +729,7 @@ static int hsw_pcm_create_modules(struct hsw_priv_data *pdata) int i; for (i = 0; i < ARRAY_SIZE(mod_map); i++) { - pcm_data = &pdata->pcm[i]; + pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; /* create new runtime module, use same offset if recreated */ pcm_data->runtime = sst_hsw_runtime_module_create(hsw, @@ -716,7 +744,7 @@ static int hsw_pcm_create_modules(struct hsw_priv_data *pdata) err: for (--i; i >= 0; i--) { - pcm_data = &pdata->pcm[i]; + pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; sst_hsw_runtime_module_free(pcm_data->runtime); } @@ -729,7 +757,7 @@ static void hsw_pcm_free_modules(struct hsw_priv_data *pdata) int i; for (i = 0; i < ARRAY_SIZE(mod_map); i++) { - pcm_data = &pdata->pcm[i]; + pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; sst_hsw_runtime_module_free(pcm_data->runtime); } @@ -757,7 +785,10 @@ static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd) return ret; } } - priv_data->pcm[rtd->cpu_dai->id].hsw_pcm = pcm; + if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) + priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_PLAYBACK].hsw_pcm = pcm; + if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) + priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_CAPTURE].hsw_pcm = pcm; return ret; } @@ -866,10 +897,9 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform) /* allocate DSP buffer page tables */ for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { - mutex_init(&priv_data->pcm[i].mutex); - /* playback */ if (hsw_dais[i].playback.channels_min) { + mutex_init(&priv_data->pcm[i][SNDRV_PCM_STREAM_PLAYBACK].mutex); ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dma_dev, PAGE_SIZE, &priv_data->dmab[i][0]); if (ret < 0) @@ -878,6 +908,7 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform) /* capture */ if (hsw_dais[i].capture.channels_min) { + mutex_init(&priv_data->pcm[i][SNDRV_PCM_STREAM_CAPTURE].mutex); ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dma_dev, PAGE_SIZE, &priv_data->dmab[i][1]); if (ret < 0) @@ -1076,7 +1107,7 @@ static void hsw_pcm_complete(struct device *dev) } for (i = 0; i < ARRAY_SIZE(mod_map); i++) { - pcm_data = &pdata->pcm[i]; + pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; if (!pcm_data->substream) continue; @@ -1110,7 +1141,7 @@ static int hsw_pcm_prepare(struct device *dev) return 0; /* suspend all active streams */ for (i = 0; i < ARRAY_SIZE(mod_map); i++) { - pcm_data = &pdata->pcm[i]; + pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; if (!pcm_data->substream) continue; @@ -1129,7 +1160,7 @@ static int hsw_pcm_prepare(struct device *dev) /* preserve persistent memory */ for (i = 0; i < ARRAY_SIZE(mod_map); i++) { - pcm_data = &pdata->pcm[i]; + pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; if (!pcm_data->substream) continue; -- cgit From 3c066c642aba407819cf83413025705c6e2a68f9 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 21:28:21 +0100 Subject: ASoC: ttc-dkb: Remove unnecessary snd_soc_dapm_disable_pin() calls The "Headset Mic 2" and the "Headset Stereophone" widget are managed by the jack detection logic. Their will be set depending on whether something is connected to the jack or not. There is no need to manually change the state beforehand as it will be overwritten anyway. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/ttc-dkb.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/ttc-dkb.c b/sound/soc/pxa/ttc-dkb.c index e3d7257ad09c..5001dbb9b257 100644 --- a/sound/soc/pxa/ttc-dkb.c +++ b/sound/soc/pxa/ttc-dkb.c @@ -76,10 +76,6 @@ static const struct snd_soc_dapm_route ttc_audio_map[] = { static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - snd_soc_dapm_disable_pin(dapm, "Headset Mic 2"); - snd_soc_dapm_disable_pin(dapm, "Headset Stereophone"); /* Headset jack detection */ snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE -- cgit From 46d0d8df157b4d9bdf7849ce4ae795d399018669 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 22:03:26 +0100 Subject: ASoC: corgi: Automatically disconnect non-connected pins All DAPM input and output pins of the wm8994 are either used in the card's DAPM routing table or are marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/corgi.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index b7cd0a71fd70..3580d10c9f28 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -259,20 +259,6 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = { corgi_set_spk), }; -/* - * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device - */ -static int corgi_wm8731_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - snd_soc_dapm_nc_pin(dapm, "LLINEIN"); - snd_soc_dapm_nc_pin(dapm, "RLINEIN"); - - return 0; -} - /* corgi digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link corgi_dai = { .name = "WM8731", @@ -281,7 +267,6 @@ static struct snd_soc_dai_link corgi_dai = { .codec_dai_name = "wm8731-hifi", .platform_name = "pxa-pcm-audio", .codec_name = "wm8731.0-001b", - .init = corgi_wm8731_init, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ops = &corgi_ops, @@ -300,6 +285,7 @@ static struct snd_soc_card corgi = { .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), .dapm_routes = corgi_audio_map, .num_dapm_routes = ARRAY_SIZE(corgi_audio_map), + .fully_routed = true, }; static int corgi_probe(struct platform_device *pdev) -- cgit From dff6c9642369e7cb0f5bf8b280a270c4a4bf797d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 22:03:27 +0100 Subject: ASoC: e740: Automatically disconnect non-connected pins All DAPM input and output pins of the wm9705 are either used in the card's DAPM routing table or are marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/e740_wm9705.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/e740_wm9705.c b/sound/soc/pxa/e740_wm9705.c index 7c691aae8af2..d72e124a3676 100644 --- a/sound/soc/pxa/e740_wm9705.c +++ b/sound/soc/pxa/e740_wm9705.c @@ -88,24 +88,6 @@ static const struct snd_soc_dapm_route audio_map[] = { {"Mic Amp", NULL, "Mic (Internal)"}, }; -static int e740_ac97_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - snd_soc_dapm_nc_pin(dapm, "HPOUTL"); - snd_soc_dapm_nc_pin(dapm, "HPOUTR"); - snd_soc_dapm_nc_pin(dapm, "PHONE"); - snd_soc_dapm_nc_pin(dapm, "LINEINL"); - snd_soc_dapm_nc_pin(dapm, "LINEINR"); - snd_soc_dapm_nc_pin(dapm, "CDINL"); - snd_soc_dapm_nc_pin(dapm, "CDINR"); - snd_soc_dapm_nc_pin(dapm, "PCBEEP"); - snd_soc_dapm_nc_pin(dapm, "MIC2"); - - return 0; -} - static struct snd_soc_dai_link e740_dai[] = { { .name = "AC97", @@ -114,7 +96,6 @@ static struct snd_soc_dai_link e740_dai[] = { .codec_dai_name = "wm9705-hifi", .platform_name = "pxa-pcm-audio", .codec_name = "wm9705-codec", - .init = e740_ac97_init, }, { .name = "AC97 Aux", @@ -136,6 +117,7 @@ static struct snd_soc_card e740 = { .num_dapm_widgets = ARRAY_SIZE(e740_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), + .fully_routed = true, }; static struct gpio e740_audio_gpios[] = { -- cgit From 7523f69e584cba16775cbc70a4f0adcb84625894 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 22:03:28 +0100 Subject: ASoC: e750: Automatically disconnect non-connected pins All DAPM input and output pins of the wm9705 are either used in the card's DAPM routing table or are marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/e750_wm9705.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/e750_wm9705.c b/sound/soc/pxa/e750_wm9705.c index 30544b65b5a8..48f2d7c2e68c 100644 --- a/sound/soc/pxa/e750_wm9705.c +++ b/sound/soc/pxa/e750_wm9705.c @@ -70,24 +70,6 @@ static const struct snd_soc_dapm_route audio_map[] = { {"MIC1", NULL, "Mic (Internal)"}, }; -static int e750_ac97_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - snd_soc_dapm_nc_pin(dapm, "LOUT"); - snd_soc_dapm_nc_pin(dapm, "ROUT"); - snd_soc_dapm_nc_pin(dapm, "PHONE"); - snd_soc_dapm_nc_pin(dapm, "LINEINL"); - snd_soc_dapm_nc_pin(dapm, "LINEINR"); - snd_soc_dapm_nc_pin(dapm, "CDINL"); - snd_soc_dapm_nc_pin(dapm, "CDINR"); - snd_soc_dapm_nc_pin(dapm, "PCBEEP"); - snd_soc_dapm_nc_pin(dapm, "MIC2"); - - return 0; -} - static struct snd_soc_dai_link e750_dai[] = { { .name = "AC97", @@ -96,7 +78,6 @@ static struct snd_soc_dai_link e750_dai[] = { .codec_dai_name = "wm9705-hifi", .platform_name = "pxa-pcm-audio", .codec_name = "wm9705-codec", - .init = e750_ac97_init, /* use ops to check startup state */ }, { @@ -119,6 +100,7 @@ static struct snd_soc_card e750 = { .num_dapm_widgets = ARRAY_SIZE(e750_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), + .fully_routed = true, }; static struct gpio e750_audio_gpios[] = { -- cgit From c529d0a420ba4ba2031f61a4b86f59e31ddc964e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 22:03:29 +0100 Subject: ASoC: hx4700: Automatically disconnect non-connected pins All DAPM input and output pins of the ak4641 are either used in the card's DAPM routing table or are marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/hx4700.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c index ce26551052a3..73eb5ddf9753 100644 --- a/sound/soc/pxa/hx4700.c +++ b/sound/soc/pxa/hx4700.c @@ -127,15 +127,8 @@ static const struct snd_soc_dapm_route hx4700_audio_map[] = { static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; int err; - /* NC codec pins */ - /* FIXME: is anything connected here? */ - snd_soc_dapm_nc_pin(dapm, "MOUT1"); - snd_soc_dapm_nc_pin(dapm, "MICEXT"); - snd_soc_dapm_nc_pin(dapm, "AUX"); - /* Jack detection API stuff */ err = snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, &hs_jack); @@ -184,6 +177,7 @@ static struct snd_soc_card snd_soc_card_hx4700 = { .num_dapm_widgets = ARRAY_SIZE(hx4700_dapm_widgets), .dapm_routes = hx4700_audio_map, .num_dapm_routes = ARRAY_SIZE(hx4700_audio_map), + .fully_routed = true, }; static struct gpio hx4700_audio_gpios[] = { -- cgit From 3cfaaaa0e729aa10a5e2dfe1efb1c05a6f5a89d1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 22:03:30 +0100 Subject: ASoC: magician: Automatically disconnect non-connected pins All DAPM input and output pins of the uda1380 are either used in the card's DAPM routing table or are marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/magician.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/magician.c b/sound/soc/pxa/magician.c index 259e048681c0..241d0be42d7a 100644 --- a/sound/soc/pxa/magician.c +++ b/sound/soc/pxa/magician.c @@ -391,25 +391,6 @@ static const struct snd_kcontrol_new uda1380_magician_controls[] = { magician_get_input, magician_set_input), }; -/* - * Logic for a uda1380 as connected on a HTC Magician - */ -static int magician_uda1380_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - /* NC codec pins */ - snd_soc_dapm_nc_pin(dapm, "VOUTLHP"); - snd_soc_dapm_nc_pin(dapm, "VOUTRHP"); - - /* FIXME: is anything connected here? */ - snd_soc_dapm_nc_pin(dapm, "VINL"); - snd_soc_dapm_nc_pin(dapm, "VINR"); - - return 0; -} - /* magician digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link magician_dai[] = { { @@ -419,7 +400,6 @@ static struct snd_soc_dai_link magician_dai[] = { .codec_dai_name = "uda1380-hifi-playback", .platform_name = "pxa-pcm-audio", .codec_name = "uda1380-codec.0-0018", - .init = magician_uda1380_init, .ops = &magician_playback_ops, }, { @@ -446,6 +426,7 @@ static struct snd_soc_card snd_soc_card_magician = { .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), + .fully_routed = true, }; static struct platform_device *magician_snd_device; -- cgit From b68ef0e0368cda4e17541ae87bbb5b40dc15cbc1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 22:03:31 +0100 Subject: ASoC: palm27x: Fix microphone route The microphone route has sink and source swapped. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/palm27x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index 1eebca2f0a97..5a0b82f93b15 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c @@ -68,7 +68,7 @@ static const struct snd_soc_dapm_route audio_map[] = { {"Ext. Speaker", NULL, "ROUT2"}, /* mic connected to MIC1 */ - {"Ext. Microphone", NULL, "MIC1"}, + {"MIC1", NULL, "Ext. Microphone"}, }; static struct snd_soc_card palm27x_asoc; -- cgit From 19a3477ec0eb635bdebd1dd905b1cee9a3c06c96 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 22:03:32 +0100 Subject: ASoC: palm27x: Automatically disconnect non-connected pins All DAPM input and output pins of the wm9712 are either used in the card's DAPM routing table or are marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/palm27x.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index 5a0b82f93b15..910336c5ebeb 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c @@ -76,18 +76,8 @@ static struct snd_soc_card palm27x_asoc; static int palm27x_ac97_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; int err; - /* not connected pins */ - snd_soc_dapm_nc_pin(dapm, "OUT3"); - snd_soc_dapm_nc_pin(dapm, "MONOOUT"); - snd_soc_dapm_nc_pin(dapm, "LINEINL"); - snd_soc_dapm_nc_pin(dapm, "LINEINR"); - snd_soc_dapm_nc_pin(dapm, "PCBEEP"); - snd_soc_dapm_nc_pin(dapm, "PHONE"); - snd_soc_dapm_nc_pin(dapm, "MIC2"); - /* Jack detection API stuff */ err = snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, &hs_jack); @@ -133,7 +123,8 @@ static struct snd_soc_card palm27x_asoc = { .dapm_widgets = palm27x_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(palm27x_dapm_widgets), .dapm_routes = audio_map, - .num_dapm_routes = ARRAY_SIZE(audio_map) + .num_dapm_routes = ARRAY_SIZE(audio_map), + .fully_routed = true, }; static int palm27x_asoc_probe(struct platform_device *pdev) -- cgit From c4b7586cc972ec8cca77d2f6faed1f19a11d6445 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 9 Jan 2015 22:03:33 +0100 Subject: ASoC: spitz: Automatically disconnect non-connected pins All DAPM input and output pins of the wm8750 are either used in the card's DAPM routing table or are marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/spitz.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c index a6d680acd907..461123ad5ff2 100644 --- a/sound/soc/pxa/spitz.c +++ b/sound/soc/pxa/spitz.c @@ -256,26 +256,6 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = { spitz_set_spk), }; -/* - * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device - */ -static int spitz_wm8750_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - /* NC codec pins */ - snd_soc_dapm_nc_pin(dapm, "RINPUT1"); - snd_soc_dapm_nc_pin(dapm, "LINPUT2"); - snd_soc_dapm_nc_pin(dapm, "RINPUT2"); - snd_soc_dapm_nc_pin(dapm, "LINPUT3"); - snd_soc_dapm_nc_pin(dapm, "RINPUT3"); - snd_soc_dapm_nc_pin(dapm, "OUT3"); - snd_soc_dapm_nc_pin(dapm, "MONO1"); - - return 0; -} - /* spitz digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link spitz_dai = { .name = "wm8750", @@ -284,7 +264,6 @@ static struct snd_soc_dai_link spitz_dai = { .codec_dai_name = "wm8750-hifi", .platform_name = "pxa-pcm-audio", .codec_name = "wm8750.0-001b", - .init = spitz_wm8750_init, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ops = &spitz_ops, @@ -303,6 +282,7 @@ static struct snd_soc_card snd_soc_spitz = { .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), .dapm_routes = spitz_audio_map, .num_dapm_routes = ARRAY_SIZE(spitz_audio_map), + .fully_routed = true, }; static int spitz_probe(struct platform_device *pdev) -- cgit From 624afe4dc9a08992b200046dfe8a61f19bab74ab Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Sat, 10 Jan 2015 13:02:22 +0100 Subject: ALSA: hda - fixup input_free_device called after input_unregister_device Input_unregister_device will internally free the device, so input_free_device should not be called. Reported-by: Dan Carpenter Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 09d213142633..a50e15e166c6 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -3548,7 +3548,6 @@ static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec, break; case HDA_FIXUP_ACT_FREE: input_unregister_device(spec->kb_dev); - input_free_device(spec->kb_dev); spec->kb_dev = NULL; } #endif -- cgit From 12c243b833c2c441f46dc592ab410fdccb5e056b Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Sat, 10 Jan 2015 16:57:45 +0200 Subject: ALSA: fm801: remove FSF address The FSF address is subject to change. So, we remove it from the header. While here, remove a line with my old and non-functional email from the header. Moreover, nowadays we have a Git VCS that contains a history of changes. Signed-off-by: Andy Shevchenko Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'sound') diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 52555bdaf91c..1fdd92b6f18f 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -2,8 +2,6 @@ * The driver for the ForteMedia FM801 based soundcards * Copyright (c) by Jaroslav Kysela * - * Support FM only card by Andy Shevchenko - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -14,10 +12,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * */ #include -- cgit From ace79a3592bee97406c88c3d856e16b7f5720a39 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Sun, 11 Jan 2015 16:31:40 +0100 Subject: ALSA: ice1712: wm8766: Remove some unused functions Removes some functions that are not used anywhere: snd_wm8766_set_power() snd_wm8766_set_master_mode() This was partially found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist Signed-off-by: Takashi Iwai --- sound/pci/ice1712/wm8766.c | 16 ---------------- sound/pci/ice1712/wm8766.h | 2 -- 2 files changed, 18 deletions(-) (limited to 'sound') diff --git a/sound/pci/ice1712/wm8766.c b/sound/pci/ice1712/wm8766.c index 21b373b2e260..f7ac8d5e862c 100644 --- a/sound/pci/ice1712/wm8766.c +++ b/sound/pci/ice1712/wm8766.c @@ -183,22 +183,6 @@ void snd_wm8766_set_if(struct snd_wm8766 *wm, u16 dac) snd_wm8766_write(wm, WM8766_REG_IFCTRL, val | dac); } -void snd_wm8766_set_master_mode(struct snd_wm8766 *wm, u16 mode) -{ - u16 val = wm->regs[WM8766_REG_DACCTRL3] & ~WM8766_DAC3_MSTR_MASK; - - mode &= WM8766_DAC3_MSTR_MASK; - snd_wm8766_write(wm, WM8766_REG_DACCTRL3, val | mode); -} - -void snd_wm8766_set_power(struct snd_wm8766 *wm, u16 power) -{ - u16 val = wm->regs[WM8766_REG_DACCTRL3] & ~WM8766_DAC3_POWER_MASK; - - power &= WM8766_DAC3_POWER_MASK; - snd_wm8766_write(wm, WM8766_REG_DACCTRL3, val | power); -} - void snd_wm8766_volume_restore(struct snd_wm8766 *wm) { u16 val = wm->regs[WM8766_REG_DACR1]; diff --git a/sound/pci/ice1712/wm8766.h b/sound/pci/ice1712/wm8766.h index c119f84bd2c2..18c8d9d47b38 100644 --- a/sound/pci/ice1712/wm8766.h +++ b/sound/pci/ice1712/wm8766.h @@ -155,8 +155,6 @@ struct snd_wm8766 { void snd_wm8766_init(struct snd_wm8766 *wm); void snd_wm8766_resume(struct snd_wm8766 *wm); void snd_wm8766_set_if(struct snd_wm8766 *wm, u16 dac); -void snd_wm8766_set_master_mode(struct snd_wm8766 *wm, u16 mode); -void snd_wm8766_set_power(struct snd_wm8766 *wm, u16 power); void snd_wm8766_volume_restore(struct snd_wm8766 *wm); int snd_wm8766_build_controls(struct snd_wm8766 *wm); -- cgit From 347de1f8625199d177caf7668cfa1c00717faedb Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Thu, 8 Jan 2015 17:54:15 +0200 Subject: ALSA: hda: export struct hda_intel This struct will be needed by the component code added in an upcoming patch, so export it into a new hda_intel.h file. At the same time also merge hda_i915.h into this new header, there is no reason to keep two separate intel specific header file. Suggested-by: Takashi Iwai Signed-off-by: Imre Deak Reviewed-by: Takashi Iwai Signed-off-by: Daniel Vetter --- sound/pci/hda/hda_i915.c | 2 +- sound/pci/hda/hda_i915.h | 37 --------------------------- sound/pci/hda/hda_intel.c | 27 +------------------- sound/pci/hda/hda_intel.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 64 deletions(-) delete mode 100644 sound/pci/hda/hda_i915.h create mode 100644 sound/pci/hda/hda_intel.h (limited to 'sound') diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c index d4d0375ac181..6a7854d8f2d9 100644 --- a/sound/pci/hda/hda_i915.c +++ b/sound/pci/hda/hda_i915.c @@ -21,7 +21,7 @@ #include #include #include "hda_priv.h" -#include "hda_i915.h" +#include "hda_intel.h" /* Intel HSW/BDW display HDA controller Extended Mode registers. * EM4 (M value) and EM5 (N Value) are used to convert CDClk (Core Display diff --git a/sound/pci/hda/hda_i915.h b/sound/pci/hda/hda_i915.h deleted file mode 100644 index e6072c627583..000000000000 --- a/sound/pci/hda/hda_i915.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#ifndef __SOUND_HDA_I915_H -#define __SOUND_HDA_I915_H - -#ifdef CONFIG_SND_HDA_I915 -int hda_display_power(bool enable); -void haswell_set_bclk(struct azx *chip); -int hda_i915_init(void); -int hda_i915_exit(void); -#else -static inline int hda_display_power(bool enable) { return 0; } -static inline void haswell_set_bclk(struct azx *chip) { return; } -static inline int hda_i915_init(void) -{ - return -ENODEV; -} -static inline int hda_i915_exit(void) -{ - return 0; -} -#endif - -#endif diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index d426a0bd6a5f..e4bc0dc29fe5 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -63,7 +63,7 @@ #include "hda_codec.h" #include "hda_controller.h" #include "hda_priv.h" -#include "hda_i915.h" +#include "hda_intel.h" /* position fix mode */ enum { @@ -354,31 +354,6 @@ static char *driver_short_names[] = { [AZX_DRIVER_GENERIC] = "HD-Audio Generic", }; -struct hda_intel { - struct azx chip; - - /* for pending irqs */ - struct work_struct irq_pending_work; - - /* sync probing */ - struct completion probe_wait; - struct work_struct probe_work; - - /* card list (for power_save trigger) */ - struct list_head list; - - /* extra flags */ - unsigned int irq_pending_warned:1; - - /* VGA-switcheroo setup */ - unsigned int use_vga_switcheroo:1; - unsigned int vga_switcheroo_registered:1; - unsigned int init_failed:1; /* delayed init failed */ - - /* secondary power domain for hdmi audio under vga device */ - struct dev_pm_domain hdmi_pm_domain; -}; - #ifdef CONFIG_X86 static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool on) { diff --git a/sound/pci/hda/hda_intel.h b/sound/pci/hda/hda_intel.h new file mode 100644 index 000000000000..434f254adb8b --- /dev/null +++ b/sound/pci/hda/hda_intel.h @@ -0,0 +1,64 @@ +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __SOUND_HDA_INTEL_H +#define __SOUND_HDA_INTEL_H + +#include "hda_priv.h" + +struct hda_intel { + struct azx chip; + + /* for pending irqs */ + struct work_struct irq_pending_work; + + /* sync probing */ + struct completion probe_wait; + struct work_struct probe_work; + + /* card list (for power_save trigger) */ + struct list_head list; + + /* extra flags */ + unsigned int irq_pending_warned:1; + + /* VGA-switcheroo setup */ + unsigned int use_vga_switcheroo:1; + unsigned int vga_switcheroo_registered:1; + unsigned int init_failed:1; /* delayed init failed */ + + /* secondary power domain for hdmi audio under vga device */ + struct dev_pm_domain hdmi_pm_domain; +}; + +#ifdef CONFIG_SND_HDA_I915 +int hda_display_power(bool enable); +void haswell_set_bclk(struct azx *chip); +int hda_i915_init(void); +int hda_i915_exit(void); +#else +static inline int hda_display_power(bool enable) { return 0; } +static inline void haswell_set_bclk(struct azx *chip) { return; } +static inline int hda_i915_init(void) +{ + return -ENODEV; +} +static inline int hda_i915_exit(void) +{ + return 0; +} +#endif + +#endif -- cgit From 926981ae3325257d0bffcf7ff7ba359edb4fd7e8 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Thu, 8 Jan 2015 17:54:16 +0200 Subject: ALSA: hda: pass intel_hda to all i915 interface functions chip is already passed to most of the i915 interface functions. Unify the interface by passing intel_hda instead of chip and passing it to all functions. Passing intel_hda instead of chip makes more sense since this is an intel specific interface. Also in an upcoming patch we will use intel_hda in all of these functions so by passing intel_hda we can save on some pointer casts from chip to intel_hda. This will be needed by an upcoming patch adding component support. No functional change. v2-3: unchanged v4: - pass intel_hda instead of chip Signed-off-by: Imre Deak Reviewed-by: Takashi Iwai Signed-off-by: Daniel Vetter --- sound/pci/hda/hda_i915.c | 12 ++++++------ sound/pci/hda/hda_intel.c | 28 ++++++++++++++++------------ sound/pci/hda/hda_intel.h | 19 +++++++++++-------- 3 files changed, 33 insertions(+), 26 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c index 6a7854d8f2d9..66acd09f5da1 100644 --- a/sound/pci/hda/hda_i915.c +++ b/sound/pci/hda/hda_i915.c @@ -35,7 +35,7 @@ static int (*get_power)(void); static int (*put_power)(void); static int (*get_cdclk)(void); -int hda_display_power(bool enable) +int hda_display_power(struct hda_intel *hda, bool enable) { if (!get_power || !put_power) return -ENODEV; @@ -48,7 +48,7 @@ int hda_display_power(bool enable) return put_power(); } -void haswell_set_bclk(struct azx *chip) +void haswell_set_bclk(struct hda_intel *hda) { int cdclk_freq; unsigned int bclk_m, bclk_n; @@ -80,12 +80,12 @@ void haswell_set_bclk(struct azx *chip) break; } - azx_writew(chip, EM4, bclk_m); - azx_writew(chip, EM5, bclk_n); + azx_writew(&hda->chip, EM4, bclk_m); + azx_writew(&hda->chip, EM5, bclk_n); } -int hda_i915_init(void) +int hda_i915_init(struct hda_intel *hda) { int err = 0; @@ -111,7 +111,7 @@ int hda_i915_init(void) return err; } -int hda_i915_exit(void) +int hda_i915_exit(struct hda_intel *hda) { if (get_power) { symbol_put(i915_request_power_well); diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index e4bc0dc29fe5..323abf952d00 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -803,7 +803,7 @@ static int azx_suspend(struct device *dev) pci_save_state(pci); pci_set_power_state(pci, PCI_D3hot); if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) - hda_display_power(false); + hda_display_power(hda, false); return 0; } @@ -823,8 +823,8 @@ static int azx_resume(struct device *dev) return 0; if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { - hda_display_power(true); - haswell_set_bclk(chip); + hda_display_power(hda, true); + haswell_set_bclk(hda); } pci_set_power_state(pci, PCI_D0); pci_restore_state(pci); @@ -876,7 +876,7 @@ static int azx_runtime_suspend(struct device *dev) azx_enter_link_reset(chip); azx_clear_irq_pending(chip); if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) - hda_display_power(false); + hda_display_power(hda, false); return 0; } @@ -902,8 +902,8 @@ static int azx_runtime_resume(struct device *dev) return 0; if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { - hda_display_power(true); - haswell_set_bclk(chip); + hda_display_power(hda, true); + haswell_set_bclk(hda); } /* Read STATESTS before controller reset */ @@ -1125,8 +1125,8 @@ static int azx_free(struct azx *chip) release_firmware(chip->fw); #endif if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { - hda_display_power(false); - hda_i915_exit(); + hda_display_power(hda, false); + hda_i915_exit(hda); } kfree(hda); @@ -1604,8 +1604,12 @@ static int azx_first_init(struct azx *chip) /* initialize chip */ azx_init_pci(chip); - if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) - haswell_set_bclk(chip); + if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { + struct hda_intel *hda; + + hda = container_of(chip, struct hda_intel, chip); + haswell_set_bclk(hda); + } azx_init_chip(chip, (probe_only[dev] & 2) == 0); @@ -1885,13 +1889,13 @@ static int azx_probe_continue(struct azx *chip) /* Request power well for Haswell HDA controller and codec */ if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { #ifdef CONFIG_SND_HDA_I915 - err = hda_i915_init(); + err = hda_i915_init(hda); if (err < 0) { dev_err(chip->card->dev, "Error request power-well from i915\n"); goto out_free; } - err = hda_display_power(true); + err = hda_display_power(hda, true); if (err < 0) { dev_err(chip->card->dev, "Cannot turn on display power on i915\n"); diff --git a/sound/pci/hda/hda_intel.h b/sound/pci/hda/hda_intel.h index 434f254adb8b..70b8306fec23 100644 --- a/sound/pci/hda/hda_intel.h +++ b/sound/pci/hda/hda_intel.h @@ -44,18 +44,21 @@ struct hda_intel { }; #ifdef CONFIG_SND_HDA_I915 -int hda_display_power(bool enable); -void haswell_set_bclk(struct azx *chip); -int hda_i915_init(void); -int hda_i915_exit(void); +int hda_display_power(struct hda_intel *hda, bool enable); +void haswell_set_bclk(struct hda_intel *hda); +int hda_i915_init(struct hda_intel *hda); +int hda_i915_exit(struct hda_intel *hda); #else -static inline int hda_display_power(bool enable) { return 0; } -static inline void haswell_set_bclk(struct azx *chip) { return; } -static inline int hda_i915_init(void) +static inline int hda_display_power(struct hda_intel *hda, bool enable) +{ + return 0; +} +static inline void haswell_set_bclk(struct hda_intel *hda) { return; } +static inline int hda_i915_init(struct hda_intel *hda) { return -ENODEV; } -static inline int hda_i915_exit(void) +static inline int hda_i915_exit(struct hda_intel *hda) { return 0; } -- cgit From d7055bd653e00ef40a07065d1c94380240314c48 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Thu, 8 Jan 2015 17:54:17 +0200 Subject: ALSA: hda: add component support Register a component master to be used to interface with the i915 driver. This is meant to replace the current interface which is based on module symbol lookups. Note that currently we keep the existing behavior and pin the i915 module while the hda driver is loaded. Using the component interface allows us to remove this dependency once support for dynamically enabling / disabling the HDMI functionality is added to the driver. v2: - change roles between the hda and i915 components (Daniel) v3: - rename display_component to audio_component (Daniel) v4: - move removal of i915_powerwell.h from this patch to the next (Takashi) - request_module fails if module support isn't enabled, so ignore any error it returns and depend on the following NULL check of the component ops (Takashi) - change over to using dev_* instead of pr_* (Takashi) Signed-off-by: Imre Deak Reviewed-by: Takashi Iwai Signed-off-by: Daniel Vetter --- sound/pci/hda/hda_i915.c | 142 +++++++++++++++++++++++++++++++++------------- sound/pci/hda/hda_intel.c | 5 +- sound/pci/hda/hda_intel.h | 4 ++ 3 files changed, 106 insertions(+), 45 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c index 66acd09f5da1..714894527e06 100644 --- a/sound/pci/hda/hda_i915.c +++ b/sound/pci/hda/hda_i915.c @@ -18,8 +18,10 @@ #include #include +#include +#include +#include #include -#include #include "hda_priv.h" #include "hda_intel.h" @@ -31,32 +33,33 @@ #define AZX_REG_EM4 0x100c #define AZX_REG_EM5 0x1010 -static int (*get_power)(void); -static int (*put_power)(void); -static int (*get_cdclk)(void); - int hda_display_power(struct hda_intel *hda, bool enable) { - if (!get_power || !put_power) + struct i915_audio_component *acomp = &hda->audio_component; + + if (!acomp->ops) return -ENODEV; - pr_debug("HDA display power %s \n", - enable ? "Enable" : "Disable"); + dev_dbg(&hda->chip.pci->dev, "display power %s\n", + enable ? "enable" : "disable"); if (enable) - return get_power(); + acomp->ops->get_power(acomp->dev); else - return put_power(); + acomp->ops->put_power(acomp->dev); + + return 0; } void haswell_set_bclk(struct hda_intel *hda) { int cdclk_freq; unsigned int bclk_m, bclk_n; + struct i915_audio_component *acomp = &hda->audio_component; - if (!get_cdclk) + if (!acomp->ops) return; - cdclk_freq = get_cdclk(); + cdclk_freq = acomp->ops->get_cdclk_freq(acomp->dev); switch (cdclk_freq) { case 337500: bclk_m = 16; @@ -84,47 +87,104 @@ void haswell_set_bclk(struct hda_intel *hda) azx_writew(&hda->chip, EM5, bclk_n); } - -int hda_i915_init(struct hda_intel *hda) +static int hda_component_master_bind(struct device *dev) { - int err = 0; + struct snd_card *card = dev_get_drvdata(dev); + struct azx *chip = card->private_data; + struct hda_intel *hda = container_of(chip, struct hda_intel, chip); + struct i915_audio_component *acomp = &hda->audio_component; + int ret; + + ret = component_bind_all(dev, acomp); + if (ret < 0) + return ret; + + if (WARN_ON(!(acomp->dev && acomp->ops && acomp->ops->get_power && + acomp->ops->put_power && acomp->ops->get_cdclk_freq))) { + ret = -EINVAL; + goto out_unbind; + } - get_power = symbol_request(i915_request_power_well); - if (!get_power) { - pr_warn("hda-i915: get_power symbol get fail\n"); - return -ENODEV; + /* + * Atm, we don't support dynamic unbinding initiated by the child + * component, so pin its containing module until we unbind. + */ + if (!try_module_get(acomp->ops->owner)) { + ret = -ENODEV; + goto out_unbind; } - put_power = symbol_request(i915_release_power_well); - if (!put_power) { - symbol_put(i915_request_power_well); - get_power = NULL; - return -ENODEV; + return 0; + +out_unbind: + component_unbind_all(dev, acomp); + + return ret; +} + +static void hda_component_master_unbind(struct device *dev) +{ + struct snd_card *card = dev_get_drvdata(dev); + struct azx *chip = card->private_data; + struct hda_intel *hda = container_of(chip, struct hda_intel, chip); + struct i915_audio_component *acomp = &hda->audio_component; + + module_put(acomp->ops->owner); + component_unbind_all(dev, acomp); + WARN_ON(acomp->ops || acomp->dev); +} + +static const struct component_master_ops hda_component_master_ops = { + .bind = hda_component_master_bind, + .unbind = hda_component_master_unbind, +}; + +static int hda_component_master_match(struct device *dev, void *data) +{ + /* i915 is the only supported component */ + return !strcmp(dev->driver->name, "i915"); +} + +int hda_i915_init(struct hda_intel *hda) +{ + struct component_match *match = NULL; + struct device *dev = &hda->chip.pci->dev; + struct i915_audio_component *acomp = &hda->audio_component; + int ret; + + component_match_add(dev, &match, hda_component_master_match, hda); + ret = component_master_add_with_match(dev, &hda_component_master_ops, + match); + if (ret < 0) + goto out_err; + + /* + * Atm, we don't support deferring the component binding, so make sure + * i915 is loaded and that the binding successfully completes. + */ + request_module("i915"); + + if (!acomp->ops) { + ret = -ENODEV; + goto out_master_del; } - get_cdclk = symbol_request(i915_get_cdclk_freq); - if (!get_cdclk) /* may have abnormal BCLK and audio playback rate */ - pr_warn("hda-i915: get_cdclk symbol get fail\n"); + dev_dbg(dev, "bound to i915 component master\n"); - pr_debug("HDA driver get symbol successfully from i915 module\n"); + return 0; +out_master_del: + component_master_del(dev, &hda_component_master_ops); +out_err: + dev_err(dev, "failed to add i915 component master (%d)\n", ret); - return err; + return ret; } int hda_i915_exit(struct hda_intel *hda) { - if (get_power) { - symbol_put(i915_request_power_well); - get_power = NULL; - } - if (put_power) { - symbol_put(i915_release_power_well); - put_power = NULL; - } - if (get_cdclk) { - symbol_put(i915_get_cdclk_freq); - get_cdclk = NULL; - } + struct device *dev = &hda->chip.pci->dev; + + component_master_del(dev, &hda_component_master_ops); return 0; } diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 323abf952d00..95a539993990 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1890,11 +1890,8 @@ static int azx_probe_continue(struct azx *chip) if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { #ifdef CONFIG_SND_HDA_I915 err = hda_i915_init(hda); - if (err < 0) { - dev_err(chip->card->dev, - "Error request power-well from i915\n"); + if (err < 0) goto out_free; - } err = hda_display_power(hda, true); if (err < 0) { dev_err(chip->card->dev, diff --git a/sound/pci/hda/hda_intel.h b/sound/pci/hda/hda_intel.h index 70b8306fec23..348611835476 100644 --- a/sound/pci/hda/hda_intel.h +++ b/sound/pci/hda/hda_intel.h @@ -16,6 +16,7 @@ #ifndef __SOUND_HDA_INTEL_H #define __SOUND_HDA_INTEL_H +#include #include "hda_priv.h" struct hda_intel { @@ -41,6 +42,9 @@ struct hda_intel { /* secondary power domain for hdmi audio under vga device */ struct dev_pm_domain hdmi_pm_domain; + + /* i915 component interface */ + struct i915_audio_component audio_component; }; #ifdef CONFIG_SND_HDA_I915 -- cgit From bdb2c74d44be691e6d3b6d441e81ea13dab34145 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 12 Jan 2015 13:54:13 +0100 Subject: ASoC: ad193x: Don't power down DAC in CODEC probe The DAC powerdown bit is managed by DAPM. Manually powering down the DAC in the CODEC probe function may cause unnecessary power state transitions which can lead to click and pop noises. So leave the DAC powerdown bit in its default poweron-reset state and let DAPM do all the management. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/ad193x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index 387530b0b0fd..17c953595660 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -333,8 +333,8 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) regmap_write(ad193x->regmap, AD193X_DAC_CHNL_MUTE, 0x0); /* de-emphasis: 48kHz, powedown dac */ regmap_write(ad193x->regmap, AD193X_DAC_CTRL2, 0x1A); - /* powerdown dac, dac in tdm mode */ - regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x41); + /* dac in tdm mode */ + regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x40); /* high-pass filter enable */ regmap_write(ad193x->regmap, AD193X_ADC_CTRL0, 0x3); /* sata delay=1, adc aux mode */ -- cgit From cfcefe01265cbaf5ca7209226d043b07bfa8b587 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 8 Jan 2015 01:52:36 +0000 Subject: ASoC: rsnd: add recovery support for under/over flow error on SRC L/R channel will be switched if under/over flow error happen on Renesas R-Car sound device by the HW bugs. Then, HW restart is required for salvage. This patch add salvage support for SRC. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/gen.c | 15 ++++ sound/soc/sh/rcar/rsnd.h | 8 +++ sound/soc/sh/rcar/src.c | 179 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 183 insertions(+), 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 87a6f2d62775..de0685f2abae 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c @@ -309,8 +309,13 @@ static int rsnd_gen2_probe(struct platform_device *pdev, RSND_GEN_M_REG(SRC_BUSIF_MODE, 0x0, 0x20), RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0xc, 0x20), RSND_GEN_M_REG(SRC_CTRL, 0x10, 0x20), + RSND_GEN_M_REG(SRC_INT_ENABLE0, 0x18, 0x20), RSND_GEN_M_REG(CMD_ROUTE_SLCT, 0x18c, 0x20), RSND_GEN_M_REG(CMD_CTRL, 0x190, 0x20), + RSND_GEN_S_REG(SCU_SYS_STATUS0, 0x1c8), + RSND_GEN_S_REG(SCU_SYS_INT_EN0, 0x1cc), + RSND_GEN_S_REG(SCU_SYS_STATUS1, 0x1d0), + RSND_GEN_S_REG(SCU_SYS_INT_EN1, 0x1c4), RSND_GEN_M_REG(SRC_SWRSR, 0x200, 0x40), RSND_GEN_M_REG(SRC_SRCIR, 0x204, 0x40), RSND_GEN_M_REG(SRC_ADINR, 0x214, 0x40), @@ -403,6 +408,16 @@ static int rsnd_gen1_probe(struct platform_device *pdev, RSND_GEN_M_REG(SRC_IFSVR, 0x220, 0x40), RSND_GEN_M_REG(SRC_SRCCR, 0x224, 0x40), RSND_GEN_M_REG(SRC_MNFSR, 0x228, 0x40), + /* + * ADD US + * + * SRC_STATUS + * SRC_INT_EN + * SCU_SYS_STATUS0 + * SCU_SYS_STATUS1 + * SCU_SYS_INT_EN0 + * SCU_SYS_INT_EN1 + */ }; struct rsnd_regmap_field_conf conf_adg[] = { RSND_GEN_S_REG(BRRA, 0x00), diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 5826c8abf794..c45700380e59 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -44,6 +44,8 @@ enum rsnd_reg { RSND_REG_SRC_IFSCR, RSND_REG_SRC_IFSVR, RSND_REG_SRC_SRCCR, + RSND_REG_SCU_SYS_STATUS0, + RSND_REG_SCU_SYS_INT_EN0, RSND_REG_CMD_ROUTE_SLCT, RSND_REG_DVC_SWRSR, RSND_REG_DVC_DVUIR, @@ -94,6 +96,9 @@ enum rsnd_reg { RSND_REG_SHARE23, RSND_REG_SHARE24, RSND_REG_SHARE25, + RSND_REG_SHARE26, + RSND_REG_SHARE27, + RSND_REG_SHARE28, RSND_REG_MAX, }; @@ -135,6 +140,9 @@ enum rsnd_reg { #define RSND_REG_DVC_VRCTR RSND_REG_SHARE23 #define RSND_REG_DVC_VRPDR RSND_REG_SHARE24 #define RSND_REG_DVC_VRDBR RSND_REG_SHARE25 +#define RSND_REG_SCU_SYS_STATUS1 RSND_REG_SHARE26 +#define RSND_REG_SCU_SYS_INT_EN1 RSND_REG_SHARE27 +#define RSND_REG_SRC_INT_ENABLE0 RSND_REG_SHARE28 struct rsnd_of_data; struct rsnd_priv; diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index eede3ac6eed2..648b35e7effc 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -12,10 +12,18 @@ #define SRC_NAME "src" +/* SRCx_STATUS */ +#define OUF_SRCO ((1 << 12) | (1 << 13)) +#define OUF_SRCI ((1 << 9) | (1 << 8)) + +/* SCU_SYSTEM_STATUS0/1 */ +#define OUF_SRC(id) ((1 << (id + 16)) | (1 << id)) + struct rsnd_src { struct rsnd_src_platform_info *info; /* rcar_snd.h */ struct rsnd_mod mod; struct clk *clk; + int err; }; #define RSND_SRC_NAME_SIZE 16 @@ -280,6 +288,8 @@ static int rsnd_src_init(struct rsnd_mod *mod, clk_prepare_enable(src->clk); + src->err = 0; + /* * Initialize the operation of the SRC internal circuits * see rsnd_src_start() @@ -293,9 +303,14 @@ static int rsnd_src_quit(struct rsnd_mod *mod, struct rsnd_dai *rdai) { struct rsnd_src *src = rsnd_mod_to_src(mod); + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); clk_disable_unprepare(src->clk); + if (src->err) + dev_warn(dev, "src under/over flow err = %d\n", src->err); + return 0; } @@ -510,6 +525,110 @@ static struct rsnd_mod_ops rsnd_src_gen1_ops = { /* * Gen2 functions */ +#define rsnd_src_irq_enable_gen2(mod) rsnd_src_irq_ctrol_gen2(mod, 1) +#define rsnd_src_irq_disable_gen2(mod) rsnd_src_irq_ctrol_gen2(mod, 0) +static void rsnd_src_irq_ctrol_gen2(struct rsnd_mod *mod, int enable) +{ + struct rsnd_src *src = rsnd_mod_to_src(mod); + u32 sys_int_val, int_val, sys_int_mask; + int irq = src->info->irq; + int id = rsnd_mod_id(mod); + + sys_int_val = + sys_int_mask = OUF_SRC(id); + int_val = 0x3300; + + /* + * IRQ is not supported on non-DT + * see + * rsnd_src_probe_gen2() + */ + if ((irq <= 0) || !enable) { + sys_int_val = 0; + int_val = 0; + } + + rsnd_mod_write(mod, SRC_INT_ENABLE0, int_val); + rsnd_mod_bset(mod, SCU_SYS_INT_EN0, sys_int_mask, sys_int_val); + rsnd_mod_bset(mod, SCU_SYS_INT_EN1, sys_int_mask, sys_int_val); +} + +static void rsnd_src_error_clear_gen2(struct rsnd_mod *mod) +{ + u32 val = OUF_SRC(rsnd_mod_id(mod)); + + rsnd_mod_bset(mod, SCU_SYS_STATUS0, val, val); + rsnd_mod_bset(mod, SCU_SYS_STATUS1, val, val); +} + +static bool rsnd_src_error_record_gen2(struct rsnd_mod *mod) +{ + u32 val = OUF_SRC(rsnd_mod_id(mod)); + bool ret = false; + + if ((rsnd_mod_read(mod, SCU_SYS_STATUS0) & val) || + (rsnd_mod_read(mod, SCU_SYS_STATUS1) & val)) { + struct rsnd_src *src = rsnd_mod_to_src(mod); + + src->err++; + ret = true; + } + + /* clear error static */ + rsnd_src_error_clear_gen2(mod); + + return ret; +} + +static int _rsnd_src_start_gen2(struct rsnd_mod *mod) +{ + struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); + u32 val = rsnd_io_to_mod_dvc(io) ? 0x01 : 0x11; + + rsnd_mod_write(mod, SRC_CTRL, val); + + rsnd_src_error_clear_gen2(mod); + + rsnd_src_start(mod); + + rsnd_src_irq_enable_gen2(mod); + + return 0; +} + +static int _rsnd_src_stop_gen2(struct rsnd_mod *mod) +{ + rsnd_src_irq_disable_gen2(mod); + + rsnd_mod_write(mod, SRC_CTRL, 0); + + rsnd_src_error_record_gen2(mod); + + return rsnd_src_stop(mod); +} + +static irqreturn_t rsnd_src_interrupt_gen2(int irq, void *data) +{ + struct rsnd_mod *mod = data; + struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); + + if (!io) + return IRQ_NONE; + + if (rsnd_src_error_record_gen2(mod)) { + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); + + _rsnd_src_stop_gen2(mod); + _rsnd_src_start_gen2(mod); + + dev_dbg(dev, "%s[%d] restart\n", + rsnd_mod_name(mod), rsnd_mod_id(mod)); + } + + return IRQ_HANDLED; +} + static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod, struct rsnd_dai *rdai) { @@ -588,18 +707,38 @@ static int rsnd_src_probe_gen2(struct rsnd_mod *mod, struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_src *src = rsnd_mod_to_src(mod); struct device *dev = rsnd_priv_to_dev(priv); + int irq = src->info->irq; int ret; + if (irq > 0) { + /* + * IRQ is not supported on non-DT + * see + * rsnd_src_irq_enable_gen2() + */ + ret = devm_request_irq(dev, irq, + rsnd_src_interrupt_gen2, + IRQF_SHARED, + dev_name(dev), mod); + if (ret) + goto rsnd_src_probe_gen2_fail; + } + ret = rsnd_dma_init(priv, rsnd_mod_to_dma(mod), rsnd_info_is_playback(priv, src), src->info->dma_id); - if (ret < 0) - dev_err(dev, "%s[%d] (Gen2) failed\n", - rsnd_mod_name(mod), rsnd_mod_id(mod)); - else - dev_dbg(dev, "%s[%d] (Gen2) is probed\n", - rsnd_mod_name(mod), rsnd_mod_id(mod)); + if (ret) + goto rsnd_src_probe_gen2_fail; + + dev_dbg(dev, "%s[%d] (Gen2) is probed\n", + rsnd_mod_name(mod), rsnd_mod_id(mod)); + + return ret; + +rsnd_src_probe_gen2_fail: + dev_err(dev, "%s[%d] (Gen2) failed\n", + rsnd_mod_name(mod), rsnd_mod_id(mod)); return ret; } @@ -635,27 +774,21 @@ static int rsnd_src_init_gen2(struct rsnd_mod *mod, static int rsnd_src_start_gen2(struct rsnd_mod *mod, struct rsnd_dai *rdai) { - struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); - struct rsnd_src *src = rsnd_mod_to_src(mod); - u32 val = rsnd_io_to_mod_dvc(io) ? 0x01 : 0x11; - - rsnd_dma_start(rsnd_mod_to_dma(&src->mod)); + rsnd_dma_start(rsnd_mod_to_dma(mod)); - rsnd_mod_write(mod, SRC_CTRL, val); - - return rsnd_src_start(mod); + return _rsnd_src_start_gen2(mod); } static int rsnd_src_stop_gen2(struct rsnd_mod *mod, struct rsnd_dai *rdai) { - struct rsnd_src *src = rsnd_mod_to_src(mod); + int ret; - rsnd_mod_write(mod, SRC_CTRL, 0); + ret = _rsnd_src_stop_gen2(mod); - rsnd_dma_stop(rsnd_mod_to_dma(&src->mod)); + rsnd_dma_stop(rsnd_mod_to_dma(mod)); - return rsnd_src_stop(mod); + return ret; } static struct rsnd_mod_ops rsnd_src_gen2_ops = { @@ -681,10 +814,11 @@ static void rsnd_of_parse_src(struct platform_device *pdev, struct rsnd_priv *priv) { struct device_node *src_node; + struct device_node *np; struct rcar_snd_info *info = rsnd_priv_to_info(priv); struct rsnd_src_platform_info *src_info; struct device *dev = &pdev->dev; - int nr; + int nr, i; if (!of_data) return; @@ -708,6 +842,13 @@ static void rsnd_of_parse_src(struct platform_device *pdev, info->src_info = src_info; info->src_info_nr = nr; + i = 0; + for_each_child_of_node(src_node, np) { + src_info[i].irq = irq_of_parse_and_map(np, 0); + + i++; + } + rsnd_of_parse_src_end: of_node_put(src_node); } -- cgit From 1730fd9cce32ba88d9b157546044b2b07db9c936 Mon Sep 17 00:00:00 2001 From: David Flater Date: Sun, 11 Jan 2015 16:08:58 -0500 Subject: ALSA: fix emu8000 DRAM sizing for AWE64 Value Applicable to any kernel since 2013: The special case added in commit 1338fc97d07a did not handle the possibility that the address space on an AWE64 Value would wrap around at 512 KiB. That is what it does, so the memory is still not detected on those cards. Fix that with a logic clean-up that eliminates the need for a special case. Signed-off-by: David Flater Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 45fcdff611f9..d25e384fa8c9 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -378,13 +378,12 @@ init_arrays(struct snd_emu8000 *emu) static void size_dram(struct snd_emu8000 *emu) { - int i, size, detected_size; + int i, size; if (emu->dram_checked) return; size = 0; - detected_size = 0; /* write out a magic number */ snd_emu8000_dma_chan(emu, 0, EMU8000_RAM_WRITE); @@ -392,10 +391,19 @@ size_dram(struct snd_emu8000 *emu) EMU8000_SMALW_WRITE(emu, EMU8000_DRAM_OFFSET); EMU8000_SMLD_WRITE(emu, UNIQUE_ID1); snd_emu8000_init_fm(emu); /* This must really be here and not 2 lines back even */ + snd_emu8000_write_wait(emu); - while (size < EMU8000_MAX_DRAM) { + /* + * Detect first 512 KiB. If a write succeeds at the beginning of a + * 512 KiB page we assume that the whole page is there. + */ + EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET); + EMU8000_SMLD_READ(emu); /* discard stale data */ + if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1) + goto skip_detect; /* No RAM */ + snd_emu8000_read_wait(emu); - size += 512 * 1024; /* increment 512kbytes */ + for (size = 512 * 1024; size < EMU8000_MAX_DRAM; size += 512 * 1024) { /* Write a unique data on the test address. * if the address is out of range, the data is written on @@ -431,18 +439,9 @@ size_dram(struct snd_emu8000 *emu) snd_emu8000_read_wait(emu); /* Otherwise, it's valid memory. */ - detected_size = size + 512 * 1024; - } - - /* Distinguish 512 KiB from 0. */ - if (detected_size == 0) { - snd_emu8000_read_wait(emu); - EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET); - EMU8000_SMLD_READ(emu); /* discard stale data */ - if (EMU8000_SMLD_READ(emu) == UNIQUE_ID1) - detected_size = 512 * 1024; } +skip_detect: /* wait until FULL bit in SMAxW register is false */ for (i = 0; i < 10000; i++) { if ((EMU8000_SMALW_READ(emu) & 0x80000000) == 0) @@ -455,9 +454,9 @@ size_dram(struct snd_emu8000 *emu) snd_emu8000_dma_chan(emu, 1, EMU8000_RAM_CLOSE); snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n", - emu->port1, detected_size/1024); + emu->port1, size/1024); - emu->mem_size = detected_size; + emu->mem_size = size; emu->dram_checked = 1; } -- cgit From d2866409baaf644c8f875498b05fd3adf26fcdcd Mon Sep 17 00:00:00 2001 From: David Flater Date: Sun, 11 Jan 2015 16:10:07 -0500 Subject: ALSA: log emu8000 DRAM size at level INFO Detected sound font memory goes unreported unless the kernel was built with ALSA debugging enabled. Elevate that to a pr_info. Signed-off-by: David Flater Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index d25e384fa8c9..96e9d94d07e4 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -453,7 +453,7 @@ skip_detect: snd_emu8000_dma_chan(emu, 0, EMU8000_RAM_CLOSE); snd_emu8000_dma_chan(emu, 1, EMU8000_RAM_CLOSE); - snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n", + pr_info("EMU8000 [0x%lx]: %d KiB on-board DRAM detected\n", emu->port1, size/1024); emu->mem_size = size; -- cgit From 6c869d301bda3f672f001e2c9fcb01685000fc83 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 12 Jan 2015 16:56:51 +0100 Subject: ALSA: rme*: Use snd_pcm_format_t Fix sparse warnings below by using snd_pcm_format_t properly: sound/pci/rme32.c:682:60: sparse: incorrect type in argument 2 (different base types) sound/pci/rme96.c:1006:69: sparse: incorrect type in argument 2 (different base types) ..... Signed-off-by: Takashi Iwai --- sound/pci/rme32.c | 2 +- sound/pci/rme96.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 6c60dcd2e5a1..1a7affad7164 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -632,7 +632,7 @@ snd_rme32_setframelog(struct rme32 * rme32, int n_channels, int is_playback) } } -static int snd_rme32_setformat(struct rme32 * rme32, int format) +static int snd_rme32_setformat(struct rme32 *rme32, snd_pcm_format_t format) { switch (format) { case SNDRV_PCM_FORMAT_S16_LE: diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index e33e79eadf83..236ac1d48184 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -922,8 +922,7 @@ snd_rme96_setframelog(struct rme96 *rme96, } static int -snd_rme96_playback_setformat(struct rme96 *rme96, - int format) +snd_rme96_playback_setformat(struct rme96 *rme96, snd_pcm_format_t format) { switch (format) { case SNDRV_PCM_FORMAT_S16_LE: @@ -940,8 +939,7 @@ snd_rme96_playback_setformat(struct rme96 *rme96, } static int -snd_rme96_capture_setformat(struct rme96 *rme96, - int format) +snd_rme96_capture_setformat(struct rme96 *rme96, snd_pcm_format_t format) { switch (format) { case SNDRV_PCM_FORMAT_S16_LE: -- cgit From 61864d844c296933d40c02683252bbea5193b101 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 12 Jan 2015 22:29:57 +0100 Subject: ALSA: move line6 usb driver into sound/usb Promote line6 driver from staging to sound/usb/line6 directory, and maintain through sound subsystem tree. This commit just moves the code and adapts Makefile / Kconfig. The further renames and misc cleanups will follow. Signed-off-by: Takashi Iwai --- sound/usb/Kconfig | 2 + sound/usb/Makefile | 1 + sound/usb/line6/Kconfig | 38 ++ sound/usb/line6/Makefile | 14 + sound/usb/line6/audio.c | 71 +++ sound/usb/line6/audio.h | 21 + sound/usb/line6/capture.c | 433 +++++++++++++++++ sound/usb/line6/capture.h | 35 ++ sound/usb/line6/driver.c | 1114 ++++++++++++++++++++++++++++++++++++++++++++ sound/usb/line6/driver.h | 228 +++++++++ sound/usb/line6/midi.c | 321 +++++++++++++ sound/usb/line6/midi.h | 72 +++ sound/usb/line6/midibuf.c | 270 +++++++++++ sound/usb/line6/midibuf.h | 38 ++ sound/usb/line6/pcm.c | 527 +++++++++++++++++++++ sound/usb/line6/pcm.h | 374 +++++++++++++++ sound/usb/line6/playback.c | 593 +++++++++++++++++++++++ sound/usb/line6/playback.h | 41 ++ sound/usb/line6/pod.c | 453 ++++++++++++++++++ sound/usb/line6/pod.h | 92 ++++ sound/usb/line6/podhd.c | 156 +++++++ sound/usb/line6/podhd.h | 29 ++ sound/usb/line6/revision.h | 4 + sound/usb/line6/toneport.c | 465 ++++++++++++++++++ sound/usb/line6/toneport.h | 51 ++ sound/usb/line6/usbdefs.h | 27 ++ sound/usb/line6/variax.c | 239 ++++++++++ sound/usb/line6/variax.h | 70 +++ 28 files changed, 5779 insertions(+) create mode 100644 sound/usb/line6/Kconfig create mode 100644 sound/usb/line6/Makefile create mode 100644 sound/usb/line6/audio.c create mode 100644 sound/usb/line6/audio.h create mode 100644 sound/usb/line6/capture.c create mode 100644 sound/usb/line6/capture.h create mode 100644 sound/usb/line6/driver.c create mode 100644 sound/usb/line6/driver.h create mode 100644 sound/usb/line6/midi.c create mode 100644 sound/usb/line6/midi.h create mode 100644 sound/usb/line6/midibuf.c create mode 100644 sound/usb/line6/midibuf.h create mode 100644 sound/usb/line6/pcm.c create mode 100644 sound/usb/line6/pcm.h create mode 100644 sound/usb/line6/playback.c create mode 100644 sound/usb/line6/playback.h create mode 100644 sound/usb/line6/pod.c create mode 100644 sound/usb/line6/pod.h create mode 100644 sound/usb/line6/podhd.c create mode 100644 sound/usb/line6/podhd.h create mode 100644 sound/usb/line6/revision.h create mode 100644 sound/usb/line6/toneport.c create mode 100644 sound/usb/line6/toneport.h create mode 100644 sound/usb/line6/usbdefs.h create mode 100644 sound/usb/line6/variax.c create mode 100644 sound/usb/line6/variax.h (limited to 'sound') diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig index d393153c474f..a452ad7cec40 100644 --- a/sound/usb/Kconfig +++ b/sound/usb/Kconfig @@ -160,5 +160,7 @@ config SND_BCD2000 To compile this driver as a module, choose M here: the module will be called snd-bcd2000. +source "sound/usb/line6/Kconfig" + endif # SND_USB diff --git a/sound/usb/Makefile b/sound/usb/Makefile index bcee4060fd18..54045b745d11 100644 --- a/sound/usb/Makefile +++ b/sound/usb/Makefile @@ -25,3 +25,4 @@ obj-$(CONFIG_SND_USB_USX2Y) += snd-usbmidi-lib.o obj-$(CONFIG_SND_USB_US122L) += snd-usbmidi-lib.o obj-$(CONFIG_SND) += misc/ usx2y/ caiaq/ 6fire/ hiface/ bcd2000/ +obj-$(CONFIG_LINE6_USB) += line6/ diff --git a/sound/usb/line6/Kconfig b/sound/usb/line6/Kconfig new file mode 100644 index 000000000000..4f1219b4c692 --- /dev/null +++ b/sound/usb/line6/Kconfig @@ -0,0 +1,38 @@ +menuconfig LINE6_USB + tristate "Line6 USB support" + depends on USB && SND + select SND_RAWMIDI + select SND_PCM + help + This is a driver for the guitar amp, cab, and effects modeller + PODxt Pro by Line6 (and similar devices), supporting the + following features: + * Reading/writing individual parameters + * Reading/writing complete channel, effects setup, and amp + setup data + * Channel switching + * Virtual MIDI interface + * Tuner access + * Playback/capture/mixer device for any ALSA-compatible PCM + audio application + * Signal routing (record clean/processed guitar signal, + re-amping) + + Preliminary support for the Variax Workbench and TonePort + devices is included. + +if LINE6_USB + +config LINE6_USB_IMPULSE_RESPONSE + bool "measure impulse response" + default n + help + Say Y here to add code to measure the impulse response of a Line6 + device. This is more accurate than user-space methods since it + bypasses any PCM data buffering (e.g., by ALSA or jack). This is + useful for assessing the performance of new devices, but is not + required for normal operation. + + If unsure, say N. + +endif # LINE6_USB diff --git a/sound/usb/line6/Makefile b/sound/usb/line6/Makefile new file mode 100644 index 000000000000..ae5c374b0f87 --- /dev/null +++ b/sound/usb/line6/Makefile @@ -0,0 +1,14 @@ +obj-$(CONFIG_LINE6_USB) += line6usb.o + +line6usb-y := \ + audio.o \ + capture.o \ + driver.o \ + midi.o \ + midibuf.o \ + pcm.o \ + playback.o \ + pod.o \ + toneport.o \ + variax.o \ + podhd.o diff --git a/sound/usb/line6/audio.c b/sound/usb/line6/audio.c new file mode 100644 index 000000000000..171d80c1b020 --- /dev/null +++ b/sound/usb/line6/audio.c @@ -0,0 +1,71 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include +#include + +#include "driver.h" +#include "audio.h" + +/* + Initialize the Line6 USB audio system. +*/ +int line6_init_audio(struct usb_line6 *line6) +{ + struct snd_card *card; + int err; + + err = snd_card_new(line6->ifcdev, + SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, + THIS_MODULE, 0, &card); + if (err < 0) + return err; + + line6->card = card; + + strcpy(card->id, line6->properties->id); + strcpy(card->driver, DRIVER_NAME); + strcpy(card->shortname, line6->properties->name); + /* longname is 80 chars - see asound.h */ + sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name, + dev_name(line6->ifcdev)); + return 0; +} + +/* + Register the Line6 USB audio system. +*/ +int line6_register_audio(struct usb_line6 *line6) +{ + int err; + + err = snd_card_register(line6->card); + if (err < 0) + return err; + + return 0; +} + +/* + Cleanup the Line6 USB audio system. +*/ +void line6_cleanup_audio(struct usb_line6 *line6) +{ + struct snd_card *card = line6->card; + + if (card == NULL) + return; + + snd_card_disconnect(card); + snd_card_free(card); + line6->card = NULL; +} diff --git a/sound/usb/line6/audio.h b/sound/usb/line6/audio.h new file mode 100644 index 000000000000..5f8a09a0fa95 --- /dev/null +++ b/sound/usb/line6/audio.h @@ -0,0 +1,21 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef AUDIO_H +#define AUDIO_H + +#include "driver.h" + +extern void line6_cleanup_audio(struct usb_line6 *); +extern int line6_init_audio(struct usb_line6 *); +extern int line6_register_audio(struct usb_line6 *); + +#endif diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c new file mode 100644 index 000000000000..f24c7c5e0a3e --- /dev/null +++ b/sound/usb/line6/capture.c @@ -0,0 +1,433 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include +#include +#include + +#include "audio.h" +#include "capture.h" +#include "driver.h" +#include "pcm.h" +#include "pod.h" + +/* + Find a free URB and submit it. +*/ +static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) +{ + int index; + unsigned long flags; + int i, urb_size; + int ret; + struct urb *urb_in; + + spin_lock_irqsave(&line6pcm->lock_audio_in, flags); + index = + find_first_zero_bit(&line6pcm->active_urb_in, LINE6_ISO_BUFFERS); + + if (index < 0 || index >= LINE6_ISO_BUFFERS) { + spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); + dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); + return -EINVAL; + } + + urb_in = line6pcm->urb_audio_in[index]; + urb_size = 0; + + for (i = 0; i < LINE6_ISO_PACKETS; ++i) { + struct usb_iso_packet_descriptor *fin = + &urb_in->iso_frame_desc[i]; + fin->offset = urb_size; + fin->length = line6pcm->max_packet_size; + urb_size += line6pcm->max_packet_size; + } + + urb_in->transfer_buffer = + line6pcm->buffer_in + + index * LINE6_ISO_PACKETS * line6pcm->max_packet_size; + urb_in->transfer_buffer_length = urb_size; + urb_in->context = line6pcm; + + ret = usb_submit_urb(urb_in, GFP_ATOMIC); + + if (ret == 0) + set_bit(index, &line6pcm->active_urb_in); + else + dev_err(line6pcm->line6->ifcdev, + "URB in #%d submission failed (%d)\n", index, ret); + + spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); + return 0; +} + +/* + Submit all currently available capture URBs. +*/ +int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm) +{ + int ret, i; + + for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { + ret = submit_audio_in_urb(line6pcm); + if (ret < 0) + return ret; + } + + return 0; +} + +/* + Unlink all currently active capture URBs. +*/ +void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm) +{ + unsigned int i; + + for (i = LINE6_ISO_BUFFERS; i--;) { + if (test_bit(i, &line6pcm->active_urb_in)) { + if (!test_and_set_bit(i, &line6pcm->unlink_urb_in)) { + struct urb *u = line6pcm->urb_audio_in[i]; + + usb_unlink_urb(u); + } + } + } +} + +/* + Wait until unlinking of all currently active capture URBs has been + finished. +*/ +void line6_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) +{ + int timeout = HZ; + unsigned int i; + int alive; + + do { + alive = 0; + for (i = LINE6_ISO_BUFFERS; i--;) { + if (test_bit(i, &line6pcm->active_urb_in)) + alive++; + } + if (!alive) + break; + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); + } while (--timeout > 0); + if (alive) + snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive); +} + +/* + Unlink all currently active capture URBs, and wait for finishing. +*/ +void line6_unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) +{ + line6_unlink_audio_in_urbs(line6pcm); + line6_wait_clear_audio_in_urbs(line6pcm); +} + +/* + Copy data into ALSA capture buffer. +*/ +void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) +{ + struct snd_pcm_substream *substream = + get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE); + struct snd_pcm_runtime *runtime = substream->runtime; + const int bytes_per_frame = line6pcm->properties->bytes_per_frame; + int frames = fsize / bytes_per_frame; + + if (runtime == NULL) + return; + + if (line6pcm->pos_in_done + frames > runtime->buffer_size) { + /* + The transferred area goes over buffer boundary, + copy two separate chunks. + */ + int len; + + len = runtime->buffer_size - line6pcm->pos_in_done; + + if (len > 0) { + memcpy(runtime->dma_area + + line6pcm->pos_in_done * bytes_per_frame, fbuf, + len * bytes_per_frame); + memcpy(runtime->dma_area, fbuf + len * bytes_per_frame, + (frames - len) * bytes_per_frame); + } else { + /* this is somewhat paranoid */ + dev_err(line6pcm->line6->ifcdev, + "driver bug: len = %d\n", len); + } + } else { + /* copy single chunk */ + memcpy(runtime->dma_area + + line6pcm->pos_in_done * bytes_per_frame, fbuf, fsize); + } + + line6pcm->pos_in_done += frames; + if (line6pcm->pos_in_done >= runtime->buffer_size) + line6pcm->pos_in_done -= runtime->buffer_size; +} + +void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length) +{ + struct snd_pcm_substream *substream = + get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE); + + line6pcm->bytes_in += length; + if (line6pcm->bytes_in >= line6pcm->period_in) { + line6pcm->bytes_in %= line6pcm->period_in; + snd_pcm_period_elapsed(substream); + } +} + +void line6_free_capture_buffer(struct snd_line6_pcm *line6pcm) +{ + kfree(line6pcm->buffer_in); + line6pcm->buffer_in = NULL; +} + +/* + * Callback for completed capture URB. + */ +static void audio_in_callback(struct urb *urb) +{ + int i, index, length = 0, shutdown = 0; + unsigned long flags; + + struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context; + + line6pcm->last_frame_in = urb->start_frame; + + /* find index of URB */ + for (index = 0; index < LINE6_ISO_BUFFERS; ++index) + if (urb == line6pcm->urb_audio_in[index]) + break; + + spin_lock_irqsave(&line6pcm->lock_audio_in, flags); + + for (i = 0; i < LINE6_ISO_PACKETS; ++i) { + char *fbuf; + int fsize; + struct usb_iso_packet_descriptor *fin = &urb->iso_frame_desc[i]; + + if (fin->status == -EXDEV) { + shutdown = 1; + break; + } + + fbuf = urb->transfer_buffer + fin->offset; + fsize = fin->actual_length; + + if (fsize > line6pcm->max_packet_size) { + dev_err(line6pcm->line6->ifcdev, + "driver and/or device bug: packet too large (%d > %d)\n", + fsize, line6pcm->max_packet_size); + } + + length += fsize; + + /* the following assumes LINE6_ISO_PACKETS == 1: */ + line6pcm->prev_fbuf = fbuf; + line6pcm->prev_fsize = fsize; + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + if (!(line6pcm->flags & LINE6_BITS_PCM_IMPULSE)) +#endif + if (test_bit(LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM, + &line6pcm->flags) && (fsize > 0)) + line6_capture_copy(line6pcm, fbuf, fsize); + } + + clear_bit(index, &line6pcm->active_urb_in); + + if (test_and_clear_bit(index, &line6pcm->unlink_urb_in)) + shutdown = 1; + + spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); + + if (!shutdown) { + submit_audio_in_urb(line6pcm); + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + if (!(line6pcm->flags & LINE6_BITS_PCM_IMPULSE)) +#endif + if (test_bit(LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM, + &line6pcm->flags)) + line6_capture_check_period(line6pcm, length); + } +} + +/* open capture callback */ +static int snd_line6_capture_open(struct snd_pcm_substream *substream) +{ + int err; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + err = snd_pcm_hw_constraint_ratdens(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + (&line6pcm-> + properties->snd_line6_rates)); + if (err < 0) + return err; + + runtime->hw = line6pcm->properties->snd_line6_capture_hw; + return 0; +} + +/* close capture callback */ +static int snd_line6_capture_close(struct snd_pcm_substream *substream) +{ + return 0; +} + +/* hw_params capture callback */ +static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) +{ + int ret; + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + /* -- Florian Demski [FD] */ + /* don't ask me why, but this fixes the bug on my machine */ + if (line6pcm == NULL) { + if (substream->pcm == NULL) + return -ENOMEM; + if (substream->pcm->private_data == NULL) + return -ENOMEM; + substream->private_data = substream->pcm->private_data; + line6pcm = snd_pcm_substream_chip(substream); + } + /* -- [FD] end */ + + ret = line6_pcm_acquire(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER); + + if (ret < 0) + return ret; + + ret = snd_pcm_lib_malloc_pages(substream, + params_buffer_bytes(hw_params)); + if (ret < 0) { + line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER); + return ret; + } + + line6pcm->period_in = params_period_bytes(hw_params); + return 0; +} + +/* hw_free capture callback */ +static int snd_line6_capture_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER); + return snd_pcm_lib_free_pages(substream); +} + +/* trigger callback */ +int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd) +{ + int err; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: +#ifdef CONFIG_PM + case SNDRV_PCM_TRIGGER_RESUME: +#endif + err = line6_pcm_acquire(line6pcm, + LINE6_BIT_PCM_ALSA_CAPTURE_STREAM); + + if (err < 0) + return err; + + break; + + case SNDRV_PCM_TRIGGER_STOP: +#ifdef CONFIG_PM + case SNDRV_PCM_TRIGGER_SUSPEND: +#endif + err = line6_pcm_release(line6pcm, + LINE6_BIT_PCM_ALSA_CAPTURE_STREAM); + + if (err < 0) + return err; + + break; + + default: + return -EINVAL; + } + + return 0; +} + +/* capture pointer callback */ +static snd_pcm_uframes_t +snd_line6_capture_pointer(struct snd_pcm_substream *substream) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + return line6pcm->pos_in_done; +} + +/* capture operators */ +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_capture_hw_params, + .hw_free = snd_line6_capture_hw_free, + .prepare = snd_line6_prepare, + .trigger = snd_line6_trigger, + .pointer = snd_line6_capture_pointer, +}; + +int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) +{ + struct usb_line6 *line6 = line6pcm->line6; + int i; + + /* create audio URBs and fill in constant values: */ + for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { + struct urb *urb; + + /* URB for audio in: */ + urb = line6pcm->urb_audio_in[i] = + usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); + + if (urb == NULL) { + dev_err(line6->ifcdev, "Out of memory\n"); + return -ENOMEM; + } + + urb->dev = line6->usbdev; + urb->pipe = + usb_rcvisocpipe(line6->usbdev, + line6->properties->ep_audio_r & + USB_ENDPOINT_NUMBER_MASK); + urb->transfer_flags = URB_ISO_ASAP; + urb->start_frame = -1; + urb->number_of_packets = LINE6_ISO_PACKETS; + urb->interval = LINE6_ISO_INTERVAL; + urb->error_count = 0; + urb->complete = audio_in_callback; + } + + return 0; +} diff --git a/sound/usb/line6/capture.h b/sound/usb/line6/capture.h new file mode 100644 index 000000000000..4157bcb598a9 --- /dev/null +++ b/sound/usb/line6/capture.h @@ -0,0 +1,35 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef CAPTURE_H +#define CAPTURE_H + +#include + +#include "driver.h" +#include "pcm.h" + +extern struct snd_pcm_ops snd_line6_capture_ops; + +extern void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, + int fsize); +extern void line6_capture_check_period(struct snd_line6_pcm *line6pcm, + int length); +extern int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm); +extern void line6_free_capture_buffer(struct snd_line6_pcm *line6pcm); +extern int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm); +extern void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm); +extern void line6_unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm + *line6pcm); +extern void line6_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm); +extern int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd); + +#endif diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c new file mode 100644 index 000000000000..fc852f6ab8bc --- /dev/null +++ b/sound/usb/line6/driver.c @@ -0,0 +1,1114 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include +#include +#include + +#include "audio.h" +#include "capture.h" +#include "driver.h" +#include "midi.h" +#include "playback.h" +#include "pod.h" +#include "podhd.h" +#include "revision.h" +#include "toneport.h" +#include "usbdefs.h" +#include "variax.h" + +#define DRIVER_AUTHOR "Markus Grabner " +#define DRIVER_DESC "Line6 USB Driver" +#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION + +#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) +#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) + +/* table of devices that work with this driver */ +static const struct usb_device_id line6_id_table[] = { + { LINE6_DEVICE(0x4250), .driver_info = LINE6_BASSPODXT }, + { LINE6_DEVICE(0x4642), .driver_info = LINE6_BASSPODXTLIVE }, + { LINE6_DEVICE(0x4252), .driver_info = LINE6_BASSPODXTPRO }, + { LINE6_DEVICE(0x4750), .driver_info = LINE6_GUITARPORT }, + { LINE6_IF_NUM(0x5051, 1), .driver_info = LINE6_POCKETPOD }, + { LINE6_DEVICE(0x5057), .driver_info = LINE6_PODHD300 }, + { LINE6_DEVICE(0x5058), .driver_info = LINE6_PODHD400 }, + { LINE6_IF_NUM(0x414D, 0), .driver_info = LINE6_PODHD500_0 }, + { LINE6_IF_NUM(0x414D, 1), .driver_info = LINE6_PODHD500_1 }, + { LINE6_DEVICE(0x4153), .driver_info = LINE6_PODSTUDIO_GX }, + { LINE6_DEVICE(0x4150), .driver_info = LINE6_PODSTUDIO_UX1 }, + { LINE6_IF_NUM(0x4151, 0), .driver_info = LINE6_PODSTUDIO_UX2 }, + { LINE6_DEVICE(0x5044), .driver_info = LINE6_PODXT }, + { LINE6_IF_NUM(0x4650, 0), .driver_info = LINE6_PODXTLIVE_POD }, + { LINE6_IF_NUM(0x4650, 1), .driver_info = LINE6_PODXTLIVE_VARIAX }, + { LINE6_DEVICE(0x5050), .driver_info = LINE6_PODXTPRO }, + { LINE6_DEVICE(0x4147), .driver_info = LINE6_TONEPORT_GX }, + { LINE6_DEVICE(0x4141), .driver_info = LINE6_TONEPORT_UX1 }, + { LINE6_IF_NUM(0x4142, 0), .driver_info = LINE6_TONEPORT_UX2 }, + { LINE6_DEVICE(0x534d), .driver_info = LINE6_VARIAX }, + {} +}; + +MODULE_DEVICE_TABLE(usb, line6_id_table); + +static const struct line6_properties line6_properties_table[] = { + [LINE6_BASSPODXT] = { + .id = "BassPODxt", + .name = "BassPODxt", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_BASSPODXTLIVE] = { + .id = "BassPODxtLive", + .name = "BassPODxt Live", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_BASSPODXTPRO] = { + .id = "BassPODxtPro", + .name = "BassPODxt Pro", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_GUITARPORT] = { + .id = "GuitarPort", + .name = "GuitarPort", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_POCKETPOD] = { + .id = "PocketPOD", + .name = "Pocket POD", + .capabilities = LINE6_CAP_CONTROL, + .altsetting = 0, + .ep_ctrl_r = 0x82, + .ep_ctrl_w = 0x02, + /* no audio channel */ + }, + [LINE6_PODHD300] = { + .id = "PODHD300", + .name = "POD HD300", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODHD400] = { + .id = "PODHD400", + .name = "POD HD400", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODHD500_0] = { + .id = "PODHD500", + .name = "POD HD500", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x81, + .ep_ctrl_w = 0x01, + .ep_audio_r = 0x86, + .ep_audio_w = 0x02, + }, + [LINE6_PODHD500_1] = { + .id = "PODHD500", + .name = "POD HD500", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x81, + .ep_ctrl_w = 0x01, + .ep_audio_r = 0x86, + .ep_audio_w = 0x02, + }, + [LINE6_PODSTUDIO_GX] = { + .id = "PODStudioGX", + .name = "POD Studio GX", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODSTUDIO_UX1] = { + .id = "PODStudioUX1", + .name = "POD Studio UX1", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODSTUDIO_UX2] = { + .id = "PODStudioUX2", + .name = "POD Studio UX2", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* defaults to 44.1kHz, 16-bit */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODXT] = { + .id = "PODxt", + .name = "PODxt", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODXTLIVE_POD] = { + .id = "PODxtLive", + .name = "PODxt Live", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODXTLIVE_VARIAX] = { + .id = "PODxtLive", + .name = "PODxt Live", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x86, + .ep_ctrl_w = 0x05, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODXTPRO] = { + .id = "PODxtPro", + .name = "PODxt Pro", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_TONEPORT_GX] = { + .id = "TonePortGX", + .name = "TonePort GX", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_TONEPORT_UX1] = { + .id = "TonePortUX1", + .name = "TonePort UX1", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_TONEPORT_UX2] = { + .id = "TonePortUX2", + .name = "TonePort UX2", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* defaults to 44.1kHz, 16-bit */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_VARIAX] = { + .id = "Variax", + .name = "Variax Workbench", + .capabilities = LINE6_CAP_CONTROL, + .altsetting = 1, + .ep_ctrl_r = 0x82, + .ep_ctrl_w = 0x01, + /* no audio channel */ + } +}; + +/* + This is Line6's MIDI manufacturer ID. +*/ +const unsigned char line6_midi_id[] = { + 0x00, 0x01, 0x0c +}; + +/* + Code to request version of POD, Variax interface + (and maybe other devices). +*/ +static const char line6_request_version[] = { + 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7 +}; + +/** + Class for asynchronous messages. +*/ +struct message { + struct usb_line6 *line6; + const char *buffer; + int size; + int done; +}; + +/* + Forward declarations. +*/ +static void line6_data_received(struct urb *urb); +static int line6_send_raw_message_async_part(struct message *msg, + struct urb *urb); + +/* + Start to listen on endpoint. +*/ +static int line6_start_listen(struct usb_line6 *line6) +{ + int err; + + usb_fill_int_urb(line6->urb_listen, line6->usbdev, + usb_rcvintpipe(line6->usbdev, line6->properties->ep_ctrl_r), + line6->buffer_listen, LINE6_BUFSIZE_LISTEN, + line6_data_received, line6, line6->interval); + line6->urb_listen->actual_length = 0; + err = usb_submit_urb(line6->urb_listen, GFP_ATOMIC); + return err; +} + +/* + Stop listening on endpoint. +*/ +static void line6_stop_listen(struct usb_line6 *line6) +{ + usb_kill_urb(line6->urb_listen); +} + +/* + Send raw message in pieces of wMaxPacketSize bytes. +*/ +int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, + int size) +{ + int i, done = 0; + + for (i = 0; i < size; i += line6->max_packet_size) { + int partial; + const char *frag_buf = buffer + i; + int frag_size = min(line6->max_packet_size, size - i); + int retval; + + retval = usb_interrupt_msg(line6->usbdev, + usb_sndintpipe(line6->usbdev, + line6->properties->ep_ctrl_w), + (char *)frag_buf, frag_size, + &partial, LINE6_TIMEOUT * HZ); + + if (retval) { + dev_err(line6->ifcdev, + "usb_interrupt_msg failed (%d)\n", retval); + break; + } + + done += frag_size; + } + + return done; +} + +/* + Notification of completion of asynchronous request transmission. +*/ +static void line6_async_request_sent(struct urb *urb) +{ + struct message *msg = (struct message *)urb->context; + + if (msg->done >= msg->size) { + usb_free_urb(urb); + kfree(msg); + } else + line6_send_raw_message_async_part(msg, urb); +} + +/* + Asynchronously send part of a raw message. +*/ +static int line6_send_raw_message_async_part(struct message *msg, + struct urb *urb) +{ + int retval; + struct usb_line6 *line6 = msg->line6; + int done = msg->done; + int bytes = min(msg->size - done, line6->max_packet_size); + + usb_fill_int_urb(urb, line6->usbdev, + usb_sndintpipe(line6->usbdev, line6->properties->ep_ctrl_w), + (char *)msg->buffer + done, bytes, + line6_async_request_sent, msg, line6->interval); + + msg->done += bytes; + retval = usb_submit_urb(urb, GFP_ATOMIC); + + if (retval < 0) { + dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n", + __func__, retval); + usb_free_urb(urb); + kfree(msg); + return retval; + } + + return 0; +} + +/* + Setup and start timer. +*/ +void line6_start_timer(struct timer_list *timer, unsigned int msecs, + void (*function)(unsigned long), unsigned long data) +{ + setup_timer(timer, function, data); + timer->expires = jiffies + msecs * HZ / 1000; + add_timer(timer); +} + +/* + Asynchronously send raw message. +*/ +int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, + int size) +{ + struct message *msg; + struct urb *urb; + + /* create message: */ + msg = kmalloc(sizeof(struct message), GFP_ATOMIC); + if (msg == NULL) + return -ENOMEM; + + /* create URB: */ + urb = usb_alloc_urb(0, GFP_ATOMIC); + + if (urb == NULL) { + kfree(msg); + dev_err(line6->ifcdev, "Out of memory\n"); + return -ENOMEM; + } + + /* set message data: */ + msg->line6 = line6; + msg->buffer = buffer; + msg->size = size; + msg->done = 0; + + /* start sending: */ + return line6_send_raw_message_async_part(msg, urb); +} + +/* + Send asynchronous device version request. +*/ +int line6_version_request_async(struct usb_line6 *line6) +{ + char *buffer; + int retval; + + buffer = kmemdup(line6_request_version, + sizeof(line6_request_version), GFP_ATOMIC); + if (buffer == NULL) { + dev_err(line6->ifcdev, "Out of memory"); + return -ENOMEM; + } + + retval = line6_send_raw_message_async(line6, buffer, + sizeof(line6_request_version)); + kfree(buffer); + return retval; +} + +/* + Send sysex message in pieces of wMaxPacketSize bytes. +*/ +int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, + int size) +{ + return line6_send_raw_message(line6, buffer, + size + SYSEX_EXTRA_SIZE) - + SYSEX_EXTRA_SIZE; +} + +/* + Allocate buffer for sysex message and prepare header. + @param code sysex message code + @param size number of bytes between code and sysex end +*/ +char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, + int size) +{ + char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_ATOMIC); + + if (!buffer) + return NULL; + + buffer[0] = LINE6_SYSEX_BEGIN; + memcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id)); + buffer[sizeof(line6_midi_id) + 1] = code1; + buffer[sizeof(line6_midi_id) + 2] = code2; + buffer[sizeof(line6_midi_id) + 3 + size] = LINE6_SYSEX_END; + return buffer; +} + +/* + Notification of data received from the Line6 device. +*/ +static void line6_data_received(struct urb *urb) +{ + struct usb_line6 *line6 = (struct usb_line6 *)urb->context; + struct midi_buffer *mb = &line6->line6midi->midibuf_in; + int done; + + if (urb->status == -ESHUTDOWN) + return; + + done = + line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length); + + if (done < urb->actual_length) { + line6_midibuf_ignore(mb, done); + dev_dbg(line6->ifcdev, "%d %d buffer overflow - message skipped\n", + done, urb->actual_length); + } + + for (;;) { + done = + line6_midibuf_read(mb, line6->buffer_message, + LINE6_MESSAGE_MAXLEN); + + if (done == 0) + break; + + line6->message_length = done; + line6_midi_receive(line6, line6->buffer_message, done); + + if (line6->process_message) + line6->process_message(line6); + } + + line6_start_listen(line6); +} + +/* + Send channel number (i.e., switch to a different sound). +*/ +int line6_send_program(struct usb_line6 *line6, u8 value) +{ + int retval; + unsigned char *buffer; + int partial; + + buffer = kmalloc(2, GFP_KERNEL); + if (!buffer) + return -ENOMEM; + + buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST; + buffer[1] = value; + + retval = usb_interrupt_msg(line6->usbdev, + usb_sndintpipe(line6->usbdev, + line6->properties->ep_ctrl_w), + buffer, 2, &partial, LINE6_TIMEOUT * HZ); + + if (retval) + dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", + retval); + + kfree(buffer); + return retval; +} + +/* + Transmit Line6 control parameter. +*/ +int line6_transmit_parameter(struct usb_line6 *line6, int param, u8 value) +{ + int retval; + unsigned char *buffer; + int partial; + + buffer = kmalloc(3, GFP_KERNEL); + if (!buffer) + return -ENOMEM; + + buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST; + buffer[1] = param; + buffer[2] = value; + + retval = usb_interrupt_msg(line6->usbdev, + usb_sndintpipe(line6->usbdev, + line6->properties->ep_ctrl_w), + buffer, 3, &partial, LINE6_TIMEOUT * HZ); + + if (retval) + dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", + retval); + + kfree(buffer); + return retval; +} + +/* + Read data from device. +*/ +int line6_read_data(struct usb_line6 *line6, int address, void *data, + size_t datalen) +{ + struct usb_device *usbdev = line6->usbdev; + int ret; + unsigned char len; + + /* query the serial number: */ + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + (datalen << 8) | 0x21, address, + NULL, 0, LINE6_TIMEOUT * HZ); + + if (ret < 0) { + dev_err(line6->ifcdev, "read request failed (error %d)\n", ret); + return ret; + } + + /* Wait for data length. We'll get 0xff until length arrives. */ + do { + ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | + USB_DIR_IN, + 0x0012, 0x0000, &len, 1, + LINE6_TIMEOUT * HZ); + if (ret < 0) { + dev_err(line6->ifcdev, + "receive length failed (error %d)\n", ret); + return ret; + } + } while (len == 0xff); + + if (len != datalen) { + /* should be equal or something went wrong */ + dev_err(line6->ifcdev, + "length mismatch (expected %d, got %d)\n", + (int)datalen, (int)len); + return -EINVAL; + } + + /* receive the result: */ + ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0013, 0x0000, data, datalen, + LINE6_TIMEOUT * HZ); + + if (ret < 0) { + dev_err(line6->ifcdev, "read failed (error %d)\n", ret); + return ret; + } + + return 0; +} + +/* + Write data to device. +*/ +int line6_write_data(struct usb_line6 *line6, int address, void *data, + size_t datalen) +{ + struct usb_device *usbdev = line6->usbdev; + int ret; + unsigned char status; + + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + 0x0022, address, data, datalen, + LINE6_TIMEOUT * HZ); + + if (ret < 0) { + dev_err(line6->ifcdev, + "write request failed (error %d)\n", ret); + return ret; + } + + do { + ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), + 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | + USB_DIR_IN, + 0x0012, 0x0000, + &status, 1, LINE6_TIMEOUT * HZ); + + if (ret < 0) { + dev_err(line6->ifcdev, + "receiving status failed (error %d)\n", ret); + return ret; + } + } while (status == 0xff); + + if (status != 0) { + dev_err(line6->ifcdev, "write failed (error %d)\n", ret); + return -EINVAL; + } + + return 0; +} + +/* + Read Line6 device serial number. + (POD, TonePort, GuitarPort) +*/ +int line6_read_serial_number(struct usb_line6 *line6, int *serial_number) +{ + return line6_read_data(line6, 0x80d0, serial_number, + sizeof(*serial_number)); +} + +/* + No operation (i.e., unsupported). +*/ +ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return 0; +} + +/* + Generic destructor. +*/ +static void line6_destruct(struct usb_interface *interface) +{ + struct usb_line6 *line6; + + if (interface == NULL) + return; + line6 = usb_get_intfdata(interface); + if (line6 == NULL) + return; + + /* free buffer memory first: */ + kfree(line6->buffer_message); + kfree(line6->buffer_listen); + + /* then free URBs: */ + usb_free_urb(line6->urb_listen); + + /* make sure the device isn't destructed twice: */ + usb_set_intfdata(interface, NULL); + + /* free interface data: */ + kfree(line6); +} + +/* + Probe USB device. +*/ +static int line6_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + enum line6_device_type devtype; + struct usb_device *usbdev; + struct usb_line6 *line6; + const struct line6_properties *properties; + int interface_number; + int size = 0; + int ret; + + if (interface == NULL) + return -ENODEV; + usbdev = interface_to_usbdev(interface); + if (usbdev == NULL) + return -ENODEV; + + /* we don't handle multiple configurations */ + if (usbdev->descriptor.bNumConfigurations != 1) { + ret = -ENODEV; + goto err_put; + } + + devtype = id->driver_info; + + /* initialize device info: */ + properties = &line6_properties_table[devtype]; + dev_info(&interface->dev, "Line6 %s found\n", properties->name); + + /* query interface number */ + interface_number = interface->cur_altsetting->desc.bInterfaceNumber; + + ret = usb_set_interface(usbdev, interface_number, + properties->altsetting); + if (ret < 0) { + dev_err(&interface->dev, "set_interface failed\n"); + goto err_put; + } + + /* initialize device data based on device: */ + switch (devtype) { + case LINE6_BASSPODXT: + case LINE6_BASSPODXTLIVE: + case LINE6_BASSPODXTPRO: + case LINE6_PODXT: + case LINE6_PODXTPRO: + size = sizeof(struct usb_line6_pod); + break; + + case LINE6_PODHD300: + case LINE6_PODHD400: + size = sizeof(struct usb_line6_podhd); + break; + + case LINE6_PODHD500_0: + case LINE6_PODHD500_1: + size = sizeof(struct usb_line6_podhd); + break; + + case LINE6_POCKETPOD: + size = sizeof(struct usb_line6_pod); + break; + + case LINE6_PODSTUDIO_GX: + case LINE6_PODSTUDIO_UX1: + case LINE6_PODSTUDIO_UX2: + case LINE6_TONEPORT_GX: + case LINE6_TONEPORT_UX1: + case LINE6_TONEPORT_UX2: + case LINE6_GUITARPORT: + size = sizeof(struct usb_line6_toneport); + break; + + case LINE6_PODXTLIVE_POD: + size = sizeof(struct usb_line6_pod); + break; + + case LINE6_PODXTLIVE_VARIAX: + size = sizeof(struct usb_line6_variax); + break; + + case LINE6_VARIAX: + size = sizeof(struct usb_line6_variax); + break; + + default: + MISSING_CASE; + ret = -ENODEV; + goto err_put; + } + + if (size == 0) { + dev_err(&interface->dev, + "driver bug: interface data size not set\n"); + ret = -ENODEV; + goto err_put; + } + + line6 = kzalloc(size, GFP_KERNEL); + if (line6 == NULL) { + ret = -ENODEV; + goto err_put; + } + + /* store basic data: */ + line6->properties = properties; + line6->usbdev = usbdev; + line6->ifcdev = &interface->dev; + line6->type = devtype; + + /* get data from endpoint descriptor (see usb_maxpacket): */ + { + struct usb_host_endpoint *ep; + unsigned pipe = usb_rcvintpipe(usbdev, properties->ep_ctrl_r); + unsigned epnum = usb_pipeendpoint(pipe); + ep = usbdev->ep_in[epnum]; + + if (ep != NULL) { + line6->interval = ep->desc.bInterval; + line6->max_packet_size = + le16_to_cpu(ep->desc.wMaxPacketSize); + } else { + line6->interval = LINE6_FALLBACK_INTERVAL; + line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE; + dev_err(line6->ifcdev, + "endpoint not available, using fallback values"); + } + } + + usb_set_intfdata(interface, line6); + + if (properties->capabilities & LINE6_CAP_CONTROL) { + /* initialize USB buffers: */ + line6->buffer_listen = + kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL); + if (line6->buffer_listen == NULL) { + ret = -ENOMEM; + goto err_destruct; + } + + line6->buffer_message = + kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL); + if (line6->buffer_message == NULL) { + ret = -ENOMEM; + goto err_destruct; + } + + line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL); + + if (line6->urb_listen == NULL) { + dev_err(&interface->dev, "Out of memory\n"); + line6_destruct(interface); + ret = -ENOMEM; + goto err_destruct; + } + + ret = line6_start_listen(line6); + if (ret < 0) { + dev_err(&interface->dev, "%s: usb_submit_urb failed\n", + __func__); + goto err_destruct; + } + } + + /* initialize device data based on device: */ + switch (devtype) { + case LINE6_BASSPODXT: + case LINE6_BASSPODXTLIVE: + case LINE6_BASSPODXTPRO: + case LINE6_POCKETPOD: + case LINE6_PODXT: + case LINE6_PODXTPRO: + ret = line6_pod_init(interface, line6); + break; + + case LINE6_PODHD300: + case LINE6_PODHD400: + case LINE6_PODHD500_0: + case LINE6_PODHD500_1: + ret = line6_podhd_init(interface, line6); + break; + + case LINE6_PODXTLIVE_POD: + ret = line6_pod_init(interface, line6); + break; + + case LINE6_PODXTLIVE_VARIAX: + ret = line6_variax_init(interface, line6); + break; + + case LINE6_VARIAX: + ret = line6_variax_init(interface, line6); + break; + + case LINE6_PODSTUDIO_GX: + case LINE6_PODSTUDIO_UX1: + case LINE6_PODSTUDIO_UX2: + case LINE6_TONEPORT_GX: + case LINE6_TONEPORT_UX1: + case LINE6_TONEPORT_UX2: + case LINE6_GUITARPORT: + ret = line6_toneport_init(interface, line6); + break; + + default: + MISSING_CASE; + ret = -ENODEV; + } + + if (ret < 0) + goto err_destruct; + + ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj, + "usb_device"); + if (ret < 0) + goto err_destruct; + + /* creation of additional special files should go here */ + + dev_info(&interface->dev, "Line6 %s now attached\n", + line6->properties->name); + + /* increment reference counters: */ + usb_get_intf(interface); + usb_get_dev(usbdev); + + return 0; + +err_destruct: + line6_destruct(interface); +err_put: + return ret; +} + +/* + Line6 device disconnected. +*/ +static void line6_disconnect(struct usb_interface *interface) +{ + struct usb_line6 *line6; + struct usb_device *usbdev; + int interface_number; + + if (interface == NULL) + return; + usbdev = interface_to_usbdev(interface); + if (usbdev == NULL) + return; + + /* removal of additional special files should go here */ + + sysfs_remove_link(&interface->dev.kobj, "usb_device"); + + interface_number = interface->cur_altsetting->desc.bInterfaceNumber; + line6 = usb_get_intfdata(interface); + + if (line6 != NULL) { + if (line6->urb_listen != NULL) + line6_stop_listen(line6); + + if (usbdev != line6->usbdev) + dev_err(line6->ifcdev, + "driver bug: inconsistent usb device\n"); + + line6->disconnect(interface); + + dev_info(&interface->dev, "Line6 %s now disconnected\n", + line6->properties->name); + } + + line6_destruct(interface); + + /* decrement reference counters: */ + usb_put_intf(interface); + usb_put_dev(usbdev); +} + +#ifdef CONFIG_PM + +/* + Suspend Line6 device. +*/ +static int line6_suspend(struct usb_interface *interface, pm_message_t message) +{ + struct usb_line6 *line6 = usb_get_intfdata(interface); + struct snd_line6_pcm *line6pcm = line6->line6pcm; + + snd_power_change_state(line6->card, SNDRV_CTL_POWER_D3hot); + + if (line6->properties->capabilities & LINE6_CAP_CONTROL) + line6_stop_listen(line6); + + if (line6pcm != NULL) { + snd_pcm_suspend_all(line6pcm->pcm); + line6_pcm_disconnect(line6pcm); + line6pcm->flags = 0; + } + + return 0; +} + +/* + Resume Line6 device. +*/ +static int line6_resume(struct usb_interface *interface) +{ + struct usb_line6 *line6 = usb_get_intfdata(interface); + + if (line6->properties->capabilities & LINE6_CAP_CONTROL) + line6_start_listen(line6); + + snd_power_change_state(line6->card, SNDRV_CTL_POWER_D0); + return 0; +} + +/* + Resume Line6 device after reset. +*/ +static int line6_reset_resume(struct usb_interface *interface) +{ + struct usb_line6 *line6 = usb_get_intfdata(interface); + + switch (line6->type) { + case LINE6_PODSTUDIO_GX: + case LINE6_PODSTUDIO_UX1: + case LINE6_PODSTUDIO_UX2: + case LINE6_TONEPORT_GX: + case LINE6_TONEPORT_UX1: + case LINE6_TONEPORT_UX2: + case LINE6_GUITARPORT: + line6_toneport_reset_resume((struct usb_line6_toneport *)line6); + + default: + break; + } + + return line6_resume(interface); +} + +#endif /* CONFIG_PM */ + +static struct usb_driver line6_driver = { + .name = DRIVER_NAME, + .probe = line6_probe, + .disconnect = line6_disconnect, +#ifdef CONFIG_PM + .suspend = line6_suspend, + .resume = line6_resume, + .reset_resume = line6_reset_resume, +#endif + .id_table = line6_id_table, +}; + +module_usb_driver(line6_driver); + +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRIVER_VERSION); diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h new file mode 100644 index 000000000000..ad203f197e80 --- /dev/null +++ b/sound/usb/line6/driver.h @@ -0,0 +1,228 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef DRIVER_H +#define DRIVER_H + +#include +#include +#include + +#include "midi.h" + +#define DRIVER_NAME "line6usb" + +enum line6_device_type { + LINE6_BASSPODXT, + LINE6_BASSPODXTLIVE, + LINE6_BASSPODXTPRO, + LINE6_GUITARPORT, + LINE6_POCKETPOD, + LINE6_PODHD300, + LINE6_PODHD400, + LINE6_PODHD500_0, + LINE6_PODHD500_1, + LINE6_PODSTUDIO_GX, + LINE6_PODSTUDIO_UX1, + LINE6_PODSTUDIO_UX2, + LINE6_PODXT, + LINE6_PODXTLIVE_POD, + LINE6_PODXTLIVE_VARIAX, + LINE6_PODXTPRO, + LINE6_TONEPORT_GX, + LINE6_TONEPORT_UX1, + LINE6_TONEPORT_UX2, + LINE6_VARIAX +}; + +#define LINE6_TIMEOUT 1 +#define LINE6_BUFSIZE_LISTEN 32 +#define LINE6_MESSAGE_MAXLEN 256 + +/* + Line6 MIDI control commands +*/ +#define LINE6_PARAM_CHANGE 0xb0 +#define LINE6_PROGRAM_CHANGE 0xc0 +#define LINE6_SYSEX_BEGIN 0xf0 +#define LINE6_SYSEX_END 0xf7 +#define LINE6_RESET 0xff + +/* + MIDI channel for messages initiated by the host + (and eventually echoed back by the device) +*/ +#define LINE6_CHANNEL_HOST 0x00 + +/* + MIDI channel for messages initiated by the device +*/ +#define LINE6_CHANNEL_DEVICE 0x02 + +#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */ + +#define LINE6_CHANNEL_MASK 0x0f + +#define MISSING_CASE \ + pr_err("line6usb driver bug: missing case in %s:%d\n", \ + __FILE__, __LINE__) + +#define CHECK_RETURN(x) \ +do { \ + err = x; \ + if (err < 0) \ + return err; \ +} while (0) + +#define CHECK_STARTUP_PROGRESS(x, n) \ +do { \ + if ((x) >= (n)) \ + return; \ + x = (n); \ +} while (0) + +extern const unsigned char line6_midi_id[3]; + +static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3; +static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4; + +/** + Common properties of Line6 devices. +*/ +struct line6_properties { + /** + Card id string (maximum 16 characters). + This can be used to address the device in ALSA programs as + "default:CARD=" + */ + const char *id; + + /** + Card short name (maximum 32 characters). + */ + const char *name; + + /** + Bit vector defining this device's capabilities in the + line6usb driver. + */ + int capabilities; + + int altsetting; + + unsigned ep_ctrl_r; + unsigned ep_ctrl_w; + unsigned ep_audio_r; + unsigned ep_audio_w; +}; + +/** + Common data shared by all Line6 devices. + Corresponds to a pair of USB endpoints. +*/ +struct usb_line6 { + /** + USB device. + */ + struct usb_device *usbdev; + + /** + Device type. + */ + enum line6_device_type type; + + /** + Properties. + */ + const struct line6_properties *properties; + + /** + Interval (ms). + */ + int interval; + + /** + Maximum size of USB packet. + */ + int max_packet_size; + + /** + Device representing the USB interface. + */ + struct device *ifcdev; + + /** + Line6 sound card data structure. + Each device has at least MIDI or PCM. + */ + struct snd_card *card; + + /** + Line6 PCM device data structure. + */ + struct snd_line6_pcm *line6pcm; + + /** + Line6 MIDI device data structure. + */ + struct snd_line6_midi *line6midi; + + /** + URB for listening to PODxt Pro control endpoint. + */ + struct urb *urb_listen; + + /** + Buffer for listening to PODxt Pro control endpoint. + */ + unsigned char *buffer_listen; + + /** + Buffer for message to be processed. + */ + unsigned char *buffer_message; + + /** + Length of message to be processed. + */ + int message_length; + + void (*process_message)(struct usb_line6 *); + void (*disconnect)(struct usb_interface *); +}; + +extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, + int code2, int size); +extern ssize_t line6_nop_read(struct device *dev, + struct device_attribute *attr, char *buf); +extern int line6_read_data(struct usb_line6 *line6, int address, void *data, + size_t datalen); +extern int line6_read_serial_number(struct usb_line6 *line6, + int *serial_number); +extern int line6_send_program(struct usb_line6 *line6, u8 value); +extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, + int size); +extern int line6_send_raw_message_async(struct usb_line6 *line6, + const char *buffer, int size); +extern int line6_send_sysex_message(struct usb_line6 *line6, + const char *buffer, int size); +extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +extern void line6_start_timer(struct timer_list *timer, unsigned int msecs, + void (*function)(unsigned long), + unsigned long data); +extern int line6_transmit_parameter(struct usb_line6 *line6, int param, + u8 value); +extern int line6_version_request_async(struct usb_line6 *line6); +extern int line6_write_data(struct usb_line6 *line6, int address, void *data, + size_t datalen); + +#endif diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c new file mode 100644 index 000000000000..c9d725ae85a0 --- /dev/null +++ b/sound/usb/line6/midi.c @@ -0,0 +1,321 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include +#include +#include + +#include "audio.h" +#include "driver.h" +#include "midi.h" +#include "pod.h" +#include "usbdefs.h" + +#define line6_rawmidi_substream_midi(substream) \ + ((struct snd_line6_midi *)((substream)->rmidi->private_data)) + +static int send_midi_async(struct usb_line6 *line6, unsigned char *data, + int length); + +/* + Pass data received via USB to MIDI. +*/ +void line6_midi_receive(struct usb_line6 *line6, unsigned char *data, + int length) +{ + if (line6->line6midi->substream_receive) + snd_rawmidi_receive(line6->line6midi->substream_receive, + data, length); +} + +/* + Read data from MIDI buffer and transmit them via USB. +*/ +static void line6_midi_transmit(struct snd_rawmidi_substream *substream) +{ + struct usb_line6 *line6 = + line6_rawmidi_substream_midi(substream)->line6; + struct snd_line6_midi *line6midi = line6->line6midi; + struct midi_buffer *mb = &line6midi->midibuf_out; + unsigned long flags; + unsigned char chunk[LINE6_FALLBACK_MAXPACKETSIZE]; + int req, done; + + spin_lock_irqsave(&line6->line6midi->midi_transmit_lock, flags); + + for (;;) { + req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size); + done = snd_rawmidi_transmit_peek(substream, chunk, req); + + if (done == 0) + break; + + line6_midibuf_write(mb, chunk, done); + snd_rawmidi_transmit_ack(substream, done); + } + + for (;;) { + done = line6_midibuf_read(mb, chunk, + LINE6_FALLBACK_MAXPACKETSIZE); + + if (done == 0) + break; + + send_midi_async(line6, chunk, done); + } + + spin_unlock_irqrestore(&line6->line6midi->midi_transmit_lock, flags); +} + +/* + Notification of completion of MIDI transmission. +*/ +static void midi_sent(struct urb *urb) +{ + unsigned long flags; + int status; + int num; + struct usb_line6 *line6 = (struct usb_line6 *)urb->context; + + status = urb->status; + kfree(urb->transfer_buffer); + usb_free_urb(urb); + + if (status == -ESHUTDOWN) + return; + + spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags); + num = --line6->line6midi->num_active_send_urbs; + + if (num == 0) { + line6_midi_transmit(line6->line6midi->substream_transmit); + num = line6->line6midi->num_active_send_urbs; + } + + if (num == 0) + wake_up(&line6->line6midi->send_wait); + + spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags); +} + +/* + Send an asynchronous MIDI message. + Assumes that line6->line6midi->send_urb_lock is held + (i.e., this function is serialized). +*/ +static int send_midi_async(struct usb_line6 *line6, unsigned char *data, + int length) +{ + struct urb *urb; + int retval; + unsigned char *transfer_buffer; + + urb = usb_alloc_urb(0, GFP_ATOMIC); + + if (urb == NULL) { + dev_err(line6->ifcdev, "Out of memory\n"); + return -ENOMEM; + } + + transfer_buffer = kmemdup(data, length, GFP_ATOMIC); + + if (transfer_buffer == NULL) { + usb_free_urb(urb); + dev_err(line6->ifcdev, "Out of memory\n"); + return -ENOMEM; + } + + usb_fill_int_urb(urb, line6->usbdev, + usb_sndbulkpipe(line6->usbdev, + line6->properties->ep_ctrl_w), + transfer_buffer, length, midi_sent, line6, + line6->interval); + urb->actual_length = 0; + retval = usb_submit_urb(urb, GFP_ATOMIC); + + if (retval < 0) { + dev_err(line6->ifcdev, "usb_submit_urb failed\n"); + usb_free_urb(urb); + return retval; + } + + ++line6->line6midi->num_active_send_urbs; + return 0; +} + +static int line6_midi_output_open(struct snd_rawmidi_substream *substream) +{ + return 0; +} + +static int line6_midi_output_close(struct snd_rawmidi_substream *substream) +{ + return 0; +} + +static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream, + int up) +{ + unsigned long flags; + struct usb_line6 *line6 = + line6_rawmidi_substream_midi(substream)->line6; + + line6->line6midi->substream_transmit = substream; + spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags); + + if (line6->line6midi->num_active_send_urbs == 0) + line6_midi_transmit(substream); + + spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags); +} + +static void line6_midi_output_drain(struct snd_rawmidi_substream *substream) +{ + struct usb_line6 *line6 = + line6_rawmidi_substream_midi(substream)->line6; + struct snd_line6_midi *midi = line6->line6midi; + + wait_event_interruptible(midi->send_wait, + midi->num_active_send_urbs == 0); +} + +static int line6_midi_input_open(struct snd_rawmidi_substream *substream) +{ + return 0; +} + +static int line6_midi_input_close(struct snd_rawmidi_substream *substream) +{ + return 0; +} + +static void line6_midi_input_trigger(struct snd_rawmidi_substream *substream, + int up) +{ + struct usb_line6 *line6 = + line6_rawmidi_substream_midi(substream)->line6; + + if (up) + line6->line6midi->substream_receive = substream; + else + line6->line6midi->substream_receive = NULL; +} + +static struct snd_rawmidi_ops line6_midi_output_ops = { + .open = line6_midi_output_open, + .close = line6_midi_output_close, + .trigger = line6_midi_output_trigger, + .drain = line6_midi_output_drain, +}; + +static struct snd_rawmidi_ops line6_midi_input_ops = { + .open = line6_midi_input_open, + .close = line6_midi_input_close, + .trigger = line6_midi_input_trigger, +}; + +/* + Cleanup the Line6 MIDI device. +*/ +static void line6_cleanup_midi(struct snd_rawmidi *rmidi) +{ +} + +/* Create a MIDI device */ +static int snd_line6_new_midi(struct snd_line6_midi *line6midi) +{ + struct snd_rawmidi *rmidi; + int err; + + err = snd_rawmidi_new(line6midi->line6->card, "Line6 MIDI", 0, 1, 1, + &rmidi); + if (err < 0) + return err; + + rmidi->private_data = line6midi; + rmidi->private_free = line6_cleanup_midi; + strcpy(rmidi->id, line6midi->line6->properties->id); + strcpy(rmidi->name, line6midi->line6->properties->name); + + rmidi->info_flags = + SNDRV_RAWMIDI_INFO_OUTPUT | + SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; + + snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, + &line6_midi_output_ops); + snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, + &line6_midi_input_ops); + return 0; +} + +/* MIDI device destructor */ +static int snd_line6_midi_free(struct snd_device *device) +{ + struct snd_line6_midi *line6midi = device->device_data; + + line6_midibuf_destroy(&line6midi->midibuf_in); + line6_midibuf_destroy(&line6midi->midibuf_out); + return 0; +} + +/* + Initialize the Line6 MIDI subsystem. +*/ +int line6_init_midi(struct usb_line6 *line6) +{ + static struct snd_device_ops midi_ops = { + .dev_free = snd_line6_midi_free, + }; + + int err; + struct snd_line6_midi *line6midi; + + if (!(line6->properties->capabilities & LINE6_CAP_CONTROL)) { + /* skip MIDI initialization and report success */ + return 0; + } + + line6midi = kzalloc(sizeof(struct snd_line6_midi), GFP_KERNEL); + + if (line6midi == NULL) + return -ENOMEM; + + err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0); + if (err < 0) { + kfree(line6midi); + return err; + } + + err = line6_midibuf_init(&line6midi->midibuf_out, MIDI_BUFFER_SIZE, 1); + if (err < 0) { + kfree(line6midi->midibuf_in.buf); + kfree(line6midi); + return err; + } + + line6midi->line6 = line6; + line6->line6midi = line6midi; + + err = snd_device_new(line6->card, SNDRV_DEV_RAWMIDI, line6midi, + &midi_ops); + if (err < 0) + return err; + + err = snd_line6_new_midi(line6midi); + if (err < 0) + return err; + + init_waitqueue_head(&line6midi->send_wait); + spin_lock_init(&line6midi->send_urb_lock); + spin_lock_init(&line6midi->midi_transmit_lock); + return 0; +} diff --git a/sound/usb/line6/midi.h b/sound/usb/line6/midi.h new file mode 100644 index 000000000000..78f903fb4d41 --- /dev/null +++ b/sound/usb/line6/midi.h @@ -0,0 +1,72 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef MIDI_H +#define MIDI_H + +#include + +#include "midibuf.h" + +#define MIDI_BUFFER_SIZE 1024 + +struct snd_line6_midi { + /** + Pointer back to the Line6 driver data structure. + */ + struct usb_line6 *line6; + + /** + MIDI substream for receiving (or NULL if not active). + */ + struct snd_rawmidi_substream *substream_receive; + + /** + MIDI substream for transmitting (or NULL if not active). + */ + struct snd_rawmidi_substream *substream_transmit; + + /** + Number of currently active MIDI send URBs. + */ + int num_active_send_urbs; + + /** + Spin lock to protect updates of send_urb. + */ + spinlock_t send_urb_lock; + + /** + Spin lock to protect MIDI buffer handling. + */ + spinlock_t midi_transmit_lock; + + /** + Wait queue for MIDI transmission. + */ + wait_queue_head_t send_wait; + + /** + Buffer for incoming MIDI stream. + */ + struct midi_buffer midibuf_in; + + /** + Buffer for outgoing MIDI stream. + */ + struct midi_buffer midibuf_out; +}; + +extern int line6_init_midi(struct usb_line6 *line6); +extern void line6_midi_receive(struct usb_line6 *line6, unsigned char *data, + int length); + +#endif diff --git a/sound/usb/line6/midibuf.c b/sound/usb/line6/midibuf.c new file mode 100644 index 000000000000..1ff856989fd6 --- /dev/null +++ b/sound/usb/line6/midibuf.c @@ -0,0 +1,270 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include + +#include "midibuf.h" + +static int midibuf_message_length(unsigned char code) +{ + int message_length; + + if (code < 0x80) + message_length = -1; + else if (code < 0xf0) { + static const int length[] = { 3, 3, 3, 3, 2, 2, 3 }; + + message_length = length[(code >> 4) - 8]; + } else { + /* + Note that according to the MIDI specification 0xf2 is + the "Song Position Pointer", but this is used by Line6 + to send sysex messages to the host. + */ + static const int length[] = { -1, 2, -1, 2, -1, -1, 1, 1, 1, 1, + 1, 1, 1, -1, 1, 1 + }; + message_length = length[code & 0x0f]; + } + + return message_length; +} + +static int midibuf_is_empty(struct midi_buffer *this) +{ + return (this->pos_read == this->pos_write) && !this->full; +} + +static int midibuf_is_full(struct midi_buffer *this) +{ + return this->full; +} + +void line6_midibuf_reset(struct midi_buffer *this) +{ + this->pos_read = this->pos_write = this->full = 0; + this->command_prev = -1; +} + +int line6_midibuf_init(struct midi_buffer *this, int size, int split) +{ + this->buf = kmalloc(size, GFP_KERNEL); + + if (this->buf == NULL) + return -ENOMEM; + + this->size = size; + this->split = split; + line6_midibuf_reset(this); + return 0; +} + +void line6_midibuf_status(struct midi_buffer *this) +{ + pr_debug("midibuf size=%d split=%d pos_read=%d pos_write=%d full=%d command_prev=%02x\n", + this->size, this->split, this->pos_read, this->pos_write, + this->full, this->command_prev); +} + +int line6_midibuf_bytes_free(struct midi_buffer *this) +{ + return + midibuf_is_full(this) ? + 0 : + (this->pos_read - this->pos_write + this->size - 1) % this->size + + 1; +} + +int line6_midibuf_bytes_used(struct midi_buffer *this) +{ + return + midibuf_is_empty(this) ? + 0 : + (this->pos_write - this->pos_read + this->size - 1) % this->size + + 1; +} + +int line6_midibuf_write(struct midi_buffer *this, unsigned char *data, + int length) +{ + int bytes_free; + int length1, length2; + int skip_active_sense = 0; + + if (midibuf_is_full(this) || (length <= 0)) + return 0; + + /* skip trailing active sense */ + if (data[length - 1] == 0xfe) { + --length; + skip_active_sense = 1; + } + + bytes_free = line6_midibuf_bytes_free(this); + + if (length > bytes_free) + length = bytes_free; + + if (length > 0) { + length1 = this->size - this->pos_write; + + if (length < length1) { + /* no buffer wraparound */ + memcpy(this->buf + this->pos_write, data, length); + this->pos_write += length; + } else { + /* buffer wraparound */ + length2 = length - length1; + memcpy(this->buf + this->pos_write, data, length1); + memcpy(this->buf, data + length1, length2); + this->pos_write = length2; + } + + if (this->pos_write == this->pos_read) + this->full = 1; + } + + return length + skip_active_sense; +} + +int line6_midibuf_read(struct midi_buffer *this, unsigned char *data, + int length) +{ + int bytes_used; + int length1, length2; + int command; + int midi_length; + int repeat = 0; + int i; + + /* we need to be able to store at least a 3 byte MIDI message */ + if (length < 3) + return -EINVAL; + + if (midibuf_is_empty(this)) + return 0; + + bytes_used = line6_midibuf_bytes_used(this); + + if (length > bytes_used) + length = bytes_used; + + length1 = this->size - this->pos_read; + + /* check MIDI command length */ + command = this->buf[this->pos_read]; + + if (command & 0x80) { + midi_length = midibuf_message_length(command); + this->command_prev = command; + } else { + if (this->command_prev > 0) { + int midi_length_prev = + midibuf_message_length(this->command_prev); + + if (midi_length_prev > 0) { + midi_length = midi_length_prev - 1; + repeat = 1; + } else + midi_length = -1; + } else + midi_length = -1; + } + + if (midi_length < 0) { + /* search for end of message */ + if (length < length1) { + /* no buffer wraparound */ + for (i = 1; i < length; ++i) + if (this->buf[this->pos_read + i] & 0x80) + break; + + midi_length = i; + } else { + /* buffer wraparound */ + length2 = length - length1; + + for (i = 1; i < length1; ++i) + if (this->buf[this->pos_read + i] & 0x80) + break; + + if (i < length1) + midi_length = i; + else { + for (i = 0; i < length2; ++i) + if (this->buf[i] & 0x80) + break; + + midi_length = length1 + i; + } + } + + if (midi_length == length) + midi_length = -1; /* end of message not found */ + } + + if (midi_length < 0) { + if (!this->split) + return 0; /* command is not yet complete */ + } else { + if (length < midi_length) + return 0; /* command is not yet complete */ + + length = midi_length; + } + + if (length < length1) { + /* no buffer wraparound */ + memcpy(data + repeat, this->buf + this->pos_read, length); + this->pos_read += length; + } else { + /* buffer wraparound */ + length2 = length - length1; + memcpy(data + repeat, this->buf + this->pos_read, length1); + memcpy(data + repeat + length1, this->buf, length2); + this->pos_read = length2; + } + + if (repeat) + data[0] = this->command_prev; + + this->full = 0; + return length + repeat; +} + +int line6_midibuf_ignore(struct midi_buffer *this, int length) +{ + int bytes_used = line6_midibuf_bytes_used(this); + + if (length > bytes_used) + length = bytes_used; + + this->pos_read = (this->pos_read + length) % this->size; + this->full = 0; + return length; +} + +int line6_midibuf_skip_message(struct midi_buffer *this, unsigned short mask) +{ + int cmd = this->command_prev; + + if ((cmd >= 0x80) && (cmd < 0xf0)) + if ((mask & (1 << (cmd & 0x0f))) == 0) + return 1; + + return 0; +} + +void line6_midibuf_destroy(struct midi_buffer *this) +{ + kfree(this->buf); + this->buf = NULL; +} diff --git a/sound/usb/line6/midibuf.h b/sound/usb/line6/midibuf.h new file mode 100644 index 000000000000..707482b940e4 --- /dev/null +++ b/sound/usb/line6/midibuf.h @@ -0,0 +1,38 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef MIDIBUF_H +#define MIDIBUF_H + +struct midi_buffer { + unsigned char *buf; + int size; + int split; + int pos_read, pos_write; + int full; + int command_prev; +}; + +extern int line6_midibuf_bytes_used(struct midi_buffer *mb); +extern int line6_midibuf_bytes_free(struct midi_buffer *mb); +extern void line6_midibuf_destroy(struct midi_buffer *mb); +extern int line6_midibuf_ignore(struct midi_buffer *mb, int length); +extern int line6_midibuf_init(struct midi_buffer *mb, int size, int split); +extern int line6_midibuf_read(struct midi_buffer *mb, unsigned char *data, + int length); +extern void line6_midibuf_reset(struct midi_buffer *mb); +extern int line6_midibuf_skip_message(struct midi_buffer *mb, + unsigned short mask); +extern void line6_midibuf_status(struct midi_buffer *mb); +extern int line6_midibuf_write(struct midi_buffer *mb, unsigned char *data, + int length); + +#endif diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c new file mode 100644 index 000000000000..6d4e5cd0482c --- /dev/null +++ b/sound/usb/line6/pcm.c @@ -0,0 +1,527 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include +#include +#include +#include + +#include "audio.h" +#include "capture.h" +#include "driver.h" +#include "playback.h" +#include "pod.h" + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + +static struct snd_line6_pcm *dev2pcm(struct device *dev) +{ + struct usb_interface *interface = to_usb_interface(dev); + struct usb_line6 *line6 = usb_get_intfdata(interface); + struct snd_line6_pcm *line6pcm = line6->line6pcm; + return line6pcm; +} + +/* + "read" request on "impulse_volume" special file. +*/ +static ssize_t impulse_volume_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_volume); +} + +/* + "write" request on "impulse_volume" special file. +*/ +static ssize_t impulse_volume_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct snd_line6_pcm *line6pcm = dev2pcm(dev); + int value; + int ret; + + ret = kstrtoint(buf, 10, &value); + if (ret < 0) + return ret; + + line6pcm->impulse_volume = value; + + if (value > 0) + line6_pcm_acquire(line6pcm, LINE6_BITS_PCM_IMPULSE); + else + line6_pcm_release(line6pcm, LINE6_BITS_PCM_IMPULSE); + + return count; +} +static DEVICE_ATTR_RW(impulse_volume); + +/* + "read" request on "impulse_period" special file. +*/ +static ssize_t impulse_period_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_period); +} + +/* + "write" request on "impulse_period" special file. +*/ +static ssize_t impulse_period_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int value; + int ret; + + ret = kstrtoint(buf, 10, &value); + if (ret < 0) + return ret; + + dev2pcm(dev)->impulse_period = value; + return count; +} +static DEVICE_ATTR_RW(impulse_period); + +#endif + +static bool test_flags(unsigned long flags0, unsigned long flags1, + unsigned long mask) +{ + return ((flags0 & mask) == 0) && ((flags1 & mask) != 0); +} + +int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) +{ + unsigned long flags_old, flags_new, flags_final; + int err; + + do { + flags_old = ACCESS_ONCE(line6pcm->flags); + flags_new = flags_old | channels; + } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old); + + flags_final = flags_old; + + line6pcm->prev_fbuf = NULL; + + if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_BUFFER)) { + /* Invoked multiple times in a row so allocate once only */ + if (!line6pcm->buffer_in) { + line6pcm->buffer_in = + kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * + line6pcm->max_packet_size, GFP_KERNEL); + if (!line6pcm->buffer_in) { + err = -ENOMEM; + goto pcm_acquire_error; + } + + flags_final |= channels & LINE6_BITS_CAPTURE_BUFFER; + } + } + + if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_STREAM)) { + /* + Waiting for completion of active URBs in the stop handler is + a bug, we therefore report an error if capturing is restarted + too soon. + */ + if (line6pcm->active_urb_in | line6pcm->unlink_urb_in) { + dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); + return -EBUSY; + } + + line6pcm->count_in = 0; + line6pcm->prev_fsize = 0; + err = line6_submit_audio_in_all_urbs(line6pcm); + + if (err < 0) + goto pcm_acquire_error; + + flags_final |= channels & LINE6_BITS_CAPTURE_STREAM; + } + + if (test_flags(flags_old, flags_new, LINE6_BITS_PLAYBACK_BUFFER)) { + /* Invoked multiple times in a row so allocate once only */ + if (!line6pcm->buffer_out) { + line6pcm->buffer_out = + kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * + line6pcm->max_packet_size, GFP_KERNEL); + if (!line6pcm->buffer_out) { + err = -ENOMEM; + goto pcm_acquire_error; + } + + flags_final |= channels & LINE6_BITS_PLAYBACK_BUFFER; + } + } + + if (test_flags(flags_old, flags_new, LINE6_BITS_PLAYBACK_STREAM)) { + /* + See comment above regarding PCM restart. + */ + if (line6pcm->active_urb_out | line6pcm->unlink_urb_out) { + dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); + return -EBUSY; + } + + line6pcm->count_out = 0; + err = line6_submit_audio_out_all_urbs(line6pcm); + + if (err < 0) + goto pcm_acquire_error; + + flags_final |= channels & LINE6_BITS_PLAYBACK_STREAM; + } + + return 0; + +pcm_acquire_error: + /* + If not all requested resources/streams could be obtained, release + those which were successfully obtained (if any). + */ + line6_pcm_release(line6pcm, flags_final & channels); + return err; +} + +int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) +{ + unsigned long flags_old, flags_new; + + do { + flags_old = ACCESS_ONCE(line6pcm->flags); + flags_new = flags_old & ~channels; + } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old); + + if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_STREAM)) + line6_unlink_audio_in_urbs(line6pcm); + + if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_BUFFER)) { + line6_wait_clear_audio_in_urbs(line6pcm); + line6_free_capture_buffer(line6pcm); + } + + if (test_flags(flags_new, flags_old, LINE6_BITS_PLAYBACK_STREAM)) + line6_unlink_audio_out_urbs(line6pcm); + + if (test_flags(flags_new, flags_old, LINE6_BITS_PLAYBACK_BUFFER)) { + line6_wait_clear_audio_out_urbs(line6pcm); + line6_free_playback_buffer(line6pcm); + } + + return 0; +} + +/* trigger callback */ +int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + struct snd_pcm_substream *s; + int err; + unsigned long flags; + + spin_lock_irqsave(&line6pcm->lock_trigger, flags); + clear_bit(LINE6_INDEX_PREPARED, &line6pcm->flags); + + snd_pcm_group_for_each_entry(s, substream) { + switch (s->stream) { + case SNDRV_PCM_STREAM_PLAYBACK: + err = snd_line6_playback_trigger(line6pcm, cmd); + + if (err < 0) { + spin_unlock_irqrestore(&line6pcm->lock_trigger, + flags); + return err; + } + + break; + + case SNDRV_PCM_STREAM_CAPTURE: + err = snd_line6_capture_trigger(line6pcm, cmd); + + if (err < 0) { + spin_unlock_irqrestore(&line6pcm->lock_trigger, + flags); + return err; + } + + break; + + default: + dev_err(line6pcm->line6->ifcdev, + "Unknown stream direction %d\n", s->stream); + } + } + + spin_unlock_irqrestore(&line6pcm->lock_trigger, flags); + return 0; +} + +/* control info callback */ +static int snd_line6_control_playback_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 2; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 256; + return 0; +} + +/* control get callback */ +static int snd_line6_control_playback_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int i; + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + + for (i = 2; i--;) + ucontrol->value.integer.value[i] = line6pcm->volume_playback[i]; + + return 0; +} + +/* control put callback */ +static int snd_line6_control_playback_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int i, changed = 0; + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + + for (i = 2; i--;) + if (line6pcm->volume_playback[i] != + ucontrol->value.integer.value[i]) { + line6pcm->volume_playback[i] = + ucontrol->value.integer.value[i]; + changed = 1; + } + + return changed; +} + +/* control definition */ +static struct snd_kcontrol_new line6_control_playback = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "PCM Playback Volume", + .index = 0, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, + .info = snd_line6_control_playback_info, + .get = snd_line6_control_playback_get, + .put = snd_line6_control_playback_put +}; + +/* + Cleanup the PCM device. +*/ +static void line6_cleanup_pcm(struct snd_pcm *pcm) +{ + int i; + struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm); + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + device_remove_file(line6pcm->line6->ifcdev, &dev_attr_impulse_volume); + device_remove_file(line6pcm->line6->ifcdev, &dev_attr_impulse_period); +#endif + + for (i = LINE6_ISO_BUFFERS; i--;) { + if (line6pcm->urb_audio_out[i]) { + usb_kill_urb(line6pcm->urb_audio_out[i]); + usb_free_urb(line6pcm->urb_audio_out[i]); + } + if (line6pcm->urb_audio_in[i]) { + usb_kill_urb(line6pcm->urb_audio_in[i]); + usb_free_urb(line6pcm->urb_audio_in[i]); + } + } +} + +/* create a PCM device */ +static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm) +{ + struct snd_pcm *pcm; + int err; + + err = snd_pcm_new(line6pcm->line6->card, + (char *)line6pcm->line6->properties->name, + 0, 1, 1, &pcm); + if (err < 0) + return err; + + pcm->private_data = line6pcm; + pcm->private_free = line6_cleanup_pcm; + line6pcm->pcm = pcm; + strcpy(pcm->name, line6pcm->line6->properties->name); + + /* set operators */ + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, + &snd_line6_playback_ops); + 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, + snd_dma_continuous_data + (GFP_KERNEL), 64 * 1024, + 128 * 1024); + + return 0; +} + +/* PCM device destructor */ +static int snd_line6_pcm_free(struct snd_device *device) +{ + return 0; +} + +/* + Stop substream if still running. +*/ +static void pcm_disconnect_substream(struct snd_pcm_substream *substream) +{ + if (substream->runtime && snd_pcm_running(substream)) { + snd_pcm_stream_lock_irq(substream); + snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED); + snd_pcm_stream_unlock_irq(substream); + } +} + +/* + Stop PCM stream. +*/ +void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm) +{ + pcm_disconnect_substream(get_substream + (line6pcm, SNDRV_PCM_STREAM_CAPTURE)); + pcm_disconnect_substream(get_substream + (line6pcm, SNDRV_PCM_STREAM_PLAYBACK)); + line6_unlink_wait_clear_audio_out_urbs(line6pcm); + line6_unlink_wait_clear_audio_in_urbs(line6pcm); +} + +/* + Create and register the PCM device and mixer entries. + Create URBs for playback and capture. +*/ +int line6_init_pcm(struct usb_line6 *line6, + struct line6_pcm_properties *properties) +{ + static struct snd_device_ops pcm_ops = { + .dev_free = snd_line6_pcm_free, + }; + + int err; + unsigned ep_read = line6->properties->ep_audio_r; + unsigned ep_write = line6->properties->ep_audio_w; + struct snd_line6_pcm *line6pcm; + + if (!(line6->properties->capabilities & LINE6_CAP_PCM)) + return 0; /* skip PCM initialization and report success */ + + line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL); + + if (line6pcm == NULL) + return -ENOMEM; + + line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255; + line6pcm->volume_monitor = 255; + line6pcm->line6 = line6; + + /* Read and write buffers are sized identically, so choose minimum */ + line6pcm->max_packet_size = min( + usb_maxpacket(line6->usbdev, + usb_rcvisocpipe(line6->usbdev, ep_read), 0), + usb_maxpacket(line6->usbdev, + usb_sndisocpipe(line6->usbdev, ep_write), 1)); + + line6pcm->properties = properties; + line6->line6pcm = line6pcm; + + /* PCM device: */ + err = snd_device_new(line6->card, SNDRV_DEV_PCM, line6, &pcm_ops); + if (err < 0) + return err; + + err = snd_line6_new_pcm(line6pcm); + if (err < 0) + return err; + + spin_lock_init(&line6pcm->lock_audio_out); + spin_lock_init(&line6pcm->lock_audio_in); + spin_lock_init(&line6pcm->lock_trigger); + + err = line6_create_audio_out_urbs(line6pcm); + if (err < 0) + return err; + + err = line6_create_audio_in_urbs(line6pcm); + if (err < 0) + return err; + + /* mixer: */ + err = + snd_ctl_add(line6->card, + snd_ctl_new1(&line6_control_playback, line6pcm)); + if (err < 0) + return err; + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + /* impulse response test: */ + err = device_create_file(line6->ifcdev, &dev_attr_impulse_volume); + if (err < 0) + return err; + + err = device_create_file(line6->ifcdev, &dev_attr_impulse_period); + if (err < 0) + return err; + + line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; +#endif + + return 0; +} + +/* prepare pcm callback */ +int snd_line6_prepare(struct snd_pcm_substream *substream) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + switch (substream->stream) { + case SNDRV_PCM_STREAM_PLAYBACK: + if ((line6pcm->flags & LINE6_BITS_PLAYBACK_STREAM) == 0) + line6_unlink_wait_clear_audio_out_urbs(line6pcm); + + break; + + case SNDRV_PCM_STREAM_CAPTURE: + if ((line6pcm->flags & LINE6_BITS_CAPTURE_STREAM) == 0) + line6_unlink_wait_clear_audio_in_urbs(line6pcm); + + break; + + default: + MISSING_CASE; + } + + if (!test_and_set_bit(LINE6_INDEX_PREPARED, &line6pcm->flags)) { + line6pcm->count_out = 0; + line6pcm->pos_out = 0; + line6pcm->pos_out_done = 0; + line6pcm->bytes_out = 0; + line6pcm->count_in = 0; + line6pcm->pos_in_done = 0; + line6pcm->bytes_in = 0; + } + + return 0; +} diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h new file mode 100644 index 000000000000..7315e8131184 --- /dev/null +++ b/sound/usb/line6/pcm.h @@ -0,0 +1,374 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +/* + PCM interface to POD series devices. +*/ + +#ifndef PCM_H +#define PCM_H + +#include + +#include "driver.h" +#include "usbdefs.h" + +/* number of URBs */ +#define LINE6_ISO_BUFFERS 2 + +/* + number of USB frames per URB + The Line6 Windows driver always transmits two frames per packet, but + the Linux driver performs significantly better (i.e., lower latency) + with only one frame per packet. +*/ +#define LINE6_ISO_PACKETS 1 + +/* in a "full speed" device (such as the PODxt Pro) this means 1ms */ +#define LINE6_ISO_INTERVAL 1 + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE +#define LINE6_IMPULSE_DEFAULT_PERIOD 100 +#endif + +/* + Get substream from Line6 PCM data structure +*/ +#define get_substream(line6pcm, stream) \ + (line6pcm->pcm->streams[stream].substream) + +/* + PCM mode bits. + + There are several features of the Line6 USB driver which require PCM + data to be exchanged with the device: + *) PCM playback and capture via ALSA + *) software monitoring (for devices without hardware monitoring) + *) optional impulse response measurement + However, from the device's point of view, there is just a single + capture and playback stream, which must be shared between these + subsystems. It is therefore necessary to maintain the state of the + subsystems with respect to PCM usage. We define several constants of + the form LINE6_BIT_PCM___ with the + following meanings: + *) is one of + -) ALSA: PCM playback and capture via ALSA + -) MONITOR: software monitoring + -) IMPULSE: optional impulse response measurement + *) is one of + -) PLAYBACK: audio output (from host to device) + -) CAPTURE: audio input (from device to host) + *) is one of + -) BUFFER: buffer required by PCM data stream + -) STREAM: actual PCM data stream + + The subsystems call line6_pcm_acquire() to acquire the (shared) + resources needed for a particular operation (e.g., allocate the buffer + for ALSA playback or start the capture stream for software monitoring). + When a resource is no longer needed, it is released by calling + line6_pcm_release(). Buffer allocation and stream startup are handled + separately to allow the ALSA kernel driver to perform them at + appropriate places (since the callback which starts a PCM stream is not + allowed to sleep). +*/ +enum { + /* individual bit indices: */ + LINE6_INDEX_PCM_ALSA_PLAYBACK_BUFFER, + LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, + LINE6_INDEX_PCM_ALSA_CAPTURE_BUFFER, + LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM, + LINE6_INDEX_PCM_MONITOR_PLAYBACK_BUFFER, + LINE6_INDEX_PCM_MONITOR_PLAYBACK_STREAM, + LINE6_INDEX_PCM_MONITOR_CAPTURE_BUFFER, + LINE6_INDEX_PCM_MONITOR_CAPTURE_STREAM, +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + LINE6_INDEX_PCM_IMPULSE_PLAYBACK_BUFFER, + LINE6_INDEX_PCM_IMPULSE_PLAYBACK_STREAM, + LINE6_INDEX_PCM_IMPULSE_CAPTURE_BUFFER, + LINE6_INDEX_PCM_IMPULSE_CAPTURE_STREAM, +#endif + LINE6_INDEX_PAUSE_PLAYBACK, + LINE6_INDEX_PREPARED, + +#define LINE6_BIT(x) LINE6_BIT_ ## x = 1 << LINE6_INDEX_ ## x + + /* individual bit masks: */ + LINE6_BIT(PCM_ALSA_PLAYBACK_BUFFER), + LINE6_BIT(PCM_ALSA_PLAYBACK_STREAM), + LINE6_BIT(PCM_ALSA_CAPTURE_BUFFER), + LINE6_BIT(PCM_ALSA_CAPTURE_STREAM), + LINE6_BIT(PCM_MONITOR_PLAYBACK_BUFFER), + LINE6_BIT(PCM_MONITOR_PLAYBACK_STREAM), + LINE6_BIT(PCM_MONITOR_CAPTURE_BUFFER), + LINE6_BIT(PCM_MONITOR_CAPTURE_STREAM), +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + LINE6_BIT(PCM_IMPULSE_PLAYBACK_BUFFER), + LINE6_BIT(PCM_IMPULSE_PLAYBACK_STREAM), + LINE6_BIT(PCM_IMPULSE_CAPTURE_BUFFER), + LINE6_BIT(PCM_IMPULSE_CAPTURE_STREAM), +#endif + LINE6_BIT(PAUSE_PLAYBACK), + LINE6_BIT(PREPARED), + + /* combined bit masks (by operation): */ + LINE6_BITS_PCM_ALSA_BUFFER = + LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER | + LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER, + + LINE6_BITS_PCM_ALSA_STREAM = + LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM | + LINE6_BIT_PCM_ALSA_CAPTURE_STREAM, + + LINE6_BITS_PCM_MONITOR = + LINE6_BIT_PCM_MONITOR_PLAYBACK_BUFFER | + LINE6_BIT_PCM_MONITOR_PLAYBACK_STREAM | + LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER | + LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM, + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + LINE6_BITS_PCM_IMPULSE = + LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER | + LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM | + LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER | + LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM, +#endif + + /* combined bit masks (by direction): */ + LINE6_BITS_PLAYBACK_BUFFER = +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER | +#endif + LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER | + LINE6_BIT_PCM_MONITOR_PLAYBACK_BUFFER, + + LINE6_BITS_PLAYBACK_STREAM = +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM | +#endif + LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM | + LINE6_BIT_PCM_MONITOR_PLAYBACK_STREAM, + + LINE6_BITS_CAPTURE_BUFFER = +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER | +#endif + LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER | + LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER, + + LINE6_BITS_CAPTURE_STREAM = +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM | +#endif + LINE6_BIT_PCM_ALSA_CAPTURE_STREAM | + LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM, + + LINE6_BITS_STREAM = + LINE6_BITS_PLAYBACK_STREAM | + LINE6_BITS_CAPTURE_STREAM +}; + +struct line6_pcm_properties { + struct snd_pcm_hardware snd_line6_playback_hw, snd_line6_capture_hw; + struct snd_pcm_hw_constraint_ratdens snd_line6_rates; + int bytes_per_frame; +}; + +struct snd_line6_pcm { + /** + Pointer back to the Line6 driver data structure. + */ + struct usb_line6 *line6; + + /** + Properties. + */ + struct line6_pcm_properties *properties; + + /** + ALSA pcm stream + */ + struct snd_pcm *pcm; + + /** + URBs for audio playback. + */ + struct urb *urb_audio_out[LINE6_ISO_BUFFERS]; + + /** + URBs for audio capture. + */ + struct urb *urb_audio_in[LINE6_ISO_BUFFERS]; + + /** + Temporary buffer for playback. + Since the packet size is not known in advance, this buffer is + large enough to store maximum size packets. + */ + unsigned char *buffer_out; + + /** + Temporary buffer for capture. + Since the packet size is not known in advance, this buffer is + large enough to store maximum size packets. + */ + unsigned char *buffer_in; + + /** + Previously captured frame (for software monitoring). + */ + unsigned char *prev_fbuf; + + /** + Size of previously captured frame (for software monitoring). + */ + int prev_fsize; + + /** + Free frame position in the playback buffer. + */ + snd_pcm_uframes_t pos_out; + + /** + Count processed bytes for playback. + This is modulo period size (to determine when a period is + finished). + */ + unsigned bytes_out; + + /** + Counter to create desired playback sample rate. + */ + unsigned count_out; + + /** + Playback period size in bytes + */ + unsigned period_out; + + /** + Processed frame position in the playback buffer. + The contents of the output ring buffer have been consumed by + the USB subsystem (i.e., sent to the USB device) up to this + position. + */ + snd_pcm_uframes_t pos_out_done; + + /** + Count processed bytes for capture. + This is modulo period size (to determine when a period is + finished). + */ + unsigned bytes_in; + + /** + Counter to create desired capture sample rate. + */ + unsigned count_in; + + /** + Capture period size in bytes + */ + unsigned period_in; + + /** + Processed frame position in the capture buffer. + The contents of the output ring buffer have been consumed by + the USB subsystem (i.e., sent to the USB device) up to this + position. + */ + snd_pcm_uframes_t pos_in_done; + + /** + Bit mask of active playback URBs. + */ + unsigned long active_urb_out; + + /** + Maximum size of USB packet. + */ + int max_packet_size; + + /** + Bit mask of active capture URBs. + */ + unsigned long active_urb_in; + + /** + Bit mask of playback URBs currently being unlinked. + */ + unsigned long unlink_urb_out; + + /** + Bit mask of capture URBs currently being unlinked. + */ + unsigned long unlink_urb_in; + + /** + Spin lock to protect updates of the playback buffer positions (not + contents!) + */ + spinlock_t lock_audio_out; + + /** + Spin lock to protect updates of the capture buffer positions (not + contents!) + */ + spinlock_t lock_audio_in; + + /** + Spin lock to protect trigger. + */ + spinlock_t lock_trigger; + + /** + PCM playback volume (left and right). + */ + int volume_playback[2]; + + /** + PCM monitor volume. + */ + int volume_monitor; + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + /** + Volume of impulse response test signal (if zero, test is disabled). + */ + int impulse_volume; + + /** + Period of impulse response test signal. + */ + int impulse_period; + + /** + Counter for impulse response test signal. + */ + int impulse_count; +#endif + + /** + Several status bits (see LINE6_BIT_*). + */ + unsigned long flags; + + int last_frame_in, last_frame_out; +}; + +extern int line6_init_pcm(struct usb_line6 *line6, + struct line6_pcm_properties *properties); +extern int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd); +extern int snd_line6_prepare(struct snd_pcm_substream *substream); +extern void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm); +extern int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels); +extern int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels); + +#endif diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c new file mode 100644 index 000000000000..da2e3b8876b8 --- /dev/null +++ b/sound/usb/line6/playback.c @@ -0,0 +1,593 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include +#include +#include + +#include "audio.h" +#include "capture.h" +#include "driver.h" +#include "pcm.h" +#include "pod.h" +#include "playback.h" + +/* + Software stereo volume control. +*/ +static void change_volume(struct urb *urb_out, int volume[], + int bytes_per_frame) +{ + int chn = 0; + + if (volume[0] == 256 && volume[1] == 256) + return; /* maximum volume - no change */ + + if (bytes_per_frame == 4) { + short *p, *buf_end; + + p = (short *)urb_out->transfer_buffer; + buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); + + for (; p < buf_end; ++p) { + *p = (*p * volume[chn & 1]) >> 8; + ++chn; + } + } else if (bytes_per_frame == 6) { + unsigned char *p, *buf_end; + + p = (unsigned char *)urb_out->transfer_buffer; + buf_end = p + urb_out->transfer_buffer_length; + + for (; p < buf_end; p += 3) { + int val; + + val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16); + val = (val * volume[chn & 1]) >> 8; + p[0] = val; + p[1] = val >> 8; + p[2] = val >> 16; + ++chn; + } + } +} + +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + +/* + Create signal for impulse response test. +*/ +static void create_impulse_test_signal(struct snd_line6_pcm *line6pcm, + struct urb *urb_out, int bytes_per_frame) +{ + int frames = urb_out->transfer_buffer_length / bytes_per_frame; + + if (bytes_per_frame == 4) { + int i; + short *pi = (short *)line6pcm->prev_fbuf; + short *po = (short *)urb_out->transfer_buffer; + + for (i = 0; i < frames; ++i) { + po[0] = pi[0]; + po[1] = 0; + pi += 2; + po += 2; + } + } else if (bytes_per_frame == 6) { + int i, j; + unsigned char *pi = line6pcm->prev_fbuf; + unsigned char *po = urb_out->transfer_buffer; + + for (i = 0; i < frames; ++i) { + for (j = 0; j < bytes_per_frame / 2; ++j) + po[j] = pi[j]; + + for (; j < bytes_per_frame; ++j) + po[j] = 0; + + pi += bytes_per_frame; + po += bytes_per_frame; + } + } + if (--line6pcm->impulse_count <= 0) { + ((unsigned char *)(urb_out->transfer_buffer))[bytes_per_frame - + 1] = + line6pcm->impulse_volume; + line6pcm->impulse_count = line6pcm->impulse_period; + } +} + +#endif + +/* + Add signal to buffer for software monitoring. +*/ +static void add_monitor_signal(struct urb *urb_out, unsigned char *signal, + int volume, int bytes_per_frame) +{ + if (volume == 0) + return; /* zero volume - no change */ + + if (bytes_per_frame == 4) { + short *pi, *po, *buf_end; + + pi = (short *)signal; + po = (short *)urb_out->transfer_buffer; + buf_end = po + urb_out->transfer_buffer_length / sizeof(*po); + + for (; po < buf_end; ++pi, ++po) + *po += (*pi * volume) >> 8; + } + + /* + We don't need to handle devices with 6 bytes per frame here + since they all support hardware monitoring. + */ +} + +/* + Find a free URB, prepare audio data, and submit URB. +*/ +static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) +{ + int index; + unsigned long flags; + int i, urb_size, urb_frames; + int ret; + const int bytes_per_frame = line6pcm->properties->bytes_per_frame; + const int frame_increment = + line6pcm->properties->snd_line6_rates.rats[0].num_min; + const int frame_factor = + line6pcm->properties->snd_line6_rates.rats[0].den * + (USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL); + struct urb *urb_out; + + spin_lock_irqsave(&line6pcm->lock_audio_out, flags); + index = + find_first_zero_bit(&line6pcm->active_urb_out, LINE6_ISO_BUFFERS); + + if (index < 0 || index >= LINE6_ISO_BUFFERS) { + spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); + dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); + return -EINVAL; + } + + urb_out = line6pcm->urb_audio_out[index]; + urb_size = 0; + + for (i = 0; i < LINE6_ISO_PACKETS; ++i) { + /* compute frame size for given sampling rate */ + int fsize = 0; + struct usb_iso_packet_descriptor *fout = + &urb_out->iso_frame_desc[i]; + + if (line6pcm->flags & LINE6_BITS_CAPTURE_STREAM) + fsize = line6pcm->prev_fsize; + + if (fsize == 0) { + int n; + + line6pcm->count_out += frame_increment; + n = line6pcm->count_out / frame_factor; + line6pcm->count_out -= n * frame_factor; + fsize = n * bytes_per_frame; + } + + fout->offset = urb_size; + fout->length = fsize; + urb_size += fsize; + } + + if (urb_size == 0) { + /* can't determine URB size */ + spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); + dev_err(line6pcm->line6->ifcdev, "driver bug: urb_size = 0\n"); + return -EINVAL; + } + + urb_frames = urb_size / bytes_per_frame; + urb_out->transfer_buffer = + line6pcm->buffer_out + + index * LINE6_ISO_PACKETS * line6pcm->max_packet_size; + urb_out->transfer_buffer_length = urb_size; + urb_out->context = line6pcm; + + if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags) && + !test_bit(LINE6_INDEX_PAUSE_PLAYBACK, &line6pcm->flags)) { + struct snd_pcm_runtime *runtime = + get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK)->runtime; + + if (line6pcm->pos_out + urb_frames > runtime->buffer_size) { + /* + The transferred area goes over buffer boundary, + copy the data to the temp buffer. + */ + int len; + + len = runtime->buffer_size - line6pcm->pos_out; + + if (len > 0) { + memcpy(urb_out->transfer_buffer, + runtime->dma_area + + line6pcm->pos_out * bytes_per_frame, + len * bytes_per_frame); + memcpy(urb_out->transfer_buffer + + len * bytes_per_frame, runtime->dma_area, + (urb_frames - len) * bytes_per_frame); + } else + dev_err(line6pcm->line6->ifcdev, "driver bug: len = %d\n", + len); + } else { + memcpy(urb_out->transfer_buffer, + runtime->dma_area + + line6pcm->pos_out * bytes_per_frame, + urb_out->transfer_buffer_length); + } + + line6pcm->pos_out += urb_frames; + if (line6pcm->pos_out >= runtime->buffer_size) + line6pcm->pos_out -= runtime->buffer_size; + } else { + memset(urb_out->transfer_buffer, 0, + urb_out->transfer_buffer_length); + } + + change_volume(urb_out, line6pcm->volume_playback, bytes_per_frame); + + if (line6pcm->prev_fbuf != NULL) { +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + if (line6pcm->flags & LINE6_BITS_PCM_IMPULSE) { + create_impulse_test_signal(line6pcm, urb_out, + bytes_per_frame); + if (line6pcm->flags & + LINE6_BIT_PCM_ALSA_CAPTURE_STREAM) { + line6_capture_copy(line6pcm, + urb_out->transfer_buffer, + urb_out-> + transfer_buffer_length); + line6_capture_check_period(line6pcm, + urb_out->transfer_buffer_length); + } + } else { +#endif + if (! + (line6pcm->line6-> + properties->capabilities & LINE6_CAP_HWMON) + && (line6pcm->flags & LINE6_BITS_PLAYBACK_STREAM) + && (line6pcm->flags & LINE6_BITS_CAPTURE_STREAM)) + add_monitor_signal(urb_out, line6pcm->prev_fbuf, + line6pcm->volume_monitor, + bytes_per_frame); +#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE + } +#endif + } + + ret = usb_submit_urb(urb_out, GFP_ATOMIC); + + if (ret == 0) + set_bit(index, &line6pcm->active_urb_out); + else + dev_err(line6pcm->line6->ifcdev, + "URB out #%d submission failed (%d)\n", index, ret); + + spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); + return 0; +} + +/* + Submit all currently available playback URBs. +*/ +int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm) +{ + int ret, i; + + for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { + ret = submit_audio_out_urb(line6pcm); + if (ret < 0) + return ret; + } + + return 0; +} + +/* + Unlink all currently active playback URBs. +*/ +void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm) +{ + unsigned int i; + + for (i = LINE6_ISO_BUFFERS; i--;) { + if (test_bit(i, &line6pcm->active_urb_out)) { + if (!test_and_set_bit(i, &line6pcm->unlink_urb_out)) { + struct urb *u = line6pcm->urb_audio_out[i]; + + usb_unlink_urb(u); + } + } + } +} + +/* + Wait until unlinking of all currently active playback URBs has been + finished. +*/ +void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) +{ + int timeout = HZ; + unsigned int i; + int alive; + + do { + alive = 0; + for (i = LINE6_ISO_BUFFERS; i--;) { + if (test_bit(i, &line6pcm->active_urb_out)) + alive++; + } + if (!alive) + break; + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); + } while (--timeout > 0); + if (alive) + snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive); +} + +/* + Unlink all currently active playback URBs, and wait for finishing. +*/ +void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) +{ + line6_unlink_audio_out_urbs(line6pcm); + line6_wait_clear_audio_out_urbs(line6pcm); +} + +void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm) +{ + kfree(line6pcm->buffer_out); + line6pcm->buffer_out = NULL; +} + +/* + Callback for completed playback URB. +*/ +static void audio_out_callback(struct urb *urb) +{ + int i, index, length = 0, shutdown = 0; + unsigned long flags; + struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context; + struct snd_pcm_substream *substream = + get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK); + +#if USE_CLEAR_BUFFER_WORKAROUND + memset(urb->transfer_buffer, 0, urb->transfer_buffer_length); +#endif + + line6pcm->last_frame_out = urb->start_frame; + + /* find index of URB */ + for (index = LINE6_ISO_BUFFERS; index--;) + if (urb == line6pcm->urb_audio_out[index]) + break; + + if (index < 0) + return; /* URB has been unlinked asynchronously */ + + for (i = LINE6_ISO_PACKETS; i--;) + length += urb->iso_frame_desc[i].length; + + spin_lock_irqsave(&line6pcm->lock_audio_out, flags); + + if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags)) { + struct snd_pcm_runtime *runtime = substream->runtime; + + line6pcm->pos_out_done += + length / line6pcm->properties->bytes_per_frame; + + if (line6pcm->pos_out_done >= runtime->buffer_size) + line6pcm->pos_out_done -= runtime->buffer_size; + } + + clear_bit(index, &line6pcm->active_urb_out); + + for (i = LINE6_ISO_PACKETS; i--;) + if (urb->iso_frame_desc[i].status == -EXDEV) { + shutdown = 1; + break; + } + + if (test_and_clear_bit(index, &line6pcm->unlink_urb_out)) + shutdown = 1; + + spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); + + if (!shutdown) { + submit_audio_out_urb(line6pcm); + + if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, + &line6pcm->flags)) { + line6pcm->bytes_out += length; + if (line6pcm->bytes_out >= line6pcm->period_out) { + line6pcm->bytes_out %= line6pcm->period_out; + snd_pcm_period_elapsed(substream); + } + } + } +} + +/* open playback callback */ +static int snd_line6_playback_open(struct snd_pcm_substream *substream) +{ + int err; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + err = snd_pcm_hw_constraint_ratdens(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + (&line6pcm-> + properties->snd_line6_rates)); + if (err < 0) + return err; + + runtime->hw = line6pcm->properties->snd_line6_playback_hw; + return 0; +} + +/* close playback callback */ +static int snd_line6_playback_close(struct snd_pcm_substream *substream) +{ + return 0; +} + +/* hw_params playback callback */ +static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) +{ + int ret; + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + /* -- Florian Demski [FD] */ + /* don't ask me why, but this fixes the bug on my machine */ + if (line6pcm == NULL) { + if (substream->pcm == NULL) + return -ENOMEM; + if (substream->pcm->private_data == NULL) + return -ENOMEM; + substream->private_data = substream->pcm->private_data; + line6pcm = snd_pcm_substream_chip(substream); + } + /* -- [FD] end */ + + ret = line6_pcm_acquire(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER); + + if (ret < 0) + return ret; + + ret = snd_pcm_lib_malloc_pages(substream, + params_buffer_bytes(hw_params)); + if (ret < 0) { + line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER); + return ret; + } + + line6pcm->period_out = params_period_bytes(hw_params); + return 0; +} + +/* hw_free playback callback */ +static int snd_line6_playback_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER); + return snd_pcm_lib_free_pages(substream); +} + +/* trigger playback callback */ +int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd) +{ + int err; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: +#ifdef CONFIG_PM + case SNDRV_PCM_TRIGGER_RESUME: +#endif + err = line6_pcm_acquire(line6pcm, + LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM); + + if (err < 0) + return err; + + break; + + case SNDRV_PCM_TRIGGER_STOP: +#ifdef CONFIG_PM + case SNDRV_PCM_TRIGGER_SUSPEND: +#endif + err = line6_pcm_release(line6pcm, + LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM); + + if (err < 0) + return err; + + break; + + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + set_bit(LINE6_INDEX_PAUSE_PLAYBACK, &line6pcm->flags); + break; + + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + clear_bit(LINE6_INDEX_PAUSE_PLAYBACK, &line6pcm->flags); + break; + + default: + return -EINVAL; + } + + return 0; +} + +/* playback pointer callback */ +static snd_pcm_uframes_t +snd_line6_playback_pointer(struct snd_pcm_substream *substream) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + + return line6pcm->pos_out_done; +} + +/* playback operators */ +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_playback_hw_params, + .hw_free = snd_line6_playback_hw_free, + .prepare = snd_line6_prepare, + .trigger = snd_line6_trigger, + .pointer = snd_line6_playback_pointer, +}; + +int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) +{ + struct usb_line6 *line6 = line6pcm->line6; + int i; + + /* create audio URBs and fill in constant values: */ + for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { + struct urb *urb; + + /* URB for audio out: */ + urb = line6pcm->urb_audio_out[i] = + usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); + + if (urb == NULL) { + dev_err(line6->ifcdev, "Out of memory\n"); + return -ENOMEM; + } + + urb->dev = line6->usbdev; + urb->pipe = + usb_sndisocpipe(line6->usbdev, + line6->properties->ep_audio_w & + USB_ENDPOINT_NUMBER_MASK); + urb->transfer_flags = URB_ISO_ASAP; + urb->start_frame = -1; + urb->number_of_packets = LINE6_ISO_PACKETS; + urb->interval = LINE6_ISO_INTERVAL; + urb->error_count = 0; + urb->complete = audio_out_callback; + } + + return 0; +} diff --git a/sound/usb/line6/playback.h b/sound/usb/line6/playback.h new file mode 100644 index 000000000000..743bd6f74c57 --- /dev/null +++ b/sound/usb/line6/playback.h @@ -0,0 +1,41 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef PLAYBACK_H +#define PLAYBACK_H + +#include + +#include "driver.h" + +/* + * When the TonePort is used with jack in full duplex mode and the outputs are + * not connected, the software monitor produces an ugly noise since everything + * written to the output buffer (i.e., the input signal) will be repeated in + * the next period (sounds like a delay effect). As a workaround, the output + * buffer is cleared after the data have been read, but there must be a better + * solution. Until one is found, this workaround can be used to fix the + * problem. + */ +#define USE_CLEAR_BUFFER_WORKAROUND 1 + +extern struct snd_pcm_ops snd_line6_playback_ops; + +extern int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm); +extern void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm); +extern int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm); +extern void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm); +extern void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm + *line6pcm); +extern void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm); +extern int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd); + +#endif diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c new file mode 100644 index 000000000000..85a43631996e --- /dev/null +++ b/sound/usb/line6/pod.c @@ -0,0 +1,453 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include +#include + +#include "audio.h" +#include "capture.h" +#include "driver.h" +#include "playback.h" +#include "pod.h" + +#define POD_SYSEX_CODE 3 +#define POD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */ + +/* *INDENT-OFF* */ + +enum { + POD_SYSEX_SAVE = 0x24, + POD_SYSEX_SYSTEM = 0x56, + POD_SYSEX_SYSTEMREQ = 0x57, + /* POD_SYSEX_UPDATE = 0x6c, */ /* software update! */ + POD_SYSEX_STORE = 0x71, + POD_SYSEX_FINISH = 0x72, + POD_SYSEX_DUMPMEM = 0x73, + POD_SYSEX_DUMP = 0x74, + POD_SYSEX_DUMPREQ = 0x75 + + /* dumps entire internal memory of PODxt Pro */ + /* POD_SYSEX_DUMPMEM2 = 0x76 */ +}; + +enum { + POD_MONITOR_LEVEL = 0x04, + POD_SYSTEM_INVALID = 0x10000 +}; + +/* *INDENT-ON* */ + +enum { + POD_DUMP_MEMORY = 2 +}; + +enum { + POD_BUSY_READ, + POD_BUSY_WRITE, + POD_CHANNEL_DIRTY, + POD_SAVE_PRESSED, + POD_BUSY_MIDISEND +}; + +static struct snd_ratden pod_ratden = { + .num_min = 78125, + .num_max = 78125, + .num_step = 1, + .den = 2 +}; + +static struct line6_pcm_properties pod_pcm_properties = { + .snd_line6_playback_hw = { + .info = (SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | +#ifdef CONFIG_PM + SNDRV_PCM_INFO_RESUME | +#endif + SNDRV_PCM_INFO_SYNC_START), + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .rates = SNDRV_PCM_RATE_KNOT, + .rate_min = 39062, + .rate_max = 39063, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = 60000, + .period_bytes_min = 64, + .period_bytes_max = 8192, + .periods_min = 1, + .periods_max = 1024}, + .snd_line6_capture_hw = { + .info = (SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | +#ifdef CONFIG_PM + SNDRV_PCM_INFO_RESUME | +#endif + SNDRV_PCM_INFO_SYNC_START), + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .rates = SNDRV_PCM_RATE_KNOT, + .rate_min = 39062, + .rate_max = 39063, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = 60000, + .period_bytes_min = 64, + .period_bytes_max = 8192, + .periods_min = 1, + .periods_max = 1024}, + .snd_line6_rates = { + .nrats = 1, + .rats = &pod_ratden}, + .bytes_per_frame = POD_BYTES_PER_FRAME +}; + +static const char pod_version_header[] = { + 0xf2, 0x7e, 0x7f, 0x06, 0x02 +}; + +/* forward declarations: */ +static void pod_startup2(unsigned long data); +static void pod_startup3(struct usb_line6_pod *pod); + +static char *pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code, + int size) +{ + return line6_alloc_sysex_buffer(&pod->line6, POD_SYSEX_CODE, code, + size); +} + +/* + Process a completely received message. +*/ +static void line6_pod_process_message(struct usb_line6 *line6) +{ + struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; + const unsigned char *buf = pod->line6.buffer_message; + + if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) { + pod->firmware_version = buf[13] * 100 + buf[14] * 10 + buf[15]; + pod->device_id = ((int)buf[8] << 16) | ((int)buf[9] << 8) | + (int) buf[10]; + pod_startup3(pod); + return; + } + + /* Only look for sysex messages from this device */ + if (buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE) && + buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN)) { + return; + } + if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) != 0) + return; + + if (buf[5] == POD_SYSEX_SYSTEM && buf[6] == POD_MONITOR_LEVEL) { + short value = ((int)buf[7] << 12) | ((int)buf[8] << 8) | + ((int)buf[9] << 4) | (int)buf[10]; + pod->monitor_level = value; + } +} + +/* + Send system parameter (from integer). +*/ +static int pod_set_system_param_int(struct usb_line6_pod *pod, int value, + int code) +{ + char *sysex; + static const int size = 5; + + sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEM, size); + if (!sysex) + return -ENOMEM; + sysex[SYSEX_DATA_OFS] = code; + sysex[SYSEX_DATA_OFS + 1] = (value >> 12) & 0x0f; + sysex[SYSEX_DATA_OFS + 2] = (value >> 8) & 0x0f; + sysex[SYSEX_DATA_OFS + 3] = (value >> 4) & 0x0f; + sysex[SYSEX_DATA_OFS + 4] = (value) & 0x0f; + line6_send_sysex_message(&pod->line6, sysex, size); + kfree(sysex); + return 0; +} + +/* + "read" request on "serial_number" special file. +*/ +static ssize_t serial_number_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct usb_interface *interface = to_usb_interface(dev); + struct usb_line6_pod *pod = usb_get_intfdata(interface); + + return sprintf(buf, "%d\n", pod->serial_number); +} + +/* + "read" request on "firmware_version" special file. +*/ +static ssize_t firmware_version_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct usb_interface *interface = to_usb_interface(dev); + struct usb_line6_pod *pod = usb_get_intfdata(interface); + + return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100, + pod->firmware_version % 100); +} + +/* + "read" request on "device_id" special file. +*/ +static ssize_t device_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct usb_interface *interface = to_usb_interface(dev); + struct usb_line6_pod *pod = usb_get_intfdata(interface); + + return sprintf(buf, "%d\n", pod->device_id); +} + +/* + POD startup procedure. + This is a sequence of functions with special requirements (e.g., must + not run immediately after initialization, must not run in interrupt + context). After the last one has finished, the device is ready to use. +*/ + +static void pod_startup1(struct usb_line6_pod *pod) +{ + CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_INIT); + + /* delay startup procedure: */ + line6_start_timer(&pod->startup_timer, POD_STARTUP_DELAY, pod_startup2, + (unsigned long)pod); +} + +static void pod_startup2(unsigned long data) +{ + struct usb_line6_pod *pod = (struct usb_line6_pod *)data; + struct usb_line6 *line6 = &pod->line6; + + CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_VERSIONREQ); + + /* request firmware version: */ + line6_version_request_async(line6); +} + +static void pod_startup3(struct usb_line6_pod *pod) +{ + CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_WORKQUEUE); + + /* schedule work for global work queue: */ + schedule_work(&pod->startup_work); +} + +static void pod_startup4(struct work_struct *work) +{ + struct usb_line6_pod *pod = + container_of(work, struct usb_line6_pod, startup_work); + struct usb_line6 *line6 = &pod->line6; + + CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_SETUP); + + /* serial number: */ + line6_read_serial_number(&pod->line6, &pod->serial_number); + + /* ALSA audio interface: */ + line6_register_audio(line6); +} + +/* POD special files: */ +static DEVICE_ATTR_RO(device_id); +static DEVICE_ATTR_RO(firmware_version); +static DEVICE_ATTR_RO(serial_number); + +/* control info callback */ +static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 65535; + return 0; +} + +/* control get callback */ +static int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6; + + ucontrol->value.integer.value[0] = pod->monitor_level; + return 0; +} + +/* control put callback */ +static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6; + + if (ucontrol->value.integer.value[0] == pod->monitor_level) + return 0; + + pod->monitor_level = ucontrol->value.integer.value[0]; + pod_set_system_param_int(pod, ucontrol->value.integer.value[0], + POD_MONITOR_LEVEL); + return 1; +} + +/* control definition */ +static struct snd_kcontrol_new pod_control_monitor = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Monitor Playback Volume", + .index = 0, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, + .info = snd_pod_control_monitor_info, + .get = snd_pod_control_monitor_get, + .put = snd_pod_control_monitor_put +}; + +/* + POD destructor. +*/ +static void pod_destruct(struct usb_interface *interface) +{ + struct usb_line6_pod *pod = usb_get_intfdata(interface); + + if (pod == NULL) + return; + line6_cleanup_audio(&pod->line6); + + del_timer(&pod->startup_timer); + cancel_work_sync(&pod->startup_work); +} + +/* + POD device disconnected. +*/ +static void line6_pod_disconnect(struct usb_interface *interface) +{ + struct usb_line6_pod *pod; + + if (interface == NULL) + return; + pod = usb_get_intfdata(interface); + + if (pod != NULL) { + struct snd_line6_pcm *line6pcm = pod->line6.line6pcm; + struct device *dev = &interface->dev; + + if (line6pcm != NULL) + line6_pcm_disconnect(line6pcm); + + if (dev != NULL) { + /* remove sysfs entries: */ + device_remove_file(dev, &dev_attr_device_id); + device_remove_file(dev, &dev_attr_firmware_version); + device_remove_file(dev, &dev_attr_serial_number); + } + } + + pod_destruct(interface); +} + +/* + Create sysfs entries. +*/ +static int pod_create_files2(struct device *dev) +{ + int err; + + CHECK_RETURN(device_create_file(dev, &dev_attr_device_id)); + CHECK_RETURN(device_create_file(dev, &dev_attr_firmware_version)); + CHECK_RETURN(device_create_file(dev, &dev_attr_serial_number)); + return 0; +} + +/* + Try to init POD device. +*/ +static int pod_try_init(struct usb_interface *interface, + struct usb_line6 *line6) +{ + int err; + struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; + + line6->process_message = line6_pod_process_message; + line6->disconnect = line6_pod_disconnect; + + init_timer(&pod->startup_timer); + INIT_WORK(&pod->startup_work, pod_startup4); + + if ((interface == NULL) || (pod == NULL)) + return -ENODEV; + + /* create sysfs entries: */ + err = pod_create_files2(&interface->dev); + if (err < 0) + return err; + + /* initialize audio system: */ + err = line6_init_audio(line6); + if (err < 0) + return err; + + /* initialize MIDI subsystem: */ + err = line6_init_midi(line6); + if (err < 0) + return err; + + /* initialize PCM subsystem: */ + err = line6_init_pcm(line6, &pod_pcm_properties); + if (err < 0) + return err; + + /* register monitor control: */ + err = snd_ctl_add(line6->card, + snd_ctl_new1(&pod_control_monitor, line6->line6pcm)); + if (err < 0) + return err; + + /* + When the sound card is registered at this point, the PODxt Live + displays "Invalid Code Error 07", so we do it later in the event + handler. + */ + + if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL) { + pod->monitor_level = POD_SYSTEM_INVALID; + + /* initiate startup procedure: */ + pod_startup1(pod); + } + + return 0; +} + +/* + Init POD device (and clean up in case of failure). +*/ +int line6_pod_init(struct usb_interface *interface, struct usb_line6 *line6) +{ + int err = pod_try_init(interface, line6); + + if (err < 0) + pod_destruct(interface); + + return err; +} diff --git a/sound/usb/line6/pod.h b/sound/usb/line6/pod.h new file mode 100644 index 000000000000..87a8f0fa9cba --- /dev/null +++ b/sound/usb/line6/pod.h @@ -0,0 +1,92 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef POD_H +#define POD_H + +#include +#include +#include + +#include + +#include "driver.h" + +/* + Locate name in binary program dump +*/ +#define POD_NAME_OFFSET 0 +#define POD_NAME_LENGTH 16 + +/* + Other constants +*/ +#define POD_CONTROL_SIZE 0x80 +#define POD_BUFSIZE_DUMPREQ 7 +#define POD_STARTUP_DELAY 1000 + +/* + Stages of POD startup procedure +*/ +enum { + POD_STARTUP_INIT = 1, + POD_STARTUP_VERSIONREQ, + POD_STARTUP_WORKQUEUE, + POD_STARTUP_SETUP, + POD_STARTUP_LAST = POD_STARTUP_SETUP - 1 +}; + +struct usb_line6_pod { + /** + Generic Line6 USB data. + */ + struct usb_line6 line6; + + /** + Instrument monitor level. + */ + int monitor_level; + + /** + Timer for device initializaton. + */ + struct timer_list startup_timer; + + /** + Work handler for device initializaton. + */ + struct work_struct startup_work; + + /** + Current progress in startup procedure. + */ + int startup_progress; + + /** + Serial number of device. + */ + int serial_number; + + /** + Firmware version (x 100). + */ + int firmware_version; + + /** + Device ID. + */ + int device_id; +}; + +extern int line6_pod_init(struct usb_interface *interface, + struct usb_line6 *line6); + +#endif diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c new file mode 100644 index 000000000000..27c5402cece8 --- /dev/null +++ b/sound/usb/line6/podhd.c @@ -0,0 +1,156 @@ +/* + * Line6 Pod HD + * + * Copyright (C) 2011 Stefan Hajnoczi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include + +#include "audio.h" +#include "driver.h" +#include "pcm.h" +#include "podhd.h" + +#define PODHD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */ + +static struct snd_ratden podhd_ratden = { + .num_min = 48000, + .num_max = 48000, + .num_step = 1, + .den = 1, +}; + +static struct line6_pcm_properties podhd_pcm_properties = { + .snd_line6_playback_hw = { + .info = (SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | +#ifdef CONFIG_PM + SNDRV_PCM_INFO_RESUME | +#endif + SNDRV_PCM_INFO_SYNC_START), + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = 60000, + .period_bytes_min = 64, + .period_bytes_max = 8192, + .periods_min = 1, + .periods_max = 1024}, + .snd_line6_capture_hw = { + .info = (SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | +#ifdef CONFIG_PM + SNDRV_PCM_INFO_RESUME | +#endif + SNDRV_PCM_INFO_SYNC_START), + .formats = SNDRV_PCM_FMTBIT_S24_3LE, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = 60000, + .period_bytes_min = 64, + .period_bytes_max = 8192, + .periods_min = 1, + .periods_max = 1024}, + .snd_line6_rates = { + .nrats = 1, + .rats = &podhd_ratden}, + .bytes_per_frame = PODHD_BYTES_PER_FRAME +}; + +/* + POD HD destructor. +*/ +static void podhd_destruct(struct usb_interface *interface) +{ + struct usb_line6_podhd *podhd = usb_get_intfdata(interface); + + if (podhd == NULL) + return; + line6_cleanup_audio(&podhd->line6); +} + +/* + POD HD device disconnected. +*/ +static void line6_podhd_disconnect(struct usb_interface *interface) +{ + struct usb_line6_podhd *podhd; + + if (interface == NULL) + return; + podhd = usb_get_intfdata(interface); + + if (podhd != NULL) { + struct snd_line6_pcm *line6pcm = podhd->line6.line6pcm; + + if (line6pcm != NULL) + line6_pcm_disconnect(line6pcm); + } + + podhd_destruct(interface); +} + +/* + Try to init POD HD device. +*/ +static int podhd_try_init(struct usb_interface *interface, + struct usb_line6_podhd *podhd) +{ + int err; + struct usb_line6 *line6 = &podhd->line6; + + if ((interface == NULL) || (podhd == NULL)) + return -ENODEV; + + line6->disconnect = line6_podhd_disconnect; + + /* initialize audio system: */ + err = line6_init_audio(line6); + if (err < 0) + return err; + + /* initialize MIDI subsystem: */ + err = line6_init_midi(line6); + if (err < 0) + return err; + + /* initialize PCM subsystem: */ + err = line6_init_pcm(line6, &podhd_pcm_properties); + if (err < 0) + return err; + + /* register USB audio system: */ + err = line6_register_audio(line6); + return err; +} + +/* + Init POD HD device (and clean up in case of failure). +*/ +int line6_podhd_init(struct usb_interface *interface, struct usb_line6 *line6) +{ + struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; + int err = podhd_try_init(interface, podhd); + + if (err < 0) + podhd_destruct(interface); + + return err; +} diff --git a/sound/usb/line6/podhd.h b/sound/usb/line6/podhd.h new file mode 100644 index 000000000000..a14f711f9725 --- /dev/null +++ b/sound/usb/line6/podhd.h @@ -0,0 +1,29 @@ +/* + * Line6 Pod HD + * + * Copyright (C) 2011 Stefan Hajnoczi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef PODHD_H +#define PODHD_H + +#include + +#include "driver.h" + +struct usb_line6_podhd { + /** + Generic Line6 USB data. + */ + struct usb_line6 line6; +}; + +extern int line6_podhd_init(struct usb_interface *interface, + struct usb_line6 *line6); + +#endif /* PODHD_H */ diff --git a/sound/usb/line6/revision.h b/sound/usb/line6/revision.h new file mode 100644 index 000000000000..b4eee2b73831 --- /dev/null +++ b/sound/usb/line6/revision.h @@ -0,0 +1,4 @@ +#ifndef DRIVER_REVISION +/* current subversion revision */ +#define DRIVER_REVISION " (904)" +#endif diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c new file mode 100644 index 000000000000..aae78d8a82d9 --- /dev/null +++ b/sound/usb/line6/toneport.c @@ -0,0 +1,465 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * Emil Myhrman (emil.myhrman@gmail.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include +#include + +#include "audio.h" +#include "capture.h" +#include "driver.h" +#include "playback.h" +#include "toneport.h" + +static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); + +#define TONEPORT_PCM_DELAY 1 + +static struct snd_ratden toneport_ratden = { + .num_min = 44100, + .num_max = 44100, + .num_step = 1, + .den = 1 +}; + +static struct line6_pcm_properties toneport_pcm_properties = { + .snd_line6_playback_hw = { + .info = (SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | +#ifdef CONFIG_PM + SNDRV_PCM_INFO_RESUME | +#endif + SNDRV_PCM_INFO_SYNC_START), + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rates = SNDRV_PCM_RATE_KNOT, + .rate_min = 44100, + .rate_max = 44100, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = 60000, + .period_bytes_min = 64, + .period_bytes_max = 8192, + .periods_min = 1, + .periods_max = 1024}, + .snd_line6_capture_hw = { + .info = (SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | +#ifdef CONFIG_PM + SNDRV_PCM_INFO_RESUME | +#endif + SNDRV_PCM_INFO_SYNC_START), + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rates = SNDRV_PCM_RATE_KNOT, + .rate_min = 44100, + .rate_max = 44100, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = 60000, + .period_bytes_min = 64, + .period_bytes_max = 8192, + .periods_min = 1, + .periods_max = 1024}, + .snd_line6_rates = { + .nrats = 1, + .rats = &toneport_ratden}, + .bytes_per_frame = 4 +}; + +/* + For the led on Guitarport. + Brightness goes from 0x00 to 0x26. Set a value above this to have led + blink. + (void cmd_0x02(byte red, byte green) +*/ +static int led_red = 0x00; +static int led_green = 0x26; + +static const struct { + const char *name; + int code; +} toneport_source_info[] = { + {"Microphone", 0x0a01}, + {"Line", 0x0801}, + {"Instrument", 0x0b01}, + {"Inst & Mic", 0x0901} +}; + +static bool toneport_has_led(enum line6_device_type type) +{ + return + (type == LINE6_GUITARPORT) || + (type == LINE6_TONEPORT_GX); + /* add your device here if you are missing support for the LEDs */ +} + +static void toneport_update_led(struct device *dev) +{ + struct usb_interface *interface = to_usb_interface(dev); + struct usb_line6_toneport *tp = usb_get_intfdata(interface); + struct usb_line6 *line6; + + if (!tp) + return; + + line6 = &tp->line6; + if (line6) + toneport_send_cmd(line6->usbdev, (led_red << 8) | 0x0002, + led_green); +} + +static ssize_t toneport_set_led_red(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int retval; + + retval = kstrtoint(buf, 10, &led_red); + if (retval) + return retval; + + toneport_update_led(dev); + return count; +} + +static ssize_t toneport_set_led_green(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int retval; + + retval = kstrtoint(buf, 10, &led_green); + if (retval) + return retval; + + toneport_update_led(dev); + return count; +} + +static DEVICE_ATTR(led_red, S_IWUSR | S_IRUGO, line6_nop_read, + toneport_set_led_red); +static DEVICE_ATTR(led_green, S_IWUSR | S_IRUGO, line6_nop_read, + toneport_set_led_green); + +static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) +{ + int ret; + + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ); + + if (ret < 0) { + dev_err(&usbdev->dev, "send failed (error %d)\n", ret); + return ret; + } + + return 0; +} + +/* monitor info callback */ +static int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 256; + return 0; +} + +/* monitor get callback */ +static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + + ucontrol->value.integer.value[0] = line6pcm->volume_monitor; + return 0; +} + +/* monitor put callback */ +static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + + if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor) + return 0; + + line6pcm->volume_monitor = ucontrol->value.integer.value[0]; + + if (line6pcm->volume_monitor > 0) + line6_pcm_acquire(line6pcm, LINE6_BITS_PCM_MONITOR); + else + line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR); + + return 1; +} + +/* source info callback */ +static int snd_toneport_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + const int size = ARRAY_SIZE(toneport_source_info); + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = size; + + if (uinfo->value.enumerated.item >= size) + uinfo->value.enumerated.item = size - 1; + + strcpy(uinfo->value.enumerated.name, + toneport_source_info[uinfo->value.enumerated.item].name); + + return 0; +} + +/* source get callback */ +static int snd_toneport_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + struct usb_line6_toneport *toneport = + (struct usb_line6_toneport *)line6pcm->line6; + ucontrol->value.enumerated.item[0] = toneport->source; + return 0; +} + +/* source put callback */ +static int snd_toneport_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + struct usb_line6_toneport *toneport = + (struct usb_line6_toneport *)line6pcm->line6; + unsigned int source; + + source = ucontrol->value.enumerated.item[0]; + if (source >= ARRAY_SIZE(toneport_source_info)) + return -EINVAL; + if (source == toneport->source) + return 0; + + toneport->source = source; + toneport_send_cmd(toneport->line6.usbdev, + toneport_source_info[source].code, 0x0000); + return 1; +} + +static void toneport_start_pcm(unsigned long arg) +{ + struct usb_line6_toneport *toneport = (struct usb_line6_toneport *)arg; + struct usb_line6 *line6 = &toneport->line6; + + line6_pcm_acquire(line6->line6pcm, LINE6_BITS_PCM_MONITOR); +} + +/* control definition */ +static struct snd_kcontrol_new toneport_control_monitor = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Monitor Playback Volume", + .index = 0, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, + .info = snd_toneport_monitor_info, + .get = snd_toneport_monitor_get, + .put = snd_toneport_monitor_put +}; + +/* source selector definition */ +static struct snd_kcontrol_new toneport_control_source = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "PCM Capture Source", + .index = 0, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, + .info = snd_toneport_source_info, + .get = snd_toneport_source_get, + .put = snd_toneport_source_put +}; + +/* + Toneport destructor. +*/ +static void toneport_destruct(struct usb_interface *interface) +{ + struct usb_line6_toneport *toneport = usb_get_intfdata(interface); + + if (toneport == NULL) + return; + line6_cleanup_audio(&toneport->line6); +} + +/* + Setup Toneport device. +*/ +static void toneport_setup(struct usb_line6_toneport *toneport) +{ + int ticks; + struct usb_line6 *line6 = &toneport->line6; + struct usb_device *usbdev = line6->usbdev; + + /* sync time on device with host: */ + ticks = (int)get_seconds(); + line6_write_data(line6, 0x80c6, &ticks, 4); + + /* enable device: */ + toneport_send_cmd(usbdev, 0x0301, 0x0000); + + /* initialize source select: */ + switch (line6->type) { + case LINE6_TONEPORT_UX1: + case LINE6_TONEPORT_UX2: + case LINE6_PODSTUDIO_UX1: + case LINE6_PODSTUDIO_UX2: + toneport_send_cmd(usbdev, + toneport_source_info[toneport->source].code, + 0x0000); + default: + break; + } + + if (toneport_has_led(line6->type)) + toneport_update_led(&usbdev->dev); +} + +/* + Toneport device disconnected. +*/ +static void line6_toneport_disconnect(struct usb_interface *interface) +{ + struct usb_line6_toneport *toneport; + u16 idProduct; + + if (interface == NULL) + return; + + toneport = usb_get_intfdata(interface); + del_timer_sync(&toneport->timer); + idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct); + + if (toneport_has_led(idProduct)) { + device_remove_file(&interface->dev, &dev_attr_led_red); + device_remove_file(&interface->dev, &dev_attr_led_green); + } + + if (toneport != NULL) { + struct snd_line6_pcm *line6pcm = toneport->line6.line6pcm; + + if (line6pcm != NULL) { + line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR); + line6_pcm_disconnect(line6pcm); + } + } + + toneport_destruct(interface); +} + + +/* + Try to init Toneport device. +*/ +static int toneport_try_init(struct usb_interface *interface, + struct usb_line6 *line6) +{ + int err; + struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; + + if ((interface == NULL) || (toneport == NULL)) + return -ENODEV; + + line6->disconnect = line6_toneport_disconnect; + + /* initialize audio system: */ + err = line6_init_audio(line6); + if (err < 0) + return err; + + /* initialize PCM subsystem: */ + err = line6_init_pcm(line6, &toneport_pcm_properties); + if (err < 0) + return err; + + /* register monitor control: */ + err = snd_ctl_add(line6->card, + snd_ctl_new1(&toneport_control_monitor, + line6->line6pcm)); + if (err < 0) + return err; + + /* register source select control: */ + switch (line6->type) { + case LINE6_TONEPORT_UX1: + case LINE6_TONEPORT_UX2: + case LINE6_PODSTUDIO_UX1: + case LINE6_PODSTUDIO_UX2: + err = + snd_ctl_add(line6->card, + snd_ctl_new1(&toneport_control_source, + line6->line6pcm)); + if (err < 0) + return err; + + default: + break; + } + + /* register audio system: */ + err = line6_register_audio(line6); + if (err < 0) + return err; + + line6_read_serial_number(line6, &toneport->serial_number); + line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); + + if (toneport_has_led(line6->type)) { + CHECK_RETURN(device_create_file + (&interface->dev, &dev_attr_led_red)); + CHECK_RETURN(device_create_file + (&interface->dev, &dev_attr_led_green)); + } + + toneport_setup(toneport); + + init_timer(&toneport->timer); + toneport->timer.expires = jiffies + TONEPORT_PCM_DELAY * HZ; + toneport->timer.function = toneport_start_pcm; + toneport->timer.data = (unsigned long)toneport; + add_timer(&toneport->timer); + + return 0; +} + +/* + Init Toneport device (and clean up in case of failure). +*/ +int line6_toneport_init(struct usb_interface *interface, + struct usb_line6 *line6) +{ + int err = toneport_try_init(interface, line6); + + if (err < 0) + toneport_destruct(interface); + + return err; +} + +/* + Resume Toneport device after reset. +*/ +void line6_toneport_reset_resume(struct usb_line6_toneport *toneport) +{ + toneport_setup(toneport); +} diff --git a/sound/usb/line6/toneport.h b/sound/usb/line6/toneport.h new file mode 100644 index 000000000000..8cb14426f6ae --- /dev/null +++ b/sound/usb/line6/toneport.h @@ -0,0 +1,51 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef TONEPORT_H +#define TONEPORT_H + +#include +#include + +#include "driver.h" + +struct usb_line6_toneport { + /** + Generic Line6 USB data. + */ + struct usb_line6 line6; + + /** + Source selector. + */ + int source; + + /** + Serial number of device. + */ + int serial_number; + + /** + Firmware version (x 100). + */ + int firmware_version; + + /** + Timer for delayed PCM startup. + */ + struct timer_list timer; +}; + +extern int line6_toneport_init(struct usb_interface *interface, + struct usb_line6 *line6); +extern void line6_toneport_reset_resume(struct usb_line6_toneport *toneport); + +#endif diff --git a/sound/usb/line6/usbdefs.h b/sound/usb/line6/usbdefs.h new file mode 100644 index 000000000000..f4d080e69abc --- /dev/null +++ b/sound/usb/line6/usbdefs.h @@ -0,0 +1,27 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2005-2008 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef USBDEFS_H +#define USBDEFS_H + +#define USB_INTERVALS_PER_SECOND 1000 + +/* device supports settings parameter via USB */ +#define LINE6_CAP_CONTROL (1 << 0) +/* device supports PCM input/output via USB */ +#define LINE6_CAP_PCM (1 << 1) +/* device support hardware monitoring */ +#define LINE6_CAP_HWMON (1 << 2) + +#define LINE6_FALLBACK_INTERVAL 10 +#define LINE6_FALLBACK_MAXPACKETSIZE 16 + +#endif diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c new file mode 100644 index 000000000000..b4a41b0ad0ea --- /dev/null +++ b/sound/usb/line6/variax.c @@ -0,0 +1,239 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#include + +#include "audio.h" +#include "driver.h" +#include "variax.h" + +#define VARIAX_OFFSET_ACTIVATE 7 + +/* + This message is sent by the device during initialization and identifies + the connected guitar version. +*/ +static const char variax_init_version[] = { + 0xf0, 0x7e, 0x7f, 0x06, 0x02, 0x00, 0x01, 0x0c, + 0x07, 0x00, 0x00, 0x00 +}; + +/* + This message is the last one sent by the device during initialization. +*/ +static const char variax_init_done[] = { + 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x6b +}; + +static const char variax_activate[] = { + 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x2a, 0x01, + 0xf7 +}; + +/* forward declarations: */ +static void variax_startup2(unsigned long data); +static void variax_startup4(unsigned long data); +static void variax_startup5(unsigned long data); + +static void variax_activate_async(struct usb_line6_variax *variax, int a) +{ + variax->buffer_activate[VARIAX_OFFSET_ACTIVATE] = a; + line6_send_raw_message_async(&variax->line6, variax->buffer_activate, + sizeof(variax_activate)); +} + +/* + Variax startup procedure. + This is a sequence of functions with special requirements (e.g., must + not run immediately after initialization, must not run in interrupt + context). After the last one has finished, the device is ready to use. +*/ + +static void variax_startup1(struct usb_line6_variax *variax) +{ + CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_INIT); + + /* delay startup procedure: */ + line6_start_timer(&variax->startup_timer1, VARIAX_STARTUP_DELAY1, + variax_startup2, (unsigned long)variax); +} + +static void variax_startup2(unsigned long data) +{ + struct usb_line6_variax *variax = (struct usb_line6_variax *)data; + struct usb_line6 *line6 = &variax->line6; + + /* schedule another startup procedure until startup is complete: */ + if (variax->startup_progress >= VARIAX_STARTUP_LAST) + return; + + variax->startup_progress = VARIAX_STARTUP_VERSIONREQ; + line6_start_timer(&variax->startup_timer1, VARIAX_STARTUP_DELAY1, + variax_startup2, (unsigned long)variax); + + /* request firmware version: */ + line6_version_request_async(line6); +} + +static void variax_startup3(struct usb_line6_variax *variax) +{ + CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_WAIT); + + /* delay startup procedure: */ + line6_start_timer(&variax->startup_timer2, VARIAX_STARTUP_DELAY3, + variax_startup4, (unsigned long)variax); +} + +static void variax_startup4(unsigned long data) +{ + struct usb_line6_variax *variax = (struct usb_line6_variax *)data; + + CHECK_STARTUP_PROGRESS(variax->startup_progress, + VARIAX_STARTUP_ACTIVATE); + + /* activate device: */ + variax_activate_async(variax, 1); + line6_start_timer(&variax->startup_timer2, VARIAX_STARTUP_DELAY4, + variax_startup5, (unsigned long)variax); +} + +static void variax_startup5(unsigned long data) +{ + struct usb_line6_variax *variax = (struct usb_line6_variax *)data; + + CHECK_STARTUP_PROGRESS(variax->startup_progress, + VARIAX_STARTUP_WORKQUEUE); + + /* schedule work for global work queue: */ + schedule_work(&variax->startup_work); +} + +static void variax_startup6(struct work_struct *work) +{ + struct usb_line6_variax *variax = + container_of(work, struct usb_line6_variax, startup_work); + + CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_SETUP); + + /* ALSA audio interface: */ + line6_register_audio(&variax->line6); +} + +/* + Process a completely received message. +*/ +static void line6_variax_process_message(struct usb_line6 *line6) +{ + struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; + const unsigned char *buf = variax->line6.buffer_message; + + switch (buf[0]) { + case LINE6_RESET: + dev_info(variax->line6.ifcdev, "VARIAX reset\n"); + break; + + case LINE6_SYSEX_BEGIN: + if (memcmp(buf + 1, variax_init_version + 1, + sizeof(variax_init_version) - 1) == 0) { + variax_startup3(variax); + } else if (memcmp(buf + 1, variax_init_done + 1, + sizeof(variax_init_done) - 1) == 0) { + /* notify of complete initialization: */ + variax_startup4((unsigned long)variax); + } + break; + } +} + +/* + Variax destructor. +*/ +static void variax_destruct(struct usb_interface *interface) +{ + struct usb_line6_variax *variax = usb_get_intfdata(interface); + + if (variax == NULL) + return; + line6_cleanup_audio(&variax->line6); + + del_timer(&variax->startup_timer1); + del_timer(&variax->startup_timer2); + cancel_work_sync(&variax->startup_work); + + kfree(variax->buffer_activate); +} + +/* + Workbench device disconnected. +*/ +static void line6_variax_disconnect(struct usb_interface *interface) +{ + if (interface == NULL) + return; + + variax_destruct(interface); +} + +/* + Try to init workbench device. +*/ +static int variax_try_init(struct usb_interface *interface, + struct usb_line6 *line6) +{ + struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; + int err; + + line6->process_message = line6_variax_process_message; + line6->disconnect = line6_variax_disconnect; + + init_timer(&variax->startup_timer1); + init_timer(&variax->startup_timer2); + INIT_WORK(&variax->startup_work, variax_startup6); + + if ((interface == NULL) || (variax == NULL)) + return -ENODEV; + + /* initialize USB buffers: */ + variax->buffer_activate = kmemdup(variax_activate, + sizeof(variax_activate), GFP_KERNEL); + + if (variax->buffer_activate == NULL) { + dev_err(&interface->dev, "Out of memory\n"); + return -ENOMEM; + } + + /* initialize audio system: */ + err = line6_init_audio(&variax->line6); + if (err < 0) + return err; + + /* initialize MIDI subsystem: */ + err = line6_init_midi(&variax->line6); + if (err < 0) + return err; + + /* initiate startup procedure: */ + variax_startup1(variax); + return 0; +} + +/* + Init workbench device (and clean up in case of failure). +*/ +int line6_variax_init(struct usb_interface *interface, struct usb_line6 *line6) +{ + int err = variax_try_init(interface, line6); + + if (err < 0) + variax_destruct(interface); + + return err; +} diff --git a/sound/usb/line6/variax.h b/sound/usb/line6/variax.h new file mode 100644 index 000000000000..dfb94e574cc4 --- /dev/null +++ b/sound/usb/line6/variax.h @@ -0,0 +1,70 @@ +/* + * Line6 Linux USB driver - 0.9.1beta + * + * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + * + */ + +#ifndef VARIAX_H +#define VARIAX_H + +#include +#include +#include +#include + +#include "driver.h" + +#define VARIAX_STARTUP_DELAY1 1000 +#define VARIAX_STARTUP_DELAY3 100 +#define VARIAX_STARTUP_DELAY4 100 + +/* + Stages of Variax startup procedure +*/ +enum { + VARIAX_STARTUP_INIT = 1, + VARIAX_STARTUP_VERSIONREQ, + VARIAX_STARTUP_WAIT, + VARIAX_STARTUP_ACTIVATE, + VARIAX_STARTUP_WORKQUEUE, + VARIAX_STARTUP_SETUP, + VARIAX_STARTUP_LAST = VARIAX_STARTUP_SETUP - 1 +}; + +struct usb_line6_variax { + /** + Generic Line6 USB data. + */ + struct usb_line6 line6; + + /** + Buffer for activation code. + */ + unsigned char *buffer_activate; + + /** + Handler for device initializaton. + */ + struct work_struct startup_work; + + /** + Timers for device initializaton. + */ + struct timer_list startup_timer1; + struct timer_list startup_timer2; + + /** + Current progress in startup procedure. + */ + int startup_progress; +}; + +extern int line6_variax_init(struct usb_interface *interface, + struct usb_line6 *line6); + +#endif -- cgit From 9e446ad500db0fd0823990409da17fde9e9cffdc Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 14 Jan 2015 10:48:59 -0200 Subject: ASoC: fsl_ssi: Change irq type to 'int' Since commit 2ffa531078037a0 ("ASoC: fsl_ssi: Fix module unbound") the irq number is retrieved via platform_get_irq(), which may fail and return a negative number, so adapt its type to 'int'. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index a65f17d57ffb..4a48da5673ce 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -160,7 +160,7 @@ struct fsl_ssi_soc_data { */ struct fsl_ssi_private { struct regmap *regs; - unsigned int irq; + int irq; struct snd_soc_dai_driver cpu_dai_drv; unsigned int dai_fmt; -- cgit From e4b7e6a89955a27ccd608fce895b1b645c08deec Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Tue, 13 Jan 2015 11:13:14 +0800 Subject: ASoC: rt5677: Use the regmap functions instead of the snd_soc functions The patch uses the regmap functions instead of the snd_soc functions in some cases. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 3b32c3ecbe05..f6affba734c3 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -924,6 +924,8 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = source->codec; + struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); unsigned int reg, shift, val; if (source->reg == RT5677_ASRC_1) { @@ -990,7 +992,9 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, } } - val = (snd_soc_read(source->codec, reg) >> shift) & 0xf; + regmap_read(rt5677->regmap, reg, &val); + val = (val >> shift) & 0xf; + switch (val) { case 1 ... 6: return 1; @@ -4087,6 +4091,7 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { struct snd_soc_codec *codec = dai->codec; + struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); unsigned int val = 0; if (rx_mask || tx_mask) @@ -4124,10 +4129,12 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, switch (dai->id) { case RT5677_AIF1: - snd_soc_update_bits(codec, RT5677_TDM1_CTRL1, 0x1f00, val); + regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00, + val); break; case RT5677_AIF2: - snd_soc_update_bits(codec, RT5677_TDM2_CTRL1, 0x1f00, val); + regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00, + val); break; default: break; -- cgit From 9913b9f549330e9b72945ec94cb9c7fe57d78cce Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Tue, 13 Jan 2015 11:13:15 +0800 Subject: ASoC: rt5677: Add the slot_width "25" support in the TDM mode Add the slot_width "25" support in the TDM mode for the Intel platform. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index f6affba734c3..88de759fb7fc 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4092,7 +4092,7 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, { struct snd_soc_codec *codec = dai->codec; struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); - unsigned int val = 0; + unsigned int val = 0, slot_width_25 = 0; if (rx_mask || tx_mask) val |= (1 << 12); @@ -4116,6 +4116,8 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, case 20: val |= (1 << 8); break; + case 25: + slot_width_25 = 0x8080; case 24: val |= (2 << 8); break; @@ -4131,10 +4133,14 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, case RT5677_AIF1: regmap_update_bits(rt5677->regmap, RT5677_TDM1_CTRL1, 0x1f00, val); + regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x8000, + slot_width_25); break; case RT5677_AIF2: regmap_update_bits(rt5677->regmap, RT5677_TDM2_CTRL1, 0x1f00, val); + regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x80, + slot_width_25); break; default: break; -- cgit From 7a3a907022439524704caecb717639aea2f1ef9c Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 14 Jan 2015 16:39:15 -0200 Subject: ASoC: fsl: imx-spdif: Set the card owner field Set the card owner field to avoid getting a kernel crash when the imx-spdif is unloaded while the playback is active. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/fsl/imx-spdif.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/fsl/imx-spdif.c b/sound/soc/fsl/imx-spdif.c index e94704f1b9ee..33da26a12457 100644 --- a/sound/soc/fsl/imx-spdif.c +++ b/sound/soc/fsl/imx-spdif.c @@ -60,6 +60,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev) data->card.dev = &pdev->dev; data->card.dai_link = &data->dai; data->card.num_links = 1; + data->card.owner = THIS_MODULE; ret = snd_soc_of_parse_card_name(&data->card, "model"); if (ret) -- cgit From d869769663a19d79ddad24ff906576fc2cf0fbb4 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Tue, 13 Jan 2015 13:27:26 +0100 Subject: Asoc: sam9x5_wm8731: depend on ARCH_AT91 instead of SOC_AT91SAM9X5 The SOC_AT91SAM9X5 option is going to be removed, only depend on ARCH_AT91 like for the other drivers. Signed-off-by: Alexandre Belloni Acked-by: Nicolas Ferre Acked-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/atmel/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index fb3878312bf8..1579e994acf8 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -45,7 +45,7 @@ config SND_ATMEL_SOC_WM8904 config SND_AT91_SOC_SAM9X5_WM8731 tristate "SoC Audio support for WM8731-based at91sam9x5 board" - depends on ATMEL_SSC && SND_ATMEL_SOC && SOC_AT91SAM9X5 + depends on ARCH_AT91 && ATMEL_SSC && SND_ATMEL_SOC select SND_ATMEL_SOC_SSC select SND_ATMEL_SOC_DMA select SND_SOC_WM8731 -- cgit From bec78c5f4ae228c4cbd432e97cadb8827fd8f1f9 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 12 Jan 2015 10:27:17 +0100 Subject: ASoC: mc13783: Update set_tdm_slot() semantics The mc13783 driver uses inverted semantics for the tx_mask and rx_mask parameter of the set_tdm_slot() callback compared to rest of ASoC. This patch updates the driver's semantics to be consistent with the rest of ASoC, i.e. a set bit means a active slot and a cleared bit means a inactive slot. This will allow us to use the set_tdm_slot() API in a more generic way. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/mc13783.c | 10 +++++----- sound/soc/fsl/imx-mc13783.c | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index c1e441c2c8af..2ffb9a0570dc 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -328,16 +328,16 @@ static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai, } switch (rx_mask) { - case 0xfffffffc: + case 0x03: val |= SSI_NETWORK_DAC_RXSLOT_0_1; break; - case 0xfffffff3: + case 0x0c: val |= SSI_NETWORK_DAC_RXSLOT_2_3; break; - case 0xffffffcf: + case 0x30: val |= SSI_NETWORK_DAC_RXSLOT_4_5; break; - case 0xffffff3f: + case 0xc0: val |= SSI_NETWORK_DAC_RXSLOT_6_7; break; default: @@ -360,7 +360,7 @@ static int mc13783_set_tdm_slot_codec(struct snd_soc_dai *dai, if (slots != 4) return -EINVAL; - if (tx_mask != 0xfffffffc) + if (tx_mask != 0x3) return -EINVAL; val |= (0x00 << 2); /* primary timeslot RX/TX(?) is 0 */ diff --git a/sound/soc/fsl/imx-mc13783.c b/sound/soc/fsl/imx-mc13783.c index 6bf5bce01a92..9589452e995e 100644 --- a/sound/soc/fsl/imx-mc13783.c +++ b/sound/soc/fsl/imx-mc13783.c @@ -37,8 +37,7 @@ static int imx_mc13783_hifi_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; int ret; - ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xfffffffc, 0xfffffffc, - 4, 16); + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 4, 16); if (ret) return ret; -- cgit From d0077aaf2206f3c3524d71a9f38b408dca63852f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 12 Jan 2015 10:27:18 +0100 Subject: ASoC: fsl: Update set_tdm_slot() semantics The fsl-ssi and imx-ssi drivers use inverted semantics for the tx_mask and rx_mask parameter of the set_tdm_slot() callback compared to rest of ASoC. This patch updates the driver's semantics to be consistent with the rest of ASoC, i.e. a set bit means a active slot and a cleared bit means a inactive slot. This will allow us to use the set_tdm_slot() API in a more generic way. Signed-off-by: Lars-Peter Clausen Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/eukrea-tlv320.c | 2 +- sound/soc/fsl/fsl_ssi.c | 4 ++-- sound/soc/fsl/fsl_utils.c | 6 +++--- sound/soc/fsl/imx-mc13783.c | 2 +- sound/soc/fsl/imx-ssi.c | 4 ++-- sound/soc/fsl/wm1133-ev1.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c index 9ce70fc67b09..0d0203b34d8b 100644 --- a/sound/soc/fsl/eukrea-tlv320.c +++ b/sound/soc/fsl/eukrea-tlv320.c @@ -69,7 +69,7 @@ static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream, return ret; } - snd_soc_dai_set_tdm_slot(cpu_dai, 0xffffffc, 0xffffffc, 2, 0); + snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 0x3, 2, 0); ret = snd_soc_dai_set_sysclk(cpu_dai, IMX_SSP_SYS_CLK, 0, SND_SOC_CLOCK_IN); diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index a65f17d57ffb..8841e59a9869 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -992,8 +992,8 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, CCSR_SSI_SCR_SSIEN); - regmap_write(regs, CCSR_SSI_STMSK, tx_mask); - regmap_write(regs, CCSR_SSI_SRMSK, rx_mask); + regmap_write(regs, CCSR_SSI_STMSK, ~tx_mask); + regmap_write(regs, CCSR_SSI_SRMSK, ~rx_mask); regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, val); diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c index 2ac7755da876..5fd4463dbf05 100644 --- a/sound/soc/fsl/fsl_utils.c +++ b/sound/soc/fsl/fsl_utils.c @@ -94,7 +94,7 @@ EXPORT_SYMBOL(fsl_asoc_get_dma_channel); * @rx_mask: bitmask representing active RX slots. * * This function used to generate the TDM slot TX/RX mask. And the TX/RX - * mask will use a 0 bit for an active slot as default, and the default + * mask will use a 1 bit for an active slot as default, and the default * active bits are at the LSB of the mask value. */ int fsl_asoc_xlate_tdm_slot_mask(unsigned int slots, @@ -105,9 +105,9 @@ int fsl_asoc_xlate_tdm_slot_mask(unsigned int slots, return -EINVAL; if (tx_mask) - *tx_mask = ~((1 << slots) - 1); + *tx_mask = ((1 << slots) - 1); if (rx_mask) - *rx_mask = ~((1 << slots) - 1); + *rx_mask = ((1 << slots) - 1); return 0; } diff --git a/sound/soc/fsl/imx-mc13783.c b/sound/soc/fsl/imx-mc13783.c index 9589452e995e..9e6493d4e7ff 100644 --- a/sound/soc/fsl/imx-mc13783.c +++ b/sound/soc/fsl/imx-mc13783.c @@ -45,7 +45,7 @@ static int imx_mc13783_hifi_hw_params(struct snd_pcm_substream *substream, if (ret) return ret; - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x0, 0xfffffffc, 2, 16); + ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 0x3, 2, 16); if (ret) return ret; diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index fa801e17c51e..6aeaac33871a 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -74,8 +74,8 @@ static int imx_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, sccr |= SSI_STCCR_DC(slots - 1); writel(sccr, ssi->base + SSI_SRCCR); - writel(tx_mask, ssi->base + SSI_STMSK); - writel(rx_mask, ssi->base + SSI_SRMSK); + writel(~tx_mask, ssi->base + SSI_STMSK); + writel(~rx_mask, ssi->base + SSI_SRMSK); return 0; } diff --git a/sound/soc/fsl/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c index 804749a6c61e..ca7b774b13ee 100644 --- a/sound/soc/fsl/wm1133-ev1.c +++ b/sound/soc/fsl/wm1133-ev1.c @@ -116,10 +116,10 @@ static int wm1133_ev1_hw_params(struct snd_pcm_substream *substream, /* TODO: The SSI driver should figure this out for us */ switch (channels) { case 2: - snd_soc_dai_set_tdm_slot(cpu_dai, 0xffffffc, 0xffffffc, 2, 0); + snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 0x3, 2, 0); break; case 1: - snd_soc_dai_set_tdm_slot(cpu_dai, 0xffffffe, 0xffffffe, 1, 0); + snd_soc_dai_set_tdm_slot(cpu_dai, 0x1, 0x1, 1, 0); break; default: return -EINVAL; -- cgit From bbcdb69dfcbd8842ee2a54265abd3e53cb3089e2 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 12 Jan 2015 10:27:19 +0100 Subject: ASoC: fsl: Remove fsl_asoc_xlate_tdm_slot_mask() Now that the fsl DAI drivers uses the same semantics as the rest of a ASoC the custom fsl_asoc_xlate_tdm_slot_mask() callback can be removed as it is identical to the generic one. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_utils.c | 27 --------------------------- sound/soc/fsl/fsl_utils.h | 3 --- sound/soc/fsl/imx-ssi.c | 1 - 3 files changed, 31 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c index 5fd4463dbf05..b9e42b503a37 100644 --- a/sound/soc/fsl/fsl_utils.c +++ b/sound/soc/fsl/fsl_utils.c @@ -86,33 +86,6 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np, } EXPORT_SYMBOL(fsl_asoc_get_dma_channel); -/** - * fsl_asoc_xlate_tdm_slot_mask - generate TDM slot TX/RX mask. - * - * @slots: Number of slots in use. - * @tx_mask: bitmask representing active TX slots. - * @rx_mask: bitmask representing active RX slots. - * - * This function used to generate the TDM slot TX/RX mask. And the TX/RX - * mask will use a 1 bit for an active slot as default, and the default - * active bits are at the LSB of the mask value. - */ -int fsl_asoc_xlate_tdm_slot_mask(unsigned int slots, - unsigned int *tx_mask, - unsigned int *rx_mask) -{ - if (!slots) - return -EINVAL; - - if (tx_mask) - *tx_mask = ((1 << slots) - 1); - if (rx_mask) - *rx_mask = ((1 << slots) - 1); - - return 0; -} -EXPORT_SYMBOL_GPL(fsl_asoc_xlate_tdm_slot_mask); - MODULE_AUTHOR("Timur Tabi "); MODULE_DESCRIPTION("Freescale ASoC utility code"); MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/fsl/fsl_utils.h b/sound/soc/fsl/fsl_utils.h index df535db40313..1687b66ef18e 100644 --- a/sound/soc/fsl/fsl_utils.h +++ b/sound/soc/fsl/fsl_utils.h @@ -22,7 +22,4 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np, const char *name, struct snd_soc_dai_link *dai, unsigned int *dma_channel_id, unsigned int *dma_id); -int fsl_asoc_xlate_tdm_slot_mask(unsigned int slots, - unsigned int *tx_mask, - unsigned int *rx_mask); #endif /* _FSL_UTILS_H */ diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index 6aeaac33871a..461ce27b884f 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -340,7 +340,6 @@ static const struct snd_soc_dai_ops imx_ssi_pcm_dai_ops = { .set_fmt = imx_ssi_set_dai_fmt, .set_clkdiv = imx_ssi_set_dai_clkdiv, .set_sysclk = imx_ssi_set_dai_sysclk, - .xlate_tdm_slot_mask = fsl_asoc_xlate_tdm_slot_mask, .set_tdm_slot = imx_ssi_set_dai_tdm_slot, .trigger = imx_ssi_trigger, }; -- cgit From e46c93669349072f5caca853f5618cfa01b86008 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 12 Jan 2015 10:27:20 +0100 Subject: ASoC: Update snd_soc_dai_set_tdm_slot() documentation There have been some conflicting interpretations of how snd_soc_dai_set_tdm_slot() is supposed to work. This patch updates the documentation to be more specific on the exact semantics to avoid such problems in the future. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 985052b3fbed..64e047dc7cdf 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2119,15 +2119,27 @@ static int snd_soc_xlate_tdm_slot_mask(unsigned int slots, } /** - * snd_soc_dai_set_tdm_slot - configure DAI TDM. - * @dai: DAI + * snd_soc_dai_set_tdm_slot() - Configures a DAI for TDM operation + * @dai: The DAI to configure * @tx_mask: bitmask representing active TX slots. * @rx_mask: bitmask representing active RX slots. * @slots: Number of slots in use. * @slot_width: Width in bits for each slot. * - * Configures a DAI for TDM operation. Both mask and slots are codec and DAI - * specific. + * This function configures the specified DAI for TDM operation. @slot contains + * the total number of slots of the TDM stream and @slot_with the width of each + * slot in bit clock cycles. @tx_mask and @rx_mask are bitmasks specifying the + * active slots of the TDM stream for the specified DAI, i.e. which slots the + * DAI should write to or read from. If a bit is set the corresponding slot is + * active, if a bit is cleared the corresponding slot is inactive. Bit 0 maps to + * the first slot, bit 1 to the second slot and so on. The first active slot + * maps to the first channel of the DAI, the second active slot to the second + * channel and so on. + * + * TDM mode can be disabled by passing 0 for @slots. In this case @tx_mask, + * @rx_mask and @slot_width will be ignored. + * + * Returns 0 on success, a negative error code otherwise. */ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) -- cgit From 75aa88684d73ed00a38bfa14b9edfac18b2acae8 Mon Sep 17 00:00:00 2001 From: Zidan Wang Date: Wed, 7 Jan 2015 15:31:44 +0800 Subject: ASoC: wm8960: Let wm8960 codec driver manage its own MCLK When we want to use wm8960 codec, we should enable its MCLK in machine driver. It's reasonable for wm8960 codec driver to manage its own MCLK. When current bias_level is SND_SOC_BIAS_ON, it is preparing for a transition away from ON. In this case, disable the codec mclk. When current bias_level is not SND_SOC_BIAS_ON, it preparing for a transition to ON. In this case, enable the codec mclk. Signed-off-by: Zidan Wang Signed-off-by: Mark Brown --- sound/soc/codecs/wm8960.c | 51 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 031a1ae71d94..f63cadf45215 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -117,6 +118,7 @@ static bool wm8960_volatile(struct device *dev, unsigned int reg) } struct wm8960_priv { + struct clk *mclk; struct regmap *regmap; int (*set_bias_level)(struct snd_soc_codec *, enum snd_soc_bias_level level); @@ -618,14 +620,38 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + int ret; switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - /* Set VMID to 2x50k */ - snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80); + switch (codec->dapm.bias_level) { + case SND_SOC_BIAS_STANDBY: + if (!IS_ERR(wm8960->mclk)) { + ret = clk_prepare_enable(wm8960->mclk); + if (ret) { + dev_err(codec->dev, + "Failed to enable MCLK: %d\n", + ret); + return ret; + } + } + + /* Set VMID to 2x50k */ + snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80); + break; + + case SND_SOC_BIAS_ON: + if (!IS_ERR(wm8960->mclk)) + clk_disable_unprepare(wm8960->mclk); + break; + + default: + break; + } + break; case SND_SOC_BIAS_STANDBY: @@ -674,7 +700,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); - int reg; + int reg, ret; switch (level) { case SND_SOC_BIAS_ON: @@ -715,9 +741,22 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, WM8960_VREF, WM8960_VREF); msleep(100); + + if (!IS_ERR(wm8960->mclk)) { + ret = clk_prepare_enable(wm8960->mclk); + if (ret) { + dev_err(codec->dev, + "Failed to enable MCLK: %d\n", + ret); + return ret; + } + } break; case SND_SOC_BIAS_ON: + if (!IS_ERR(wm8960->mclk)) + clk_disable_unprepare(wm8960->mclk); + /* Enable anti-pop mode */ snd_soc_update_bits(codec, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | @@ -1002,6 +1041,12 @@ static int wm8960_i2c_probe(struct i2c_client *i2c, if (wm8960 == NULL) return -ENOMEM; + wm8960->mclk = devm_clk_get(&i2c->dev, "mclk"); + if (IS_ERR(wm8960->mclk)) { + if (PTR_ERR(wm8960->mclk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + } + wm8960->regmap = devm_regmap_init_i2c(i2c, &wm8960_regmap); if (IS_ERR(wm8960->regmap)) return PTR_ERR(wm8960->regmap); -- cgit From 9cf247473167df29a3d99464385b4afe1fc16f2f Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:28 +0100 Subject: ASoC: samsung: i2s: samsung_i2s_get_driver_data() cleanup Tidy up the samsung_i2s_get_driver_data() function by using IS_ENABLE() instead of #ifdef and add missing braces for the 'else' part. Also ensure we are not dereferencing NULL 'match' pointer. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 86491c9f121f..e5473ee799d7 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1123,15 +1123,14 @@ static const struct of_device_id exynos_i2s_match[]; static inline const struct samsung_i2s_dai_data *samsung_i2s_get_driver_data( struct platform_device *pdev) { -#ifdef CONFIG_OF - if (pdev->dev.of_node) { + if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) { const struct of_device_id *match; match = of_match_node(exynos_i2s_match, pdev->dev.of_node); - return match->data; - } else -#endif + return match ? match->data : NULL; + } else { return (struct samsung_i2s_dai_data *) platform_get_device_id(pdev)->driver_data; + } } #ifdef CONFIG_PM -- cgit From 53f7faa17e9489f8b7be67dd9e87167f1779ef28 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:29 +0100 Subject: ASoC: samsung: i2s: Add return value checks in probe() These functions may fail so let's properly report any errors. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index e5473ee799d7..aa52b41f1749 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1173,11 +1173,13 @@ static int samsung_i2s_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Unable to get drvdata\n"); return -EFAULT; } - devm_snd_soc_register_component(&sec_dai->pdev->dev, + ret = devm_snd_soc_register_component(&sec_dai->pdev->dev, &samsung_i2s_component, &sec_dai->i2s_dai_drv, 1); - samsung_asoc_dma_platform_register(&pdev->dev); - return 0; + if (ret != 0) + return ret; + + return samsung_asoc_dma_platform_register(&pdev->dev); } pri_dai = i2s_alloc_dai(pdev, false); @@ -1290,7 +1292,9 @@ static int samsung_i2s_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); - samsung_asoc_dma_platform_register(&pdev->dev); + ret = samsung_asoc_dma_platform_register(&pdev->dev); + if (ret != 0) + return ret; return 0; err: -- cgit From af1cf5cf9c1881192f72af204e873ac345a3e265 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:30 +0100 Subject: ASoC: samsung: i2s: Request memory region in driver probe() The memory mapped registers region is common for both DAIs so request it in the I2S platform device driver's probe for the platform device corresponding to the primary DAI, rather than in the ASoC DAI's probe callback. While at it switch to devm_ioremap_resource(). This also drops the hard coded (0x100) register region size in the driver. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 45 +++++++-------------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index aa52b41f1749..366b720731e1 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -59,10 +59,8 @@ struct samsung_i2s_dai_data { struct i2s_dai { /* Platform device for this DAI */ struct platform_device *pdev; - /* IOREMAP'd SFRs */ + /* Memory mapped SFR region */ void __iomem *addr; - /* Physical base address of SFRs */ - u32 base; /* Rate of RCLK source clock */ unsigned long rclk_srcrate; /* Frame Clock */ @@ -979,16 +977,9 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) goto probe_exit; } - i2s->addr = ioremap(i2s->base, 0x100); - if (i2s->addr == NULL) { - dev_err(&i2s->pdev->dev, "cannot ioremap registers\n"); - return -ENXIO; - } - i2s->clk = clk_get(&i2s->pdev->dev, "iis"); if (IS_ERR(i2s->clk)) { dev_err(&i2s->pdev->dev, "failed to get i2s_clock\n"); - iounmap(i2s->addr); return PTR_ERR(i2s->clk); } @@ -1001,7 +992,6 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); if (other) { - other->addr = i2s->addr; other->clk = i2s->clk; } @@ -1043,8 +1033,6 @@ static int samsung_i2s_dai_remove(struct snd_soc_dai *dai) clk_disable_unprepare(i2s->clk); clk_put(i2s->clk); - - iounmap(i2s->addr); } i2s->clk = NULL; @@ -1162,7 +1150,6 @@ static int samsung_i2s_probe(struct platform_device *pdev) u32 regs_base, quirks = 0, idma_addr = 0; struct device_node *np = pdev->dev.of_node; const struct samsung_i2s_dai_data *i2s_dai_data; - int ret = 0; /* Call during Seconday interface registration */ i2s_dai_data = samsung_i2s_get_driver_data(pdev); @@ -1229,16 +1216,10 @@ static int samsung_i2s_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "Unable to get I2S SFR address\n"); - return -ENXIO; - } + pri_dai->addr = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(pri_dai->addr)) + return PTR_ERR(pri_dai->addr); - if (!request_mem_region(res->start, resource_size(res), - "samsung-i2s")) { - dev_err(&pdev->dev, "Unable to request SFR region\n"); - return -EBUSY; - } regs_base = res->start; pri_dai->dma_playback.dma_addr = regs_base + I2STXD; @@ -1247,7 +1228,6 @@ static int samsung_i2s_probe(struct platform_device *pdev) pri_dai->dma_capture.ch_name = "rx"; pri_dai->dma_playback.dma_size = 4; pri_dai->dma_capture.dma_size = 4; - pri_dai->base = regs_base; pri_dai->quirks = quirks; pri_dai->variant_regs = i2s_dai_data->i2s_variant_regs; @@ -1258,8 +1238,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) sec_dai = i2s_alloc_dai(pdev, true); if (!sec_dai) { dev_err(&pdev->dev, "Unable to alloc I2S_sec\n"); - ret = -ENOMEM; - goto err; + return -ENOMEM; } sec_dai->variant_regs = pri_dai->variant_regs; @@ -1273,7 +1252,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) } sec_dai->dma_playback.dma_size = 4; - sec_dai->base = regs_base; + sec_dai->addr = pri_dai->addr; sec_dai->quirks = quirks; sec_dai->idma_playback.dma_addr = idma_addr; sec_dai->pri_dai = pri_dai; @@ -1282,8 +1261,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) if (i2s_pdata && i2s_pdata->cfg_gpio && i2s_pdata->cfg_gpio(pdev)) { dev_err(&pdev->dev, "Unable to configure gpio\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } devm_snd_soc_register_component(&pri_dai->pdev->dev, @@ -1297,17 +1275,11 @@ static int samsung_i2s_probe(struct platform_device *pdev) return ret; return 0; -err: - if (res) - release_mem_region(regs_base, resource_size(res)); - - return ret; } static int samsung_i2s_remove(struct platform_device *pdev) { struct i2s_dai *i2s, *other; - struct resource *res; i2s = dev_get_drvdata(&pdev->dev); other = i2s->pri_dai ? : i2s->sec_dai; @@ -1317,9 +1289,6 @@ static int samsung_i2s_remove(struct platform_device *pdev) other->sec_dai = NULL; } else { pm_runtime_disable(&pdev->dev); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res) - release_mem_region(res->start, resource_size(res)); } i2s->pri_dai = NULL; -- cgit From 0ec2ba807c1563134a865b6f0b326b8a2e776937 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:31 +0100 Subject: ASoC: samsung: i2s: Move clk_get() to platform driver probe() Acquire the I2S interface clock in driver probe() callback as it's a per-device not a per-DAI clock. While at it switch to the resource managed clk_get(). Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 366b720731e1..a854ffca2416 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -971,18 +971,12 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; int ret; - if (other && other->clk) { /* If this is probe on secondary */ + if (is_secondary(i2s)) { /* If this is probe on the secondary DAI */ samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, NULL); goto probe_exit; } - i2s->clk = clk_get(&i2s->pdev->dev, "iis"); - if (IS_ERR(i2s->clk)) { - dev_err(&i2s->pdev->dev, "failed to get i2s_clock\n"); - return PTR_ERR(i2s->clk); - } - ret = clk_prepare_enable(i2s->clk); if (ret != 0) { dev_err(&i2s->pdev->dev, "failed to enable clock: %d\n", ret); @@ -991,10 +985,6 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); - if (other) { - other->clk = i2s->clk; - } - if (i2s->quirks & QUIRK_NEED_RSTCLR) writel(CON_RSTCLR, i2s->addr + I2SCON); @@ -1032,7 +1022,6 @@ static int samsung_i2s_dai_remove(struct snd_soc_dai *dai) writel(0, i2s->addr + I2SCON); clk_disable_unprepare(i2s->clk); - clk_put(i2s->clk); } i2s->clk = NULL; @@ -1222,6 +1211,11 @@ static int samsung_i2s_probe(struct platform_device *pdev) regs_base = res->start; + pri_dai->clk = devm_clk_get(&pdev->dev, "iis"); + if (IS_ERR(pri_dai->clk)) { + dev_err(&pdev->dev, "Failed to get iis clock\n"); + return PTR_ERR(pri_dai->clk); + } pri_dai->dma_playback.dma_addr = regs_base + I2STXD; pri_dai->dma_capture.dma_addr = regs_base + I2SRXD; pri_dai->dma_playback.ch_name = "tx"; @@ -1253,6 +1247,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) sec_dai->dma_playback.dma_size = 4; sec_dai->addr = pri_dai->addr; + sec_dai->clk = pri_dai->clk; sec_dai->quirks = quirks; sec_dai->idma_playback.dma_addr = idma_addr; sec_dai->pri_dai = pri_dai; -- cgit From c92f1d0e7c8431f8b3bf1d42e951ead07b22078e Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:32 +0100 Subject: ASoC: samsung: i2s: Move clk enable to the platform driver probe() The clk_prepare_enable() call on the "iis" clock is moved to happen earlier in the DAI platform device driver's probe() callback, so the I2S registers can be safely accessed through the clk API, after the clk supplier is registered in the platform device probe(). After this patch the "iis" clock is kept enabled since the (primary) I2S platform device probe() and until the platform device driver remove() call. This is similar to gating the clock in the snd_soc_dai probe() and remove() callbacks. Normally, in addition to that we should mark the device as PM runtime active, so if runtime PM is enabled it can idle the device by turning off the clock. Correcting this issue is left for a separate patch series, as we need to ensure the BUSCLK clock is always enabled when required. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index a854ffca2416..f75c19e5b5c3 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -969,7 +969,6 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; - int ret; if (is_secondary(i2s)) { /* If this is probe on the secondary DAI */ samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, @@ -977,12 +976,6 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) goto probe_exit; } - ret = clk_prepare_enable(i2s->clk); - if (ret != 0) { - dev_err(&i2s->pdev->dev, "failed to enable clock: %d\n", ret); - return ret; - } - samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); if (i2s->quirks & QUIRK_NEED_RSTCLR) @@ -1014,18 +1007,12 @@ probe_exit: static int samsung_i2s_dai_remove(struct snd_soc_dai *dai) { struct i2s_dai *i2s = snd_soc_dai_get_drvdata(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; - - if (!other || !other->clk) { + if (!is_secondary(i2s)) { if (i2s->quirks & QUIRK_NEED_RSTCLR) writel(0, i2s->addr + I2SCON); - - clk_disable_unprepare(i2s->clk); } - i2s->clk = NULL; - return 0; } @@ -1139,6 +1126,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) u32 regs_base, quirks = 0, idma_addr = 0; struct device_node *np = pdev->dev.of_node; const struct samsung_i2s_dai_data *i2s_dai_data; + int ret; /* Call during Seconday interface registration */ i2s_dai_data = samsung_i2s_get_driver_data(pdev); @@ -1216,6 +1204,12 @@ static int samsung_i2s_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to get iis clock\n"); return PTR_ERR(pri_dai->clk); } + + ret = clk_prepare_enable(pri_dai->clk); + if (ret != 0) { + dev_err(&pdev->dev, "failed to enable clock: %d\n", ret); + return ret; + } pri_dai->dma_playback.dma_addr = regs_base + I2STXD; pri_dai->dma_capture.dma_addr = regs_base + I2SRXD; pri_dai->dma_playback.ch_name = "tx"; @@ -1286,6 +1280,9 @@ static int samsung_i2s_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); } + if (!is_secondary(i2s)) + clk_disable_unprepare(i2s->clk); + i2s->pri_dai = NULL; i2s->sec_dai = NULL; -- cgit From dcd60fc3445329d738a23ab7997717491c2f4cec Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:33 +0100 Subject: ASoC: samsung: i2s: Add get_other_dai helper function The code to get pointer to the other DAI is repeated multiple times. Add a helper function and use it instead. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index f75c19e5b5c3..cab2a2abc89b 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -130,10 +130,16 @@ static inline bool tx_active(struct i2s_dai *i2s) return active ? true : false; } +/* Return pointer to the other DAI */ +static inline struct i2s_dai *get_other_dai(struct i2s_dai *i2s) +{ + return i2s->pri_dai ? : i2s->sec_dai; +} + /* If the other interface of the controller is transmitting data */ static inline bool other_tx_active(struct i2s_dai *i2s) { - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); return tx_active(other); } @@ -160,7 +166,7 @@ static inline bool rx_active(struct i2s_dai *i2s) /* If the other interface of the controller is receiving data */ static inline bool other_rx_active(struct i2s_dai *i2s) { - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); return rx_active(other); } @@ -461,7 +467,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs, int dir) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); u32 mod = readl(i2s->addr + I2SMOD); const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off; @@ -733,7 +739,7 @@ static int i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); unsigned long flags; spin_lock_irqsave(&lock, flags); @@ -760,7 +766,7 @@ static void i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); unsigned long flags; const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; @@ -791,7 +797,7 @@ static void i2s_shutdown(struct snd_pcm_substream *substream, static int config_setup(struct i2s_dai *i2s) { - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); unsigned rfs, bfs, blc; u32 psr; @@ -899,7 +905,7 @@ static int i2s_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); switch (div_id) { case SAMSUNG_I2S_DIV_BCLK: @@ -968,7 +974,7 @@ static int i2s_resume(struct snd_soc_dai *dai) static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); if (is_secondary(i2s)) { /* If this is probe on the secondary DAI */ samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, @@ -1271,7 +1277,7 @@ static int samsung_i2s_remove(struct platform_device *pdev) struct i2s_dai *i2s, *other; i2s = dev_get_drvdata(&pdev->dev); - other = i2s->pri_dai ? : i2s->sec_dai; + other = get_other_dai(i2s); if (other) { other->pri_dai = NULL; -- cgit From 872c26bd801dcda21402caa2dcd0a39315b08b65 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:34 +0100 Subject: ASoC: samsung: i2s: Remove an unneeded goto usage The usage of this goto seems unjustified, use if/else statement instead. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index cab2a2abc89b..2bac71945b3e 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -979,19 +979,18 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) if (is_secondary(i2s)) { /* If this is probe on the secondary DAI */ samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, NULL); - goto probe_exit; - } - - samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); + } else { + samsung_asoc_init_dma_data(dai, &i2s->dma_playback, + &i2s->dma_capture); - if (i2s->quirks & QUIRK_NEED_RSTCLR) - writel(CON_RSTCLR, i2s->addr + I2SCON); + if (i2s->quirks & QUIRK_NEED_RSTCLR) + writel(CON_RSTCLR, i2s->addr + I2SCON); - if (i2s->quirks & QUIRK_SUPPORTS_IDMA) - idma_reg_addr_init(i2s->addr, + if (i2s->quirks & QUIRK_SUPPORTS_IDMA) + idma_reg_addr_init(i2s->addr, i2s->sec_dai->idma_playback.dma_addr); + } -probe_exit: /* Reset any constraint on RFS and BFS */ i2s->rfs = 0; i2s->bfs = 0; -- cgit From f36705366a2324fedd6cca7683fadf947ac0b154 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:35 +0100 Subject: ASoC: samsung: i2s: Add spinlock in place of local_irq_* calls It seems this driver hasn't been updated for SMP, as local_irq_save/ local_irq_restore don't provide proper protection of read/modify/write of the device's registers on such systems. Introduce a spinlock serializing access to the register region, it will be helpful later when I2SMOD, I2SPSR registers are made also accessible through the clk API. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 2bac71945b3e..20cc51fc76ae 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -94,6 +94,10 @@ struct i2s_dai { u32 suspend_i2scon; u32 suspend_i2spsr; const struct samsung_i2s_variant_regs *variant_regs; + + /* Spinlock protecting access to the device's registers */ + spinlock_t spinlock; + spinlock_t *lock; }; /* Lock for cross i/f checks */ @@ -867,10 +871,10 @@ static int i2s_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - local_irq_save(flags); + spin_lock_irqsave(i2s->lock, flags); if (config_setup(i2s)) { - local_irq_restore(flags); + spin_unlock_irqrestore(i2s->lock, flags); return -EINVAL; } @@ -879,12 +883,12 @@ static int i2s_trigger(struct snd_pcm_substream *substream, else i2s_txctrl(i2s, 1); - local_irq_restore(flags); + spin_unlock_irqrestore(i2s->lock, flags); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - local_irq_save(flags); + spin_lock_irqsave(i2s->lock, flags); if (capture) { i2s_rxctrl(i2s, 0); @@ -894,7 +898,7 @@ static int i2s_trigger(struct snd_pcm_substream *substream, i2s_fifo(i2s, FIC_TXFLUSH); } - local_irq_restore(flags); + spin_unlock_irqrestore(i2s->lock, flags); break; } @@ -1157,6 +1161,9 @@ static int samsung_i2s_probe(struct platform_device *pdev) return -ENOMEM; } + spin_lock_init(&pri_dai->spinlock); + pri_dai->lock = &pri_dai->spinlock; + if (!np) { res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!res) { @@ -1234,6 +1241,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) return -ENOMEM; } + sec_dai->lock = &pri_dai->spinlock; sec_dai->variant_regs = pri_dai->variant_regs; sec_dai->dma_playback.dma_addr = regs_base + I2STXDS; sec_dai->dma_playback.ch_name = "tx-sec"; -- cgit From ce8bcdbb61d96de481de14b3ad985797a417246c Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:36 +0100 Subject: ASoC: samsung: i2s: Protect more registers with a spinlock Ensure the I2SMOD, I2SPSR registers, which are also exposed through clk API are only accessed with the i2s->spinlock spinlock held. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 81 +++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 30 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 20cc51fc76ae..05fc2f0e91ca 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -472,17 +472,22 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, { struct i2s_dai *i2s = to_info(dai); struct i2s_dai *other = get_other_dai(i2s); - u32 mod = readl(i2s->addr + I2SMOD); const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off; unsigned int rsrc_mask = 1 << i2s_regs->rclksrc_off; + u32 mod, mask, val = 0; + + spin_lock(i2s->lock); + mod = readl(i2s->addr + I2SMOD); + spin_unlock(i2s->lock); switch (clk_id) { case SAMSUNG_I2S_OPCLK: - mod &= ~MOD_OPCLK_MASK; - mod |= dir; + mask = MOD_OPCLK_MASK; + val = dir; break; case SAMSUNG_I2S_CDCLK: + mask = 1 << i2s_regs->cdclkcon_off; /* Shouldn't matter in GATING(CLOCK_IN) mode */ if (dir == SND_SOC_CLOCK_IN) rfs = 0; @@ -499,15 +504,15 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, } if (dir == SND_SOC_CLOCK_IN) - mod |= 1 << i2s_regs->cdclkcon_off; - else - mod &= ~(1 << i2s_regs->cdclkcon_off); + val = 1 << i2s_regs->cdclkcon_off; i2s->rfs = rfs; break; case SAMSUNG_I2S_RCLKSRC_0: /* clock corrsponding to IISMOD[10] := 0 */ case SAMSUNG_I2S_RCLKSRC_1: /* clock corrsponding to IISMOD[10] := 1 */ + mask = 1 << i2s_regs->rclksrc_off; + if ((i2s->quirks & QUIRK_NO_MUXPSR) || (clk_id == SAMSUNG_I2S_RCLKSRC_0)) clk_id = 0; @@ -557,18 +562,19 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, return 0; } - if (clk_id == 0) - mod &= ~(1 << i2s_regs->rclksrc_off); - else - mod |= 1 << i2s_regs->rclksrc_off; - + if (clk_id == 1) + val = 1 << i2s_regs->rclksrc_off; break; default: dev_err(&i2s->pdev->dev, "We don't serve that!\n"); return -EINVAL; } + spin_lock(i2s->lock); + mod = readl(i2s->addr + I2SMOD); + mod = (mod & ~mask) | val; writel(mod, i2s->addr + I2SMOD); + spin_unlock(i2s->lock); return 0; } @@ -577,9 +583,8 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct i2s_dai *i2s = to_info(dai); - u32 mod = readl(i2s->addr + I2SMOD); int lrp_shift, sdf_shift, sdf_mask, lrp_rlow, mod_slave; - u32 tmp = 0; + u32 mod, tmp = 0; lrp_shift = i2s->variant_regs->lrp_off; sdf_shift = i2s->variant_regs->sdf_off; @@ -639,12 +644,15 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, return -EINVAL; } + spin_lock(i2s->lock); + mod = readl(i2s->addr + I2SMOD); /* * Don't change the I2S mode if any controller is active on this * channel. */ if (any_active(i2s) && ((mod & (sdf_mask | lrp_rlow | mod_slave)) != tmp)) { + spin_unlock(i2s->lock); dev_err(&i2s->pdev->dev, "%s:%d Other DAI busy\n", __func__, __LINE__); return -EAGAIN; @@ -653,6 +661,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, mod &= ~(sdf_mask | lrp_rlow | mod_slave); mod |= tmp; writel(mod, i2s->addr + I2SMOD); + spin_unlock(i2s->lock); return 0; } @@ -661,16 +670,16 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); - u32 mod = readl(i2s->addr + I2SMOD); + u32 mod, mask = 0, val = 0; if (!is_secondary(i2s)) - mod &= ~(MOD_DC2_EN | MOD_DC1_EN); + mask |= (MOD_DC2_EN | MOD_DC1_EN); switch (params_channels(params)) { case 6: - mod |= MOD_DC2_EN; + val |= MOD_DC2_EN; case 4: - mod |= MOD_DC1_EN; + val |= MOD_DC1_EN; break; case 2: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -692,44 +701,49 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, } if (is_secondary(i2s)) - mod &= ~MOD_BLCS_MASK; + mask |= MOD_BLCS_MASK; else - mod &= ~MOD_BLCP_MASK; + mask |= MOD_BLCP_MASK; if (is_manager(i2s)) - mod &= ~MOD_BLC_MASK; + mask |= MOD_BLC_MASK; switch (params_width(params)) { case 8: if (is_secondary(i2s)) - mod |= MOD_BLCS_8BIT; + val |= MOD_BLCS_8BIT; else - mod |= MOD_BLCP_8BIT; + val |= MOD_BLCP_8BIT; if (is_manager(i2s)) - mod |= MOD_BLC_8BIT; + val |= MOD_BLC_8BIT; break; case 16: if (is_secondary(i2s)) - mod |= MOD_BLCS_16BIT; + val |= MOD_BLCS_16BIT; else - mod |= MOD_BLCP_16BIT; + val |= MOD_BLCP_16BIT; if (is_manager(i2s)) - mod |= MOD_BLC_16BIT; + val |= MOD_BLC_16BIT; break; case 24: if (is_secondary(i2s)) - mod |= MOD_BLCS_24BIT; + val |= MOD_BLCS_24BIT; else - mod |= MOD_BLCP_24BIT; + val |= MOD_BLCP_24BIT; if (is_manager(i2s)) - mod |= MOD_BLC_24BIT; + val |= MOD_BLC_24BIT; break; default: dev_err(&i2s->pdev->dev, "Format(%d) not supported\n", params_format(params)); return -EINVAL; } + + spin_lock(i2s->lock); + mod = readl(i2s->addr + I2SMOD); + mod = (mod & ~mask) | val; writel(mod, i2s->addr + I2SMOD); + spin_unlock(i2s->lock); samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); @@ -979,6 +993,7 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); struct i2s_dai *other = get_other_dai(i2s); + unsigned long flags; if (is_secondary(i2s)) { /* If this is probe on the secondary DAI */ samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, @@ -999,11 +1014,14 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) i2s->rfs = 0; i2s->bfs = 0; i2s->rclk_srcrate = 0; + + spin_lock_irqsave(i2s->lock, flags); i2s_txctrl(i2s, 0); i2s_rxctrl(i2s, 0); i2s_fifo(i2s, FIC_TXFLUSH); i2s_fifo(other, FIC_TXFLUSH); i2s_fifo(i2s, FIC_RXFLUSH); + spin_unlock_irqrestore(i2s->lock, flags); /* Gate CDCLK by default */ if (!is_opened(other)) @@ -1018,8 +1036,11 @@ static int samsung_i2s_dai_remove(struct snd_soc_dai *dai) struct i2s_dai *i2s = snd_soc_dai_get_drvdata(dai); if (!is_secondary(i2s)) { - if (i2s->quirks & QUIRK_NEED_RSTCLR) + if (i2s->quirks & QUIRK_NEED_RSTCLR) { + spin_lock(i2s->lock); writel(0, i2s->addr + I2SCON); + spin_unlock(i2s->lock); + } } return 0; -- cgit From ecb400cabb37cfef3221e45e4f6370a855aa7a44 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:37 +0100 Subject: ASoC: samsung: odroidx2: Handle I2S CDCLK clock conditionally In order to support old DTs we check the codec device node if it contains "clocks" property and only if it doesn't (which indicates an old DT) we proceed with enabling the CDCLK clock by means of the set_sysclk() callback. For new DTs which use the common clock bindings for CDCLK that clock is supposed to be handled outside the sound machine driver. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/odroidx2_max98090.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/odroidx2_max98090.c b/sound/soc/samsung/odroidx2_max98090.c index fa4f1d2f69bf..596f1180a369 100644 --- a/sound/soc/samsung/odroidx2_max98090.c +++ b/sound/soc/samsung/odroidx2_max98090.c @@ -21,6 +21,8 @@ struct odroidx2_drv_data { /* The I2S CDCLK output clock frequency for the MAX98090 codec */ #define MAX98090_MCLK 19200000 +static struct snd_soc_dai_link odroidx2_dai[]; + static int odroidx2_late_probe(struct snd_soc_card *card) { struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; @@ -29,7 +31,9 @@ static int odroidx2_late_probe(struct snd_soc_card *card) ret = snd_soc_dai_set_sysclk(codec_dai, 0, MAX98090_MCLK, SND_SOC_CLOCK_IN); - if (ret < 0) + + if (ret < 0 || of_find_property(odroidx2_dai[0].codec_of_node, + "clocks", NULL)) return ret; /* Set the cpu DAI configuration in order to use CDCLK */ -- cgit From 074b89bb5fb7e80e0f98f1b45f276b0386269e3d Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Jan 2015 19:42:39 +0100 Subject: ASoC: samsung: i2s: Add clock provider for the I2S internal clocks This patch adds clock provider (currently only for DT platforms) for the CODECLKO (CDCLK) gate, RCLKSRC mux and RCLK pre-scaler divider divider clock. Those all tree clock are only available in the IIS Multi Audio Interface (I2S0), the regular IIS Bus Interface has only CDCLK gate clock. The motivation behind this patch is to expose the I2S internal clocks which are currently controlled through set_sysclk() through the clk API, so dedicated sound machine driver per each board can be avoided. The intention is also to fix the CDCLK gating issue reported by Daniel Drake: http://mailman.alsa-project.org/pipermail/alsa-devel/2014-September/081753.html This patch also reverts commit b97c60abf9a561f86ae71bd741add02673cc1 ("ASoC: samsung-i2s: Maintain CDCLK settings across i2s_{shutdown/ startup}") The problem that commit attempted to solve only affects the Odroid X2/U3, which doesn't configure the CDCLK clock in struct snd_soc_dai_ops hw_params callback and the issue should be now resolved by using clk API, i.e. having the codec enabling/ disabling the CDCLK clock as required. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 113 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 93 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 05fc2f0e91ca..b92ab40d2be6 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -10,9 +10,11 @@ * published by the Free Software Foundation. */ +#include #include #include #include +#include #include #include #include @@ -81,8 +83,6 @@ struct i2s_dai { #define DAI_OPENED (1 << 0) /* Dai is opened */ #define DAI_MANAGER (1 << 1) /* Dai is the manager */ unsigned mode; - /* CDCLK pin direction: 0 - input, 1 - output */ - unsigned int cdclk_out:1; /* Driver for this DAI */ struct snd_soc_dai_driver i2s_dai_drv; /* DMA parameters */ @@ -98,6 +98,10 @@ struct i2s_dai { /* Spinlock protecting access to the device's registers */ spinlock_t spinlock; spinlock_t *lock; + + /* Below fields are only valid if this is the primary FIFO */ + struct clk *clk_table[3]; + struct clk_onecell_data clk_data; }; /* Lock for cross i/f checks */ @@ -774,9 +778,6 @@ static int i2s_startup(struct snd_pcm_substream *substream, spin_unlock_irqrestore(&lock, flags); - if (!is_opened(other) && i2s->cdclk_out) - i2s_set_sysclk(dai, SAMSUNG_I2S_CDCLK, - 0, SND_SOC_CLOCK_OUT); return 0; } @@ -786,31 +787,20 @@ static void i2s_shutdown(struct snd_pcm_substream *substream, struct i2s_dai *i2s = to_info(dai); struct i2s_dai *other = get_other_dai(i2s); unsigned long flags; - const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; spin_lock_irqsave(&lock, flags); i2s->mode &= ~DAI_OPENED; i2s->mode &= ~DAI_MANAGER; - if (is_opened(other)) { + if (is_opened(other)) other->mode |= DAI_MANAGER; - } else { - u32 mod = readl(i2s->addr + I2SMOD); - i2s->cdclk_out = !(mod & (1 << i2s_regs->cdclkcon_off)); - if (other) - other->cdclk_out = i2s->cdclk_out; - } + /* Reset any constraint on RFS and BFS */ i2s->rfs = 0; i2s->bfs = 0; spin_unlock_irqrestore(&lock, flags); - - /* Gate CDCLK by default */ - if (!is_opened(other)) - i2s_set_sysclk(dai, SAMSUNG_I2S_CDCLK, - 0, SND_SOC_CLOCK_IN); } static int config_setup(struct i2s_dai *i2s) @@ -1147,6 +1137,87 @@ static int i2s_runtime_resume(struct device *dev) } #endif /* CONFIG_PM */ +static void i2s_unregister_clocks(struct i2s_dai *i2s) +{ + int i; + + for (i = 0; i < i2s->clk_data.clk_num; i++) { + if (!IS_ERR(i2s->clk_table[i])) + clk_unregister(i2s->clk_table[i]); + } +} + +static void i2s_unregister_clock_provider(struct platform_device *pdev) +{ + struct i2s_dai *i2s = dev_get_drvdata(&pdev->dev); + + of_clk_del_provider(pdev->dev.of_node); + i2s_unregister_clocks(i2s); +} + +static int i2s_register_clock_provider(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct i2s_dai *i2s = dev_get_drvdata(dev); + const char *clk_name[2] = { "i2s_opclk0", "i2s_opclk1" }; + const char *p_names[2] = { NULL }; + const struct samsung_i2s_variant_regs *reg_info = i2s->variant_regs; + struct clk *rclksrc; + int ret, i; + + /* Register the clock provider only if it's expected in the DTB */ + if (!of_find_property(dev->of_node, "#clock-cells", NULL)) + return 0; + + /* Get the RCLKSRC mux clock parent clock names */ + for (i = 0; i < ARRAY_SIZE(p_names); i++) { + rclksrc = clk_get(dev, clk_name[i]); + if (IS_ERR(rclksrc)) + continue; + p_names[i] = __clk_get_name(rclksrc); + clk_put(rclksrc); + } + + if (!(i2s->quirks & QUIRK_NO_MUXPSR)) { + /* Activate the prescaler */ + u32 val = readl(i2s->addr + I2SPSR); + writel(val | PSR_PSREN, i2s->addr + I2SPSR); + + i2s->clk_table[CLK_I2S_RCLK_SRC] = clk_register_mux(NULL, + "i2s_rclksrc", p_names, ARRAY_SIZE(p_names), + CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, + i2s->addr + I2SMOD, reg_info->rclksrc_off, + 1, 0, i2s->lock); + + i2s->clk_table[CLK_I2S_RCLK_PSR] = clk_register_divider(NULL, + "i2s_presc", "i2s_rclksrc", + CLK_SET_RATE_PARENT, + i2s->addr + I2SPSR, 8, 6, 0, i2s->lock); + + p_names[0] = "i2s_presc"; + i2s->clk_data.clk_num = 2; + } + of_property_read_string_index(dev->of_node, + "clock-output-names", 0, &clk_name[0]); + + i2s->clk_table[CLK_I2S_CDCLK] = clk_register_gate(NULL, clk_name[0], + p_names[0], CLK_SET_RATE_PARENT, + i2s->addr + I2SMOD, reg_info->cdclkcon_off, + CLK_GATE_SET_TO_DISABLE, i2s->lock); + + i2s->clk_data.clk_num += 1; + i2s->clk_data.clks = i2s->clk_table; + + ret = of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, + &i2s->clk_data); + if (ret < 0) { + dev_err(dev, "failed to add clock provider: %d\n", ret); + i2s_unregister_clocks(i2s); + } + + return ret; +} + static int samsung_i2s_probe(struct platform_device *pdev) { struct i2s_dai *pri_dai, *sec_dai = NULL; @@ -1297,7 +1368,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) if (ret != 0) return ret; - return 0; + return i2s_register_clock_provider(pdev); } static int samsung_i2s_remove(struct platform_device *pdev) @@ -1314,8 +1385,10 @@ static int samsung_i2s_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); } - if (!is_secondary(i2s)) + if (!is_secondary(i2s)) { + i2s_unregister_clock_provider(pdev); clk_disable_unprepare(i2s->clk); + } i2s->pri_dai = NULL; i2s->sec_dai = NULL; -- cgit From bbc8aa7371bbc3df2a6db08dec6815973f7a7982 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 10 Jan 2015 15:44:04 +0100 Subject: ASoC: 88pm860x: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/88pm860x-codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index a2bf27f4baab..a0f265327fdf 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -386,7 +386,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); /* * In order to avoid current on the load, mute power-on and power-off @@ -403,7 +403,7 @@ static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, static int pm860x_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int dac = 0; int data; -- cgit From 08ca560aa0a0aa634f3d946a9a713473d5d2cda4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 10 Jan 2015 15:44:05 +0100 Subject: ASoC: ak4671: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/ak4671.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c index 686cacb0e835..632e89f793a7 100644 --- a/sound/soc/codecs/ak4671.c +++ b/sound/soc/codecs/ak4671.c @@ -163,7 +163,7 @@ static const struct snd_kcontrol_new ak4671_snd_controls[] = { static int ak4671_out2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: -- cgit From 76f5537f4dd246b31ed85434144506f50b9cbb70 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 10 Jan 2015 15:44:06 +0100 Subject: ASoC: da732x: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Adam Thomson Signed-off-by: Mark Brown --- sound/soc/codecs/da732x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c index 61b2f9a2eef1..ffe96175a8a5 100644 --- a/sound/soc/codecs/da732x.c +++ b/sound/soc/codecs/da732x.c @@ -609,7 +609,7 @@ static const struct snd_kcontrol_new da732x_snd_controls[] = { static int da732x_adc_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -663,7 +663,7 @@ static int da732x_adc_event(struct snd_soc_dapm_widget *w, static int da732x_out_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: -- cgit From 73bffd17785488197b55c05c02f0d2d2798fce03 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 10 Jan 2015 15:44:07 +0100 Subject: ASoC: sgtl5000: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/sgtl5000.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 29cf7ce610f4..6d6ba3a1d25a 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -155,18 +155,19 @@ struct sgtl5000_priv { static int mic_bias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); switch (event) { case SND_SOC_DAPM_POST_PMU: /* change mic bias resistor */ - snd_soc_update_bits(w->codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(w->codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, 0); break; } @@ -181,11 +182,12 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, static int power_vag_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP; switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); break; @@ -195,9 +197,9 @@ static int power_vag_event(struct snd_soc_dapm_widget *w, * operational to prevent inadvertently starving the * other one of them. */ - if ((snd_soc_read(w->codec, SGTL5000_CHIP_ANA_POWER) & + if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) & mask) != mask) { - snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, 0); msleep(400); } -- cgit From 278a202620131c1b83f2776d31b67a287c38df87 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 10 Jan 2015 15:44:08 +0100 Subject: ASoC: sn95031: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/codecs/sn95031.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index 1f451a1946eb..47b257e41809 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c @@ -233,16 +233,18 @@ static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, static int sn95031_vhs_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + if (SND_SOC_DAPM_EVENT_ON(event)) { pr_debug("VHS SND_SOC_DAPM_EVENT_ON doing rail startup now\n"); /* power up the rail */ - snd_soc_write(w->codec, SN95031_VHSP, 0x3D); - snd_soc_write(w->codec, SN95031_VHSN, 0x3F); + snd_soc_write(codec, SN95031_VHSP, 0x3D); + snd_soc_write(codec, SN95031_VHSN, 0x3F); msleep(1); } else if (SND_SOC_DAPM_EVENT_OFF(event)) { pr_debug("VHS SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n"); - snd_soc_write(w->codec, SN95031_VHSP, 0xC4); - snd_soc_write(w->codec, SN95031_VHSN, 0x04); + snd_soc_write(codec, SN95031_VHSP, 0xC4); + snd_soc_write(codec, SN95031_VHSN, 0x04); } return 0; } @@ -250,14 +252,16 @@ static int sn95031_vhs_event(struct snd_soc_dapm_widget *w, static int sn95031_vihf_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + if (SND_SOC_DAPM_EVENT_ON(event)) { pr_debug("VIHF SND_SOC_DAPM_EVENT_ON doing rail startup now\n"); /* power up the rail */ - snd_soc_write(w->codec, SN95031_VIHF, 0x27); + snd_soc_write(codec, SN95031_VIHF, 0x27); msleep(1); } else if (SND_SOC_DAPM_EVENT_OFF(event)) { pr_debug("VIHF SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n"); - snd_soc_write(w->codec, SN95031_VIHF, 0x24); + snd_soc_write(codec, SN95031_VIHF, 0x24); } return 0; } @@ -265,6 +269,7 @@ static int sn95031_vihf_event(struct snd_soc_dapm_widget *w, static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int ldo = 0, clk_dir = 0, data_dir = 0; if (SND_SOC_DAPM_EVENT_ON(event)) { @@ -273,15 +278,16 @@ static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w, data_dir = BIT(7); } /* program DMIC LDO, clock and set clock */ - snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); - snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(0), clk_dir); - snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(7), data_dir); + snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); + snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(0), clk_dir); + snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(7), data_dir); return 0; } static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int ldo = 0, clk_dir = 0, data_dir = 0; if (SND_SOC_DAPM_EVENT_ON(event)) { @@ -290,22 +296,23 @@ static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w, data_dir = BIT(1); } /* program DMIC LDO, clock and set clock */ - snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); - snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(2), clk_dir); - snd_soc_update_bits(w->codec, SN95031_DMICBUF45, BIT(1), data_dir); + snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); + snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(2), clk_dir); + snd_soc_update_bits(codec, SN95031_DMICBUF45, BIT(1), data_dir); return 0; } static int sn95031_dmic56_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int ldo = 0; if (SND_SOC_DAPM_EVENT_ON(event)) ldo = BIT(7)|BIT(6); /* program DMIC LDO */ - snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(7)|BIT(6), ldo); + snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(7)|BIT(6), ldo); return 0; } -- cgit From 043123fd5b2efac325c796b51797946df2b6bfb0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:07 +0100 Subject: ASoC: arizona: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/arizona.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 9550d7433ad0..65977bc0db19 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -84,7 +84,7 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct arizona *arizona = dev_get_drvdata(codec->dev->parent); struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); bool manual_ena = false; @@ -692,7 +692,8 @@ static void arizona_in_set_vu(struct snd_soc_codec *codec, int ena) int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); unsigned int reg; if (w->shift % 2) @@ -705,25 +706,25 @@ int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, priv->in_pending++; break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(w->codec, reg, ARIZONA_IN1L_MUTE, 0); + snd_soc_update_bits(codec, reg, ARIZONA_IN1L_MUTE, 0); /* If this is the last input pending then allow VU */ priv->in_pending--; if (priv->in_pending == 0) { msleep(1); - arizona_in_set_vu(w->codec, 1); + arizona_in_set_vu(codec, 1); } break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(w->codec, reg, + snd_soc_update_bits(codec, reg, ARIZONA_IN1L_MUTE | ARIZONA_IN_VU, ARIZONA_IN1L_MUTE | ARIZONA_IN_VU); break; case SND_SOC_DAPM_POST_PMD: /* Disable volume updates if no inputs are enabled */ - reg = snd_soc_read(w->codec, ARIZONA_INPUT_ENABLES); + reg = snd_soc_read(codec, ARIZONA_INPUT_ENABLES); if (reg == 0) - arizona_in_set_vu(w->codec, 0); + arizona_in_set_vu(codec, 0); } return 0; @@ -760,7 +761,8 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); struct arizona *arizona = priv->arizona; unsigned int mask = 1 << w->shift; unsigned int val; -- cgit From b96aef71e3bb1b4719325c94a95ddff20583417f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:08 +0100 Subject: ASoC: wm2000: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm2000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 34ef65c52a7d..8d9de49a5052 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -683,7 +683,7 @@ static const struct snd_kcontrol_new wm2000_controls[] = { static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); int ret; -- cgit From 3196048ee6543e53d32b848660284a8d0ef09fbf Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:09 +0100 Subject: ASoC: wm5102: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5100.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index b80970dc2d2f..ea09db585aa1 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c @@ -775,7 +775,8 @@ static int wm5100_out_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); switch (w->reg) { case WM5100_CHANNEL_ENABLES_1: @@ -839,7 +840,7 @@ static int wm5100_post_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); int ret; -- cgit From 42b7a197915b14503a15247c34c619aa15a170b7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:10 +0100 Subject: ASoC: wm5102: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5102.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index f439ae052128..f57235be8b0a 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -580,7 +580,7 @@ static const struct reg_default wm5102_sysclk_revb_patch[] = { static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct arizona *arizona = dev_get_drvdata(codec->dev->parent); struct regmap *regmap = arizona->regmap; const struct reg_default *patch = NULL; -- cgit From cf53380c88c0193107113932975ef4adf518a58b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:11 +0100 Subject: ASoC: wm5110: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5110.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 4456b38a3ef5..7cb02e9d3b53 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -134,7 +134,7 @@ static const struct reg_default wm5110_sysclk_revd_patch[] = { static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct arizona *arizona = dev_get_drvdata(codec->dev->parent); struct regmap *regmap = arizona->regmap; const struct reg_default *patch = NULL; -- cgit From 83f132c5e3c18db61965fe49c827bd7ec04e78c0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:12 +0100 Subject: ASoC: wm8350: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8350.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 574579b98872..c81a9eab3e3e 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -259,7 +259,7 @@ static void wm8350_pga_work(struct work_struct *work) static int pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); struct wm8350_output *out; -- cgit From a8c696f13ba79a6e60517d43110038a24862e286 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:13 +0100 Subject: ASoC: wm8400: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8400.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 8ee446987aa9..b0d84e552fca 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -324,6 +324,7 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, static int outmixer_event (struct snd_soc_dapm_widget *w, struct snd_kcontrol * kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; u32 reg_shift = mc->shift; @@ -332,7 +333,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, switch (reg_shift) { case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) : - reg = snd_soc_read(w->codec, WM8400_OUTPUT_MIXER1); + reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER1); if (reg & WM8400_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -340,7 +341,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8): - reg = snd_soc_read(w->codec, WM8400_OUTPUT_MIXER2); + reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER2); if (reg & WM8400_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -348,7 +349,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8): - reg = snd_soc_read(w->codec, WM8400_SPEAKER_MIXER); + reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER); if (reg & WM8400_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -356,7 +357,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8): - reg = snd_soc_read(w->codec, WM8400_SPEAKER_MIXER); + reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER); if (reg & WM8400_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); -- cgit From d286b805e74a95390bc917b1b0ab508e27eda7d7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:14 +0100 Subject: ASoC: wm8731: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8731.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index b9211b42f6e9..e129c81ad219 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -217,7 +217,8 @@ SND_SOC_DAPM_INPUT("LLINEIN"), static int wm8731_check_osc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(source->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); return wm8731->sysclk_type == WM8731_SYSCLK_XTAL; } -- cgit From c3495aea5de1ad14e0ffdb8ade4d263afd73babb Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:15 +0100 Subject: ASoC: wm8770: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8770.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c index 180e7a098726..53e977da2f86 100644 --- a/sound/soc/codecs/wm8770.c +++ b/sound/soc/codecs/wm8770.c @@ -308,9 +308,7 @@ static const struct snd_soc_dapm_route wm8770_intercon[] = { static int vout12supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec; - - codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -327,9 +325,7 @@ static int vout12supply_event(struct snd_soc_dapm_widget *w, static int vout34supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec; - - codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: -- cgit From 2de4d649252bf9a0c6660eeb0a4615160a709b6f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:16 +0100 Subject: ASoC: wm8900: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8900.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 3a0d4b7d692f..2eb986c19b88 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -224,7 +224,7 @@ static void wm8900_reset(struct snd_soc_codec *codec) static int wm8900_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u16 hpctl1 = snd_soc_read(codec, WM8900_REG_HPCTL1); switch (event) { -- cgit From 2ea7a3f354a91410d95d1dcf43df4ba46522e2c5 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:17 +0100 Subject: ASoC: wm8903: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8903.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index cc6b0ef98a34..dde462c082be 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -260,7 +260,7 @@ static int wm8903_cp_event(struct snd_soc_dapm_widget *w, static int wm8903_dcs_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); switch (event) { -- cgit From 8f13bd4e6cfed02e107ab916e14cee5675933e5f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:18 +0100 Subject: ASoC: wm8904: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8904.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 4d2d2b1380d5..a0f8a6263660 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -673,7 +673,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int sysclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -711,7 +711,7 @@ static int sysclk_event(struct snd_soc_dapm_widget *w, static int out_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); int reg, val; int dcs_mask; -- cgit From 11e5e79af8eb1ace533d49495f9da9e6f8718545 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:19 +0100 Subject: ASoC: wm8955: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8955.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index 1173f7fef5a7..1ab2d462afad 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c @@ -333,7 +333,7 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec) static int wm8955_sysclk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); int ret = 0; /* Always disable the clocks - if we're doing reconfiguration this -- cgit From 32a4b446c5ecebd7d92526364ea26ed73fafd0b8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:20 +0100 Subject: ASoC: wm8961: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8958-dsp2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index 3cbc82b33292..c799cca5abeb 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -418,7 +418,7 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) int wm8958_aif_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); int i; switch (event) { -- cgit From 0e13064d91414bc49e98a916d9a4ded041404868 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:21 +0100 Subject: ASoC: wm8961: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8961.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c index eeffd05384b4..95e2c1bfc809 100644 --- a/sound/soc/codecs/wm8961.c +++ b/sound/soc/codecs/wm8961.c @@ -194,7 +194,7 @@ static bool wm8961_readable(struct device *dev, unsigned int reg) static int wm8961_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u16 hp_reg = snd_soc_read(codec, WM8961_ANALOGUE_HP_0); u16 cp_reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_1); u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); @@ -286,7 +286,7 @@ static int wm8961_hp_event(struct snd_soc_dapm_widget *w, static int wm8961_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); u16 spk_reg = snd_soc_read(codec, WM8961_CLASS_D_CONTROL_1); -- cgit From 6374b19de61ce023878d485b990cece1f146a754 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:22 +0100 Subject: ASoC: wm8962: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8962.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index d32d554f5b34..118b0034ba23 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -1866,7 +1866,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); int timeout; int reg; int expected = (WM8962_DCS_STARTUP_DONE_HP1L | @@ -1960,7 +1960,7 @@ static int hp_event(struct snd_soc_dapm_widget *w, static int out_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); int reg; switch (w->shift) { @@ -1993,7 +1993,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, static int dsp2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); switch (event) { -- cgit From 8b39dd9f08a824f1d855f69a69855c962579619d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:23 +0100 Subject: ASoC: wm8988: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8988.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index e418199155a8..baff2cc222a6 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c @@ -244,7 +244,7 @@ SOC_DOUBLE_R_TLV("Output 2 Playback Volume", WM8988_LOUT2V, WM8988_ROUT2V, static int wm8988_lrc_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u16 adctl2 = snd_soc_read(codec, WM8988_ADCTL2); /* Use the DAC to gate LRC if active, otherwise use ADC */ -- cgit From 68ca2f682e8b7ab9223f833877f29970e4e10003 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:24 +0100 Subject: ASoC: wm8990: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8990.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 8a584229310a..c93bffcb3cfb 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -374,13 +374,14 @@ SOC_SINGLE("RIN34 Mute Switch", WM8990_RIGHT_LINE_INPUT_3_4_VOLUME, static int outmixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u32 reg_shift = kcontrol->private_value & 0xfff; int ret = 0; u16 reg; switch (reg_shift) { case WM8990_SPEAKER_MIXER | (WM8990_LDSPK_BIT << 8) : - reg = snd_soc_read(w->codec, WM8990_OUTPUT_MIXER1); + reg = snd_soc_read(codec, WM8990_OUTPUT_MIXER1); if (reg & WM8990_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -388,7 +389,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_SPEAKER_MIXER | (WM8990_RDSPK_BIT << 8): - reg = snd_soc_read(w->codec, WM8990_OUTPUT_MIXER2); + reg = snd_soc_read(codec, WM8990_OUTPUT_MIXER2); if (reg & WM8990_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -396,7 +397,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_OUTPUT_MIXER1 | (WM8990_LDLO_BIT << 8): - reg = snd_soc_read(w->codec, WM8990_SPEAKER_MIXER); + reg = snd_soc_read(codec, WM8990_SPEAKER_MIXER); if (reg & WM8990_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -404,7 +405,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_OUTPUT_MIXER2 | (WM8990_RDRO_BIT << 8): - reg = snd_soc_read(w->codec, WM8990_SPEAKER_MIXER); + reg = snd_soc_read(codec, WM8990_SPEAKER_MIXER); if (reg & WM8990_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); -- cgit From f3b4d68fc21cc536f4f6b4b539864e33eca00bc0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:25 +0100 Subject: ASoC: wm8991: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8991.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index b0ac2c3e31b9..49df0dc607e6 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c @@ -382,13 +382,14 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = { static int outmixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u32 reg_shift = kcontrol->private_value & 0xfff; int ret = 0; u16 reg; switch (reg_shift) { case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8): - reg = snd_soc_read(w->codec, WM8991_OUTPUT_MIXER1); + reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER1); if (reg & WM8991_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -397,7 +398,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break; case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8): - reg = snd_soc_read(w->codec, WM8991_OUTPUT_MIXER2); + reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER2); if (reg & WM8991_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -406,7 +407,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break; case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8): - reg = snd_soc_read(w->codec, WM8991_SPEAKER_MIXER); + reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER); if (reg & WM8991_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -415,7 +416,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break; case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8): - reg = snd_soc_read(w->codec, WM8991_SPEAKER_MIXER); + reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER); if (reg & WM8991_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); -- cgit From 07276572e639793565333baac16de48e4c55ed7f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:26 +0100 Subject: ASoC: wm8993: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8993.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index 53c6fe359496..2e70a270eb28 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c @@ -810,7 +810,7 @@ SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv), static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: -- cgit From 12e3080c4fd849d7da139b536844fa3378188a58 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:27 +0100 Subject: ASoC: wm8995: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8994.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 1b97de2e4e67..4fbc7689339a 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -249,7 +249,8 @@ static int configure_clock(struct snd_soc_codec *codec) static int check_clk_sys(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - int reg = snd_soc_read(source->codec, WM8994_CLOCKING_1); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + int reg = snd_soc_read(codec, WM8994_CLOCKING_1); const char *clk; /* Check what we're currently using for CLK_SYS */ @@ -806,7 +807,7 @@ static void active_dereference(struct snd_soc_codec *codec) static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -981,7 +982,7 @@ static void vmid_dereference(struct snd_soc_codec *codec) static int vmid_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1037,7 +1038,7 @@ static bool wm8994_check_class_w_digital(struct snd_soc_codec *codec) static int aif1clk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994 *control = wm8994->wm8994; int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA; @@ -1135,7 +1136,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, static int aif2clk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); int i; int dac; int adc; @@ -1220,7 +1221,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, static int aif1clk_late_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -1238,7 +1239,7 @@ static int aif1clk_late_ev(struct snd_soc_dapm_widget *w, static int aif2clk_late_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -1256,7 +1257,7 @@ static int aif2clk_late_ev(struct snd_soc_dapm_widget *w, static int late_enable_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -1289,7 +1290,7 @@ static int late_enable_ev(struct snd_soc_dapm_widget *w, static int late_disable_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -1331,7 +1332,7 @@ static int micbias_ev(struct snd_soc_dapm_widget *w, static int dac_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int mask = 1 << w->shift; snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, @@ -1372,7 +1373,7 @@ SOC_DAPM_SINGLE("DAC1 Switch", WM8994_SPEAKER_MIXER, 0, 1, 0), static int post_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); dev_dbg(codec->dev, "SRC status: %x\n", snd_soc_read(codec, WM8994_RATE_STATUS)); -- cgit From 9887adf1d00456f7988e8c425309181adac06a06 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:28 +0100 Subject: ASoC: wm8995: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8995.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index c280f0a3a424..79e1aead5131 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c @@ -534,10 +534,11 @@ static void wm8995_update_class_w(struct snd_soc_codec *codec) static int check_clk_sys(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg; const char *clk; - reg = snd_soc_read(source->codec, WM8995_CLOCKING_1); + reg = snd_soc_read(codec, WM8995_CLOCKING_1); /* Check what we're currently using for CLK_SYS */ if (reg & WM8995_SYSCLK_SRC) clk = "AIF2CLK"; @@ -560,9 +561,7 @@ static int wm8995_put_class_w(struct snd_kcontrol *kcontrol, static int hp_supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec; - - codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -611,10 +610,9 @@ static void dc_servo_cmd(struct snd_soc_codec *codec, static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int reg; - codec = w->codec; reg = snd_soc_read(codec, WM8995_ANALOGUE_HP_1); switch (event) { @@ -761,9 +759,7 @@ static int configure_clock(struct snd_soc_codec *codec) static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec; - - codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: -- cgit From 00748490f7ada5117bb18a4ed5df6b9a9ab50881 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:29 +0100 Subject: ASoC: wm8996: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8996.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index b1dcc11c1b23..dc92d5e4e942 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -599,7 +599,7 @@ static void wm8996_bg_disable(struct snd_soc_codec *codec) static int bg_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); int ret = 0; switch (event) { @@ -634,7 +634,8 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int rmv_short_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); /* Record which outputs we enabled */ switch (event) { @@ -758,7 +759,8 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, static int dcs_start(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); switch (event) { case SND_SOC_DAPM_POST_PMU: -- cgit From 8643707fb87a9801307d2c64b6a10a71a5294936 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:30 +0100 Subject: ASoC: wm8997: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8997.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 7e8bfe27566b..0760ede0a6e5 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -84,7 +84,7 @@ static const struct reg_default wm8997_sysclk_reva_patch[] = { static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct arizona *arizona = dev_get_drvdata(codec->dev->parent); struct regmap *regmap = arizona->regmap; const struct reg_default *patch = NULL; -- cgit From 8a8a84e6b9d83c03126e01e372c95f2d37ba5b80 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:31 +0100 Subject: ASoC: wm9081: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm9081.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index b1d946facd57..13a3f335ea5b 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -734,7 +734,7 @@ static int configure_clock(struct snd_soc_codec *codec) static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); /* This should be done on init() for bypass paths */ -- cgit From 0a3042d7835bb37d8a5ed318d1ec3bd66224eaf7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:32 +0100 Subject: ASoC: wm9090: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm9090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c index 6ffe8dc4f3fa..60d243c904f5 100644 --- a/sound/soc/codecs/wm9090.c +++ b/sound/soc/codecs/wm9090.c @@ -254,7 +254,7 @@ SOC_SINGLE_TLV("MIXOUTR IN2B Volume", WM9090_OUTPUT_MIXER4, 0, 3, 1, static int hp_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int reg = snd_soc_read(codec, WM9090_ANALOGUE_HP_0); switch (event) { -- cgit From ff70508a8a795111b4bcc5de540f6e8073a05f14 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:33 +0100 Subject: ASoC: wm9713: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm9713.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 71b9d5b0734d..e5807de796cd 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -217,7 +217,7 @@ SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u16 status, rate; if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD)) -- cgit From 72718517b46fea686d93483ff0f5d4fa05d4de2e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:34 +0100 Subject: ASoC: wm_adsp: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm_adsp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 720d6e852986..ff67b334065b 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1373,7 +1373,7 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); struct wm_adsp *dsp = &dsps[w->shift]; struct wm_adsp_alg_region *alg_region; @@ -1605,7 +1605,7 @@ err: int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); struct wm_adsp *dsp = &dsps[w->shift]; @@ -1626,7 +1626,7 @@ EXPORT_SYMBOL_GPL(wm_adsp2_early_event); int wm_adsp2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); struct wm_adsp *dsp = &dsps[w->shift]; struct wm_adsp_alg_region *alg_region; -- cgit From 0201e5052157d82144ff272f56c9eb27f151cddc Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Jan 2015 10:27:35 +0100 Subject: ASoC: wm_hubs: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm_hubs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index 374537d5e179..8366e19657a7 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c @@ -500,7 +500,7 @@ SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1, static int hp_supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -542,7 +542,7 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w, static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0); switch (event) { @@ -594,7 +594,7 @@ static int hp_event(struct snd_soc_dapm_widget *w, static int earpiece_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *control, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; switch (event) { @@ -619,7 +619,7 @@ static int earpiece_event(struct snd_soc_dapm_widget *w, static int lineout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *control, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); bool *flag; @@ -649,7 +649,7 @@ static int lineout_event(struct snd_soc_dapm_widget *w, static int micbias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); switch (w->shift) { -- cgit From a0a7c48fe1a6dc6cae7c589640443bbaaddc28b3 Mon Sep 17 00:00:00 2001 From: Jie Yang Date: Mon, 12 Jan 2015 17:17:34 +0800 Subject: ASoC: Intel: initial stream_hw_id to invalid value The stream_hw_id for System stream is 0x0, if we use initial stream_hw_id value 0, it may return wrong(not committed) stream when calling function get_stream_by_id() with stream_id=0. Here initial stream_hw_id to invalid value to fix this issue. Signed-off-by: Jie Yang Signed-off-by: Mark Brown --- sound/soc/intel/sst-haswell-ipc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c index 3f8c48231364..083292362da6 100644 --- a/sound/soc/intel/sst-haswell-ipc.c +++ b/sound/soc/intel/sst-haswell-ipc.c @@ -94,6 +94,8 @@ /* Mailbox */ #define IPC_MAX_MAILBOX_BYTES 256 +#define INVALID_STREAM_HW_ID 0xffffffff + /* Global Message - Types and Replies */ enum ipc_glb_type { IPC_GLB_GET_FW_VERSION = 0, /* Retrieves firmware version */ @@ -1208,6 +1210,7 @@ struct sst_hsw_stream *sst_hsw_stream_new(struct sst_hsw *hsw, int id, return NULL; spin_lock_irqsave(&sst->spinlock, flags); + stream->reply.stream_hw_id = INVALID_STREAM_HW_ID; list_add(&stream->node, &hsw->stream_list); stream->notify_position = notify_position; stream->pdata = data; -- cgit From fd4e8dde42bb142448e3fd7dc6094cb2707d3b64 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Wed, 14 Jan 2015 23:11:43 -0800 Subject: sound/oss: use current->state helpers Call __set_current_state() instead of assigning the new state directly. These interfaces also aid CONFIG_DEBUG_ATOMIC_SLEEP environments, keeping track of who changed the state. Signed-off-by: Davidlohr Bueso Signed-off-by: Takashi Iwai --- sound/oss/msnd_pinnacle.c | 4 ++-- sound/oss/swarm_cs4297a.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c index c23f9f95bfa5..a8ceef8d1a8d 100644 --- a/sound/oss/msnd_pinnacle.c +++ b/sound/oss/msnd_pinnacle.c @@ -675,7 +675,7 @@ static void dsp_write_flush(void) timeout); clear_bit(F_WRITEFLUSH, &dev.flags); if (!signal_pending(current)) { - current->state = TASK_INTERRUPTIBLE; + __set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(get_play_delay_jiffies(DAP_BUFF_SIZE)); } clear_bit(F_WRITING, &dev.flags); @@ -1288,7 +1288,7 @@ static int __init calibrate_adc(WORD srate) & ~0x0001, dev.SMA + SMA_wCurrHostStatusFlags); if (msnd_send_word(&dev, 0, 0, HDEXAR_CAL_A_TO_D) == 0 && chk_send_dsp_cmd(&dev, HDEX_AUX_REQ) == 0) { - current->state = TASK_INTERRUPTIBLE; + __set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(HZ / 3); return 0; } diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c index a33e8ce8085b..213a416b6e0b 100644 --- a/sound/oss/swarm_cs4297a.c +++ b/sound/oss/swarm_cs4297a.c @@ -1654,7 +1654,7 @@ static int drain_dac(struct cs4297a_state *s, int nonblock) s->dma_dac.hwptr = s->dma_dac.swptr = hwptr; spin_unlock_irqrestore(&s->lock, flags); remove_wait_queue(&s->dma_dac.wait, &wait); - current->state = TASK_RUNNING; + __set_current_state(TASK_RUNNING); return 0; } -- cgit From ffcd28d88e4f3bdb2c300e4a13e973cd2070968e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 15 Jan 2015 10:11:52 +0100 Subject: ALSA: hda - Select INPUT for Realtek HD-audio codec The commit commit [33f4acd3b214: ALSA: hda - Enable mic mute hotkey and LEDs for an HP machine] introduced a quirk for a HP machine involving with the input event handling. Although the relevant code is protected via IS_ENABLED(CONFIG_INPUT), this doesn't suffice when the audio driver is built in while the input is module. As an easy workaround, this patch forcibly selects CONFIG_INPUT in Kconfig. This shouldn't be a practical problem since CONFIG_INPUT is almost mandatory for all systems. Also, this allows to remove the ugly ifdefs in the code. Fixes: 33f4acd3b214 ('ALSA: hda - Enable mic mute hotkey and LEDs for an HP machine') Acked-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/Kconfig | 1 + sound/pci/hda/patch_realtek.c | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index ebf4c2fb99df..7f0f2c5a4e97 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig @@ -107,6 +107,7 @@ config SND_HDA_PATCH_LOADER config SND_HDA_CODEC_REALTEK tristate "Build Realtek HD-audio codec support" select SND_HDA_GENERIC + select INPUT help Say Y or M here to include Realtek HD-audio codec support in snd-hda-intel driver, such as ALC880. diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index a50e15e166c6..1720f8a457d1 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -121,9 +121,7 @@ struct alc_spec { hda_nid_t pll_nid; unsigned int pll_coef_idx, pll_coef_bit; unsigned int coef0; -#if IS_ENABLED(CONFIG_INPUT) struct input_dev *kb_dev; -#endif }; /* @@ -3476,7 +3474,6 @@ static void alc280_fixup_hp_gpio4(struct hda_codec *codec, } } -#if IS_ENABLED(CONFIG_INPUT) static void gpio2_mic_hotkey_event(struct hda_codec *codec, struct hda_jack_callback *event) { @@ -3489,12 +3486,10 @@ static void gpio2_mic_hotkey_event(struct hda_codec *codec, input_report_key(spec->kb_dev, KEY_MICMUTE, 0); input_sync(spec->kb_dev); } -#endif static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec, const struct hda_fixup *fix, int action) { -#if IS_ENABLED(CONFIG_INPUT) /* GPIO1 = set according to SKU external amp GPIO2 = mic mute hotkey GPIO3 = mute LED @@ -3550,7 +3545,6 @@ static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec, input_unregister_device(spec->kb_dev); spec->kb_dev = NULL; } -#endif } static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, -- cgit From 70462457ff80c214d87135380d2dffe646867e71 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Thu, 15 Jan 2015 19:22:19 +0900 Subject: ALSA: hda - Fix typo in hda_controller.c This patch fix spelling typo in hda_controller.c. Signed-off-by: Masanari Iida Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 0cfc9c8c4b4e..657b604e1a2b 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -1993,4 +1993,4 @@ void azx_notifier_unregister(struct azx *chip) EXPORT_SYMBOL_GPL(azx_notifier_unregister); MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Common HDA driver funcitons"); +MODULE_DESCRIPTION("Common HDA driver functions"); -- cgit From a465122ae388c4951d1b39ed0186e82c1f5bcfb0 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Thu, 15 Jan 2015 19:29:28 +0900 Subject: ASoC: Fix typo in bt-sco.c This patch fix spelling typo in bt-sco.c Signed-off-by: Masanari Iida Signed-off-by: Mark Brown --- sound/soc/codecs/bt-sco.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/bt-sco.c b/sound/soc/codecs/bt-sco.c index 5075bf0a7276..e7238b8904bc 100644 --- a/sound/soc/codecs/bt-sco.c +++ b/sound/soc/codecs/bt-sco.c @@ -86,5 +86,5 @@ static struct platform_driver bt_sco_driver = { module_platform_driver(bt_sco_driver); MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_DESCRIPTION("ASoC generic bluethooth sco link driver"); +MODULE_DESCRIPTION("ASoC generic bluetooth sco link driver"); MODULE_LICENSE("GPL"); -- cgit From 798cbb400aa0198f8ed5aa0a0b0691985885e14c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:02:24 +0000 Subject: ASoC: rsnd: remove unsed .rate rsnd_ssi::rate is not used. Let's remove it Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 3844fbef4664..df10585dd325 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -70,7 +70,6 @@ struct rsnd_ssi { u32 cr_clk; int err; unsigned int usrcnt; - unsigned int rate; }; #define for_each_rsnd_ssi(pos, priv, i) \ @@ -157,7 +156,6 @@ static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi, ret = rsnd_adg_ssi_clk_try_start(&ssi->mod, main_rate); if (0 == ret) { - ssi->rate = rate; ssi->cr_clk = FORCE | SWL_32 | SCKD | SWSD | CKDV(j); @@ -176,7 +174,6 @@ static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi, static void rsnd_ssi_master_clk_stop(struct rsnd_ssi *ssi) { - ssi->rate = 0; ssi->cr_clk = 0; rsnd_adg_ssi_clk_stop(&ssi->mod); } -- cgit From 9d0e202f1314cb4a88bf7e04a6ba017d1a1910dc Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:02:40 +0000 Subject: ASoC: rsnd: tidyup rsnd_io_to_xxx() macro declaration position Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/rsnd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index c45700380e59..ff191cfbdcf6 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -286,6 +286,8 @@ struct rsnd_dai_stream { #define rsnd_io_to_mod_ssi(io) ((io)->mod[RSND_MOD_SSI]) #define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC]) #define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC]) +#define rsnd_io_to_runtime(io) ((io)->substream ? \ + (io)->substream->runtime : NULL) struct rsnd_dai { char name[RSND_DAI_NAME_SIZE]; @@ -311,8 +313,6 @@ struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id); int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io); int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai); #define rsnd_dai_get_platform_info(rdai) ((rdai)->info) -#define rsnd_io_to_runtime(io) ((io)->substream ? \ - (io)->substream->runtime : NULL) void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt); int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional); -- cgit From 8564295231727c4a05ed2e9b8337fe70afe531ef Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:03:22 +0000 Subject: ASoC: rsnd: rsnd_mod controls clock Current rsnd driver's mod (= ssi/src/dvc) have each own clk, but, these are needed to start/stop each mod. This patch adds struct clk in rsnd_mod, and start/stop these via rsnd_mod_hw_start/stop() macro Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 2 ++ sound/soc/sh/rcar/dvc.c | 12 ++++-------- sound/soc/sh/rcar/rsnd.h | 4 ++++ sound/soc/sh/rcar/src.c | 8 +++----- sound/soc/sh/rcar/ssi.c | 8 +++----- 5 files changed, 16 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index d9c81cda09f7..766bd4ce439b 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -152,6 +152,7 @@ char *rsnd_mod_dma_name(struct rsnd_mod *mod) void rsnd_mod_init(struct rsnd_priv *priv, struct rsnd_mod *mod, struct rsnd_mod_ops *ops, + struct clk *clk, enum rsnd_mod_type type, int id) { @@ -159,6 +160,7 @@ void rsnd_mod_init(struct rsnd_priv *priv, mod->id = id; mod->ops = ops; mod->type = type; + mod->clk = clk; } /* diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 5380a4827ba7..77cb00890471 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -17,7 +17,6 @@ struct rsnd_dvc { struct rsnd_dvc_platform_info *info; /* rcar_snd.h */ struct rsnd_mod mod; - struct clk *clk; struct rsnd_kctrl_cfg_m volume; struct rsnd_kctrl_cfg_m mute; struct rsnd_kctrl_cfg_s ren; /* Ramp Enable */ @@ -132,7 +131,6 @@ static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod, static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, struct rsnd_dai *rdai) { - struct rsnd_dvc *dvc = rsnd_mod_to_dvc(dvc_mod); struct rsnd_dai_stream *io = rsnd_mod_to_io(dvc_mod); struct rsnd_priv *priv = rsnd_mod_to_priv(dvc_mod); struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io); @@ -153,7 +151,7 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, return -EINVAL; } - clk_prepare_enable(dvc->clk); + rsnd_mod_hw_start(dvc_mod); /* * fixme @@ -181,9 +179,7 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, static int rsnd_dvc_quit(struct rsnd_mod *mod, struct rsnd_dai *rdai) { - struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); - - clk_disable_unprepare(dvc->clk); + rsnd_mod_hw_stop(mod); return 0; } @@ -356,9 +352,9 @@ int rsnd_dvc_probe(struct platform_device *pdev, return PTR_ERR(clk); dvc->info = &info->dvc_info[i]; - dvc->clk = clk; - rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops, RSND_MOD_DVC, i); + rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops, + clk, RSND_MOD_DVC, i); dev_dbg(dev, "CMD%d probed\n", i); } diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index ff191cfbdcf6..d8c31170b491 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -226,6 +226,7 @@ struct rsnd_mod { struct rsnd_mod_ops *ops; struct rsnd_dma dma; struct rsnd_dai_stream *io; + struct clk *clk; u32 status; }; /* @@ -261,10 +262,13 @@ struct rsnd_mod { #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) #define rsnd_mod_to_io(mod) ((mod)->io) #define rsnd_mod_id(mod) ((mod)->id) +#define rsnd_mod_hw_start(mod) clk_prepare_enable((mod)->clk) +#define rsnd_mod_hw_stop(mod) clk_disable_unprepare((mod)->clk) void rsnd_mod_init(struct rsnd_priv *priv, struct rsnd_mod *mod, struct rsnd_mod_ops *ops, + struct clk *clk, enum rsnd_mod_type type, int id); char *rsnd_mod_name(struct rsnd_mod *mod); diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 648b35e7effc..6a3fd8dce1c3 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -22,7 +22,6 @@ struct rsnd_src { struct rsnd_src_platform_info *info; /* rcar_snd.h */ struct rsnd_mod mod; - struct clk *clk; int err; }; @@ -286,7 +285,7 @@ static int rsnd_src_init(struct rsnd_mod *mod, { struct rsnd_src *src = rsnd_mod_to_src(mod); - clk_prepare_enable(src->clk); + rsnd_mod_hw_start(mod); src->err = 0; @@ -306,7 +305,7 @@ static int rsnd_src_quit(struct rsnd_mod *mod, struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); - clk_disable_unprepare(src->clk); + rsnd_mod_hw_stop(mod); if (src->err) dev_warn(dev, "src under/over flow err = %d\n", src->err); @@ -902,9 +901,8 @@ int rsnd_src_probe(struct platform_device *pdev, return PTR_ERR(clk); src->info = &info->src_info[i]; - src->clk = clk; - rsnd_mod_init(priv, &src->mod, ops, RSND_MOD_SRC, i); + rsnd_mod_init(priv, &src->mod, ops, clk, RSND_MOD_SRC, i); dev_dbg(dev, "SRC%d probed\n", i); } diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index df10585dd325..a55b96399ada 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -60,7 +60,6 @@ #define SSI_NAME "ssi" struct rsnd_ssi { - struct clk *clk; struct rsnd_ssi_platform_info *info; /* rcar_snd.h */ struct rsnd_ssi *parent; struct rsnd_mod mod; @@ -188,7 +187,7 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, u32 cr; if (0 == ssi->usrcnt) { - clk_prepare_enable(ssi->clk); + rsnd_mod_hw_start(&ssi->mod); if (rsnd_dai_is_clk_master(rdai)) { if (rsnd_ssi_clk_from_parent(ssi)) @@ -260,7 +259,7 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi, rsnd_ssi_master_clk_stop(ssi); } - clk_disable_unprepare(ssi->clk); + rsnd_mod_hw_stop(&ssi->mod); } dev_dbg(dev, "%s[%d] hw stopped\n", @@ -731,7 +730,6 @@ int rsnd_ssi_probe(struct platform_device *pdev, return PTR_ERR(clk); ssi->info = pinfo; - ssi->clk = clk; ops = &rsnd_ssi_non_ops; if (pinfo->dma_id > 0) @@ -739,7 +737,7 @@ int rsnd_ssi_probe(struct platform_device *pdev, else if (rsnd_ssi_pio_available(ssi)) ops = &rsnd_ssi_pio_ops; - rsnd_mod_init(priv, &ssi->mod, ops, RSND_MOD_SSI, i); + rsnd_mod_init(priv, &ssi->mod, ops, clk, RSND_MOD_SSI, i); rsnd_ssi_parent_clk_setup(priv, ssi); } -- cgit From 710d088923856bb0e0369e675985047a51ba729c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:03:38 +0000 Subject: ASoC: rsnd: rename rsnd_dai_get() to rsnd_rdai_get() struct rsnd_dai is called as "rdai", and struct snd_soc_dai is called as "dai" on this driver. but macro/function have confusable naming. This patch rename rsnd_dai_get() to rsnd_rdai_get() Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 4 ++-- sound/soc/sh/rcar/rsnd.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 766bd4ce439b..b4c25d661e3d 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -489,7 +489,7 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai) return id; } -struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id) +struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id) { if ((id < 0) || (id >= rsnd_rdai_nr(priv))) return NULL; @@ -501,7 +501,7 @@ static struct rsnd_dai *rsnd_dai_to_rdai(struct snd_soc_dai *dai) { struct rsnd_priv *priv = snd_soc_dai_get_drvdata(dai); - return rsnd_dai_get(priv, dai->id); + return rsnd_rdai_get(priv, dai->id); } int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index d8c31170b491..cd39f32acaa8 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -310,10 +310,11 @@ struct rsnd_dai { #define for_each_rsnd_dai(rdai, priv, i) \ for (i = 0; \ (i < rsnd_rdai_nr(priv)) && \ - ((rdai) = rsnd_dai_get(priv, i)); \ + ((rdai) = rsnd_rdai_get(priv, i)); \ i++) -struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id); +struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id); + int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io); int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai); #define rsnd_dai_get_platform_info(rdai) ((rdai)->info) -- cgit From 3ed6448c9509d2394532b2ed91db16fa1ef47447 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:04:51 +0000 Subject: ASoC: rsnd: rename rsnd_dai_is_clk_master() to rsnd_rdai_is_clk_master() struct rsnd_dai is called as "rdai", and struct snd_soc_dai is called as "dai" on this driver. but macro/function have confusable naming. This patch rename rsnd_dai_is_clk_master() to rsnd_rdai_is_clk_master() Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/rsnd.h | 2 +- sound/soc/sh/rcar/src.c | 2 +- sound/soc/sh/rcar/ssi.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index cd39f32acaa8..749b9779dd1e 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -307,6 +307,7 @@ struct rsnd_dai { }; #define rsnd_rdai_nr(priv) ((priv)->rdai_nr) +#define rsnd_rdai_is_clk_master(rdai) ((rdai)->clk_master) #define for_each_rsnd_dai(rdai, priv, i) \ for (i = 0; \ (i < rsnd_rdai_nr(priv)) && \ @@ -321,7 +322,6 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai); void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt); int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional); -#define rsnd_dai_is_clk_master(rdai) ((rdai)->clk_master) /* * R-Car Gen1/Gen2 diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 6a3fd8dce1c3..cb2dbf3b8569 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -147,7 +147,7 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, if (shift >= 0) rsnd_mod_bset(ssi_mod, SSI_MODE1, 0x3 << shift, - rsnd_dai_is_clk_master(rdai) ? + rsnd_rdai_is_clk_master(rdai) ? 0x2 << shift : 0x1 << shift); } diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index a55b96399ada..816178c71a6b 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -189,7 +189,7 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, if (0 == ssi->usrcnt) { rsnd_mod_hw_start(&ssi->mod); - if (rsnd_dai_is_clk_master(rdai)) { + if (rsnd_rdai_is_clk_master(rdai)) { if (rsnd_ssi_clk_from_parent(ssi)) rsnd_ssi_hw_start(ssi->parent, rdai, io); else @@ -210,7 +210,7 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, rsnd_mod_write(&ssi->mod, SSICR, cr); /* enable WS continue */ - if (rsnd_dai_is_clk_master(rdai)) + if (rsnd_rdai_is_clk_master(rdai)) rsnd_mod_write(&ssi->mod, SSIWSR, CONT); /* clear error status */ @@ -252,7 +252,7 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi, rsnd_mod_write(&ssi->mod, SSICR, cr); /* disabled all */ rsnd_ssi_status_check(&ssi->mod, IIRQ); - if (rsnd_dai_is_clk_master(rdai)) { + if (rsnd_rdai_is_clk_master(rdai)) { if (rsnd_ssi_clk_from_parent(ssi)) rsnd_ssi_hw_stop(ssi->parent, rdai); else -- cgit From 2842aa719252bbec99869b03dfc42c52a307877a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:05:10 +0000 Subject: ASoC: rsnd: remove unused rsnd_dai_id() rsnd_dai_id() was not used. Let's remove it Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 10 ---------- sound/soc/sh/rcar/rsnd.h | 1 - 2 files changed, 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index b4c25d661e3d..487ddf78b8ee 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -479,16 +479,6 @@ static void rsnd_dai_disconnect(struct rsnd_mod *mod, io->mod[mod->type] = NULL; } -int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai) -{ - int id = rdai - priv->rdai; - - if ((id < 0) || (id >= rsnd_rdai_nr(priv))) - return -EINVAL; - - return id; -} - struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id) { if ((id < 0) || (id >= rsnd_rdai_nr(priv))) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 749b9779dd1e..28a06fce794e 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -317,7 +317,6 @@ struct rsnd_dai { struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id); int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io); -int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai); #define rsnd_dai_get_platform_info(rdai) ((rdai)->info) void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt); -- cgit From 7c57d76f5181d50ae04adf92180c5d53dd3c9756 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:05:59 +0000 Subject: ASoC: rsnd: remove rsnd_dai_get_platform_info() macro rsnd_dai_get_platform_info() is not used. Let's remove it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 5 ++--- sound/soc/sh/rcar/rsnd.h | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 487ddf78b8ee..852fa0410afd 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -865,10 +865,9 @@ static int rsnd_dai_probe(struct platform_device *pdev, priv->rdai = rdai; for (i = 0; i < dai_nr; i++) { - rdai[i].info = &info->dai_info[i]; - pmod = rdai[i].info->playback.ssi; - cmod = rdai[i].info->capture.ssi; + pmod = info->dai_info[i].playback.ssi; + cmod = info->dai_info[i].capture.ssi; /* * init rsnd_dai diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 28a06fce794e..ad76870dba13 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -295,7 +295,6 @@ struct rsnd_dai_stream { struct rsnd_dai { char name[RSND_DAI_NAME_SIZE]; - struct rsnd_dai_platform_info *info; /* rcar_snd.h */ struct rsnd_dai_stream playback; struct rsnd_dai_stream capture; @@ -317,7 +316,6 @@ struct rsnd_dai { struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id); int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io); -#define rsnd_dai_get_platform_info(rdai) ((rdai)->info) void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt); int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional); -- cgit From 54cb556247b171753484efb3c4777ca4d1babfa0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:06:24 +0000 Subject: ASoC: rsnd: add rsnd_io_to_rdai() Current rsnd driver request rdai in everywhere, but each mod should reach to rdai by itself. this patch adds missing rsnd_io_to_rdai(). io = rsnd_mod_to_io(mod); rdai = rsnd_io_to_rdai(io); Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 2 ++ sound/soc/sh/rcar/rsnd.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 852fa0410afd..c8111857c9d9 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -886,6 +886,7 @@ static int rsnd_dai_probe(struct platform_device *pdev, drv[i].playback.channels_max = 2; rdai[i].playback.info = &info->dai_info[i].playback; + rdai[i].playback.rdai = rdai + i; rsnd_path_init(priv, &rdai[i], &rdai[i].playback); } if (cmod) { @@ -895,6 +896,7 @@ static int rsnd_dai_probe(struct platform_device *pdev, drv[i].capture.channels_max = 2; rdai[i].capture.info = &info->dai_info[i].capture; + rdai[i].capture.rdai = rdai + i; rsnd_path_init(priv, &rdai[i], &rdai[i].capture); } diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index ad76870dba13..0b5518259c28 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -282,6 +282,7 @@ struct rsnd_dai_stream { struct snd_pcm_substream *substream; struct rsnd_mod *mod[RSND_MOD_MAX]; struct rsnd_dai_path_info *info; /* rcar_snd.h */ + struct rsnd_dai *rdai; int byte_pos; int period_pos; int byte_per_period; @@ -290,6 +291,7 @@ struct rsnd_dai_stream { #define rsnd_io_to_mod_ssi(io) ((io)->mod[RSND_MOD_SSI]) #define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC]) #define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC]) +#define rsnd_io_to_rdai(io) ((io)->rdai) #define rsnd_io_to_runtime(io) ((io)->substream ? \ (io)->substream->runtime : NULL) -- cgit From 985a4f6e61560c4cba19d910a0d81757a1063571 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:06:49 +0000 Subject: ASoC: rsnd: replace rsnd_dai_is_play() to rsnd_io_is_play() Current rsnd driver can use rsnd_io_to_rdai() we can get play/capture direction via io now. Let's replace rsnd_dai_is_play() to rsnd_io_is_play() Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/adg.c | 2 +- sound/soc/sh/rcar/core.c | 5 ----- sound/soc/sh/rcar/dvc.c | 11 ++++++----- sound/soc/sh/rcar/rsnd.h | 4 ++-- sound/soc/sh/rcar/src.c | 2 +- sound/soc/sh/rcar/ssi.c | 4 ++-- 6 files changed, 12 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index 14d1a7193469..9d22c75b9b32 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c @@ -80,7 +80,7 @@ static int rsnd_adg_set_src_timsel_gen2(struct rsnd_dai *rdai, struct rsnd_dai_stream *io, u32 timsel) { - int is_play = rsnd_dai_is_play(rdai, io); + int is_play = rsnd_io_is_play(io); int id = rsnd_mod_id(mod); int shift = (id % 2) ? 16 : 0; u32 mask, ws; diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index c8111857c9d9..c1f577da41fe 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -494,11 +494,6 @@ static struct rsnd_dai *rsnd_dai_to_rdai(struct snd_soc_dai *dai) return rsnd_rdai_get(priv, dai->id); } -int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io) -{ - return &rdai->playback == io; -} - /* * rsnd_soc_dai functions */ diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 77cb00890471..225baa32bf0b 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -206,11 +206,12 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, { struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); + int is_play = rsnd_io_is_play(io); int ret; /* Volume */ ret = rsnd_kctrl_new_m(mod, rdai, rtd, - rsnd_dai_is_play(rdai, io) ? + is_play ? "DVC Out Playback Volume" : "DVC In Capture Volume", rsnd_dvc_volume_update, &dvc->volume, 0x00800000 - 1); @@ -219,7 +220,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, /* Mute */ ret = rsnd_kctrl_new_m(mod, rdai, rtd, - rsnd_dai_is_play(rdai, io) ? + is_play ? "DVC Out Mute Switch" : "DVC In Mute Switch", rsnd_dvc_volume_update, &dvc->mute, 1); @@ -228,7 +229,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, /* Ramp */ ret = rsnd_kctrl_new_s(mod, rdai, rtd, - rsnd_dai_is_play(rdai, io) ? + is_play ? "DVC Out Ramp Switch" : "DVC In Ramp Switch", rsnd_dvc_volume_update, &dvc->ren, 1); @@ -236,7 +237,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, return ret; ret = rsnd_kctrl_new_e(mod, rdai, rtd, - rsnd_dai_is_play(rdai, io) ? + is_play ? "DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate", &dvc->rup, rsnd_dvc_volume_update, @@ -245,7 +246,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, return ret; ret = rsnd_kctrl_new_e(mod, rdai, rtd, - rsnd_dai_is_play(rdai, io) ? + is_play ? "DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate", &dvc->rdown, rsnd_dvc_volume_update, diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 0b5518259c28..83eb46c35e94 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -292,9 +292,11 @@ struct rsnd_dai_stream { #define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC]) #define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC]) #define rsnd_io_to_rdai(io) ((io)->rdai) +#define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io) #define rsnd_io_to_runtime(io) ((io)->substream ? \ (io)->substream->runtime : NULL) + struct rsnd_dai { char name[RSND_DAI_NAME_SIZE]; struct rsnd_dai_stream playback; @@ -317,8 +319,6 @@ struct rsnd_dai { struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id); -int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io); - void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt); int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional); diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index cb2dbf3b8569..d4f9cccfff55 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -362,7 +362,7 @@ static int rsnd_src_set_route_gen1(struct rsnd_mod *mod, /* * SRC_ROUTE_SELECT */ - val = rsnd_dai_is_play(rdai, io) ? 0x1 : 0x2; + val = rsnd_io_is_play(io) ? 0x1 : 0x2; val = val << routes[id].shift; mask = routes[id].mask << routes[id].shift; diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 816178c71a6b..b9d33b985845 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -307,7 +307,7 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, cr |= SDTA; if (rdai->sys_delay) cr |= DEL; - if (rsnd_dai_is_play(rdai, io)) + if (rsnd_io_is_play(io)) cr |= TRMD; /* @@ -401,7 +401,7 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data) * directly as 32bit data * see rsnd_ssi_init() */ - if (rsnd_dai_is_play(rdai, io)) + if (rsnd_io_is_play(io)) rsnd_mod_write(mod, SSITDR, *buf); else *buf = rsnd_mod_read(mod, SSIRDR); -- cgit From f708d944fee384961f5ab7df3463760099c9d69c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:07:19 +0000 Subject: ASoC: rsnd: remove unsed rdai parameter from each function Current rsnd driver's many functions requests struct rsnd_dai (= rdai), but, 1) we can get rdai from rsnd_io_to_rsnd(), 2) almost all rdai is not used. Let's remove these rdai. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/adg.c | 12 ++++------- sound/soc/sh/rcar/core.c | 19 +++++++---------- sound/soc/sh/rcar/dvc.c | 12 +++++------ sound/soc/sh/rcar/rsnd.h | 18 ++++------------ sound/soc/sh/rcar/src.c | 54 ++++++++++++++++++++---------------------------- sound/soc/sh/rcar/ssi.c | 28 ++++++++++++------------- 6 files changed, 56 insertions(+), 87 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index 9d22c75b9b32..7ac35c9d1cb8 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c @@ -57,8 +57,7 @@ static u32 rsnd_adg_ssi_ws_timing_gen2(struct rsnd_dai_stream *io) return (0x6 + ws) << 8; } -int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_dai *rdai, - struct rsnd_mod *mod, +int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod, struct rsnd_dai_stream *io) { int id = rsnd_mod_id(mod); @@ -75,8 +74,7 @@ int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_dai *rdai, return 0; } -static int rsnd_adg_set_src_timsel_gen2(struct rsnd_dai *rdai, - struct rsnd_mod *mod, +static int rsnd_adg_set_src_timsel_gen2(struct rsnd_mod *mod, struct rsnd_dai_stream *io, u32 timsel) { @@ -122,7 +120,6 @@ static int rsnd_adg_set_src_timsel_gen2(struct rsnd_dai *rdai, } int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct rsnd_dai_stream *io, unsigned int src_rate, unsigned int dst_rate) @@ -178,7 +175,7 @@ int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod, return -EIO; } - ret = rsnd_adg_set_src_timsel_gen2(rdai, mod, io, val); + ret = rsnd_adg_set_src_timsel_gen2(mod, io, val); if (ret < 0) { dev_err(dev, "timsel error\n"); return ret; @@ -190,12 +187,11 @@ int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod, } int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct rsnd_dai_stream *io) { u32 val = rsnd_adg_ssi_ws_timing_gen2(io); - return rsnd_adg_set_src_timsel_gen2(rdai, mod, io, val); + return rsnd_adg_set_src_timsel_gen2(mod, io, val); } int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv, diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index c1f577da41fe..74e2c4214058 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1025,7 +1025,6 @@ static int rsnd_kctrl_put(struct snd_kcontrol *kctrl, } static int __rsnd_kctrl_new(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, struct rsnd_kctrl_cfg *cfg, @@ -1057,7 +1056,6 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod, } int rsnd_kctrl_new_m(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, void (*update)(struct rsnd_mod *mod), @@ -1067,11 +1065,10 @@ int rsnd_kctrl_new_m(struct rsnd_mod *mod, _cfg->cfg.max = max; _cfg->cfg.size = RSND_DVC_CHANNELS; _cfg->cfg.val = _cfg->val; - return __rsnd_kctrl_new(mod, rdai, rtd, name, &_cfg->cfg, update); + return __rsnd_kctrl_new(mod, rtd, name, &_cfg->cfg, update); } int rsnd_kctrl_new_s(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, void (*update)(struct rsnd_mod *mod), @@ -1081,11 +1078,10 @@ int rsnd_kctrl_new_s(struct rsnd_mod *mod, _cfg->cfg.max = max; _cfg->cfg.size = 1; _cfg->cfg.val = &_cfg->val; - return __rsnd_kctrl_new(mod, rdai, rtd, name, &_cfg->cfg, update); + return __rsnd_kctrl_new(mod, rtd, name, &_cfg->cfg, update); } int rsnd_kctrl_new_e(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, struct rsnd_kctrl_cfg_s *_cfg, @@ -1097,7 +1093,7 @@ int rsnd_kctrl_new_e(struct rsnd_mod *mod, _cfg->cfg.size = 1; _cfg->cfg.val = &_cfg->val; _cfg->cfg.texts = texts; - return __rsnd_kctrl_new(mod, rdai, rtd, name, &_cfg->cfg, update); + return __rsnd_kctrl_new(mod, rtd, name, &_cfg->cfg, update); } /* @@ -1138,10 +1134,9 @@ static const struct snd_soc_component_driver rsnd_soc_component = { }; static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, - struct rsnd_dai *rdai, - int is_play) + struct rsnd_dai_stream *io) { - struct rsnd_dai_stream *io = is_play ? &rdai->playback : &rdai->capture; + struct rsnd_dai *rdai = rsnd_io_to_rdai(io); int ret; ret = rsnd_dai_call(probe, io, rdai); @@ -1241,11 +1236,11 @@ static int rsnd_probe(struct platform_device *pdev) } for_each_rsnd_dai(rdai, priv, i) { - ret = rsnd_rdai_continuance_probe(priv, rdai, 1); + ret = rsnd_rdai_continuance_probe(priv, &rdai->playback); if (ret) goto exit_snd_probe; - ret = rsnd_rdai_continuance_probe(priv, rdai, 0); + ret = rsnd_rdai_continuance_probe(priv, &rdai->capture); if (ret) goto exit_snd_probe; } diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 225baa32bf0b..e24db9e4ee25 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -171,7 +171,7 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, rsnd_mod_write(dvc_mod, DVC_DVUIR, 0); - rsnd_adg_set_cmd_timsel_gen2(rdai, dvc_mod, io); + rsnd_adg_set_cmd_timsel_gen2(dvc_mod, io); return 0; } @@ -210,7 +210,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, int ret; /* Volume */ - ret = rsnd_kctrl_new_m(mod, rdai, rtd, + ret = rsnd_kctrl_new_m(mod, rtd, is_play ? "DVC Out Playback Volume" : "DVC In Capture Volume", rsnd_dvc_volume_update, @@ -219,7 +219,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, return ret; /* Mute */ - ret = rsnd_kctrl_new_m(mod, rdai, rtd, + ret = rsnd_kctrl_new_m(mod, rtd, is_play ? "DVC Out Mute Switch" : "DVC In Mute Switch", rsnd_dvc_volume_update, @@ -228,7 +228,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, return ret; /* Ramp */ - ret = rsnd_kctrl_new_s(mod, rdai, rtd, + ret = rsnd_kctrl_new_s(mod, rtd, is_play ? "DVC Out Ramp Switch" : "DVC In Ramp Switch", rsnd_dvc_volume_update, @@ -236,7 +236,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, if (ret < 0) return ret; - ret = rsnd_kctrl_new_e(mod, rdai, rtd, + ret = rsnd_kctrl_new_e(mod, rtd, is_play ? "DVC Out Ramp Up Rate" : "DVC In Ramp Up Rate", &dvc->rup, @@ -245,7 +245,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, if (ret < 0) return ret; - ret = rsnd_kctrl_new_e(mod, rdai, rtd, + ret = rsnd_kctrl_new_e(mod, rtd, is_play ? "DVC Out Ramp Down Rate" : "DVC In Ramp Down Rate", &dvc->rdown, diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 83eb46c35e94..aaba717b8fd3 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -351,15 +351,12 @@ int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv, unsigned int src_rate, unsigned int dst_rate); int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct rsnd_dai_stream *io, unsigned int src_rate, unsigned int dst_rate); int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct rsnd_dai_stream *io); -int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_dai *rdai, - struct rsnd_mod *mod, +int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod, struct rsnd_dai_stream *io); /* @@ -453,21 +450,18 @@ struct rsnd_kctrl_cfg_s { }; int rsnd_kctrl_new_m(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, void (*update)(struct rsnd_mod *mod), struct rsnd_kctrl_cfg_m *_cfg, u32 max); int rsnd_kctrl_new_s(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, void (*update)(struct rsnd_mod *mod), struct rsnd_kctrl_cfg_s *_cfg, u32 max); int rsnd_kctrl_new_e(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, struct rsnd_kctrl_cfg_s *_cfg, @@ -486,14 +480,10 @@ unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, struct rsnd_dai_stream *io, struct snd_pcm_runtime *runtime); int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, - struct rsnd_dai *rdai, int use_busif); -int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod, - struct rsnd_dai *rdai); -int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod, - struct rsnd_dai *rdai); -int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod, - struct rsnd_dai *rdai); +int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod); +int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod); +int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod); #define rsnd_src_nr(priv) ((priv)->src_nr) diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index d4f9cccfff55..31e19a00655f 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -114,10 +114,10 @@ struct rsnd_src { * Gen1/Gen2 common functions */ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, - struct rsnd_dai *rdai, int use_busif) { struct rsnd_dai_stream *io = rsnd_mod_to_io(ssi_mod); + struct rsnd_dai *rdai = rsnd_io_to_rdai(io); struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); int ssi_id = rsnd_mod_id(ssi_mod); @@ -181,8 +181,7 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, return 0; } -int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod, - struct rsnd_dai *rdai) +int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod) { /* * DMA settings for SSIU @@ -192,8 +191,7 @@ int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod, return 0; } -int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod, - struct rsnd_dai *rdai) +int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod) { struct rsnd_priv *priv = rsnd_mod_to_priv(ssi_mod); @@ -209,8 +207,7 @@ int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod, return 0; } -int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod, - struct rsnd_dai *rdai) +int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod) { struct rsnd_priv *priv = rsnd_mod_to_priv(ssi_mod); @@ -247,8 +244,7 @@ unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, return rate; } -static int rsnd_src_set_convert_rate(struct rsnd_mod *mod, - struct rsnd_dai *rdai) +static int rsnd_src_set_convert_rate(struct rsnd_mod *mod) { struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); @@ -280,8 +276,7 @@ static int rsnd_src_set_convert_rate(struct rsnd_mod *mod, return 0; } -static int rsnd_src_init(struct rsnd_mod *mod, - struct rsnd_dai *rdai) +static int rsnd_src_init(struct rsnd_mod *mod) { struct rsnd_src *src = rsnd_mod_to_src(mod); @@ -333,8 +328,7 @@ static int rsnd_src_stop(struct rsnd_mod *mod) /* * Gen1 functions */ -static int rsnd_src_set_route_gen1(struct rsnd_mod *mod, - struct rsnd_dai *rdai) +static int rsnd_src_set_route_gen1(struct rsnd_mod *mod) { struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); struct src_route_config { @@ -371,8 +365,7 @@ static int rsnd_src_set_route_gen1(struct rsnd_mod *mod, return 0; } -static int rsnd_src_set_convert_timing_gen1(struct rsnd_mod *mod, - struct rsnd_dai *rdai) +static int rsnd_src_set_convert_timing_gen1(struct rsnd_mod *mod) { struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); struct rsnd_priv *priv = rsnd_mod_to_priv(mod); @@ -430,13 +423,12 @@ static int rsnd_src_set_convert_timing_gen1(struct rsnd_mod *mod, return 0; } -static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod, - struct rsnd_dai *rdai) +static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod) { struct rsnd_src *src = rsnd_mod_to_src(mod); int ret; - ret = rsnd_src_set_convert_rate(mod, rdai); + ret = rsnd_src_set_convert_rate(mod); if (ret < 0) return ret; @@ -473,19 +465,19 @@ static int rsnd_src_init_gen1(struct rsnd_mod *mod, { int ret; - ret = rsnd_src_init(mod, rdai); + ret = rsnd_src_init(mod); if (ret < 0) return ret; - ret = rsnd_src_set_route_gen1(mod, rdai); + ret = rsnd_src_set_route_gen1(mod); if (ret < 0) return ret; - ret = rsnd_src_set_convert_rate_gen1(mod, rdai); + ret = rsnd_src_set_convert_rate_gen1(mod); if (ret < 0) return ret; - ret = rsnd_src_set_convert_timing_gen1(mod, rdai); + ret = rsnd_src_set_convert_timing_gen1(mod); if (ret < 0) return ret; @@ -628,8 +620,7 @@ static irqreturn_t rsnd_src_interrupt_gen2(int irq, void *data) return IRQ_HANDLED; } -static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai) +static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod) { struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); @@ -653,7 +644,7 @@ static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod, return -EINVAL; } - ret = rsnd_src_set_convert_rate(mod, rdai); + ret = rsnd_src_set_convert_rate(mod); if (ret < 0) return ret; @@ -681,8 +672,7 @@ static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod, return 0; } -static int rsnd_src_set_convert_timing_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai) +static int rsnd_src_set_convert_timing_gen2(struct rsnd_mod *mod) { struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); @@ -691,11 +681,11 @@ static int rsnd_src_set_convert_timing_gen2(struct rsnd_mod *mod, int ret; if (convert_rate) - ret = rsnd_adg_set_convert_clk_gen2(mod, rdai, io, + ret = rsnd_adg_set_convert_clk_gen2(mod, io, runtime->rate, convert_rate); else - ret = rsnd_adg_set_convert_timing_gen2(mod, rdai, io); + ret = rsnd_adg_set_convert_timing_gen2(mod, io); return ret; } @@ -755,15 +745,15 @@ static int rsnd_src_init_gen2(struct rsnd_mod *mod, { int ret; - ret = rsnd_src_init(mod, rdai); + ret = rsnd_src_init(mod); if (ret < 0) return ret; - ret = rsnd_src_set_convert_rate_gen2(mod, rdai); + ret = rsnd_src_set_convert_rate_gen2(mod); if (ret < 0) return ret; - ret = rsnd_src_set_convert_timing_gen2(mod, rdai); + ret = rsnd_src_set_convert_timing_gen2(mod); if (ret < 0) return ret; diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index b9d33b985845..6e36c53e7b8f 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -64,7 +64,6 @@ struct rsnd_ssi { struct rsnd_ssi *parent; struct rsnd_mod mod; - struct rsnd_dai *rdai; u32 cr_own; u32 cr_clk; int err; @@ -178,10 +177,10 @@ static void rsnd_ssi_master_clk_stop(struct rsnd_ssi *ssi) } static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, - struct rsnd_dai *rdai, struct rsnd_dai_stream *io) { struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod); + struct rsnd_dai *rdai = rsnd_io_to_rdai(io); struct device *dev = rsnd_priv_to_dev(priv); u32 cr_mode; u32 cr; @@ -191,7 +190,7 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, if (rsnd_rdai_is_clk_master(rdai)) { if (rsnd_ssi_clk_from_parent(ssi)) - rsnd_ssi_hw_start(ssi->parent, rdai, io); + rsnd_ssi_hw_start(ssi->parent, io); else rsnd_ssi_master_clk_start(ssi, io); } @@ -222,10 +221,11 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, rsnd_mod_name(&ssi->mod), rsnd_mod_id(&ssi->mod)); } -static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi, - struct rsnd_dai *rdai) +static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi) { struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod); + struct rsnd_dai_stream *io = rsnd_mod_to_io(&ssi->mod); + struct rsnd_dai *rdai = rsnd_io_to_rdai(io); struct device *dev = rsnd_priv_to_dev(priv); u32 cr; @@ -254,7 +254,7 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi, if (rsnd_rdai_is_clk_master(rdai)) { if (rsnd_ssi_clk_from_parent(ssi)) - rsnd_ssi_hw_stop(ssi->parent, rdai); + rsnd_ssi_hw_stop(ssi->parent); else rsnd_ssi_master_clk_stop(ssi); } @@ -313,7 +313,6 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, /* * set ssi parameter */ - ssi->rdai = rdai; ssi->cr_own = cr; ssi->err = -1; /* ignore 1st error */ @@ -330,7 +329,6 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod, if (ssi->err > 0) dev_warn(dev, "ssi under/over flow err = %d\n", ssi->err); - ssi->rdai = NULL; ssi->cr_own = 0; ssi->err = 0; @@ -354,11 +352,11 @@ static int rsnd_ssi_start(struct rsnd_mod *mod, struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); - rsnd_src_ssiu_start(mod, rdai, rsnd_ssi_use_busif(mod)); + rsnd_src_ssiu_start(mod, rsnd_ssi_use_busif(mod)); - rsnd_ssi_hw_start(ssi, rdai, io); + rsnd_ssi_hw_start(ssi, io); - rsnd_src_ssi_irq_enable(mod, rdai); + rsnd_src_ssi_irq_enable(mod); return 0; } @@ -368,13 +366,13 @@ static int rsnd_ssi_stop(struct rsnd_mod *mod, { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - rsnd_src_ssi_irq_disable(mod, rdai); + rsnd_src_ssi_irq_disable(mod); rsnd_ssi_record_error(ssi, rsnd_mod_read(mod, SSISR)); - rsnd_ssi_hw_stop(ssi, rdai); + rsnd_ssi_hw_stop(ssi); - rsnd_src_ssiu_stop(mod, rdai); + rsnd_src_ssiu_stop(mod); return 0; } @@ -382,9 +380,9 @@ static int rsnd_ssi_stop(struct rsnd_mod *mod, static irqreturn_t rsnd_ssi_interrupt(int irq, void *data) { struct rsnd_ssi *ssi = data; - struct rsnd_dai *rdai = ssi->rdai; struct rsnd_mod *mod = &ssi->mod; struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); + struct rsnd_dai *rdai = rsnd_io_to_rdai(io); u32 status = rsnd_mod_read(mod, SSISR); if (!io) -- cgit From 690602fcd85385ff325b65fe4bba32ceaf3c33a3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:07:47 +0000 Subject: ASoC: rsnd: replace rdai to priv in each function Current rsnd driver's function requests rdai, but it is not used. Adding priv is more reasonable. Let's replace it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 41 ++++++++++++++++++++--------------------- sound/soc/sh/rcar/dvc.c | 13 +++++-------- sound/soc/sh/rcar/rsnd.h | 15 +++++++-------- sound/soc/sh/rcar/src.c | 25 +++++++++++-------------- sound/soc/sh/rcar/ssi.c | 39 +++++++++++++++++---------------------- 5 files changed, 60 insertions(+), 73 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 74e2c4214058..6fa8709571ff 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -414,7 +414,7 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod) /* * rsnd_dai functions */ -#define __rsnd_mod_call(mod, func, rdai...) \ +#define __rsnd_mod_call(mod, func, param...) \ ({ \ struct rsnd_priv *priv = rsnd_mod_to_priv(mod); \ struct device *dev = rsnd_priv_to_dev(priv); \ @@ -424,18 +424,18 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod) if ((mod->status & mask) == call) { \ dev_dbg(dev, "%s[%d] %s\n", \ rsnd_mod_name(mod), rsnd_mod_id(mod), #func); \ - ret = (mod)->ops->func(mod, rdai); \ + ret = (mod)->ops->func(mod, param); \ mod->status = (mod->status & ~mask) | (~call & mask); \ } \ ret; \ }) -#define rsnd_mod_call(mod, func, rdai...) \ +#define rsnd_mod_call(mod, func, param...) \ (!(mod) ? -ENODEV : \ !((mod)->ops->func) ? 0 : \ - __rsnd_mod_call(mod, func, rdai)) + __rsnd_mod_call(mod, func, param)) -#define rsnd_dai_call(fn, io, rdai...) \ +#define rsnd_dai_call(fn, io, param...) \ ({ \ struct rsnd_mod *mod; \ int ret = 0, i; \ @@ -443,7 +443,7 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod) mod = (io)->mod[i]; \ if (!mod) \ continue; \ - ret = rsnd_mod_call(mod, fn, rdai); \ + ret = rsnd_mod_call(mod, fn, param); \ if (ret < 0) \ break; \ } \ @@ -585,20 +585,20 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd, if (ret < 0) goto dai_trigger_end; - ret = rsnd_dai_call(init, io, rdai); + ret = rsnd_dai_call(init, io, priv); if (ret < 0) goto dai_trigger_end; - ret = rsnd_dai_call(start, io, rdai); + ret = rsnd_dai_call(start, io, priv); if (ret < 0) goto dai_trigger_end; break; case SNDRV_PCM_TRIGGER_STOP: - ret = rsnd_dai_call(stop, io, rdai); + ret = rsnd_dai_call(stop, io, priv); if (ret < 0) goto dai_trigger_end; - ret = rsnd_dai_call(quit, io, rdai); + ret = rsnd_dai_call(quit, io, priv); if (ret < 0) goto dai_trigger_end; @@ -1109,11 +1109,11 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); int ret; - ret = rsnd_dai_call(pcm_new, &rdai->playback, rdai, rtd); + ret = rsnd_dai_call(pcm_new, &rdai->playback, rtd); if (ret) return ret; - ret = rsnd_dai_call(pcm_new, &rdai->capture, rdai, rtd); + ret = rsnd_dai_call(pcm_new, &rdai->capture, rtd); if (ret) return ret; @@ -1136,10 +1136,9 @@ static const struct snd_soc_component_driver rsnd_soc_component = { static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, struct rsnd_dai_stream *io) { - struct rsnd_dai *rdai = rsnd_io_to_rdai(io); int ret; - ret = rsnd_dai_call(probe, io, rdai); + ret = rsnd_dai_call(probe, io, priv); if (ret == -EAGAIN) { /* * Fallback to PIO mode @@ -1152,7 +1151,7 @@ static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, * rsnd_dma_init() * rsnd_ssi_fallback() */ - rsnd_dai_call(remove, io, rdai); + rsnd_dai_call(remove, io, priv); /* * remove SRC/DVC from DAI, @@ -1163,13 +1162,13 @@ static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, /* * fallback */ - rsnd_dai_call(fallback, io, rdai); + rsnd_dai_call(fallback, io, priv); /* * retry to "probe". * DAI has SSI which is PIO mode only now. */ - ret = rsnd_dai_call(probe, io, rdai); + ret = rsnd_dai_call(probe, io, priv); } return ret; @@ -1272,8 +1271,8 @@ exit_snd_soc: snd_soc_unregister_platform(dev); exit_snd_probe: for_each_rsnd_dai(rdai, priv, i) { - rsnd_dai_call(remove, &rdai->playback, rdai); - rsnd_dai_call(remove, &rdai->capture, rdai); + rsnd_dai_call(remove, &rdai->playback, priv); + rsnd_dai_call(remove, &rdai->capture, priv); } return ret; @@ -1288,8 +1287,8 @@ static int rsnd_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); for_each_rsnd_dai(rdai, priv, i) { - ret |= rsnd_dai_call(remove, &rdai->playback, rdai); - ret |= rsnd_dai_call(remove, &rdai->capture, rdai); + ret |= rsnd_dai_call(remove, &rdai->playback, priv); + ret |= rsnd_dai_call(remove, &rdai->capture, priv); } return ret; diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index e24db9e4ee25..4ddca4f380c7 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -117,9 +117,8 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod) } static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); dev_dbg(dev, "%s[%d] (Gen2) is probed\n", @@ -129,10 +128,9 @@ static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod, } static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { struct rsnd_dai_stream *io = rsnd_mod_to_io(dvc_mod); - struct rsnd_priv *priv = rsnd_mod_to_priv(dvc_mod); struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io); struct device *dev = rsnd_priv_to_dev(priv); int dvc_id = rsnd_mod_id(dvc_mod); @@ -177,7 +175,7 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, } static int rsnd_dvc_quit(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { rsnd_mod_hw_stop(mod); @@ -185,7 +183,7 @@ static int rsnd_dvc_quit(struct rsnd_mod *mod, } static int rsnd_dvc_start(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { rsnd_mod_write(mod, CMD_CTRL, 0x10); @@ -193,7 +191,7 @@ static int rsnd_dvc_start(struct rsnd_mod *mod, } static int rsnd_dvc_stop(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { rsnd_mod_write(mod, CMD_CTRL, 0); @@ -201,7 +199,6 @@ static int rsnd_dvc_stop(struct rsnd_mod *mod, } static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd) { struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index aaba717b8fd3..61545357f036 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -200,22 +200,21 @@ struct rsnd_mod_ops { char *name; char* (*dma_name)(struct rsnd_mod *mod); int (*probe)(struct rsnd_mod *mod, - struct rsnd_dai *rdai); + struct rsnd_priv *priv); int (*remove)(struct rsnd_mod *mod, - struct rsnd_dai *rdai); + struct rsnd_priv *priv); int (*init)(struct rsnd_mod *mod, - struct rsnd_dai *rdai); + struct rsnd_priv *priv); int (*quit)(struct rsnd_mod *mod, - struct rsnd_dai *rdai); + struct rsnd_priv *priv); int (*start)(struct rsnd_mod *mod, - struct rsnd_dai *rdai); + struct rsnd_priv *priv); int (*stop)(struct rsnd_mod *mod, - struct rsnd_dai *rdai); + struct rsnd_priv *priv); int (*pcm_new)(struct rsnd_mod *mod, - struct rsnd_dai *rdai, struct snd_soc_pcm_runtime *rtd); int (*fallback)(struct rsnd_mod *mod, - struct rsnd_dai *rdai); + struct rsnd_priv *priv); }; struct rsnd_dai_stream; diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 31e19a00655f..0d136cdc4ada 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -294,10 +294,9 @@ static int rsnd_src_init(struct rsnd_mod *mod) } static int rsnd_src_quit(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { struct rsnd_src *src = rsnd_mod_to_src(mod); - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); rsnd_mod_hw_stop(mod); @@ -449,9 +448,8 @@ static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod) } static int rsnd_src_probe_gen1(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); dev_dbg(dev, "%s[%d] (Gen1) is probed\n", @@ -461,7 +459,7 @@ static int rsnd_src_probe_gen1(struct rsnd_mod *mod, } static int rsnd_src_init_gen1(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { int ret; @@ -485,7 +483,7 @@ static int rsnd_src_init_gen1(struct rsnd_mod *mod, } static int rsnd_src_start_gen1(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { int id = rsnd_mod_id(mod); @@ -495,7 +493,7 @@ static int rsnd_src_start_gen1(struct rsnd_mod *mod, } static int rsnd_src_stop_gen1(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { int id = rsnd_mod_id(mod); @@ -691,9 +689,8 @@ static int rsnd_src_set_convert_timing_gen2(struct rsnd_mod *mod) } static int rsnd_src_probe_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_src *src = rsnd_mod_to_src(mod); struct device *dev = rsnd_priv_to_dev(priv); int irq = src->info->irq; @@ -733,15 +730,15 @@ rsnd_src_probe_gen2_fail: } static int rsnd_src_remove_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { - rsnd_dma_quit(rsnd_mod_to_priv(mod), rsnd_mod_to_dma(mod)); + rsnd_dma_quit(priv, rsnd_mod_to_dma(mod)); return 0; } static int rsnd_src_init_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { int ret; @@ -761,7 +758,7 @@ static int rsnd_src_init_gen2(struct rsnd_mod *mod, } static int rsnd_src_start_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { rsnd_dma_start(rsnd_mod_to_dma(mod)); @@ -769,7 +766,7 @@ static int rsnd_src_start_gen2(struct rsnd_mod *mod, } static int rsnd_src_stop_gen2(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { int ret; diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 6e36c53e7b8f..b5a2fd61029d 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -270,10 +270,11 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi) * SSI mod common functions */ static int rsnd_ssi_init(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); + struct rsnd_dai *rdai = rsnd_io_to_rdai(io); struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); u32 cr; @@ -320,10 +321,9 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, } static int rsnd_ssi_quit(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); if (ssi->err > 0) @@ -347,7 +347,7 @@ static void rsnd_ssi_record_error(struct rsnd_ssi *ssi, u32 status) } static int rsnd_ssi_start(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); @@ -362,7 +362,7 @@ static int rsnd_ssi_start(struct rsnd_mod *mod, } static int rsnd_ssi_stop(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); @@ -381,8 +381,8 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data) { struct rsnd_ssi *ssi = data; struct rsnd_mod *mod = &ssi->mod; + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); - struct rsnd_dai *rdai = rsnd_io_to_rdai(io); u32 status = rsnd_mod_read(mod, SSISR); if (!io) @@ -409,14 +409,13 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data) /* PIO / DMA */ if (status & (UIRQ | OIRQ)) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); /* * restart SSI */ - rsnd_ssi_stop(mod, rdai); - rsnd_ssi_start(mod, rdai); + rsnd_ssi_stop(mod, priv); + rsnd_ssi_start(mod, priv); dev_dbg(dev, "%s[%d] restart\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); @@ -431,9 +430,8 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data) * SSI PIO */ static int rsnd_ssi_pio_probe(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); int ret; @@ -462,9 +460,8 @@ static struct rsnd_mod_ops rsnd_ssi_pio_ops = { }; static int rsnd_ssi_dma_probe(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); struct device *dev = rsnd_priv_to_dev(priv); int dma_id = ssi->info->dma_id; @@ -497,14 +494,13 @@ rsnd_ssi_dma_probe_fail: } static int rsnd_ssi_dma_remove(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); struct device *dev = rsnd_priv_to_dev(priv); int irq = ssi->info->irq; - rsnd_dma_quit(rsnd_mod_to_priv(mod), rsnd_mod_to_dma(mod)); + rsnd_dma_quit(priv, rsnd_mod_to_dma(mod)); /* PIO will request IRQ again */ devm_free_irq(dev, irq, ssi); @@ -513,9 +509,8 @@ static int rsnd_ssi_dma_remove(struct rsnd_mod *mod, } static int rsnd_ssi_fallback(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); /* @@ -534,11 +529,11 @@ static int rsnd_ssi_fallback(struct rsnd_mod *mod, } static int rsnd_ssi_dma_start(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { struct rsnd_dma *dma = rsnd_mod_to_dma(mod); - rsnd_ssi_start(mod, rdai); + rsnd_ssi_start(mod, priv); rsnd_dma_start(dma); @@ -546,13 +541,13 @@ static int rsnd_ssi_dma_start(struct rsnd_mod *mod, } static int rsnd_ssi_dma_stop(struct rsnd_mod *mod, - struct rsnd_dai *rdai) + struct rsnd_priv *priv) { struct rsnd_dma *dma = rsnd_mod_to_dma(mod); rsnd_dma_stop(dma); - rsnd_ssi_stop(mod, rdai); + rsnd_ssi_stop(mod, priv); return 0; } -- cgit From 1b13d118ee8f25227ad779c0f62b46e997e9f5a3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:08:34 +0000 Subject: ASoC: rsnd: save priv in struct rsnd_dai Current rsnd driver has rsnd_mod_to_priv() macro, and struct rsnd_mod has struct rsnd_priv pointer. But, it is waste of memory from data structure point of view. Today we can link mod <-> io <-> rdai each other, so saving priv in rdai is very reasonable. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 5 ++--- sound/soc/sh/rcar/dvc.c | 2 +- sound/soc/sh/rcar/rsnd.h | 9 +++++---- sound/soc/sh/rcar/src.c | 2 +- sound/soc/sh/rcar/ssi.c | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 6fa8709571ff..f0bb137da31b 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -149,14 +149,12 @@ char *rsnd_mod_dma_name(struct rsnd_mod *mod) return mod->ops->dma_name(mod); } -void rsnd_mod_init(struct rsnd_priv *priv, - struct rsnd_mod *mod, +void rsnd_mod_init(struct rsnd_mod *mod, struct rsnd_mod_ops *ops, struct clk *clk, enum rsnd_mod_type type, int id) { - mod->priv = priv; mod->id = id; mod->ops = ops; mod->type = type; @@ -868,6 +866,7 @@ static int rsnd_dai_probe(struct platform_device *pdev, * init rsnd_dai */ snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i); + rdai[i].priv = priv; /* * init snd_soc_dai_driver diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 4ddca4f380c7..38a5f334a6a7 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -351,7 +351,7 @@ int rsnd_dvc_probe(struct platform_device *pdev, dvc->info = &info->dvc_info[i]; - rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops, + rsnd_mod_init(&dvc->mod, &rsnd_dvc_ops, clk, RSND_MOD_DVC, i); dev_dbg(dev, "CMD%d probed\n", i); diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 61545357f036..11a1c412f1f1 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -221,7 +221,6 @@ struct rsnd_dai_stream; struct rsnd_mod { int id; enum rsnd_mod_type type; - struct rsnd_priv *priv; struct rsnd_mod_ops *ops; struct rsnd_dma dma; struct rsnd_dai_stream *io; @@ -256,7 +255,7 @@ struct rsnd_mod { #define __rsnd_mod_call_pcm_new 0 #define __rsnd_mod_call_fallback 0 -#define rsnd_mod_to_priv(mod) ((mod)->priv) +#define rsnd_mod_to_priv(mod) (rsnd_io_to_priv(rsnd_mod_to_io(mod))) #define rsnd_mod_to_dma(mod) (&(mod)->dma) #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) #define rsnd_mod_to_io(mod) ((mod)->io) @@ -264,8 +263,7 @@ struct rsnd_mod { #define rsnd_mod_hw_start(mod) clk_prepare_enable((mod)->clk) #define rsnd_mod_hw_stop(mod) clk_disable_unprepare((mod)->clk) -void rsnd_mod_init(struct rsnd_priv *priv, - struct rsnd_mod *mod, +void rsnd_mod_init(struct rsnd_mod *mod, struct rsnd_mod_ops *ops, struct clk *clk, enum rsnd_mod_type type, @@ -291,6 +289,7 @@ struct rsnd_dai_stream { #define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC]) #define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC]) #define rsnd_io_to_rdai(io) ((io)->rdai) +#define rsnd_io_to_priv(io) (rsnd_rdai_to_priv(rsnd_io_to_rdai(io))) #define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io) #define rsnd_io_to_runtime(io) ((io)->substream ? \ (io)->substream->runtime : NULL) @@ -300,6 +299,7 @@ struct rsnd_dai { char name[RSND_DAI_NAME_SIZE]; struct rsnd_dai_stream playback; struct rsnd_dai_stream capture; + struct rsnd_priv *priv; unsigned int clk_master:1; unsigned int bit_clk_inv:1; @@ -310,6 +310,7 @@ struct rsnd_dai { #define rsnd_rdai_nr(priv) ((priv)->rdai_nr) #define rsnd_rdai_is_clk_master(rdai) ((rdai)->clk_master) +#define rsnd_rdai_to_priv(rdai) ((rdai)->priv) #define for_each_rsnd_dai(rdai, priv, i) \ for (i = 0; \ (i < rsnd_rdai_nr(priv)) && \ diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 0d136cdc4ada..8c22d2112a1d 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -889,7 +889,7 @@ int rsnd_src_probe(struct platform_device *pdev, src->info = &info->src_info[i]; - rsnd_mod_init(priv, &src->mod, ops, clk, RSND_MOD_SRC, i); + rsnd_mod_init(&src->mod, ops, clk, RSND_MOD_SRC, i); dev_dbg(dev, "SRC%d probed\n", i); } diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index b5a2fd61029d..9b89f6cf7680 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -125,7 +125,7 @@ static void rsnd_ssi_status_check(struct rsnd_mod *mod, static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi, struct rsnd_dai_stream *io) { - struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod); + struct rsnd_priv *priv = rsnd_io_to_priv(io); struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); struct device *dev = rsnd_priv_to_dev(priv); int i, j, ret; @@ -179,7 +179,7 @@ static void rsnd_ssi_master_clk_stop(struct rsnd_ssi *ssi) static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, struct rsnd_dai_stream *io) { - struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod); + struct rsnd_priv *priv = rsnd_io_to_priv(io); struct rsnd_dai *rdai = rsnd_io_to_rdai(io); struct device *dev = rsnd_priv_to_dev(priv); u32 cr_mode; @@ -730,7 +730,7 @@ int rsnd_ssi_probe(struct platform_device *pdev, else if (rsnd_ssi_pio_available(ssi)) ops = &rsnd_ssi_pio_ops; - rsnd_mod_init(priv, &ssi->mod, ops, clk, RSND_MOD_SSI, i); + rsnd_mod_init(&ssi->mod, ops, clk, RSND_MOD_SSI, i); rsnd_ssi_parent_clk_setup(priv, ssi); } -- cgit From 337b0b4c5f415705f1b97df57cecfac45903449a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:08:57 +0000 Subject: ASoC: rsnd: error meesage indicates its port Current SRC/SSI output its error, but it desn't indicate port number. it is un-understandable. Let's indicate port number for it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/src.c | 3 ++- sound/soc/sh/rcar/ssi.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 8c22d2112a1d..81c182b4bad5 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -302,7 +302,8 @@ static int rsnd_src_quit(struct rsnd_mod *mod, rsnd_mod_hw_stop(mod); if (src->err) - dev_warn(dev, "src under/over flow err = %d\n", src->err); + dev_warn(dev, "%s[%d] under/over flow err = %d\n", + rsnd_mod_name(mod), rsnd_mod_id(mod), src->err); return 0; } diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 9b89f6cf7680..d26634bde908 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -327,7 +327,8 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod, struct device *dev = rsnd_priv_to_dev(priv); if (ssi->err > 0) - dev_warn(dev, "ssi under/over flow err = %d\n", ssi->err); + dev_warn(dev, "%s[%d] under/over flow err = %d\n", + rsnd_mod_name(mod), rsnd_mod_id(mod), ssi->err); ssi->cr_own = 0; ssi->err = 0; -- cgit From 765ae7c8dda7d06d7ce74b35beb4c7ec06b78643 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:09:13 +0000 Subject: ASoC: rsnd: ignore DIRQ when DMA transfer SSI interrupt handler of R-Car sound driver will be called when DIRQ (= Data read/write timing for PIO) or UIRQ / OIRQ (= under/over run error). DIRQ "interrupt" doesn't occur when DMA transfer, but then, DIRQ "status bit" might occur. we need to ignore this DIRQ operation when DMA. Otherwise, driver will push/pop as PIO. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index d26634bde908..4b646124ab8a 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -384,13 +384,14 @@ static irqreturn_t rsnd_ssi_interrupt(int irq, void *data) struct rsnd_mod *mod = &ssi->mod; struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); + int is_dma = rsnd_ssi_is_dma_mode(mod); u32 status = rsnd_mod_read(mod, SSISR); if (!io) return IRQ_NONE; /* PIO only */ - if (status & DIRQ) { + if (!is_dma && (status & DIRQ)) { struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); u32 *buf = (u32 *)(runtime->dma_area + rsnd_dai_pointer_offset(io, 0)); -- cgit From 1ceeab2679069738fc73da6d8256014d3e195dab Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:09:26 +0000 Subject: ASoC: rsnd: tidyup DMA start/stop timing on SSI Current DMA starts after SSI, and stops before SSI. but we need to reverse these order. Otherwise, under/over run error might happen. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 4b646124ab8a..9e7b627c08e2 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -535,10 +535,10 @@ static int rsnd_ssi_dma_start(struct rsnd_mod *mod, { struct rsnd_dma *dma = rsnd_mod_to_dma(mod); - rsnd_ssi_start(mod, priv); - rsnd_dma_start(dma); + rsnd_ssi_start(mod, priv); + return 0; } @@ -547,10 +547,10 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod, { struct rsnd_dma *dma = rsnd_mod_to_dma(mod); - rsnd_dma_stop(dma); - rsnd_ssi_stop(mod, priv); + rsnd_dma_stop(dma); + return 0; } -- cgit From 8048b91ffca872d704b7e7fb404a121955ce8d8e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 15 Jan 2015 08:09:44 +0000 Subject: ASoC: rsnd: tidyup DVC/SRC/SSI order Current R-Car sound driver calls SRC -> SSI -> DVC functions, but, it should be DVC -> SRC -> SSI. Otherwise, SSI (= interface of codec) will have underrun error when playback. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/rsnd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 11a1c412f1f1..b57d8ace012a 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -190,9 +190,9 @@ void rsnd_dma_quit(struct rsnd_priv *priv, * R-Car sound mod */ enum rsnd_mod_type { - RSND_MOD_SRC = 0, + RSND_MOD_DVC = 0, + RSND_MOD_SRC, RSND_MOD_SSI, - RSND_MOD_DVC, RSND_MOD_MAX, }; -- cgit From f9911803e82a32c126c40dd6246ade2faf472cbc Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 13 Jan 2015 21:16:34 +0200 Subject: ASoC: simple-card: Enable and disable DAI clocks as needed Call clk_prepare_enable() and clk_disable_unprepare() for cpu dai clock and codec dai clock in dai statup and shutdown callbacks. This to make sure the related clock are enabled when the audio device is used. Signed-off-by: Jyri Sarha Signed-off-by: Mark Brown --- sound/soc/generic/simple-card.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'sound') diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index fb9240fdc9b7..cb3998d96cca 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -39,6 +39,37 @@ struct simple_card_data { #define simple_priv_to_link(priv, i) ((priv)->snd_card.dai_link + i) #define simple_priv_to_props(priv, i) ((priv)->dai_props + i) +static int asoc_simple_card_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = + &priv->dai_props[rtd - rtd->card->rtd]; + int ret; + + ret = clk_prepare_enable(dai_props->cpu_dai.clk); + if (ret) + return ret; + + ret = clk_prepare_enable(dai_props->codec_dai.clk); + if (ret) + clk_disable_unprepare(dai_props->cpu_dai.clk); + + return ret; +} + +static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_dai_props *dai_props = + &priv->dai_props[rtd - rtd->card->rtd]; + + clk_disable_unprepare(dai_props->cpu_dai.clk); + + clk_disable_unprepare(dai_props->codec_dai.clk); +} + static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -58,6 +89,8 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, } static struct snd_soc_ops asoc_simple_card_ops = { + .startup = asoc_simple_card_startup, + .shutdown = asoc_simple_card_shutdown, .hw_params = asoc_simple_card_hw_params, }; @@ -219,6 +252,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, } dai->sysclk = clk_get_rate(clk); + dai->clk = clk; } else if (!of_property_read_u32(np, "system-clock-frequency", &val)) { dai->sysclk = val; } else { -- cgit From 7331ea474e9e7a348541c207bdb6aa518c6403f4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:01 +0100 Subject: ASoC: mioa701_wm9713: Fix speaker event Commit f6b2a04590bb ("ASoC: pxa: mioa701_wm9713: Convert to table based DAPM setup") converted the driver to register the board level DAPM elements with the card's DAPM context rather than the CODEC's DAPM context. The change overlooked that the speaker widget event callback accesses the widget's codec field which is only valid if the widget has been registered in a CODEC DAPM context. This patch modifies the callback to take an alternative route to get the CODEC. Fixes: f6b2a04590bb ("ASoC: pxa: mioa701_wm9713: Convert to table based DAPM setup") Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/mioa701_wm9713.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c index 396dbd51a64f..a9615a574546 100644 --- a/sound/soc/pxa/mioa701_wm9713.c +++ b/sound/soc/pxa/mioa701_wm9713.c @@ -81,7 +81,7 @@ static int rear_amp_power(struct snd_soc_codec *codec, int power) static int rear_amp_event(struct snd_soc_dapm_widget *widget, struct snd_kcontrol *kctl, int event) { - struct snd_soc_codec *codec = widget->codec; + struct snd_soc_codec *codec = widget->dapm->card->rtd[0].codec; return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event)); } -- cgit From 0d76091ca89d6094b52d442db39f61c896207256 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:02 +0100 Subject: ASoC: pcm3008: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/pcm3008.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/pcm3008.c b/sound/soc/codecs/pcm3008.c index 7e73fa4b3183..8fb445f33f6f 100644 --- a/sound/soc/codecs/pcm3008.c +++ b/sound/soc/codecs/pcm3008.c @@ -32,7 +32,7 @@ static int pcm3008_dac_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct pcm3008_setup_data *setup = codec->dev->platform_data; gpio_set_value_cansleep(setup->pdda_pin, @@ -45,7 +45,7 @@ static int pcm3008_adc_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct pcm3008_setup_data *setup = codec->dev->platform_data; gpio_set_value_cansleep(setup->pdad_pin, -- cgit From dd943d36f1c4029b6fc5dc1feeb15acda930756d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:03 +0100 Subject: ASoC: tlv320aic31xx: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic31xx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index dc3223d6eca1..c86dd9aae157 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -349,7 +349,8 @@ static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg, static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); unsigned int reg = AIC31XX_DACFLAG1; unsigned int mask; @@ -377,7 +378,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, reg = AIC31XX_ADCFLAG; break; default: - dev_err(w->codec->dev, "Unknown widget '%s' calling %s\n", + dev_err(codec->dev, "Unknown widget '%s' calling %s\n", w->name, __func__); return -EINVAL; } @@ -388,7 +389,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMD: return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100); default: - dev_dbg(w->codec->dev, + dev_dbg(codec->dev, "Unhandled dapm widget event %d from %s\n", event, w->name); } @@ -433,7 +434,7 @@ static const struct snd_kcontrol_new aic31xx_dapm_spr_switch = static int mic_bias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); switch (event) { -- cgit From 38d3df61e094eb3c8f8af7c6f264a8cd59501ec0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:04 +0100 Subject: ASoC: tlv320aic3x: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic3x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index b7ebce054b4e..a78ad361f494 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -197,7 +197,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, static int mic_bias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); switch (event) { -- cgit From c61ac6b7ebaa84a674ca7299dd8f7290967f28a1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:05 +0100 Subject: ASoC: tlv320dac33: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320dac33.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 0fe2ced5b09f..4e3e607dec13 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -423,17 +423,18 @@ exit: static int dac33_playback_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (likely(dac33->substream)) { - dac33_calculate_times(dac33->substream, w->codec); - dac33_prepare_chip(dac33->substream, w->codec); + dac33_calculate_times(dac33->substream, codec); + dac33_prepare_chip(dac33->substream, codec); } break; case SND_SOC_DAPM_POST_PMD: - dac33_disable_digital(w->codec); + dac33_disable_digital(codec); break; } return 0; -- cgit From a36ac9b32c1d653741f26e8ea3ed56e31fb6fe2f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:06 +0100 Subject: ASoC: twl4030: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 55 ++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 21 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 44af3188afb9..d04693e9cf9f 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -567,12 +567,13 @@ static const struct snd_kcontrol_new twl4030_dapm_dbypassv_control = static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \ struct snd_kcontrol *kcontrol, int event) \ { \ - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); \ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); \ + struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); \ \ switch (event) { \ case SND_SOC_DAPM_POST_PMU: \ twl4030->pin_name##_enabled = 1; \ - twl4030_write(w->codec, reg, twl4030_read(w->codec, reg)); \ + twl4030_write(codec, reg, twl4030_read(codec, reg)); \ break; \ case SND_SOC_DAPM_POST_PMD: \ twl4030->pin_name##_enabled = 0; \ @@ -621,12 +622,14 @@ static void handsfree_ramp(struct snd_soc_codec *codec, int reg, int ramp) static int handsfreelpga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + switch (event) { case SND_SOC_DAPM_POST_PMU: - handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 1); + handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 1); break; case SND_SOC_DAPM_POST_PMD: - handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 0); + handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 0); break; } return 0; @@ -635,12 +638,14 @@ static int handsfreelpga_event(struct snd_soc_dapm_widget *w, static int handsfreerpga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + switch (event) { case SND_SOC_DAPM_POST_PMU: - handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 1); + handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 1); break; case SND_SOC_DAPM_POST_PMD: - handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 0); + handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 0); break; } return 0; @@ -649,19 +654,23 @@ static int handsfreerpga_event(struct snd_soc_dapm_widget *w, static int vibramux_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - twl4030_write(w->codec, TWL4030_REG_VIBRA_SET, 0xff); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + + twl4030_write(codec, TWL4030_REG_VIBRA_SET, 0xff); return 0; } static int apll_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + switch (event) { case SND_SOC_DAPM_PRE_PMU: - twl4030_apll_enable(w->codec, 1); + twl4030_apll_enable(codec, 1); break; case SND_SOC_DAPM_POST_PMD: - twl4030_apll_enable(w->codec, 0); + twl4030_apll_enable(codec, 0); break; } return 0; @@ -670,23 +679,24 @@ static int apll_event(struct snd_soc_dapm_widget *w, static int aif_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u8 audio_if; - audio_if = twl4030_read(w->codec, TWL4030_REG_AUDIO_IF); + audio_if = twl4030_read(codec, TWL4030_REG_AUDIO_IF); switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable AIF */ /* enable the PLL before we use it to clock the DAI */ - twl4030_apll_enable(w->codec, 1); + twl4030_apll_enable(codec, 1); - twl4030_write(w->codec, TWL4030_REG_AUDIO_IF, + twl4030_write(codec, TWL4030_REG_AUDIO_IF, audio_if | TWL4030_AIF_EN); break; case SND_SOC_DAPM_POST_PMD: /* disable the DAI before we stop it's source PLL */ - twl4030_write(w->codec, TWL4030_REG_AUDIO_IF, + twl4030_write(codec, TWL4030_REG_AUDIO_IF, audio_if & ~TWL4030_AIF_EN); - twl4030_apll_enable(w->codec, 0); + twl4030_apll_enable(codec, 0); break; } return 0; @@ -758,20 +768,21 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) static int headsetlpga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); switch (event) { case SND_SOC_DAPM_POST_PMU: /* Do the ramp-up only once */ if (!twl4030->hsr_enabled) - headset_ramp(w->codec, 1); + headset_ramp(codec, 1); twl4030->hsl_enabled = 1; break; case SND_SOC_DAPM_POST_PMD: /* Do the ramp-down only if both headsetL/R is disabled */ if (!twl4030->hsr_enabled) - headset_ramp(w->codec, 0); + headset_ramp(codec, 0); twl4030->hsl_enabled = 0; break; @@ -782,20 +793,21 @@ static int headsetlpga_event(struct snd_soc_dapm_widget *w, static int headsetrpga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); switch (event) { case SND_SOC_DAPM_POST_PMU: /* Do the ramp-up only once */ if (!twl4030->hsl_enabled) - headset_ramp(w->codec, 1); + headset_ramp(codec, 1); twl4030->hsr_enabled = 1; break; case SND_SOC_DAPM_POST_PMD: /* Do the ramp-down only if both headsetL/R is disabled */ if (!twl4030->hsl_enabled) - headset_ramp(w->codec, 0); + headset_ramp(codec, 0); twl4030->hsr_enabled = 0; break; @@ -806,7 +818,8 @@ static int headsetrpga_event(struct snd_soc_dapm_widget *w, static int digimic_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); struct twl4030_codec_data *pdata = twl4030->pdata; if (pdata && pdata->digimic_delay) -- cgit From b27727df32e5c44ad2e31326b148b5ba7823a370 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:07 +0100 Subject: ASoC: twl6040: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/twl6040.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 90f47f988b3f..aeec27b6f1af 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -234,7 +234,7 @@ static int headset_power_mode(struct snd_soc_codec *codec, int high_perf) static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); u8 hslctl, hsrctl; /* @@ -261,7 +261,7 @@ static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w, static int twl6040_ep_drv_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); int ret = 0; -- cgit From a50d761f6d5ea360515dd425ef08a54d3b3836ba Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:08 +0100 Subject: ASoC: alc5623: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/alc5623.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c index bdf8c5ac8ca4..0e357996864b 100644 --- a/sound/soc/codecs/alc5623.c +++ b/sound/soc/codecs/alc5623.c @@ -55,18 +55,20 @@ static inline int alc5623_reset(struct snd_soc_codec *codec) static int amp_mixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + /* to power-on/off class-d amp generators/speaker */ /* need to write to 'index-46h' register : */ /* so write index num (here 0x46) to reg 0x6a */ /* and then 0xffff/0 to reg 0x6c */ - snd_soc_write(w->codec, ALC5623_HID_CTRL_INDEX, 0x46); + snd_soc_write(codec, ALC5623_HID_CTRL_INDEX, 0x46); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_write(w->codec, ALC5623_HID_CTRL_DATA, 0xFFFF); + snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0xFFFF); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(w->codec, ALC5623_HID_CTRL_DATA, 0); + snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0); break; } -- cgit From 0bb043f523f1c226c05f8d919407fb07b1578884 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:09 +0100 Subject: ASoC: alc5632: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/alc5632.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c index d1fdbc266631..dd012c7b2d2c 100644 --- a/sound/soc/codecs/alc5632.c +++ b/sound/soc/codecs/alc5632.c @@ -116,18 +116,20 @@ static inline int alc5632_reset(struct regmap *map) static int amp_mixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + /* to power-on/off class-d amp generators/speaker */ /* need to write to 'index-46h' register : */ /* so write index num (here 0x46) to reg 0x6a */ /* and then 0xffff/0 to reg 0x6c */ - snd_soc_write(w->codec, ALC5632_HID_CTRL_INDEX, 0x46); + snd_soc_write(codec, ALC5632_HID_CTRL_INDEX, 0x46); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_write(w->codec, ALC5632_HID_CTRL_DATA, 0xFFFF); + snd_soc_write(codec, ALC5632_HID_CTRL_DATA, 0xFFFF); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(w->codec, ALC5632_HID_CTRL_DATA, 0); + snd_soc_write(codec, ALC5632_HID_CTRL_DATA, 0); break; } -- cgit From 76f17f185e18ac858c7d20cc079f978630e50746 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:10 +0100 Subject: ASoC: rt286: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/rt286.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index 2cd4fe463102..99dcfec4834a 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -403,7 +403,8 @@ EXPORT_SYMBOL_GPL(rt286_mic_detect); static int is_mclk_mode(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(source->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); if (rt286->clk_id == RT286_SCLK_S_MCLK) return 1; @@ -500,7 +501,7 @@ SOC_DAPM_ENUM("SPO source", rt286_spo_enum); static int rt286_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -522,7 +523,7 @@ static int rt286_spk_event(struct snd_soc_dapm_widget *w, static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -541,7 +542,7 @@ static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, static int rt286_adc_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); unsigned int nid; nid = (w->reg >> 20) & 0xff; @@ -567,7 +568,7 @@ static int rt286_adc_event(struct snd_soc_dapm_widget *w, static int rt286_vref_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -585,7 +586,7 @@ static int rt286_vref_event(struct snd_soc_dapm_widget *w, static int rt286_ldo2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -604,7 +605,7 @@ static int rt286_ldo2_event(struct snd_soc_dapm_widget *w, static int rt286_mic1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: -- cgit From 4389eb29078f1ab35e65d0386e342ec043389e49 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:11 +0100 Subject: ASoC: rt5631: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/rt5631.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index 6d7b7ca7d530..c61852742ee3 100644 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c @@ -287,70 +287,78 @@ static const struct snd_kcontrol_new rt5631_snd_controls[] = { static int check_sysclk1_source(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg; - reg = snd_soc_read(source->codec, RT5631_GLOBAL_CLK_CTRL); + reg = snd_soc_read(codec, RT5631_GLOBAL_CLK_CTRL); return reg & RT5631_SYSCLK_SOUR_SEL_PLL; } static int check_dmic_used(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(source->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); return rt5631->dmic_used_flag; } static int check_dacl_to_outmixl(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg; - reg = snd_soc_read(source->codec, RT5631_OUTMIXER_L_CTRL); + reg = snd_soc_read(codec, RT5631_OUTMIXER_L_CTRL); return !(reg & RT5631_M_DAC_L_TO_OUTMIXER_L); } static int check_dacr_to_outmixr(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg; - reg = snd_soc_read(source->codec, RT5631_OUTMIXER_R_CTRL); + reg = snd_soc_read(codec, RT5631_OUTMIXER_R_CTRL); return !(reg & RT5631_M_DAC_R_TO_OUTMIXER_R); } static int check_dacl_to_spkmixl(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg; - reg = snd_soc_read(source->codec, RT5631_SPK_MIXER_CTRL); + reg = snd_soc_read(codec, RT5631_SPK_MIXER_CTRL); return !(reg & RT5631_M_DAC_L_TO_SPKMIXER_L); } static int check_dacr_to_spkmixr(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg; - reg = snd_soc_read(source->codec, RT5631_SPK_MIXER_CTRL); + reg = snd_soc_read(codec, RT5631_SPK_MIXER_CTRL); return !(reg & RT5631_M_DAC_R_TO_SPKMIXER_R); } static int check_adcl_select(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg; - reg = snd_soc_read(source->codec, RT5631_ADC_REC_MIXER); + reg = snd_soc_read(codec, RT5631_ADC_REC_MIXER); return !(reg & RT5631_M_MIC1_TO_RECMIXER_L); } static int check_adcr_select(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg; - reg = snd_soc_read(source->codec, RT5631_ADC_REC_MIXER); + reg = snd_soc_read(codec, RT5631_ADC_REC_MIXER); return !(reg & RT5631_M_MIC2_TO_RECMIXER_R); } @@ -556,7 +564,7 @@ static void depop_seq_mute_stage(struct snd_soc_codec *codec, int enable) static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -590,7 +598,7 @@ static int hp_event(struct snd_soc_dapm_widget *w, static int set_dmic_params(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); switch (rt5631->rx_rate) { -- cgit From bb1cd608b1198a8c24fe56074b9d93df393ee9a7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:12 +0100 Subject: ASoC: rt5640: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index c3f2decd643c..b386958de042 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -458,7 +458,7 @@ static const struct snd_kcontrol_new rt5640_specific_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); int idx = -EINVAL; @@ -475,9 +475,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int val; - val = snd_soc_read(source->codec, RT5640_GLB_CLK); + val = snd_soc_read(codec, RT5640_GLB_CLK); val &= RT5640_SCLK_SRC_MASK; if (val == RT5640_SCLK_SRC_PLL1) return 1; @@ -963,7 +964,7 @@ static void rt5640_pmu_depop(struct snd_soc_codec *codec) static int rt5640_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -987,7 +988,7 @@ static int rt5640_hp_event(struct snd_soc_dapm_widget *w, static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1003,7 +1004,7 @@ static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w, static int rt5640_hp_post_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); switch (event) { -- cgit From c5f596cb4b4969a5539a7c71b960045a1399093d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:13 +0100 Subject: ASoC: rt5645: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/rt5645.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 27141e2df878..068dfd5c7640 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -527,7 +527,7 @@ static const struct snd_kcontrol_new rt5645_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); int idx = -EINVAL; @@ -544,9 +544,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int val; - val = snd_soc_read(source->codec, RT5645_GLB_CLK); + val = snd_soc_read(codec, RT5645_GLB_CLK); val &= RT5645_SCLK_SRC_MASK; if (val == RT5645_SCLK_SRC_PLL1) return 1; @@ -557,6 +558,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg, shift, val; switch (source->shift) { @@ -588,7 +590,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, return 0; } - val = (snd_soc_read(source->codec, reg) >> shift) & 0xf; + val = (snd_soc_read(codec, reg) >> shift) & 0xf; switch (val) { case 1: case 2: @@ -1144,7 +1146,7 @@ static void hp_amp_power(struct snd_soc_codec *codec, int on) static int rt5645_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -1205,7 +1207,7 @@ static int rt5645_hp_event(struct snd_soc_dapm_widget *w, static int rt5645_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1232,7 +1234,7 @@ static int rt5645_spk_event(struct snd_soc_dapm_widget *w, static int rt5645_lout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1262,7 +1264,7 @@ static int rt5645_lout_event(struct snd_soc_dapm_widget *w, static int rt5645_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: -- cgit From 30c173ed3e03a21be78257852d1815d7c4e55ae9 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:14 +0100 Subject: ASoC: rt5651: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index bb0a3ab5416c..9f4c7be6d798 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -376,7 +376,7 @@ static const struct snd_kcontrol_new rt5651_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); int idx = -EINVAL; @@ -394,9 +394,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sysclk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int val; - val = snd_soc_read(source->codec, RT5651_GLB_CLK); + val = snd_soc_read(codec, RT5651_GLB_CLK); val &= RT5651_SCLK_SRC_MASK; if (val == RT5651_SCLK_SRC_PLL1) return 1; @@ -731,7 +732,7 @@ static const struct snd_kcontrol_new rt5651_pdm_r_mux = static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -769,7 +770,7 @@ static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w, static int rt5651_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -813,7 +814,8 @@ static int rt5651_hp_event(struct snd_soc_dapm_widget *w, static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -833,7 +835,7 @@ static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w, static int rt5651_bst1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -856,7 +858,7 @@ static int rt5651_bst1_event(struct snd_soc_dapm_widget *w, static int rt5651_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -879,7 +881,7 @@ static int rt5651_bst2_event(struct snd_soc_dapm_widget *w, static int rt5651_bst3_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: -- cgit From 8eee1468eebdcef3e094bb8abc846fa101a9a961 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:15 +0100 Subject: ASoC: rt5670: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 8a0833de1665..697aabf456a5 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -498,7 +498,7 @@ static const struct snd_kcontrol_new rt5670_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); int idx = -EINVAL; @@ -515,9 +515,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int val; - val = snd_soc_read(source->codec, RT5670_GLB_CLK); + val = snd_soc_read(codec, RT5670_GLB_CLK); val &= RT5670_SCLK_SRC_MASK; if (val == RT5670_SCLK_SRC_PLL1) return 1; @@ -528,6 +529,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); unsigned int reg, shift, val; switch (source->shift) { @@ -563,7 +565,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, return 0; } - val = (snd_soc_read(source->codec, reg) >> shift) & 0xf; + val = (snd_soc_read(codec, reg) >> shift) & 0xf; switch (val) { case 1: case 2: @@ -1146,7 +1148,7 @@ static const struct snd_kcontrol_new rt5670_vad_adc_mux = static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -1182,7 +1184,7 @@ static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, static int rt5670_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -1232,7 +1234,7 @@ static int rt5670_hp_event(struct snd_soc_dapm_widget *w, static int rt5670_bst1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1255,7 +1257,7 @@ static int rt5670_bst1_event(struct snd_soc_dapm_widget *w, static int rt5670_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: -- cgit From 46f20872bc22c7513027dea09ac8d87f88e7e730 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:16 +0100 Subject: ASoC: rt5677: Replace w->codec snd_soc_dapm_to_codec(w->dapm) The codec field of the snd_soc_widget struct is eventually going to be removed, use snd_soc_dapm_to_codec(w->dapm) instead. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 88de759fb7fc..ff7cce941106 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -895,7 +895,7 @@ static const struct snd_kcontrol_new rt5677_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); int idx = rl6231_calc_dmic_clk(rt5677->sysclk); @@ -910,7 +910,8 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(source->codec); + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); unsigned int val; regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val); @@ -924,7 +925,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = source->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); unsigned int reg, shift, val; @@ -2125,7 +2126,7 @@ static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux = static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -2149,7 +2150,7 @@ static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, static int rt5677_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -2173,7 +2174,7 @@ static int rt5677_bst2_event(struct snd_soc_dapm_widget *w, static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -2191,7 +2192,7 @@ static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w, static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -2209,7 +2210,7 @@ static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w, static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); switch (event) { @@ -2236,7 +2237,7 @@ static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); unsigned int value; @@ -2259,7 +2260,7 @@ static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w, static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); unsigned int value; @@ -2282,7 +2283,7 @@ static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w, static int rt5677_vref_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = w->codec; + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); switch (event) { -- cgit From 96da4e5b2e1d04478fb6d540085f2859256ca788 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 15 Jan 2015 12:52:17 +0100 Subject: ASoC: Remove codec field from snd_soc_dapm_widget There are no more users of this field left so it can finally be removed. New users should use snd_soc_dapm_to_codec(w->dapm); The reason why it is removed is because it doesn't fit to well anymore in the componentized ASoC hierarchy, where DAPM works on the snd_soc_component level. And the alternative of snd_soc_dapm_to_codec(w->dapm) typically generates the same amount of code, so there is really no reason to keep it. For automatic conversion the following coccinelle semantic patch can be used: // @@ struct snd_soc_dapm_widget *w; @@ -w->codec +snd_soc_dapm_to_codec(w->dapm) // Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index c5136bb1f982..f6ae254e33ef 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3130,8 +3130,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, } w->dapm = dapm; - if (dapm->component) - w->codec = dapm->component->codec; INIT_LIST_HEAD(&w->sources); INIT_LIST_HEAD(&w->sinks); INIT_LIST_HEAD(&w->list); -- cgit From 3a41e0f7233a644b45e536a31c0116500ac106a4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 16 Jan 2015 14:34:52 +0100 Subject: ASoC: jive: Automatically disconnect non-connected pins All DAPM input and output pins of the wm8750 are either used in the card's DAPM routing table or are marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/jive_wm8750.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/jive_wm8750.c b/sound/soc/samsung/jive_wm8750.c index 6c3b359bb4c1..7fcb51faa2a0 100644 --- a/sound/soc/samsung/jive_wm8750.c +++ b/sound/soc/samsung/jive_wm8750.c @@ -83,22 +83,6 @@ static struct snd_soc_ops jive_ops = { .hw_params = jive_hw_params, }; -static int jive_wm8750_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - /* These endpoints are not being used. */ - snd_soc_dapm_nc_pin(dapm, "LINPUT2"); - snd_soc_dapm_nc_pin(dapm, "RINPUT2"); - snd_soc_dapm_nc_pin(dapm, "LINPUT3"); - snd_soc_dapm_nc_pin(dapm, "RINPUT3"); - snd_soc_dapm_nc_pin(dapm, "OUT3"); - snd_soc_dapm_nc_pin(dapm, "MONO"); - - return 0; -} - static struct snd_soc_dai_link jive_dai = { .name = "wm8750", .stream_name = "WM8750", @@ -106,7 +90,6 @@ static struct snd_soc_dai_link jive_dai = { .codec_dai_name = "wm8750-hifi", .platform_name = "s3c2412-i2s", .codec_name = "wm8750.0-001a", - .init = jive_wm8750_init, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ops = &jive_ops, @@ -123,6 +106,7 @@ static struct snd_soc_card snd_soc_machine_jive = { .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), + .fully_routed = true, }; static struct platform_device *jive_snd_device; -- cgit From e236d4d796f87d062f59af8004c8f485baf10b62 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 16 Jan 2015 14:34:53 +0100 Subject: ASoC: smdk_wm8580: Pass card DAPM context to snd_soc_dapm_disable_pin() The "MicIn" widget is a card level DAPM element so pass the card's DAPM context instead of the CODEC's DAPM context to snd_soc_dapm_disable_pin(). Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/smdk_wm8580.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/smdk_wm8580.c b/sound/soc/samsung/smdk_wm8580.c index 17a2f717ec02..548bfd993788 100644 --- a/sound/soc/samsung/smdk_wm8580.c +++ b/sound/soc/samsung/smdk_wm8580.c @@ -136,13 +136,10 @@ static const struct snd_soc_dapm_route smdk_wm8580_audio_map[] = { static int smdk_wm8580_init_paiftx(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - /* Enabling the microphone requires the fitting of a 0R * resistor to connect the line from the microphone jack. */ - snd_soc_dapm_disable_pin(dapm, "MicIn"); + snd_soc_dapm_disable_pin(&rtd->card->dapm, "MicIn"); return 0; } -- cgit From a59aa180ea56004a8dd6ece93699adf5eacdf4d9 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 16 Jan 2015 20:04:16 +0100 Subject: ASoC: samsung: Replace depends on REGMAP_I2C with depends on I2C regmap is a library function that gets selected by drivers that need it. No driver modules should depend on it, since this can create dependency loops. E.g. if machine driver depends on REGMAP_I2C and selects the CODEC driver and the CODEC driver selects REGMAP_I2C, then the machine driver selects by extension one of its dependencies. The proper way to handle this is for machine drivers to depend on the same dependencies as the CODEC driver they select. In this case it is I2C. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/samsung/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index fc67f97f19f6..e817a2f43ea8 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig @@ -54,7 +54,7 @@ config SND_SOC_SAMSUNG_JIVE_WM8750 config SND_SOC_SAMSUNG_SMDK_WM8580 tristate "SoC I2S Audio support for WM8580 on SMDK" depends on SND_SOC_SAMSUNG && (MACH_SMDK6410 || MACH_SMDKC100 || MACH_SMDKV210 || MACH_SMDKC110) - depends on REGMAP_I2C + depends on I2C select SND_SOC_WM8580 select SND_SAMSUNG_I2S help @@ -167,7 +167,7 @@ config SND_SOC_SAMSUNG_SMDK_SPDIF config SND_SOC_SMDK_WM8580_PCM tristate "SoC PCM Audio support for WM8580 on SMDK" depends on SND_SOC_SAMSUNG && (MACH_SMDKV210 || MACH_SMDKC110) - depends on REGMAP_I2C + depends on I2C select SND_SOC_WM8580 select SND_SAMSUNG_PCM help -- cgit From 20eb26a2ec8d28f6106d210ea6a12f360e57a72b Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 16 Jan 2015 22:14:18 +0100 Subject: ALSA: oxygen: do not create useless S/PDIF controls Cards without S/PDIF output do not need those controls. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_mixer.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sound') diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index 5988e044c519..2f698a9a5044 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c @@ -786,6 +786,9 @@ static const struct snd_kcontrol_new controls[] = { .get = upmix_get, .put = upmix_put, }, +}; + +static const struct snd_kcontrol_new spdif_output_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH), @@ -1073,6 +1076,12 @@ int oxygen_mixer_init(struct oxygen *chip) err = add_controls(chip, controls, ARRAY_SIZE(controls)); if (err < 0) return err; + if (chip->model.device_config & PLAYBACK_1_TO_SPDIF) { + err = add_controls(chip, spdif_output_controls, + ARRAY_SIZE(spdif_output_controls)); + if (err < 0) + return err; + } if (chip->model.device_config & CAPTURE_1_FROM_SPDIF) { err = add_controls(chip, spdif_input_controls, ARRAY_SIZE(spdif_input_controls)); -- cgit From 0902fbb9ccf7e3be67b9774b0d5f096da44e7c65 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 16 Jan 2015 22:15:13 +0100 Subject: ALSA: oxygen: add support for third analog input Make it possible for cards to have three stereo analog input pairs. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen.h | 2 +- sound/pci/oxygen/oxygen_lib.c | 15 +++++++++++--- sound/pci/oxygen/oxygen_mixer.c | 27 +++++++++++++++++++++++++ sound/pci/oxygen/oxygen_pcm.c | 45 ++++++++++++++++++++++++++++++++++++++--- 4 files changed, 82 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index c10ab077afd8..293d0b9a50c3 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h @@ -35,7 +35,7 @@ #define CAPTURE_1_FROM_SPDIF 0x0080 #define CAPTURE_2_FROM_I2S_2 0x0100 #define CAPTURE_2_FROM_AC97_1 0x0200 - /* CAPTURE_3_FROM_I2S_3 not implemented */ +#define CAPTURE_3_FROM_I2S_3 0x0400 #define MIDI_OUTPUT 0x0800 #define MIDI_INPUT 0x1000 #define AC97_CD_INPUT 0x2000 diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index dbf1f2d4e4b5..ab47c1ca21c4 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -441,9 +441,18 @@ static void oxygen_init(struct oxygen *chip) oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK); - oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, - OXYGEN_I2S_MASTER | - OXYGEN_I2S_MUTE_MCLK); + if (chip->model.device_config & CAPTURE_3_FROM_I2S_3) + oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, + OXYGEN_RATE_48000 | + chip->model.adc_i2s_format | + OXYGEN_I2S_MCLK(chip->model.adc_mclks) | + OXYGEN_I2S_BITS_16 | + OXYGEN_I2S_MASTER | + OXYGEN_I2S_BCLK_64); + else + oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, + OXYGEN_I2S_MASTER | + OXYGEN_I2S_MUTE_MCLK); oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, OXYGEN_SPDIF_OUT_ENABLE | OXYGEN_SPDIF_LOOPBACK); diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index 2f698a9a5044..6492bca8c70f 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c @@ -940,6 +940,33 @@ static const struct { }, }, }, + { + .pcm_dev = CAPTURE_3_FROM_I2S_3, + .controls = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Analog Input Monitor Playback Switch", + .index = 2, + .info = snd_ctl_boolean_mono_info, + .get = monitor_get, + .put = monitor_put, + .private_value = OXYGEN_ADC_MONITOR_C, + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Analog Input Monitor Playback Volume", + .index = 2, + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | + SNDRV_CTL_ELEM_ACCESS_TLV_READ, + .info = monitor_volume_info, + .get = monitor_get, + .put = monitor_put, + .private_value = OXYGEN_ADC_MONITOR_C_HALF_VOL + | (1 << 8), + .tlv = { .p = monitor_db_scale, }, + }, + }, + }, { .pcm_dev = CAPTURE_1_FROM_SPDIF, .controls = { diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index af22a74311d7..aa2ebd1d6d12 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c @@ -144,9 +144,11 @@ static int oxygen_open(struct snd_pcm_substream *substream, runtime->hw = *oxygen_hardware[channel]; switch (channel) { case PCM_C: - runtime->hw.rates &= ~(SNDRV_PCM_RATE_32000 | - SNDRV_PCM_RATE_64000); - runtime->hw.rate_min = 44100; + if (chip->model.device_config & CAPTURE_1_FROM_SPDIF) { + runtime->hw.rates &= ~(SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_64000); + runtime->hw.rate_min = 44100; + } /* fall through */ case PCM_A: case PCM_B: @@ -430,17 +432,36 @@ static int oxygen_rec_c_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct oxygen *chip = snd_pcm_substream_chip(substream); + bool is_spdif; int err; err = oxygen_hw_params(substream, hw_params); if (err < 0) return err; + is_spdif = chip->model.device_config & CAPTURE_1_FROM_SPDIF; + spin_lock_irq(&chip->reg_lock); oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, oxygen_format(hw_params) << OXYGEN_REC_FORMAT_C_SHIFT, OXYGEN_REC_FORMAT_C_MASK); + if (!is_spdif) + oxygen_write16_masked(chip, OXYGEN_I2S_C_FORMAT, + oxygen_rate(hw_params) | + chip->model.adc_i2s_format | + get_mclk(chip, PCM_B, hw_params) | + oxygen_i2s_bits(hw_params), + OXYGEN_I2S_RATE_MASK | + OXYGEN_I2S_FORMAT_MASK | + OXYGEN_I2S_MCLK_MASK | + OXYGEN_I2S_BITS_MASK); spin_unlock_irq(&chip->reg_lock); + + if (!is_spdif) { + mutex_lock(&chip->mutex); + chip->model.set_adc_params(chip, hw_params); + mutex_unlock(&chip->mutex); + } return 0; } @@ -764,5 +785,23 @@ int oxygen_pcm_init(struct oxygen *chip) DEFAULT_BUFFER_BYTES, BUFFER_BYTES_MAX); } + + ins = !!(chip->model.device_config & CAPTURE_3_FROM_I2S_3); + if (ins) { + err = snd_pcm_new(chip->card, "Analog3", 3, 0, ins, &pcm); + if (err < 0) + return err; + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, + &oxygen_rec_c_ops); + oxygen_write8_masked(chip, OXYGEN_REC_ROUTING, + OXYGEN_REC_C_ROUTE_I2S_ADC_3, + 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, + snd_dma_pci_data(chip->pci), + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); + } return 0; } -- cgit From a5a335336715d8648ffb1b105ea625790b9d984e Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 16 Jan 2015 22:15:43 +0100 Subject: ALSA: oxygen: add XIO2001 initialization Configure the XIO2001 bridge on PCI Express cards so that it does less needless prefetching. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_lib.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index ab47c1ca21c4..ffff3b25fd73 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -319,11 +319,12 @@ static void oxygen_restore_eeprom(struct oxygen *chip, static void configure_pcie_bridge(struct pci_dev *pci) { - enum { PEX811X, PI7C9X110 }; + enum { PEX811X, PI7C9X110, XIO2001 }; static const struct pci_device_id bridge_ids[] = { { PCI_VDEVICE(PLX, 0x8111), .driver_data = PEX811X }, { PCI_VDEVICE(PLX, 0x8112), .driver_data = PEX811X }, { PCI_DEVICE(0x12d8, 0xe110), .driver_data = PI7C9X110 }, + { PCI_VDEVICE(TI, 0x8240), .driver_data = XIO2001 }, { } }; struct pci_dev *bridge; @@ -357,6 +358,14 @@ static void configure_pcie_bridge(struct pci_dev *pci) tmp |= 1; /* park the PCI arbiter to the sound chip */ pci_write_config_dword(bridge, 0x40, tmp); break; + + case XIO2001: /* Texas Instruments XIO2001 PCIe/PCI bridge */ + pci_read_config_dword(bridge, 0xe8, &tmp); + tmp &= ~0xf; /* request length limit: 64 bytes */ + tmp &= ~(0xf << 8); + tmp |= 1 << 8; /* request count limit: one buffer */ + pci_write_config_dword(bridge, 0xe8, tmp); + break; } } -- cgit From 53c098bfc5b614cd28c416215f5fa68815f1cce9 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 16 Jan 2015 22:16:35 +0100 Subject: ALSA: add Studio Evolution SE6X support Add a driver for an embedded sound card. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/Kconfig | 9 +++ sound/pci/oxygen/Makefile | 2 + sound/pci/oxygen/se6x.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 sound/pci/oxygen/se6x.c (limited to 'sound') diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 50dd0086cfb1..edfc1b8d553e 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -793,6 +793,15 @@ config SND_RME9652 To compile this driver as a module, choose M here: the module will be called snd-rme9652. +config SND_SE6X + tristate "Studio Evolution SE6X" + depends on SND_OXYGEN=n && SND_VIRTUOSO=n # PCI ID conflict + select SND_OXYGEN_LIB + select SND_PCM + select SND_MPU401_UART + help + Say Y or M here only if you actually have this sound card. + config SND_SIS7019 tristate "SiS 7019 Audio Accelerator" depends on X86_32 diff --git a/sound/pci/oxygen/Makefile b/sound/pci/oxygen/Makefile index 8f4c409f7e45..ab085d753661 100644 --- a/sound/pci/oxygen/Makefile +++ b/sound/pci/oxygen/Makefile @@ -1,8 +1,10 @@ snd-oxygen-lib-objs := oxygen_io.o oxygen_lib.o oxygen_mixer.o oxygen_pcm.o snd-oxygen-objs := oxygen.o xonar_dg_mixer.o xonar_dg.o +snd-se6x-objs := se6x.o snd-virtuoso-objs := virtuoso.o xonar_lib.o \ xonar_pcm179x.o xonar_cs43xx.o xonar_wm87x6.o xonar_hdmi.o obj-$(CONFIG_SND_OXYGEN_LIB) += snd-oxygen-lib.o obj-$(CONFIG_SND_OXYGEN) += snd-oxygen.o +obj-$(CONFIG_SND_SE6X) += snd-se6x.o obj-$(CONFIG_SND_VIRTUOSO) += snd-virtuoso.o diff --git a/sound/pci/oxygen/se6x.c b/sound/pci/oxygen/se6x.c new file mode 100644 index 000000000000..f70d514c1084 --- /dev/null +++ b/sound/pci/oxygen/se6x.c @@ -0,0 +1,160 @@ +/* + * C-Media CMI8787 driver for the Studio Evolution SE6X + * + * Copyright (c) Clemens Ladisch + * + * This driver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2. + * + * This driver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this driver; if not, see . + */ + +/* + * CMI8787: + * + * SPI -> microcontroller (not actually used) + * GPIO 0 -> do. + * GPIO 2 -> do. + * + * DAC0 -> both PCM1792A (L+R, each in mono mode) + * ADC1 <- 1st PCM1804 + * ADC2 <- 2nd PCM1804 + * ADC3 <- 3rd PCM1804 + */ + +#include +#include +#include +#include +#include +#include +#include "oxygen.h" + +MODULE_AUTHOR("Clemens Ladisch "); +MODULE_DESCRIPTION("Studio Evolution SE6X driver"); +MODULE_LICENSE("GPL v2"); +MODULE_SUPPORTED_DEVICE("{{Studio Evolution,SE6X}}"); + +static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; +static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; +static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; + +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "card index"); +module_param_array(id, charp, NULL, 0444); +MODULE_PARM_DESC(id, "ID string"); +module_param_array(enable, bool, NULL, 0444); +MODULE_PARM_DESC(enable, "enable card"); + +static const struct pci_device_id se6x_ids[] = { + { OXYGEN_PCI_SUBID(0x13f6, 0x8788) }, + { } +}; +MODULE_DEVICE_TABLE(pci, se6x_ids); + +static void se6x_init(struct oxygen *chip) +{ + oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x005); + + snd_component_add(chip->card, "PCM1792A"); + snd_component_add(chip->card, "PCM1804"); +} + +static int se6x_control_filter(struct snd_kcontrol_new *template) +{ + /* no DAC volume/mute */ + if (!strncmp(template->name, "Master Playback ", 16)) + return 1; + return 0; +} + +static void se6x_cleanup(struct oxygen *chip) +{ +} + +static void set_pcm1792a_params(struct oxygen *chip, + struct snd_pcm_hw_params *params) +{ + /* nothing to do (the microcontroller monitors DAC_LRCK) */ +} + +static void set_pcm1804_params(struct oxygen *chip, + struct snd_pcm_hw_params *params) +{ +} + +static unsigned int se6x_adjust_dac_routing(struct oxygen *chip, + unsigned int play_routing) +{ + /* route the same stereo pair to DAC0 and DAC1 */ + return ( play_routing & OXYGEN_PLAY_DAC0_SOURCE_MASK) | + ((play_routing << 2) & OXYGEN_PLAY_DAC1_SOURCE_MASK); +} + +static const struct oxygen_model model_se6x = { + .shortname = "Studio Evolution SE6X", + .longname = "C-Media Oxygen HD Audio", + .chip = "CMI8787", + .init = se6x_init, + .control_filter = se6x_control_filter, + .cleanup = se6x_cleanup, + .set_dac_params = set_pcm1792a_params, + .set_adc_params = set_pcm1804_params, + .adjust_dac_routing = se6x_adjust_dac_routing, + .device_config = PLAYBACK_0_TO_I2S | + CAPTURE_0_FROM_I2S_1 | + CAPTURE_2_FROM_I2S_2 | + CAPTURE_3_FROM_I2S_3, + .dac_channels_pcm = 2, + .function_flags = OXYGEN_FUNCTION_SPI, + .dac_mclks = OXYGEN_MCLKS(256, 128, 128), + .adc_mclks = OXYGEN_MCLKS(256, 256, 128), + .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, + .adc_i2s_format = OXYGEN_I2S_FORMAT_I2S, +}; + +static int se6x_get_model(struct oxygen *chip, + const struct pci_device_id *pci_id) +{ + chip->model = model_se6x; + return 0; +} + +static int se6x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) +{ + static int dev; + int err; + + if (dev >= SNDRV_CARDS) + return -ENODEV; + if (!enable[dev]) { + ++dev; + return -ENOENT; + } + err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE, + se6x_ids, se6x_get_model); + if (err >= 0) + ++dev; + return err; +} + +static struct pci_driver se6x_driver = { + .name = KBUILD_MODNAME, + .id_table = se6x_ids, + .probe = se6x_probe, + .remove = oxygen_pci_remove, +#ifdef CONFIG_PM_SLEEP + .driver = { + .pm = &oxygen_pci_pm, + }, +#endif + .shutdown = oxygen_pci_shutdown, +}; + +module_pci_driver(se6x_driver); -- cgit From 2a52b6eef7386cc19dfc0a2e82a7e23d807e51e5 Mon Sep 17 00:00:00 2001 From: Roman Kollar Date: Mon, 19 Jan 2015 10:42:54 +0100 Subject: ALSA: dummy: use setup_timer and mod_timer Use setup_timer and mod_timer instead of structure assignments as it is the preferred way to setup and set the timer. Signed-off-by: Roman Kollar Signed-off-by: Jiri Slaby Signed-off-by: Takashi Iwai --- sound/drivers/dummy.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 5d0dfb787cec..d11baaf0f0b4 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -245,9 +245,8 @@ struct dummy_systimer_pcm { static void dummy_systimer_rearm(struct dummy_systimer_pcm *dpcm) { - dpcm->timer.expires = jiffies + - (dpcm->frac_period_rest + dpcm->rate - 1) / dpcm->rate; - add_timer(&dpcm->timer); + mod_timer(&dpcm->timer, jiffies + + (dpcm->frac_period_rest + dpcm->rate - 1) / dpcm->rate); } static void dummy_systimer_update(struct dummy_systimer_pcm *dpcm) @@ -340,9 +339,8 @@ static int dummy_systimer_create(struct snd_pcm_substream *substream) if (!dpcm) return -ENOMEM; substream->runtime->private_data = dpcm; - init_timer(&dpcm->timer); - dpcm->timer.data = (unsigned long) dpcm; - dpcm->timer.function = dummy_systimer_callback; + setup_timer(&dpcm->timer, dummy_systimer_callback, + (unsigned long) dpcm); spin_lock_init(&dpcm->lock); dpcm->substream = substream; return 0; -- cgit From f169c10597bd55125fc5c9d0c63b8ebf6dd6b5b2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:26:25 +0100 Subject: ALSA: timer: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/core/timer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/core/timer.c b/sound/core/timer.c index 777a45e08e53..a44235555896 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1030,9 +1030,7 @@ static int snd_timer_register_system(void) snd_timer_free(timer); return -ENOMEM; } - init_timer(&priv->tlist); - priv->tlist.function = snd_timer_s_function; - priv->tlist.data = (unsigned long) timer; + setup_timer(&priv->tlist, snd_timer_s_function, (unsigned long) timer); timer->private_data = priv; timer->private_free = snd_timer_free_system; return snd_timer_global_register(timer); -- cgit From db974553e368f0c2caef004b775569e898541c15 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:27:31 +0100 Subject: ALSA: aloop: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/drivers/aloop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 7ea53399404d..7f9126efc1e5 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -181,8 +181,7 @@ static void loopback_timer_start(struct loopback_pcm *dpcm) } tick = dpcm->period_size_frac - dpcm->irq_pos; tick = (tick + dpcm->pcm_bps - 1) / dpcm->pcm_bps; - dpcm->timer.expires = jiffies + tick; - add_timer(&dpcm->timer); + mod_timer(&dpcm->timer, jiffies + tick); } /* call in cable->lock */ -- cgit From b093ed23dad894d473bb2e9948facf7fc509ae77 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:28:13 +0100 Subject: ALSA: mpu401: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/drivers/mpu401/mpu401_uart.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index e3a90d043f03..1e19eb9e1596 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -176,8 +176,7 @@ static void snd_mpu401_uart_timer(unsigned long data) spin_lock_irqsave(&mpu->timer_lock, flags); /*mpu->mode |= MPU401_MODE_TIMER;*/ - mpu->timer.expires = 1 + jiffies; - add_timer(&mpu->timer); + mod_timer(&mpu->timer, 1 + jiffies); spin_unlock_irqrestore(&mpu->timer_lock, flags); if (mpu->rmidi) _snd_mpu401_uart_interrupt(mpu); @@ -192,11 +191,9 @@ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu, int input) spin_lock_irqsave (&mpu->timer_lock, flags); if (mpu->timer_invoked == 0) { - init_timer(&mpu->timer); - mpu->timer.data = (unsigned long)mpu; - mpu->timer.function = snd_mpu401_uart_timer; - mpu->timer.expires = 1 + jiffies; - add_timer(&mpu->timer); + setup_timer(&mpu->timer, snd_mpu401_uart_timer, + (unsigned long)mpu); + mod_timer(&mpu->timer, 1 + jiffies); } mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER : MPU401_MODE_OUTPUT_TIMER; -- cgit From 2b1b78114319e0ed2b7ca8c75d9cde6d2bf8f9fc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:28:36 +0100 Subject: ALSA: mtpav: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/drivers/mtpav.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index 15769447688f..30e8a1d5bc87 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -414,8 +414,7 @@ static void snd_mtpav_output_timer(unsigned long data) spin_lock_irqsave(&chip->spinlock, flags); /* reprogram timer */ - chip->timer.expires = 1 + jiffies; - add_timer(&chip->timer); + mod_timer(&chip->timer, 1 + jiffies); /* process each port */ for (p = 0; p <= chip->num_ports * 2 + MTPAV_PIDX_BROADCAST; p++) { struct mtpav_port *portp = &chip->ports[p]; @@ -428,8 +427,7 @@ static void snd_mtpav_output_timer(unsigned long data) /* spinlock held! */ static void snd_mtpav_add_output_timer(struct mtpav *chip) { - chip->timer.expires = 1 + jiffies; - add_timer(&chip->timer); + mod_timer(&chip->timer, 1 + jiffies); } /* spinlock held! */ @@ -704,15 +702,13 @@ static int snd_mtpav_probe(struct platform_device *dev) mtp_card = card->private_data; spin_lock_init(&mtp_card->spinlock); - init_timer(&mtp_card->timer); mtp_card->card = card; mtp_card->irq = -1; mtp_card->share_irq = 0; mtp_card->inmidistate = 0; mtp_card->outmidihwport = 0xffffffff; - init_timer(&mtp_card->timer); - mtp_card->timer.function = snd_mtpav_output_timer; - mtp_card->timer.data = (unsigned long) mtp_card; + setup_timer(&mtp_card->timer, snd_mtpav_output_timer, + (unsigned long) mtp_card); card->private_free = snd_mtpav_free; -- cgit From f5d5f75fe167c8b80747290968aeaa91457cb10a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:28:54 +0100 Subject: ALSA: opl3: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_midi.c | 11 ++++------- sound/drivers/opl3/opl3_seq.c | 4 +--- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 6c6d09a51f42..f62780ed64ad 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -258,12 +258,10 @@ void snd_opl3_timer_func(unsigned long data) spin_unlock_irqrestore(&opl3->voice_lock, flags); spin_lock_irqsave(&opl3->sys_timer_lock, flags); - if (again) { - opl3->tlist.expires = jiffies + 1; /* invoke again */ - add_timer(&opl3->tlist); - } else { + if (again) + mod_timer(&opl3->tlist, jiffies + 1); /* invoke again */ + else opl3->sys_timer_status = 0; - } spin_unlock_irqrestore(&opl3->sys_timer_lock, flags); } @@ -275,8 +273,7 @@ static void snd_opl3_start_timer(struct snd_opl3 *opl3) unsigned long flags; spin_lock_irqsave(&opl3->sys_timer_lock, flags); if (! opl3->sys_timer_status) { - opl3->tlist.expires = jiffies + 1; - add_timer(&opl3->tlist); + mod_timer(&opl3->tlist, jiffies + 1); opl3->sys_timer_status = 1; } spin_unlock_irqrestore(&opl3->sys_timer_lock, flags); diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 68399538e435..a9f618e06a22 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -247,9 +247,7 @@ static int snd_opl3_seq_new_device(struct snd_seq_device *dev) } /* setup system timer */ - init_timer(&opl3->tlist); - opl3->tlist.function = snd_opl3_timer_func; - opl3->tlist.data = (unsigned long) opl3; + setup_timer(&opl3->tlist, snd_opl3_timer_func, (unsigned long) opl3); spin_lock_init(&opl3->sys_timer_lock); opl3->sys_timer_status = 0; -- cgit From d80d05fcca1771ff68e0b385459fabb3eb938e98 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:29:09 +0100 Subject: ALSA: serial-u16550: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/drivers/serial-u16550.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 13a34e3c6382..8c1dc73e14e4 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -174,9 +174,8 @@ static inline void snd_uart16550_add_timer(struct snd_uart16550 *uart) { if (!uart->timer_running) { /* timer 38600bps * 10bit * 16byte */ - uart->buffer_timer.expires = jiffies + (HZ+255)/256; + mod_timer(&uart->buffer_timer, jiffies + (HZ + 255) / 256); uart->timer_running = 1; - add_timer(&uart->buffer_timer); } } @@ -830,9 +829,8 @@ static int snd_uart16550_create(struct snd_card *card, uart->prev_in = 0; uart->rstatus = 0; memset(uart->prev_status, 0x80, sizeof(unsigned char) * SNDRV_SERIAL_MAX_OUTS); - init_timer(&uart->buffer_timer); - uart->buffer_timer.function = snd_uart16550_buffer_timer; - uart->buffer_timer.data = (unsigned long)uart; + setup_timer(&uart->buffer_timer, snd_uart16550_buffer_timer, + (unsigned long)uart); uart->timer_running = 0; /* Register device */ -- cgit From 867a0e057f69a06e032f779efd4325ef632084af Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:29:25 +0100 Subject: ALSA: ak4117: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/i2c/other/ak4117.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c index 88452e899bd9..48848909a5a9 100644 --- a/sound/i2c/other/ak4117.c +++ b/sound/i2c/other/ak4117.c @@ -91,9 +91,7 @@ int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t chip->read = read; chip->write = write; chip->private_data = private_data; - init_timer(&chip->timer); - chip->timer.data = (unsigned long)chip; - chip->timer.function = snd_ak4117_timer; + setup_timer(&chip->timer, snd_ak4117_timer, (unsigned long)chip); for (reg = 0; reg < 5; reg++) chip->regmap[reg] = pgm[reg]; @@ -139,8 +137,7 @@ void snd_ak4117_reinit(struct ak4117 *chip) /* release powerdown, everything is initialized now */ reg_write(chip, AK4117_REG_PWRDN, old | AK4117_RST | AK4117_PWN); chip->init = 0; - chip->timer.expires = 1 + jiffies; - add_timer(&chip->timer); + mod_timer(&chip->timer, 1 + jiffies); } static unsigned int external_rate(unsigned char rcs1) @@ -540,8 +537,7 @@ static void snd_ak4117_timer(unsigned long data) if (chip->init) return; snd_ak4117_check_rate_and_errors(chip, 0); - chip->timer.expires = 1 + jiffies; - add_timer(&chip->timer); + mod_timer(&chip->timer, 1 + jiffies); } EXPORT_SYMBOL(snd_ak4117_create); -- cgit From f05b4127730f16641de8cc39cd79b30120d37b51 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:29:42 +0100 Subject: ALSA: sb: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000_pcm.c | 10 +++------- sound/isa/sb/sb8_midi.c | 12 +++++------- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 2f85c66f8e38..250fd0006b53 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -207,8 +207,7 @@ static void emu8k_pcm_timer_func(unsigned long data) rec->last_ptr = ptr; /* reprogram timer */ - rec->timer.expires = jiffies + 1; - add_timer(&rec->timer); + mod_timer(&rec->timer, jiffies + 1); /* update period */ if (rec->period_pos >= (int)rec->period_size) { @@ -240,9 +239,7 @@ static int emu8k_pcm_open(struct snd_pcm_substream *subs) runtime->private_data = rec; spin_lock_init(&rec->timer_lock); - init_timer(&rec->timer); - rec->timer.function = emu8k_pcm_timer_func; - rec->timer.data = (unsigned long)rec; + setup_timer(&rec->timer, emu8k_pcm_timer_func, (unsigned long)rec); runtime->hw = emu8k_pcm_hw; runtime->hw.buffer_bytes_max = emu->mem_size - LOOP_BLANK_SIZE * 3; @@ -359,8 +356,7 @@ static void start_voice(struct snd_emu8k_pcm *rec, int ch) /* start timer */ spin_lock_irqsave(&rec->timer_lock, flags); if (! rec->timer_running) { - rec->timer.expires = jiffies + 1; - add_timer(&rec->timer); + mod_timer(&rec->timer, jiffies + 1); rec->timer_running = 1; } spin_unlock_irqrestore(&rec->timer_lock, flags); diff --git a/sound/isa/sb/sb8_midi.c b/sound/isa/sb/sb8_midi.c index ffc71f0267df..925ea45b3d97 100644 --- a/sound/isa/sb/sb8_midi.c +++ b/sound/isa/sb/sb8_midi.c @@ -216,8 +216,7 @@ static void snd_sb8dsp_midi_output_timer(unsigned long data) unsigned long flags; spin_lock_irqsave(&chip->open_lock, flags); - chip->midi_timer.expires = 1 + jiffies; - add_timer(&chip->midi_timer); + mod_timer(&chip->midi_timer, 1 + jiffies); spin_unlock_irqrestore(&chip->open_lock, flags); snd_sb8dsp_midi_output_write(substream); } @@ -231,11 +230,10 @@ static void snd_sb8dsp_midi_output_trigger(struct snd_rawmidi_substream *substre spin_lock_irqsave(&chip->open_lock, flags); if (up) { if (!(chip->open & SB_OPEN_MIDI_OUTPUT_TRIGGER)) { - init_timer(&chip->midi_timer); - chip->midi_timer.function = snd_sb8dsp_midi_output_timer; - chip->midi_timer.data = (unsigned long) substream; - chip->midi_timer.expires = 1 + jiffies; - add_timer(&chip->midi_timer); + setup_timer(&chip->midi_timer, + snd_sb8dsp_midi_output_timer, + (unsigned long) substream); + mod_timer(&chip->midi_timer, 1 + jiffies); chip->open |= SB_OPEN_MIDI_OUTPUT_TRIGGER; } } else { -- cgit From b843ce7425e6c7e5daa731f755373298499c22d4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:29:55 +0100 Subject: ALSA: wavefront: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/isa/wavefront/wavefront_midi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/isa/wavefront/wavefront_midi.c b/sound/isa/wavefront/wavefront_midi.c index 7dc991682297..b8009cbcd34e 100644 --- a/sound/isa/wavefront/wavefront_midi.c +++ b/sound/isa/wavefront/wavefront_midi.c @@ -356,8 +356,7 @@ static void snd_wavefront_midi_output_timer(unsigned long data) unsigned long flags; spin_lock_irqsave (&midi->virtual, flags); - midi->timer.expires = 1 + jiffies; - add_timer(&midi->timer); + mod_timer(&midi->timer, 1 + jiffies); spin_unlock_irqrestore (&midi->virtual, flags); snd_wavefront_midi_output_write(card); } @@ -384,11 +383,10 @@ static void snd_wavefront_midi_output_trigger(struct snd_rawmidi_substream *subs if (up) { if ((midi->mode[mpu] & MPU401_MODE_OUTPUT_TRIGGER) == 0) { if (!midi->istimer) { - init_timer(&midi->timer); - midi->timer.function = snd_wavefront_midi_output_timer; - midi->timer.data = (unsigned long) substream->rmidi->card->private_data; - midi->timer.expires = 1 + jiffies; - add_timer(&midi->timer); + setup_timer(&midi->timer, + snd_wavefront_midi_output_timer, + (unsigned long) substream->rmidi->card->private_data); + mod_timer(&midi->timer, 1 + jiffies); } midi->istimer++; midi->mode[mpu] |= MPU401_MODE_OUTPUT_TRIGGER; -- cgit From 6fec2b57239fa253829912ac0ab76375da8e879d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:32:51 +0100 Subject: ALSA: asihpi: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 7a55fefed5c4..e5cd7be85355 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -540,9 +540,8 @@ static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream * expiry = HZ / 200; expiry = max(expiry, 1); /* don't let it be zero! */ - dpcm->timer.expires = jiffies + expiry; + mod_timer(&dpcm->timer, jiffies + expiry); dpcm->respawn_timer = 1; - add_timer(&dpcm->timer); } static void snd_card_asihpi_pcm_timer_stop(struct snd_pcm_substream *substream) @@ -1064,9 +1063,8 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) If internal and other stream playing, can't switch */ - init_timer(&dpcm->timer); - dpcm->timer.data = (unsigned long) dpcm; - dpcm->timer.function = snd_card_asihpi_timer_function; + setup_timer(&dpcm->timer, snd_card_asihpi_timer_function, + (unsigned long) dpcm); dpcm->substream = substream; runtime->private_data = dpcm; runtime->private_free = snd_card_asihpi_runtime_free; @@ -1246,9 +1244,8 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) if (err) return -EIO; - init_timer(&dpcm->timer); - dpcm->timer.data = (unsigned long) dpcm; - dpcm->timer.function = snd_card_asihpi_timer_function; + setup_timer(&dpcm->timer, snd_card_asihpi_timer_function, + (unsigned long) dpcm); dpcm->substream = substream; runtime->private_data = dpcm; runtime->private_free = snd_card_asihpi_runtime_free; -- cgit From 8a3e7dfc90dcb2ed6e79b559ce072aeaec291ebd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:33:20 +0100 Subject: ALSA: echoaudio: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/midi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/echoaudio/midi.c b/sound/pci/echoaudio/midi.c index d913749d154a..a8fe58335ddc 100644 --- a/sound/pci/echoaudio/midi.c +++ b/sound/pci/echoaudio/midi.c @@ -257,9 +257,8 @@ static void snd_echo_midi_output_trigger(struct snd_rawmidi_substream *substream spin_lock_irq(&chip->lock); if (up) { if (!chip->tinuse) { - init_timer(&chip->timer); - chip->timer.function = snd_echo_midi_output_write; - chip->timer.data = (unsigned long)chip; + setup_timer(&chip->timer, snd_echo_midi_output_write, + (unsigned long)chip); chip->tinuse = 1; } } else { -- cgit From 3d6f0e0cb348ab1d74cb6fcb2745ebca6029bf9d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:34:18 +0100 Subject: ALSA: korg1212: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/pci/korg1212/korg1212.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 59d21c9401d2..bd569e580277 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -585,8 +585,7 @@ static void snd_korg1212_SendStop(struct snd_korg1212 *korg1212) korg1212->sharedBufferPtr->cardCommand = 0xffffffff; /* program the timer */ korg1212->stop_pending_cnt = HZ; - korg1212->timer.expires = jiffies + 1; - add_timer(&korg1212->timer); + mod_timer(&korg1212->timer, jiffies + 1); } } @@ -617,8 +616,7 @@ static void snd_korg1212_timer_func(unsigned long data) } else { if (--korg1212->stop_pending_cnt > 0) { /* reprogram timer */ - korg1212->timer.expires = jiffies + 1; - add_timer(&korg1212->timer); + mod_timer(&korg1212->timer, jiffies + 1); } else { snd_printd("korg1212_timer_func timeout\n"); korg1212->sharedBufferPtr->cardCommand = 0; @@ -2172,9 +2170,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, init_waitqueue_head(&korg1212->wait); spin_lock_init(&korg1212->lock); mutex_init(&korg1212->open_mutex); - init_timer(&korg1212->timer); - korg1212->timer.function = snd_korg1212_timer_func; - korg1212->timer.data = (unsigned long)korg1212; + setup_timer(&korg1212->timer, snd_korg1212_timer_func, + (unsigned long)korg1212); korg1212->irq = -1; korg1212->clkSource = K1212_CLKIDX_Local; -- cgit From c41c009ed5f0d20ab4cbdff37ddbfd072c3c2d92 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:34:36 +0100 Subject: ALSA: hdsp: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdsp.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index fe66bcb21475..98a2d911ef17 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -1428,10 +1428,8 @@ static void snd_hdsp_midi_output_timer(unsigned long data) leaving istimer wherever it was set before. */ - if (hmidi->istimer) { - hmidi->timer.expires = 1 + jiffies; - add_timer(&hmidi->timer); - } + if (hmidi->istimer) + mod_timer(&hmidi->timer, 1 + jiffies); spin_unlock_irqrestore (&hmidi->lock, flags); } @@ -1445,11 +1443,9 @@ static void snd_hdsp_midi_output_trigger(struct snd_rawmidi_substream *substream spin_lock_irqsave (&hmidi->lock, flags); if (up) { if (!hmidi->istimer) { - init_timer(&hmidi->timer); - hmidi->timer.function = snd_hdsp_midi_output_timer; - hmidi->timer.data = (unsigned long) hmidi; - hmidi->timer.expires = 1 + jiffies; - add_timer(&hmidi->timer); + setup_timer(&hmidi->timer, snd_hdsp_midi_output_timer, + (unsigned long) hmidi); + mod_timer(&hmidi->timer, 1 + jiffies); hmidi->istimer++; } } else { -- cgit From 04018e137c298f199fbf0f0c431d975f584f4702 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:34:45 +0100 Subject: ALSA: hdspm: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdspm.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 8109b8e5f6ef..1716323fed9c 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -1957,10 +1957,8 @@ static void snd_hdspm_midi_output_timer(unsigned long data) leaving istimer wherever it was set before. */ - if (hmidi->istimer) { - hmidi->timer.expires = 1 + jiffies; - add_timer(&hmidi->timer); - } + if (hmidi->istimer) + mod_timer(&hmidi->timer, 1 + jiffies); spin_unlock_irqrestore (&hmidi->lock, flags); } @@ -1975,11 +1973,9 @@ snd_hdspm_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) spin_lock_irqsave (&hmidi->lock, flags); if (up) { if (!hmidi->istimer) { - init_timer(&hmidi->timer); - hmidi->timer.function = snd_hdspm_midi_output_timer; - hmidi->timer.data = (unsigned long) hmidi; - hmidi->timer.expires = 1 + jiffies; - add_timer(&hmidi->timer); + setup_timer(&hmidi->timer, snd_hdspm_midi_output_timer, + (unsigned long) hmidi); + mod_timer(&hmidi->timer, 1 + jiffies); hmidi->istimer++; } } else { -- cgit From da1a39242a946b34cf16a0119a7a3b852b17fef5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:35:01 +0100 Subject: ALSA: aica: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/sh/aica.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/sh/aica.c b/sound/sh/aica.c index f44dda610ed2..8212300088fc 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -343,11 +343,9 @@ static void spu_begin_dma(struct snd_pcm_substream *substream) mod_timer(&dreamcastcard->timer, jiffies + 4); return; } - init_timer(&(dreamcastcard->timer)); - dreamcastcard->timer.data = (unsigned long) substream; - dreamcastcard->timer.function = aica_period_elapsed; - dreamcastcard->timer.expires = jiffies + 4; - add_timer(&(dreamcastcard->timer)); + setup_timer(&dreamcastcard->timer, aica_period_elapsed, + (unsigned long) substream); + mod_timer(&dreamcastcard->timer, jiffies + 4); } static int snd_aicapcm_pcm_open(struct snd_pcm_substream -- cgit From abd083526af3a8a1610e884c8e619925c3d663e6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:41:13 +0100 Subject: ALSA: emux: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/synth/emux/emux.c | 4 +--- sound/synth/emux/emux_synth.c | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index f27a1c85f81b..49195325fdf6 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -53,9 +53,7 @@ int snd_emux_new(struct snd_emux **remu) emu->max_voices = 0; emu->use_time = 0; - init_timer(&emu->tlist); - emu->tlist.function = snd_emux_timer_callback; - emu->tlist.data = (unsigned long)emu; + setup_timer(&emu->tlist, snd_emux_timer_callback, (unsigned long)emu); emu->timer_active = 0; *remu = emu; diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c index 9a38de459acb..599551b5af44 100644 --- a/sound/synth/emux/emux_synth.c +++ b/sound/synth/emux/emux_synth.c @@ -186,8 +186,7 @@ snd_emux_note_off(void *p, int note, int vel, struct snd_midi_channel *chan) */ vp->state = SNDRV_EMUX_ST_PENDING; if (! emu->timer_active) { - emu->tlist.expires = jiffies + 1; - add_timer(&emu->tlist); + mod_timer(&emu->tlist, jiffies + 1); emu->timer_active = 1; } } else @@ -223,8 +222,7 @@ void snd_emux_timer_callback(unsigned long data) } } if (do_again) { - emu->tlist.expires = jiffies + 1; - add_timer(&emu->tlist); + mod_timer(&emu->tlist, jiffies + 1); emu->timer_active = 1; } else emu->timer_active = 0; -- cgit From 28e237a9b7bc45d048ba7cb683ab348701e099fd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:43:50 +0100 Subject: ALSA: usb-audio: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/usb/midi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/usb/midi.c b/sound/usb/midi.c index 5bfb695547f8..417ebb11cf48 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -2292,14 +2292,13 @@ int snd_usbmidi_create(struct snd_card *card, umidi->iface = iface; umidi->quirk = quirk; umidi->usb_protocol_ops = &snd_usbmidi_standard_ops; - init_timer(&umidi->error_timer); spin_lock_init(&umidi->disc_lock); init_rwsem(&umidi->disc_rwsem); mutex_init(&umidi->mutex); umidi->usb_id = USB_ID(le16_to_cpu(umidi->dev->descriptor.idVendor), le16_to_cpu(umidi->dev->descriptor.idProduct)); - umidi->error_timer.function = snd_usbmidi_error_timer; - umidi->error_timer.data = (unsigned long)umidi; + setup_timer(&umidi->error_timer, snd_usbmidi_error_timer, + (unsigned long)umidi); /* detect the endpoint(s) to use */ memset(endpoints, 0, sizeof(endpoints)); -- cgit From 0f2524b347b1ce16ce6a34cb194445e25bc6ae42 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 11:44:40 +0100 Subject: ALSA: line6: Use setup_timer() and mod_timer() No functional change, refactoring with the standard helpers. Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 3 +-- sound/usb/line6/toneport.c | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index fc852f6ab8bc..19904d677114 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -415,8 +415,7 @@ void line6_start_timer(struct timer_list *timer, unsigned int msecs, void (*function)(unsigned long), unsigned long data) { setup_timer(timer, function, data); - timer->expires = jiffies + msecs * HZ / 1000; - add_timer(timer); + mod_timer(timer, jiffies + msecs * HZ / 1000); } /* diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index aae78d8a82d9..7f97f4a812a7 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -433,11 +433,9 @@ static int toneport_try_init(struct usb_interface *interface, toneport_setup(toneport); - init_timer(&toneport->timer); - toneport->timer.expires = jiffies + TONEPORT_PCM_DELAY * HZ; - toneport->timer.function = toneport_start_pcm; - toneport->timer.data = (unsigned long)toneport; - add_timer(&toneport->timer); + setup_timer(&toneport->timer, toneport_start_pcm, + (unsigned long)toneport); + mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ); return 0; } -- cgit From ccddbe4a99536154e61d16c0f1c2df8a6d63f52a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 15 Jan 2015 08:22:31 +0100 Subject: ALSA: line6: Split to each driver Split to each individual driver for POD, PODHD, TonePort and Variax with a core LINE6 helper module. The new modules follow the standard ALSA naming rule with snd prefix: snd-usb-pod, snd-usb-podhd, snd-usb-toneport and snd-usb-variax, together with the corresponding CONFIG_SND_USB_* Kconfig items. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/Makefile | 2 +- sound/usb/line6/Kconfig | 36 ++-- sound/usb/line6/Makefile | 21 ++- sound/usb/line6/audio.c | 3 + sound/usb/line6/capture.c | 1 - sound/usb/line6/driver.c | 452 ++++----------------------------------------- sound/usb/line6/driver.h | 39 ++-- sound/usb/line6/midi.c | 3 +- sound/usb/line6/pcm.c | 6 +- sound/usb/line6/playback.c | 1 - sound/usb/line6/pod.c | 224 +++++++++++++++++++++- sound/usb/line6/pod.h | 92 --------- sound/usb/line6/podhd.c | 124 ++++++++++++- sound/usb/line6/podhd.h | 29 --- sound/usb/line6/toneport.c | 188 ++++++++++++++++++- sound/usb/line6/toneport.h | 51 ----- sound/usb/line6/variax.c | 133 ++++++++++++- sound/usb/line6/variax.h | 70 ------- 18 files changed, 748 insertions(+), 727 deletions(-) delete mode 100644 sound/usb/line6/pod.h delete mode 100644 sound/usb/line6/podhd.h delete mode 100644 sound/usb/line6/toneport.h delete mode 100644 sound/usb/line6/variax.h (limited to 'sound') diff --git a/sound/usb/Makefile b/sound/usb/Makefile index 54045b745d11..2d2d122b069f 100644 --- a/sound/usb/Makefile +++ b/sound/usb/Makefile @@ -25,4 +25,4 @@ obj-$(CONFIG_SND_USB_USX2Y) += snd-usbmidi-lib.o obj-$(CONFIG_SND_USB_US122L) += snd-usbmidi-lib.o obj-$(CONFIG_SND) += misc/ usx2y/ caiaq/ 6fire/ hiface/ bcd2000/ -obj-$(CONFIG_LINE6_USB) += line6/ +obj-$(CONFIG_SND_USB_LINE6) += line6/ diff --git a/sound/usb/line6/Kconfig b/sound/usb/line6/Kconfig index 4f1219b4c692..33deb419dde8 100644 --- a/sound/usb/line6/Kconfig +++ b/sound/usb/line6/Kconfig @@ -1,12 +1,14 @@ -menuconfig LINE6_USB - tristate "Line6 USB support" - depends on USB && SND +config SND_USB_LINE6 + tristate select SND_RAWMIDI select SND_PCM + +config SND_USB_POD + tristate "Line6 POD USB support" + select SND_USB_LINE6 help - This is a driver for the guitar amp, cab, and effects modeller - PODxt Pro by Line6 (and similar devices), supporting the - following features: + This is a driver for PODxt and other similar devices, + supporting the following features: * Reading/writing individual parameters * Reading/writing complete channel, effects setup, and amp setup data @@ -18,14 +20,27 @@ menuconfig LINE6_USB * Signal routing (record clean/processed guitar signal, re-amping) - Preliminary support for the Variax Workbench and TonePort - devices is included. +config SND_USB_PODHD + tristate "Line6 POD HD300/400/500 USB support" + select SND_USB_LINE6 + help + This is a driver for POD HD300, 400 and 500 devices. -if LINE6_USB +config SND_USB_TONEPORT + tristate "TonePort GX, UX1 and UX2 USB support" + select SND_USB_LINE6 + help + This is a driver for TonePort GX, UX1 and UX2 devices. + +config SND_USB_VARIAX + tristate "Variax Workbench USB support" + select SND_USB_LINE6 + help + This is a driver for Variax Workbench device. config LINE6_USB_IMPULSE_RESPONSE bool "measure impulse response" - default n + depends on SND_USB_LINE6 help Say Y here to add code to measure the impulse response of a Line6 device. This is more accurate than user-space methods since it @@ -35,4 +50,3 @@ config LINE6_USB_IMPULSE_RESPONSE If unsure, say N. -endif # LINE6_USB diff --git a/sound/usb/line6/Makefile b/sound/usb/line6/Makefile index ae5c374b0f87..fa3a78dac097 100644 --- a/sound/usb/line6/Makefile +++ b/sound/usb/line6/Makefile @@ -1,14 +1,19 @@ -obj-$(CONFIG_LINE6_USB) += line6usb.o - -line6usb-y := \ +snd-usb-line6-y := \ audio.o \ capture.o \ driver.o \ midi.o \ midibuf.o \ pcm.o \ - playback.o \ - pod.o \ - toneport.o \ - variax.o \ - podhd.o + playback.o + +snd-usb-pod-y := pod.o +snd-usb-podhd-y := podhd.o +snd-usb-toneport-y := toneport.o +snd-usb-variax-y := variax.o + +obj-$(CONFIG_SND_USB_LINE6) += snd-usb-line6.o +obj-$(CONFIG_SND_USB_POD) += snd-usb-pod.o +obj-$(CONFIG_SND_USB_PODHD) += snd-usb-podhd.o +obj-$(CONFIG_SND_USB_TONEPORT) += snd-usb-toneport.o +obj-$(CONFIG_SND_USB_VARIAX) += snd-usb-variax.o diff --git a/sound/usb/line6/audio.c b/sound/usb/line6/audio.c index 171d80c1b020..95686e5af4bd 100644 --- a/sound/usb/line6/audio.c +++ b/sound/usb/line6/audio.c @@ -40,6 +40,7 @@ int line6_init_audio(struct usb_line6 *line6) dev_name(line6->ifcdev)); return 0; } +EXPORT_SYMBOL_GPL(line6_init_audio); /* Register the Line6 USB audio system. @@ -54,6 +55,7 @@ int line6_register_audio(struct usb_line6 *line6) return 0; } +EXPORT_SYMBOL_GPL(line6_register_audio); /* Cleanup the Line6 USB audio system. @@ -69,3 +71,4 @@ void line6_cleanup_audio(struct usb_line6 *line6) snd_card_free(card); line6->card = NULL; } +EXPORT_SYMBOL_GPL(line6_cleanup_audio); diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index f24c7c5e0a3e..da4ab013ea8e 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -18,7 +18,6 @@ #include "capture.h" #include "driver.h" #include "pcm.h" -#include "pod.h" /* Find a free URB and submit it. diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 19904d677114..149c393c7302 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -19,269 +20,20 @@ #include "driver.h" #include "midi.h" #include "playback.h" -#include "pod.h" -#include "podhd.h" #include "revision.h" -#include "toneport.h" #include "usbdefs.h" -#include "variax.h" #define DRIVER_AUTHOR "Markus Grabner " #define DRIVER_DESC "Line6 USB Driver" #define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION -#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) -#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) - -/* table of devices that work with this driver */ -static const struct usb_device_id line6_id_table[] = { - { LINE6_DEVICE(0x4250), .driver_info = LINE6_BASSPODXT }, - { LINE6_DEVICE(0x4642), .driver_info = LINE6_BASSPODXTLIVE }, - { LINE6_DEVICE(0x4252), .driver_info = LINE6_BASSPODXTPRO }, - { LINE6_DEVICE(0x4750), .driver_info = LINE6_GUITARPORT }, - { LINE6_IF_NUM(0x5051, 1), .driver_info = LINE6_POCKETPOD }, - { LINE6_DEVICE(0x5057), .driver_info = LINE6_PODHD300 }, - { LINE6_DEVICE(0x5058), .driver_info = LINE6_PODHD400 }, - { LINE6_IF_NUM(0x414D, 0), .driver_info = LINE6_PODHD500_0 }, - { LINE6_IF_NUM(0x414D, 1), .driver_info = LINE6_PODHD500_1 }, - { LINE6_DEVICE(0x4153), .driver_info = LINE6_PODSTUDIO_GX }, - { LINE6_DEVICE(0x4150), .driver_info = LINE6_PODSTUDIO_UX1 }, - { LINE6_IF_NUM(0x4151, 0), .driver_info = LINE6_PODSTUDIO_UX2 }, - { LINE6_DEVICE(0x5044), .driver_info = LINE6_PODXT }, - { LINE6_IF_NUM(0x4650, 0), .driver_info = LINE6_PODXTLIVE_POD }, - { LINE6_IF_NUM(0x4650, 1), .driver_info = LINE6_PODXTLIVE_VARIAX }, - { LINE6_DEVICE(0x5050), .driver_info = LINE6_PODXTPRO }, - { LINE6_DEVICE(0x4147), .driver_info = LINE6_TONEPORT_GX }, - { LINE6_DEVICE(0x4141), .driver_info = LINE6_TONEPORT_UX1 }, - { LINE6_IF_NUM(0x4142, 0), .driver_info = LINE6_TONEPORT_UX2 }, - { LINE6_DEVICE(0x534d), .driver_info = LINE6_VARIAX }, - {} -}; - -MODULE_DEVICE_TABLE(usb, line6_id_table); - -static const struct line6_properties line6_properties_table[] = { - [LINE6_BASSPODXT] = { - .id = "BassPODxt", - .name = "BassPODxt", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 5, - .ep_ctrl_r = 0x84, - .ep_ctrl_w = 0x03, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_BASSPODXTLIVE] = { - .id = "BassPODxtLive", - .name = "BassPODxt Live", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 1, - .ep_ctrl_r = 0x84, - .ep_ctrl_w = 0x03, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_BASSPODXTPRO] = { - .id = "BassPODxtPro", - .name = "BassPODxt Pro", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 5, - .ep_ctrl_r = 0x84, - .ep_ctrl_w = 0x03, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_GUITARPORT] = { - .id = "GuitarPort", - .name = "GuitarPort", - .capabilities = LINE6_CAP_PCM, - .altsetting = 2, /* 1..4 seem to be ok */ - /* no control channel */ - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_POCKETPOD] = { - .id = "PocketPOD", - .name = "Pocket POD", - .capabilities = LINE6_CAP_CONTROL, - .altsetting = 0, - .ep_ctrl_r = 0x82, - .ep_ctrl_w = 0x02, - /* no audio channel */ - }, - [LINE6_PODHD300] = { - .id = "PODHD300", - .name = "POD HD300", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 5, - .ep_ctrl_r = 0x84, - .ep_ctrl_w = 0x03, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_PODHD400] = { - .id = "PODHD400", - .name = "POD HD400", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 5, - .ep_ctrl_r = 0x84, - .ep_ctrl_w = 0x03, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_PODHD500_0] = { - .id = "PODHD500", - .name = "POD HD500", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 1, - .ep_ctrl_r = 0x81, - .ep_ctrl_w = 0x01, - .ep_audio_r = 0x86, - .ep_audio_w = 0x02, - }, - [LINE6_PODHD500_1] = { - .id = "PODHD500", - .name = "POD HD500", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 1, - .ep_ctrl_r = 0x81, - .ep_ctrl_w = 0x01, - .ep_audio_r = 0x86, - .ep_audio_w = 0x02, - }, - [LINE6_PODSTUDIO_GX] = { - .id = "PODStudioGX", - .name = "POD Studio GX", - .capabilities = LINE6_CAP_PCM, - .altsetting = 2, /* 1..4 seem to be ok */ - /* no control channel */ - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_PODSTUDIO_UX1] = { - .id = "PODStudioUX1", - .name = "POD Studio UX1", - .capabilities = LINE6_CAP_PCM, - .altsetting = 2, /* 1..4 seem to be ok */ - /* no control channel */ - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_PODSTUDIO_UX2] = { - .id = "PODStudioUX2", - .name = "POD Studio UX2", - .capabilities = LINE6_CAP_PCM, - .altsetting = 2, /* defaults to 44.1kHz, 16-bit */ - /* no control channel */ - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_PODXT] = { - .id = "PODxt", - .name = "PODxt", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 5, - .ep_ctrl_r = 0x84, - .ep_ctrl_w = 0x03, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_PODXTLIVE_POD] = { - .id = "PODxtLive", - .name = "PODxt Live", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 1, - .ep_ctrl_r = 0x84, - .ep_ctrl_w = 0x03, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_PODXTLIVE_VARIAX] = { - .id = "PODxtLive", - .name = "PODxt Live", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 1, - .ep_ctrl_r = 0x86, - .ep_ctrl_w = 0x05, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_PODXTPRO] = { - .id = "PODxtPro", - .name = "PODxt Pro", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, - .altsetting = 5, - .ep_ctrl_r = 0x84, - .ep_ctrl_w = 0x03, - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_TONEPORT_GX] = { - .id = "TonePortGX", - .name = "TonePort GX", - .capabilities = LINE6_CAP_PCM, - .altsetting = 2, /* 1..4 seem to be ok */ - /* no control channel */ - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_TONEPORT_UX1] = { - .id = "TonePortUX1", - .name = "TonePort UX1", - .capabilities = LINE6_CAP_PCM, - .altsetting = 2, /* 1..4 seem to be ok */ - /* no control channel */ - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_TONEPORT_UX2] = { - .id = "TonePortUX2", - .name = "TonePort UX2", - .capabilities = LINE6_CAP_PCM, - .altsetting = 2, /* defaults to 44.1kHz, 16-bit */ - /* no control channel */ - .ep_audio_r = 0x82, - .ep_audio_w = 0x01, - }, - [LINE6_VARIAX] = { - .id = "Variax", - .name = "Variax Workbench", - .capabilities = LINE6_CAP_CONTROL, - .altsetting = 1, - .ep_ctrl_r = 0x82, - .ep_ctrl_w = 0x01, - /* no audio channel */ - } -}; - /* This is Line6's MIDI manufacturer ID. */ const unsigned char line6_midi_id[] = { 0x00, 0x01, 0x0c }; +EXPORT_SYMBOL_GPL(line6_midi_id); /* Code to request version of POD, Variax interface @@ -417,6 +169,7 @@ void line6_start_timer(struct timer_list *timer, unsigned int msecs, setup_timer(timer, function, data); mod_timer(timer, jiffies + msecs * HZ / 1000); } +EXPORT_SYMBOL_GPL(line6_start_timer); /* Asynchronously send raw message. @@ -450,6 +203,7 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, /* start sending: */ return line6_send_raw_message_async_part(msg, urb); } +EXPORT_SYMBOL_GPL(line6_send_raw_message_async); /* Send asynchronous device version request. @@ -471,6 +225,7 @@ int line6_version_request_async(struct usb_line6 *line6) kfree(buffer); return retval; } +EXPORT_SYMBOL_GPL(line6_version_request_async); /* Send sysex message in pieces of wMaxPacketSize bytes. @@ -482,6 +237,7 @@ int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, size + SYSEX_EXTRA_SIZE) - SYSEX_EXTRA_SIZE; } +EXPORT_SYMBOL_GPL(line6_send_sysex_message); /* Allocate buffer for sysex message and prepare header. @@ -503,6 +259,7 @@ char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, buffer[sizeof(line6_midi_id) + 3 + size] = LINE6_SYSEX_END; return buffer; } +EXPORT_SYMBOL_GPL(line6_alloc_sysex_buffer); /* Notification of data received from the Line6 device. @@ -658,6 +415,7 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, return 0; } +EXPORT_SYMBOL_GPL(line6_read_data); /* Write data to device. @@ -702,6 +460,7 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data, return 0; } +EXPORT_SYMBOL_GPL(line6_write_data); /* Read Line6 device serial number. @@ -712,6 +471,7 @@ int line6_read_serial_number(struct usb_line6 *line6, int *serial_number) return line6_read_data(line6, 0x80d0, serial_number, sizeof(*serial_number)); } +EXPORT_SYMBOL_GPL(line6_read_serial_number); /* No operation (i.e., unsupported). @@ -721,6 +481,7 @@ ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, { return 0; } +EXPORT_SYMBOL_GPL(line6_nop_read); /* Generic destructor. @@ -744,30 +505,29 @@ static void line6_destruct(struct usb_interface *interface) /* make sure the device isn't destructed twice: */ usb_set_intfdata(interface, NULL); - - /* free interface data: */ - kfree(line6); } /* Probe USB device. */ -static int line6_probe(struct usb_interface *interface, - const struct usb_device_id *id) +int line6_probe(struct usb_interface *interface, + struct usb_line6 *line6, + const struct line6_properties *properties, + int (*private_init)(struct usb_interface *, struct usb_line6 *)) { - enum line6_device_type devtype; struct usb_device *usbdev; - struct usb_line6 *line6; - const struct line6_properties *properties; int interface_number; - int size = 0; int ret; - if (interface == NULL) - return -ENODEV; + if (!interface) { + ret = -ENODEV; + goto err_put; + } usbdev = interface_to_usbdev(interface); - if (usbdev == NULL) - return -ENODEV; + if (!usbdev) { + ret = -ENODEV; + goto err_put; + } /* we don't handle multiple configurations */ if (usbdev->descriptor.bNumConfigurations != 1) { @@ -775,10 +535,7 @@ static int line6_probe(struct usb_interface *interface, goto err_put; } - devtype = id->driver_info; - /* initialize device info: */ - properties = &line6_properties_table[devtype]; dev_info(&interface->dev, "Line6 %s found\n", properties->name); /* query interface number */ @@ -791,76 +548,10 @@ static int line6_probe(struct usb_interface *interface, goto err_put; } - /* initialize device data based on device: */ - switch (devtype) { - case LINE6_BASSPODXT: - case LINE6_BASSPODXTLIVE: - case LINE6_BASSPODXTPRO: - case LINE6_PODXT: - case LINE6_PODXTPRO: - size = sizeof(struct usb_line6_pod); - break; - - case LINE6_PODHD300: - case LINE6_PODHD400: - size = sizeof(struct usb_line6_podhd); - break; - - case LINE6_PODHD500_0: - case LINE6_PODHD500_1: - size = sizeof(struct usb_line6_podhd); - break; - - case LINE6_POCKETPOD: - size = sizeof(struct usb_line6_pod); - break; - - case LINE6_PODSTUDIO_GX: - case LINE6_PODSTUDIO_UX1: - case LINE6_PODSTUDIO_UX2: - case LINE6_TONEPORT_GX: - case LINE6_TONEPORT_UX1: - case LINE6_TONEPORT_UX2: - case LINE6_GUITARPORT: - size = sizeof(struct usb_line6_toneport); - break; - - case LINE6_PODXTLIVE_POD: - size = sizeof(struct usb_line6_pod); - break; - - case LINE6_PODXTLIVE_VARIAX: - size = sizeof(struct usb_line6_variax); - break; - - case LINE6_VARIAX: - size = sizeof(struct usb_line6_variax); - break; - - default: - MISSING_CASE; - ret = -ENODEV; - goto err_put; - } - - if (size == 0) { - dev_err(&interface->dev, - "driver bug: interface data size not set\n"); - ret = -ENODEV; - goto err_put; - } - - line6 = kzalloc(size, GFP_KERNEL); - if (line6 == NULL) { - ret = -ENODEV; - goto err_put; - } - /* store basic data: */ line6->properties = properties; line6->usbdev = usbdev; line6->ifcdev = &interface->dev; - line6->type = devtype; /* get data from endpoint descriptor (see usb_maxpacket): */ { @@ -903,7 +594,6 @@ static int line6_probe(struct usb_interface *interface, if (line6->urb_listen == NULL) { dev_err(&interface->dev, "Out of memory\n"); - line6_destruct(interface); ret = -ENOMEM; goto err_destruct; } @@ -917,50 +607,7 @@ static int line6_probe(struct usb_interface *interface, } /* initialize device data based on device: */ - switch (devtype) { - case LINE6_BASSPODXT: - case LINE6_BASSPODXTLIVE: - case LINE6_BASSPODXTPRO: - case LINE6_POCKETPOD: - case LINE6_PODXT: - case LINE6_PODXTPRO: - ret = line6_pod_init(interface, line6); - break; - - case LINE6_PODHD300: - case LINE6_PODHD400: - case LINE6_PODHD500_0: - case LINE6_PODHD500_1: - ret = line6_podhd_init(interface, line6); - break; - - case LINE6_PODXTLIVE_POD: - ret = line6_pod_init(interface, line6); - break; - - case LINE6_PODXTLIVE_VARIAX: - ret = line6_variax_init(interface, line6); - break; - - case LINE6_VARIAX: - ret = line6_variax_init(interface, line6); - break; - - case LINE6_PODSTUDIO_GX: - case LINE6_PODSTUDIO_UX1: - case LINE6_PODSTUDIO_UX2: - case LINE6_TONEPORT_GX: - case LINE6_TONEPORT_UX1: - case LINE6_TONEPORT_UX2: - case LINE6_GUITARPORT: - ret = line6_toneport_init(interface, line6); - break; - - default: - MISSING_CASE; - ret = -ENODEV; - } - + ret = private_init(interface, line6); if (ret < 0) goto err_destruct; @@ -985,11 +632,12 @@ err_destruct: err_put: return ret; } +EXPORT_SYMBOL_GPL(line6_probe); /* Line6 device disconnected. */ -static void line6_disconnect(struct usb_interface *interface) +void line6_disconnect(struct usb_interface *interface) { struct usb_line6 *line6; struct usb_device *usbdev; @@ -1024,17 +672,21 @@ static void line6_disconnect(struct usb_interface *interface) line6_destruct(interface); + /* free interface data: */ + kfree(line6); + /* decrement reference counters: */ usb_put_intf(interface); usb_put_dev(usbdev); } +EXPORT_SYMBOL_GPL(line6_disconnect); #ifdef CONFIG_PM /* Suspend Line6 device. */ -static int line6_suspend(struct usb_interface *interface, pm_message_t message) +int line6_suspend(struct usb_interface *interface, pm_message_t message) { struct usb_line6 *line6 = usb_get_intfdata(interface); struct snd_line6_pcm *line6pcm = line6->line6pcm; @@ -1052,11 +704,12 @@ static int line6_suspend(struct usb_interface *interface, pm_message_t message) return 0; } +EXPORT_SYMBOL_GPL(line6_suspend); /* Resume Line6 device. */ -static int line6_resume(struct usb_interface *interface) +int line6_resume(struct usb_interface *interface) { struct usb_line6 *line6 = usb_get_intfdata(interface); @@ -1066,47 +719,10 @@ static int line6_resume(struct usb_interface *interface) snd_power_change_state(line6->card, SNDRV_CTL_POWER_D0); return 0; } - -/* - Resume Line6 device after reset. -*/ -static int line6_reset_resume(struct usb_interface *interface) -{ - struct usb_line6 *line6 = usb_get_intfdata(interface); - - switch (line6->type) { - case LINE6_PODSTUDIO_GX: - case LINE6_PODSTUDIO_UX1: - case LINE6_PODSTUDIO_UX2: - case LINE6_TONEPORT_GX: - case LINE6_TONEPORT_UX1: - case LINE6_TONEPORT_UX2: - case LINE6_GUITARPORT: - line6_toneport_reset_resume((struct usb_line6_toneport *)line6); - - default: - break; - } - - return line6_resume(interface); -} +EXPORT_SYMBOL_GPL(line6_resume); #endif /* CONFIG_PM */ -static struct usb_driver line6_driver = { - .name = DRIVER_NAME, - .probe = line6_probe, - .disconnect = line6_disconnect, -#ifdef CONFIG_PM - .suspend = line6_suspend, - .resume = line6_resume, - .reset_resume = line6_reset_resume, -#endif - .id_table = line6_id_table, -}; - -module_usb_driver(line6_driver); - MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index ad203f197e80..31cd318369e9 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -20,29 +20,6 @@ #define DRIVER_NAME "line6usb" -enum line6_device_type { - LINE6_BASSPODXT, - LINE6_BASSPODXTLIVE, - LINE6_BASSPODXTPRO, - LINE6_GUITARPORT, - LINE6_POCKETPOD, - LINE6_PODHD300, - LINE6_PODHD400, - LINE6_PODHD500_0, - LINE6_PODHD500_1, - LINE6_PODSTUDIO_GX, - LINE6_PODSTUDIO_UX1, - LINE6_PODSTUDIO_UX2, - LINE6_PODXT, - LINE6_PODXTLIVE_POD, - LINE6_PODXTLIVE_VARIAX, - LINE6_PODXTPRO, - LINE6_TONEPORT_GX, - LINE6_TONEPORT_UX1, - LINE6_TONEPORT_UX2, - LINE6_VARIAX -}; - #define LINE6_TIMEOUT 1 #define LINE6_BUFSIZE_LISTEN 32 #define LINE6_MESSAGE_MAXLEN 256 @@ -134,11 +111,6 @@ struct usb_line6 { */ struct usb_device *usbdev; - /** - Device type. - */ - enum line6_device_type type; - /** Properties. */ @@ -225,4 +197,15 @@ extern int line6_version_request_async(struct usb_line6 *line6); extern int line6_write_data(struct usb_line6 *line6, int address, void *data, size_t datalen); +int line6_probe(struct usb_interface *interface, + struct usb_line6 *line6, + const struct line6_properties *properties, + int (*private_init)(struct usb_interface *, struct usb_line6 *)); +void line6_disconnect(struct usb_interface *interface); + +#ifdef CONFIG_PM +int line6_suspend(struct usb_interface *interface, pm_message_t message); +int line6_resume(struct usb_interface *interface); +#endif + #endif diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index c9d725ae85a0..2a42d533f49c 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -11,13 +11,13 @@ #include #include +#include #include #include #include "audio.h" #include "driver.h" #include "midi.h" -#include "pod.h" #include "usbdefs.h" #define line6_rawmidi_substream_midi(substream) \ @@ -319,3 +319,4 @@ int line6_init_midi(struct usb_line6 *line6) spin_lock_init(&line6midi->midi_transmit_lock); return 0; } +EXPORT_SYMBOL_GPL(line6_init_midi); diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 6d4e5cd0482c..b7348b031bf7 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -19,7 +20,6 @@ #include "capture.h" #include "driver.h" #include "playback.h" -#include "pod.h" #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE @@ -195,6 +195,7 @@ pcm_acquire_error: line6_pcm_release(line6pcm, flags_final & channels); return err; } +EXPORT_SYMBOL_GPL(line6_pcm_acquire); int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) { @@ -223,6 +224,7 @@ int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) return 0; } +EXPORT_SYMBOL_GPL(line6_pcm_release); /* trigger callback */ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) @@ -408,6 +410,7 @@ void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm) line6_unlink_wait_clear_audio_out_urbs(line6pcm); line6_unlink_wait_clear_audio_in_urbs(line6pcm); } +EXPORT_SYMBOL_GPL(line6_pcm_disconnect); /* Create and register the PCM device and mixer entries. @@ -490,6 +493,7 @@ int line6_init_pcm(struct usb_line6 *line6, return 0; } +EXPORT_SYMBOL_GPL(line6_init_pcm); /* prepare pcm callback */ int snd_line6_prepare(struct snd_pcm_substream *substream) diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index da2e3b8876b8..0a874105ccef 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -18,7 +18,6 @@ #include "capture.h" #include "driver.h" #include "pcm.h" -#include "pod.h" #include "playback.h" /* diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 85a43631996e..dde9c2b8ad0f 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -11,13 +11,94 @@ #include #include +#include +#include +#include + +#include #include #include "audio.h" #include "capture.h" #include "driver.h" #include "playback.h" -#include "pod.h" +#include "usbdefs.h" + +/* + Locate name in binary program dump +*/ +#define POD_NAME_OFFSET 0 +#define POD_NAME_LENGTH 16 + +/* + Other constants +*/ +#define POD_CONTROL_SIZE 0x80 +#define POD_BUFSIZE_DUMPREQ 7 +#define POD_STARTUP_DELAY 1000 + +/* + Stages of POD startup procedure +*/ +enum { + POD_STARTUP_INIT = 1, + POD_STARTUP_VERSIONREQ, + POD_STARTUP_WORKQUEUE, + POD_STARTUP_SETUP, + POD_STARTUP_LAST = POD_STARTUP_SETUP - 1 +}; + +enum { + LINE6_BASSPODXT, + LINE6_BASSPODXTLIVE, + LINE6_BASSPODXTPRO, + LINE6_POCKETPOD, + LINE6_PODXT, + LINE6_PODXTLIVE_POD, + LINE6_PODXTPRO, +}; + +struct usb_line6_pod { + /** + Generic Line6 USB data. + */ + struct usb_line6 line6; + + /** + Instrument monitor level. + */ + int monitor_level; + + /** + Timer for device initializaton. + */ + struct timer_list startup_timer; + + /** + Work handler for device initializaton. + */ + struct work_struct startup_work; + + /** + Current progress in startup procedure. + */ + int startup_progress; + + /** + Serial number of device. + */ + int serial_number; + + /** + Firmware version (x 100). + */ + int firmware_version; + + /** + Device ID. + */ + int device_id; +}; #define POD_SYSEX_CODE 3 #define POD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */ @@ -442,7 +523,8 @@ static int pod_try_init(struct usb_interface *interface, /* Init POD device (and clean up in case of failure). */ -int line6_pod_init(struct usb_interface *interface, struct usb_line6 *line6) +static int pod_init(struct usb_interface *interface, + struct usb_line6 *line6) { int err = pod_try_init(interface, line6); @@ -451,3 +533,141 @@ int line6_pod_init(struct usb_interface *interface, struct usb_line6 *line6) return err; } + +#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) +#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) + +/* table of devices that work with this driver */ +static const struct usb_device_id pod_id_table[] = { + { LINE6_DEVICE(0x4250), .driver_info = LINE6_BASSPODXT }, + { LINE6_DEVICE(0x4642), .driver_info = LINE6_BASSPODXTLIVE }, + { LINE6_DEVICE(0x4252), .driver_info = LINE6_BASSPODXTPRO }, + { LINE6_IF_NUM(0x5051, 1), .driver_info = LINE6_POCKETPOD }, + { LINE6_DEVICE(0x5044), .driver_info = LINE6_PODXT }, + { LINE6_IF_NUM(0x4650, 0), .driver_info = LINE6_PODXTLIVE_POD }, + { LINE6_DEVICE(0x5050), .driver_info = LINE6_PODXTPRO }, + {} +}; + +MODULE_DEVICE_TABLE(usb, pod_id_table); + +static const struct line6_properties pod_properties_table[] = { + [LINE6_BASSPODXT] = { + .id = "BassPODxt", + .name = "BassPODxt", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_BASSPODXTLIVE] = { + .id = "BassPODxtLive", + .name = "BassPODxt Live", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_BASSPODXTPRO] = { + .id = "BassPODxtPro", + .name = "BassPODxt Pro", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_POCKETPOD] = { + .id = "PocketPOD", + .name = "Pocket POD", + .capabilities = LINE6_CAP_CONTROL, + .altsetting = 0, + .ep_ctrl_r = 0x82, + .ep_ctrl_w = 0x02, + /* no audio channel */ + }, + [LINE6_PODXT] = { + .id = "PODxt", + .name = "PODxt", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODXTLIVE_POD] = { + .id = "PODxtLive", + .name = "PODxt Live", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODXTPRO] = { + .id = "PODxtPro", + .name = "PODxt Pro", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, +}; + +/* + Probe USB device. +*/ +static int pod_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct usb_line6_pod *pod; + int err; + + pod = kzalloc(sizeof(*pod), GFP_KERNEL); + if (!pod) + return -ENODEV; + err = line6_probe(interface, &pod->line6, + &pod_properties_table[id->driver_info], + pod_init); + if (err < 0) + kfree(pod); + return err; +} + +static struct usb_driver pod_driver = { + .name = KBUILD_MODNAME, + .probe = pod_probe, + .disconnect = line6_disconnect, +#ifdef CONFIG_PM + .suspend = line6_suspend, + .resume = line6_resume, + .reset_resume = line6_resume, +#endif + .id_table = pod_id_table, +}; + +module_usb_driver(pod_driver); + +MODULE_DESCRIPTION("Line6 POD USB driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/usb/line6/pod.h b/sound/usb/line6/pod.h deleted file mode 100644 index 87a8f0fa9cba..000000000000 --- a/sound/usb/line6/pod.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Line6 Linux USB driver - 0.9.1beta - * - * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2. - * - */ - -#ifndef POD_H -#define POD_H - -#include -#include -#include - -#include - -#include "driver.h" - -/* - Locate name in binary program dump -*/ -#define POD_NAME_OFFSET 0 -#define POD_NAME_LENGTH 16 - -/* - Other constants -*/ -#define POD_CONTROL_SIZE 0x80 -#define POD_BUFSIZE_DUMPREQ 7 -#define POD_STARTUP_DELAY 1000 - -/* - Stages of POD startup procedure -*/ -enum { - POD_STARTUP_INIT = 1, - POD_STARTUP_VERSIONREQ, - POD_STARTUP_WORKQUEUE, - POD_STARTUP_SETUP, - POD_STARTUP_LAST = POD_STARTUP_SETUP - 1 -}; - -struct usb_line6_pod { - /** - Generic Line6 USB data. - */ - struct usb_line6 line6; - - /** - Instrument monitor level. - */ - int monitor_level; - - /** - Timer for device initializaton. - */ - struct timer_list startup_timer; - - /** - Work handler for device initializaton. - */ - struct work_struct startup_work; - - /** - Current progress in startup procedure. - */ - int startup_progress; - - /** - Serial number of device. - */ - int serial_number; - - /** - Firmware version (x 100). - */ - int firmware_version; - - /** - Device ID. - */ - int device_id; -}; - -extern int line6_pod_init(struct usb_interface *interface, - struct usb_line6 *line6); - -#endif diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 27c5402cece8..84096326694c 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -9,13 +9,30 @@ * */ +#include +#include +#include #include #include #include "audio.h" #include "driver.h" #include "pcm.h" -#include "podhd.h" +#include "usbdefs.h" + +enum { + LINE6_PODHD300, + LINE6_PODHD400, + LINE6_PODHD500_0, + LINE6_PODHD500_1, +}; + +struct usb_line6_podhd { + /** + Generic Line6 USB data. + */ + struct usb_line6 line6; +}; #define PODHD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */ @@ -141,10 +158,76 @@ static int podhd_try_init(struct usb_interface *interface, return err; } +#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) +#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) + +/* table of devices that work with this driver */ +static const struct usb_device_id podhd_id_table[] = { + { LINE6_DEVICE(0x5057), .driver_info = LINE6_PODHD300 }, + { LINE6_DEVICE(0x5058), .driver_info = LINE6_PODHD400 }, + { LINE6_IF_NUM(0x414D, 0), .driver_info = LINE6_PODHD500_0 }, + { LINE6_IF_NUM(0x414D, 1), .driver_info = LINE6_PODHD500_1 }, + {} +}; + +MODULE_DEVICE_TABLE(usb, podhd_id_table); + +static const struct line6_properties podhd_properties_table[] = { + [LINE6_PODHD300] = { + .id = "PODHD300", + .name = "POD HD300", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODHD400] = { + .id = "PODHD400", + .name = "POD HD400", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 5, + .ep_ctrl_r = 0x84, + .ep_ctrl_w = 0x03, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODHD500_0] = { + .id = "PODHD500", + .name = "POD HD500", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x81, + .ep_ctrl_w = 0x01, + .ep_audio_r = 0x86, + .ep_audio_w = 0x02, + }, + [LINE6_PODHD500_1] = { + .id = "PODHD500", + .name = "POD HD500", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x81, + .ep_ctrl_w = 0x01, + .ep_audio_r = 0x86, + .ep_audio_w = 0x02, + }, +}; + /* Init POD HD device (and clean up in case of failure). */ -int line6_podhd_init(struct usb_interface *interface, struct usb_line6 *line6) +static int podhd_init(struct usb_interface *interface, + struct usb_line6 *line6) { struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; int err = podhd_try_init(interface, podhd); @@ -154,3 +237,40 @@ int line6_podhd_init(struct usb_interface *interface, struct usb_line6 *line6) return err; } + +/* + Probe USB device. +*/ +static int podhd_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct usb_line6_podhd *podhd; + int err; + + podhd = kzalloc(sizeof(*podhd), GFP_KERNEL); + if (!podhd) + return -ENODEV; + err = line6_probe(interface, &podhd->line6, + &podhd_properties_table[id->driver_info], + podhd_init); + if (err < 0) + kfree(podhd); + return err; +} + +static struct usb_driver podhd_driver = { + .name = KBUILD_MODNAME, + .probe = podhd_probe, + .disconnect = line6_disconnect, +#ifdef CONFIG_PM + .suspend = line6_suspend, + .resume = line6_resume, + .reset_resume = line6_resume, +#endif + .id_table = podhd_id_table, +}; + +module_usb_driver(podhd_driver); + +MODULE_DESCRIPTION("Line6 PODHD USB driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/usb/line6/podhd.h b/sound/usb/line6/podhd.h deleted file mode 100644 index a14f711f9725..000000000000 --- a/sound/usb/line6/podhd.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Line6 Pod HD - * - * Copyright (C) 2011 Stefan Hajnoczi - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2. - * - */ - -#ifndef PODHD_H -#define PODHD_H - -#include - -#include "driver.h" - -struct usb_line6_podhd { - /** - Generic Line6 USB data. - */ - struct usb_line6 line6; -}; - -extern int line6_podhd_init(struct usb_interface *interface, - struct usb_line6 *line6); - -#endif /* PODHD_H */ diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 7f97f4a812a7..4f07643e47f2 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -11,13 +11,59 @@ */ #include +#include +#include +#include +#include #include #include "audio.h" #include "capture.h" #include "driver.h" #include "playback.h" -#include "toneport.h" +#include "usbdefs.h" + +enum line6_device_type { + LINE6_GUITARPORT, + LINE6_PODSTUDIO_GX, + LINE6_PODSTUDIO_UX1, + LINE6_PODSTUDIO_UX2, + LINE6_TONEPORT_GX, + LINE6_TONEPORT_UX1, + LINE6_TONEPORT_UX2, +}; + +struct usb_line6_toneport { + /** + Generic Line6 USB data. + */ + struct usb_line6 line6; + + /** + Source selector. + */ + int source; + + /** + Serial number of device. + */ + int serial_number; + + /** + Firmware version (x 100). + */ + int firmware_version; + + /** + Timer for delayed PCM startup. + */ + struct timer_list timer; + + /** + Device type. + */ + enum line6_device_type type; +}; static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); @@ -319,7 +365,7 @@ static void toneport_setup(struct usb_line6_toneport *toneport) toneport_send_cmd(usbdev, 0x0301, 0x0000); /* initialize source select: */ - switch (line6->type) { + switch (toneport->type) { case LINE6_TONEPORT_UX1: case LINE6_TONEPORT_UX2: case LINE6_PODSTUDIO_UX1: @@ -331,7 +377,7 @@ static void toneport_setup(struct usb_line6_toneport *toneport) break; } - if (toneport_has_led(line6->type)) + if (toneport_has_led(toneport->type)) toneport_update_led(&usbdev->dev); } @@ -400,7 +446,7 @@ static int toneport_try_init(struct usb_interface *interface, return err; /* register source select control: */ - switch (line6->type) { + switch (toneport->type) { case LINE6_TONEPORT_UX1: case LINE6_TONEPORT_UX2: case LINE6_PODSTUDIO_UX1: @@ -424,7 +470,7 @@ static int toneport_try_init(struct usb_interface *interface, line6_read_serial_number(line6, &toneport->serial_number); line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); - if (toneport_has_led(line6->type)) { + if (toneport_has_led(toneport->type)) { CHECK_RETURN(device_create_file (&interface->dev, &dev_attr_led_red)); CHECK_RETURN(device_create_file @@ -443,8 +489,8 @@ static int toneport_try_init(struct usb_interface *interface, /* Init Toneport device (and clean up in case of failure). */ -int line6_toneport_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int toneport_init(struct usb_interface *interface, + struct usb_line6 *line6) { int err = toneport_try_init(interface, line6); @@ -454,10 +500,134 @@ int line6_toneport_init(struct usb_interface *interface, return err; } +#ifdef CONFIG_PM /* Resume Toneport device after reset. */ -void line6_toneport_reset_resume(struct usb_line6_toneport *toneport) +static int toneport_reset_resume(struct usb_interface *interface) { - toneport_setup(toneport); + toneport_setup(usb_get_intfdata(interface)); + return line6_resume(interface); } +#endif + +#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) +#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) + +/* table of devices that work with this driver */ +static const struct usb_device_id toneport_id_table[] = { + { LINE6_DEVICE(0x4750), .driver_info = LINE6_GUITARPORT }, + { LINE6_DEVICE(0x4153), .driver_info = LINE6_PODSTUDIO_GX }, + { LINE6_DEVICE(0x4150), .driver_info = LINE6_PODSTUDIO_UX1 }, + { LINE6_IF_NUM(0x4151, 0), .driver_info = LINE6_PODSTUDIO_UX2 }, + { LINE6_DEVICE(0x4147), .driver_info = LINE6_TONEPORT_GX }, + { LINE6_DEVICE(0x4141), .driver_info = LINE6_TONEPORT_UX1 }, + { LINE6_IF_NUM(0x4142, 0), .driver_info = LINE6_TONEPORT_UX2 }, + {} +}; + +MODULE_DEVICE_TABLE(usb, toneport_id_table); + +static const struct line6_properties toneport_properties_table[] = { + [LINE6_GUITARPORT] = { + .id = "GuitarPort", + .name = "GuitarPort", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODSTUDIO_GX] = { + .id = "PODStudioGX", + .name = "POD Studio GX", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODSTUDIO_UX1] = { + .id = "PODStudioUX1", + .name = "POD Studio UX1", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_PODSTUDIO_UX2] = { + .id = "PODStudioUX2", + .name = "POD Studio UX2", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* defaults to 44.1kHz, 16-bit */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_TONEPORT_GX] = { + .id = "TonePortGX", + .name = "TonePort GX", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_TONEPORT_UX1] = { + .id = "TonePortUX1", + .name = "TonePort UX1", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* 1..4 seem to be ok */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_TONEPORT_UX2] = { + .id = "TonePortUX2", + .name = "TonePort UX2", + .capabilities = LINE6_CAP_PCM, + .altsetting = 2, /* defaults to 44.1kHz, 16-bit */ + /* no control channel */ + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, +}; + +/* + Probe USB device. +*/ +static int toneport_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct usb_line6_toneport *toneport; + int err; + + toneport = kzalloc(sizeof(*toneport), GFP_KERNEL); + if (!toneport) + return -ENODEV; + toneport->type = id->driver_info; + err = line6_probe(interface, &toneport->line6, + &toneport_properties_table[id->driver_info], + toneport_init); + if (err < 0) + kfree(toneport); + return err; +} + +static struct usb_driver toneport_driver = { + .name = KBUILD_MODNAME, + .probe = toneport_probe, + .disconnect = line6_disconnect, +#ifdef CONFIG_PM + .suspend = line6_suspend, + .resume = line6_resume, + .reset_resume = toneport_reset_resume, +#endif + .id_table = toneport_id_table, +}; + +module_usb_driver(toneport_driver); + +MODULE_DESCRIPTION("TonePort USB driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/usb/line6/toneport.h b/sound/usb/line6/toneport.h deleted file mode 100644 index 8cb14426f6ae..000000000000 --- a/sound/usb/line6/toneport.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Line6 Linux USB driver - 0.9.1beta - * - * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2. - * - */ - -#ifndef TONEPORT_H -#define TONEPORT_H - -#include -#include - -#include "driver.h" - -struct usb_line6_toneport { - /** - Generic Line6 USB data. - */ - struct usb_line6 line6; - - /** - Source selector. - */ - int source; - - /** - Serial number of device. - */ - int serial_number; - - /** - Firmware version (x 100). - */ - int firmware_version; - - /** - Timer for delayed PCM startup. - */ - struct timer_list timer; -}; - -extern int line6_toneport_init(struct usb_interface *interface, - struct usb_line6 *line6); -extern void line6_toneport_reset_resume(struct usb_line6_toneport *toneport); - -#endif diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index b4a41b0ad0ea..0c852bb1e76c 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -10,10 +10,65 @@ */ #include +#include +#include +#include +#include +#include #include "audio.h" #include "driver.h" -#include "variax.h" +#include "usbdefs.h" + +#define VARIAX_STARTUP_DELAY1 1000 +#define VARIAX_STARTUP_DELAY3 100 +#define VARIAX_STARTUP_DELAY4 100 + +/* + Stages of Variax startup procedure +*/ +enum { + VARIAX_STARTUP_INIT = 1, + VARIAX_STARTUP_VERSIONREQ, + VARIAX_STARTUP_WAIT, + VARIAX_STARTUP_ACTIVATE, + VARIAX_STARTUP_WORKQUEUE, + VARIAX_STARTUP_SETUP, + VARIAX_STARTUP_LAST = VARIAX_STARTUP_SETUP - 1 +}; + +enum { + LINE6_PODXTLIVE_VARIAX, + LINE6_VARIAX +}; + +struct usb_line6_variax { + /** + Generic Line6 USB data. + */ + struct usb_line6 line6; + + /** + Buffer for activation code. + */ + unsigned char *buffer_activate; + + /** + Handler for device initializaton. + */ + struct work_struct startup_work; + + /** + Timers for device initializaton. + */ + struct timer_list startup_timer1; + struct timer_list startup_timer2; + + /** + Current progress in startup procedure. + */ + int startup_progress; +}; #define VARIAX_OFFSET_ACTIVATE 7 @@ -228,7 +283,8 @@ static int variax_try_init(struct usb_interface *interface, /* Init workbench device (and clean up in case of failure). */ -int line6_variax_init(struct usb_interface *interface, struct usb_line6 *line6) +static int variax_init(struct usb_interface *interface, + struct usb_line6 *line6) { int err = variax_try_init(interface, line6); @@ -237,3 +293,76 @@ int line6_variax_init(struct usb_interface *interface, struct usb_line6 *line6) return err; } + +#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) +#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) + +/* table of devices that work with this driver */ +static const struct usb_device_id variax_id_table[] = { + { LINE6_IF_NUM(0x4650, 1), .driver_info = LINE6_PODXTLIVE_VARIAX }, + { LINE6_DEVICE(0x534d), .driver_info = LINE6_VARIAX }, + {} +}; + +MODULE_DEVICE_TABLE(usb, variax_id_table); + +static const struct line6_properties variax_properties_table[] = { + [LINE6_PODXTLIVE_VARIAX] = { + .id = "PODxtLive", + .name = "PODxt Live", + .capabilities = LINE6_CAP_CONTROL + | LINE6_CAP_PCM + | LINE6_CAP_HWMON, + .altsetting = 1, + .ep_ctrl_r = 0x86, + .ep_ctrl_w = 0x05, + .ep_audio_r = 0x82, + .ep_audio_w = 0x01, + }, + [LINE6_VARIAX] = { + .id = "Variax", + .name = "Variax Workbench", + .capabilities = LINE6_CAP_CONTROL, + .altsetting = 1, + .ep_ctrl_r = 0x82, + .ep_ctrl_w = 0x01, + /* no audio channel */ + } +}; + +/* + Probe USB device. +*/ +static int variax_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct usb_line6_variax *variax; + int err; + + variax = kzalloc(sizeof(*variax), GFP_KERNEL); + if (!variax) + return -ENODEV; + err = line6_probe(interface, &variax->line6, + &variax_properties_table[id->driver_info], + variax_init); + if (err < 0) + kfree(variax); + return err; +} + +static struct usb_driver variax_driver = { + .name = KBUILD_MODNAME, + .probe = variax_probe, + .disconnect = line6_disconnect, +#ifdef CONFIG_PM + .suspend = line6_suspend, + .resume = line6_resume, + .reset_resume = line6_resume, +#endif + .id_table = variax_id_table, +}; + +module_usb_driver(variax_driver); + +MODULE_DESCRIPTION("Vairax Workbench USB driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/usb/line6/variax.h b/sound/usb/line6/variax.h deleted file mode 100644 index dfb94e574cc4..000000000000 --- a/sound/usb/line6/variax.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Line6 Linux USB driver - 0.9.1beta - * - * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2. - * - */ - -#ifndef VARIAX_H -#define VARIAX_H - -#include -#include -#include -#include - -#include "driver.h" - -#define VARIAX_STARTUP_DELAY1 1000 -#define VARIAX_STARTUP_DELAY3 100 -#define VARIAX_STARTUP_DELAY4 100 - -/* - Stages of Variax startup procedure -*/ -enum { - VARIAX_STARTUP_INIT = 1, - VARIAX_STARTUP_VERSIONREQ, - VARIAX_STARTUP_WAIT, - VARIAX_STARTUP_ACTIVATE, - VARIAX_STARTUP_WORKQUEUE, - VARIAX_STARTUP_SETUP, - VARIAX_STARTUP_LAST = VARIAX_STARTUP_SETUP - 1 -}; - -struct usb_line6_variax { - /** - Generic Line6 USB data. - */ - struct usb_line6 line6; - - /** - Buffer for activation code. - */ - unsigned char *buffer_activate; - - /** - Handler for device initializaton. - */ - struct work_struct startup_work; - - /** - Timers for device initializaton. - */ - struct timer_list startup_timer1; - struct timer_list startup_timer2; - - /** - Current progress in startup procedure. - */ - int startup_progress; -}; - -extern int line6_variax_init(struct usb_interface *interface, - struct usb_line6 *line6); - -#endif -- cgit From 075587b723ec5d90d1788b9cdba3034f524a64c9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 14:28:25 +0100 Subject: ALSA: line6: Handle impulse response via control API Instead of sysfs and the conditional build with Kconfig, implement the handling of the impulse response controls via control API, and always enable the build. Two new controls, "Impulse Response Volume" and "Impulse Response Period" are added as a replacement for the former sysfs files. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/Kconfig | 12 ---- sound/usb/line6/capture.c | 4 -- sound/usb/line6/pcm.c | 157 ++++++++++++++++++++++----------------------- sound/usb/line6/pcm.h | 18 ------ sound/usb/line6/playback.c | 8 --- 5 files changed, 75 insertions(+), 124 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/Kconfig b/sound/usb/line6/Kconfig index 33deb419dde8..8287ae6a2c26 100644 --- a/sound/usb/line6/Kconfig +++ b/sound/usb/line6/Kconfig @@ -38,15 +38,3 @@ config SND_USB_VARIAX help This is a driver for Variax Workbench device. -config LINE6_USB_IMPULSE_RESPONSE - bool "measure impulse response" - depends on SND_USB_LINE6 - help - Say Y here to add code to measure the impulse response of a Line6 - device. This is more accurate than user-space methods since it - bypasses any PCM data buffering (e.g., by ALSA or jack). This is - useful for assessing the performance of new devices, but is not - required for normal operation. - - If unsure, say N. - diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index da4ab013ea8e..4cf6fa0541f1 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -244,9 +244,7 @@ static void audio_in_callback(struct urb *urb) line6pcm->prev_fbuf = fbuf; line6pcm->prev_fsize = fsize; -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE if (!(line6pcm->flags & LINE6_BITS_PCM_IMPULSE)) -#endif if (test_bit(LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM, &line6pcm->flags) && (fsize > 0)) line6_capture_copy(line6pcm, fbuf, fsize); @@ -262,9 +260,7 @@ static void audio_in_callback(struct urb *urb) if (!shutdown) { submit_audio_in_urb(line6pcm); -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE if (!(line6pcm->flags & LINE6_BITS_PCM_IMPULSE)) -#endif if (test_bit(LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM, &line6pcm->flags)) line6_capture_check_period(line6pcm, length); diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index b7348b031bf7..626b6c158023 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -21,80 +21,75 @@ #include "driver.h" #include "playback.h" -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE - -static struct snd_line6_pcm *dev2pcm(struct device *dev) +/* impulse response volume controls */ +static int snd_line6_impulse_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - struct usb_interface *interface = to_usb_interface(dev); - struct usb_line6 *line6 = usb_get_intfdata(interface); - struct snd_line6_pcm *line6pcm = line6->line6pcm; - return line6pcm; + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 255; + return 0; } -/* - "read" request on "impulse_volume" special file. -*/ -static ssize_t impulse_volume_show(struct device *dev, - struct device_attribute *attr, char *buf) +static int snd_line6_impulse_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_volume); + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + + ucontrol->value.integer.value[0] = line6pcm->impulse_volume; + return 0; } -/* - "write" request on "impulse_volume" special file. -*/ -static ssize_t impulse_volume_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static int snd_line6_impulse_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - struct snd_line6_pcm *line6pcm = dev2pcm(dev); - int value; - int ret; + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + int value = ucontrol->value.integer.value[0]; - ret = kstrtoint(buf, 10, &value); - if (ret < 0) - return ret; + if (line6pcm->impulse_volume == value) + return 0; line6pcm->impulse_volume = value; - if (value > 0) line6_pcm_acquire(line6pcm, LINE6_BITS_PCM_IMPULSE); else line6_pcm_release(line6pcm, LINE6_BITS_PCM_IMPULSE); + return 1; +} - return count; +/* impulse response period controls */ +static int snd_line6_impulse_period_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 2000; + return 0; } -static DEVICE_ATTR_RW(impulse_volume); -/* - "read" request on "impulse_period" special file. -*/ -static ssize_t impulse_period_show(struct device *dev, - struct device_attribute *attr, char *buf) +static int snd_line6_impulse_period_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_period); + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + + ucontrol->value.integer.value[0] = line6pcm->impulse_period; + return 0; } -/* - "write" request on "impulse_period" special file. -*/ -static ssize_t impulse_period_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static int snd_line6_impulse_period_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - int value; - int ret; + struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + int value = ucontrol->value.integer.value[0]; - ret = kstrtoint(buf, 10, &value); - if (ret < 0) - return ret; + if (line6pcm->impulse_period == value) + return 0; - dev2pcm(dev)->impulse_period = value; - return count; + line6pcm->impulse_period = value; + return 1; } -static DEVICE_ATTR_RW(impulse_period); - -#endif static bool test_flags(unsigned long flags0, unsigned long flags1, unsigned long mask) @@ -314,14 +309,28 @@ static int snd_line6_control_playback_put(struct snd_kcontrol *kcontrol, } /* control definition */ -static struct snd_kcontrol_new line6_control_playback = { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "PCM Playback Volume", - .index = 0, - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = snd_line6_control_playback_info, - .get = snd_line6_control_playback_get, - .put = snd_line6_control_playback_put +static struct snd_kcontrol_new line6_controls[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "PCM Playback Volume", + .info = snd_line6_control_playback_info, + .get = snd_line6_control_playback_get, + .put = snd_line6_control_playback_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Impulse Response Volume", + .info = snd_line6_impulse_volume_info, + .get = snd_line6_impulse_volume_get, + .put = snd_line6_impulse_volume_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Impulse Response Period", + .info = snd_line6_impulse_period_info, + .get = snd_line6_impulse_period_get, + .put = snd_line6_impulse_period_put + }, }; /* @@ -332,11 +341,6 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm) int i; struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm); -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE - device_remove_file(line6pcm->line6->ifcdev, &dev_attr_impulse_volume); - device_remove_file(line6pcm->line6->ifcdev, &dev_attr_impulse_period); -#endif - for (i = LINE6_ISO_BUFFERS; i--;) { if (line6pcm->urb_audio_out[i]) { usb_kill_urb(line6pcm->urb_audio_out[i]); @@ -423,7 +427,7 @@ int line6_init_pcm(struct usb_line6 *line6, .dev_free = snd_line6_pcm_free, }; - int err; + int i, err; unsigned ep_read = line6->properties->ep_audio_r; unsigned ep_write = line6->properties->ep_audio_w; struct snd_line6_pcm *line6pcm; @@ -462,6 +466,7 @@ int line6_init_pcm(struct usb_line6 *line6, spin_lock_init(&line6pcm->lock_audio_out); spin_lock_init(&line6pcm->lock_audio_in); spin_lock_init(&line6pcm->lock_trigger); + line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; err = line6_create_audio_out_urbs(line6pcm); if (err < 0) @@ -472,24 +477,12 @@ int line6_init_pcm(struct usb_line6 *line6, return err; /* mixer: */ - err = - snd_ctl_add(line6->card, - snd_ctl_new1(&line6_control_playback, line6pcm)); - if (err < 0) - return err; - -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE - /* impulse response test: */ - err = device_create_file(line6->ifcdev, &dev_attr_impulse_volume); - if (err < 0) - return err; - - err = device_create_file(line6->ifcdev, &dev_attr_impulse_period); - if (err < 0) - return err; - - line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; -#endif + for (i = 0; i < ARRAY_SIZE(line6_controls); i++) { + err = snd_ctl_add(line6->card, + snd_ctl_new1(&line6_controls[i], line6pcm)); + if (err < 0) + return err; + } return 0; } diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index 7315e8131184..9328e6ffb191 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -35,9 +35,7 @@ /* in a "full speed" device (such as the PODxt Pro) this means 1ms */ #define LINE6_ISO_INTERVAL 1 -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE #define LINE6_IMPULSE_DEFAULT_PERIOD 100 -#endif /* Get substream from Line6 PCM data structure @@ -89,12 +87,10 @@ enum { LINE6_INDEX_PCM_MONITOR_PLAYBACK_STREAM, LINE6_INDEX_PCM_MONITOR_CAPTURE_BUFFER, LINE6_INDEX_PCM_MONITOR_CAPTURE_STREAM, -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE LINE6_INDEX_PCM_IMPULSE_PLAYBACK_BUFFER, LINE6_INDEX_PCM_IMPULSE_PLAYBACK_STREAM, LINE6_INDEX_PCM_IMPULSE_CAPTURE_BUFFER, LINE6_INDEX_PCM_IMPULSE_CAPTURE_STREAM, -#endif LINE6_INDEX_PAUSE_PLAYBACK, LINE6_INDEX_PREPARED, @@ -109,12 +105,10 @@ enum { LINE6_BIT(PCM_MONITOR_PLAYBACK_STREAM), LINE6_BIT(PCM_MONITOR_CAPTURE_BUFFER), LINE6_BIT(PCM_MONITOR_CAPTURE_STREAM), -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE LINE6_BIT(PCM_IMPULSE_PLAYBACK_BUFFER), LINE6_BIT(PCM_IMPULSE_PLAYBACK_STREAM), LINE6_BIT(PCM_IMPULSE_CAPTURE_BUFFER), LINE6_BIT(PCM_IMPULSE_CAPTURE_STREAM), -#endif LINE6_BIT(PAUSE_PLAYBACK), LINE6_BIT(PREPARED), @@ -133,40 +127,30 @@ enum { LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER | LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM, -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE LINE6_BITS_PCM_IMPULSE = LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER | LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM | LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER | LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM, -#endif /* combined bit masks (by direction): */ LINE6_BITS_PLAYBACK_BUFFER = -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER | -#endif LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER | LINE6_BIT_PCM_MONITOR_PLAYBACK_BUFFER, LINE6_BITS_PLAYBACK_STREAM = -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM | -#endif LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM | LINE6_BIT_PCM_MONITOR_PLAYBACK_STREAM, LINE6_BITS_CAPTURE_BUFFER = -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER | -#endif LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER | LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER, LINE6_BITS_CAPTURE_STREAM = -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM | -#endif LINE6_BIT_PCM_ALSA_CAPTURE_STREAM | LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM, @@ -338,7 +322,6 @@ struct snd_line6_pcm { */ int volume_monitor; -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE /** Volume of impulse response test signal (if zero, test is disabled). */ @@ -353,7 +336,6 @@ struct snd_line6_pcm { Counter for impulse response test signal. */ int impulse_count; -#endif /** Several status bits (see LINE6_BIT_*). diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 0a874105ccef..258147eadf37 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -60,8 +60,6 @@ static void change_volume(struct urb *urb_out, int volume[], } } -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE - /* Create signal for impulse response test. */ @@ -105,8 +103,6 @@ static void create_impulse_test_signal(struct snd_line6_pcm *line6pcm, } } -#endif - /* Add signal to buffer for software monitoring. */ @@ -243,7 +239,6 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) change_volume(urb_out, line6pcm->volume_playback, bytes_per_frame); if (line6pcm->prev_fbuf != NULL) { -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE if (line6pcm->flags & LINE6_BITS_PCM_IMPULSE) { create_impulse_test_signal(line6pcm, urb_out, bytes_per_frame); @@ -257,7 +252,6 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer_length); } } else { -#endif if (! (line6pcm->line6-> properties->capabilities & LINE6_CAP_HWMON) @@ -266,9 +260,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) add_monitor_signal(urb_out, line6pcm->prev_fbuf, line6pcm->volume_monitor, bytes_per_frame); -#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE } -#endif } ret = usb_submit_urb(urb_out, GFP_ATOMIC); -- cgit From b45a7c565473d29bd7e02ac8ca86232a24ca247f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 14:41:57 +0100 Subject: ALSA: line6: Drop superfluous snd_device for PCM Instead of handling the card-specific resource in snd_device, attach it into pcm->private_data and release it directly in private_free. This simplifies the code and structure. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 53 ++++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 626b6c158023..520cf540e83c 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -351,24 +351,21 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm) usb_free_urb(line6pcm->urb_audio_in[i]); } } + kfree(line6pcm); } /* create a PCM device */ -static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm) +static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret) { struct snd_pcm *pcm; int err; - err = snd_pcm_new(line6pcm->line6->card, - (char *)line6pcm->line6->properties->name, - 0, 1, 1, &pcm); + err = snd_pcm_new(line6->card, (char *)line6->properties->name, + 0, 1, 1, pcm_ret); if (err < 0) return err; - - pcm->private_data = line6pcm; - pcm->private_free = line6_cleanup_pcm; - line6pcm->pcm = pcm; - strcpy(pcm->name, line6pcm->line6->properties->name); + pcm = *pcm_ret; + strcpy(pcm->name, line6->properties->name); /* set operators */ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, @@ -380,13 +377,6 @@ static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm) snd_dma_continuous_data (GFP_KERNEL), 64 * 1024, 128 * 1024); - - return 0; -} - -/* PCM device destructor */ -static int snd_line6_pcm_free(struct snd_device *device) -{ return 0; } @@ -423,23 +413,25 @@ EXPORT_SYMBOL_GPL(line6_pcm_disconnect); int line6_init_pcm(struct usb_line6 *line6, struct line6_pcm_properties *properties) { - static struct snd_device_ops pcm_ops = { - .dev_free = snd_line6_pcm_free, - }; - int i, err; unsigned ep_read = line6->properties->ep_audio_r; unsigned ep_write = line6->properties->ep_audio_w; + struct snd_pcm *pcm; struct snd_line6_pcm *line6pcm; if (!(line6->properties->capabilities & LINE6_CAP_PCM)) return 0; /* skip PCM initialization and report success */ - line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL); + err = snd_line6_new_pcm(line6, &pcm); + if (err < 0) + return err; - if (line6pcm == NULL) + line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL); + if (!line6pcm) return -ENOMEM; + line6pcm->pcm = pcm; + line6pcm->properties = properties; line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255; line6pcm->volume_monitor = 255; line6pcm->line6 = line6; @@ -451,23 +443,16 @@ int line6_init_pcm(struct usb_line6 *line6, usb_maxpacket(line6->usbdev, usb_sndisocpipe(line6->usbdev, ep_write), 1)); - line6pcm->properties = properties; - line6->line6pcm = line6pcm; - - /* PCM device: */ - err = snd_device_new(line6->card, SNDRV_DEV_PCM, line6, &pcm_ops); - if (err < 0) - return err; - - err = snd_line6_new_pcm(line6pcm); - if (err < 0) - return err; - spin_lock_init(&line6pcm->lock_audio_out); spin_lock_init(&line6pcm->lock_audio_in); spin_lock_init(&line6pcm->lock_trigger); line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; + line6->line6pcm = line6pcm; + + pcm->private_data = line6pcm; + pcm->private_free = line6_cleanup_pcm; + err = line6_create_audio_out_urbs(line6pcm); if (err < 0) return err; -- cgit From aaa68d2f295147a7b648bbab632557c7429fb8cd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 14:50:31 +0100 Subject: ALSA: line6: Drop superfluous snd_device for rawmidi Like the previous fix for PCM, attach the card-specific resource into rawmidi->private_data instead of handling in a snd_device object. This simplifies the code and structure. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/midi.c | 65 ++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 42 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index 2a42d533f49c..ebca5ebcfecc 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -223,28 +223,20 @@ static struct snd_rawmidi_ops line6_midi_input_ops = { .trigger = line6_midi_input_trigger, }; -/* - Cleanup the Line6 MIDI device. -*/ -static void line6_cleanup_midi(struct snd_rawmidi *rmidi) -{ -} - /* Create a MIDI device */ -static int snd_line6_new_midi(struct snd_line6_midi *line6midi) +static int snd_line6_new_midi(struct usb_line6 *line6, + struct snd_rawmidi **rmidi_ret) { struct snd_rawmidi *rmidi; int err; - err = snd_rawmidi_new(line6midi->line6->card, "Line6 MIDI", 0, 1, 1, - &rmidi); + err = snd_rawmidi_new(line6->card, "Line6 MIDI", 0, 1, 1, rmidi_ret); if (err < 0) return err; - rmidi->private_data = line6midi; - rmidi->private_free = line6_cleanup_midi; - strcpy(rmidi->id, line6midi->line6->properties->id); - strcpy(rmidi->name, line6midi->line6->properties->name); + rmidi = *rmidi_ret; + strcpy(rmidi->id, line6->properties->id); + strcpy(rmidi->name, line6->properties->name); rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT | @@ -258,13 +250,13 @@ static int snd_line6_new_midi(struct snd_line6_midi *line6midi) } /* MIDI device destructor */ -static int snd_line6_midi_free(struct snd_device *device) +static void snd_line6_midi_free(struct snd_rawmidi *rmidi) { - struct snd_line6_midi *line6midi = device->device_data; + struct snd_line6_midi *line6midi = rmidi->private_data; line6_midibuf_destroy(&line6midi->midibuf_in); line6_midibuf_destroy(&line6midi->midibuf_out); - return 0; + kfree(line6midi); } /* @@ -272,11 +264,8 @@ static int snd_line6_midi_free(struct snd_device *device) */ int line6_init_midi(struct usb_line6 *line6) { - static struct snd_device_ops midi_ops = { - .dev_free = snd_line6_midi_free, - }; - int err; + struct snd_rawmidi *rmidi; struct snd_line6_midi *line6midi; if (!(line6->properties->capabilities & LINE6_CAP_CONTROL)) { @@ -284,39 +273,31 @@ int line6_init_midi(struct usb_line6 *line6) return 0; } - line6midi = kzalloc(sizeof(struct snd_line6_midi), GFP_KERNEL); + err = snd_line6_new_midi(line6, &rmidi); + if (err < 0) + return err; - if (line6midi == NULL) + line6midi = kzalloc(sizeof(struct snd_line6_midi), GFP_KERNEL); + if (!line6midi) return -ENOMEM; - err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0); - if (err < 0) { - kfree(line6midi); - return err; - } - - err = line6_midibuf_init(&line6midi->midibuf_out, MIDI_BUFFER_SIZE, 1); - if (err < 0) { - kfree(line6midi->midibuf_in.buf); - kfree(line6midi); - return err; - } + rmidi->private_data = line6midi; + rmidi->private_free = snd_line6_midi_free; + init_waitqueue_head(&line6midi->send_wait); + spin_lock_init(&line6midi->send_urb_lock); + spin_lock_init(&line6midi->midi_transmit_lock); line6midi->line6 = line6; - line6->line6midi = line6midi; - err = snd_device_new(line6->card, SNDRV_DEV_RAWMIDI, line6midi, - &midi_ops); + err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0); if (err < 0) return err; - err = snd_line6_new_midi(line6midi); + err = line6_midibuf_init(&line6midi->midibuf_out, MIDI_BUFFER_SIZE, 1); if (err < 0) return err; - init_waitqueue_head(&line6midi->send_wait); - spin_lock_init(&line6midi->send_urb_lock); - spin_lock_init(&line6midi->midi_transmit_lock); + line6->line6midi = line6midi; return 0; } EXPORT_SYMBOL_GPL(line6_init_midi); -- cgit From 988d350aef30b798198e7915c574f82ba173f40f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 14:58:29 +0100 Subject: ALSA: line6: Drop invalid SNDRV_PCM_INFO_RESUME flag The line6 drivers don't support the full resume although they set SNDRV_PCM_INFO_RESUME. These flags have to be dropped to inform properly to the user-space. Also, drop the CONFIG_PM in trigger callbacks, too, which are rather superfluous. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 4 ---- sound/usb/line6/playback.c | 4 ---- sound/usb/line6/pod.c | 6 ------ sound/usb/line6/podhd.c | 6 ------ sound/usb/line6/toneport.c | 6 ------ 5 files changed, 26 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 4cf6fa0541f1..1970ab57cb6f 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -342,9 +342,7 @@ int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd) switch (cmd) { case SNDRV_PCM_TRIGGER_START: -#ifdef CONFIG_PM case SNDRV_PCM_TRIGGER_RESUME: -#endif err = line6_pcm_acquire(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_STREAM); @@ -354,9 +352,7 @@ int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd) break; case SNDRV_PCM_TRIGGER_STOP: -#ifdef CONFIG_PM case SNDRV_PCM_TRIGGER_SUSPEND: -#endif err = line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_STREAM); diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 258147eadf37..8fc2dedbeb52 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -490,9 +490,7 @@ int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd) switch (cmd) { case SNDRV_PCM_TRIGGER_START: -#ifdef CONFIG_PM case SNDRV_PCM_TRIGGER_RESUME: -#endif err = line6_pcm_acquire(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM); @@ -502,9 +500,7 @@ int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd) break; case SNDRV_PCM_TRIGGER_STOP: -#ifdef CONFIG_PM case SNDRV_PCM_TRIGGER_SUSPEND: -#endif err = line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM); diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index dde9c2b8ad0f..d6bc5a1ab7f4 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -153,9 +153,6 @@ static struct line6_pcm_properties pod_pcm_properties = { SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_KNOT, @@ -173,9 +170,6 @@ static struct line6_pcm_properties pod_pcm_properties = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_KNOT, diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 84096326694c..8f4ca1d20b62 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -50,9 +50,6 @@ static struct line6_pcm_properties podhd_pcm_properties = { SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_48000, @@ -70,9 +67,6 @@ static struct line6_pcm_properties podhd_pcm_properties = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S24_3LE, .rates = SNDRV_PCM_RATE_48000, diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 4f07643e47f2..6ec3268a6153 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -83,9 +83,6 @@ static struct line6_pcm_properties toneport_pcm_properties = { SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_KNOT, @@ -103,9 +100,6 @@ static struct line6_pcm_properties toneport_pcm_properties = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | -#ifdef CONFIG_PM - SNDRV_PCM_INFO_RESUME | -#endif SNDRV_PCM_INFO_SYNC_START), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_KNOT, -- cgit From 45a82f18913fd9b959f0703ed47750733840e92a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 15:02:30 +0100 Subject: ALSA: line6: Drop usb_device sysfs symlink It's non-standard and rather superfluous. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 149c393c7302..23d504f4b6bc 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -611,11 +611,6 @@ int line6_probe(struct usb_interface *interface, if (ret < 0) goto err_destruct; - ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj, - "usb_device"); - if (ret < 0) - goto err_destruct; - /* creation of additional special files should go here */ dev_info(&interface->dev, "Line6 %s now attached\n", @@ -649,10 +644,6 @@ void line6_disconnect(struct usb_interface *interface) if (usbdev == NULL) return; - /* removal of additional special files should go here */ - - sysfs_remove_link(&interface->dev.kobj, "usb_device"); - interface_number = interface->cur_altsetting->desc.bInterfaceNumber; line6 = usb_get_intfdata(interface); -- cgit From a019f5e8c522f5b5f8b3419a1e56d142ea4c7621 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 15:05:10 +0100 Subject: ALSA: line6: Remove superfluous out-of-memory error messages Kernel already shows the error in the common path. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 4 +--- sound/usb/line6/driver.c | 6 +----- sound/usb/line6/midi.c | 5 +---- sound/usb/line6/playback.c | 4 +--- sound/usb/line6/variax.c | 4 +--- 5 files changed, 5 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 1970ab57cb6f..727b31876d48 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -402,10 +402,8 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) urb = line6pcm->urb_audio_in[i] = usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); - if (urb == NULL) { - dev_err(line6->ifcdev, "Out of memory\n"); + if (urb == NULL) return -ENOMEM; - } urb->dev = line6->usbdev; urb->pipe = diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 23d504f4b6bc..b8f5134dcec2 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -190,7 +190,6 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, if (urb == NULL) { kfree(msg); - dev_err(line6->ifcdev, "Out of memory\n"); return -ENOMEM; } @@ -215,10 +214,8 @@ int line6_version_request_async(struct usb_line6 *line6) buffer = kmemdup(line6_request_version, sizeof(line6_request_version), GFP_ATOMIC); - if (buffer == NULL) { - dev_err(line6->ifcdev, "Out of memory"); + if (buffer == NULL) return -ENOMEM; - } retval = line6_send_raw_message_async(line6, buffer, sizeof(line6_request_version)); @@ -593,7 +590,6 @@ int line6_probe(struct usb_interface *interface, line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL); if (line6->urb_listen == NULL) { - dev_err(&interface->dev, "Out of memory\n"); ret = -ENOMEM; goto err_destruct; } diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index ebca5ebcfecc..f333cef5d2d7 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -121,16 +121,13 @@ static int send_midi_async(struct usb_line6 *line6, unsigned char *data, urb = usb_alloc_urb(0, GFP_ATOMIC); - if (urb == NULL) { - dev_err(line6->ifcdev, "Out of memory\n"); + if (urb == NULL) return -ENOMEM; - } transfer_buffer = kmemdup(data, length, GFP_ATOMIC); if (transfer_buffer == NULL) { usb_free_urb(urb); - dev_err(line6->ifcdev, "Out of memory\n"); return -ENOMEM; } diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 8fc2dedbeb52..5a7fe409a3b9 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -558,10 +558,8 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) urb = line6pcm->urb_audio_out[i] = usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); - if (urb == NULL) { - dev_err(line6->ifcdev, "Out of memory\n"); + if (urb == NULL) return -ENOMEM; - } urb->dev = line6->usbdev; urb->pipe = diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index 0c852bb1e76c..9a9c7e48e24f 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -260,10 +260,8 @@ static int variax_try_init(struct usb_interface *interface, variax->buffer_activate = kmemdup(variax_activate, sizeof(variax_activate), GFP_KERNEL); - if (variax->buffer_activate == NULL) { - dev_err(&interface->dev, "Out of memory\n"); + if (variax->buffer_activate == NULL) return -ENOMEM; - } /* initialize audio system: */ err = line6_init_audio(&variax->line6); -- cgit From 7d70c81ccaccb74326255fb9549c872bc29193d6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 15:11:17 +0100 Subject: ALSA: line6: Don't handle PCM trigger for other cards Otherwise it oopses. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 520cf540e83c..932cc7e194e2 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -233,6 +233,8 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) clear_bit(LINE6_INDEX_PREPARED, &line6pcm->flags); snd_pcm_group_for_each_entry(s, substream) { + if (s->pcm->card != substream->pcm->card) + continue; switch (s->stream) { case SNDRV_PCM_STREAM_PLAYBACK: err = snd_line6_playback_trigger(line6pcm, cmd); -- cgit From 84ac9bb12e8158e1affad4ae7718eb653fa5e36d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 15:15:21 +0100 Subject: ALSA: line6: Drop superfluous irqsave/irqrestore in PCM trigger callback The PCM trigger callback is guaranteed to be called already in spinlock / irq-disabled context. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 932cc7e194e2..edab3cd7c048 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -227,9 +227,8 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); struct snd_pcm_substream *s; int err; - unsigned long flags; - spin_lock_irqsave(&line6pcm->lock_trigger, flags); + spin_lock(&line6pcm->lock_trigger); clear_bit(LINE6_INDEX_PREPARED, &line6pcm->flags); snd_pcm_group_for_each_entry(s, substream) { @@ -240,8 +239,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) err = snd_line6_playback_trigger(line6pcm, cmd); if (err < 0) { - spin_unlock_irqrestore(&line6pcm->lock_trigger, - flags); + spin_unlock(&line6pcm->lock_trigger); return err; } @@ -251,8 +249,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) err = snd_line6_capture_trigger(line6pcm, cmd); if (err < 0) { - spin_unlock_irqrestore(&line6pcm->lock_trigger, - flags); + spin_unlock(&line6pcm->lock_trigger); return err; } @@ -264,7 +261,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) } } - spin_unlock_irqrestore(&line6pcm->lock_trigger, flags); + spin_unlock(&line6pcm->lock_trigger); return 0; } -- cgit From 85a9339becf0af4d547ceb6bb16d1893b05fbce4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 15:54:00 +0100 Subject: ALSA: line6: Reorganize card resource handling This is a fairly big rewrite regarding the card resource management in line6 drivers: - The card creation is moved into line6_probe(). This adds the global destructor to private_free, so that each driver doesn't have to call it any longer. - The USB disconnect callback handles the card release, thus each driver needs to concentrate on only its own resources. No need to snd_card_*() call in the destructor. - Fix the potential stall in disconnection by removing snd_card_free(). It's replaced with snd_card_free_when_closed() for asynchronous release. - The only remaining operation for the card in each driver is the call of snd_card_register(). All the rest are dealt in the common module by itself. - These ended up with removal of audio.[ch] as a result of a reduction of one layer. Each driver just needs to call line6_probe(). Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/Makefile | 1 - sound/usb/line6/audio.c | 74 ----------------------------------------- sound/usb/line6/audio.h | 21 ------------ sound/usb/line6/capture.c | 1 - sound/usb/line6/driver.c | 82 +++++++++++++++++++++++++++------------------- sound/usb/line6/midi.c | 1 - sound/usb/line6/pcm.c | 1 - sound/usb/line6/playback.c | 1 - sound/usb/line6/pod.c | 60 +++++---------------------------- sound/usb/line6/podhd.c | 75 ++++-------------------------------------- sound/usb/line6/toneport.c | 65 ++++-------------------------------- sound/usb/line6/variax.c | 58 ++++++++------------------------ 12 files changed, 85 insertions(+), 355 deletions(-) delete mode 100644 sound/usb/line6/audio.c delete mode 100644 sound/usb/line6/audio.h (limited to 'sound') diff --git a/sound/usb/line6/Makefile b/sound/usb/line6/Makefile index fa3a78dac097..b8b3b2a543d8 100644 --- a/sound/usb/line6/Makefile +++ b/sound/usb/line6/Makefile @@ -1,5 +1,4 @@ snd-usb-line6-y := \ - audio.o \ capture.o \ driver.o \ midi.o \ diff --git a/sound/usb/line6/audio.c b/sound/usb/line6/audio.c deleted file mode 100644 index 95686e5af4bd..000000000000 --- a/sound/usb/line6/audio.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Line6 Linux USB driver - 0.9.1beta - * - * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2. - * - */ - -#include -#include -#include - -#include "driver.h" -#include "audio.h" - -/* - Initialize the Line6 USB audio system. -*/ -int line6_init_audio(struct usb_line6 *line6) -{ - struct snd_card *card; - int err; - - err = snd_card_new(line6->ifcdev, - SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, - THIS_MODULE, 0, &card); - if (err < 0) - return err; - - line6->card = card; - - strcpy(card->id, line6->properties->id); - strcpy(card->driver, DRIVER_NAME); - strcpy(card->shortname, line6->properties->name); - /* longname is 80 chars - see asound.h */ - sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name, - dev_name(line6->ifcdev)); - return 0; -} -EXPORT_SYMBOL_GPL(line6_init_audio); - -/* - Register the Line6 USB audio system. -*/ -int line6_register_audio(struct usb_line6 *line6) -{ - int err; - - err = snd_card_register(line6->card); - if (err < 0) - return err; - - return 0; -} -EXPORT_SYMBOL_GPL(line6_register_audio); - -/* - Cleanup the Line6 USB audio system. -*/ -void line6_cleanup_audio(struct usb_line6 *line6) -{ - struct snd_card *card = line6->card; - - if (card == NULL) - return; - - snd_card_disconnect(card); - snd_card_free(card); - line6->card = NULL; -} -EXPORT_SYMBOL_GPL(line6_cleanup_audio); diff --git a/sound/usb/line6/audio.h b/sound/usb/line6/audio.h deleted file mode 100644 index 5f8a09a0fa95..000000000000 --- a/sound/usb/line6/audio.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Line6 Linux USB driver - 0.9.1beta - * - * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2. - * - */ - -#ifndef AUDIO_H -#define AUDIO_H - -#include "driver.h" - -extern void line6_cleanup_audio(struct usb_line6 *); -extern int line6_init_audio(struct usb_line6 *); -extern int line6_register_audio(struct usb_line6 *); - -#endif diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 727b31876d48..e8c54ede9227 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -14,7 +14,6 @@ #include #include -#include "audio.h" #include "capture.h" #include "driver.h" #include "pcm.h" diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index b8f5134dcec2..8b6a658a8a58 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -15,7 +15,9 @@ #include #include -#include "audio.h" +#include +#include + #include "capture.h" #include "driver.h" #include "midi.h" @@ -481,17 +483,16 @@ ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, EXPORT_SYMBOL_GPL(line6_nop_read); /* - Generic destructor. + Card destructor. */ -static void line6_destruct(struct usb_interface *interface) +static void line6_destruct(struct snd_card *card) { - struct usb_line6 *line6; + struct usb_line6 *line6 = card->private_data; + struct usb_device *usbdev; - if (interface == NULL) - return; - line6 = usb_get_intfdata(interface); - if (line6 == NULL) + if (!line6) return; + usbdev = line6->usbdev; /* free buffer memory first: */ kfree(line6->buffer_message); @@ -500,8 +501,11 @@ static void line6_destruct(struct usb_interface *interface) /* then free URBs: */ usb_free_urb(line6->urb_listen); - /* make sure the device isn't destructed twice: */ - usb_set_intfdata(interface, NULL); + /* free interface data: */ + kfree(line6); + + /* decrement reference counters: */ + usb_put_dev(usbdev); } /* @@ -513,6 +517,7 @@ int line6_probe(struct usb_interface *interface, int (*private_init)(struct usb_interface *, struct usb_line6 *)) { struct usb_device *usbdev; + struct snd_card *card; int interface_number; int ret; @@ -569,8 +574,26 @@ int line6_probe(struct usb_interface *interface, } } + ret = snd_card_new(line6->ifcdev, + SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, + THIS_MODULE, 0, &card); + if (ret < 0) + goto err_put; + + line6->card = card; + strcpy(card->id, line6->properties->id); + strcpy(card->driver, DRIVER_NAME); + strcpy(card->shortname, line6->properties->name); + sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name, + dev_name(line6->ifcdev)); + card->private_data = line6; + card->private_free = line6_destruct; + usb_set_intfdata(interface, line6); + /* increment reference counters: */ + usb_get_dev(usbdev); + if (properties->capabilities & LINE6_CAP_CONTROL) { /* initialize USB buffers: */ line6->buffer_listen = @@ -612,15 +635,11 @@ int line6_probe(struct usb_interface *interface, dev_info(&interface->dev, "Line6 %s now attached\n", line6->properties->name); - /* increment reference counters: */ - usb_get_intf(interface); - usb_get_dev(usbdev); - return 0; -err_destruct: - line6_destruct(interface); -err_put: + err_destruct: + snd_card_free(card); + err_put: return ret; } EXPORT_SYMBOL_GPL(line6_probe); @@ -642,29 +661,26 @@ void line6_disconnect(struct usb_interface *interface) interface_number = interface->cur_altsetting->desc.bInterfaceNumber; line6 = usb_get_intfdata(interface); + if (!line6) + return; - if (line6 != NULL) { - if (line6->urb_listen != NULL) - line6_stop_listen(line6); + if (line6->urb_listen != NULL) + line6_stop_listen(line6); - if (usbdev != line6->usbdev) - dev_err(line6->ifcdev, - "driver bug: inconsistent usb device\n"); + if (usbdev != line6->usbdev) + dev_err(line6->ifcdev, "driver bug: inconsistent usb device\n"); + snd_card_disconnect(line6->card); + if (line6->disconnect) line6->disconnect(interface); - dev_info(&interface->dev, "Line6 %s now disconnected\n", - line6->properties->name); - } - - line6_destruct(interface); + dev_info(&interface->dev, "Line6 %s now disconnected\n", + line6->properties->name); - /* free interface data: */ - kfree(line6); + /* make sure the device isn't destructed twice: */ + usb_set_intfdata(interface, NULL); - /* decrement reference counters: */ - usb_put_intf(interface); - usb_put_dev(usbdev); + snd_card_free_when_closed(line6->card); } EXPORT_SYMBOL_GPL(line6_disconnect); diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index f333cef5d2d7..68793cc5dc1e 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -15,7 +15,6 @@ #include #include -#include "audio.h" #include "driver.h" #include "midi.h" #include "usbdefs.h" diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index edab3cd7c048..1e77d0d9da17 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -16,7 +16,6 @@ #include #include -#include "audio.h" #include "capture.h" #include "driver.h" #include "playback.h" diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 5a7fe409a3b9..ec2384c875a7 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -14,7 +14,6 @@ #include #include -#include "audio.h" #include "capture.h" #include "driver.h" #include "pcm.h" diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index d6bc5a1ab7f4..6b30deb6b157 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -18,7 +18,6 @@ #include #include -#include "audio.h" #include "capture.h" #include "driver.h" #include "playback.h" @@ -340,7 +339,7 @@ static void pod_startup4(struct work_struct *work) line6_read_serial_number(&pod->line6, &pod->serial_number); /* ALSA audio interface: */ - line6_register_audio(line6); + snd_card_register(line6->card); } /* POD special files: */ @@ -397,21 +396,6 @@ static struct snd_kcontrol_new pod_control_monitor = { .put = snd_pod_control_monitor_put }; -/* - POD destructor. -*/ -static void pod_destruct(struct usb_interface *interface) -{ - struct usb_line6_pod *pod = usb_get_intfdata(interface); - - if (pod == NULL) - return; - line6_cleanup_audio(&pod->line6); - - del_timer(&pod->startup_timer); - cancel_work_sync(&pod->startup_work); -} - /* POD device disconnected. */ @@ -424,21 +408,18 @@ static void line6_pod_disconnect(struct usb_interface *interface) pod = usb_get_intfdata(interface); if (pod != NULL) { - struct snd_line6_pcm *line6pcm = pod->line6.line6pcm; struct device *dev = &interface->dev; - if (line6pcm != NULL) - line6_pcm_disconnect(line6pcm); - if (dev != NULL) { /* remove sysfs entries: */ device_remove_file(dev, &dev_attr_device_id); device_remove_file(dev, &dev_attr_firmware_version); device_remove_file(dev, &dev_attr_serial_number); } - } - pod_destruct(interface); + del_timer_sync(&pod->startup_timer); + cancel_work_sync(&pod->startup_work); + } } /* @@ -457,8 +438,8 @@ static int pod_create_files2(struct device *dev) /* Try to init POD device. */ -static int pod_try_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int pod_init(struct usb_interface *interface, + struct usb_line6 *line6) { int err; struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; @@ -477,11 +458,6 @@ static int pod_try_init(struct usb_interface *interface, if (err < 0) return err; - /* initialize audio system: */ - err = line6_init_audio(line6); - if (err < 0) - return err; - /* initialize MIDI subsystem: */ err = line6_init_midi(line6); if (err < 0) @@ -514,20 +490,6 @@ static int pod_try_init(struct usb_interface *interface, return 0; } -/* - Init POD device (and clean up in case of failure). -*/ -static int pod_init(struct usb_interface *interface, - struct usb_line6 *line6) -{ - int err = pod_try_init(interface, line6); - - if (err < 0) - pod_destruct(interface); - - return err; -} - #define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) #define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) @@ -636,17 +598,13 @@ static int pod_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_line6_pod *pod; - int err; pod = kzalloc(sizeof(*pod), GFP_KERNEL); if (!pod) return -ENODEV; - err = line6_probe(interface, &pod->line6, - &pod_properties_table[id->driver_info], - pod_init); - if (err < 0) - kfree(pod); - return err; + return line6_probe(interface, &pod->line6, + &pod_properties_table[id->driver_info], + pod_init); } static struct usb_driver pod_driver = { diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 8f4ca1d20b62..1d11185780e3 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -15,7 +15,6 @@ #include #include -#include "audio.h" #include "driver.h" #include "pcm.h" #include "usbdefs.h" @@ -85,58 +84,18 @@ static struct line6_pcm_properties podhd_pcm_properties = { .bytes_per_frame = PODHD_BYTES_PER_FRAME }; -/* - POD HD destructor. -*/ -static void podhd_destruct(struct usb_interface *interface) -{ - struct usb_line6_podhd *podhd = usb_get_intfdata(interface); - - if (podhd == NULL) - return; - line6_cleanup_audio(&podhd->line6); -} - -/* - POD HD device disconnected. -*/ -static void line6_podhd_disconnect(struct usb_interface *interface) -{ - struct usb_line6_podhd *podhd; - - if (interface == NULL) - return; - podhd = usb_get_intfdata(interface); - - if (podhd != NULL) { - struct snd_line6_pcm *line6pcm = podhd->line6.line6pcm; - - if (line6pcm != NULL) - line6_pcm_disconnect(line6pcm); - } - - podhd_destruct(interface); -} - /* Try to init POD HD device. */ -static int podhd_try_init(struct usb_interface *interface, - struct usb_line6_podhd *podhd) +static int podhd_init(struct usb_interface *interface, + struct usb_line6 *line6) { + struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; int err; - struct usb_line6 *line6 = &podhd->line6; if ((interface == NULL) || (podhd == NULL)) return -ENODEV; - line6->disconnect = line6_podhd_disconnect; - - /* initialize audio system: */ - err = line6_init_audio(line6); - if (err < 0) - return err; - /* initialize MIDI subsystem: */ err = line6_init_midi(line6); if (err < 0) @@ -148,8 +107,7 @@ static int podhd_try_init(struct usb_interface *interface, return err; /* register USB audio system: */ - err = line6_register_audio(line6); - return err; + return snd_card_register(line6->card); } #define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) @@ -217,21 +175,6 @@ static const struct line6_properties podhd_properties_table[] = { }, }; -/* - Init POD HD device (and clean up in case of failure). -*/ -static int podhd_init(struct usb_interface *interface, - struct usb_line6 *line6) -{ - struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; - int err = podhd_try_init(interface, podhd); - - if (err < 0) - podhd_destruct(interface); - - return err; -} - /* Probe USB device. */ @@ -239,17 +182,13 @@ static int podhd_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_line6_podhd *podhd; - int err; podhd = kzalloc(sizeof(*podhd), GFP_KERNEL); if (!podhd) return -ENODEV; - err = line6_probe(interface, &podhd->line6, - &podhd_properties_table[id->driver_info], - podhd_init); - if (err < 0) - kfree(podhd); - return err; + return line6_probe(interface, &podhd->line6, + &podhd_properties_table[id->driver_info], + podhd_init); } static struct usb_driver podhd_driver = { diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 6ec3268a6153..3097a75a9bec 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -17,7 +17,6 @@ #include #include -#include "audio.h" #include "capture.h" #include "driver.h" #include "playback.h" @@ -330,18 +329,6 @@ static struct snd_kcontrol_new toneport_control_source = { .put = snd_toneport_source_put }; -/* - Toneport destructor. -*/ -static void toneport_destruct(struct usb_interface *interface) -{ - struct usb_line6_toneport *toneport = usb_get_intfdata(interface); - - if (toneport == NULL) - return; - line6_cleanup_audio(&toneport->line6); -} - /* Setup Toneport device. */ @@ -394,25 +381,14 @@ static void line6_toneport_disconnect(struct usb_interface *interface) device_remove_file(&interface->dev, &dev_attr_led_red); device_remove_file(&interface->dev, &dev_attr_led_green); } - - if (toneport != NULL) { - struct snd_line6_pcm *line6pcm = toneport->line6.line6pcm; - - if (line6pcm != NULL) { - line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR); - line6_pcm_disconnect(line6pcm); - } - } - - toneport_destruct(interface); } /* Try to init Toneport device. */ -static int toneport_try_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int toneport_init(struct usb_interface *interface, + struct usb_line6 *line6) { int err; struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; @@ -422,11 +398,6 @@ static int toneport_try_init(struct usb_interface *interface, line6->disconnect = line6_toneport_disconnect; - /* initialize audio system: */ - err = line6_init_audio(line6); - if (err < 0) - return err; - /* initialize PCM subsystem: */ err = line6_init_pcm(line6, &toneport_pcm_properties); if (err < 0) @@ -456,11 +427,6 @@ static int toneport_try_init(struct usb_interface *interface, break; } - /* register audio system: */ - err = line6_register_audio(line6); - if (err < 0) - return err; - line6_read_serial_number(line6, &toneport->serial_number); line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); @@ -477,21 +443,8 @@ static int toneport_try_init(struct usb_interface *interface, (unsigned long)toneport); mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ); - return 0; -} - -/* - Init Toneport device (and clean up in case of failure). -*/ -static int toneport_init(struct usb_interface *interface, - struct usb_line6 *line6) -{ - int err = toneport_try_init(interface, line6); - - if (err < 0) - toneport_destruct(interface); - - return err; + /* register audio system: */ + return snd_card_register(line6->card); } #ifdef CONFIG_PM @@ -595,18 +548,14 @@ static int toneport_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_line6_toneport *toneport; - int err; toneport = kzalloc(sizeof(*toneport), GFP_KERNEL); if (!toneport) return -ENODEV; toneport->type = id->driver_info; - err = line6_probe(interface, &toneport->line6, - &toneport_properties_table[id->driver_info], - toneport_init); - if (err < 0) - kfree(toneport); - return err; + return line6_probe(interface, &toneport->line6, + &toneport_properties_table[id->driver_info], + toneport_init); } static struct usb_driver toneport_driver = { diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index 9a9c7e48e24f..a591c2c5794f 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -16,7 +16,6 @@ #include #include -#include "audio.h" #include "driver.h" #include "usbdefs.h" @@ -179,7 +178,7 @@ static void variax_startup6(struct work_struct *work) CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_SETUP); /* ALSA audio interface: */ - line6_register_audio(&variax->line6); + snd_card_register(variax->line6.card); } /* @@ -211,13 +210,16 @@ static void line6_variax_process_message(struct usb_line6 *line6) /* Variax destructor. */ -static void variax_destruct(struct usb_interface *interface) +static void line6_variax_disconnect(struct usb_interface *interface) { - struct usb_line6_variax *variax = usb_get_intfdata(interface); + struct usb_line6_variax *variax; + + if (!interface) + return; - if (variax == NULL) + variax = usb_get_intfdata(interface); + if (!variax) return; - line6_cleanup_audio(&variax->line6); del_timer(&variax->startup_timer1); del_timer(&variax->startup_timer2); @@ -226,22 +228,11 @@ static void variax_destruct(struct usb_interface *interface) kfree(variax->buffer_activate); } -/* - Workbench device disconnected. -*/ -static void line6_variax_disconnect(struct usb_interface *interface) -{ - if (interface == NULL) - return; - - variax_destruct(interface); -} - /* Try to init workbench device. */ -static int variax_try_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int variax_init(struct usb_interface *interface, + struct usb_line6 *line6) { struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; int err; @@ -263,11 +254,6 @@ static int variax_try_init(struct usb_interface *interface, if (variax->buffer_activate == NULL) return -ENOMEM; - /* initialize audio system: */ - err = line6_init_audio(&variax->line6); - if (err < 0) - return err; - /* initialize MIDI subsystem: */ err = line6_init_midi(&variax->line6); if (err < 0) @@ -278,20 +264,6 @@ static int variax_try_init(struct usb_interface *interface, return 0; } -/* - Init workbench device (and clean up in case of failure). -*/ -static int variax_init(struct usb_interface *interface, - struct usb_line6 *line6) -{ - int err = variax_try_init(interface, line6); - - if (err < 0) - variax_destruct(interface); - - return err; -} - #define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) #define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) @@ -335,17 +307,13 @@ static int variax_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_line6_variax *variax; - int err; variax = kzalloc(sizeof(*variax), GFP_KERNEL); if (!variax) return -ENODEV; - err = line6_probe(interface, &variax->line6, - &variax_properties_table[id->driver_info], - variax_init); - if (err < 0) - kfree(variax); - return err; + return line6_probe(interface, &variax->line6, + &variax_properties_table[id->driver_info], + variax_init); } static struct usb_driver variax_driver = { -- cgit From 2cd53fa9d38b98ea5ae4268e021c4f4cd68227a5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 16:02:36 +0100 Subject: ALSA: line6: Remove driver version string This is rather useless for a driver that has been already merged into the official tree. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 8b6a658a8a58..6a3ec07d869f 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -27,7 +27,6 @@ #define DRIVER_AUTHOR "Markus Grabner " #define DRIVER_DESC "Line6 USB Driver" -#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION /* This is Line6's MIDI manufacturer ID. @@ -729,4 +728,3 @@ EXPORT_SYMBOL_GPL(line6_resume); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRIVER_VERSION); -- cgit From 10e3a023c97e67975812027c1a96db874be2e78d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 16:06:03 +0100 Subject: ALSA: line6: Drop MISSING_CASE macro Such a debug is needed in the core code, not in each lowlevel driver. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.h | 4 ---- sound/usb/line6/pcm.c | 3 --- 2 files changed, 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index 31cd318369e9..8e4d946a130c 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -48,10 +48,6 @@ #define LINE6_CHANNEL_MASK 0x0f -#define MISSING_CASE \ - pr_err("line6usb driver bug: missing case in %s:%d\n", \ - __FILE__, __LINE__) - #define CHECK_RETURN(x) \ do { \ err = x; \ diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 1e77d0d9da17..39034c7681da 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -488,9 +488,6 @@ int snd_line6_prepare(struct snd_pcm_substream *substream) line6_unlink_wait_clear_audio_in_urbs(line6pcm); break; - - default: - MISSING_CASE; } if (!test_and_set_bit(LINE6_INDEX_PREPARED, &line6pcm->flags)) { -- cgit From b2a3b02392836b8cc0aa4246d7496028911f1539 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 16:08:02 +0100 Subject: ALSA: line6: Remove CHECK_RETURN macro Such a macro doesn't improve readability. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.h | 7 ------- sound/usb/line6/pod.c | 12 +++++++++--- sound/usb/line6/toneport.c | 10 ++++++---- 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index 8e4d946a130c..f484aa09840b 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -48,13 +48,6 @@ #define LINE6_CHANNEL_MASK 0x0f -#define CHECK_RETURN(x) \ -do { \ - err = x; \ - if (err < 0) \ - return err; \ -} while (0) - #define CHECK_STARTUP_PROGRESS(x, n) \ do { \ if ((x) >= (n)) \ diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 6b30deb6b157..6f4b09982589 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -429,9 +429,15 @@ static int pod_create_files2(struct device *dev) { int err; - CHECK_RETURN(device_create_file(dev, &dev_attr_device_id)); - CHECK_RETURN(device_create_file(dev, &dev_attr_firmware_version)); - CHECK_RETURN(device_create_file(dev, &dev_attr_serial_number)); + err = device_create_file(dev, &dev_attr_device_id); + if (err < 0) + return err; + err = device_create_file(dev, &dev_attr_firmware_version); + if (err < 0) + return err; + err = device_create_file(dev, &dev_attr_serial_number); + if (err < 0) + return err; return 0; } diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 3097a75a9bec..24544b7ab476 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -431,10 +431,12 @@ static int toneport_init(struct usb_interface *interface, line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); if (toneport_has_led(toneport->type)) { - CHECK_RETURN(device_create_file - (&interface->dev, &dev_attr_led_red)); - CHECK_RETURN(device_create_file - (&interface->dev, &dev_attr_led_green)); + err = device_create_file(&interface->dev, &dev_attr_led_red); + if (err < 0) + return err; + err = device_create_file(&interface->dev, &dev_attr_led_green); + if (err < 0) + return err; } toneport_setup(toneport); -- cgit From 31ca192139a152fcc550b9ebfb0e2d2d6247585e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 16:12:19 +0100 Subject: ALSA: line6: Remove superfluous disconnect call in suspend handler Calling line6_pcm_disconnect() at suspend callback is superfluous and rather confusing. Let's get rid of it. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 6a3ec07d869f..f222d9ffeca5 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -700,7 +700,6 @@ int line6_suspend(struct usb_interface *interface, pm_message_t message) if (line6pcm != NULL) { snd_pcm_suspend_all(line6pcm->pcm); - line6_pcm_disconnect(line6pcm); line6pcm->flags = 0; } -- cgit From 5a4753112afc4d418ec6023bac757a9ec3eb7a32 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 16:15:54 +0100 Subject: ALSA: line6: Sync PCM stop at disconnect Call line6_pcm_disconnect() at disconnect to make sure that all URBs are cleared. Also reduce the superfluous snd_pcm_stop() calls from the function (and remove the unused function) since the streams are guaranteed to be stopped at this point via snd_card_disconnect(). Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 2 ++ sound/usb/line6/pcm.c | 19 +------------------ 2 files changed, 3 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index f222d9ffeca5..1193d16396a0 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -670,6 +670,8 @@ void line6_disconnect(struct usb_interface *interface) dev_err(line6->ifcdev, "driver bug: inconsistent usb device\n"); snd_card_disconnect(line6->card); + if (line6->line6pcm) + line6_pcm_disconnect(line6->line6pcm); if (line6->disconnect) line6->disconnect(interface); diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 39034c7681da..08fa9753a680 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -379,30 +379,13 @@ static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret) } /* - Stop substream if still running. -*/ -static void pcm_disconnect_substream(struct snd_pcm_substream *substream) -{ - if (substream->runtime && snd_pcm_running(substream)) { - snd_pcm_stream_lock_irq(substream); - snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED); - snd_pcm_stream_unlock_irq(substream); - } -} - -/* - Stop PCM stream. + Sync with PCM stream stops. */ void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm) { - pcm_disconnect_substream(get_substream - (line6pcm, SNDRV_PCM_STREAM_CAPTURE)); - pcm_disconnect_substream(get_substream - (line6pcm, SNDRV_PCM_STREAM_PLAYBACK)); line6_unlink_wait_clear_audio_out_urbs(line6pcm); line6_unlink_wait_clear_audio_in_urbs(line6pcm); } -EXPORT_SYMBOL_GPL(line6_pcm_disconnect); /* Create and register the PCM device and mixer entries. -- cgit From 73723190282d2d6dcb831b3d98f760337d83408c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 16:36:21 +0100 Subject: ALSA: line6: Make line6_send_raw_message() static It's used only locally. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 4 ++-- sound/usb/line6/driver.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 1193d16396a0..a2f72cc2bf96 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -88,8 +88,8 @@ static void line6_stop_listen(struct usb_line6 *line6) /* Send raw message in pieces of wMaxPacketSize bytes. */ -int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, - int size) +static int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, + int size) { int i, done = 0; diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index f484aa09840b..8fd65f2e1f06 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -169,8 +169,6 @@ extern int line6_read_data(struct usb_line6 *line6, int address, void *data, extern int line6_read_serial_number(struct usb_line6 *line6, int *serial_number); extern int line6_send_program(struct usb_line6 *line6, u8 value); -extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, - int size); extern int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, int size); extern int line6_send_sysex_message(struct usb_line6 *line6, -- cgit From 4d79fb1ed2487f204a185b59895e9a92ac4b475a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 16:38:23 +0100 Subject: ALSA: line6: Drop line6_send_program() and line6_transmit_parameter() Both functions are used nowhere. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 59 ------------------------------------------------ sound/usb/line6/driver.h | 3 --- 2 files changed, 62 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index a2f72cc2bf96..a3da18b876d1 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -298,65 +298,6 @@ static void line6_data_received(struct urb *urb) line6_start_listen(line6); } -/* - Send channel number (i.e., switch to a different sound). -*/ -int line6_send_program(struct usb_line6 *line6, u8 value) -{ - int retval; - unsigned char *buffer; - int partial; - - buffer = kmalloc(2, GFP_KERNEL); - if (!buffer) - return -ENOMEM; - - buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST; - buffer[1] = value; - - retval = usb_interrupt_msg(line6->usbdev, - usb_sndintpipe(line6->usbdev, - line6->properties->ep_ctrl_w), - buffer, 2, &partial, LINE6_TIMEOUT * HZ); - - if (retval) - dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", - retval); - - kfree(buffer); - return retval; -} - -/* - Transmit Line6 control parameter. -*/ -int line6_transmit_parameter(struct usb_line6 *line6, int param, u8 value) -{ - int retval; - unsigned char *buffer; - int partial; - - buffer = kmalloc(3, GFP_KERNEL); - if (!buffer) - return -ENOMEM; - - buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST; - buffer[1] = param; - buffer[2] = value; - - retval = usb_interrupt_msg(line6->usbdev, - usb_sndintpipe(line6->usbdev, - line6->properties->ep_ctrl_w), - buffer, 3, &partial, LINE6_TIMEOUT * HZ); - - if (retval) - dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", - retval); - - kfree(buffer); - return retval; -} - /* Read data from device. */ diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index 8fd65f2e1f06..d539c11d333d 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -168,7 +168,6 @@ extern int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen); extern int line6_read_serial_number(struct usb_line6 *line6, int *serial_number); -extern int line6_send_program(struct usb_line6 *line6, u8 value); extern int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, int size); extern int line6_send_sysex_message(struct usb_line6 *line6, @@ -178,8 +177,6 @@ extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr, extern void line6_start_timer(struct timer_list *timer, unsigned int msecs, void (*function)(unsigned long), unsigned long data); -extern int line6_transmit_parameter(struct usb_line6 *line6, int param, - u8 value); extern int line6_version_request_async(struct usb_line6 *line6); extern int line6_write_data(struct usb_line6 *line6, int address, void *data, size_t datalen); -- cgit From 35ae48a3f40cff8a418b4f2061de3e2bc432e663 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Tue, 20 Jan 2015 02:20:48 -0600 Subject: ALSA: line6: Remove superfluous NULL checks Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index a3da18b876d1..3757b0c03054 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -456,21 +456,11 @@ int line6_probe(struct usb_interface *interface, const struct line6_properties *properties, int (*private_init)(struct usb_interface *, struct usb_line6 *)) { - struct usb_device *usbdev; + struct usb_device *usbdev = interface_to_usbdev(interface); struct snd_card *card; int interface_number; int ret; - if (!interface) { - ret = -ENODEV; - goto err_put; - } - usbdev = interface_to_usbdev(interface); - if (!usbdev) { - ret = -ENODEV; - goto err_put; - } - /* we don't handle multiple configurations */ if (usbdev->descriptor.bNumConfigurations != 1) { ret = -ENODEV; -- cgit From c6fffce92e1a8cda8c1b552f5a24295839f3f93a Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Tue, 20 Jan 2015 02:20:49 -0600 Subject: ALSA: line6: Refer to manufacturer as "Line 6" The correct spelling includes the space. Fix this in strings and comments that refer to the manufacturer. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/Kconfig | 4 ++-- sound/usb/line6/capture.c | 2 +- sound/usb/line6/capture.h | 2 +- sound/usb/line6/driver.c | 24 ++++++++++++------------ sound/usb/line6/driver.h | 14 +++++++------- sound/usb/line6/midi.c | 6 +++--- sound/usb/line6/midi.h | 4 ++-- sound/usb/line6/midibuf.c | 4 ++-- sound/usb/line6/midibuf.h | 2 +- sound/usb/line6/pcm.c | 2 +- sound/usb/line6/pcm.h | 10 +++++----- sound/usb/line6/playback.c | 2 +- sound/usb/line6/playback.h | 2 +- sound/usb/line6/pod.c | 6 +++--- sound/usb/line6/podhd.c | 6 +++--- sound/usb/line6/toneport.c | 4 ++-- sound/usb/line6/usbdefs.h | 2 +- sound/usb/line6/variax.c | 4 ++-- 18 files changed, 50 insertions(+), 50 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/Kconfig b/sound/usb/line6/Kconfig index 8287ae6a2c26..af20947e0bda 100644 --- a/sound/usb/line6/Kconfig +++ b/sound/usb/line6/Kconfig @@ -4,7 +4,7 @@ config SND_USB_LINE6 select SND_PCM config SND_USB_POD - tristate "Line6 POD USB support" + tristate "Line 6 POD USB support" select SND_USB_LINE6 help This is a driver for PODxt and other similar devices, @@ -21,7 +21,7 @@ config SND_USB_POD re-amping) config SND_USB_PODHD - tristate "Line6 POD HD300/400/500 USB support" + tristate "Line 6 POD HD300/400/500 USB support" select SND_USB_LINE6 help This is a driver for POD HD300, 400 and 500 devices. diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index e8c54ede9227..9da31175dfed 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/capture.h b/sound/usb/line6/capture.h index 4157bcb598a9..ff172fb5bad9 100644 --- a/sound/usb/line6/capture.h +++ b/sound/usb/line6/capture.h @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 3757b0c03054..c668e0755fc4 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * @@ -26,10 +26,10 @@ #include "usbdefs.h" #define DRIVER_AUTHOR "Markus Grabner " -#define DRIVER_DESC "Line6 USB Driver" +#define DRIVER_DESC "Line 6 USB Driver" /* - This is Line6's MIDI manufacturer ID. + This is Line 6's MIDI manufacturer ID. */ const unsigned char line6_midi_id[] = { 0x00, 0x01, 0x0c @@ -260,7 +260,7 @@ char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, EXPORT_SYMBOL_GPL(line6_alloc_sysex_buffer); /* - Notification of data received from the Line6 device. + Notification of data received from the Line 6 device. */ static void line6_data_received(struct urb *urb) { @@ -402,7 +402,7 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data, EXPORT_SYMBOL_GPL(line6_write_data); /* - Read Line6 device serial number. + Read Line 6 device serial number. (POD, TonePort, GuitarPort) */ int line6_read_serial_number(struct usb_line6 *line6, int *serial_number) @@ -468,7 +468,7 @@ int line6_probe(struct usb_interface *interface, } /* initialize device info: */ - dev_info(&interface->dev, "Line6 %s found\n", properties->name); + dev_info(&interface->dev, "Line 6 %s found\n", properties->name); /* query interface number */ interface_number = interface->cur_altsetting->desc.bInterfaceNumber; @@ -514,7 +514,7 @@ int line6_probe(struct usb_interface *interface, strcpy(card->id, line6->properties->id); strcpy(card->driver, DRIVER_NAME); strcpy(card->shortname, line6->properties->name); - sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name, + sprintf(card->longname, "Line 6 %s at USB %s", line6->properties->name, dev_name(line6->ifcdev)); card->private_data = line6; card->private_free = line6_destruct; @@ -562,7 +562,7 @@ int line6_probe(struct usb_interface *interface, /* creation of additional special files should go here */ - dev_info(&interface->dev, "Line6 %s now attached\n", + dev_info(&interface->dev, "Line 6 %s now attached\n", line6->properties->name); return 0; @@ -575,7 +575,7 @@ int line6_probe(struct usb_interface *interface, EXPORT_SYMBOL_GPL(line6_probe); /* - Line6 device disconnected. + Line 6 device disconnected. */ void line6_disconnect(struct usb_interface *interface) { @@ -606,7 +606,7 @@ void line6_disconnect(struct usb_interface *interface) if (line6->disconnect) line6->disconnect(interface); - dev_info(&interface->dev, "Line6 %s now disconnected\n", + dev_info(&interface->dev, "Line 6 %s now disconnected\n", line6->properties->name); /* make sure the device isn't destructed twice: */ @@ -619,7 +619,7 @@ EXPORT_SYMBOL_GPL(line6_disconnect); #ifdef CONFIG_PM /* - Suspend Line6 device. + Suspend Line 6 device. */ int line6_suspend(struct usb_interface *interface, pm_message_t message) { @@ -641,7 +641,7 @@ int line6_suspend(struct usb_interface *interface, pm_message_t message) EXPORT_SYMBOL_GPL(line6_suspend); /* - Resume Line6 device. + Resume Line 6 device. */ int line6_resume(struct usb_interface *interface) { diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index d539c11d333d..ff52169bb5a1 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * @@ -25,7 +25,7 @@ #define LINE6_MESSAGE_MAXLEN 256 /* - Line6 MIDI control commands + Line 6 MIDI control commands */ #define LINE6_PARAM_CHANGE 0xb0 #define LINE6_PROGRAM_CHANGE 0xc0 @@ -61,7 +61,7 @@ static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3; static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4; /** - Common properties of Line6 devices. + Common properties of Line 6 devices. */ struct line6_properties { /** @@ -91,7 +91,7 @@ struct line6_properties { }; /** - Common data shared by all Line6 devices. + Common data shared by all Line 6 devices. Corresponds to a pair of USB endpoints. */ struct usb_line6 { @@ -121,18 +121,18 @@ struct usb_line6 { struct device *ifcdev; /** - Line6 sound card data structure. + Line 6 sound card data structure. Each device has at least MIDI or PCM. */ struct snd_card *card; /** - Line6 PCM device data structure. + Line 6 PCM device data structure. */ struct snd_line6_pcm *line6pcm; /** - Line6 MIDI device data structure. + Line 6 MIDI device data structure. */ struct snd_line6_midi *line6midi; diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index 68793cc5dc1e..64e242b9ce82 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * @@ -226,7 +226,7 @@ static int snd_line6_new_midi(struct usb_line6 *line6, struct snd_rawmidi *rmidi; int err; - err = snd_rawmidi_new(line6->card, "Line6 MIDI", 0, 1, 1, rmidi_ret); + err = snd_rawmidi_new(line6->card, "Line 6 MIDI", 0, 1, 1, rmidi_ret); if (err < 0) return err; @@ -256,7 +256,7 @@ static void snd_line6_midi_free(struct snd_rawmidi *rmidi) } /* - Initialize the Line6 MIDI subsystem. + Initialize the Line 6 MIDI subsystem. */ int line6_init_midi(struct usb_line6 *line6) { diff --git a/sound/usb/line6/midi.h b/sound/usb/line6/midi.h index 78f903fb4d41..68e7d3a19139 100644 --- a/sound/usb/line6/midi.h +++ b/sound/usb/line6/midi.h @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * @@ -20,7 +20,7 @@ struct snd_line6_midi { /** - Pointer back to the Line6 driver data structure. + Pointer back to the Line 6 driver data structure. */ struct usb_line6 *line6; diff --git a/sound/usb/line6/midibuf.c b/sound/usb/line6/midibuf.c index 1ff856989fd6..55df0da5f919 100644 --- a/sound/usb/line6/midibuf.c +++ b/sound/usb/line6/midibuf.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * @@ -26,7 +26,7 @@ static int midibuf_message_length(unsigned char code) } else { /* Note that according to the MIDI specification 0xf2 is - the "Song Position Pointer", but this is used by Line6 + the "Song Position Pointer", but this is used by Line 6 to send sysex messages to the host. */ static const int length[] = { -1, 2, -1, 2, -1, -1, 1, 1, 1, 1, diff --git a/sound/usb/line6/midibuf.h b/sound/usb/line6/midibuf.h index 707482b940e4..18eed7565e05 100644 --- a/sound/usb/line6/midibuf.h +++ b/sound/usb/line6/midibuf.h @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 08fa9753a680..a31a86be2c77 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index 9328e6ffb191..715e84b3057c 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * @@ -26,7 +26,7 @@ /* number of USB frames per URB - The Line6 Windows driver always transmits two frames per packet, but + The Line 6 Windows driver always transmits two frames per packet, but the Linux driver performs significantly better (i.e., lower latency) with only one frame per packet. */ @@ -38,7 +38,7 @@ #define LINE6_IMPULSE_DEFAULT_PERIOD 100 /* - Get substream from Line6 PCM data structure + Get substream from Line 6 PCM data structure */ #define get_substream(line6pcm, stream) \ (line6pcm->pcm->streams[stream].substream) @@ -46,7 +46,7 @@ /* PCM mode bits. - There are several features of the Line6 USB driver which require PCM + There are several features of the Line 6 USB driver which require PCM data to be exchanged with the device: *) PCM playback and capture via ALSA *) software monitoring (for devices without hardware monitoring) @@ -167,7 +167,7 @@ struct line6_pcm_properties { struct snd_line6_pcm { /** - Pointer back to the Line6 driver data structure. + Pointer back to the Line 6 driver data structure. */ struct usb_line6 *line6; diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index ec2384c875a7..660094b46753 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/playback.h b/sound/usb/line6/playback.h index 743bd6f74c57..0dfca5e42490 100644 --- a/sound/usb/line6/playback.h +++ b/sound/usb/line6/playback.h @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 6f4b09982589..7766f5349324 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * @@ -59,7 +59,7 @@ enum { struct usb_line6_pod { /** - Generic Line6 USB data. + Generic Line 6 USB data. */ struct usb_line6 line6; @@ -627,5 +627,5 @@ static struct usb_driver pod_driver = { module_usb_driver(pod_driver); -MODULE_DESCRIPTION("Line6 POD USB driver"); +MODULE_DESCRIPTION("Line 6 POD USB driver"); MODULE_LICENSE("GPL"); diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 1d11185780e3..7217fa7e5db1 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -1,5 +1,5 @@ /* - * Line6 Pod HD + * Line 6 Pod HD * * Copyright (C) 2011 Stefan Hajnoczi * @@ -28,7 +28,7 @@ enum { struct usb_line6_podhd { /** - Generic Line6 USB data. + Generic Line 6 USB data. */ struct usb_line6 line6; }; @@ -205,5 +205,5 @@ static struct usb_driver podhd_driver = { module_usb_driver(podhd_driver); -MODULE_DESCRIPTION("Line6 PODHD USB driver"); +MODULE_DESCRIPTION("Line 6 PODHD USB driver"); MODULE_LICENSE("GPL"); diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 24544b7ab476..77ad98c1a948 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * Emil Myhrman (emil.myhrman@gmail.com) @@ -34,7 +34,7 @@ enum line6_device_type { struct usb_line6_toneport { /** - Generic Line6 USB data. + Generic Line 6 USB data. */ struct usb_line6 line6; diff --git a/sound/usb/line6/usbdefs.h b/sound/usb/line6/usbdefs.h index f4d080e69abc..3aab2e7cbd63 100644 --- a/sound/usb/line6/usbdefs.h +++ b/sound/usb/line6/usbdefs.h @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2005-2008 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index a591c2c5794f..5e4da466da50 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -1,5 +1,5 @@ /* - * Line6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver - 0.9.1beta * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * @@ -43,7 +43,7 @@ enum { struct usb_line6_variax { /** - Generic Line6 USB data. + Generic Line 6 USB data. */ struct usb_line6 line6; -- cgit From c078a4aac2944cb9cac5cdb4e9a482623435578b Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Tue, 20 Jan 2015 02:20:50 -0600 Subject: ALSA: line6: Remove driver version from header comment The driver version string was removed in an ealier commit for being useless. These are equally useless. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 2 +- sound/usb/line6/capture.h | 2 +- sound/usb/line6/driver.c | 2 +- sound/usb/line6/driver.h | 2 +- sound/usb/line6/midi.c | 2 +- sound/usb/line6/midi.h | 2 +- sound/usb/line6/midibuf.c | 2 +- sound/usb/line6/midibuf.h | 2 +- sound/usb/line6/pcm.c | 2 +- sound/usb/line6/pcm.h | 2 +- sound/usb/line6/playback.c | 2 +- sound/usb/line6/playback.h | 2 +- sound/usb/line6/pod.c | 2 +- sound/usb/line6/toneport.c | 2 +- sound/usb/line6/usbdefs.h | 2 +- sound/usb/line6/variax.c | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 9da31175dfed..5a010ba163fa 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/capture.h b/sound/usb/line6/capture.h index ff172fb5bad9..0939f400a405 100644 --- a/sound/usb/line6/capture.h +++ b/sound/usb/line6/capture.h @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index c668e0755fc4..93cd4daa56bc 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index ff52169bb5a1..efd58ac3215b 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index 64e242b9ce82..b5a58a7fe11a 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/midi.h b/sound/usb/line6/midi.h index 68e7d3a19139..ba6bf3828aa5 100644 --- a/sound/usb/line6/midi.h +++ b/sound/usb/line6/midi.h @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/midibuf.c b/sound/usb/line6/midibuf.c index 55df0da5f919..b5c4d79de031 100644 --- a/sound/usb/line6/midibuf.c +++ b/sound/usb/line6/midibuf.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/midibuf.h b/sound/usb/line6/midibuf.h index 18eed7565e05..05dbf11a4d63 100644 --- a/sound/usb/line6/midibuf.h +++ b/sound/usb/line6/midibuf.h @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index a31a86be2c77..8a6059adef69 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index 715e84b3057c..c742b33666eb 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 660094b46753..1c9f95a370ff 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/playback.h b/sound/usb/line6/playback.h index 0dfca5e42490..78a885113221 100644 --- a/sound/usb/line6/playback.h +++ b/sound/usb/line6/playback.h @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 7766f5349324..bf027fc70cba 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 77ad98c1a948..c1f61cde52ab 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * Emil Myhrman (emil.myhrman@gmail.com) diff --git a/sound/usb/line6/usbdefs.h b/sound/usb/line6/usbdefs.h index 3aab2e7cbd63..5ef7bcd24e18 100644 --- a/sound/usb/line6/usbdefs.h +++ b/sound/usb/line6/usbdefs.h @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2005-2008 Markus Grabner (grabner@icg.tugraz.at) * diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index 5e4da466da50..99a58cbfd2da 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -1,5 +1,5 @@ /* - * Line 6 Linux USB driver - 0.9.1beta + * Line 6 Linux USB driver * * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) * -- cgit From b4b33f9d64c3edcdcbea874acdc1e9626fd961f1 Mon Sep 17 00:00:00 2001 From: TienFu Chen Date: Tue, 20 Jan 2015 15:06:21 +0100 Subject: ALSA: hda - Enable docking station for an HP machine On this machine we need to inform the driver where the docking station pins are, because it has not been set up by BIOS. Tested-by: TienFu Chen BugLink: https://bugs.launchpad.net/bugs/1412800 Signed-off-by: TienFu Chen Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 1720f8a457d1..040306194e6d 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -4417,6 +4417,7 @@ enum { ALC280_FIXUP_HP_GPIO4, ALC286_FIXUP_HP_GPIO_LED, ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, + ALC280_FIXUP_HP_DOCK_PINS, }; static const struct hda_fixup alc269_fixups[] = { @@ -4894,6 +4895,17 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc280_fixup_hp_gpio2_mic_hotkey, }, + [ALC280_FIXUP_HP_DOCK_PINS] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + { 0x1b, 0x21011020 }, /* line-out */ + { 0x1a, 0x01a1903c }, /* headset mic */ + { 0x18, 0x2181103f }, /* line-in */ + { }, + }, + .chained = true, + .chain_id = ALC280_FIXUP_HP_GPIO4 + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = { @@ -4937,6 +4949,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS), SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), -- cgit From 467be357c622bb33235a4b810c1e3c3ab509c129 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 25 Jan 2015 14:34:57 +0100 Subject: ALSA: seq: correctly report maximum number of ports Due to SNDRV_SEQ_ADDRESS_BROADCAST, not all 256 port number values can be used. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/core/seq/seq_clientmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 225c73152ee9..808918ad2938 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -1133,7 +1133,7 @@ static int snd_seq_ioctl_system_info(struct snd_seq_client *client, void __user /* fill the info fields */ info.queues = SNDRV_SEQ_MAX_QUEUES; info.clients = SNDRV_SEQ_MAX_CLIENTS; - info.ports = 256; /* fixed limit */ + info.ports = SNDRV_SEQ_MAX_PORTS; info.channels = 256; /* fixed limit */ info.cur_clients = client_usage.cur; info.cur_queues = snd_seq_queue_get_cur_queues(); -- cgit From de20b572a30ac3628602cbd17d2765bc3f2cb122 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 25 Jan 2015 14:35:24 +0100 Subject: ALSA: seq: fix off-by-one error in port limit check Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/core/seq/seq_ports.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 794a341bf0e5..52b279b7b030 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -134,7 +134,7 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, if (snd_BUG_ON(!client)) return NULL; - if (client->num_ports >= SNDRV_SEQ_MAX_PORTS - 1) { + if (client->num_ports >= SNDRV_SEQ_MAX_PORTS) { pr_warn("ALSA: seq: too many ports for client %d\n", client->number); return NULL; } -- cgit From a55bdf1ec5945050bfce9c3b2c3d8b70e8fd01a1 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 25 Jan 2015 14:36:27 +0100 Subject: ALSA: seq: remove unused callback_all field Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/core/seq/seq_clientmgr.c | 1 - sound/core/seq/seq_ports.c | 7 ++----- sound/core/seq/seq_ports.h | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 808918ad2938..29182f56bfb7 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -1279,7 +1279,6 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, port->owner = callback->owner; port->private_data = callback->private_data; port->private_free = callback->private_free; - port->callback_all = callback->callback_all; port->event_input = callback->event_input; port->c_src.open = callback->subscribe; port->c_src.close = callback->unsubscribe; diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 52b279b7b030..46ff593f618d 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -411,9 +411,6 @@ int snd_seq_get_port_info(struct snd_seq_client_port * port, * invoked. * This feature is useful if these callbacks are associated with * initialization or termination of devices (see seq_midi.c). - * - * If callback_all option is set, the callback function is invoked - * at each connection/disconnection. */ static int subscribe_port(struct snd_seq_client *client, @@ -427,7 +424,7 @@ static int subscribe_port(struct snd_seq_client *client, if (!try_module_get(port->owner)) return -EFAULT; grp->count++; - if (grp->open && (port->callback_all || grp->count == 1)) { + if (grp->open && grp->count == 1) { err = grp->open(port->private_data, info); if (err < 0) { module_put(port->owner); @@ -452,7 +449,7 @@ static int unsubscribe_port(struct snd_seq_client *client, if (! grp->count) return -EINVAL; grp->count--; - if (grp->close && (port->callback_all || grp->count == 0)) + if (grp->close && grp->count == 0) err = grp->close(port->private_data, info); if (send_ack && client->type == USER_CLIENT) snd_seq_client_notify_subscription(port->addr.client, port->addr.port, diff --git a/sound/core/seq/seq_ports.h b/sound/core/seq/seq_ports.h index 9d7117118ba4..26bd71f36c41 100644 --- a/sound/core/seq/seq_ports.h +++ b/sound/core/seq/seq_ports.h @@ -73,7 +73,6 @@ struct snd_seq_client_port { int atomic, int hop); void (*private_free)(void *private_data); void *private_data; - unsigned int callback_all : 1; unsigned int closing : 1; unsigned int timestamping: 1; unsigned int time_real: 1; -- cgit From 54d96a40e0dfb5aa2eea0b010ddc1c7e8742e364 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Fri, 23 Jan 2015 14:51:09 +0800 Subject: ASoC: rt286: Fix capture volume setting issue The purpose of rt286_adc_event is to mute/numnte the ADC mixer. However, it will also set the capture volume to default value. As a result, "ADC0 Capture Volume" is not working if it is set before capture start. This patch remove rt286_adc_event and add "ADC0 Capture Switch" to mute/unmute ADC mixer. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt286.c | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index 1d1c7f8a9af2..847cc4b9bee5 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -417,6 +417,8 @@ static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); static const struct snd_kcontrol_new rt286_snd_controls[] = { SOC_DOUBLE_R_TLV("DAC0 Playback Volume", RT286_DACL_GAIN, RT286_DACR_GAIN, 0, 0x7f, 0, out_vol_tlv), + SOC_DOUBLE_R("ADC0 Capture Switch", RT286_ADCL_GAIN, + RT286_ADCR_GAIN, 7, 1, 1), SOC_DOUBLE_R_TLV("ADC0 Capture Volume", RT286_ADCL_GAIN, RT286_ADCR_GAIN, 0, 0x7f, 0, out_vol_tlv), SOC_SINGLE_TLV("AMIC Volume", RT286_MIC_GAIN, @@ -538,32 +540,6 @@ static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, return 0; } -static int rt286_adc_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - unsigned int nid; - - nid = (w->reg >> 20) & 0xff; - - switch (event) { - case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, - VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), - 0x7080, 0x7000); - break; - case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, - VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), - 0x7080, 0x7080); - break; - default: - return 0; - } - - return 0; -} - static int rt286_vref_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -667,12 +643,10 @@ static const struct snd_soc_dapm_widget rt286_dapm_widgets[] = { SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 0, 0), /* ADC Mux */ - SND_SOC_DAPM_MUX_E("ADC 0 Mux", RT286_SET_POWER(RT286_ADC_IN1), 0, 1, - &rt286_adc0_mux, rt286_adc_event, SND_SOC_DAPM_PRE_PMD | - SND_SOC_DAPM_POST_PMU), - SND_SOC_DAPM_MUX_E("ADC 1 Mux", RT286_SET_POWER(RT286_ADC_IN2), 0, 1, - &rt286_adc1_mux, rt286_adc_event, SND_SOC_DAPM_PRE_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_MUX("ADC 0 Mux", RT286_SET_POWER(RT286_ADC_IN1), 0, 1, + &rt286_adc0_mux), + SND_SOC_DAPM_MUX("ADC 1 Mux", RT286_SET_POWER(RT286_ADC_IN2), 0, 1, + &rt286_adc1_mux), /* Audio Interface */ SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), -- cgit From b0402717c987c7e1150ae7ad800a9eb75664012f Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:02:01 +0100 Subject: ASoC: sta32x: correct bit shift value for IDE register MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The IDE bit in the CONFF register is the third bit not the fourth. Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/sta32x.h b/sound/soc/codecs/sta32x.h index d8e32a6262ee..d3191c983d71 100644 --- a/sound/soc/codecs/sta32x.h +++ b/sound/soc/codecs/sta32x.h @@ -131,7 +131,7 @@ #define STA32X_CONFF_OCFG_MASK 0x03 #define STA32X_CONFF_OCFG_SHIFT 0 #define STA32X_CONFF_IDE 0x04 -#define STA32X_CONFF_IDE_SHIFT 3 +#define STA32X_CONFF_IDE_SHIFT 2 #define STA32X_CONFF_BCLE 0x08 #define STA32X_CONFF_ECLE 0x20 #define STA32X_CONFF_PWDN 0x40 -- cgit From a1be4cead9b9504aa6fc93b624975601cec8c188 Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:01:53 +0100 Subject: ASoC: sta32x: Convert to direct regmap API usage. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use the regmap API directly rather than relying on the snd_soc_read/write functions as this seems to be in accordance with common practice. Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 1 + sound/soc/codecs/sta32x.c | 271 ++++++++++++++++++++++++++-------------------- 2 files changed, 152 insertions(+), 120 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 8349f982a586..27e1e3b59649 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -581,6 +581,7 @@ config SND_SOC_SSM4567 config SND_SOC_STA32X tristate + select REGMAP_I2C config SND_SOC_STA350 tristate "STA350 speaker amplifier" diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 7e18200dd6a9..4517453b33b6 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -102,6 +102,35 @@ static const struct reg_default sta32x_regs[] = { { 0x2c, 0x0c }, }; +static const struct regmap_range sta32x_write_regs_range[] = { + regmap_reg_range(STA32X_CONFA, STA32X_AUTO2), + regmap_reg_range(STA32X_C1CFG, STA32X_FDRC2), +}; + +static const struct regmap_range sta32x_read_regs_range[] = { + regmap_reg_range(STA32X_CONFA, STA32X_AUTO2), + regmap_reg_range(STA32X_C1CFG, STA32X_FDRC2), +}; + +static const struct regmap_range sta32x_volatile_regs_range[] = { + regmap_reg_range(STA32X_CFADDR2, STA32X_CFUD), +}; + +static const struct regmap_access_table sta32x_write_regs = { + .yes_ranges = sta32x_write_regs_range, + .n_yes_ranges = ARRAY_SIZE(sta32x_write_regs_range), +}; + +static const struct regmap_access_table sta32x_read_regs = { + .yes_ranges = sta32x_read_regs_range, + .n_yes_ranges = ARRAY_SIZE(sta32x_read_regs_range), +}; + +static const struct regmap_access_table sta32x_volatile_regs = { + .yes_ranges = sta32x_volatile_regs_range, + .n_yes_ranges = ARRAY_SIZE(sta32x_volatile_regs_range), +}; + /* regulator power supply names */ static const char *sta32x_supply_names[] = { "Vdda", /* analog supply, 3.3VV */ @@ -122,6 +151,7 @@ struct sta32x_priv { u32 coef_shadow[STA32X_COEF_COUNT]; struct delayed_work watchdog_work; int shutdown; + struct mutex coeff_lock; }; static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12700, 50, 1); @@ -244,29 +274,42 @@ static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; - unsigned int cfud; - int i; + unsigned int cfud, val; + int i, ret = 0; + + mutex_lock(&sta32x->coeff_lock); /* preserve reserved bits in STA32X_CFUD */ - cfud = snd_soc_read(codec, STA32X_CFUD) & 0xf0; - /* chip documentation does not say if the bits are self clearing, - * so do it explicitly */ - snd_soc_write(codec, STA32X_CFUD, cfud); + regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); + cfud &= 0xf0; + /* + * chip documentation does not say if the bits are self clearing, + * so do it explicitly + */ + regmap_write(sta32x->regmap, STA32X_CFUD, cfud); - snd_soc_write(codec, STA32X_CFADDR2, index); - if (numcoef == 1) - snd_soc_write(codec, STA32X_CFUD, cfud | 0x04); - else if (numcoef == 5) - snd_soc_write(codec, STA32X_CFUD, cfud | 0x08); - else - return -EINVAL; - for (i = 0; i < 3 * numcoef; i++) - ucontrol->value.bytes.data[i] = - snd_soc_read(codec, STA32X_B1CF1 + i); + regmap_write(sta32x->regmap, STA32X_CFADDR2, index); + if (numcoef == 1) { + regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x04); + } else if (numcoef == 5) { + regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x08); + } else { + ret = -EINVAL; + goto exit_unlock; + } - return 0; + for (i = 0; i < 3 * numcoef; i++) { + regmap_read(sta32x->regmap, STA32X_B1CF1 + i, &val); + ucontrol->value.bytes.data[i] = val; + } + +exit_unlock: + mutex_unlock(&sta32x->coeff_lock); + + return ret; } static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, @@ -280,24 +323,27 @@ static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, int i; /* preserve reserved bits in STA32X_CFUD */ - cfud = snd_soc_read(codec, STA32X_CFUD) & 0xf0; - /* chip documentation does not say if the bits are self clearing, - * so do it explicitly */ - snd_soc_write(codec, STA32X_CFUD, cfud); + regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); + cfud &= 0xf0; + /* + * chip documentation does not say if the bits are self clearing, + * so do it explicitly + */ + regmap_write(sta32x->regmap, STA32X_CFUD, cfud); - snd_soc_write(codec, STA32X_CFADDR2, index); + regmap_write(sta32x->regmap, STA32X_CFADDR2, index); for (i = 0; i < numcoef && (index + i < STA32X_COEF_COUNT); i++) sta32x->coef_shadow[index + i] = (ucontrol->value.bytes.data[3 * i] << 16) | (ucontrol->value.bytes.data[3 * i + 1] << 8) | (ucontrol->value.bytes.data[3 * i + 2]); for (i = 0; i < 3 * numcoef; i++) - snd_soc_write(codec, STA32X_B1CF1 + i, - ucontrol->value.bytes.data[i]); + regmap_write(sta32x->regmap, STA32X_B1CF1 + i, + ucontrol->value.bytes.data[i]); if (numcoef == 1) - snd_soc_write(codec, STA32X_CFUD, cfud | 0x01); + regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); else if (numcoef == 5) - snd_soc_write(codec, STA32X_CFUD, cfud | 0x02); + regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x02); else return -EINVAL; @@ -311,20 +357,23 @@ static int sta32x_sync_coef_shadow(struct snd_soc_codec *codec) int i; /* preserve reserved bits in STA32X_CFUD */ - cfud = snd_soc_read(codec, STA32X_CFUD) & 0xf0; + regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); + cfud &= 0xf0; for (i = 0; i < STA32X_COEF_COUNT; i++) { - snd_soc_write(codec, STA32X_CFADDR2, i); - snd_soc_write(codec, STA32X_B1CF1, - (sta32x->coef_shadow[i] >> 16) & 0xff); - snd_soc_write(codec, STA32X_B1CF2, - (sta32x->coef_shadow[i] >> 8) & 0xff); - snd_soc_write(codec, STA32X_B1CF3, - (sta32x->coef_shadow[i]) & 0xff); - /* chip documentation does not say if the bits are - * self-clearing, so do it explicitly */ - snd_soc_write(codec, STA32X_CFUD, cfud); - snd_soc_write(codec, STA32X_CFUD, cfud | 0x01); + regmap_write(sta32x->regmap, STA32X_CFADDR2, i); + regmap_write(sta32x->regmap, STA32X_B1CF1, + (sta32x->coef_shadow[i] >> 16) & 0xff); + regmap_write(sta32x->regmap, STA32X_B1CF2, + (sta32x->coef_shadow[i] >> 8) & 0xff); + regmap_write(sta32x->regmap, STA32X_B1CF3, + (sta32x->coef_shadow[i]) & 0xff); + /* + * chip documentation does not say if the bits are + * self-clearing, so do it explicitly + */ + regmap_write(sta32x->regmap, STA32X_CFUD, cfud); + regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); } return 0; } @@ -336,11 +385,11 @@ static int sta32x_cache_sync(struct snd_soc_codec *codec) int rc; /* mute during register sync */ - mute = snd_soc_read(codec, STA32X_MMUTE); - snd_soc_write(codec, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE); + regmap_read(sta32x->regmap, STA32X_MMUTE, &mute); + regmap_write(sta32x->regmap, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE); sta32x_sync_coef_shadow(codec); rc = regcache_sync(sta32x->regmap); - snd_soc_write(codec, STA32X_MMUTE, mute); + regmap_write(sta32x->regmap, STA32X_MMUTE, mute); return rc; } @@ -599,10 +648,7 @@ static int sta32x_set_dai_fmt(struct snd_soc_dai *codec_dai, { struct snd_soc_codec *codec = codec_dai->codec; struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); - u8 confb = snd_soc_read(codec, STA32X_CONFB); - - pr_debug("\n"); - confb &= ~(STA32X_CONFB_C1IM | STA32X_CONFB_C2IM); + u8 confb = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: @@ -632,8 +678,8 @@ static int sta32x_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, STA32X_CONFB, confb); - return 0; + return regmap_update_bits(sta32x->regmap, STA32X_CONFB, + STA32X_CONFB_C1IM | STA32X_CONFB_C2IM, confb); } /** @@ -653,7 +699,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); unsigned int rate; int i, mcs = -1, ir = -1; - u8 confa, confb; + unsigned int confa, confb; rate = params_rate(params); pr_debug("rate: %u\n", rate); @@ -672,12 +718,10 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, if (mcs < 0) return -EINVAL; - confa = snd_soc_read(codec, STA32X_CONFA); - confa &= ~(STA32X_CONFA_MCS_MASK | STA32X_CONFA_IR_MASK); - confa |= (ir << STA32X_CONFA_IR_SHIFT) | (mcs << STA32X_CONFA_MCS_SHIFT); + confa = (ir << STA32X_CONFA_IR_SHIFT) | + (mcs << STA32X_CONFA_MCS_SHIFT); + confb = 0; - confb = snd_soc_read(codec, STA32X_CONFB); - confb &= ~(STA32X_CONFB_SAI_MASK | STA32X_CONFB_SAIFB); switch (params_width(params)) { case 24: pr_debug("24bit\n"); @@ -746,8 +790,20 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_write(codec, STA32X_CONFA, confa); - snd_soc_write(codec, STA32X_CONFB, confb); + ret = regmap_update_bits(sta32x->regmap, STA32X_CONFA, + STA32X_CONFA_MCS_MASK | STA32X_CONFA_IR_MASK, + confa); + if (ret < 0) + return ret; + + ret = regmap_update_bits(sta32x->regmap, STA32X_CONFB, + STA32X_CONFB_SAI_MASK | STA32X_CONFB_SAIFB, + confb); + if (ret < 0) + return ret; + + return 0; +} return 0; } @@ -773,7 +829,7 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* Full power on */ - snd_soc_update_bits(codec, STA32X_CONFF, + regmap_update_bits(sta32x->regmap, STA32X_CONFF, STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, STA32X_CONFF_PWDN | STA32X_CONFF_EAPD); break; @@ -792,19 +848,17 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec, sta32x_watchdog_start(sta32x); } - /* Power up to mute */ - /* FIXME */ - snd_soc_update_bits(codec, STA32X_CONFF, - STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, - STA32X_CONFF_PWDN | STA32X_CONFF_EAPD); + /* Power down */ + regmap_update_bits(sta32x->regmap, STA32X_CONFF, + STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, + 0); break; case SND_SOC_BIAS_OFF: /* The chip runs through the power down sequence for us. */ - snd_soc_update_bits(codec, STA32X_CONFF, - STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, - STA32X_CONFF_PWDN); + regmap_update_bits(sta32x->regmap, STA32X_CONFF, + STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, 0); msleep(300); sta32x_watchdog_stop(sta32x); regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), @@ -836,11 +890,8 @@ static struct snd_soc_dai_driver sta32x_dai = { static int sta32x_probe(struct snd_soc_codec *codec) { struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct sta32x_platform_data *pdata = sta32x->pdata; int i, ret = 0, thermal = 0; - - sta32x->codec = codec; - sta32x->pdata = dev_get_platdata(codec->dev); - ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); if (ret != 0) { @@ -848,50 +899,34 @@ static int sta32x_probe(struct snd_soc_codec *codec) return ret; } - /* Chip documentation explicitly requires that the reset values - * of reserved register bits are left untouched. - * Write the register default value to cache for reserved registers, - * so the write to the these registers are suppressed by the cache - * restore code when it skips writes of default registers. - */ - regcache_cache_only(sta32x->regmap, true); - snd_soc_write(codec, STA32X_CONFC, 0xc2); - snd_soc_write(codec, STA32X_CONFE, 0xc2); - snd_soc_write(codec, STA32X_CONFF, 0x5c); - snd_soc_write(codec, STA32X_MMUTE, 0x10); - snd_soc_write(codec, STA32X_AUTO1, 0x60); - snd_soc_write(codec, STA32X_AUTO3, 0x00); - snd_soc_write(codec, STA32X_C3CFG, 0x40); - regcache_cache_only(sta32x->regmap, false); - /* set thermal warning adjustment and recovery */ - if (!(sta32x->pdata->thermal_conf & STA32X_THERMAL_ADJUSTMENT_ENABLE)) + if (!pdata->thermal_warning_recovery) thermal |= STA32X_CONFA_TWAB; - if (!(sta32x->pdata->thermal_conf & STA32X_THERMAL_RECOVERY_ENABLE)) + if (!pdata->thermal_warning_adjustment) thermal |= STA32X_CONFA_TWRB; - snd_soc_update_bits(codec, STA32X_CONFA, - STA32X_CONFA_TWAB | STA32X_CONFA_TWRB, - thermal); + regmap_update_bits(sta32x->regmap, STA32X_CONFA, + STA32X_CONFA_TWAB | STA32X_CONFA_TWRB, + thermal); /* select output configuration */ - snd_soc_update_bits(codec, STA32X_CONFF, - STA32X_CONFF_OCFG_MASK, - sta32x->pdata->output_conf - << STA32X_CONFF_OCFG_SHIFT); + regmap_update_bits(sta32x->regmap, STA32X_CONFF, + STA32X_CONFF_OCFG_MASK, + pdata->output_conf + << STA32X_CONFF_OCFG_SHIFT); /* channel to output mapping */ - snd_soc_update_bits(codec, STA32X_C1CFG, - STA32X_CxCFG_OM_MASK, - sta32x->pdata->ch1_output_mapping - << STA32X_CxCFG_OM_SHIFT); - snd_soc_update_bits(codec, STA32X_C2CFG, - STA32X_CxCFG_OM_MASK, - sta32x->pdata->ch2_output_mapping - << STA32X_CxCFG_OM_SHIFT); - snd_soc_update_bits(codec, STA32X_C3CFG, - STA32X_CxCFG_OM_MASK, - sta32x->pdata->ch3_output_mapping - << STA32X_CxCFG_OM_SHIFT); + regmap_update_bits(sta32x->regmap, STA32X_C1CFG, + STA32X_CxCFG_OM_MASK, + pdata->ch1_output_mapping + << STA32X_CxCFG_OM_SHIFT); + regmap_update_bits(sta32x->regmap, STA32X_C2CFG, + STA32X_CxCFG_OM_MASK, + pdata->ch2_output_mapping + << STA32X_CxCFG_OM_SHIFT); + regmap_update_bits(sta32x->regmap, STA32X_C3CFG, + STA32X_CxCFG_OM_MASK, + pdata->ch3_output_mapping + << STA32X_CxCFG_OM_SHIFT); /* initialize coefficient shadow RAM with reset values */ for (i = 4; i <= 49; i += 5) @@ -924,16 +959,6 @@ static int sta32x_remove(struct snd_soc_codec *codec) return 0; } -static bool sta32x_reg_is_volatile(struct device *dev, unsigned int reg) -{ - switch (reg) { - case STA32X_CONFA ... STA32X_L2ATRT: - case STA32X_MPCC1 ... STA32X_FDRC2: - return 0; - } - return 1; -} - static const struct snd_soc_codec_driver sta32x_codec = { .probe = sta32x_probe, .remove = sta32x_remove, @@ -954,12 +979,16 @@ static const struct regmap_config sta32x_regmap = { .reg_defaults = sta32x_regs, .num_reg_defaults = ARRAY_SIZE(sta32x_regs), .cache_type = REGCACHE_RBTREE, - .volatile_reg = sta32x_reg_is_volatile, + .wr_table = &sta32x_write_regs, + .rd_table = &sta32x_read_regs, + .volatile_table = &sta32x_volatile_regs, +}; }; static int sta32x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { + struct device *dev = &i2c->dev; struct sta32x_priv *sta32x; int ret, i; @@ -968,6 +997,8 @@ static int sta32x_i2c_probe(struct i2c_client *i2c, if (!sta32x) return -ENOMEM; + mutex_init(&sta32x->coeff_lock); + sta32x->pdata = dev_get_platdata(dev); /* regulators */ for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) sta32x->supplies[i].supply = sta32x_supply_names[i]; @@ -982,15 +1013,15 @@ static int sta32x_i2c_probe(struct i2c_client *i2c, sta32x->regmap = devm_regmap_init_i2c(i2c, &sta32x_regmap); if (IS_ERR(sta32x->regmap)) { ret = PTR_ERR(sta32x->regmap); - dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); + dev_err(dev, "Failed to init regmap: %d\n", ret); return ret; } i2c_set_clientdata(i2c, sta32x); - ret = snd_soc_register_codec(&i2c->dev, &sta32x_codec, &sta32x_dai, 1); - if (ret != 0) - dev_err(&i2c->dev, "Failed to register codec (%d)\n", ret); + ret = snd_soc_register_codec(dev, &sta32x_codec, &sta32x_dai, 1); + if (ret < 0) + dev_err(dev, "Failed to register codec (%d)\n", ret); return ret; } -- cgit From b66a29808e1fac7fc5c8174e3ec0f014bd418280 Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:01:54 +0100 Subject: ASoC: sta32x: make sta32x a gpio consumer for the reset GPIO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reset GPIO on the STA32X Codecs is used to reset the Codec and clear all registers. Also taking it down puts the IC in power save mode, so we put the device in reset mode when we go to sleep. Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 4517453b33b6..ae9283781bb6 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -151,6 +152,7 @@ struct sta32x_priv { u32 coef_shadow[STA32X_COEF_COUNT]; struct delayed_work watchdog_work; int shutdown; + struct gpio_desc *gpiod_nreset; struct mutex coeff_lock; }; @@ -804,6 +806,16 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, return 0; } + +static int sta32x_startup_sequence(struct sta32x_priv *sta32x) +{ + if (sta32x->gpiod_nreset) { + gpiod_set_value(sta32x->gpiod_nreset, 0); + mdelay(1); + gpiod_set_value(sta32x->gpiod_nreset, 1); + mdelay(1); + } + return 0; } @@ -844,6 +856,7 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec, return ret; } + sta32x_startup_sequence(sta32x); sta32x_cache_sync(codec); sta32x_watchdog_start(sta32x); } @@ -861,6 +874,10 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec, STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, 0); msleep(300); sta32x_watchdog_stop(sta32x); + + if (sta32x->gpiod_nreset) + gpiod_set_value(sta32x->gpiod_nreset, 0); + regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); break; @@ -899,6 +916,11 @@ static int sta32x_probe(struct snd_soc_codec *codec) return ret; } + ret = sta32x_startup_sequence(sta32x); + if (ret < 0) { + dev_err(codec->dev, "Failed to startup device\n"); + return ret; + } /* set thermal warning adjustment and recovery */ if (!pdata->thermal_warning_recovery) thermal |= STA32X_CONFA_TWAB; @@ -999,6 +1021,19 @@ static int sta32x_i2c_probe(struct i2c_client *i2c, mutex_init(&sta32x->coeff_lock); sta32x->pdata = dev_get_platdata(dev); + + /* GPIOs */ + sta32x->gpiod_nreset = devm_gpiod_get(dev, "reset"); + if (IS_ERR(sta32x->gpiod_nreset)) { + ret = PTR_ERR(sta32x->gpiod_nreset); + if (ret != -ENOENT && ret != -ENOSYS) + return ret; + + sta32x->gpiod_nreset = NULL; + } else { + gpiod_direction_output(sta32x->gpiod_nreset, 0); + } + /* regulators */ for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) sta32x->supplies[i].supply = sta32x_supply_names[i]; -- cgit From 88483f59d95f06e43dc9152afc81402df687bd27 Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:01:55 +0100 Subject: ASoC: sta32x: use DECLARE_TLV_DB_RANGE macro. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index ae9283781bb6..b808c65788fa 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -187,37 +187,32 @@ static const char *sta32x_limiter_release_rate[] = { "0.5116", "0.1370", "0.0744", "0.0499", "0.0360", "0.0299", "0.0264", "0.0208", "0.0198", "0.0172", "0.0147", "0.0137", "0.0134", "0.0117", "0.0110", "0.0104" }; - -static const unsigned int sta32x_limiter_ac_attack_tlv[] = { - TLV_DB_RANGE_HEAD(2), +static DECLARE_TLV_DB_RANGE(sta32x_limiter_ac_attack_tlv, 0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0), 8, 16, TLV_DB_SCALE_ITEM(300, 100, 0), -}; +); -static const unsigned int sta32x_limiter_ac_release_tlv[] = { - TLV_DB_RANGE_HEAD(5), +static DECLARE_TLV_DB_RANGE(sta32x_limiter_ac_release_tlv, 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0), 1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0), 2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0), 3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0), 8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0), -}; +); -static const unsigned int sta32x_limiter_drc_attack_tlv[] = { - TLV_DB_RANGE_HEAD(3), +static DECLARE_TLV_DB_RANGE(sta32x_limiter_drc_attack_tlv, 0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0), 8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0), 14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0), -}; +); -static const unsigned int sta32x_limiter_drc_release_tlv[] = { - TLV_DB_RANGE_HEAD(5), +static DECLARE_TLV_DB_RANGE(sta32x_limiter_drc_release_tlv, 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0), 1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0), 3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0), 5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0), 13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0), -}; +); static SOC_ENUM_SINGLE_DECL(sta32x_drc_ac_enum, STA32X_CONFD, STA32X_CONFD_DRC_SHIFT, -- cgit From 1c34c876c4abb219381dcb7096206f1a609f119b Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:01:57 +0100 Subject: ASoC: sta32x: move code to calculate mclk divider and extrapolation ratio to sta32x_hw_params() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.c | 87 +++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 55 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index b808c65788fa..ec2372498c92 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -554,17 +554,12 @@ static struct { }; /* MCLK to fs clock ratios */ -static struct { - int ratio; - int mcs; -} mclk_ratios[3][7] = { - { { 768, 0 }, { 512, 1 }, { 384, 2 }, { 256, 3 }, - { 128, 4 }, { 576, 5 }, { 0, 0 } }, - { { 384, 2 }, { 256, 3 }, { 192, 4 }, { 128, 5 }, {64, 0 }, { 0, 0 } }, - { { 384, 2 }, { 256, 3 }, { 192, 4 }, { 128, 5 }, {64, 0 }, { 0, 0 } }, +static int mcs_ratio_table[3][7] = { + { 768, 512, 384, 256, 128, 576, 0 }, + { 384, 256, 192, 128, 64, 0 }, + { 384, 256, 192, 128, 64, 0 }, }; - /** * sta32x_set_dai_sysclk - configure MCLK * @codec_dai: the codec DAI @@ -589,46 +584,10 @@ static int sta32x_set_dai_sysclk(struct snd_soc_dai *codec_dai, { struct snd_soc_codec *codec = codec_dai->codec; struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); - int i, j, ir, fs; - unsigned int rates = 0; - unsigned int rate_min = -1; - unsigned int rate_max = 0; - pr_debug("mclk=%u\n", freq); + dev_dbg(codec->dev, "mclk=%u\n", freq); sta32x->mclk = freq; - if (sta32x->mclk) { - for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { - ir = interpolation_ratios[i].ir; - fs = interpolation_ratios[i].fs; - for (j = 0; mclk_ratios[ir][j].ratio; j++) { - if (mclk_ratios[ir][j].ratio * fs == freq) { - rates |= snd_pcm_rate_to_rate_bit(fs); - if (fs < rate_min) - rate_min = fs; - if (fs > rate_max) - rate_max = fs; - break; - } - } - } - /* FIXME: soc should support a rate list */ - rates &= ~SNDRV_PCM_RATE_KNOT; - - if (!rates) { - dev_err(codec->dev, "could not find a valid sample rate\n"); - return -EINVAL; - } - } else { - /* enable all possible rates */ - rates = STA32X_RATES; - rate_min = 32000; - rate_max = 192000; - } - - codec_dai->driver->playback.rates = rates; - codec_dai->driver->playback.rate_min = rate_min; - codec_dai->driver->playback.rate_max = rate_max; return 0; } @@ -694,26 +653,44 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_codec *codec = dai->codec; struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); - unsigned int rate; - int i, mcs = -1, ir = -1; + int i, mcs = -EINVAL, ir = -EINVAL; unsigned int confa, confb; + unsigned int rate, ratio; + int ret; + + if (!sta32x->mclk) { + dev_err(codec->dev, + "sta32x->mclk is unset. Unable to determine ratio\n"); + return -EIO; + } rate = params_rate(params); - pr_debug("rate: %u\n", rate); - for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) + ratio = sta32x->mclk / rate; + dev_dbg(codec->dev, "rate: %u, ratio: %u\n", rate, ratio); + + for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { if (interpolation_ratios[i].fs == rate) { ir = interpolation_ratios[i].ir; break; } - if (ir < 0) + } + + if (ir < 0) { + dev_err(codec->dev, "Unsupported samplerate: %u\n", rate); return -EINVAL; - for (i = 0; mclk_ratios[ir][i].ratio; i++) - if (mclk_ratios[ir][i].ratio * rate == sta32x->mclk) { - mcs = mclk_ratios[ir][i].mcs; + } + + for (i = 0; i < 6; i++) { + if (mcs_ratio_table[ir][i] == ratio) { + mcs = i; break; } - if (mcs < 0) + } + + if (mcs < 0) { + dev_err(codec->dev, "Unresolvable ratio: %u\n", ratio); return -EINVAL; + } confa = (ir << STA32X_CONFA_IR_SHIFT) | (mcs << STA32X_CONFA_MCS_SHIFT); -- cgit From f04b1e760a51120f358826d815d12c3f8ecdf1b4 Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:01:58 +0100 Subject: ASoC: sta32x: add device tree binding. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make the sta32x driver usable with device tree configs. Code is heavily based on the sta350 driver. Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.c | 108 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index ec2372498c92..669b67f8cee3 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -893,15 +895,49 @@ static int sta32x_probe(struct snd_soc_codec *codec) dev_err(codec->dev, "Failed to startup device\n"); return ret; } - /* set thermal warning adjustment and recovery */ + + /* CONFA */ if (!pdata->thermal_warning_recovery) thermal |= STA32X_CONFA_TWAB; if (!pdata->thermal_warning_adjustment) thermal |= STA32X_CONFA_TWRB; + if (!pdata->fault_detect_recovery) + thermal |= STA32X_CONFA_FDRB; regmap_update_bits(sta32x->regmap, STA32X_CONFA, - STA32X_CONFA_TWAB | STA32X_CONFA_TWRB, + STA32X_CONFA_TWAB | STA32X_CONFA_TWRB | + STA32X_CONFA_FDRB, thermal); + /* CONFC */ + regmap_update_bits(sta32x->regmap, STA32X_CONFC, + STA32X_CONFC_CSZ_MASK, + pdata->drop_compensation_ns + << STA32X_CONFC_CSZ_SHIFT); + + /* CONFE */ + regmap_update_bits(sta32x->regmap, STA32X_CONFE, + STA32X_CONFE_MPCV, + pdata->max_power_use_mpcc ? + STA32X_CONFE_MPCV : 0); + regmap_update_bits(sta32x->regmap, STA32X_CONFE, + STA32X_CONFE_MPC, + pdata->max_power_correction ? + STA32X_CONFE_MPC : 0); + regmap_update_bits(sta32x->regmap, STA32X_CONFE, + STA32X_CONFE_AME, + pdata->am_reduction_mode ? + STA32X_CONFE_AME : 0); + regmap_update_bits(sta32x->regmap, STA32X_CONFE, + STA32X_CONFE_PWMS, + pdata->odd_pwm_speed_mode ? + STA32X_CONFE_PWMS : 0); + + /* CONFF */ + regmap_update_bits(sta32x->regmap, STA32X_CONFF, + STA32X_CONFF_IDE, + pdata->invalid_input_detect_mute ? + STA32X_CONFF_IDE : 0); + /* select output configuration */ regmap_update_bits(sta32x->regmap, STA32X_CONFF, STA32X_CONFF_OCFG_MASK, @@ -977,7 +1013,66 @@ static const struct regmap_config sta32x_regmap = { .rd_table = &sta32x_read_regs, .volatile_table = &sta32x_volatile_regs, }; + +#ifdef CONFIG_OF +static const struct of_device_id st32x_dt_ids[] = { + { .compatible = "st,sta32x", }, + { } }; +MODULE_DEVICE_TABLE(of, st32x_dt_ids); + +static int sta32x_probe_dt(struct device *dev, struct sta32x_priv *sta32x) +{ + struct device_node *np = dev->of_node; + struct sta32x_platform_data *pdata; + u16 tmp; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + of_property_read_u8(np, "st,output-conf", + &pdata->output_conf); + of_property_read_u8(np, "st,ch1-output-mapping", + &pdata->ch1_output_mapping); + of_property_read_u8(np, "st,ch2-output-mapping", + &pdata->ch2_output_mapping); + of_property_read_u8(np, "st,ch3-output-mapping", + &pdata->ch3_output_mapping); + + if (of_get_property(np, "st,thermal-warning-recovery", NULL)) + pdata->thermal_warning_recovery = 1; + if (of_get_property(np, "st,thermal-warning-adjustment", NULL)) + pdata->thermal_warning_adjustment = 1; + if (of_get_property(np, "st,needs_esd_watchdog", NULL)) + pdata->needs_esd_watchdog = 1; + + tmp = 140; + of_property_read_u16(np, "st,drop-compensation-ns", &tmp); + pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20; + + /* CONFE */ + if (of_get_property(np, "st,max-power-use-mpcc", NULL)) + pdata->max_power_use_mpcc = 1; + + if (of_get_property(np, "st,max-power-correction", NULL)) + pdata->max_power_correction = 1; + + if (of_get_property(np, "st,am-reduction-mode", NULL)) + pdata->am_reduction_mode = 1; + + if (of_get_property(np, "st,odd-pwm-speed-mode", NULL)) + pdata->odd_pwm_speed_mode = 1; + + /* CONFF */ + if (of_get_property(np, "st,invalid-input-detect-mute", NULL)) + pdata->invalid_input_detect_mute = 1; + + sta32x->pdata = pdata; + + return 0; +} +#endif static int sta32x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) @@ -994,6 +1089,14 @@ static int sta32x_i2c_probe(struct i2c_client *i2c, mutex_init(&sta32x->coeff_lock); sta32x->pdata = dev_get_platdata(dev); +#ifdef CONFIG_OF + if (dev->of_node) { + ret = sta32x_probe_dt(dev, sta32x); + if (ret < 0) + return ret; + } +#endif + /* GPIOs */ sta32x->gpiod_nreset = devm_gpiod_get(dev, "reset"); if (IS_ERR(sta32x->gpiod_nreset)) { @@ -1051,6 +1154,7 @@ static struct i2c_driver sta32x_i2c_driver = { .driver = { .name = "sta32x", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(st32x_dt_ids), }, .probe = sta32x_i2c_probe, .remove = sta32x_i2c_remove, -- cgit From 30374d5dd3028cdc522ec7cc6593cb877deb0435 Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:01:59 +0100 Subject: ASoC: sta32x: use dev_dbg() for debug output. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 669b67f8cee3..e696efc6ec25 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -700,10 +700,10 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 24: - pr_debug("24bit\n"); + dev_dbg(codec->dev, "24bit\n"); /* fall through */ case 32: - pr_debug("24bit or 32bit\n"); + dev_dbg(codec->dev, "24bit or 32bit\n"); switch (sta32x->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x0; @@ -718,7 +718,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, break; case 20: - pr_debug("20bit\n"); + dev_dbg(codec->dev, "20bit\n"); switch (sta32x->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x4; @@ -733,7 +733,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, break; case 18: - pr_debug("18bit\n"); + dev_dbg(codec->dev, "18bit\n"); switch (sta32x->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x8; @@ -748,7 +748,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, break; case 16: - pr_debug("16bit\n"); + dev_dbg(codec->dev, "16bit\n"); switch (sta32x->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x0; @@ -808,7 +808,7 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec, int ret; struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); - pr_debug("level = %d\n", level); + dev_dbg(codec->dev, "level = %d\n", level); switch (level) { case SND_SOC_BIAS_ON: break; -- cgit From 6fad62599982319a2631daa99906c6b45cacdaff Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:02:00 +0100 Subject: ASoC: sta32x: minor Kconfig update. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add description for the driver - Add dependency on the I2C module Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 27e1e3b59649..c63ee0e37188 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -580,7 +580,8 @@ config SND_SOC_SSM4567 depends on I2C config SND_SOC_STA32X - tristate + tristate "STA326, STA328 and STA329 speaker amplifier" + depends on I2C select REGMAP_I2C config SND_SOC_STA350 -- cgit From 3c9390ad0fa642f42e437feae1c75bdd21e8e1bc Mon Sep 17 00:00:00 2001 From: Thomas Niederprüm Date: Thu, 22 Jan 2015 00:02:02 +0100 Subject: ASoC: sta32x: change dai name to be in line with the sta350 driver. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Niederprüm Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index e696efc6ec25..3a1343fa109b 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -867,7 +867,7 @@ static const struct snd_soc_dai_ops sta32x_dai_ops = { }; static struct snd_soc_dai_driver sta32x_dai = { - .name = "STA32X", + .name = "sta32x-hifi", .playback = { .stream_name = "Playback", .channels_min = 2, -- cgit From 054e1b4892271731453fbfa8658899050196e427 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 20 Jan 2015 16:31:50 +0000 Subject: ASoC: arizona: Add delay for output disable Give the output disable sequence a chance to fully complete, otherwise there is a danger we may remove the clock before it is finished resulting in a pop noise. The delay for each output must be cumulative and these are coalesced into a single delay. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/arizona.c | 37 +++++++++++++++++++++++++++++++++++++ sound/soc/codecs/arizona.h | 3 +++ sound/soc/codecs/wm5102.c | 15 ++++++++++----- sound/soc/codecs/wm5110.c | 18 ++++++++++++------ sound/soc/codecs/wm8997.c | 9 ++++++--- 5 files changed, 68 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 9550d7433ad0..9e203eff6860 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -734,6 +734,8 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); + switch (event) { case SND_SOC_DAPM_POST_PMU: switch (w->shift) { @@ -750,6 +752,39 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, break; } break; + case SND_SOC_DAPM_PRE_PMD: + switch (w->shift) { + case ARIZONA_OUT1L_ENA_SHIFT: + case ARIZONA_OUT1R_ENA_SHIFT: + case ARIZONA_OUT2L_ENA_SHIFT: + case ARIZONA_OUT2R_ENA_SHIFT: + case ARIZONA_OUT3L_ENA_SHIFT: + case ARIZONA_OUT3R_ENA_SHIFT: + priv->out_down_pending++; + priv->out_down_delay++; + break; + default: + break; + } + break; + case SND_SOC_DAPM_POST_PMD: + switch (w->shift) { + case ARIZONA_OUT1L_ENA_SHIFT: + case ARIZONA_OUT1R_ENA_SHIFT: + case ARIZONA_OUT2L_ENA_SHIFT: + case ARIZONA_OUT2R_ENA_SHIFT: + case ARIZONA_OUT3L_ENA_SHIFT: + case ARIZONA_OUT3R_ENA_SHIFT: + priv->out_down_pending--; + if (!priv->out_down_pending) { + msleep(priv->out_down_delay); + priv->out_down_delay = 0; + } + break; + default: + break; + } + break; } return 0; @@ -772,6 +807,8 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: val = 0; break; + case SND_SOC_DAPM_POST_PMD: + return arizona_out_ev(w, kcontrol, event); default: return -EINVAL; } diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 942cfb197b6d..59b0f50b80b4 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h @@ -77,6 +77,9 @@ struct arizona_priv { int num_inputs; unsigned int in_pending; + unsigned int out_down_pending; + unsigned int out_down_delay; + unsigned int spk_ena:2; unsigned int spk_ena_pending:1; }; diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 7dbac8a98f6d..5e0f72cb3181 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -1272,19 +1272,24 @@ SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 4456b38a3ef5..009a9ba95bdf 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -905,22 +905,28 @@ SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT3R", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT3R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 7e8bfe27566b..a1d4ac717d08 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -610,13 +610,16 @@ SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), -- cgit From e1ae5fba3fae34537492758a21eef90a182620de Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 20 Jan 2015 16:31:51 +0000 Subject: ASoC: arizona: Coalesce output power up delays Save a bit of scheduling by coalescing all the output power up delays into a single delay. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/arizona.c | 22 +++++++++++++++++++++- sound/soc/codecs/arizona.h | 2 ++ sound/soc/codecs/wm5102.c | 10 +++++----- sound/soc/codecs/wm5110.c | 12 ++++++------ sound/soc/codecs/wm8997.c | 6 +++--- 5 files changed, 37 insertions(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 9e203eff6860..32bc609f23e4 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -737,6 +737,21 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); switch (event) { + case SND_SOC_DAPM_PRE_PMU: + switch (w->shift) { + case ARIZONA_OUT1L_ENA_SHIFT: + case ARIZONA_OUT1R_ENA_SHIFT: + case ARIZONA_OUT2L_ENA_SHIFT: + case ARIZONA_OUT2R_ENA_SHIFT: + case ARIZONA_OUT3L_ENA_SHIFT: + case ARIZONA_OUT3R_ENA_SHIFT: + priv->out_up_pending++; + priv->out_up_delay += 17; + break; + default: + break; + } + break; case SND_SOC_DAPM_POST_PMU: switch (w->shift) { case ARIZONA_OUT1L_ENA_SHIFT: @@ -745,7 +760,11 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, case ARIZONA_OUT2R_ENA_SHIFT: case ARIZONA_OUT3L_ENA_SHIFT: case ARIZONA_OUT3R_ENA_SHIFT: - msleep(17); + priv->out_up_pending--; + if (!priv->out_up_pending) { + msleep(priv->out_up_delay); + priv->out_up_delay = 0; + } break; default: @@ -807,6 +826,7 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: val = 0; break; + case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_POST_PMD: return arizona_out_ev(w, kcontrol, event); default: diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 59b0f50b80b4..11ff899b0272 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h @@ -77,6 +77,8 @@ struct arizona_priv { int num_inputs; unsigned int in_pending; + unsigned int out_up_pending; + unsigned int out_up_delay; unsigned int out_down_pending; unsigned int out_down_delay; diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 5e0f72cb3181..154d67d7f249 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -1273,23 +1273,23 @@ SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 009a9ba95bdf..33eefec54be4 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -906,27 +906,27 @@ SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT3R", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT3R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index a1d4ac717d08..911132943b50 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -611,15 +611,15 @@ SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), -- cgit From 67d1aed0a5de49dfbc81315610a4fd49c864ec45 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Tue, 20 Jan 2015 15:43:17 +0800 Subject: ASoC: atmel_ssc_dai: remove clock pin comments As the clock can be get from TK/RK pin, so remove the comments. Signed-off-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/atmel/atmel_ssc_dai.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index e691aab60761..3cd70597d109 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -450,13 +450,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, break; case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM: - /* - * I2S format, CODEC supplies BCLK and LRC clocks. - * - * The SSC transmit clock is obtained from the BCLK signal on - * on the TK line, and the SSC receive clock is - * generated from the transmit clock. - */ + /* I2S format, CODEC supplies BCLK and LRC clocks. */ rcmr = SSC_BF(RCMR_PERIOD, 0) | SSC_BF(RCMR_STTDLY, START_DELAY) | SSC_BF(RCMR_START, SSC_START_FALLING_RF) @@ -535,10 +529,6 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, /* * DSP/PCM Mode A format, CODEC supplies BCLK and LRC clocks. * - * The SSC transmit clock is obtained from the BCLK signal on - * on the TK line, and the SSC receive clock is - * generated from the transmit clock. - * * Data is transferred on first BCLK after LRC pulse rising * edge.If stereo, the right channel data is contiguous with * the left channel data. -- cgit From ddf9ea21f5fa0832c9711ae13dd467d1f5c4cd87 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Thu, 22 Jan 2015 15:47:16 -0800 Subject: ASoC: ts3a227e: Remap keys to match Android headset specification ts3a227e datasheet says typical key resistance is key1 50 Ohm key2 135 Ohm key3 240 Ohm key4 470 Ohm The android headset specification expect buttons impedance: A (MEDIA) 0-70 Ohm D (VOICECOMMAND) 110-180 Ohm B (VOLUMEUP) 210-290 Ohm C (VOLUMEDOWN) 360-680 Ohm Thus key mapping should be key1 - MEDIA key2 - VOICECOMMAND key3 - VOLUMEUP key3 - VOLUMEDOWN Signed-off-by: Anatol Pomozov Acked-by: Dylan Reid Signed-off-by: Mark Brown --- sound/soc/codecs/ts3a227e.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index 1d1205702d23..b55034f63de5 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -221,9 +221,9 @@ int ts3a227e_enable_jack_detect(struct snd_soc_component *component, struct ts3a227e *ts3a227e = snd_soc_component_get_drvdata(component); snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA); - 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); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); ts3a227e->jack = jack; ts3a227e_jack_report(ts3a227e); -- cgit From 39552d7ad1409d07ef278a97adbfbee02a272d25 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Thu, 22 Jan 2015 15:47:24 -0800 Subject: ASoC: ts3a227e: Add dts property that allows to specify micbias voltage The voltage controls key press threshold. Signed-off-by: Anatol Pomozov Signed-off-by: Mark Brown --- sound/soc/codecs/ts3a227e.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index b55034f63de5..65f8ec2094fb 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -79,6 +79,10 @@ static const int ts3a227e_buttons[] = { /* TS3A227E_REG_SETTING_2 0x05 */ #define KP_ENABLE 0x04 +/* TS3A227E_REG_SETTING_3 0x06 */ +#define MICBIAS_SETTING_SFT (3) +#define MICBIAS_SETTING_MASK (0x7 << MICBIAS_SETTING_SFT) + /* TS3A227E_REG_ACCESSORY_STATUS 0x0b */ #define TYPE_3_POLE 0x01 #define TYPE_4_POLE_OMTP 0x02 @@ -248,6 +252,21 @@ static const struct regmap_config ts3a227e_regmap_config = { .num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults), }; +static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np) +{ + u32 micbias; + int err; + + err = of_property_read_u32(np, "ti,micbias", &micbias); + if (!err) { + regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3, + MICBIAS_SETTING_MASK, + (micbias & 0x07) << MICBIAS_SETTING_SFT); + } + + return 0; +} + static int ts3a227e_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -265,6 +284,14 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c, if (IS_ERR(ts3a227e->regmap)) return PTR_ERR(ts3a227e->regmap); + if (dev->of_node) { + ret = ts3a227e_parse_dt(ts3a227e, dev->of_node); + if (ret) { + dev_err(dev, "Failed to parse device tree: %d\n", ret); + return ret; + } + } + ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT, "TS3A227E", ts3a227e); -- cgit From 5c4ca99df718f6569849ab5fabdf18c14755b144 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 21 Jan 2015 20:50:15 +0800 Subject: ASoC: rt5645: Add rt5650 codec support This patch adds support for rt5650 codec. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5645.c | 158 +++++++++++++++++++++++++++++++++++++++++----- sound/soc/codecs/rt5645.h | 15 +++++ 2 files changed, 156 insertions(+), 17 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 27141e2df878..21b2d72b4ea8 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -31,6 +31,7 @@ #include "rt5645.h" #define RT5645_DEVICE_ID 0x6308 +#define RT5650_DEVICE_ID 0x6419 #define RT5645_PR_RANGE_BASE (0xff + 1) #define RT5645_PR_SPACING 0x100 @@ -59,6 +60,10 @@ static const struct reg_default init_list[] = { }; #define RT5645_INIT_REG_LEN ARRAY_SIZE(init_list) +static const struct reg_default rt5650_init_list[] = { + {0xf6, 0x0100}, +}; + static const struct reg_default rt5645_reg[] = { { 0x00, 0x0000 }, { 0x01, 0xc8c8 }, @@ -86,6 +91,7 @@ static const struct reg_default rt5645_reg[] = { { 0x2a, 0x5656 }, { 0x2b, 0x5454 }, { 0x2c, 0xaaa0 }, + { 0x2d, 0x0000 }, { 0x2f, 0x1002 }, { 0x31, 0x5000 }, { 0x32, 0x0000 }, @@ -193,6 +199,8 @@ static const struct reg_default rt5645_reg[] = { { 0xdb, 0x0003 }, { 0xdc, 0x0049 }, { 0xdd, 0x001b }, + { 0xdf, 0x0008 }, + { 0xe0, 0x4000 }, { 0xe6, 0x8000 }, { 0xe7, 0x0200 }, { 0xec, 0xb300 }, @@ -242,6 +250,7 @@ static bool rt5645_volatile_register(struct device *dev, unsigned int reg) case RT5645_IRQ_CTRL3: case RT5645_INT_IRQ_ST: case RT5645_IL_CMD: + case RT5650_4BTN_IL_CMD1: case RT5645_VENDOR_ID: case RT5645_VENDOR_ID1: case RT5645_VENDOR_ID2: @@ -287,6 +296,7 @@ static bool rt5645_readable_register(struct device *dev, unsigned int reg) case RT5645_STO_DAC_MIXER: case RT5645_MONO_DAC_MIXER: case RT5645_DIG_MIXER: + case RT5650_A_DAC_SOUR: case RT5645_DIG_INF1_DATA: case RT5645_PDM_OUT_CTRL: case RT5645_REC_L1_MIXER: @@ -378,6 +388,8 @@ static bool rt5645_readable_register(struct device *dev, unsigned int reg) case RT5645_IL_CMD: case RT5645_IL_CMD2: case RT5645_IL_CMD3: + case RT5650_4BTN_IL_CMD1: + case RT5650_4BTN_IL_CMD2: case RT5645_DRC1_HL_CTRL1: case RT5645_DRC2_HL_CTRL1: case RT5645_ADC_MONO_HP_CTRL1: @@ -1007,6 +1019,44 @@ static SOC_ENUM_SINGLE_DECL( static const struct snd_kcontrol_new rt5645_if1_adc_in_mux = SOC_DAPM_ENUM("IF1 ADC IN source", rt5645_if1_adc_in_enum); +/* MX-2d [3] [2] */ +static const char * const rt5650_a_dac1_src[] = { + "DAC1", "Stereo DAC Mixer" +}; + +static SOC_ENUM_SINGLE_DECL( + rt5650_a_dac1_l_enum, RT5650_A_DAC_SOUR, + RT5650_A_DAC1_L_IN_SFT, rt5650_a_dac1_src); + +static const struct snd_kcontrol_new rt5650_a_dac1_l_mux = + SOC_DAPM_ENUM("A DAC1 L source", rt5650_a_dac1_l_enum); + +static SOC_ENUM_SINGLE_DECL( + rt5650_a_dac1_r_enum, RT5650_A_DAC_SOUR, + RT5650_A_DAC1_R_IN_SFT, rt5650_a_dac1_src); + +static const struct snd_kcontrol_new rt5650_a_dac1_r_mux = + SOC_DAPM_ENUM("A DAC1 R source", rt5650_a_dac1_r_enum); + +/* MX-2d [1] [0] */ +static const char * const rt5650_a_dac2_src[] = { + "Stereo DAC Mixer", "Mono DAC Mixer" +}; + +static SOC_ENUM_SINGLE_DECL( + rt5650_a_dac2_l_enum, RT5650_A_DAC_SOUR, + RT5650_A_DAC2_L_IN_SFT, rt5650_a_dac2_src); + +static const struct snd_kcontrol_new rt5650_a_dac2_l_mux = + SOC_DAPM_ENUM("A DAC2 L source", rt5650_a_dac2_l_enum); + +static SOC_ENUM_SINGLE_DECL( + rt5650_a_dac2_r_enum, RT5650_A_DAC_SOUR, + RT5650_A_DAC2_R_IN_SFT, rt5650_a_dac2_src); + +static const struct snd_kcontrol_new rt5650_a_dac2_r_mux = + SOC_DAPM_ENUM("A DAC2 R source", rt5650_a_dac2_r_enum); + /* MX-2F [13:12] */ static const char * const rt5645_if2_adc_in_src[] = { "IF_ADC1", "IF_ADC2", "VAD_ADC" @@ -1151,11 +1201,16 @@ static int rt5645_hp_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMU: hp_amp_power(codec, 1); /* headphone unmute sequence */ - snd_soc_update_bits(codec, RT5645_DEPOP_M3, RT5645_CP_FQ1_MASK | - RT5645_CP_FQ2_MASK | RT5645_CP_FQ3_MASK, - (RT5645_CP_FQ_192_KHZ << RT5645_CP_FQ1_SFT) | - (RT5645_CP_FQ_12_KHZ << RT5645_CP_FQ2_SFT) | - (RT5645_CP_FQ_192_KHZ << RT5645_CP_FQ3_SFT)); + if (rt5645->codec_type == CODEC_TYPE_RT5650) { + snd_soc_write(codec, RT5645_DEPOP_M3, 0x0737); + } else { + snd_soc_update_bits(codec, RT5645_DEPOP_M3, + RT5645_CP_FQ1_MASK | RT5645_CP_FQ2_MASK | + RT5645_CP_FQ3_MASK, + (RT5645_CP_FQ_192_KHZ << RT5645_CP_FQ1_SFT) | + (RT5645_CP_FQ_12_KHZ << RT5645_CP_FQ2_SFT) | + (RT5645_CP_FQ_192_KHZ << RT5645_CP_FQ3_SFT)); + } regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_MAMP_INT_REG2, 0xfc00); snd_soc_update_bits(codec, RT5645_DEPOP_M1, @@ -1175,12 +1230,16 @@ static int rt5645_hp_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: /* headphone mute sequence */ - snd_soc_update_bits(codec, RT5645_DEPOP_M3, - RT5645_CP_FQ1_MASK | RT5645_CP_FQ2_MASK | - RT5645_CP_FQ3_MASK, - (RT5645_CP_FQ_96_KHZ << RT5645_CP_FQ1_SFT) | - (RT5645_CP_FQ_12_KHZ << RT5645_CP_FQ2_SFT) | - (RT5645_CP_FQ_96_KHZ << RT5645_CP_FQ3_SFT)); + if (rt5645->codec_type == CODEC_TYPE_RT5650) { + snd_soc_write(codec, RT5645_DEPOP_M3, 0x0737); + } else { + snd_soc_update_bits(codec, RT5645_DEPOP_M3, + RT5645_CP_FQ1_MASK | RT5645_CP_FQ2_MASK | + RT5645_CP_FQ3_MASK, + (RT5645_CP_FQ_96_KHZ << RT5645_CP_FQ1_SFT) | + (RT5645_CP_FQ_12_KHZ << RT5645_CP_FQ2_SFT) | + (RT5645_CP_FQ_96_KHZ << RT5645_CP_FQ3_SFT)); + } regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_MAMP_INT_REG2, 0xfc00); snd_soc_update_bits(codec, RT5645_DEPOP_M1, @@ -1574,6 +1633,17 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = { SND_SOC_DAPM_OUTPUT("SPOR"), }; +static const struct snd_soc_dapm_widget rt5650_specific_dapm_widgets[] = { + SND_SOC_DAPM_MUX("A DAC1 L Mux", SND_SOC_NOPM, + 0, 0, &rt5650_a_dac1_l_mux), + SND_SOC_DAPM_MUX("A DAC1 R Mux", SND_SOC_NOPM, + 0, 0, &rt5650_a_dac1_r_mux), + SND_SOC_DAPM_MUX("A DAC2 L Mux", SND_SOC_NOPM, + 0, 0, &rt5650_a_dac2_l_mux), + SND_SOC_DAPM_MUX("A DAC2 R Mux", SND_SOC_NOPM, + 0, 0, &rt5650_a_dac2_r_mux), +}; + static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc }, { "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc }, @@ -1779,13 +1849,9 @@ static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { { "DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" }, { "DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" }, - { "DAC L1", NULL, "Stereo DAC MIXL" }, { "DAC L1", NULL, "PLL1", is_sys_clk_from_pll }, - { "DAC R1", NULL, "Stereo DAC MIXR" }, { "DAC R1", NULL, "PLL1", is_sys_clk_from_pll }, - { "DAC L2", NULL, "Mono DAC MIXL" }, { "DAC L2", NULL, "PLL1", is_sys_clk_from_pll }, - { "DAC R2", NULL, "Mono DAC MIXR" }, { "DAC R2", NULL, "PLL1", is_sys_clk_from_pll }, { "SPK MIXL", "BST1 Switch", "BST1" }, @@ -1874,6 +1940,30 @@ static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { { "SPOR", NULL, "SPK amp" }, }; +static const struct snd_soc_dapm_route rt5650_specific_dapm_routes[] = { + { "A DAC1 L Mux", "DAC1", "DAC1 MIXL"}, + { "A DAC1 L Mux", "Stereo DAC Mixer", "Stereo DAC MIXL"}, + { "A DAC1 R Mux", "DAC1", "DAC1 MIXR"}, + { "A DAC1 R Mux", "Stereo DAC Mixer", "Stereo DAC MIXR"}, + + { "A DAC2 L Mux", "Stereo DAC Mixer", "Stereo DAC MIXL"}, + { "A DAC2 L Mux", "Mono DAC Mixer", "Mono DAC MIXL"}, + { "A DAC2 R Mux", "Stereo DAC Mixer", "Stereo DAC MIXR"}, + { "A DAC2 R Mux", "Mono DAC Mixer", "Mono DAC MIXR"}, + + { "DAC L1", NULL, "A DAC1 L Mux" }, + { "DAC R1", NULL, "A DAC1 R Mux" }, + { "DAC L2", NULL, "A DAC2 L Mux" }, + { "DAC R2", NULL, "A DAC2 R Mux" }, +}; + +static const struct snd_soc_dapm_route rt5645_specific_dapm_routes[] = { + { "DAC L1", NULL, "Stereo DAC MIXL" }, + { "DAC R1", NULL, "Stereo DAC MIXR" }, + { "DAC L2", NULL, "Mono DAC MIXL" }, + { "DAC R2", NULL, "Mono DAC MIXR" }, +}; + static int rt5645_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { @@ -2293,6 +2383,22 @@ static int rt5645_probe(struct snd_soc_codec *codec) rt5645->codec = codec; + switch (rt5645->codec_type) { + case CODEC_TYPE_RT5645: + snd_soc_dapm_add_routes(&codec->dapm, + rt5645_specific_dapm_routes, + ARRAY_SIZE(rt5645_specific_dapm_routes)); + break; + case CODEC_TYPE_RT5650: + snd_soc_dapm_new_controls(&codec->dapm, + rt5650_specific_dapm_widgets, + ARRAY_SIZE(rt5650_specific_dapm_widgets)); + snd_soc_dapm_add_routes(&codec->dapm, + rt5650_specific_dapm_routes, + ARRAY_SIZE(rt5650_specific_dapm_routes)); + break; + } + rt5645_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_update_bits(codec, RT5645_CHARGE_PUMP, 0x0300, 0x0200); @@ -2424,6 +2530,7 @@ static const struct regmap_config rt5645_regmap = { static const struct i2c_device_id rt5645_i2c_id[] = { { "rt5645", 0 }, + { "rt5650", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, rt5645_i2c_id); @@ -2456,9 +2563,18 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, } regmap_read(rt5645->regmap, RT5645_VENDOR_ID2, &val); - if (val != RT5645_DEVICE_ID) { + + switch (val) { + case RT5645_DEVICE_ID: + rt5645->codec_type = CODEC_TYPE_RT5645; + break; + case RT5650_DEVICE_ID: + rt5645->codec_type = CODEC_TYPE_RT5650; + break; + default: dev_err(&i2c->dev, - "Device with ID register %x is not rt5645\n", val); + "Device with ID register %x is not rt5645 or rt5650\n", + val); return -ENODEV; } @@ -2469,6 +2585,14 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); + if (rt5645->codec_type == CODEC_TYPE_RT5650) { + ret = regmap_register_patch(rt5645->regmap, rt5650_init_list, + ARRAY_SIZE(rt5650_init_list)); + if (ret != 0) + dev_warn(&i2c->dev, "Apply rt5650 patch failed: %d\n", + ret); + } + if (rt5645->pdata.in2_diff) regmap_update_bits(rt5645->regmap, RT5645_IN2_CTRL, RT5645_IN_DF2, RT5645_IN_DF2); diff --git a/sound/soc/codecs/rt5645.h b/sound/soc/codecs/rt5645.h index a815e36a2bdb..74542310d3f0 100644 --- a/sound/soc/codecs/rt5645.h +++ b/sound/soc/codecs/rt5645.h @@ -47,6 +47,7 @@ #define RT5645_STO_DAC_MIXER 0x2a #define RT5645_MONO_DAC_MIXER 0x2b #define RT5645_DIG_MIXER 0x2c +#define RT5650_A_DAC_SOUR 0x2d #define RT5645_DIG_INF1_DATA 0x2f /* Mixer - PDM */ #define RT5645_PDM_OUT_CTRL 0x31 @@ -150,6 +151,8 @@ #define RT5645_IL_CMD 0xdb #define RT5645_IL_CMD2 0xdc #define RT5645_IL_CMD3 0xdd +#define RT5650_4BTN_IL_CMD1 0xdf +#define RT5650_4BTN_IL_CMD2 0xe0 #define RT5645_DRC1_HL_CTRL1 0xe7 #define RT5645_DRC2_HL_CTRL1 0xe9 #define RT5645_MUTI_DRC_CTRL1 0xea @@ -472,6 +475,12 @@ #define RT5645_DAC_L2_DAC_R_VOL_MASK (0x1 << 4) #define RT5645_DAC_L2_DAC_R_VOL_SFT 4 +/* Analog DAC1/2 Input Source Control (0x2d) */ +#define RT5650_A_DAC1_L_IN_SFT 3 +#define RT5650_A_DAC1_R_IN_SFT 2 +#define RT5650_A_DAC2_L_IN_SFT 1 +#define RT5650_A_DAC2_R_IN_SFT 0 + /* Digital Interface Data Control (0x2f) */ #define RT5645_IF1_ADC2_IN_SEL (0x1 << 15) #define RT5645_IF1_ADC2_IN_SFT 15 @@ -2175,6 +2184,11 @@ enum { RT5645_DMIC_DATA_GPIO11, }; +enum { + CODEC_TYPE_RT5645, + CODEC_TYPE_RT5650, +}; + struct rt5645_priv { struct snd_soc_codec *codec; struct rt5645_platform_data pdata; @@ -2184,6 +2198,7 @@ struct rt5645_priv { struct snd_soc_jack *mic_jack; struct delayed_work jack_detect_work; + int codec_type; int sysclk; int sysclk_src; int lrck[RT5645_AIFS]; -- cgit From 270fd9c7f91fe8be900ede740ceeaa4abefa5d98 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 20 Jan 2015 08:40:51 +0100 Subject: ALSA: line6: Yet more cleanup of superfluous NULL checks ... in line6_disconnect() as well. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 93cd4daa56bc..e8d51381ffdb 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -579,18 +579,9 @@ EXPORT_SYMBOL_GPL(line6_probe); */ void line6_disconnect(struct usb_interface *interface) { - struct usb_line6 *line6; - struct usb_device *usbdev; - int interface_number; - - if (interface == NULL) - return; - usbdev = interface_to_usbdev(interface); - if (usbdev == NULL) - return; + struct usb_line6 *line6 = usb_get_intfdata(interface); + struct usb_device *usbdev = interface_to_usbdev(interface); - interface_number = interface->cur_altsetting->desc.bInterfaceNumber; - line6 = usb_get_intfdata(interface); if (!line6) return; -- cgit From 2a324fcdb568f4d7b0b65b271039beb987f6e1cd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 20 Jan 2015 09:58:54 +0100 Subject: ALSA: line6: Abort if inconsistent usbdev is found at disconnect It's utterly unsafe to proceed further the disconnect procedure if the assigned usbdev is inconsistent with the expected object. Better to put a WARN_ON() for more cautions and abort immediately. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index e8d51381ffdb..625272fe227a 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -585,12 +585,12 @@ void line6_disconnect(struct usb_interface *interface) if (!line6) return; + if (WARN_ON(usbdev != line6->usbdev)) + return; + if (line6->urb_listen != NULL) line6_stop_listen(line6); - if (usbdev != line6->usbdev) - dev_err(line6->ifcdev, "driver bug: inconsistent usb device\n"); - snd_card_disconnect(line6->card); if (line6->line6pcm) line6_pcm_disconnect(line6->line6pcm); -- cgit From 8a3b7c086a509d90c312ebab6d8e5a9bf48c6cf5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 20 Jan 2015 08:42:42 +0100 Subject: ALSA: line6: Remove superfluous NULL checks in each driver The interface and driver objects are always set when callbacks are called. Drop such superfluous NULL checks in init and disconnect calls of each driver. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pod.c | 28 ++++++++-------------------- sound/usb/line6/podhd.c | 4 ---- sound/usb/line6/toneport.c | 6 ------ sound/usb/line6/variax.c | 8 -------- 4 files changed, 8 insertions(+), 38 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index bf027fc70cba..26ecf26a33ec 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -401,25 +401,16 @@ static struct snd_kcontrol_new pod_control_monitor = { */ static void line6_pod_disconnect(struct usb_interface *interface) { - struct usb_line6_pod *pod; - - if (interface == NULL) - return; - pod = usb_get_intfdata(interface); - - if (pod != NULL) { - struct device *dev = &interface->dev; + struct usb_line6_pod *pod = usb_get_intfdata(interface); + struct device *dev = &interface->dev; - if (dev != NULL) { - /* remove sysfs entries: */ - device_remove_file(dev, &dev_attr_device_id); - device_remove_file(dev, &dev_attr_firmware_version); - device_remove_file(dev, &dev_attr_serial_number); - } + /* remove sysfs entries: */ + device_remove_file(dev, &dev_attr_device_id); + device_remove_file(dev, &dev_attr_firmware_version); + device_remove_file(dev, &dev_attr_serial_number); - del_timer_sync(&pod->startup_timer); - cancel_work_sync(&pod->startup_work); - } + del_timer_sync(&pod->startup_timer); + cancel_work_sync(&pod->startup_work); } /* @@ -456,9 +447,6 @@ static int pod_init(struct usb_interface *interface, init_timer(&pod->startup_timer); INIT_WORK(&pod->startup_work, pod_startup4); - if ((interface == NULL) || (pod == NULL)) - return -ENODEV; - /* create sysfs entries: */ err = pod_create_files2(&interface->dev); if (err < 0) diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 7217fa7e5db1..59abbd92624e 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -90,12 +90,8 @@ static struct line6_pcm_properties podhd_pcm_properties = { static int podhd_init(struct usb_interface *interface, struct usb_line6 *line6) { - struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; int err; - if ((interface == NULL) || (podhd == NULL)) - return -ENODEV; - /* initialize MIDI subsystem: */ err = line6_init_midi(line6); if (err < 0) diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index c1f61cde52ab..e5669bd3233a 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -370,9 +370,6 @@ static void line6_toneport_disconnect(struct usb_interface *interface) struct usb_line6_toneport *toneport; u16 idProduct; - if (interface == NULL) - return; - toneport = usb_get_intfdata(interface); del_timer_sync(&toneport->timer); idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct); @@ -393,9 +390,6 @@ static int toneport_init(struct usb_interface *interface, int err; struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; - if ((interface == NULL) || (toneport == NULL)) - return -ENODEV; - line6->disconnect = line6_toneport_disconnect; /* initialize PCM subsystem: */ diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index 99a58cbfd2da..cd3adeffde02 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -214,12 +214,7 @@ static void line6_variax_disconnect(struct usb_interface *interface) { struct usb_line6_variax *variax; - if (!interface) - return; - variax = usb_get_intfdata(interface); - if (!variax) - return; del_timer(&variax->startup_timer1); del_timer(&variax->startup_timer2); @@ -244,9 +239,6 @@ static int variax_init(struct usb_interface *interface, init_timer(&variax->startup_timer2); INIT_WORK(&variax->startup_work, variax_startup6); - if ((interface == NULL) || (variax == NULL)) - return -ENODEV; - /* initialize USB buffers: */ variax->buffer_activate = kmemdup(variax_activate, sizeof(variax_activate), GFP_KERNEL); -- cgit From 6dd1c05cd7c26a463bbcca1ab50b59b86d88de64 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 20 Jan 2015 09:40:20 +0100 Subject: ALSA: line6/toneport: Move setup_timer() at the beginning ... so that timer_del_sync() in the destructor can be called safely at any time. Also move the mod_timer() call in toneport_setup(), which is a bit clearer place. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/toneport.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index e5669bd3233a..fb6d5e1e2ade 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -360,6 +360,8 @@ static void toneport_setup(struct usb_line6_toneport *toneport) if (toneport_has_led(toneport->type)) toneport_update_led(&usbdev->dev); + + mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ); } /* @@ -390,6 +392,9 @@ static int toneport_init(struct usb_interface *interface, int err; struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; + setup_timer(&toneport->timer, toneport_start_pcm, + (unsigned long)toneport); + line6->disconnect = line6_toneport_disconnect; /* initialize PCM subsystem: */ @@ -435,10 +440,6 @@ static int toneport_init(struct usb_interface *interface, toneport_setup(toneport); - setup_timer(&toneport->timer, toneport_start_pcm, - (unsigned long)toneport); - mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ); - /* register audio system: */ return snd_card_register(line6->card); } -- cgit From eedd0e95d355c7bc09df1481ef92511f631832b3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 20 Jan 2015 09:09:27 +0100 Subject: ALSA: line6: Don't forget to call driver's destructor at error path Currently disconnect callback is used as a driver's destructor, and this has to be called not only at the disconnection time but also at the error paths during probe. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 625272fe227a..e7f9a99e1949 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -568,6 +568,8 @@ int line6_probe(struct usb_interface *interface, return 0; err_destruct: + if (line6->disconnect) + line6->disconnect(interface); snd_card_free(card); err_put: return ret; -- cgit From bf115fcf957f080a1766bb785e23980c1440d06e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 20 Jan 2015 08:55:06 +0100 Subject: ALSA: line6/toneport: Fix wrong argument for toneport_has_led() Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/toneport.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index fb6d5e1e2ade..9a4f5403569e 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -370,13 +370,11 @@ static void toneport_setup(struct usb_line6_toneport *toneport) static void line6_toneport_disconnect(struct usb_interface *interface) { struct usb_line6_toneport *toneport; - u16 idProduct; toneport = usb_get_intfdata(interface); del_timer_sync(&toneport->timer); - idProduct = le16_to_cpu(toneport->line6.usbdev->descriptor.idProduct); - if (toneport_has_led(idProduct)) { + if (toneport_has_led(toneport->type)) { device_remove_file(&interface->dev, &dev_attr_led_red); device_remove_file(&interface->dev, &dev_attr_led_green); } -- cgit From f44edd7b2bbeddef602fe84d3b175818024d7fce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 20 Jan 2015 09:36:31 +0100 Subject: ALSA: line6/toneport: Implement LED controls via LED class Instead of non-standard sysfs, reimplement the LED controls on TonePort as LED class devices. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/Kconfig | 2 + sound/usb/line6/toneport.c | 163 +++++++++++++++++++++++++-------------------- 2 files changed, 91 insertions(+), 74 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/Kconfig b/sound/usb/line6/Kconfig index af20947e0bda..f4585d378ef3 100644 --- a/sound/usb/line6/Kconfig +++ b/sound/usb/line6/Kconfig @@ -29,6 +29,8 @@ config SND_USB_PODHD config SND_USB_TONEPORT tristate "TonePort GX, UX1 and UX2 USB support" select SND_USB_LINE6 + select NEW_LEDS + select LEDS_CLASS help This is a driver for TonePort GX, UX1 and UX2 devices. diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 9a4f5403569e..9a769463f7bf 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -32,6 +33,15 @@ enum line6_device_type { LINE6_TONEPORT_UX2, }; +struct usb_line6_toneport; + +struct toneport_led { + struct led_classdev dev; + char name[64]; + struct usb_line6_toneport *toneport; + bool registered; +}; + struct usb_line6_toneport { /** Generic Line 6 USB data. @@ -62,6 +72,9 @@ struct usb_line6_toneport { Device type. */ enum line6_device_type type; + + /* LED instances */ + struct toneport_led leds[2]; }; static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); @@ -117,15 +130,6 @@ static struct line6_pcm_properties toneport_pcm_properties = { .bytes_per_frame = 4 }; -/* - For the led on Guitarport. - Brightness goes from 0x00 to 0x26. Set a value above this to have led - blink. - (void cmd_0x02(byte red, byte green) -*/ -static int led_red = 0x00; -static int led_green = 0x26; - static const struct { const char *name; int code; @@ -136,62 +140,6 @@ static const struct { {"Inst & Mic", 0x0901} }; -static bool toneport_has_led(enum line6_device_type type) -{ - return - (type == LINE6_GUITARPORT) || - (type == LINE6_TONEPORT_GX); - /* add your device here if you are missing support for the LEDs */ -} - -static void toneport_update_led(struct device *dev) -{ - struct usb_interface *interface = to_usb_interface(dev); - struct usb_line6_toneport *tp = usb_get_intfdata(interface); - struct usb_line6 *line6; - - if (!tp) - return; - - line6 = &tp->line6; - if (line6) - toneport_send_cmd(line6->usbdev, (led_red << 8) | 0x0002, - led_green); -} - -static ssize_t toneport_set_led_red(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - int retval; - - retval = kstrtoint(buf, 10, &led_red); - if (retval) - return retval; - - toneport_update_led(dev); - return count; -} - -static ssize_t toneport_set_led_green(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - int retval; - - retval = kstrtoint(buf, 10, &led_green); - if (retval) - return retval; - - toneport_update_led(dev); - return count; -} - -static DEVICE_ATTR(led_red, S_IWUSR | S_IRUGO, line6_nop_read, - toneport_set_led_red); -static DEVICE_ATTR(led_green, S_IWUSR | S_IRUGO, line6_nop_read, - toneport_set_led_green); - static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) { int ret; @@ -329,6 +277,78 @@ static struct snd_kcontrol_new toneport_control_source = { .put = snd_toneport_source_put }; +/* + For the led on Guitarport. + Brightness goes from 0x00 to 0x26. Set a value above this to have led + blink. + (void cmd_0x02(byte red, byte green) +*/ + +static bool toneport_has_led(enum line6_device_type type) +{ + return + (type == LINE6_GUITARPORT) || + (type == LINE6_TONEPORT_GX); + /* add your device here if you are missing support for the LEDs */ +} + +static const char * const led_colors[2] = { "red", "green" }; +static const int led_init_vals[2] = { 0x00, 0x26 }; + +static void toneport_update_led(struct usb_line6_toneport *toneport) +{ + toneport_send_cmd(toneport->line6.usbdev, + (toneport->leds[0].dev.brightness << 8) | 0x0002, + toneport->leds[1].dev.brightness); +} + +static void toneport_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct toneport_led *leds = + container_of(led_cdev, struct toneport_led, dev); + toneport_update_led(leds->toneport); +} + +static int toneport_init_leds(struct usb_line6_toneport *toneport) +{ + struct device *dev = &toneport->line6.usbdev->dev; + int i, err; + + for (i = 0; i < 2; i++) { + struct toneport_led *led = &toneport->leds[i]; + struct led_classdev *leddev = &led->dev; + + led->toneport = toneport; + snprintf(led->name, sizeof(led->name), "%s::%s", + dev_name(dev), led_colors[i]); + leddev->name = led->name; + leddev->brightness = led_init_vals[i]; + leddev->max_brightness = 0x26; + leddev->brightness_set = toneport_led_brightness_set; + err = led_classdev_register(dev, leddev); + if (err) + return err; + led->registered = true; + } + + return 0; +} + +static void toneport_remove_leds(struct usb_line6_toneport *toneport) +{ + struct toneport_led *led; + int i; + + for (i = 0; i < 2; i++) { + led = &toneport->leds[i]; + if (!led->registered) + break; + led_classdev_unregister(&led->dev); + led->registered = false; + } +} + /* Setup Toneport device. */ @@ -359,7 +379,7 @@ static void toneport_setup(struct usb_line6_toneport *toneport) } if (toneport_has_led(toneport->type)) - toneport_update_led(&usbdev->dev); + toneport_update_led(toneport); mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ); } @@ -374,10 +394,8 @@ static void line6_toneport_disconnect(struct usb_interface *interface) toneport = usb_get_intfdata(interface); del_timer_sync(&toneport->timer); - if (toneport_has_led(toneport->type)) { - device_remove_file(&interface->dev, &dev_attr_led_red); - device_remove_file(&interface->dev, &dev_attr_led_green); - } + if (toneport_has_led(toneport->type)) + toneport_remove_leds(toneport); } @@ -428,10 +446,7 @@ static int toneport_init(struct usb_interface *interface, line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); if (toneport_has_led(toneport->type)) { - err = device_create_file(&interface->dev, &dev_attr_led_red); - if (err < 0) - return err; - err = device_create_file(&interface->dev, &dev_attr_led_green); + err = toneport_init_leds(toneport); if (err < 0) return err; } -- cgit From 644d90850c65c6ac5698e4fadb01682196a25eea Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 12:24:03 +0100 Subject: ALSA: line6: Minor refactoring Split some codes in the lengthy line6_probe(). Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 94 +++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 45 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index e7f9a99e1949..b783c0788e45 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -448,6 +448,52 @@ static void line6_destruct(struct snd_card *card) usb_put_dev(usbdev); } +/* get data from endpoint descriptor (see usb_maxpacket): */ +static void line6_get_interval(struct usb_line6 *line6) +{ + struct usb_device *usbdev = line6->usbdev; + struct usb_host_endpoint *ep; + unsigned pipe = usb_rcvintpipe(usbdev, line6->properties->ep_ctrl_r); + unsigned epnum = usb_pipeendpoint(pipe); + + ep = usbdev->ep_in[epnum]; + if (ep) { + line6->interval = ep->desc.bInterval; + line6->max_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize); + } else { + dev_err(line6->ifcdev, + "endpoint not available, using fallback values"); + line6->interval = LINE6_FALLBACK_INTERVAL; + line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE; + } +} + +static int line6_init_cap_control(struct usb_line6 *line6) +{ + int ret; + + /* initialize USB buffers: */ + line6->buffer_listen = kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL); + if (!line6->buffer_listen) + return -ENOMEM; + + line6->buffer_message = kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL); + if (!line6->buffer_message) + return -ENOMEM; + + line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL); + if (!line6->urb_listen) + return -ENOMEM; + + ret = line6_start_listen(line6); + if (ret < 0) { + dev_err(line6->ifcdev, "cannot start listening: %d\n", ret); + return ret; + } + + return 0; +} + /* Probe USB device. */ @@ -485,24 +531,7 @@ int line6_probe(struct usb_interface *interface, line6->usbdev = usbdev; line6->ifcdev = &interface->dev; - /* get data from endpoint descriptor (see usb_maxpacket): */ - { - struct usb_host_endpoint *ep; - unsigned pipe = usb_rcvintpipe(usbdev, properties->ep_ctrl_r); - unsigned epnum = usb_pipeendpoint(pipe); - ep = usbdev->ep_in[epnum]; - - if (ep != NULL) { - line6->interval = ep->desc.bInterval; - line6->max_packet_size = - le16_to_cpu(ep->desc.wMaxPacketSize); - } else { - line6->interval = LINE6_FALLBACK_INTERVAL; - line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE; - dev_err(line6->ifcdev, - "endpoint not available, using fallback values"); - } - } + line6_get_interval(line6); ret = snd_card_new(line6->ifcdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, @@ -525,34 +554,9 @@ int line6_probe(struct usb_interface *interface, usb_get_dev(usbdev); if (properties->capabilities & LINE6_CAP_CONTROL) { - /* initialize USB buffers: */ - line6->buffer_listen = - kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL); - if (line6->buffer_listen == NULL) { - ret = -ENOMEM; - goto err_destruct; - } - - line6->buffer_message = - kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL); - if (line6->buffer_message == NULL) { - ret = -ENOMEM; + ret = line6_init_cap_control(line6); + if (ret < 0) goto err_destruct; - } - - line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL); - - if (line6->urb_listen == NULL) { - ret = -ENOMEM; - goto err_destruct; - } - - ret = line6_start_listen(line6); - if (ret < 0) { - dev_err(&interface->dev, "%s: usb_submit_urb failed\n", - __func__); - goto err_destruct; - } } /* initialize device data based on device: */ -- cgit From 6b562f63dd603443c97c885daa2b88bff700b2dc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 12:27:39 +0100 Subject: ALSA: line6: Fix memory leak at probe error path Fix memory leak at probe error path by rearranging the call order in line6_destruct() so that the common destructor is always called. Also this simplifies the error path to a single goto label. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 59 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index b783c0788e45..bf9630cd2395 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -507,39 +507,20 @@ int line6_probe(struct usb_interface *interface, int interface_number; int ret; - /* we don't handle multiple configurations */ - if (usbdev->descriptor.bNumConfigurations != 1) { - ret = -ENODEV; - goto err_put; - } - - /* initialize device info: */ - dev_info(&interface->dev, "Line 6 %s found\n", properties->name); - - /* query interface number */ - interface_number = interface->cur_altsetting->desc.bInterfaceNumber; - - ret = usb_set_interface(usbdev, interface_number, - properties->altsetting); + ret = snd_card_new(&interface->dev, + SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, + THIS_MODULE, 0, &card); if (ret < 0) { - dev_err(&interface->dev, "set_interface failed\n"); - goto err_put; + kfree(line6); + return ret; } /* store basic data: */ + line6->card = card; line6->properties = properties; line6->usbdev = usbdev; line6->ifcdev = &interface->dev; - line6_get_interval(line6); - - ret = snd_card_new(line6->ifcdev, - SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, - THIS_MODULE, 0, &card); - if (ret < 0) - goto err_put; - - line6->card = card; strcpy(card->id, line6->properties->id); strcpy(card->driver, DRIVER_NAME); strcpy(card->shortname, line6->properties->name); @@ -553,16 +534,37 @@ int line6_probe(struct usb_interface *interface, /* increment reference counters: */ usb_get_dev(usbdev); + /* we don't handle multiple configurations */ + if (usbdev->descriptor.bNumConfigurations != 1) { + ret = -ENODEV; + goto error; + } + + /* initialize device info: */ + dev_info(&interface->dev, "Line 6 %s found\n", properties->name); + + /* query interface number */ + interface_number = interface->cur_altsetting->desc.bInterfaceNumber; + + ret = usb_set_interface(usbdev, interface_number, + properties->altsetting); + if (ret < 0) { + dev_err(&interface->dev, "set_interface failed\n"); + goto error; + } + + line6_get_interval(line6); + if (properties->capabilities & LINE6_CAP_CONTROL) { ret = line6_init_cap_control(line6); if (ret < 0) - goto err_destruct; + goto error; } /* initialize device data based on device: */ ret = private_init(interface, line6); if (ret < 0) - goto err_destruct; + goto error; /* creation of additional special files should go here */ @@ -571,11 +573,10 @@ int line6_probe(struct usb_interface *interface, return 0; - err_destruct: + error: if (line6->disconnect) line6->disconnect(interface); snd_card_free(card); - err_put: return ret; } EXPORT_SYMBOL_GPL(line6_probe); -- cgit From b55004f9fdee80de1b6982b3e99ebaeb7d1e7a6c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 12:30:48 +0100 Subject: ALSA: line6: Remove unused line6_nop_read() The function isn't used any longer after rewriting from sysfs to leds class in toneport.c. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 10 ---------- sound/usb/line6/driver.h | 2 -- 2 files changed, 12 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index bf9630cd2395..4d2d233d0505 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -412,16 +412,6 @@ int line6_read_serial_number(struct usb_line6 *line6, int *serial_number) } EXPORT_SYMBOL_GPL(line6_read_serial_number); -/* - No operation (i.e., unsupported). -*/ -ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return 0; -} -EXPORT_SYMBOL_GPL(line6_nop_read); - /* Card destructor. */ diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index efd58ac3215b..a6c0b2f08ba8 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -162,8 +162,6 @@ struct usb_line6 { extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, int size); -extern ssize_t line6_nop_read(struct device *dev, - struct device_attribute *attr, char *buf); extern int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen); extern int line6_read_serial_number(struct usb_line6 *line6, -- cgit From bc518ba4ccb487ef52e418c3ff68050cf07b3bc0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 12:39:11 +0100 Subject: ALSA: line6: Reduce superfluous spinlock in midi.c The midi_transmit_lock is used always inside the send_urb_lock, thus it doesn't play any role. Let's kill it. Also, rename "send_urb_lock" as a more simple name "lock" since this is the only lock for midi. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/midi.c | 18 ++++++------------ sound/usb/line6/midi.h | 7 +------ 2 files changed, 7 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index b5a58a7fe11a..beeedf9a2cbe 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -45,12 +45,9 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream) line6_rawmidi_substream_midi(substream)->line6; struct snd_line6_midi *line6midi = line6->line6midi; struct midi_buffer *mb = &line6midi->midibuf_out; - unsigned long flags; unsigned char chunk[LINE6_FALLBACK_MAXPACKETSIZE]; int req, done; - spin_lock_irqsave(&line6->line6midi->midi_transmit_lock, flags); - for (;;) { req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size); done = snd_rawmidi_transmit_peek(substream, chunk, req); @@ -71,8 +68,6 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream) send_midi_async(line6, chunk, done); } - - spin_unlock_irqrestore(&line6->line6midi->midi_transmit_lock, flags); } /* @@ -92,7 +87,7 @@ static void midi_sent(struct urb *urb) if (status == -ESHUTDOWN) return; - spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags); + spin_lock_irqsave(&line6->line6midi->lock, flags); num = --line6->line6midi->num_active_send_urbs; if (num == 0) { @@ -103,12 +98,12 @@ static void midi_sent(struct urb *urb) if (num == 0) wake_up(&line6->line6midi->send_wait); - spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags); + spin_unlock_irqrestore(&line6->line6midi->lock, flags); } /* Send an asynchronous MIDI message. - Assumes that line6->line6midi->send_urb_lock is held + Assumes that line6->line6midi->lock is held (i.e., this function is serialized). */ static int send_midi_async(struct usb_line6 *line6, unsigned char *data, @@ -166,12 +161,12 @@ static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream, line6_rawmidi_substream_midi(substream)->line6; line6->line6midi->substream_transmit = substream; - spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags); + spin_lock_irqsave(&line6->line6midi->lock, flags); if (line6->line6midi->num_active_send_urbs == 0) line6_midi_transmit(substream); - spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags); + spin_unlock_irqrestore(&line6->line6midi->lock, flags); } static void line6_midi_output_drain(struct snd_rawmidi_substream *substream) @@ -281,8 +276,7 @@ int line6_init_midi(struct usb_line6 *line6) rmidi->private_free = snd_line6_midi_free; init_waitqueue_head(&line6midi->send_wait); - spin_lock_init(&line6midi->send_urb_lock); - spin_lock_init(&line6midi->midi_transmit_lock); + spin_lock_init(&line6midi->lock); line6midi->line6 = line6; err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0); diff --git a/sound/usb/line6/midi.h b/sound/usb/line6/midi.h index ba6bf3828aa5..9d9467b2613c 100644 --- a/sound/usb/line6/midi.h +++ b/sound/usb/line6/midi.h @@ -39,15 +39,10 @@ struct snd_line6_midi { */ int num_active_send_urbs; - /** - Spin lock to protect updates of send_urb. - */ - spinlock_t send_urb_lock; - /** Spin lock to protect MIDI buffer handling. */ - spinlock_t midi_transmit_lock; + spinlock_t lock; /** Wait queue for MIDI transmission. -- cgit From eab22e4053d47250ef755deb8592e0834eb409da Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 13:00:03 +0100 Subject: ALSA: line6: Fix missing error handling in line6_pcm_acquire() Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 8a6059adef69..826158fe9149 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -133,7 +133,8 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) */ if (line6pcm->active_urb_in | line6pcm->unlink_urb_in) { dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); - return -EBUSY; + err = -EBUSY; + goto pcm_acquire_error; } line6pcm->count_in = 0; -- cgit From 6aa7f8ef293f27215f685b2f94e980c7f3a337d5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 14:31:03 +0100 Subject: ALSA: line6: Use logical OR Fixed a few places using bits OR wrongly for condition checks. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 826158fe9149..f740b4490d75 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -131,7 +131,7 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) a bug, we therefore report an error if capturing is restarted too soon. */ - if (line6pcm->active_urb_in | line6pcm->unlink_urb_in) { + if (line6pcm->active_urb_in || line6pcm->unlink_urb_in) { dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); err = -EBUSY; goto pcm_acquire_error; @@ -166,7 +166,7 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) /* See comment above regarding PCM restart. */ - if (line6pcm->active_urb_out | line6pcm->unlink_urb_out) { + if (line6pcm->active_urb_out || line6pcm->unlink_urb_out) { dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); return -EBUSY; } -- cgit From 5343ecf4e5c94aecdd6a859b76c125c3544865d1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 14:34:42 +0100 Subject: ALSA: line6: Fix the error recovery in line6_pcm_acquire() line6_pcm_acquire() tries to restore the newly obtained resources at the error path. But some flags aren't recorded and released properly when the corresponding buffer is already present. These bits have to be cleared in the error recovery, too. Also, "flags_final" can be initialized to zero since we pass only the subset of "channels" bits. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index f740b4490d75..9a2a15f4c4e4 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -106,7 +106,7 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) flags_new = flags_old | channels; } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old); - flags_final = flags_old; + flags_final = 0; line6pcm->prev_fbuf = NULL; @@ -120,9 +120,9 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) err = -ENOMEM; goto pcm_acquire_error; } - - flags_final |= channels & LINE6_BITS_CAPTURE_BUFFER; } + + flags_final |= channels & LINE6_BITS_CAPTURE_BUFFER; } if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_STREAM)) { @@ -157,9 +157,9 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) err = -ENOMEM; goto pcm_acquire_error; } - - flags_final |= channels & LINE6_BITS_PLAYBACK_BUFFER; } + + flags_final |= channels & LINE6_BITS_PLAYBACK_BUFFER; } if (test_flags(flags_old, flags_new, LINE6_BITS_PLAYBACK_STREAM)) { @@ -187,7 +187,7 @@ pcm_acquire_error: If not all requested resources/streams could be obtained, release those which were successfully obtained (if any). */ - line6_pcm_release(line6pcm, flags_final & channels); + line6_pcm_release(line6pcm, flags_final); return err; } EXPORT_SYMBOL_GPL(line6_pcm_acquire); -- cgit From f2a76225b962f00642002fb109aee2e5b0dc4259 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 14:49:22 +0100 Subject: ALSA: line6: Drop superfluous spinlock for trigger The trigger callback is already spinlocked, so we need no more lock here (even for the linked substreams). Let's drop it. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 23 ++++++----------------- sound/usb/line6/pcm.h | 5 ----- 2 files changed, 6 insertions(+), 22 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 9a2a15f4c4e4..adbcac46b785 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -226,9 +226,8 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); struct snd_pcm_substream *s; - int err; + int err = 0; - spin_lock(&line6pcm->lock_trigger); clear_bit(LINE6_INDEX_PREPARED, &line6pcm->flags); snd_pcm_group_for_each_entry(s, substream) { @@ -237,32 +236,23 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) switch (s->stream) { case SNDRV_PCM_STREAM_PLAYBACK: err = snd_line6_playback_trigger(line6pcm, cmd); - - if (err < 0) { - spin_unlock(&line6pcm->lock_trigger); - return err; - } - break; case SNDRV_PCM_STREAM_CAPTURE: err = snd_line6_capture_trigger(line6pcm, cmd); - - if (err < 0) { - spin_unlock(&line6pcm->lock_trigger); - return err; - } - break; default: dev_err(line6pcm->line6->ifcdev, "Unknown stream direction %d\n", s->stream); + err = -EINVAL; + break; } + if (err < 0) + break; } - spin_unlock(&line6pcm->lock_trigger); - return 0; + return err; } /* control info callback */ @@ -427,7 +417,6 @@ int line6_init_pcm(struct usb_line6 *line6, spin_lock_init(&line6pcm->lock_audio_out); spin_lock_init(&line6pcm->lock_audio_in); - spin_lock_init(&line6pcm->lock_trigger); line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; line6->line6pcm = line6pcm; diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index c742b33666eb..a84753ee0fa2 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -307,11 +307,6 @@ struct snd_line6_pcm { */ spinlock_t lock_audio_in; - /** - Spin lock to protect trigger. - */ - spinlock_t lock_trigger; - /** PCM playback volume (left and right). */ -- cgit From 9fb754b79e536eb35d69a4678687addff589e45b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 15:08:40 +0100 Subject: ALSA: line6: Use incremental loop Using a decremental loop without particular reasons worsens the readability a lot. Use incremental loops instead. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 4 ++-- sound/usb/line6/pcm.c | 6 +++--- sound/usb/line6/playback.c | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 5a010ba163fa..97283e631e45 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -91,7 +91,7 @@ void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm) { unsigned int i; - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (test_bit(i, &line6pcm->active_urb_in)) { if (!test_and_set_bit(i, &line6pcm->unlink_urb_in)) { struct urb *u = line6pcm->urb_audio_in[i]; @@ -114,7 +114,7 @@ void line6_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) do { alive = 0; - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (test_bit(i, &line6pcm->active_urb_in)) alive++; } diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index adbcac46b785..43474c4ebb6b 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -273,7 +273,7 @@ static int snd_line6_control_playback_get(struct snd_kcontrol *kcontrol, int i; struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); - for (i = 2; i--;) + for (i = 0; i < 2; i++) ucontrol->value.integer.value[i] = line6pcm->volume_playback[i]; return 0; @@ -286,7 +286,7 @@ static int snd_line6_control_playback_put(struct snd_kcontrol *kcontrol, int i, changed = 0; struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); - for (i = 2; i--;) + for (i = 0; i < 2; i++) if (line6pcm->volume_playback[i] != ucontrol->value.integer.value[i]) { line6pcm->volume_playback[i] = @@ -330,7 +330,7 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm) int i; struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm); - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (line6pcm->urb_audio_out[i]) { usb_kill_urb(line6pcm->urb_audio_out[i]); usb_free_urb(line6pcm->urb_audio_out[i]); diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 1c9f95a370ff..ab9a83f0f864 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -297,7 +297,7 @@ void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm) { unsigned int i; - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (test_bit(i, &line6pcm->active_urb_out)) { if (!test_and_set_bit(i, &line6pcm->unlink_urb_out)) { struct urb *u = line6pcm->urb_audio_out[i]; @@ -320,7 +320,7 @@ void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) do { alive = 0; - for (i = LINE6_ISO_BUFFERS; i--;) { + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { if (test_bit(i, &line6pcm->active_urb_out)) alive++; } @@ -366,14 +366,14 @@ static void audio_out_callback(struct urb *urb) line6pcm->last_frame_out = urb->start_frame; /* find index of URB */ - for (index = LINE6_ISO_BUFFERS; index--;) + for (index = 0; index < LINE6_ISO_BUFFERS; index++) if (urb == line6pcm->urb_audio_out[index]) break; - if (index < 0) + if (index >= LINE6_ISO_BUFFERS) return; /* URB has been unlinked asynchronously */ - for (i = LINE6_ISO_PACKETS; i--;) + for (i = 0; i < LINE6_ISO_PACKETS; i++) length += urb->iso_frame_desc[i].length; spin_lock_irqsave(&line6pcm->lock_audio_out, flags); @@ -390,7 +390,7 @@ static void audio_out_callback(struct urb *urb) clear_bit(index, &line6pcm->active_urb_out); - for (i = LINE6_ISO_PACKETS; i--;) + for (i = 0; i < LINE6_ISO_PACKETS; i++) if (urb->iso_frame_desc[i].status == -EXDEV) { shutdown = 1; break; -- cgit From ab5cdcbab2efb833b4c199d0b0a6603af080eaa2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 15:12:13 +0100 Subject: ALSA: line6: Drop voodoo workarounds If the problem still really remains, we should fix it instead of papering over it like this... Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 12 ------------ sound/usb/line6/playback.c | 12 ------------ 2 files changed, 24 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 97283e631e45..bad1b5b02786 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -297,18 +297,6 @@ static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream, int ret; struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - /* -- Florian Demski [FD] */ - /* don't ask me why, but this fixes the bug on my machine */ - if (line6pcm == NULL) { - if (substream->pcm == NULL) - return -ENOMEM; - if (substream->pcm->private_data == NULL) - return -ENOMEM; - substream->private_data = substream->pcm->private_data; - line6pcm = snd_pcm_substream_chip(substream); - } - /* -- [FD] end */ - ret = line6_pcm_acquire(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER); if (ret < 0) diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index ab9a83f0f864..7e031b1761aa 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -445,18 +445,6 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream, int ret; struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - /* -- Florian Demski [FD] */ - /* don't ask me why, but this fixes the bug on my machine */ - if (line6pcm == NULL) { - if (substream->pcm == NULL) - return -ENOMEM; - if (substream->pcm->private_data == NULL) - return -ENOMEM; - substream->private_data = substream->pcm->private_data; - line6pcm = snd_pcm_substream_chip(substream); - } - /* -- [FD] end */ - ret = line6_pcm_acquire(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER); if (ret < 0) -- cgit From ad0119abe29fe3d506486a789de4c4619fa7602c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 16:10:57 +0100 Subject: ALSA: line6: Rearrange PCM structure Introduce a new line6_pcm_stream structure and group individual fields of snd_line6_pcm struct to playback and capture groups. This patch itself just does rename and nothing else. More meaningful cleanups based on these fields shuffling will follow. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 64 +++++++++--------- sound/usb/line6/pcm.c | 50 +++++++------- sound/usb/line6/pcm.h | 158 +++++++++++++-------------------------------- sound/usb/line6/playback.c | 78 +++++++++++----------- 4 files changed, 142 insertions(+), 208 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index bad1b5b02786..439f1941eb56 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -29,17 +29,17 @@ static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) int ret; struct urb *urb_in; - spin_lock_irqsave(&line6pcm->lock_audio_in, flags); + spin_lock_irqsave(&line6pcm->in.lock, flags); index = - find_first_zero_bit(&line6pcm->active_urb_in, LINE6_ISO_BUFFERS); + find_first_zero_bit(&line6pcm->in.active_urbs, LINE6_ISO_BUFFERS); if (index < 0 || index >= LINE6_ISO_BUFFERS) { - spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); + spin_unlock_irqrestore(&line6pcm->in.lock, flags); dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); return -EINVAL; } - urb_in = line6pcm->urb_audio_in[index]; + urb_in = line6pcm->in.urbs[index]; urb_size = 0; for (i = 0; i < LINE6_ISO_PACKETS; ++i) { @@ -51,7 +51,7 @@ static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) } urb_in->transfer_buffer = - line6pcm->buffer_in + + line6pcm->in.buffer + index * LINE6_ISO_PACKETS * line6pcm->max_packet_size; urb_in->transfer_buffer_length = urb_size; urb_in->context = line6pcm; @@ -59,12 +59,12 @@ static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) ret = usb_submit_urb(urb_in, GFP_ATOMIC); if (ret == 0) - set_bit(index, &line6pcm->active_urb_in); + set_bit(index, &line6pcm->in.active_urbs); else dev_err(line6pcm->line6->ifcdev, "URB in #%d submission failed (%d)\n", index, ret); - spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); + spin_unlock_irqrestore(&line6pcm->in.lock, flags); return 0; } @@ -92,9 +92,9 @@ void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm) unsigned int i; for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (test_bit(i, &line6pcm->active_urb_in)) { - if (!test_and_set_bit(i, &line6pcm->unlink_urb_in)) { - struct urb *u = line6pcm->urb_audio_in[i]; + if (test_bit(i, &line6pcm->in.active_urbs)) { + if (!test_and_set_bit(i, &line6pcm->in.unlink_urbs)) { + struct urb *u = line6pcm->in.urbs[i]; usb_unlink_urb(u); } @@ -115,7 +115,7 @@ void line6_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) do { alive = 0; for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (test_bit(i, &line6pcm->active_urb_in)) + if (test_bit(i, &line6pcm->in.active_urbs)) alive++; } if (!alive) @@ -150,18 +150,18 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) if (runtime == NULL) return; - if (line6pcm->pos_in_done + frames > runtime->buffer_size) { + if (line6pcm->in.pos_done + frames > runtime->buffer_size) { /* The transferred area goes over buffer boundary, copy two separate chunks. */ int len; - len = runtime->buffer_size - line6pcm->pos_in_done; + len = runtime->buffer_size - line6pcm->in.pos_done; if (len > 0) { memcpy(runtime->dma_area + - line6pcm->pos_in_done * bytes_per_frame, fbuf, + line6pcm->in.pos_done * bytes_per_frame, fbuf, len * bytes_per_frame); memcpy(runtime->dma_area, fbuf + len * bytes_per_frame, (frames - len) * bytes_per_frame); @@ -173,12 +173,12 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) } else { /* copy single chunk */ memcpy(runtime->dma_area + - line6pcm->pos_in_done * bytes_per_frame, fbuf, fsize); + line6pcm->in.pos_done * bytes_per_frame, fbuf, fsize); } - line6pcm->pos_in_done += frames; - if (line6pcm->pos_in_done >= runtime->buffer_size) - line6pcm->pos_in_done -= runtime->buffer_size; + line6pcm->in.pos_done += frames; + if (line6pcm->in.pos_done >= runtime->buffer_size) + line6pcm->in.pos_done -= runtime->buffer_size; } void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length) @@ -186,17 +186,17 @@ void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length) struct snd_pcm_substream *substream = get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE); - line6pcm->bytes_in += length; - if (line6pcm->bytes_in >= line6pcm->period_in) { - line6pcm->bytes_in %= line6pcm->period_in; + line6pcm->in.bytes += length; + if (line6pcm->in.bytes >= line6pcm->in.period) { + line6pcm->in.bytes %= line6pcm->in.period; snd_pcm_period_elapsed(substream); } } void line6_free_capture_buffer(struct snd_line6_pcm *line6pcm) { - kfree(line6pcm->buffer_in); - line6pcm->buffer_in = NULL; + kfree(line6pcm->in.buffer); + line6pcm->in.buffer = NULL; } /* @@ -209,14 +209,14 @@ static void audio_in_callback(struct urb *urb) struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context; - line6pcm->last_frame_in = urb->start_frame; + line6pcm->in.last_frame = urb->start_frame; /* find index of URB */ for (index = 0; index < LINE6_ISO_BUFFERS; ++index) - if (urb == line6pcm->urb_audio_in[index]) + if (urb == line6pcm->in.urbs[index]) break; - spin_lock_irqsave(&line6pcm->lock_audio_in, flags); + spin_lock_irqsave(&line6pcm->in.lock, flags); for (i = 0; i < LINE6_ISO_PACKETS; ++i) { char *fbuf; @@ -249,12 +249,12 @@ static void audio_in_callback(struct urb *urb) line6_capture_copy(line6pcm, fbuf, fsize); } - clear_bit(index, &line6pcm->active_urb_in); + clear_bit(index, &line6pcm->in.active_urbs); - if (test_and_clear_bit(index, &line6pcm->unlink_urb_in)) + if (test_and_clear_bit(index, &line6pcm->in.unlink_urbs)) shutdown = 1; - spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags); + spin_unlock_irqrestore(&line6pcm->in.lock, flags); if (!shutdown) { submit_audio_in_urb(line6pcm); @@ -309,7 +309,7 @@ static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream, return ret; } - line6pcm->period_in = params_period_bytes(hw_params); + line6pcm->in.period = params_period_bytes(hw_params); return 0; } @@ -361,7 +361,7 @@ snd_line6_capture_pointer(struct snd_pcm_substream *substream) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - return line6pcm->pos_in_done; + return line6pcm->in.pos_done; } /* capture operators */ @@ -386,7 +386,7 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) struct urb *urb; /* URB for audio in: */ - urb = line6pcm->urb_audio_in[i] = + urb = line6pcm->in.urbs[i] = usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); if (urb == NULL) diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 43474c4ebb6b..738bfd82cecd 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -112,11 +112,11 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_BUFFER)) { /* Invoked multiple times in a row so allocate once only */ - if (!line6pcm->buffer_in) { - line6pcm->buffer_in = + if (!line6pcm->in.buffer) { + line6pcm->in.buffer = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * line6pcm->max_packet_size, GFP_KERNEL); - if (!line6pcm->buffer_in) { + if (!line6pcm->in.buffer) { err = -ENOMEM; goto pcm_acquire_error; } @@ -131,13 +131,13 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) a bug, we therefore report an error if capturing is restarted too soon. */ - if (line6pcm->active_urb_in || line6pcm->unlink_urb_in) { + if (line6pcm->in.active_urbs || line6pcm->in.unlink_urbs) { dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); err = -EBUSY; goto pcm_acquire_error; } - line6pcm->count_in = 0; + line6pcm->in.count = 0; line6pcm->prev_fsize = 0; err = line6_submit_audio_in_all_urbs(line6pcm); @@ -149,11 +149,11 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) if (test_flags(flags_old, flags_new, LINE6_BITS_PLAYBACK_BUFFER)) { /* Invoked multiple times in a row so allocate once only */ - if (!line6pcm->buffer_out) { - line6pcm->buffer_out = + if (!line6pcm->out.buffer) { + line6pcm->out.buffer = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * line6pcm->max_packet_size, GFP_KERNEL); - if (!line6pcm->buffer_out) { + if (!line6pcm->out.buffer) { err = -ENOMEM; goto pcm_acquire_error; } @@ -166,12 +166,12 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) /* See comment above regarding PCM restart. */ - if (line6pcm->active_urb_out || line6pcm->unlink_urb_out) { + if (line6pcm->out.active_urbs || line6pcm->out.unlink_urbs) { dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); return -EBUSY; } - line6pcm->count_out = 0; + line6pcm->out.count = 0; err = line6_submit_audio_out_all_urbs(line6pcm); if (err < 0) @@ -331,13 +331,13 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm) struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm); for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (line6pcm->urb_audio_out[i]) { - usb_kill_urb(line6pcm->urb_audio_out[i]); - usb_free_urb(line6pcm->urb_audio_out[i]); + if (line6pcm->out.urbs[i]) { + usb_kill_urb(line6pcm->out.urbs[i]); + usb_free_urb(line6pcm->out.urbs[i]); } - if (line6pcm->urb_audio_in[i]) { - usb_kill_urb(line6pcm->urb_audio_in[i]); - usb_free_urb(line6pcm->urb_audio_in[i]); + if (line6pcm->in.urbs[i]) { + usb_kill_urb(line6pcm->in.urbs[i]); + usb_free_urb(line6pcm->in.urbs[i]); } } kfree(line6pcm); @@ -415,8 +415,8 @@ int line6_init_pcm(struct usb_line6 *line6, usb_maxpacket(line6->usbdev, usb_sndisocpipe(line6->usbdev, ep_write), 1)); - spin_lock_init(&line6pcm->lock_audio_out); - spin_lock_init(&line6pcm->lock_audio_in); + spin_lock_init(&line6pcm->out.lock); + spin_lock_init(&line6pcm->in.lock); line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; line6->line6pcm = line6pcm; @@ -464,13 +464,13 @@ int snd_line6_prepare(struct snd_pcm_substream *substream) } if (!test_and_set_bit(LINE6_INDEX_PREPARED, &line6pcm->flags)) { - line6pcm->count_out = 0; - line6pcm->pos_out = 0; - line6pcm->pos_out_done = 0; - line6pcm->bytes_out = 0; - line6pcm->count_in = 0; - line6pcm->pos_in_done = 0; - line6pcm->bytes_in = 0; + line6pcm->out.count = 0; + line6pcm->out.pos = 0; + line6pcm->out.pos_done = 0; + line6pcm->out.bytes = 0; + line6pcm->in.count = 0; + line6pcm->in.pos_done = 0; + line6pcm->in.bytes = 0; } return 0; diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index a84753ee0fa2..4c74f4e85074 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -165,148 +165,84 @@ struct line6_pcm_properties { int bytes_per_frame; }; -struct snd_line6_pcm { - /** - Pointer back to the Line 6 driver data structure. - */ - struct usb_line6 *line6; +struct line6_pcm_stream { + /* allocated URBs */ + struct urb *urbs[LINE6_ISO_BUFFERS]; - /** - Properties. - */ - struct line6_pcm_properties *properties; + /* Temporary buffer; + * Since the packet size is not known in advance, this buffer is + * large enough to store maximum size packets. + */ + unsigned char *buffer; - /** - ALSA pcm stream - */ - struct snd_pcm *pcm; + /* Free frame position in the buffer. */ + snd_pcm_uframes_t pos; - /** - URBs for audio playback. - */ - struct urb *urb_audio_out[LINE6_ISO_BUFFERS]; + /* Count processed bytes; + * This is modulo period size (to determine when a period is finished). + */ + unsigned bytes; - /** - URBs for audio capture. - */ - struct urb *urb_audio_in[LINE6_ISO_BUFFERS]; + /* Counter to create desired sample rate */ + unsigned count; - /** - Temporary buffer for playback. - Since the packet size is not known in advance, this buffer is - large enough to store maximum size packets. - */ - unsigned char *buffer_out; + /* period size in bytes */ + unsigned period; - /** - Temporary buffer for capture. - Since the packet size is not known in advance, this buffer is - large enough to store maximum size packets. - */ - unsigned char *buffer_in; + /* Processed frame position in the buffer; + * The contents of the ring buffer have been consumed by the USB + * subsystem (i.e., sent to the USB device) up to this position. + */ + snd_pcm_uframes_t pos_done; - /** - Previously captured frame (for software monitoring). - */ - unsigned char *prev_fbuf; + /* Bit mask of active URBs */ + unsigned long active_urbs; - /** - Size of previously captured frame (for software monitoring). - */ - int prev_fsize; - - /** - Free frame position in the playback buffer. - */ - snd_pcm_uframes_t pos_out; + /* Bit mask of URBs currently being unlinked */ + unsigned long unlink_urbs; - /** - Count processed bytes for playback. - This is modulo period size (to determine when a period is - finished). - */ - unsigned bytes_out; + /* Spin lock to protect updates of the buffer positions (not contents) + */ + spinlock_t lock; - /** - Counter to create desired playback sample rate. - */ - unsigned count_out; - - /** - Playback period size in bytes - */ - unsigned period_out; + int last_frame; +}; +struct snd_line6_pcm { /** - Processed frame position in the playback buffer. - The contents of the output ring buffer have been consumed by - the USB subsystem (i.e., sent to the USB device) up to this - position. + Pointer back to the Line 6 driver data structure. */ - snd_pcm_uframes_t pos_out_done; + struct usb_line6 *line6; /** - Count processed bytes for capture. - This is modulo period size (to determine when a period is - finished). + Properties. */ - unsigned bytes_in; + struct line6_pcm_properties *properties; /** - Counter to create desired capture sample rate. + ALSA pcm stream */ - unsigned count_in; + struct snd_pcm *pcm; - /** - Capture period size in bytes - */ - unsigned period_in; + /* Capture and playback streams */ + struct line6_pcm_stream in; + struct line6_pcm_stream out; /** - Processed frame position in the capture buffer. - The contents of the output ring buffer have been consumed by - the USB subsystem (i.e., sent to the USB device) up to this - position. + Previously captured frame (for software monitoring). */ - snd_pcm_uframes_t pos_in_done; + unsigned char *prev_fbuf; /** - Bit mask of active playback URBs. + Size of previously captured frame (for software monitoring). */ - unsigned long active_urb_out; + int prev_fsize; /** Maximum size of USB packet. */ int max_packet_size; - /** - Bit mask of active capture URBs. - */ - unsigned long active_urb_in; - - /** - Bit mask of playback URBs currently being unlinked. - */ - unsigned long unlink_urb_out; - - /** - Bit mask of capture URBs currently being unlinked. - */ - unsigned long unlink_urb_in; - - /** - Spin lock to protect updates of the playback buffer positions (not - contents!) - */ - spinlock_t lock_audio_out; - - /** - Spin lock to protect updates of the capture buffer positions (not - contents!) - */ - spinlock_t lock_audio_in; - /** PCM playback volume (left and right). */ @@ -336,8 +272,6 @@ struct snd_line6_pcm { Several status bits (see LINE6_BIT_*). */ unsigned long flags; - - int last_frame_in, last_frame_out; }; extern int line6_init_pcm(struct usb_line6 *line6, diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 7e031b1761aa..d619c1718306 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -145,17 +145,17 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) (USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL); struct urb *urb_out; - spin_lock_irqsave(&line6pcm->lock_audio_out, flags); + spin_lock_irqsave(&line6pcm->out.lock, flags); index = - find_first_zero_bit(&line6pcm->active_urb_out, LINE6_ISO_BUFFERS); + find_first_zero_bit(&line6pcm->out.active_urbs, LINE6_ISO_BUFFERS); if (index < 0 || index >= LINE6_ISO_BUFFERS) { - spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); + spin_unlock_irqrestore(&line6pcm->out.lock, flags); dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); return -EINVAL; } - urb_out = line6pcm->urb_audio_out[index]; + urb_out = line6pcm->out.urbs[index]; urb_size = 0; for (i = 0; i < LINE6_ISO_PACKETS; ++i) { @@ -170,9 +170,9 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) if (fsize == 0) { int n; - line6pcm->count_out += frame_increment; - n = line6pcm->count_out / frame_factor; - line6pcm->count_out -= n * frame_factor; + line6pcm->out.count += frame_increment; + n = line6pcm->out.count / frame_factor; + line6pcm->out.count -= n * frame_factor; fsize = n * bytes_per_frame; } @@ -183,14 +183,14 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) if (urb_size == 0) { /* can't determine URB size */ - spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); + spin_unlock_irqrestore(&line6pcm->out.lock, flags); dev_err(line6pcm->line6->ifcdev, "driver bug: urb_size = 0\n"); return -EINVAL; } urb_frames = urb_size / bytes_per_frame; urb_out->transfer_buffer = - line6pcm->buffer_out + + line6pcm->out.buffer + index * LINE6_ISO_PACKETS * line6pcm->max_packet_size; urb_out->transfer_buffer_length = urb_size; urb_out->context = line6pcm; @@ -200,19 +200,19 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) struct snd_pcm_runtime *runtime = get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK)->runtime; - if (line6pcm->pos_out + urb_frames > runtime->buffer_size) { + if (line6pcm->out.pos + urb_frames > runtime->buffer_size) { /* The transferred area goes over buffer boundary, copy the data to the temp buffer. */ int len; - len = runtime->buffer_size - line6pcm->pos_out; + len = runtime->buffer_size - line6pcm->out.pos; if (len > 0) { memcpy(urb_out->transfer_buffer, runtime->dma_area + - line6pcm->pos_out * bytes_per_frame, + line6pcm->out.pos * bytes_per_frame, len * bytes_per_frame); memcpy(urb_out->transfer_buffer + len * bytes_per_frame, runtime->dma_area, @@ -223,13 +223,13 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) } else { memcpy(urb_out->transfer_buffer, runtime->dma_area + - line6pcm->pos_out * bytes_per_frame, + line6pcm->out.pos * bytes_per_frame, urb_out->transfer_buffer_length); } - line6pcm->pos_out += urb_frames; - if (line6pcm->pos_out >= runtime->buffer_size) - line6pcm->pos_out -= runtime->buffer_size; + line6pcm->out.pos += urb_frames; + if (line6pcm->out.pos >= runtime->buffer_size) + line6pcm->out.pos -= runtime->buffer_size; } else { memset(urb_out->transfer_buffer, 0, urb_out->transfer_buffer_length); @@ -265,12 +265,12 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) ret = usb_submit_urb(urb_out, GFP_ATOMIC); if (ret == 0) - set_bit(index, &line6pcm->active_urb_out); + set_bit(index, &line6pcm->out.active_urbs); else dev_err(line6pcm->line6->ifcdev, "URB out #%d submission failed (%d)\n", index, ret); - spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); + spin_unlock_irqrestore(&line6pcm->out.lock, flags); return 0; } @@ -298,9 +298,9 @@ void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm) unsigned int i; for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (test_bit(i, &line6pcm->active_urb_out)) { - if (!test_and_set_bit(i, &line6pcm->unlink_urb_out)) { - struct urb *u = line6pcm->urb_audio_out[i]; + if (test_bit(i, &line6pcm->out.active_urbs)) { + if (!test_and_set_bit(i, &line6pcm->out.unlink_urbs)) { + struct urb *u = line6pcm->out.urbs[i]; usb_unlink_urb(u); } @@ -321,7 +321,7 @@ void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) do { alive = 0; for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (test_bit(i, &line6pcm->active_urb_out)) + if (test_bit(i, &line6pcm->out.active_urbs)) alive++; } if (!alive) @@ -344,8 +344,8 @@ void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm) { - kfree(line6pcm->buffer_out); - line6pcm->buffer_out = NULL; + kfree(line6pcm->out.buffer); + line6pcm->out.buffer = NULL; } /* @@ -363,11 +363,11 @@ static void audio_out_callback(struct urb *urb) memset(urb->transfer_buffer, 0, urb->transfer_buffer_length); #endif - line6pcm->last_frame_out = urb->start_frame; + line6pcm->out.last_frame = urb->start_frame; /* find index of URB */ for (index = 0; index < LINE6_ISO_BUFFERS; index++) - if (urb == line6pcm->urb_audio_out[index]) + if (urb == line6pcm->out.urbs[index]) break; if (index >= LINE6_ISO_BUFFERS) @@ -376,19 +376,19 @@ static void audio_out_callback(struct urb *urb) for (i = 0; i < LINE6_ISO_PACKETS; i++) length += urb->iso_frame_desc[i].length; - spin_lock_irqsave(&line6pcm->lock_audio_out, flags); + spin_lock_irqsave(&line6pcm->out.lock, flags); if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags)) { struct snd_pcm_runtime *runtime = substream->runtime; - line6pcm->pos_out_done += + line6pcm->out.pos_done += length / line6pcm->properties->bytes_per_frame; - if (line6pcm->pos_out_done >= runtime->buffer_size) - line6pcm->pos_out_done -= runtime->buffer_size; + if (line6pcm->out.pos_done >= runtime->buffer_size) + line6pcm->out.pos_done -= runtime->buffer_size; } - clear_bit(index, &line6pcm->active_urb_out); + clear_bit(index, &line6pcm->out.active_urbs); for (i = 0; i < LINE6_ISO_PACKETS; i++) if (urb->iso_frame_desc[i].status == -EXDEV) { @@ -396,19 +396,19 @@ static void audio_out_callback(struct urb *urb) break; } - if (test_and_clear_bit(index, &line6pcm->unlink_urb_out)) + if (test_and_clear_bit(index, &line6pcm->out.unlink_urbs)) shutdown = 1; - spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags); + spin_unlock_irqrestore(&line6pcm->out.lock, flags); if (!shutdown) { submit_audio_out_urb(line6pcm); if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags)) { - line6pcm->bytes_out += length; - if (line6pcm->bytes_out >= line6pcm->period_out) { - line6pcm->bytes_out %= line6pcm->period_out; + line6pcm->out.bytes += length; + if (line6pcm->out.bytes >= line6pcm->out.period) { + line6pcm->out.bytes %= line6pcm->out.period; snd_pcm_period_elapsed(substream); } } @@ -457,7 +457,7 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream, return ret; } - line6pcm->period_out = params_period_bytes(hw_params); + line6pcm->out.period = params_period_bytes(hw_params); return 0; } @@ -517,7 +517,7 @@ snd_line6_playback_pointer(struct snd_pcm_substream *substream) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - return line6pcm->pos_out_done; + return line6pcm->out.pos_done; } /* playback operators */ @@ -542,7 +542,7 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) struct urb *urb; /* URB for audio out: */ - urb = line6pcm->urb_audio_out[i] = + urb = line6pcm->out.urbs[i] = usb_alloc_urb(LINE6_ISO_PACKETS, GFP_KERNEL); if (urb == NULL) -- cgit From d8131e67f08bc15e54104cb69deb06bad9d87f30 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 16:18:42 +0100 Subject: ALSA: line6: Consolidate URB unlink and sync helpers The codes to unlink and sync URBs are identical for both playback and capture streams. Consolidate to single helper functions. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 52 --------------------------- sound/usb/line6/capture.h | 4 --- sound/usb/line6/pcm.c | 90 +++++++++++++++++++++++++++++++++++----------- sound/usb/line6/playback.c | 52 --------------------------- sound/usb/line6/playback.h | 4 --- 5 files changed, 69 insertions(+), 133 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 439f1941eb56..1d477d7a42fb 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -84,58 +84,6 @@ int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm) return 0; } -/* - Unlink all currently active capture URBs. -*/ -void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm) -{ - unsigned int i; - - for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (test_bit(i, &line6pcm->in.active_urbs)) { - if (!test_and_set_bit(i, &line6pcm->in.unlink_urbs)) { - struct urb *u = line6pcm->in.urbs[i]; - - usb_unlink_urb(u); - } - } - } -} - -/* - Wait until unlinking of all currently active capture URBs has been - finished. -*/ -void line6_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) -{ - int timeout = HZ; - unsigned int i; - int alive; - - do { - alive = 0; - for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (test_bit(i, &line6pcm->in.active_urbs)) - alive++; - } - if (!alive) - break; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } while (--timeout > 0); - if (alive) - snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive); -} - -/* - Unlink all currently active capture URBs, and wait for finishing. -*/ -void line6_unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm) -{ - line6_unlink_audio_in_urbs(line6pcm); - line6_wait_clear_audio_in_urbs(line6pcm); -} - /* Copy data into ALSA capture buffer. */ diff --git a/sound/usb/line6/capture.h b/sound/usb/line6/capture.h index 0939f400a405..3cc71bc70b21 100644 --- a/sound/usb/line6/capture.h +++ b/sound/usb/line6/capture.h @@ -26,10 +26,6 @@ extern void line6_capture_check_period(struct snd_line6_pcm *line6pcm, extern int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm); extern void line6_free_capture_buffer(struct snd_line6_pcm *line6pcm); extern int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm); -extern void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm); -extern void line6_unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm - *line6pcm); -extern void line6_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm); extern int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd); #endif diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 738bfd82cecd..677419dcacf9 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -90,6 +90,47 @@ static int snd_line6_impulse_period_put(struct snd_kcontrol *kcontrol, return 1; } +/* + Unlink all currently active URBs. +*/ +static void line6_unlink_audio_urbs(struct snd_line6_pcm *line6pcm, + struct line6_pcm_stream *pcms) +{ + int i; + + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { + if (test_bit(i, &pcms->active_urbs)) { + if (!test_and_set_bit(i, &pcms->unlink_urbs)) + usb_unlink_urb(pcms->urbs[i]); + } + } +} + +/* + Wait until unlinking of all currently active URBs has been finished. +*/ +static void line6_wait_clear_audio_urbs(struct snd_line6_pcm *line6pcm, + struct line6_pcm_stream *pcms) +{ + int timeout = HZ; + int i; + int alive; + + do { + alive = 0; + for (i = 0; i < LINE6_ISO_BUFFERS; i++) { + if (test_bit(i, &pcms->active_urbs)) + alive++; + } + if (!alive) + break; + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); + } while (--timeout > 0); + if (alive) + snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive); +} + static bool test_flags(unsigned long flags0, unsigned long flags1, unsigned long mask) { @@ -202,18 +243,18 @@ int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old); if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_STREAM)) - line6_unlink_audio_in_urbs(line6pcm); + line6_unlink_audio_urbs(line6pcm, &line6pcm->in); if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_BUFFER)) { - line6_wait_clear_audio_in_urbs(line6pcm); + line6_wait_clear_audio_urbs(line6pcm, &line6pcm->in); line6_free_capture_buffer(line6pcm); } if (test_flags(flags_new, flags_old, LINE6_BITS_PLAYBACK_STREAM)) - line6_unlink_audio_out_urbs(line6pcm); + line6_unlink_audio_urbs(line6pcm, &line6pcm->out); if (test_flags(flags_new, flags_old, LINE6_BITS_PLAYBACK_BUFFER)) { - line6_wait_clear_audio_out_urbs(line6pcm); + line6_wait_clear_audio_urbs(line6pcm, &line6pcm->out); line6_free_playback_buffer(line6pcm); } @@ -325,21 +366,24 @@ static struct snd_kcontrol_new line6_controls[] = { /* Cleanup the PCM device. */ -static void line6_cleanup_pcm(struct snd_pcm *pcm) +static void cleanup_urbs(struct line6_pcm_stream *pcms) { int i; - struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm); for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (line6pcm->out.urbs[i]) { - usb_kill_urb(line6pcm->out.urbs[i]); - usb_free_urb(line6pcm->out.urbs[i]); - } - if (line6pcm->in.urbs[i]) { - usb_kill_urb(line6pcm->in.urbs[i]); - usb_free_urb(line6pcm->in.urbs[i]); + if (pcms->urbs[i]) { + usb_kill_urb(pcms->urbs[i]); + usb_free_urb(pcms->urbs[i]); } } +} + +static void line6_cleanup_pcm(struct snd_pcm *pcm) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm); + + cleanup_urbs(&line6pcm->out); + cleanup_urbs(&line6pcm->in); kfree(line6pcm); } @@ -374,8 +418,10 @@ static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret) */ void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm) { - line6_unlink_wait_clear_audio_out_urbs(line6pcm); - line6_unlink_wait_clear_audio_in_urbs(line6pcm); + line6_unlink_audio_urbs(line6pcm, &line6pcm->out); + line6_unlink_audio_urbs(line6pcm, &line6pcm->in); + line6_wait_clear_audio_urbs(line6pcm, &line6pcm->out); + line6_wait_clear_audio_urbs(line6pcm, &line6pcm->in); } /* @@ -451,15 +497,17 @@ int snd_line6_prepare(struct snd_pcm_substream *substream) switch (substream->stream) { case SNDRV_PCM_STREAM_PLAYBACK: - if ((line6pcm->flags & LINE6_BITS_PLAYBACK_STREAM) == 0) - line6_unlink_wait_clear_audio_out_urbs(line6pcm); - + if ((line6pcm->flags & LINE6_BITS_PLAYBACK_STREAM) == 0) { + line6_unlink_audio_urbs(line6pcm, &line6pcm->out); + line6_wait_clear_audio_urbs(line6pcm, &line6pcm->out); + } break; case SNDRV_PCM_STREAM_CAPTURE: - if ((line6pcm->flags & LINE6_BITS_CAPTURE_STREAM) == 0) - line6_unlink_wait_clear_audio_in_urbs(line6pcm); - + if ((line6pcm->flags & LINE6_BITS_CAPTURE_STREAM) == 0) { + line6_unlink_audio_urbs(line6pcm, &line6pcm->in); + line6_wait_clear_audio_urbs(line6pcm, &line6pcm->in); + } break; } diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index d619c1718306..3820ed08b342 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -290,58 +290,6 @@ int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm) return 0; } -/* - Unlink all currently active playback URBs. -*/ -void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm) -{ - unsigned int i; - - for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (test_bit(i, &line6pcm->out.active_urbs)) { - if (!test_and_set_bit(i, &line6pcm->out.unlink_urbs)) { - struct urb *u = line6pcm->out.urbs[i]; - - usb_unlink_urb(u); - } - } - } -} - -/* - Wait until unlinking of all currently active playback URBs has been - finished. -*/ -void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) -{ - int timeout = HZ; - unsigned int i; - int alive; - - do { - alive = 0; - for (i = 0; i < LINE6_ISO_BUFFERS; i++) { - if (test_bit(i, &line6pcm->out.active_urbs)) - alive++; - } - if (!alive) - break; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } while (--timeout > 0); - if (alive) - snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive); -} - -/* - Unlink all currently active playback URBs, and wait for finishing. -*/ -void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm) -{ - line6_unlink_audio_out_urbs(line6pcm); - line6_wait_clear_audio_out_urbs(line6pcm); -} - void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm) { kfree(line6pcm->out.buffer); diff --git a/sound/usb/line6/playback.h b/sound/usb/line6/playback.h index 78a885113221..52a278353d3b 100644 --- a/sound/usb/line6/playback.h +++ b/sound/usb/line6/playback.h @@ -32,10 +32,6 @@ extern struct snd_pcm_ops snd_line6_playback_ops; extern int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm); extern void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm); extern int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm); -extern void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm); -extern void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm - *line6pcm); -extern void line6_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm); extern int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd); #endif -- cgit From ccaac9ed79c6051733f781a1cd639d488696f512 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 16:20:50 +0100 Subject: ALSA: line6: Use dev_err() This is the last remaining snd_printk() usage in this driver. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 677419dcacf9..4152d92105b1 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -128,7 +128,8 @@ static void line6_wait_clear_audio_urbs(struct snd_line6_pcm *line6pcm, schedule_timeout(1); } while (--timeout > 0); if (alive) - snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive); + dev_err(line6pcm->line6->ifcdev, + "timeout: still %d active urbs..\n", alive); } static bool test_flags(unsigned long flags0, unsigned long flags1, -- cgit From e90576c5955c83cd7e8c191b47f70d1946015041 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 16:25:03 +0100 Subject: ALSA: line6: Consolidate PCM stream buffer allocation and free The PCM stream buffer allocation and free are identical for both playback and capture streams. Provide single helper functions. These are used only in pcm.c, thus they can be even static. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 6 ------ sound/usb/line6/capture.h | 1 - sound/usb/line6/pcm.c | 53 +++++++++++++++++++++++++--------------------- sound/usb/line6/playback.c | 6 ------ sound/usb/line6/playback.h | 1 - 5 files changed, 29 insertions(+), 38 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 1d477d7a42fb..47cfcc2ab387 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -141,12 +141,6 @@ void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length) } } -void line6_free_capture_buffer(struct snd_line6_pcm *line6pcm) -{ - kfree(line6pcm->in.buffer); - line6pcm->in.buffer = NULL; -} - /* * Callback for completed capture URB. */ diff --git a/sound/usb/line6/capture.h b/sound/usb/line6/capture.h index 3cc71bc70b21..db062e7200a6 100644 --- a/sound/usb/line6/capture.h +++ b/sound/usb/line6/capture.h @@ -24,7 +24,6 @@ extern void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, extern void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length); extern int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm); -extern void line6_free_capture_buffer(struct snd_line6_pcm *line6pcm); extern int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm); extern int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd); diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 4152d92105b1..f75825995e24 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -132,6 +132,27 @@ static void line6_wait_clear_audio_urbs(struct snd_line6_pcm *line6pcm, "timeout: still %d active urbs..\n", alive); } +static int line6_alloc_stream_buffer(struct snd_line6_pcm *line6pcm, + struct line6_pcm_stream *pcms) +{ + /* Invoked multiple times in a row so allocate once only */ + if (pcms->buffer) + return 0; + + pcms->buffer = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * + line6pcm->max_packet_size, GFP_KERNEL); + if (!pcms->buffer) + return -ENOMEM; + return 0; +} + +static void line6_free_stream_buffer(struct snd_line6_pcm *line6pcm, + struct line6_pcm_stream *pcms) +{ + kfree(pcms->buffer); + pcms->buffer = NULL; +} + static bool test_flags(unsigned long flags0, unsigned long flags1, unsigned long mask) { @@ -153,17 +174,9 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) line6pcm->prev_fbuf = NULL; if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_BUFFER)) { - /* Invoked multiple times in a row so allocate once only */ - if (!line6pcm->in.buffer) { - line6pcm->in.buffer = - kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * - line6pcm->max_packet_size, GFP_KERNEL); - if (!line6pcm->in.buffer) { - err = -ENOMEM; - goto pcm_acquire_error; - } - } - + err = line6_alloc_stream_buffer(line6pcm, &line6pcm->in); + if (err < 0) + goto pcm_acquire_error; flags_final |= channels & LINE6_BITS_CAPTURE_BUFFER; } @@ -190,17 +203,9 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) } if (test_flags(flags_old, flags_new, LINE6_BITS_PLAYBACK_BUFFER)) { - /* Invoked multiple times in a row so allocate once only */ - if (!line6pcm->out.buffer) { - line6pcm->out.buffer = - kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * - line6pcm->max_packet_size, GFP_KERNEL); - if (!line6pcm->out.buffer) { - err = -ENOMEM; - goto pcm_acquire_error; - } - } - + err = line6_alloc_stream_buffer(line6pcm, &line6pcm->out); + if (err < 0) + goto pcm_acquire_error; flags_final |= channels & LINE6_BITS_PLAYBACK_BUFFER; } @@ -248,7 +253,7 @@ int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_BUFFER)) { line6_wait_clear_audio_urbs(line6pcm, &line6pcm->in); - line6_free_capture_buffer(line6pcm); + line6_free_stream_buffer(line6pcm, &line6pcm->in); } if (test_flags(flags_new, flags_old, LINE6_BITS_PLAYBACK_STREAM)) @@ -256,7 +261,7 @@ int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) if (test_flags(flags_new, flags_old, LINE6_BITS_PLAYBACK_BUFFER)) { line6_wait_clear_audio_urbs(line6pcm, &line6pcm->out); - line6_free_playback_buffer(line6pcm); + line6_free_stream_buffer(line6pcm, &line6pcm->out); } return 0; diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 3820ed08b342..750d91dced57 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -290,12 +290,6 @@ int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm) return 0; } -void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm) -{ - kfree(line6pcm->out.buffer); - line6pcm->out.buffer = NULL; -} - /* Callback for completed playback URB. */ diff --git a/sound/usb/line6/playback.h b/sound/usb/line6/playback.h index 52a278353d3b..f6a9e18f87b6 100644 --- a/sound/usb/line6/playback.h +++ b/sound/usb/line6/playback.h @@ -30,7 +30,6 @@ extern struct snd_pcm_ops snd_line6_playback_ops; extern int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm); -extern void line6_free_playback_buffer(struct snd_line6_pcm *line6pcm); extern int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm); extern int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd); -- cgit From c8491535d7f1a1e8f7f3e0d31e8f7525809c98a1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 16:54:36 +0100 Subject: ALSA: line6: Do clipping in volume / monitor manipulations Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/playback.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 750d91dced57..cbcd97f5d629 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -37,7 +37,8 @@ static void change_volume(struct urb *urb_out, int volume[], buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); for (; p < buf_end; ++p) { - *p = (*p * volume[chn & 1]) >> 8; + int val = (*p * volume[chn & 1]) >> 8; + *p = clamp(val, 0x7fff, -0x8000); ++chn; } } else if (bytes_per_frame == 6) { @@ -51,6 +52,7 @@ static void change_volume(struct urb *urb_out, int volume[], val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16); val = (val * volume[chn & 1]) >> 8; + val = clamp(val, 0x7fffff, -0x800000); p[0] = val; p[1] = val >> 8; p[2] = val >> 16; @@ -118,8 +120,10 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal, po = (short *)urb_out->transfer_buffer; buf_end = po + urb_out->transfer_buffer_length / sizeof(*po); - for (; po < buf_end; ++pi, ++po) - *po += (*pi * volume) >> 8; + for (; po < buf_end; ++pi, ++po) { + int val = *po + ((*pi * volume) >> 8); + *po = clamp(val, 0x7fff, -0x8000); + } } /* -- cgit From 62a109d9e2ce948ee75222bbb92a97669f683875 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Jan 2015 16:58:30 +0100 Subject: ALSA: line6: Skip volume manipulation during silence copying A minor optimization; while pausing, the driver just copies the zero that doesn't need any volume changes. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/playback.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index cbcd97f5d629..3762a98026aa 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -234,13 +234,14 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) line6pcm->out.pos += urb_frames; if (line6pcm->out.pos >= runtime->buffer_size) line6pcm->out.pos -= runtime->buffer_size; + + change_volume(urb_out, line6pcm->volume_playback, + bytes_per_frame); } else { memset(urb_out->transfer_buffer, 0, urb_out->transfer_buffer_length); } - change_volume(urb_out, line6pcm->volume_playback, bytes_per_frame); - if (line6pcm->prev_fbuf != NULL) { if (line6pcm->flags & LINE6_BITS_PCM_IMPULSE) { create_impulse_test_signal(line6pcm, urb_out, -- cgit From f66fd990c5db177d6b9f0eae301ca6b15882eb2e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 25 Jan 2015 18:22:58 +0100 Subject: ALSA: line6: Drop interface argument from private_init and disconnect callbacks The interface argument is used just for retrieving the assigned device, which can be already found in line6->ifcdev. Drop them from the callbacks. Also, pass the usb id to private_init so that the driver can deal with it there. This is a preliminary work for the further cleanup to move the whole allocation into driver.c. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 9 +++++---- sound/usb/line6/driver.h | 6 ++++-- sound/usb/line6/pod.c | 14 +++++++------- sound/usb/line6/podhd.c | 6 +++--- sound/usb/line6/toneport.c | 14 +++++++------- sound/usb/line6/variax.c | 12 +++++------- 6 files changed, 31 insertions(+), 30 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 4d2d233d0505..e2fbff05c1b1 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -488,9 +488,10 @@ static int line6_init_cap_control(struct usb_line6 *line6) Probe USB device. */ int line6_probe(struct usb_interface *interface, + const struct usb_device_id *id, struct usb_line6 *line6, const struct line6_properties *properties, - int (*private_init)(struct usb_interface *, struct usb_line6 *)) + int (*private_init)(struct usb_line6 *, const struct usb_device_id *id)) { struct usb_device *usbdev = interface_to_usbdev(interface); struct snd_card *card; @@ -552,7 +553,7 @@ int line6_probe(struct usb_interface *interface, } /* initialize device data based on device: */ - ret = private_init(interface, line6); + ret = private_init(line6, id); if (ret < 0) goto error; @@ -565,7 +566,7 @@ int line6_probe(struct usb_interface *interface, error: if (line6->disconnect) - line6->disconnect(interface); + line6->disconnect(line6); snd_card_free(card); return ret; } @@ -592,7 +593,7 @@ void line6_disconnect(struct usb_interface *interface) if (line6->line6pcm) line6_pcm_disconnect(line6->line6pcm); if (line6->disconnect) - line6->disconnect(interface); + line6->disconnect(line6); dev_info(&interface->dev, "Line 6 %s now disconnected\n", line6->properties->name); diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index a6c0b2f08ba8..4dc6c28e8224 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -157,7 +157,7 @@ struct usb_line6 { int message_length; void (*process_message)(struct usb_line6 *); - void (*disconnect)(struct usb_interface *); + void (*disconnect)(struct usb_line6 *line6); }; extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, @@ -180,9 +180,11 @@ extern int line6_write_data(struct usb_line6 *line6, int address, void *data, size_t datalen); int line6_probe(struct usb_interface *interface, + const struct usb_device_id *id, struct usb_line6 *line6, const struct line6_properties *properties, - int (*private_init)(struct usb_interface *, struct usb_line6 *)); + int (*private_init)(struct usb_line6 *, const struct usb_device_id *id)); + void line6_disconnect(struct usb_interface *interface); #ifdef CONFIG_PM diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 26ecf26a33ec..d1e952fbcae7 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -399,10 +399,10 @@ static struct snd_kcontrol_new pod_control_monitor = { /* POD device disconnected. */ -static void line6_pod_disconnect(struct usb_interface *interface) +static void line6_pod_disconnect(struct usb_line6 *line6) { - struct usb_line6_pod *pod = usb_get_intfdata(interface); - struct device *dev = &interface->dev; + struct usb_line6_pod *pod = (struct usb_line6_pod *)line6; + struct device *dev = line6->ifcdev; /* remove sysfs entries: */ device_remove_file(dev, &dev_attr_device_id); @@ -435,8 +435,8 @@ static int pod_create_files2(struct device *dev) /* Try to init POD device. */ -static int pod_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int pod_init(struct usb_line6 *line6, + const struct usb_device_id *id) { int err; struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; @@ -448,7 +448,7 @@ static int pod_init(struct usb_interface *interface, INIT_WORK(&pod->startup_work, pod_startup4); /* create sysfs entries: */ - err = pod_create_files2(&interface->dev); + err = pod_create_files2(line6->ifcdev); if (err < 0) return err; @@ -596,7 +596,7 @@ static int pod_probe(struct usb_interface *interface, pod = kzalloc(sizeof(*pod), GFP_KERNEL); if (!pod) return -ENODEV; - return line6_probe(interface, &pod->line6, + return line6_probe(interface, id, &pod->line6, &pod_properties_table[id->driver_info], pod_init); } diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 59abbd92624e..21d7edcfa272 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -87,8 +87,8 @@ static struct line6_pcm_properties podhd_pcm_properties = { /* Try to init POD HD device. */ -static int podhd_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int podhd_init(struct usb_line6 *line6, + const struct usb_device_id *id) { int err; @@ -182,7 +182,7 @@ static int podhd_probe(struct usb_interface *interface, podhd = kzalloc(sizeof(*podhd), GFP_KERNEL); if (!podhd) return -ENODEV; - return line6_probe(interface, &podhd->line6, + return line6_probe(interface, id, &podhd->line6, &podhd_properties_table[id->driver_info], podhd_init); } diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 9a769463f7bf..8e7020df0d10 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -387,11 +387,11 @@ static void toneport_setup(struct usb_line6_toneport *toneport) /* Toneport device disconnected. */ -static void line6_toneport_disconnect(struct usb_interface *interface) +static void line6_toneport_disconnect(struct usb_line6 *line6) { - struct usb_line6_toneport *toneport; + struct usb_line6_toneport *toneport = + (struct usb_line6_toneport *)line6; - toneport = usb_get_intfdata(interface); del_timer_sync(&toneport->timer); if (toneport_has_led(toneport->type)) @@ -402,12 +402,13 @@ static void line6_toneport_disconnect(struct usb_interface *interface) /* Try to init Toneport device. */ -static int toneport_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int toneport_init(struct usb_line6 *line6, + const struct usb_device_id *id) { int err; struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; + toneport->type = id->driver_info; setup_timer(&toneport->timer, toneport_start_pcm, (unsigned long)toneport); @@ -562,8 +563,7 @@ static int toneport_probe(struct usb_interface *interface, toneport = kzalloc(sizeof(*toneport), GFP_KERNEL); if (!toneport) return -ENODEV; - toneport->type = id->driver_info; - return line6_probe(interface, &toneport->line6, + return line6_probe(interface, id, &toneport->line6, &toneport_properties_table[id->driver_info], toneport_init); } diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index cd3adeffde02..ba6e85eed2ba 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -210,11 +210,9 @@ static void line6_variax_process_message(struct usb_line6 *line6) /* Variax destructor. */ -static void line6_variax_disconnect(struct usb_interface *interface) +static void line6_variax_disconnect(struct usb_line6 *line6) { - struct usb_line6_variax *variax; - - variax = usb_get_intfdata(interface); + struct usb_line6_variax *variax = (struct usb_line6_variax *)line6; del_timer(&variax->startup_timer1); del_timer(&variax->startup_timer2); @@ -226,8 +224,8 @@ static void line6_variax_disconnect(struct usb_interface *interface) /* Try to init workbench device. */ -static int variax_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int variax_init(struct usb_line6 *line6, + const struct usb_device_id *id) { struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; int err; @@ -303,7 +301,7 @@ static int variax_probe(struct usb_interface *interface, variax = kzalloc(sizeof(*variax), GFP_KERNEL); if (!variax) return -ENODEV; - return line6_probe(interface, &variax->line6, + return line6_probe(interface, id, &variax->line6, &variax_properties_table[id->driver_info], variax_init); } -- cgit From aca514b82356dcc3575da33453382bd27593aea1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 25 Jan 2015 18:36:29 +0100 Subject: ALSA: line6: Let snd_card_new() allocate private data Instead of allocating the private data individually in each driver's probe at first, let snd_card_new() allocate the data that is called in line6_probe(). This simplifies the primary probe functions. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 25 ++++++++++--------------- sound/usb/line6/driver.h | 4 ++-- sound/usb/line6/pod.c | 9 ++------- sound/usb/line6/podhd.c | 9 ++------- sound/usb/line6/toneport.c | 9 ++------- sound/usb/line6/variax.c | 9 ++------- 6 files changed, 20 insertions(+), 45 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index e2fbff05c1b1..c696f9773cbb 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -418,11 +418,7 @@ EXPORT_SYMBOL_GPL(line6_read_serial_number); static void line6_destruct(struct snd_card *card) { struct usb_line6 *line6 = card->private_data; - struct usb_device *usbdev; - - if (!line6) - return; - usbdev = line6->usbdev; + struct usb_device *usbdev = line6->usbdev; /* free buffer memory first: */ kfree(line6->buffer_message); @@ -431,9 +427,6 @@ static void line6_destruct(struct snd_card *card) /* then free URBs: */ usb_free_urb(line6->urb_listen); - /* free interface data: */ - kfree(line6); - /* decrement reference counters: */ usb_put_dev(usbdev); } @@ -489,24 +482,27 @@ static int line6_init_cap_control(struct usb_line6 *line6) */ int line6_probe(struct usb_interface *interface, const struct usb_device_id *id, - struct usb_line6 *line6, const struct line6_properties *properties, - int (*private_init)(struct usb_line6 *, const struct usb_device_id *id)) + int (*private_init)(struct usb_line6 *, const struct usb_device_id *id), + size_t data_size) { struct usb_device *usbdev = interface_to_usbdev(interface); struct snd_card *card; + struct usb_line6 *line6; int interface_number; int ret; + if (WARN_ON(data_size < sizeof(*line6))) + return -EINVAL; + ret = snd_card_new(&interface->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, - THIS_MODULE, 0, &card); - if (ret < 0) { - kfree(line6); + THIS_MODULE, data_size, &card); + if (ret < 0) return ret; - } /* store basic data: */ + line6 = card->private_data; line6->card = card; line6->properties = properties; line6->usbdev = usbdev; @@ -517,7 +513,6 @@ int line6_probe(struct usb_interface *interface, strcpy(card->shortname, line6->properties->name); sprintf(card->longname, "Line 6 %s at USB %s", line6->properties->name, dev_name(line6->ifcdev)); - card->private_data = line6; card->private_free = line6_destruct; usb_set_intfdata(interface, line6); diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index 4dc6c28e8224..fce10f12f0d3 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -181,9 +181,9 @@ extern int line6_write_data(struct usb_line6 *line6, int address, void *data, int line6_probe(struct usb_interface *interface, const struct usb_device_id *id, - struct usb_line6 *line6, const struct line6_properties *properties, - int (*private_init)(struct usb_line6 *, const struct usb_device_id *id)); + int (*private_init)(struct usb_line6 *, const struct usb_device_id *id), + size_t data_size); void line6_disconnect(struct usb_interface *interface); diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index d1e952fbcae7..6f7cd585f2d8 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -591,14 +591,9 @@ static const struct line6_properties pod_properties_table[] = { static int pod_probe(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_line6_pod *pod; - - pod = kzalloc(sizeof(*pod), GFP_KERNEL); - if (!pod) - return -ENODEV; - return line6_probe(interface, id, &pod->line6, + return line6_probe(interface, id, &pod_properties_table[id->driver_info], - pod_init); + pod_init, sizeof(struct usb_line6_pod)); } static struct usb_driver pod_driver = { diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 21d7edcfa272..43c39886597e 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -177,14 +177,9 @@ static const struct line6_properties podhd_properties_table[] = { static int podhd_probe(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_line6_podhd *podhd; - - podhd = kzalloc(sizeof(*podhd), GFP_KERNEL); - if (!podhd) - return -ENODEV; - return line6_probe(interface, id, &podhd->line6, + return line6_probe(interface, id, &podhd_properties_table[id->driver_info], - podhd_init); + podhd_init, sizeof(struct usb_line6_podhd)); } static struct usb_driver podhd_driver = { diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 8e7020df0d10..33d16ecf18a0 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -558,14 +558,9 @@ static const struct line6_properties toneport_properties_table[] = { static int toneport_probe(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_line6_toneport *toneport; - - toneport = kzalloc(sizeof(*toneport), GFP_KERNEL); - if (!toneport) - return -ENODEV; - return line6_probe(interface, id, &toneport->line6, + return line6_probe(interface, id, &toneport_properties_table[id->driver_info], - toneport_init); + toneport_init, sizeof(struct usb_line6_toneport)); } static struct usb_driver toneport_driver = { diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index ba6e85eed2ba..9701ffa61365 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -296,14 +296,9 @@ static const struct line6_properties variax_properties_table[] = { static int variax_probe(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_line6_variax *variax; - - variax = kzalloc(sizeof(*variax), GFP_KERNEL); - if (!variax) - return -ENODEV; - return line6_probe(interface, id, &variax->line6, + return line6_probe(interface, id, &variax_properties_table[id->driver_info], - variax_init); + variax_init, sizeof(struct usb_line6_variax)); } static struct usb_driver variax_driver = { -- cgit From d6ca69d82522cb0e59777deea3673c85c7db7f45 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 25 Jan 2015 18:41:26 +0100 Subject: ALSA: line6: Minor tidy up in line6_probe() Move the check of multi configurations before snd_card_new() as a short path, and reduce superfluous pointer references. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index c696f9773cbb..a0436993a167 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -495,6 +495,10 @@ int line6_probe(struct usb_interface *interface, if (WARN_ON(data_size < sizeof(*line6))) return -EINVAL; + /* we don't handle multiple configurations */ + if (usbdev->descriptor.bNumConfigurations != 1) + return -ENODEV; + ret = snd_card_new(&interface->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, THIS_MODULE, data_size, &card); @@ -508,10 +512,10 @@ int line6_probe(struct usb_interface *interface, line6->usbdev = usbdev; line6->ifcdev = &interface->dev; - strcpy(card->id, line6->properties->id); + strcpy(card->id, properties->id); strcpy(card->driver, DRIVER_NAME); - strcpy(card->shortname, line6->properties->name); - sprintf(card->longname, "Line 6 %s at USB %s", line6->properties->name, + strcpy(card->shortname, properties->name); + sprintf(card->longname, "Line 6 %s at USB %s", properties->name, dev_name(line6->ifcdev)); card->private_free = line6_destruct; @@ -520,12 +524,6 @@ int line6_probe(struct usb_interface *interface, /* increment reference counters: */ usb_get_dev(usbdev); - /* we don't handle multiple configurations */ - if (usbdev->descriptor.bNumConfigurations != 1) { - ret = -ENODEV; - goto error; - } - /* initialize device info: */ dev_info(&interface->dev, "Line 6 %s found\n", properties->name); @@ -533,7 +531,7 @@ int line6_probe(struct usb_interface *interface, interface_number = interface->cur_altsetting->desc.bInterfaceNumber; ret = usb_set_interface(usbdev, interface_number, - properties->altsetting); + properties->altsetting); if (ret < 0) { dev_err(&interface->dev, "set_interface failed\n"); goto error; @@ -555,7 +553,7 @@ int line6_probe(struct usb_interface *interface, /* creation of additional special files should go here */ dev_info(&interface->dev, "Line 6 %s now attached\n", - line6->properties->name); + properties->name); return 0; -- cgit From 3d3ae4454deb94bbad9ad0b2b559cbf6c0db4ec2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 27 Jan 2015 12:50:44 +0100 Subject: ALSA: line6: Fix racy loopback handling The impulse and monitor handling in submit_audio_out_urb() isn't protected thus this can be racy with the capture stream handling. This patch extends the range to protect via each stream's spinlock (now the whole submit_audio_*_urb() are covered), and take the capture stream lock additionally for the impulse and monitor handling part. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 20 +++++++++++--------- sound/usb/line6/playback.c | 24 +++++++++++++----------- 2 files changed, 24 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 47cfcc2ab387..21342a9dddd7 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -20,21 +20,19 @@ /* Find a free URB and submit it. + must be called in line6pcm->in.lock context */ static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) { int index; - unsigned long flags; int i, urb_size; int ret; struct urb *urb_in; - spin_lock_irqsave(&line6pcm->in.lock, flags); index = find_first_zero_bit(&line6pcm->in.active_urbs, LINE6_ISO_BUFFERS); if (index < 0 || index >= LINE6_ISO_BUFFERS) { - spin_unlock_irqrestore(&line6pcm->in.lock, flags); dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); return -EINVAL; } @@ -64,7 +62,6 @@ static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) dev_err(line6pcm->line6->ifcdev, "URB in #%d submission failed (%d)\n", index, ret); - spin_unlock_irqrestore(&line6pcm->in.lock, flags); return 0; } @@ -73,15 +70,18 @@ static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) */ int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm) { - int ret, i; + unsigned long flags; + int ret = 0, i; + spin_lock_irqsave(&line6pcm->in.lock, flags); for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { ret = submit_audio_in_urb(line6pcm); if (ret < 0) - return ret; + break; } - return 0; + spin_unlock_irqrestore(&line6pcm->in.lock, flags); + return ret; } /* @@ -137,7 +137,9 @@ void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length) line6pcm->in.bytes += length; if (line6pcm->in.bytes >= line6pcm->in.period) { line6pcm->in.bytes %= line6pcm->in.period; + spin_unlock(&line6pcm->in.lock); snd_pcm_period_elapsed(substream); + spin_lock(&line6pcm->in.lock); } } @@ -196,8 +198,6 @@ static void audio_in_callback(struct urb *urb) if (test_and_clear_bit(index, &line6pcm->in.unlink_urbs)) shutdown = 1; - spin_unlock_irqrestore(&line6pcm->in.lock, flags); - if (!shutdown) { submit_audio_in_urb(line6pcm); @@ -206,6 +206,8 @@ static void audio_in_callback(struct urb *urb) &line6pcm->flags)) line6_capture_check_period(line6pcm, length); } + + spin_unlock_irqrestore(&line6pcm->in.lock, flags); } /* open capture callback */ diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 3762a98026aa..b4a26d0c8267 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -134,11 +134,11 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal, /* Find a free URB, prepare audio data, and submit URB. + must be called in line6pcm->out.lock context */ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) { int index; - unsigned long flags; int i, urb_size, urb_frames; int ret; const int bytes_per_frame = line6pcm->properties->bytes_per_frame; @@ -149,12 +149,10 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) (USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL); struct urb *urb_out; - spin_lock_irqsave(&line6pcm->out.lock, flags); index = find_first_zero_bit(&line6pcm->out.active_urbs, LINE6_ISO_BUFFERS); if (index < 0 || index >= LINE6_ISO_BUFFERS) { - spin_unlock_irqrestore(&line6pcm->out.lock, flags); dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); return -EINVAL; } @@ -187,7 +185,6 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) if (urb_size == 0) { /* can't determine URB size */ - spin_unlock_irqrestore(&line6pcm->out.lock, flags); dev_err(line6pcm->line6->ifcdev, "driver bug: urb_size = 0\n"); return -EINVAL; } @@ -242,7 +239,8 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer_length); } - if (line6pcm->prev_fbuf != NULL) { + spin_lock_nested(&line6pcm->in.lock, SINGLE_DEPTH_NESTING); + if (line6pcm->prev_fbuf) { if (line6pcm->flags & LINE6_BITS_PCM_IMPULSE) { create_impulse_test_signal(line6pcm, urb_out, bytes_per_frame); @@ -266,6 +264,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) bytes_per_frame); } } + spin_unlock(&line6pcm->in.lock); ret = usb_submit_urb(urb_out, GFP_ATOMIC); @@ -275,7 +274,6 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) dev_err(line6pcm->line6->ifcdev, "URB out #%d submission failed (%d)\n", index, ret); - spin_unlock_irqrestore(&line6pcm->out.lock, flags); return 0; } @@ -284,15 +282,18 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) */ int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm) { - int ret, i; + unsigned long flags; + int ret = 0, i; + spin_lock_irqsave(&line6pcm->out.lock, flags); for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { ret = submit_audio_out_urb(line6pcm); if (ret < 0) - return ret; + break; } - return 0; + spin_unlock_irqrestore(&line6pcm->out.lock, flags); + return ret; } /* @@ -346,8 +347,6 @@ static void audio_out_callback(struct urb *urb) if (test_and_clear_bit(index, &line6pcm->out.unlink_urbs)) shutdown = 1; - spin_unlock_irqrestore(&line6pcm->out.lock, flags); - if (!shutdown) { submit_audio_out_urb(line6pcm); @@ -356,10 +355,13 @@ static void audio_out_callback(struct urb *urb) line6pcm->out.bytes += length; if (line6pcm->out.bytes >= line6pcm->out.period) { line6pcm->out.bytes %= line6pcm->out.period; + spin_unlock(&line6pcm->out.lock); snd_pcm_period_elapsed(substream); + spin_lock(&line6pcm->out.lock); } } } + spin_unlock_irqrestore(&line6pcm->out.lock, flags); } /* open playback callback */ -- cgit From f2bb614bb6c7f5245521195f144272ef93d9f086 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 27 Jan 2015 16:17:26 +0100 Subject: ALSA: line6: Clear prev_fbuf and prev_fsize properly Clearing prev_fsize in line6_pcm_acquire() is pretty racy. This can be called at any time while the stream is being played. Rather better to clear prev_fbuf and prev_fsize at the proper place like the stream stop for capture, and just after copying the monitor / impulse data inside the spinlock. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 8 ++++---- sound/usb/line6/playback.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index f75825995e24..dedbe24cbf60 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -171,8 +171,6 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) flags_final = 0; - line6pcm->prev_fbuf = NULL; - if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_BUFFER)) { err = line6_alloc_stream_buffer(line6pcm, &line6pcm->in); if (err < 0) @@ -193,7 +191,6 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) } line6pcm->in.count = 0; - line6pcm->prev_fsize = 0; err = line6_submit_audio_in_all_urbs(line6pcm); if (err < 0) @@ -248,8 +245,11 @@ int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) flags_new = flags_old & ~channels; } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old); - if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_STREAM)) + if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_STREAM)) { line6_unlink_audio_urbs(line6pcm, &line6pcm->in); + line6pcm->prev_fbuf = NULL; + line6pcm->prev_fsize = 0; + } if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_BUFFER)) { line6_wait_clear_audio_urbs(line6pcm, &line6pcm->in); diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index b4a26d0c8267..242265929145 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -166,9 +166,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) struct usb_iso_packet_descriptor *fout = &urb_out->iso_frame_desc[i]; - if (line6pcm->flags & LINE6_BITS_CAPTURE_STREAM) - fsize = line6pcm->prev_fsize; - + fsize = line6pcm->prev_fsize; if (fsize == 0) { int n; @@ -263,6 +261,8 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) line6pcm->volume_monitor, bytes_per_frame); } + line6pcm->prev_fbuf = NULL; + line6pcm->prev_fsize = 0; } spin_unlock(&line6pcm->in.lock); -- cgit From 63e20df1e5b2ef8d871ecbdb6c038d554ed1ca74 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 27 Jan 2015 15:24:09 +0100 Subject: ALSA: line6: Reorganize PCM stream handling The current code deals with the stream start / stop solely via line6_pcm_acquire() and line6_pcm_release(). This was (supposedly) intended to avoid the races, but it doesn't work as expected. The concurrent acquire and release calls can be performed without proper protections, thus this might result in memory corruption. Furthermore, we can't take a mutex to protect the whole function because it can be called from the PCM trigger callback that is an atomic context. Also spinlock isn't appropriate because the function allocates with kmalloc with GFP_KERNEL. That is, these function just lead to singular problems. This is an attempt to reduce the existing races. First off, separate both the stream buffer management and the stream URB management. The former is protected via a newly introduced state_mutex while the latter is protected via each line6_pcm_stream lock. Secondly, the stream state are now managed in opened and running bit flags of each line6_pcm_stream. Not only this a bit clearer than previous combined bit flags, this also gives a better abstraction. These rewrites allows us to make common hw_params and hw_free callbacks for both playback and capture directions. For the monitor and impulse operations, still line6_pcm_acquire() and line6_pcm_release() are used. They call internally the corresponding functions for both playback and capture streams with proper lock or mutex. Unlike the previous versions, these function don't take the bit masks but the only single type value. Also they are supposed to be applied only as duplex operations. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 88 ++---------- sound/usb/line6/capture.h | 1 - sound/usb/line6/pcm.c | 333 +++++++++++++++++++++++++-------------------- sound/usb/line6/pcm.h | 144 ++++++-------------- sound/usb/line6/playback.c | 104 ++------------ sound/usb/line6/playback.h | 1 - sound/usb/line6/toneport.c | 6 +- 7 files changed, 252 insertions(+), 425 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 21342a9dddd7..7b8186b6c0e4 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -67,20 +67,18 @@ static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm) /* Submit all currently available capture URBs. + must be called in line6pcm->in.lock context */ int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm) { - unsigned long flags; int ret = 0, i; - spin_lock_irqsave(&line6pcm->in.lock, flags); for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { ret = submit_audio_in_urb(line6pcm); if (ret < 0) break; } - spin_unlock_irqrestore(&line6pcm->in.lock, flags); return ret; } @@ -187,10 +185,10 @@ static void audio_in_callback(struct urb *urb) line6pcm->prev_fbuf = fbuf; line6pcm->prev_fsize = fsize; - if (!(line6pcm->flags & LINE6_BITS_PCM_IMPULSE)) - if (test_bit(LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM, - &line6pcm->flags) && (fsize > 0)) - line6_capture_copy(line6pcm, fbuf, fsize); + if (!test_bit(LINE6_STREAM_IMPULSE, &line6pcm->in.running) && + test_bit(LINE6_STREAM_PCM, &line6pcm->in.running) && + fsize > 0) + line6_capture_copy(line6pcm, fbuf, fsize); } clear_bit(index, &line6pcm->in.active_urbs); @@ -201,10 +199,9 @@ static void audio_in_callback(struct urb *urb) if (!shutdown) { submit_audio_in_urb(line6pcm); - if (!(line6pcm->flags & LINE6_BITS_PCM_IMPULSE)) - if (test_bit(LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM, - &line6pcm->flags)) - line6_capture_check_period(line6pcm, length); + if (!test_bit(LINE6_STREAM_IMPULSE, &line6pcm->in.running) && + test_bit(LINE6_STREAM_PCM, &line6pcm->in.running)) + line6_capture_check_period(line6pcm, length); } spin_unlock_irqrestore(&line6pcm->in.lock, flags); @@ -234,71 +231,6 @@ static int snd_line6_capture_close(struct snd_pcm_substream *substream) return 0; } -/* hw_params capture callback */ -static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - int ret; - struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - - ret = line6_pcm_acquire(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER); - - if (ret < 0) - return ret; - - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) { - line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER); - return ret; - } - - line6pcm->in.period = params_period_bytes(hw_params); - return 0; -} - -/* hw_free capture callback */ -static int snd_line6_capture_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - - line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER); - return snd_pcm_lib_free_pages(substream); -} - -/* trigger callback */ -int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd) -{ - int err; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - err = line6_pcm_acquire(line6pcm, - LINE6_BIT_PCM_ALSA_CAPTURE_STREAM); - - if (err < 0) - return err; - - break; - - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - err = line6_pcm_release(line6pcm, - LINE6_BIT_PCM_ALSA_CAPTURE_STREAM); - - if (err < 0) - return err; - - break; - - default: - return -EINVAL; - } - - return 0; -} - /* capture pointer callback */ static snd_pcm_uframes_t snd_line6_capture_pointer(struct snd_pcm_substream *substream) @@ -313,8 +245,8 @@ 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_capture_hw_params, - .hw_free = snd_line6_capture_hw_free, + .hw_params = snd_line6_hw_params, + .hw_free = snd_line6_hw_free, .prepare = snd_line6_prepare, .trigger = snd_line6_trigger, .pointer = snd_line6_capture_pointer, diff --git a/sound/usb/line6/capture.h b/sound/usb/line6/capture.h index db062e7200a6..890b21bff18c 100644 --- a/sound/usb/line6/capture.h +++ b/sound/usb/line6/capture.h @@ -25,6 +25,5 @@ extern void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length); extern int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm); extern int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm); -extern int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd); #endif diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index dedbe24cbf60..470fc1049d54 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -51,9 +51,9 @@ static int snd_line6_impulse_volume_put(struct snd_kcontrol *kcontrol, line6pcm->impulse_volume = value; if (value > 0) - line6_pcm_acquire(line6pcm, LINE6_BITS_PCM_IMPULSE); + line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE); else - line6_pcm_release(line6pcm, LINE6_BITS_PCM_IMPULSE); + line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE); return 1; } @@ -132,176 +132,226 @@ static void line6_wait_clear_audio_urbs(struct snd_line6_pcm *line6pcm, "timeout: still %d active urbs..\n", alive); } -static int line6_alloc_stream_buffer(struct snd_line6_pcm *line6pcm, - struct line6_pcm_stream *pcms) +static inline struct line6_pcm_stream * +get_stream(struct snd_line6_pcm *line6pcm, int direction) { - /* Invoked multiple times in a row so allocate once only */ - if (pcms->buffer) - return 0; - - pcms->buffer = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * - line6pcm->max_packet_size, GFP_KERNEL); - if (!pcms->buffer) - return -ENOMEM; - return 0; + return (direction == SNDRV_PCM_STREAM_PLAYBACK) ? + &line6pcm->out : &line6pcm->in; } -static void line6_free_stream_buffer(struct snd_line6_pcm *line6pcm, - struct line6_pcm_stream *pcms) +/* allocate a buffer if not opened yet; + * call this in line6pcm.state_change mutex + */ +static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm, + struct line6_pcm_stream *pstr, int type) { - kfree(pcms->buffer); - pcms->buffer = NULL; + /* Invoked multiple times in a row so allocate once only */ + if (!test_and_set_bit(type, &pstr->opened) && !pstr->buffer) { + pstr->buffer = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * + line6pcm->max_packet_size, GFP_KERNEL); + if (!pstr->buffer) + return -ENOMEM; + } + return 0; } -static bool test_flags(unsigned long flags0, unsigned long flags1, - unsigned long mask) +/* free a buffer if all streams are closed; + * call this in line6pcm.state_change mutex + */ +static void line6_buffer_release(struct snd_line6_pcm *line6pcm, + struct line6_pcm_stream *pstr, int type) { - return ((flags0 & mask) == 0) && ((flags1 & mask) != 0); + + clear_bit(type, &pstr->opened); + if (!pstr->opened) { + line6_wait_clear_audio_urbs(line6pcm, pstr); + kfree(pstr->buffer); + pstr->buffer = NULL; + } } -int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels) +/* start a PCM stream */ +static int line6_stream_start(struct snd_line6_pcm *line6pcm, int direction, + int type) { - unsigned long flags_old, flags_new, flags_final; - int err; - - do { - flags_old = ACCESS_ONCE(line6pcm->flags); - flags_new = flags_old | channels; - } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old); - - flags_final = 0; + unsigned long flags; + struct line6_pcm_stream *pstr = get_stream(line6pcm, direction); + int ret = 0; + + spin_lock_irqsave(&pstr->lock, flags); + if (!test_and_set_bit(type, &pstr->running)) { + if (pstr->active_urbs || pstr->unlink_urbs) { + ret = -EBUSY; + goto error; + } - if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_BUFFER)) { - err = line6_alloc_stream_buffer(line6pcm, &line6pcm->in); - if (err < 0) - goto pcm_acquire_error; - flags_final |= channels & LINE6_BITS_CAPTURE_BUFFER; + pstr->count = 0; + /* Submit all currently available URBs */ + if (direction == SNDRV_PCM_STREAM_PLAYBACK) + ret = line6_submit_audio_out_all_urbs(line6pcm); + else + ret = line6_submit_audio_in_all_urbs(line6pcm); } + error: + if (ret < 0) + clear_bit(type, &pstr->running); + spin_unlock_irqrestore(&pstr->lock, flags); + return ret; +} - if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_STREAM)) { - /* - Waiting for completion of active URBs in the stop handler is - a bug, we therefore report an error if capturing is restarted - too soon. - */ - if (line6pcm->in.active_urbs || line6pcm->in.unlink_urbs) { - dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); - err = -EBUSY; - goto pcm_acquire_error; +/* stop a PCM stream; this doesn't sync with the unlinked URBs */ +static void line6_stream_stop(struct snd_line6_pcm *line6pcm, int direction, + int type) +{ + unsigned long flags; + struct line6_pcm_stream *pstr = get_stream(line6pcm, direction); + + spin_lock_irqsave(&pstr->lock, flags); + clear_bit(type, &pstr->running); + if (!pstr->running) { + line6_unlink_audio_urbs(line6pcm, pstr); + if (direction == SNDRV_PCM_STREAM_CAPTURE) { + line6pcm->prev_fbuf = NULL; + line6pcm->prev_fsize = 0; } + } + spin_unlock_irqrestore(&pstr->lock, flags); +} - line6pcm->in.count = 0; - err = line6_submit_audio_in_all_urbs(line6pcm); +/* common PCM trigger callback */ +int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + struct snd_pcm_substream *s; + int err; - if (err < 0) - goto pcm_acquire_error; + clear_bit(LINE6_FLAG_PREPARED, &line6pcm->flags); - flags_final |= channels & LINE6_BITS_CAPTURE_STREAM; - } + snd_pcm_group_for_each_entry(s, substream) { + if (s->pcm->card != substream->pcm->card) + continue; - if (test_flags(flags_old, flags_new, LINE6_BITS_PLAYBACK_BUFFER)) { - err = line6_alloc_stream_buffer(line6pcm, &line6pcm->out); - if (err < 0) - goto pcm_acquire_error; - flags_final |= channels & LINE6_BITS_PLAYBACK_BUFFER; - } + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + err = line6_stream_start(line6pcm, s->stream, + LINE6_STREAM_PCM); + if (err < 0) + return err; + break; - if (test_flags(flags_old, flags_new, LINE6_BITS_PLAYBACK_STREAM)) { - /* - See comment above regarding PCM restart. - */ - if (line6pcm->out.active_urbs || line6pcm->out.unlink_urbs) { - dev_err(line6pcm->line6->ifcdev, "Device not yet ready\n"); - return -EBUSY; - } + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + line6_stream_stop(line6pcm, s->stream, + LINE6_STREAM_PCM); + break; - line6pcm->out.count = 0; - err = line6_submit_audio_out_all_urbs(line6pcm); + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + if (s->stream != SNDRV_PCM_STREAM_PLAYBACK) + return -EINVAL; + set_bit(LINE6_FLAG_PAUSE_PLAYBACK, &line6pcm->flags); + break; - if (err < 0) - goto pcm_acquire_error; + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + if (s->stream != SNDRV_PCM_STREAM_PLAYBACK) + return -EINVAL; + clear_bit(LINE6_FLAG_PAUSE_PLAYBACK, &line6pcm->flags); + break; - flags_final |= channels & LINE6_BITS_PLAYBACK_STREAM; + default: + return -EINVAL; + } } return 0; - -pcm_acquire_error: - /* - If not all requested resources/streams could be obtained, release - those which were successfully obtained (if any). - */ - line6_pcm_release(line6pcm, flags_final); - return err; } -EXPORT_SYMBOL_GPL(line6_pcm_acquire); -int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels) +/* Acquire and start duplex streams: + * type is either LINE6_STREAM_IMPULSE or LINE6_STREAM_MONITOR + */ +int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int type) { - unsigned long flags_old, flags_new; - - do { - flags_old = ACCESS_ONCE(line6pcm->flags); - flags_new = flags_old & ~channels; - } while (cmpxchg(&line6pcm->flags, flags_old, flags_new) != flags_old); - - if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_STREAM)) { - line6_unlink_audio_urbs(line6pcm, &line6pcm->in); - line6pcm->prev_fbuf = NULL; - line6pcm->prev_fsize = 0; + struct line6_pcm_stream *pstr; + int ret = 0, dir; + + mutex_lock(&line6pcm->state_mutex); + for (dir = 0; dir < 2; dir++) { + pstr = get_stream(line6pcm, dir); + ret = line6_buffer_acquire(line6pcm, pstr, type); + if (ret < 0) + goto error; + if (!pstr->running) + line6_wait_clear_audio_urbs(line6pcm, pstr); } - - if (test_flags(flags_new, flags_old, LINE6_BITS_CAPTURE_BUFFER)) { - line6_wait_clear_audio_urbs(line6pcm, &line6pcm->in); - line6_free_stream_buffer(line6pcm, &line6pcm->in); + for (dir = 0; dir < 2; dir++) { + ret = line6_stream_start(line6pcm, dir, type); + if (ret < 0) + goto error; } + error: + mutex_unlock(&line6pcm->state_mutex); + if (ret < 0) + line6_pcm_release(line6pcm, type); + return ret; +} +EXPORT_SYMBOL_GPL(line6_pcm_acquire); - if (test_flags(flags_new, flags_old, LINE6_BITS_PLAYBACK_STREAM)) - line6_unlink_audio_urbs(line6pcm, &line6pcm->out); - - if (test_flags(flags_new, flags_old, LINE6_BITS_PLAYBACK_BUFFER)) { - line6_wait_clear_audio_urbs(line6pcm, &line6pcm->out); - line6_free_stream_buffer(line6pcm, &line6pcm->out); +/* Stop and release duplex streams */ +void line6_pcm_release(struct snd_line6_pcm *line6pcm, int type) +{ + struct line6_pcm_stream *pstr; + int dir; + + mutex_lock(&line6pcm->state_mutex); + for (dir = 0; dir < 2; dir++) + line6_stream_stop(line6pcm, dir, type); + for (dir = 0; dir < 2; dir++) { + pstr = get_stream(line6pcm, dir); + line6_buffer_release(line6pcm, pstr, type); } - - return 0; + mutex_unlock(&line6pcm->state_mutex); } EXPORT_SYMBOL_GPL(line6_pcm_release); -/* trigger callback */ -int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) +/* common PCM hw_params callback */ +int snd_line6_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { + int ret; struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - struct snd_pcm_substream *s; - int err = 0; - - clear_bit(LINE6_INDEX_PREPARED, &line6pcm->flags); - - snd_pcm_group_for_each_entry(s, substream) { - if (s->pcm->card != substream->pcm->card) - continue; - switch (s->stream) { - case SNDRV_PCM_STREAM_PLAYBACK: - err = snd_line6_playback_trigger(line6pcm, cmd); - break; + struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream); + + mutex_lock(&line6pcm->state_mutex); + ret = line6_buffer_acquire(line6pcm, pstr, LINE6_STREAM_PCM); + 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; + } - case SNDRV_PCM_STREAM_CAPTURE: - err = snd_line6_capture_trigger(line6pcm, cmd); - break; + pstr->period = params_period_bytes(hw_params); + error: + mutex_unlock(&line6pcm->state_mutex); + return ret; +} - default: - dev_err(line6pcm->line6->ifcdev, - "Unknown stream direction %d\n", s->stream); - err = -EINVAL; - break; - } - if (err < 0) - break; - } +/* common PCM hw_free callback */ +int snd_line6_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream); - return err; + 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); } + /* control info callback */ static int snd_line6_control_playback_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) @@ -454,6 +504,7 @@ int line6_init_pcm(struct usb_line6 *line6, if (!line6pcm) return -ENOMEM; + mutex_init(&line6pcm->state_mutex); line6pcm->pcm = pcm; line6pcm->properties = properties; line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255; @@ -500,24 +551,13 @@ EXPORT_SYMBOL_GPL(line6_init_pcm); int snd_line6_prepare(struct snd_pcm_substream *substream) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream); - switch (substream->stream) { - case SNDRV_PCM_STREAM_PLAYBACK: - if ((line6pcm->flags & LINE6_BITS_PLAYBACK_STREAM) == 0) { - line6_unlink_audio_urbs(line6pcm, &line6pcm->out); - line6_wait_clear_audio_urbs(line6pcm, &line6pcm->out); - } - break; - - case SNDRV_PCM_STREAM_CAPTURE: - if ((line6pcm->flags & LINE6_BITS_CAPTURE_STREAM) == 0) { - line6_unlink_audio_urbs(line6pcm, &line6pcm->in); - line6_wait_clear_audio_urbs(line6pcm, &line6pcm->in); - } - break; - } + mutex_lock(&line6pcm->state_mutex); + if (!pstr->running) + line6_wait_clear_audio_urbs(line6pcm, pstr); - if (!test_and_set_bit(LINE6_INDEX_PREPARED, &line6pcm->flags)) { + if (!test_and_set_bit(LINE6_FLAG_PREPARED, &line6pcm->flags)) { line6pcm->out.count = 0; line6pcm->out.pos = 0; line6pcm->out.pos_done = 0; @@ -527,5 +567,6 @@ int snd_line6_prepare(struct snd_pcm_substream *substream) line6pcm->in.bytes = 0; } + mutex_unlock(&line6pcm->state_mutex); return 0; } diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index 4c74f4e85074..66f603dfa34e 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -54,109 +54,33 @@ However, from the device's point of view, there is just a single capture and playback stream, which must be shared between these subsystems. It is therefore necessary to maintain the state of the - subsystems with respect to PCM usage. We define several constants of - the form LINE6_BIT_PCM___ with the - following meanings: - *) is one of - -) ALSA: PCM playback and capture via ALSA - -) MONITOR: software monitoring - -) IMPULSE: optional impulse response measurement - *) is one of - -) PLAYBACK: audio output (from host to device) - -) CAPTURE: audio input (from device to host) - *) is one of - -) BUFFER: buffer required by PCM data stream - -) STREAM: actual PCM data stream - - The subsystems call line6_pcm_acquire() to acquire the (shared) - resources needed for a particular operation (e.g., allocate the buffer - for ALSA playback or start the capture stream for software monitoring). - When a resource is no longer needed, it is released by calling - line6_pcm_release(). Buffer allocation and stream startup are handled - separately to allow the ALSA kernel driver to perform them at - appropriate places (since the callback which starts a PCM stream is not - allowed to sleep). + subsystems with respect to PCM usage. + + We define two bit flags, "opened" and "running", for each playback + or capture stream. Both can contain the bit flag corresponding to + LINE6_STREAM_* type, + LINE6_STREAM_PCM = ALSA PCM playback or capture + LINE6_STREAM_MONITOR = software monitoring + IMPULSE = optional impulse response measurement + The opened flag indicates whether the buffer is allocated while + the running flag indicates whether the stream is running. + + For monitor or impulse operations, the driver needs to call + snd_line6_duplex_acquire() or snd_line6_duplex_release() with the + appropriate LINE6_STREAM_* flag. */ + +/* stream types */ +enum { + LINE6_STREAM_PCM, + LINE6_STREAM_MONITOR, + LINE6_STREAM_IMPULSE, +}; + +/* misc bit flags for PCM operation */ enum { - /* individual bit indices: */ - LINE6_INDEX_PCM_ALSA_PLAYBACK_BUFFER, - LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, - LINE6_INDEX_PCM_ALSA_CAPTURE_BUFFER, - LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM, - LINE6_INDEX_PCM_MONITOR_PLAYBACK_BUFFER, - LINE6_INDEX_PCM_MONITOR_PLAYBACK_STREAM, - LINE6_INDEX_PCM_MONITOR_CAPTURE_BUFFER, - LINE6_INDEX_PCM_MONITOR_CAPTURE_STREAM, - LINE6_INDEX_PCM_IMPULSE_PLAYBACK_BUFFER, - LINE6_INDEX_PCM_IMPULSE_PLAYBACK_STREAM, - LINE6_INDEX_PCM_IMPULSE_CAPTURE_BUFFER, - LINE6_INDEX_PCM_IMPULSE_CAPTURE_STREAM, - LINE6_INDEX_PAUSE_PLAYBACK, - LINE6_INDEX_PREPARED, - -#define LINE6_BIT(x) LINE6_BIT_ ## x = 1 << LINE6_INDEX_ ## x - - /* individual bit masks: */ - LINE6_BIT(PCM_ALSA_PLAYBACK_BUFFER), - LINE6_BIT(PCM_ALSA_PLAYBACK_STREAM), - LINE6_BIT(PCM_ALSA_CAPTURE_BUFFER), - LINE6_BIT(PCM_ALSA_CAPTURE_STREAM), - LINE6_BIT(PCM_MONITOR_PLAYBACK_BUFFER), - LINE6_BIT(PCM_MONITOR_PLAYBACK_STREAM), - LINE6_BIT(PCM_MONITOR_CAPTURE_BUFFER), - LINE6_BIT(PCM_MONITOR_CAPTURE_STREAM), - LINE6_BIT(PCM_IMPULSE_PLAYBACK_BUFFER), - LINE6_BIT(PCM_IMPULSE_PLAYBACK_STREAM), - LINE6_BIT(PCM_IMPULSE_CAPTURE_BUFFER), - LINE6_BIT(PCM_IMPULSE_CAPTURE_STREAM), - LINE6_BIT(PAUSE_PLAYBACK), - LINE6_BIT(PREPARED), - - /* combined bit masks (by operation): */ - LINE6_BITS_PCM_ALSA_BUFFER = - LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER | - LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER, - - LINE6_BITS_PCM_ALSA_STREAM = - LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM | - LINE6_BIT_PCM_ALSA_CAPTURE_STREAM, - - LINE6_BITS_PCM_MONITOR = - LINE6_BIT_PCM_MONITOR_PLAYBACK_BUFFER | - LINE6_BIT_PCM_MONITOR_PLAYBACK_STREAM | - LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER | - LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM, - - LINE6_BITS_PCM_IMPULSE = - LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER | - LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM | - LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER | - LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM, - - /* combined bit masks (by direction): */ - LINE6_BITS_PLAYBACK_BUFFER = - LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER | - LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER | - LINE6_BIT_PCM_MONITOR_PLAYBACK_BUFFER, - - LINE6_BITS_PLAYBACK_STREAM = - LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM | - LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM | - LINE6_BIT_PCM_MONITOR_PLAYBACK_STREAM, - - LINE6_BITS_CAPTURE_BUFFER = - LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER | - LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER | - LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER, - - LINE6_BITS_CAPTURE_STREAM = - LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM | - LINE6_BIT_PCM_ALSA_CAPTURE_STREAM | - LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM, - - LINE6_BITS_STREAM = - LINE6_BITS_PLAYBACK_STREAM | - LINE6_BITS_CAPTURE_STREAM + LINE6_FLAG_PAUSE_PLAYBACK, + LINE6_FLAG_PREPARED, }; struct line6_pcm_properties { @@ -205,6 +129,12 @@ struct line6_pcm_stream { */ spinlock_t lock; + /* Bit flags for operational stream types */ + unsigned long opened; + + /* Bit flags for running stream types */ + unsigned long running; + int last_frame; }; @@ -224,6 +154,9 @@ struct snd_line6_pcm { */ struct snd_pcm *pcm; + /* protection to state changes of in/out streams */ + struct mutex state_mutex; + /* Capture and playback streams */ struct line6_pcm_stream in; struct line6_pcm_stream out; @@ -269,7 +202,7 @@ struct snd_line6_pcm { int impulse_count; /** - Several status bits (see LINE6_BIT_*). + Several status bits (see LINE6_FLAG_*). */ unsigned long flags; }; @@ -278,8 +211,11 @@ extern int line6_init_pcm(struct usb_line6 *line6, struct line6_pcm_properties *properties); extern int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd); extern int snd_line6_prepare(struct snd_pcm_substream *substream); +extern int snd_line6_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params); +extern int snd_line6_hw_free(struct snd_pcm_substream *substream); extern void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm); -extern int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels); -extern int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels); +extern int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int type); +extern void line6_pcm_release(struct snd_line6_pcm *line6pcm, int type); #endif diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 242265929145..f8b04e2d36b3 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -194,8 +194,8 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer_length = urb_size; urb_out->context = line6pcm; - if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags) && - !test_bit(LINE6_INDEX_PAUSE_PLAYBACK, &line6pcm->flags)) { + if (test_bit(LINE6_STREAM_PCM, &line6pcm->out.running) && + !test_bit(LINE6_FLAG_PAUSE_PLAYBACK, &line6pcm->flags)) { struct snd_pcm_runtime *runtime = get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK)->runtime; @@ -239,11 +239,10 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) spin_lock_nested(&line6pcm->in.lock, SINGLE_DEPTH_NESTING); if (line6pcm->prev_fbuf) { - if (line6pcm->flags & LINE6_BITS_PCM_IMPULSE) { + if (test_bit(LINE6_STREAM_IMPULSE, &line6pcm->out.running)) { create_impulse_test_signal(line6pcm, urb_out, bytes_per_frame); - if (line6pcm->flags & - LINE6_BIT_PCM_ALSA_CAPTURE_STREAM) { + if (test_bit(LINE6_STREAM_PCM, &line6pcm->in.running)) { line6_capture_copy(line6pcm, urb_out->transfer_buffer, urb_out-> @@ -252,11 +251,8 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer_length); } } else { - if (! - (line6pcm->line6-> - properties->capabilities & LINE6_CAP_HWMON) - && (line6pcm->flags & LINE6_BITS_PLAYBACK_STREAM) - && (line6pcm->flags & LINE6_BITS_CAPTURE_STREAM)) + if (!(line6pcm->line6->properties->capabilities & LINE6_CAP_HWMON) + && line6pcm->out.running && line6pcm->in.running) add_monitor_signal(urb_out, line6pcm->prev_fbuf, line6pcm->volume_monitor, bytes_per_frame); @@ -279,20 +275,18 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) /* Submit all currently available playback URBs. -*/ + must be called in line6pcm->out.lock context + */ int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm) { - unsigned long flags; int ret = 0, i; - spin_lock_irqsave(&line6pcm->out.lock, flags); for (i = 0; i < LINE6_ISO_BUFFERS; ++i) { ret = submit_audio_out_urb(line6pcm); if (ret < 0) break; } - spin_unlock_irqrestore(&line6pcm->out.lock, flags); return ret; } @@ -326,7 +320,7 @@ static void audio_out_callback(struct urb *urb) spin_lock_irqsave(&line6pcm->out.lock, flags); - if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags)) { + if (test_bit(LINE6_STREAM_PCM, &line6pcm->out.running)) { struct snd_pcm_runtime *runtime = substream->runtime; line6pcm->out.pos_done += @@ -350,8 +344,7 @@ static void audio_out_callback(struct urb *urb) if (!shutdown) { submit_audio_out_urb(line6pcm); - if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, - &line6pcm->flags)) { + if (test_bit(LINE6_STREAM_PCM, &line6pcm->out.running)) { line6pcm->out.bytes += length; if (line6pcm->out.bytes >= line6pcm->out.period) { line6pcm->out.bytes %= line6pcm->out.period; @@ -387,79 +380,6 @@ static int snd_line6_playback_close(struct snd_pcm_substream *substream) return 0; } -/* hw_params playback callback */ -static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - int ret; - struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - - ret = line6_pcm_acquire(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER); - - if (ret < 0) - return ret; - - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) { - line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER); - return ret; - } - - line6pcm->out.period = params_period_bytes(hw_params); - return 0; -} - -/* hw_free playback callback */ -static int snd_line6_playback_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - - line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER); - return snd_pcm_lib_free_pages(substream); -} - -/* trigger playback callback */ -int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd) -{ - int err; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - err = line6_pcm_acquire(line6pcm, - LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM); - - if (err < 0) - return err; - - break; - - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - err = line6_pcm_release(line6pcm, - LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM); - - if (err < 0) - return err; - - break; - - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - set_bit(LINE6_INDEX_PAUSE_PLAYBACK, &line6pcm->flags); - break; - - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - clear_bit(LINE6_INDEX_PAUSE_PLAYBACK, &line6pcm->flags); - break; - - default: - return -EINVAL; - } - - return 0; -} - /* playback pointer callback */ static snd_pcm_uframes_t snd_line6_playback_pointer(struct snd_pcm_substream *substream) @@ -474,8 +394,8 @@ 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_playback_hw_params, - .hw_free = snd_line6_playback_hw_free, + .hw_params = snd_line6_hw_params, + .hw_free = snd_line6_hw_free, .prepare = snd_line6_prepare, .trigger = snd_line6_trigger, .pointer = snd_line6_playback_pointer, diff --git a/sound/usb/line6/playback.h b/sound/usb/line6/playback.h index f6a9e18f87b6..51fce29e8726 100644 --- a/sound/usb/line6/playback.h +++ b/sound/usb/line6/playback.h @@ -31,6 +31,5 @@ extern struct snd_pcm_ops snd_line6_playback_ops; extern int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm); extern int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm); -extern int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd); #endif diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 33d16ecf18a0..61fa6256d7b0 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -189,9 +189,9 @@ static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol, line6pcm->volume_monitor = ucontrol->value.integer.value[0]; if (line6pcm->volume_monitor > 0) - line6_pcm_acquire(line6pcm, LINE6_BITS_PCM_MONITOR); + line6_pcm_acquire(line6pcm, LINE6_STREAM_MONITOR); else - line6_pcm_release(line6pcm, LINE6_BITS_PCM_MONITOR); + line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR); return 1; } @@ -252,7 +252,7 @@ static void toneport_start_pcm(unsigned long arg) struct usb_line6_toneport *toneport = (struct usb_line6_toneport *)arg; struct usb_line6 *line6 = &toneport->line6; - line6_pcm_acquire(line6->line6pcm, LINE6_BITS_PCM_MONITOR); + line6_pcm_acquire(line6->line6pcm, LINE6_STREAM_MONITOR); } /* control definition */ -- cgit From 2954f914f2816738b800be7909b771f30bf6a856 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 27 Jan 2015 15:41:27 +0100 Subject: ALSA: line6: Make common PCM pointer callback Both playback and capture callbacks are identical, so let's merge them. Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 11 +---------- sound/usb/line6/pcm.c | 9 +++++++++ sound/usb/line6/pcm.h | 1 + sound/usb/line6/playback.c | 11 +---------- 4 files changed, 12 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 7b8186b6c0e4..4183c5f5edc2 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -231,15 +231,6 @@ static int snd_line6_capture_close(struct snd_pcm_substream *substream) return 0; } -/* capture pointer callback */ -static snd_pcm_uframes_t -snd_line6_capture_pointer(struct snd_pcm_substream *substream) -{ - struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - - return line6pcm->in.pos_done; -} - /* capture operators */ struct snd_pcm_ops snd_line6_capture_ops = { .open = snd_line6_capture_open, @@ -249,7 +240,7 @@ struct snd_pcm_ops snd_line6_capture_ops = { .hw_free = snd_line6_hw_free, .prepare = snd_line6_prepare, .trigger = snd_line6_trigger, - .pointer = snd_line6_capture_pointer, + .pointer = snd_line6_pointer, }; int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 470fc1049d54..73c87467d2e0 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -266,6 +266,15 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd) return 0; } +/* common PCM pointer callback */ +snd_pcm_uframes_t snd_line6_pointer(struct snd_pcm_substream *substream) +{ + struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream); + + return pstr->pos_done; +} + /* Acquire and start duplex streams: * type is either LINE6_STREAM_IMPULSE or LINE6_STREAM_MONITOR */ diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index 66f603dfa34e..42d3e6fc2c61 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -214,6 +214,7 @@ extern int snd_line6_prepare(struct snd_pcm_substream *substream); extern int snd_line6_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params); extern int snd_line6_hw_free(struct snd_pcm_substream *substream); +extern snd_pcm_uframes_t snd_line6_pointer(struct snd_pcm_substream *substream); extern void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm); extern int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int type); extern void line6_pcm_release(struct snd_line6_pcm *line6pcm, int type); diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index f8b04e2d36b3..1708c05f14db 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -380,15 +380,6 @@ static int snd_line6_playback_close(struct snd_pcm_substream *substream) return 0; } -/* playback pointer callback */ -static snd_pcm_uframes_t -snd_line6_playback_pointer(struct snd_pcm_substream *substream) -{ - struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); - - return line6pcm->out.pos_done; -} - /* playback operators */ struct snd_pcm_ops snd_line6_playback_ops = { .open = snd_line6_playback_open, @@ -398,7 +389,7 @@ struct snd_pcm_ops snd_line6_playback_ops = { .hw_free = snd_line6_hw_free, .prepare = snd_line6_prepare, .trigger = snd_line6_trigger, - .pointer = snd_line6_playback_pointer, + .pointer = snd_line6_pointer, }; int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) -- cgit From 247d95ee6dd22e5323ecf7a73ff64110ef2fa2da Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 27 Jan 2015 16:42:14 +0100 Subject: ALSA: line6: Handle error from line6_pcm_acquire() Tested-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 13 ++++++++++--- sound/usb/line6/toneport.c | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 73c87467d2e0..8461d6bf992f 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -45,15 +45,22 @@ static int snd_line6_impulse_volume_put(struct snd_kcontrol *kcontrol, { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); int value = ucontrol->value.integer.value[0]; + int err; if (line6pcm->impulse_volume == value) return 0; line6pcm->impulse_volume = value; - if (value > 0) - line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE); - else + if (value > 0) { + err = line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE); + if (err < 0) { + line6pcm->impulse_volume = 0; + line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE); + return err; + } + } else { line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE); + } return 1; } diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 61fa6256d7b0..819e06b3f3db 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -182,16 +182,23 @@ static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + int err; if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor) return 0; line6pcm->volume_monitor = ucontrol->value.integer.value[0]; - if (line6pcm->volume_monitor > 0) - line6_pcm_acquire(line6pcm, LINE6_STREAM_MONITOR); - else + if (line6pcm->volume_monitor > 0) { + err = line6_pcm_acquire(line6pcm, LINE6_STREAM_MONITOR); + if (err < 0) { + line6pcm->volume_monitor = 0; + line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR); + return err; + } + } else { line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR); + } return 1; } -- cgit From 2f1a11e624d0e8f02282204adfc2a1d374d49fb5 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 28 Jan 2015 12:44:27 +0900 Subject: ASoC: Fix warning with make xmldocs caused by soc-devres.c This patch fix warning while "make xmldocs". Warning(.//sound/soc/soc-devres.c:70): No description found for parameter 'platform_drv' Warning(.//sound/soc/soc-devres.c:70): Excess function parameter 'platform' description in 'devm_snd_soc_register_platform' Signed-off-by: Masanari Iida Signed-off-by: Mark Brown --- sound/soc/soc-devres.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c index 057e5ef7dcce..a57921eeee81 100644 --- a/sound/soc/soc-devres.c +++ b/sound/soc/soc-devres.c @@ -60,7 +60,7 @@ static void devm_platform_release(struct device *dev, void *res) /** * devm_snd_soc_register_platform - resource managed platform registration * @dev: Device used to manage platform - * @platform: platform to register + * @platform_drv: platform to register * * Register a platform driver with automatic unregistration when the device is * unregistered. -- cgit From c33bd08d65d19288faaf779ff42453075da8f3ba Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 28 Jan 2015 09:42:10 +0300 Subject: ASoC: Intel: remove an unused struct member We never set the ->scratch pointer, so let's delete it. Signed-off-by: Dan Carpenter Signed-off-by: Mark Brown --- sound/soc/intel/sst-haswell-ipc.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c index 083292362da6..ccd9669bc307 100644 --- a/sound/soc/intel/sst-haswell-ipc.c +++ b/sound/soc/intel/sst-haswell-ipc.c @@ -277,7 +277,6 @@ struct sst_hsw { /* FW config */ struct sst_hsw_ipc_fw_ready fw_ready; struct sst_hsw_ipc_fw_version version; - struct sst_module *scratch; bool fw_done; struct sst_fw *sst_fw; @@ -2105,7 +2104,6 @@ void sst_hsw_dsp_free(struct device *dev, struct sst_pdata *pdata) dma_free_coherent(hsw->dsp->dma_dev, SST_HSW_DX_CONTEXT_SIZE, hsw->dx_context, hsw->dx_context_paddr); sst_dsp_free(hsw->dsp); - kfree(hsw->scratch); kthread_stop(hsw->tx_thread); kfree(hsw->msg); } -- cgit From 37419584abbb3abf3fae6b9eb6869f18c95f6a1d Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 28 Jan 2015 16:04:46 +0100 Subject: ALSA: sscape: add missing include of linux/io.h The soundscape driver uses the ISA inb/outb functions declared in linux/io.h, so it needs to include this header to avoid a build error: sscape.c: In function 'sscape_write_unsafe': sscape.c:203:2: error: implicit declaration of function 'outb' [-Werror=implicit-function-declaration] Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/isa/sscape.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 018ab140c2be..7b248cdf06e2 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include -- cgit From 6cbbfe1c8ddb6ac1322a87795dff9d8712c3e359 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 16:49:33 +0100 Subject: ALSA: Include linux/io.h instead of asm/io.h Nowadays it's recommended. Replace all in a shot. Signed-off-by: Takashi Iwai --- sound/aoa/soundbus/i2sbus/control.c | 2 +- sound/aoa/soundbus/i2sbus/pcm.c | 2 +- sound/core/memory.c | 2 +- sound/core/pcm_memory.c | 2 +- sound/core/pcm_native.c | 2 +- sound/drivers/mpu401/mpu401_uart.c | 2 +- sound/drivers/opl3/opl3_lib.c | 2 +- sound/drivers/opl4/opl4_lib.c | 2 +- sound/drivers/opl4/opl4_synth.c | 2 +- sound/drivers/pcsp/pcsp_input.c | 2 +- sound/drivers/pcsp/pcsp_lib.c | 2 +- sound/drivers/serial-u16550.c | 3 +-- sound/drivers/vx/vx_core.c | 2 +- sound/i2c/other/ak4xxx-adda.c | 2 +- sound/isa/ad1816a/ad1816a_lib.c | 2 +- sound/isa/azt2320.c | 2 +- sound/isa/cs423x/cs4236_lib.c | 2 +- sound/isa/es1688/es1688_lib.c | 2 +- sound/isa/es18xx.c | 2 +- sound/isa/opl3sa2.c | 3 +-- sound/isa/opti9xx/miro.c | 2 +- sound/isa/opti9xx/opti92x-ad1848.c | 2 +- sound/isa/sb/emu8000.c | 2 +- sound/isa/sb/sb16_main.c | 2 +- sound/isa/sb/sb8_main.c | 2 +- sound/isa/sb/sb8_midi.c | 2 +- sound/isa/sb/sb_common.c | 2 +- sound/isa/sb/sb_mixer.c | 2 +- sound/isa/wavefront/wavefront_fx.c | 2 +- sound/isa/wavefront/wavefront_midi.c | 2 +- sound/isa/wavefront/wavefront_synth.c | 2 +- sound/isa/wss/wss_lib.c | 2 +- sound/parisc/harmony.c | 2 +- sound/pci/ad1889.c | 3 +-- sound/pci/ali5451/ali5451.c | 2 +- sound/pci/als300.c | 3 +-- sound/pci/als4000.c | 2 +- sound/pci/atiixp.c | 2 +- sound/pci/atiixp_modem.c | 2 +- sound/pci/au88x0/au88x0.h | 2 +- sound/pci/aw2/aw2-saa7146.c | 2 +- sound/pci/azt3328.c | 2 +- sound/pci/bt87x.c | 2 +- sound/pci/ca0106/ca0106_mixer.c | 2 +- sound/pci/ca0106/ca0106_proc.c | 2 +- sound/pci/cmipci.c | 2 +- sound/pci/cs4281.c | 2 +- sound/pci/cs46xx/cs46xx_lib.c | 3 +-- sound/pci/cs46xx/dsp_spos.c | 2 +- sound/pci/cs46xx/dsp_spos_scb_lib.c | 2 +- sound/pci/cs5535audio/cs5535audio.c | 2 +- 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/indigoio.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/ens1370.c | 2 +- sound/pci/es1938.c | 3 +-- sound/pci/es1968.c | 2 +- sound/pci/ice1712/ak4xxx.c | 2 +- sound/pci/intel8x0.c | 2 +- sound/pci/intel8x0m.c | 2 +- sound/pci/korg1212/korg1212.c | 3 +-- sound/pci/maestro3.c | 2 +- sound/pci/mixart/mixart_core.c | 2 +- sound/pci/mixart/mixart_hwdep.c | 2 +- sound/pci/nm256/nm256.c | 2 +- sound/pci/oxygen/oxygen_io.c | 2 +- sound/pci/pcxhr/pcxhr_core.c | 2 +- sound/pci/pcxhr/pcxhr_hwdep.c | 2 +- sound/pci/riptide/riptide.c | 2 +- sound/pci/rme32.c | 3 +-- sound/pci/rme96.c | 3 +-- sound/pci/rme9652/hdsp.c | 2 +- sound/pci/rme9652/hdspm.c | 2 +- sound/pci/rme9652/rme9652.c | 2 +- sound/pci/sonicvibes.c | 3 +-- sound/pci/trident/trident_main.c | 3 +-- sound/pci/trident/trident_memory.c | 2 +- sound/pci/via82xx.c | 2 +- sound/pci/via82xx_modem.c | 2 +- sound/pci/vx222/vx222_ops.c | 2 +- sound/pci/ymfpci/ymfpci_main.c | 2 +- sound/ppc/awacs.c | 2 +- sound/ppc/beep.c | 2 +- sound/ppc/burgundy.c | 2 +- sound/ppc/pmac.c | 2 +- sound/ppc/tumbler.c | 2 +- sound/sh/aica.c | 2 +- sound/sparc/amd7930.c | 2 +- 97 files changed, 97 insertions(+), 108 deletions(-) (limited to 'sound') diff --git a/sound/aoa/soundbus/i2sbus/control.c b/sound/aoa/soundbus/i2sbus/control.c index 4dc9b49c02cf..f4495decc699 100644 --- a/sound/aoa/soundbus/i2sbus/control.c +++ b/sound/aoa/soundbus/i2sbus/control.c @@ -9,8 +9,8 @@ #include #include #include +#include -#include #include #include #include diff --git a/sound/aoa/soundbus/i2sbus/pcm.c b/sound/aoa/soundbus/i2sbus/pcm.c index 7b74a4ba75f8..4177d9729d0b 100644 --- a/sound/aoa/soundbus/i2sbus/pcm.c +++ b/sound/aoa/soundbus/i2sbus/pcm.c @@ -6,7 +6,7 @@ * GPL v2, can be found in COPYING. */ -#include +#include #include #include #include diff --git a/sound/core/memory.c b/sound/core/memory.c index 36c0f1a2e189..ca775d7589db 100644 --- a/sound/core/memory.c +++ b/sound/core/memory.c @@ -21,7 +21,7 @@ */ #include -#include +#include #include #include diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 54debc07f5cb..b45f6aa32264 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -19,7 +19,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index ff3abc3b4ff5..932234d87927 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,6 @@ #include #include #include -#include /* * Compatibility diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 1e19eb9e1596..776596b5ee05 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -28,7 +28,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index f66af5884c40..369cef212ea9 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -24,7 +24,7 @@ */ #include -#include +#include #include #include #include diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c index b953fb4aa298..3b0ee42a5343 100644 --- a/sound/drivers/opl4/opl4_lib.c +++ b/sound/drivers/opl4/opl4_lib.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include MODULE_AUTHOR("Clemens Ladisch "); MODULE_DESCRIPTION("OPL4 driver"); diff --git a/sound/drivers/opl4/opl4_synth.c b/sound/drivers/opl4/opl4_synth.c index 4b91adc0238c..7bc1e58c95aa 100644 --- a/sound/drivers/opl4/opl4_synth.c +++ b/sound/drivers/opl4/opl4_synth.c @@ -33,7 +33,7 @@ #include "opl4_local.h" #include -#include +#include #include /* GM2 controllers */ diff --git a/sound/drivers/pcsp/pcsp_input.c b/sound/drivers/pcsp/pcsp_input.c index 0ecf8a453e01..bfc25811985f 100644 --- a/sound/drivers/pcsp/pcsp_input.c +++ b/sound/drivers/pcsp/pcsp_input.c @@ -14,7 +14,7 @@ #include #include -#include +#include #include "pcsp.h" #include "pcsp_input.h" diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c index 29ebaa4ec0fd..3689f5f6be64 100644 --- a/sound/drivers/pcsp/pcsp_lib.c +++ b/sound/drivers/pcsp/pcsp_lib.c @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include "pcsp.h" static bool nforce_wa; diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 8c1dc73e14e4..1927b89e1d1f 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -44,8 +45,6 @@ #include #include -#include - MODULE_DESCRIPTION("MIDI serial u16550"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{ALSA, MIDI serial u16550}}"); diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index fc05a37fd017..289f041706cd 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -27,11 +27,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include "vx_cmd.h" diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index 67dbfde837ab..c65731088aa2 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c @@ -21,7 +21,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 5f99102cc0c1..5c815f5fb044 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -22,11 +22,11 @@ #include #include #include +#include #include #include #include -#include #include static inline int snd_ad1816a_busy_wait(struct snd_ad1816a *chip) diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c index b8e768e5ce80..fff186fa621e 100644 --- a/sound/isa/azt2320.c +++ b/sound/isa/azt2320.c @@ -29,7 +29,7 @@ activation method (full-duplex audio!). */ -#include +#include #include #include #include diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index add7ffc072c5..2b7cc596f4c6 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c @@ -79,7 +79,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 52aac8467178..e2cf508841b1 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -25,11 +25,11 @@ #include #include #include +#include #include #include #include -#include #include MODULE_AUTHOR("Jaroslav Kysela "); diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 6cc2d2bbde6a..5094b62d8f77 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -84,8 +84,8 @@ #include #include #include +#include -#include #include #include #include diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index d7aff527da88..ae133633a420 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -33,8 +34,6 @@ #include #include -#include - MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Yamaha OPL3SA2+"); MODULE_LICENSE("GPL"); diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index 546452888aed..3a9067db1a84 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 840831f1dd4e..0a5266003786 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 96e9d94d07e4..1449354a23fe 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -26,10 +26,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 63d11b7b9fe8..8b2d6c6bfe97 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -33,7 +33,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index d4d8b0e604ee..9043397fe62f 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -30,7 +30,7 @@ * Cleaned up and rewrote lowlevel routines. */ -#include +#include #include #include #include diff --git a/sound/isa/sb/sb8_midi.c b/sound/isa/sb/sb8_midi.c index 925ea45b3d97..d551c50e549f 100644 --- a/sound/isa/sb/sb8_midi.c +++ b/sound/isa/sb/sb8_midi.c @@ -26,7 +26,7 @@ * Added full duplex UART mode for DSP version 2.0 and later. */ -#include +#include #include #include #include diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index f22b4480828e..787a4ade4afd 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -26,11 +26,11 @@ #include #include #include +#include #include #include #include -#include #include MODULE_AUTHOR("Jaroslav Kysela "); diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index e403334a19ad..add1d3f99609 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c @@ -19,7 +19,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index b77883c7ee76..b5a19708473a 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include #include #include #include diff --git a/sound/isa/wavefront/wavefront_midi.c b/sound/isa/wavefront/wavefront_midi.c index b8009cbcd34e..8a80fc6a616b 100644 --- a/sound/isa/wavefront/wavefront_midi.c +++ b/sound/isa/wavefront/wavefront_midi.c @@ -47,7 +47,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index e5db001363ee..33f5ec14fcfa 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -20,7 +20,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 6530d32901b9..913b731d2236 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -31,12 +31,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index f2350c1d6ee8..99b64cb3cef8 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,6 @@ #include #include -#include #include #include diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 0de31290411c..850a8c984c25 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -40,14 +40,13 @@ #include #include #include +#include #include #include #include #include -#include - #include "ad1889.h" #include "ac97/ac97_id.h" diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 4cd2210fd95c..c8d499575c01 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -25,7 +25,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/pci/als300.c b/sound/pci/als300.c index bd01113de39a..57e034f208dc 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -37,8 +37,7 @@ #include #include #include - -#include +#include #include #include diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 94608524f3cc..a3dea464134d 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -65,7 +65,7 @@ * - power management? (card can do voice wakeup according to datasheet!!) */ -#include +#include #include #include #include diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index eb4f9ee54f85..d5f15c9bbeda 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -19,7 +19,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 349dd7ba6e43..0a38e08164ab 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -19,7 +19,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/pci/au88x0/au88x0.h b/sound/pci/au88x0/au88x0.h index 3a8fefefea77..98c53bbf8837 100644 --- a/sound/pci/au88x0/au88x0.h +++ b/sound/pci/au88x0/au88x0.h @@ -19,7 +19,7 @@ #ifdef __KERNEL__ #include -#include +#include #include #include #include diff --git a/sound/pci/aw2/aw2-saa7146.c b/sound/pci/aw2/aw2-saa7146.c index 6d24e9536777..1d7890459334 100644 --- a/sound/pci/aw2/aw2-saa7146.c +++ b/sound/pci/aw2/aw2-saa7146.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index bbacc75c902a..a40a2b4c8fd7 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -179,7 +179,7 @@ * - use MMIO (memory-mapped I/O)? Slightly faster access, e.g. for gameport. */ -#include +#include #include #include /* WARN_ONCE */ #include diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index e82ceacbe64f..5925b7170e25 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 68c0eb0a2807..025805cba779 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -70,7 +70,7 @@ #include #include #include -#include +#include #include "ca0106.h" diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c index 4f9c2821bb31..2c5c28adbefd 100644 --- a/sound/pci/ca0106/ca0106_proc.c +++ b/sound/pci/ca0106/ca0106_proc.c @@ -64,13 +64,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include "ca0106.h" diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 63d2c8236ec6..1d0f2cad2f5a 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -20,7 +20,7 @@ /* Does not work. Warning may block system in capture mode */ /* #define USE_VAR48KRATE */ -#include +#include #include #include #include diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 754613b772ab..c296fd0dbc9c 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -19,7 +19,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index fb3abb2203cd..8d74004b1ed2 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -65,8 +66,6 @@ #include #include "cs46xx.h" -#include - #include "cs46xx_lib.h" #include "dsp_spos.h" diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index 1c4a0fb3ffef..5c99efb004c0 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c @@ -20,7 +20,7 @@ */ -#include +#include #include #include #include diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index 8284bc9b5858..2c90c0bded69 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -21,7 +21,7 @@ */ -#include +#include #include #include #include diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 16288e4d338a..802c33f1cc59 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sound/pci/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c index 4632946205a8..c95da6301677 100644 --- a/sound/pci/echoaudio/darla20.c +++ b/sound/pci/echoaudio/darla20.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/darla24.c b/sound/pci/echoaudio/darla24.c index f81c839cc887..3013b4daa19e 100644 --- a/sound/pci/echoaudio/darla24.c +++ b/sound/pci/echoaudio/darla24.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -55,7 +56,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/echo3g.c b/sound/pci/echoaudio/echo3g.c index 3a5346c33d76..1f34a07b0b19 100644 --- a/sound/pci/echoaudio/echo3g.c +++ b/sound/pci/echoaudio/echo3g.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/gina20.c b/sound/pci/echoaudio/gina20.c index 9cb81c500824..4fa32a2e97db 100644 --- a/sound/pci/echoaudio/gina20.c +++ b/sound/pci/echoaudio/gina20.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -55,7 +56,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/gina24.c b/sound/pci/echoaudio/gina24.c index 35d3e6eac990..b1bcacaef257 100644 --- a/sound/pci/echoaudio/gina24.c +++ b/sound/pci/echoaudio/gina24.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +62,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/indigo.c b/sound/pci/echoaudio/indigo.c index 8d91842d1268..175af9b1435f 100644 --- a/sound/pci/echoaudio/indigo.c +++ b/sound/pci/echoaudio/indigo.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -53,7 +54,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/indigodj.c b/sound/pci/echoaudio/indigodj.c index 289cb969f5b9..8c60314e4901 100644 --- a/sound/pci/echoaudio/indigodj.c +++ b/sound/pci/echoaudio/indigodj.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -53,7 +54,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/indigoio.c b/sound/pci/echoaudio/indigoio.c index 405a3f2e496f..f7618edfd79c 100644 --- a/sound/pci/echoaudio/indigoio.c +++ b/sound/pci/echoaudio/indigoio.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/layla20.c b/sound/pci/echoaudio/layla20.c index b392dd776b71..12e5d2164dc4 100644 --- a/sound/pci/echoaudio/layla20.c +++ b/sound/pci/echoaudio/layla20.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +62,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/layla24.c b/sound/pci/echoaudio/layla24.c index bc7f730b0ec6..6e4023728ef5 100644 --- a/sound/pci/echoaudio/layla24.c +++ b/sound/pci/echoaudio/layla24.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/mia.c b/sound/pci/echoaudio/mia.c index 27a9a6e5db2d..2f7562f1aefb 100644 --- a/sound/pci/echoaudio/mia.c +++ b/sound/pci/echoaudio/mia.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/echoaudio/mona.c b/sound/pci/echoaudio/mona.c index 3d13875c303d..34d499466393 100644 --- a/sound/pci/echoaudio/mona.c +++ b/sound/pci/echoaudio/mona.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -59,7 +60,6 @@ #include #include #include -#include #include #include "echoaudio.h" diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 219b8af29a49..0dc44ebb0032 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -26,7 +26,7 @@ * by Kurt J. Bosch */ -#include +#include #include #include #include diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index a01454b545a0..e1858d9d23d8 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -63,8 +64,6 @@ #include #include -#include - MODULE_AUTHOR("Jaromir Koutek "); MODULE_DESCRIPTION("ESS Solo-1"); MODULE_LICENSE("GPL"); diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 631be029f8c0..059f3846d7b8 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -94,7 +94,7 @@ * places. */ -#include +#include #include #include #include diff --git a/sound/pci/ice1712/ak4xxx.c b/sound/pci/ice1712/ak4xxx.c index 3981823f9094..179ef7a5f0d1 100644 --- a/sound/pci/ice1712/ak4xxx.c +++ b/sound/pci/ice1712/ak4xxx.c @@ -21,7 +21,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 67f9e8b77385..2c5484eeb963 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -26,7 +26,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 748f6f67c982..7577f31cd504 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -23,7 +23,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index bd569e580277..7acbc21d642a 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -36,8 +37,6 @@ #include #include -#include - // ---------------------------------------------------------------------------- // Debug Stuff // ---------------------------------------------------------------------------- diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 18a60be63266..9be660993bd0 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -31,7 +31,7 @@ #define CARD_NAME "ESS Maestro3/Allegro/Canyon3D-2" #define DRIVER_NAME "Maestro3" -#include +#include #include #include #include diff --git a/sound/pci/mixart/mixart_core.c b/sound/pci/mixart/mixart_core.c index fe80313674d9..dccf3db48fe0 100644 --- a/sound/pci/mixart/mixart_core.c +++ b/sound/pci/mixart/mixart_core.c @@ -23,8 +23,8 @@ #include #include #include +#include -#include #include #include "mixart.h" #include "mixart_hwdep.h" diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c index 9996a4dead0f..5bfd3ac80db5 100644 --- a/sound/pci/mixart/mixart_hwdep.c +++ b/sound/pci/mixart/mixart_hwdep.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include "mixart.h" #include "mixart_mixer.h" diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 90674b93b930..4735e27cc773 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -24,7 +24,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include #include #include #include diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c index 4b8a32c37e31..c7851da37749 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c @@ -20,9 +20,9 @@ #include #include #include +#include #include #include -#include #include "oxygen.h" u8 oxygen_read8(struct oxygen *chip, unsigned int reg) diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c index 181f7729d409..c5194f5b150a 100644 --- a/sound/pci/pcxhr/pcxhr_core.c +++ b/sound/pci/pcxhr/pcxhr_core.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include "pcxhr.h" #include "pcxhr_mixer.h" diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c index 15a8ce5f1f48..80633055e17e 100644 --- a/sound/pci/pcxhr/pcxhr_hwdep.c +++ b/sound/pci/pcxhr/pcxhr_hwdep.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include "pcxhr.h" diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index a1521047e619..29f28273b2cc 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -99,7 +99,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 1a7affad7164..23d7f5d30c41 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -75,6 +75,7 @@ #include #include #include +#include #include #include @@ -85,8 +86,6 @@ #include #include -#include - 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 this card */ diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 236ac1d48184..2306ccf7281e 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -38,8 +39,6 @@ #include #include -#include - /* note, two last pcis should be equal, it is not a bug */ MODULE_AUTHOR("Anders Torger "); diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 98a2d911ef17..c19e021ccf66 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -42,7 +43,6 @@ #include #include -#include static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 1716323fed9c..2c363fdca9fd 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -136,7 +136,7 @@ #include #include #include -#include +#include #include #include diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 648911c1a226..fdbc0aa2776a 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,6 @@ #include #include -#include static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 34cee5c1abd8..0f40624a4275 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -39,8 +40,6 @@ #include #include -#include - MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("S3 SonicVibes PCI"); MODULE_LICENSE("GPL"); diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 2870cbf8cee0..b72be035f785 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -44,8 +45,6 @@ #include "trident.h" #include -#include - static int snd_trident_pcm_mixer_build(struct snd_trident *trident, struct snd_trident_voice * voice, struct snd_pcm_substream *substream); diff --git a/sound/pci/trident/trident_memory.c b/sound/pci/trident/trident_memory.c index 04c474658e3c..b9ebb51893c5 100644 --- a/sound/pci/trident/trident_memory.c +++ b/sound/pci/trident/trident_memory.c @@ -23,7 +23,7 @@ * */ -#include +#include #include #include #include diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 120fccbb2461..8622283e89f3 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -46,7 +46,7 @@ * - Optimize position calculation for the 823x chips. */ -#include +#include #include #include #include diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 884f49eea495..99b9137bc677 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -31,7 +31,7 @@ * modems. */ -#include +#include #include #include #include diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c index 52c1a8d5b88a..af83b3b38052 100644 --- a/sound/pci/vx222/vx222_ops.c +++ b/sound/pci/vx222/vx222_ops.c @@ -24,11 +24,11 @@ #include #include #include +#include #include #include #include -#include #include "vx222.h" diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 227d5c9dfe09..4c26076dbf78 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,6 @@ #include #include -#include #include /* diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c index 5fbf5db2543d..09da7b52bc2e 100644 --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c @@ -20,7 +20,7 @@ */ -#include +#include #include #include #include diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c index 0040f048221f..d3524f9fa05d 100644 --- a/sound/ppc/beep.c +++ b/sound/ppc/beep.c @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include #include #include #include diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c index cb4f0a5e984e..b86159e04493 100644 --- a/sound/ppc/burgundy.c +++ b/sound/ppc/burgundy.c @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include #include #include #include diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index d399df473896..13146d701413 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -20,7 +20,7 @@ */ -#include +#include #include #include #include diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index 24c8766a925d..c8fafba218a5 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -32,8 +32,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/sound/sh/aica.c b/sound/sh/aica.c index 8212300088fc..ad3d9ae38034 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -35,12 +35,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include "aica.h" diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 86280d63b76d..1b1a89e80d13 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -44,7 +45,6 @@ #include #include -#include #include #include -- cgit From 976412fbc9855176ea7e02602a601b46c4479fcc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 17:24:43 +0100 Subject: ALSA: Include linux/uaccess.h and linux/bitopts.h instead of asm/* Signed-off-by: Takashi Iwai --- sound/core/memory.c | 2 +- sound/drivers/pcsp/pcsp.c | 2 +- sound/isa/sb/emu8000.c | 2 +- sound/isa/sb/emu8000_patch.c | 2 +- sound/pci/asihpi/hpioctl.c | 2 +- sound/synth/emux/emux_hwdep.c | 2 +- sound/synth/emux/emux_oss.c | 2 +- sound/synth/emux/soundfont.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/core/memory.c b/sound/core/memory.c index ca775d7589db..4cd664efad77 100644 --- a/sound/core/memory.c +++ b/sound/core/memory.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include /** diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 2adc7548ffca..d9647bd84d0f 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include "pcsp_input.h" #include "pcsp.h" diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 1449354a23fe..94c411299e5a 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sound/isa/sb/emu8000_patch.c b/sound/isa/sb/emu8000_patch.c index c99c6078be33..71d13c0bb746 100644 --- a/sound/isa/sb/emu8000_patch.c +++ b/sound/isa/sb/emu8000_patch.c @@ -20,7 +20,7 @@ */ #include "emu8000_local.h" -#include +#include #include static int emu8000_reset_addr; diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index 67d113356971..6610bd096fc9 100644 --- a/sound/pci/asihpi/hpioctl.c +++ b/sound/pci/asihpi/hpioctl.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sound/synth/emux/emux_hwdep.c b/sound/synth/emux/emux_hwdep.c index 5ae1eae9f6db..e557946718a9 100644 --- a/sound/synth/emux/emux_hwdep.c +++ b/sound/synth/emux/emux_hwdep.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include "emux_voice.h" diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c index 319754cf6208..ab37add269ae 100644 --- a/sound/synth/emux/emux_oss.c +++ b/sound/synth/emux/emux_oss.c @@ -26,7 +26,7 @@ #ifdef CONFIG_SND_SEQUENCER_OSS #include -#include +#include #include #include "emux_voice.h" #include diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index 78683b2064f7..31a4ea94830e 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -25,7 +25,7 @@ * of doing things so that the old sfxload utility can be used. * Everything may change when there is an alsa way of doing things. */ -#include +#include #include #include #include -- cgit From ba6211a2e8f80eecdf12f7972045ea28f904a4a0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 17:26:45 +0100 Subject: ALSA: au88x0: Remove superfluous ifdef __KERNEL__ Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/au88x0/au88x0.h b/sound/pci/au88x0/au88x0.h index 98c53bbf8837..bcc648bf6478 100644 --- a/sound/pci/au88x0/au88x0.h +++ b/sound/pci/au88x0/au88x0.h @@ -17,7 +17,6 @@ #ifndef __SOUND_AU88X0_H #define __SOUND_AU88X0_H -#ifdef __KERNEL__ #include #include #include @@ -27,7 +26,6 @@ #include #include #include -#endif #ifndef CHIP_AU8820 #include "au88x0_eq.h" -- cgit From 5da7f924a41949797875c98a776dca1737a0f372 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 17:32:22 +0100 Subject: ALSA: usx2y: Move UAPI definition into include/uapi/sound/usb_stream.h The user-space API definition for usb_stream stuff should be moved to include/uapi/sound to be exposed publicly. While we're at it, add the missing ifdef guard for double inclusion, too. Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usb_stream.h | 78 +++----------------------------------------- 1 file changed, 4 insertions(+), 74 deletions(-) (limited to 'sound') diff --git a/sound/usb/usx2y/usb_stream.h b/sound/usb/usx2y/usb_stream.h index 4dd74ab1e9cc..90369001eab6 100644 --- a/sound/usb/usx2y/usb_stream.h +++ b/sound/usb/usx2y/usb_stream.h @@ -1,76 +1,7 @@ -/* - * Copyright (C) 2007, 2008 Karsten Wiese - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ +#ifndef __USB_STREAM_H +#define __USB_STREAM_H -#define USB_STREAM_INTERFACE_VERSION 2 - -#define SNDRV_USB_STREAM_IOCTL_SET_PARAMS \ - _IOW('H', 0x90, struct usb_stream_config) - -struct usb_stream_packet { - unsigned offset; - unsigned length; -}; - - -struct usb_stream_config { - unsigned version; - unsigned sample_rate; - unsigned period_frames; - unsigned frame_size; -}; - -struct usb_stream { - struct usb_stream_config cfg; - unsigned read_size; - unsigned write_size; - - int period_size; - - unsigned state; - - int idle_insize; - int idle_outsize; - int sync_packet; - unsigned insize_done; - unsigned periods_done; - unsigned periods_polled; - - struct usb_stream_packet outpacket[2]; - unsigned inpackets; - unsigned inpacket_head; - unsigned inpacket_split; - unsigned inpacket_split_at; - unsigned next_inpacket_split; - unsigned next_inpacket_split_at; - struct usb_stream_packet inpacket[0]; -}; - -enum usb_stream_state { - usb_stream_invalid, - usb_stream_stopped, - usb_stream_sync0, - usb_stream_sync1, - usb_stream_ready, - usb_stream_running, - usb_stream_xrun, -}; - -#if __KERNEL__ +#include #define USB_STREAM_NURBS 4 #define USB_STREAM_URBDEPTH 4 @@ -108,5 +39,4 @@ void usb_stream_free(struct usb_stream_kernel *); int usb_stream_start(struct usb_stream_kernel *); void usb_stream_stop(struct usb_stream_kernel *); - -#endif +#endif /* __USB_STREAM_H */ -- cgit From acae254a8e08b9406e62d456000ebd1573af0cb6 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 27 Jan 2015 20:38:28 +0000 Subject: ASoC: dwc: Remove unnecessary conditional compilation of_match_ptr is already conditionally compiled based on CONFIG_OF so further conditional compilation is not required. Remove conditional compilation surrounding of_match_ptr. Signed-off-by: Andrew Jackson Signed-off-by: Mark Brown --- sound/soc/dwc/designware_i2s.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index adefdf0e01f1..8fbf0381ee53 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c @@ -613,9 +613,7 @@ static struct platform_driver dw_i2s_driver = { .remove = dw_i2s_remove, .driver = { .name = "designware-i2s", -#ifdef CONFIG_OF .of_match_table = of_match_ptr(dw_i2s_of_match), -#endif }, }; -- cgit From f66f898e953d56779367a6cbc39cbb4808b208c0 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 28 Jan 2015 15:16:06 +0100 Subject: ALSA: pcm: Add snd_interval_ranges() and snd_pcm_hw_constraint_ranges() Add helper functions to allow drivers to specify several disjoint ranges for a variable. In particular, there is a codec (PCM512x) that has a hole in its supported range of rates, due to PLL and divider restrictions. This is like snd_pcm_hw_constraint_list(), but for ranges instead of points. Signed-off-by: Peter Rosin Reviewed-by: Lars-Peter Clausen Reviewed-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/core/pcm_lib.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'sound') diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index ec9e7866177f..446c00bd908b 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1015,6 +1015,60 @@ int snd_interval_list(struct snd_interval *i, unsigned int count, EXPORT_SYMBOL(snd_interval_list); +/** + * snd_interval_ranges - refine the interval value from the list of ranges + * @i: the interval value to refine + * @count: the number of elements in the list of ranges + * @ranges: the ranges list + * @mask: the bit-mask to evaluate + * + * Refines the interval value from the list of ranges. + * When mask is non-zero, only the elements corresponding to bit 1 are + * evaluated. + * + * Return: Positive if the value is changed, zero if it's not changed, or a + * negative error code. + */ +int snd_interval_ranges(struct snd_interval *i, unsigned int count, + const struct snd_interval *ranges, unsigned int mask) +{ + unsigned int k; + struct snd_interval range_union; + struct snd_interval range; + + if (!count) { + snd_interval_none(i); + return -EINVAL; + } + snd_interval_any(&range_union); + range_union.min = UINT_MAX; + range_union.max = 0; + for (k = 0; k < count; k++) { + if (mask && !(mask & (1 << k))) + continue; + snd_interval_copy(&range, &ranges[k]); + if (snd_interval_refine(&range, i) < 0) + continue; + if (snd_interval_empty(&range)) + continue; + + if (range.min < range_union.min) { + range_union.min = range.min; + range_union.openmin = 1; + } + if (range.min == range_union.min && !range.openmin) + range_union.openmin = 0; + if (range.max > range_union.max) { + range_union.max = range.max; + range_union.openmax = 1; + } + if (range.max == range_union.max && !range.openmax) + range_union.openmax = 0; + } + return snd_interval_refine(i, &range_union); +} +EXPORT_SYMBOL(snd_interval_ranges); + static int snd_interval_step(struct snd_interval *i, unsigned int step) { unsigned int n; @@ -1221,6 +1275,37 @@ int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, EXPORT_SYMBOL(snd_pcm_hw_constraint_list); +static int snd_pcm_hw_rule_ranges(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) +{ + struct snd_pcm_hw_constraint_ranges *r = rule->private; + return snd_interval_ranges(hw_param_interval(params, rule->var), + r->count, r->ranges, r->mask); +} + + +/** + * snd_pcm_hw_constraint_ranges - apply list of range constraints to a parameter + * @runtime: PCM runtime instance + * @cond: condition bits + * @var: hw_params variable to apply the list of range constraints + * @r: ranges + * + * Apply the list of range constraints to an interval parameter. + * + * Return: Zero if successful, or a negative error code on failure. + */ +int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime, + unsigned int cond, + snd_pcm_hw_param_t var, + const struct snd_pcm_hw_constraint_ranges *r) +{ + return snd_pcm_hw_rule_add(runtime, cond, var, + snd_pcm_hw_rule_ranges, (void *)r, + var, -1); +} +EXPORT_SYMBOL(snd_pcm_hw_constraint_ranges); + static int snd_pcm_hw_rule_ratnums(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { -- cgit From 376dc4903eec7f64b9fd1dafe542c07ab63abb49 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 28 Jan 2015 15:16:07 +0100 Subject: ASoC: pcm512x: Fix spelling of register field names. Signed-off-by: Peter Rosin Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 2 +- sound/soc/codecs/pcm512x.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index e5f2fb884bf3..874723c36d65 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -277,7 +277,7 @@ SOC_ENUM("Auto Mute Time Right", pcm512x_autom_r), SOC_SINGLE("Auto Mute Mono Switch", PCM512x_DIGITAL_MUTE_3, PCM512x_ACTL_SHIFT, 1, 0), SOC_DOUBLE("Auto Mute Switch", PCM512x_DIGITAL_MUTE_3, PCM512x_AMLE_SHIFT, - PCM512x_AMLR_SHIFT, 1, 0), + PCM512x_AMRE_SHIFT, 1, 0), SOC_ENUM("Volume Ramp Down Rate", pcm512x_vndf), SOC_ENUM("Volume Ramp Down Step", pcm512x_vnds), diff --git a/sound/soc/codecs/pcm512x.h b/sound/soc/codecs/pcm512x.h index 6ee76aaca09a..28b3dfd302bc 100644 --- a/sound/soc/codecs/pcm512x.h +++ b/sound/soc/codecs/pcm512x.h @@ -108,8 +108,8 @@ #define PCM512x_RQML_SHIFT 4 /* Page 0, Register 4 - PLL */ -#define PCM512x_PLCE (1 << 0) -#define PCM512x_RLCE_SHIFT 0 +#define PCM512x_PLLE (1 << 0) +#define PCM512x_PLLE_SHIFT 0 #define PCM512x_PLCK (1 << 4) #define PCM512x_PLCK_SHIFT 4 @@ -152,7 +152,7 @@ /* Page 0, Register 65 - Digital mute enables */ #define PCM512x_ACTL_SHIFT 2 #define PCM512x_AMLE_SHIFT 1 -#define PCM512x_AMLR_SHIFT 0 +#define PCM512x_AMRE_SHIFT 0 /* Page 1, Register 2 - analog volume control */ #define PCM512x_RAGN_SHIFT 0 -- cgit From 8124930713f2fa37ad5347ddfcd2aae45a016aa5 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 28 Jan 2015 15:16:09 +0100 Subject: ASoC: pcm512x: Support mastering BCLK/LRCLK without using the PLL Use register field names from the seemingly compatible PCM5242 datasheet, as the PCM512x and PCM514x datasheets are severly lacking. Signed-off-by: Peter Rosin Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 441 +++++++++++++++++++++++++++++++++++++++++++-- sound/soc/codecs/pcm512x.h | 57 +++++- 2 files changed, 481 insertions(+), 17 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 874723c36d65..526e6b30cdde 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "pcm512x.h" @@ -39,6 +40,7 @@ struct pcm512x_priv { struct clk *sclk; struct regulator_bulk_data supplies[PCM512x_NUM_SUPPLIES]; struct notifier_block supply_nb[PCM512x_NUM_SUPPLIES]; + int fmt; }; /* @@ -69,6 +71,7 @@ static const struct reg_default pcm512x_reg_defaults[] = { { PCM512x_MUTE, 0x00 }, { PCM512x_DSP, 0x00 }, { PCM512x_PLL_REF, 0x00 }, + { PCM512x_DAC_REF, 0x00 }, { PCM512x_DAC_ROUTING, 0x11 }, { PCM512x_DSP_PROGRAM, 0x01 }, { PCM512x_CLKDET, 0x00 }, @@ -87,6 +90,18 @@ static const struct reg_default pcm512x_reg_defaults[] = { { PCM512x_ANALOG_GAIN_BOOST, 0x00 }, { PCM512x_VCOM_CTRL_1, 0x00 }, { PCM512x_VCOM_CTRL_2, 0x01 }, + { PCM512x_BCLK_LRCLK_CFG, 0x00 }, + { PCM512x_MASTER_MODE, 0x7c }, + { PCM512x_SYNCHRONIZE, 0x10 }, + { PCM512x_DSP_CLKDIV, 0x00 }, + { PCM512x_DAC_CLKDIV, 0x00 }, + { PCM512x_NCP_CLKDIV, 0x00 }, + { PCM512x_OSR_CLKDIV, 0x00 }, + { PCM512x_MASTER_CLKDIV_1, 0x00 }, + { PCM512x_MASTER_CLKDIV_2, 0x00 }, + { PCM512x_FS_SPEED_MODE, 0x00 }, + { PCM512x_IDAC_1, 0x01 }, + { PCM512x_IDAC_2, 0x00 }, }; static bool pcm512x_readable(struct device *dev, unsigned int reg) @@ -103,6 +118,8 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg) case PCM512x_DSP_GPIO_INPUT: case PCM512x_MASTER_MODE: case PCM512x_PLL_REF: + case PCM512x_DAC_REF: + case PCM512x_SYNCHRONIZE: case PCM512x_PLL_COEFF_0: case PCM512x_PLL_COEFF_1: case PCM512x_PLL_COEFF_2: @@ -303,6 +320,94 @@ static const struct snd_soc_dapm_route pcm512x_dapm_routes[] = { { "OUTR", NULL, "DACR" }, }; +static const u32 pcm512x_dai_rates[] = { + 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, + 88200, 96000, 176400, 192000, 384000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_slave = { + .count = ARRAY_SIZE(pcm512x_dai_rates), + .list = pcm512x_dai_rates, +}; + +static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct device *dev = dai->dev; + struct snd_pcm_hw_constraint_ratnums *constraints_no_pll; + struct snd_ratnum *rats_no_pll; + + if (IS_ERR(pcm512x->sclk)) { + dev_err(dev, "Need SCLK for master mode: %ld\n", + PTR_ERR(pcm512x->sclk)); + return PTR_ERR(pcm512x->sclk); + } + + constraints_no_pll = devm_kzalloc(dev, sizeof(*constraints_no_pll), + GFP_KERNEL); + if (!constraints_no_pll) + return -ENOMEM; + constraints_no_pll->nrats = 1; + rats_no_pll = devm_kzalloc(dev, sizeof(*rats_no_pll), GFP_KERNEL); + if (!rats_no_pll) + return -ENOMEM; + constraints_no_pll->rats = rats_no_pll; + rats_no_pll->num = clk_get_rate(pcm512x->sclk) / 64; + rats_no_pll->den_min = 1; + rats_no_pll->den_max = 128; + rats_no_pll->den_step = 1; + + return snd_pcm_hw_constraint_ratnums(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + constraints_no_pll); +} + +static int pcm512x_dai_startup_slave(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct device *dev = dai->dev; + struct regmap *regmap = pcm512x->regmap; + + if (IS_ERR(pcm512x->sclk)) { + dev_info(dev, "No SCLK, using BCLK: %ld\n", + PTR_ERR(pcm512x->sclk)); + + /* Disable reporting of missing SCLK as an error */ + regmap_update_bits(regmap, PCM512x_ERROR_DETECT, + PCM512x_IDCH, PCM512x_IDCH); + + /* Switch PLL input to BCLK */ + regmap_update_bits(regmap, PCM512x_PLL_REF, + PCM512x_SREF, PCM512x_SREF_BCK); + } + + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &constraints_slave); +} + +static int pcm512x_dai_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + + switch (pcm512x->fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + return pcm512x_dai_startup_master(substream, dai); + + case SND_SOC_DAIFMT_CBS_CFS: + return pcm512x_dai_startup_slave(substream, dai); + + default: + return -EINVAL; + } +} + static int pcm512x_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { @@ -340,17 +445,333 @@ static int pcm512x_set_bias_level(struct snd_soc_codec *codec, return 0; } +static int pcm512x_set_dividers(struct snd_soc_dai *dai, + struct snd_pcm_hw_params *params) +{ + struct device *dev = dai->dev; + struct snd_soc_codec *codec = dai->codec; + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + unsigned long sck_rate; + unsigned long mck_rate; + unsigned long bclk_rate; + unsigned long sample_rate; + unsigned long osr_rate; + int bclk_div; + int lrclk_div; + int dsp_div; + int dac_div; + unsigned long dac_rate; + int ncp_div; + int osr_div; + unsigned long dac_mul; + unsigned long sck_mul; + int ret; + int idac; + int fssp; + + lrclk_div = snd_soc_params_to_frame_size(params); + if (lrclk_div == 0) { + dev_err(dev, "No LRCLK?\n"); + return -EINVAL; + } + + sck_rate = clk_get_rate(pcm512x->sclk); + bclk_div = params->rate_den * 64 / lrclk_div; + bclk_rate = DIV_ROUND_CLOSEST(sck_rate, bclk_div); + + mck_rate = sck_rate; + + if (bclk_div > 128) { + dev_err(dev, "Failed to find BCLK divider\n"); + return -EINVAL; + } + + /* the actual rate */ + sample_rate = sck_rate / bclk_div / lrclk_div; + osr_rate = 16 * sample_rate; + + /* run DSP no faster than 50 MHz */ + dsp_div = mck_rate > 50000000 ? 2 : 1; + + /* run DAC no faster than 6144000 Hz */ + dac_mul = 6144000 / osr_rate; + sck_mul = sck_rate / osr_rate; + for (; dac_mul; dac_mul--) { + if (!(sck_mul % dac_mul)) + break; + } + if (!dac_mul) { + dev_err(dev, "Failed to find DAC rate\n"); + return -EINVAL; + } + + dac_rate = dac_mul * osr_rate; + dev_dbg(dev, "dac_rate %lu sample_rate %lu\n", dac_rate, sample_rate); + + dac_div = DIV_ROUND_CLOSEST(sck_rate, dac_rate); + if (dac_div > 128) { + dev_err(dev, "Failed to find DAC divider\n"); + return -EINVAL; + } + + ncp_div = DIV_ROUND_CLOSEST(sck_rate / dac_div, 1536000); + if (ncp_div > 128 || sck_rate / dac_div / ncp_div > 2048000) { + /* run NCP no faster than 2048000 Hz, but why? */ + ncp_div = DIV_ROUND_UP(sck_rate / dac_div, 2048000); + if (ncp_div > 128) { + dev_err(dev, "Failed to find NCP divider\n"); + return -EINVAL; + } + } + + osr_div = DIV_ROUND_CLOSEST(dac_rate, osr_rate); + if (osr_div > 128) { + dev_err(dev, "Failed to find OSR divider\n"); + return -EINVAL; + } + + idac = mck_rate / (dsp_div * sample_rate); + + ret = regmap_write(pcm512x->regmap, PCM512x_DSP_CLKDIV, dsp_div - 1); + if (ret != 0) { + dev_err(dev, "Failed to write DSP divider: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, PCM512x_DAC_CLKDIV, dac_div - 1); + if (ret != 0) { + dev_err(dev, "Failed to write DAC divider: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, PCM512x_NCP_CLKDIV, ncp_div - 1); + if (ret != 0) { + dev_err(dev, "Failed to write NCP divider: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, PCM512x_OSR_CLKDIV, osr_div - 1); + if (ret != 0) { + dev_err(dev, "Failed to write OSR divider: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, + PCM512x_MASTER_CLKDIV_1, bclk_div - 1); + if (ret != 0) { + dev_err(dev, "Failed to write BCLK divider: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, + PCM512x_MASTER_CLKDIV_2, lrclk_div - 1); + if (ret != 0) { + dev_err(dev, "Failed to write LRCLK divider: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, PCM512x_IDAC_1, idac >> 8); + if (ret != 0) { + dev_err(dev, "Failed to write IDAC msb divider: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, PCM512x_IDAC_2, idac & 0xff); + if (ret != 0) { + dev_err(dev, "Failed to write IDAC lsb divider: %d\n", ret); + return ret; + } + + if (sample_rate <= 48000) + fssp = PCM512x_FSSP_48KHZ; + else if (sample_rate <= 96000) + fssp = PCM512x_FSSP_96KHZ; + else if (sample_rate <= 192000) + fssp = PCM512x_FSSP_192KHZ; + else + fssp = PCM512x_FSSP_384KHZ; + ret = regmap_update_bits(pcm512x->regmap, PCM512x_FS_SPEED_MODE, + PCM512x_FSSP, fssp); + if (ret != 0) { + dev_err(codec->dev, "Failed to set fs speed: %d\n", ret); + return ret; + } + + dev_dbg(codec->dev, "DSP divider %d\n", dsp_div); + dev_dbg(codec->dev, "DAC divider %d\n", dac_div); + dev_dbg(codec->dev, "NCP divider %d\n", ncp_div); + dev_dbg(codec->dev, "OSR divider %d\n", osr_div); + dev_dbg(codec->dev, "BCK divider %d\n", bclk_div); + dev_dbg(codec->dev, "LRCK divider %d\n", lrclk_div); + dev_dbg(codec->dev, "IDAC %d\n", idac); + dev_dbg(codec->dev, "1<codec; + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + int alen; + int ret; + + dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n", + params_rate(params), + params_channels(params)); + + switch (snd_pcm_format_width(params_format(params))) { + case 16: + alen = PCM512x_ALEN_16; + break; + case 20: + alen = PCM512x_ALEN_20; + break; + case 24: + alen = PCM512x_ALEN_24; + break; + case 32: + alen = PCM512x_ALEN_32; + break; + default: + dev_err(codec->dev, "Bad frame size: %d\n", + snd_pcm_format_width(params_format(params))); + return -EINVAL; + } + + switch (pcm512x->fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + ret = regmap_update_bits(pcm512x->regmap, + PCM512x_BCLK_LRCLK_CFG, + PCM512x_BCKP + | PCM512x_BCKO | PCM512x_LRKO, + 0); + if (ret != 0) { + dev_err(codec->dev, + "Failed to enable slave mode: %d\n", ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, + PCM512x_DCAS, 0); + if (ret != 0) { + dev_err(codec->dev, + "Failed to enable clock divider autoset: %d\n", + ret); + return ret; + } + return 0; + case SND_SOC_DAIFMT_CBM_CFM: + break; + default: + return -EINVAL; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1, + PCM512x_ALEN, alen); + if (ret != 0) { + dev_err(codec->dev, "Failed to set frame size: %d\n", ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, + PCM512x_IDFS | PCM512x_IDBK + | PCM512x_IDSK | PCM512x_IDCH + | PCM512x_IDCM | PCM512x_DCAS + | PCM512x_IPLK, + PCM512x_IDFS | PCM512x_IDBK + | PCM512x_IDSK | PCM512x_IDCH + | PCM512x_DCAS | PCM512x_IPLK); + if (ret != 0) { + dev_err(codec->dev, + "Failed to ignore auto-clock failures: %d\n", + ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, + PCM512x_PLLE, 0); + if (ret != 0) { + dev_err(codec->dev, "Failed to disable pll: %d\n", ret); + return ret; + } + + ret = pcm512x_set_dividers(dai, params); + if (ret != 0) + return ret; + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, + PCM512x_SDAC, PCM512x_SDAC_SCK); + if (ret != 0) { + dev_err(codec->dev, "Failed to set sck as dacref: %d\n", ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_BCLK_LRCLK_CFG, + PCM512x_BCKP | PCM512x_BCKO | PCM512x_LRKO, + PCM512x_BCKO | PCM512x_LRKO); + if (ret != 0) { + dev_err(codec->dev, "Failed to enable clock output: %d\n", ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_MASTER_MODE, + PCM512x_RLRK | PCM512x_RBCK, + PCM512x_RLRK | PCM512x_RBCK); + if (ret != 0) { + dev_err(codec->dev, "Failed to enable master mode: %d\n", ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, + PCM512x_RQSY, PCM512x_RQSY_HALT); + if (ret != 0) { + dev_err(codec->dev, "Failed to halt clocks: %d\n", ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, + PCM512x_RQSY, PCM512x_RQSY_RESUME); + if (ret != 0) { + dev_err(codec->dev, "Failed to resume clocks: %d\n", ret); + return ret; + } + + return 0; +} + +static int pcm512x_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct snd_soc_codec *codec = dai->codec; + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + + pcm512x->fmt = fmt; + + return 0; +} + +static const struct snd_soc_dai_ops pcm512x_dai_ops = { + .startup = pcm512x_dai_startup, + .hw_params = pcm512x_hw_params, + .set_fmt = pcm512x_set_fmt, +}; + static struct snd_soc_dai_driver pcm512x_dai = { .name = "pcm512x-hifi", .playback = { .stream_name = "Playback", .channels_min = 2, .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_192000, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 8000, + .rate_max = 384000, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE }, + .ops = &pcm512x_dai_ops, }; static struct snd_soc_codec_driver pcm512x_codec_driver = { @@ -448,21 +869,9 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) } pcm512x->sclk = devm_clk_get(dev, NULL); - if (IS_ERR(pcm512x->sclk)) { - if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER) - return -EPROBE_DEFER; - - dev_info(dev, "No SCLK, using BCLK: %ld\n", - PTR_ERR(pcm512x->sclk)); - - /* Disable reporting of missing SCLK as an error */ - regmap_update_bits(regmap, PCM512x_ERROR_DETECT, - PCM512x_IDCH, PCM512x_IDCH); - - /* Switch PLL input to BCLK */ - regmap_update_bits(regmap, PCM512x_PLL_REF, - PCM512x_SREF, PCM512x_SREF); - } else { + if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (!IS_ERR(pcm512x->sclk)) { ret = clk_prepare_enable(pcm512x->sclk); if (ret != 0) { dev_err(dev, "Failed to enable SCLK: %d\n", ret); diff --git a/sound/soc/codecs/pcm512x.h b/sound/soc/codecs/pcm512x.h index 28b3dfd302bc..fa538d5aabf2 100644 --- a/sound/soc/codecs/pcm512x.h +++ b/sound/soc/codecs/pcm512x.h @@ -37,6 +37,8 @@ #define PCM512x_DSP_GPIO_INPUT (PCM512x_PAGE_BASE(0) + 10) #define PCM512x_MASTER_MODE (PCM512x_PAGE_BASE(0) + 12) #define PCM512x_PLL_REF (PCM512x_PAGE_BASE(0) + 13) +#define PCM512x_DAC_REF (PCM512x_PAGE_BASE(0) + 14) +#define PCM512x_SYNCHRONIZE (PCM512x_PAGE_BASE(0) + 19) #define PCM512x_PLL_COEFF_0 (PCM512x_PAGE_BASE(0) + 20) #define PCM512x_PLL_COEFF_1 (PCM512x_PAGE_BASE(0) + 21) #define PCM512x_PLL_COEFF_2 (PCM512x_PAGE_BASE(0) + 22) @@ -119,8 +121,47 @@ #define PCM512x_DEMP (1 << 4) #define PCM512x_DEMP_SHIFT 4 +/* Page 0, Register 9 - BCK, LRCLK configuration */ +#define PCM512x_LRKO (1 << 0) +#define PCM512x_LRKO_SHIFT 0 +#define PCM512x_BCKO (1 << 4) +#define PCM512x_BCKO_SHIFT 4 +#define PCM512x_BCKP (1 << 5) +#define PCM512x_BCKP_SHIFT 5 + +/* Page 0, Register 12 - Master mode BCK, LRCLK reset */ +#define PCM512x_RLRK (1 << 0) +#define PCM512x_RLRK_SHIFT 0 +#define PCM512x_RBCK (1 << 1) +#define PCM512x_RBCK_SHIFT 1 + /* Page 0, Register 13 - PLL reference */ -#define PCM512x_SREF (1 << 4) +#define PCM512x_SREF (7 << 4) +#define PCM512x_SREF_SHIFT 4 +#define PCM512x_SREF_SCK (0 << 4) +#define PCM512x_SREF_BCK (1 << 4) +#define PCM512x_SREF_GPIO (3 << 4) + +/* Page 0, Register 14 - DAC reference */ +#define PCM512x_SDAC (7 << 4) +#define PCM512x_SDAC_SHIFT 4 +#define PCM512x_SDAC_MCK (0 << 4) +#define PCM512x_SDAC_PLL (1 << 4) +#define PCM512x_SDAC_SCK (3 << 4) +#define PCM512x_SDAC_BCK (4 << 4) + +/* Page 0, Register 19 - synchronize */ +#define PCM512x_RQSY (1 << 0) +#define PCM512x_RQSY_RESUME (0 << 0) +#define PCM512x_RQSY_HALT (1 << 0) + +/* Page 0, Register 34 - fs speed mode */ +#define PCM512x_FSSP (3 << 0) +#define PCM512x_FSSP_SHIFT 0 +#define PCM512x_FSSP_48KHZ (0 << 0) +#define PCM512x_FSSP_96KHZ (1 << 0) +#define PCM512x_FSSP_192KHZ (2 << 0) +#define PCM512x_FSSP_384KHZ (3 << 0) /* Page 0, Register 37 - Error detection */ #define PCM512x_IPLK (1 << 0) @@ -131,6 +172,20 @@ #define PCM512x_IDBK (1 << 5) #define PCM512x_IDFS (1 << 6) +/* Page 0, Register 40 - I2S configuration */ +#define PCM512x_ALEN (3 << 0) +#define PCM512x_ALEN_SHIFT 0 +#define PCM512x_ALEN_16 (0 << 0) +#define PCM512x_ALEN_20 (1 << 0) +#define PCM512x_ALEN_24 (2 << 0) +#define PCM512x_ALEN_32 (3 << 0) +#define PCM512x_AFMT (3 << 4) +#define PCM512x_AFMT_SHIFT 4 +#define PCM512x_AFMT_I2S (0 << 4) +#define PCM512x_AFMT_DSP (1 << 4) +#define PCM512x_AFMT_RTJ (2 << 4) +#define PCM512x_AFMT_LTJ (3 << 4) + /* Page 0, Register 42 - DAC routing */ #define PCM512x_AUPR_SHIFT 0 #define PCM512x_AUPL_SHIFT 4 -- cgit From f086ba9d5389cc9a309958c9e7c92460f1cfca5e Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 28 Jan 2015 15:16:10 +0100 Subject: ASoC: pcm512x: Support mastering BCLK/LRCLK using the PLL Using the PLL in master mode requires using an external connection between one of the GPIO pins (configured as PLL/4 output) and the SCK pin. It also requires the external clock to be fed to some other GPIO pin instead of the SCK pin. This is described for the PCM5122 chip in the answers to the forum post "PCM5122 DAC as I2S master troubles with PLL mode" at the TI E2E community pages (1). The clocking functionality is also much better described in the datasheet for the chip PCM5242, which seems to be register compatible with PCM512x and PCM514x (which both have severely lacking datasheets). (1) http://e2e.ti.com/support/data_converters/audio_converters/f/64/t/267830 Signed-off-by: Peter Rosin Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 458 ++++++++++++++++++++++++++++++++++++++++++--- sound/soc/codecs/pcm512x.h | 44 ++++- 2 files changed, 478 insertions(+), 24 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 526e6b30cdde..66dd036f0141 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,11 @@ #include "pcm512x.h" +#define DIV_ROUND_DOWN_ULL(ll, d) \ + ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; }) +#define DIV_ROUND_CLOSEST_ULL(ll, d) \ + ({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; }) + #define PCM512x_NUM_SUPPLIES 3 static const char * const pcm512x_supply_names[PCM512x_NUM_SUPPLIES] = { "AVDD", @@ -41,6 +47,13 @@ struct pcm512x_priv { struct regulator_bulk_data supplies[PCM512x_NUM_SUPPLIES]; struct notifier_block supply_nb[PCM512x_NUM_SUPPLIES]; int fmt; + int pll_in; + int pll_out; + int pll_r; + int pll_j; + int pll_d; + int pll_p; + unsigned long real_pll; }; /* @@ -92,7 +105,13 @@ static const struct reg_default pcm512x_reg_defaults[] = { { PCM512x_VCOM_CTRL_2, 0x01 }, { PCM512x_BCLK_LRCLK_CFG, 0x00 }, { PCM512x_MASTER_MODE, 0x7c }, + { PCM512x_GPIO_PLLIN, 0x00 }, { PCM512x_SYNCHRONIZE, 0x10 }, + { PCM512x_PLL_COEFF_0, 0x00 }, + { PCM512x_PLL_COEFF_1, 0x00 }, + { PCM512x_PLL_COEFF_2, 0x00 }, + { PCM512x_PLL_COEFF_3, 0x00 }, + { PCM512x_PLL_COEFF_4, 0x00 }, { PCM512x_DSP_CLKDIV, 0x00 }, { PCM512x_DAC_CLKDIV, 0x00 }, { PCM512x_NCP_CLKDIV, 0x00 }, @@ -119,6 +138,7 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg) case PCM512x_MASTER_MODE: case PCM512x_PLL_REF: case PCM512x_DAC_REF: + case PCM512x_GPIO_PLLIN: case PCM512x_SYNCHRONIZE: case PCM512x_PLL_COEFF_0: case PCM512x_PLL_COEFF_1: @@ -160,6 +180,7 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg) case PCM512x_RATE_DET_2: case PCM512x_RATE_DET_3: case PCM512x_RATE_DET_4: + case PCM512x_CLOCK_STATUS: case PCM512x_ANALOG_MUTE_DET: case PCM512x_GPIN: case PCM512x_DIGITAL_MUTE_DET: @@ -171,6 +192,8 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg) case PCM512x_VCOM_CTRL_1: case PCM512x_VCOM_CTRL_2: case PCM512x_CRAM_CTRL: + case PCM512x_FLEX_A: + case PCM512x_FLEX_B: return true; default: /* There are 256 raw register addresses */ @@ -187,6 +210,7 @@ static bool pcm512x_volatile(struct device *dev, unsigned int reg) case PCM512x_RATE_DET_2: case PCM512x_RATE_DET_3: case PCM512x_RATE_DET_4: + case PCM512x_CLOCK_STATUS: case PCM512x_ANALOG_MUTE_DET: case PCM512x_GPIN: case PCM512x_DIGITAL_MUTE_DET: @@ -330,6 +354,38 @@ static const struct snd_pcm_hw_constraint_list constraints_slave = { .list = pcm512x_dai_rates, }; +static const struct snd_interval pcm512x_dai_ranges_64bpf[] = { + { + .min = 8000, + .max = 195312, + }, { + .min = 250000, + .max = 390625, + }, +}; + +static struct snd_pcm_hw_constraint_ranges constraints_64bpf = { + .count = ARRAY_SIZE(pcm512x_dai_ranges_64bpf), + .ranges = pcm512x_dai_ranges_64bpf, +}; + +static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) +{ + struct snd_pcm_hw_constraint_ranges *r = rule->private; + int frame_size; + + frame_size = snd_soc_params_to_frame_size(params); + if (frame_size < 0) + return frame_size; + + if (frame_size != 64) + return 0; + + return snd_interval_ranges(hw_param_interval(params, rule->var), + r->count, r->ranges, r->mask); +} + static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -345,6 +401,14 @@ static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream, return PTR_ERR(pcm512x->sclk); } + if (pcm512x->pll_out) + return snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + pcm512x_hw_rule_rate, + (void *)&constraints_64bpf, + SNDRV_PCM_HW_PARAM_FRAME_BITS, + SNDRV_PCM_HW_PARAM_CHANNELS, -1); + constraints_no_pll = devm_kzalloc(dev, sizeof(*constraints_no_pll), GFP_KERNEL); if (!constraints_no_pll) @@ -445,12 +509,164 @@ static int pcm512x_set_bias_level(struct snd_soc_codec *codec, return 0; } +static unsigned long pcm512x_find_sck(struct snd_soc_dai *dai, + unsigned long bclk_rate) +{ + struct device *dev = dai->dev; + unsigned long sck_rate; + int pow2; + + /* 64 MHz <= pll_rate <= 100 MHz, VREF mode */ + /* 16 MHz <= sck_rate <= 25 MHz, VREF mode */ + + /* select sck_rate as a multiple of bclk_rate but still with + * as many factors of 2 as possible, as that makes it easier + * to find a fast DAC rate + */ + pow2 = 1 << fls((25000000 - 16000000) / bclk_rate); + for (; pow2; pow2 >>= 1) { + sck_rate = rounddown(25000000, bclk_rate * pow2); + if (sck_rate >= 16000000) + break; + } + if (!pow2) { + dev_err(dev, "Impossible to generate a suitable SCK\n"); + return 0; + } + + dev_dbg(dev, "sck_rate %lu\n", sck_rate); + return sck_rate; +} + +/* pll_rate = pllin_rate * R * J.D / P + * 1 <= R <= 16 + * 1 <= J <= 63 + * 0 <= D <= 9999 + * 1 <= P <= 15 + * 64 MHz <= pll_rate <= 100 MHz + * if D == 0 + * 1 MHz <= pllin_rate / P <= 20 MHz + * else if D > 0 + * 6.667 MHz <= pllin_rate / P <= 20 MHz + * 4 <= J <= 11 + * R = 1 + */ +static int pcm512x_find_pll_coeff(struct snd_soc_dai *dai, + unsigned long pllin_rate, + unsigned long pll_rate) +{ + struct device *dev = dai->dev; + struct snd_soc_codec *codec = dai->codec; + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + unsigned long common; + int R, J, D, P; + unsigned long K; /* 10000 * J.D */ + unsigned long num; + unsigned long den; + + common = gcd(pll_rate, pllin_rate); + dev_dbg(dev, "pll %lu pllin %lu common %lu\n", + pll_rate, pllin_rate, common); + num = pll_rate / common; + den = pllin_rate / common; + + /* pllin_rate / P (or here, den) cannot be greater than 20 MHz */ + if (pllin_rate / den > 20000000 && num < 8) { + num *= 20000000 / (pllin_rate / den); + den *= 20000000 / (pllin_rate / den); + } + dev_dbg(dev, "num / den = %lu / %lu\n", num, den); + + P = den; + if (den <= 15 && num <= 16 * 63 + && 1000000 <= pllin_rate / P && pllin_rate / P <= 20000000) { + /* Try the case with D = 0 */ + D = 0; + /* factor 'num' into J and R, such that R <= 16 and J <= 63 */ + for (R = 16; R; R--) { + if (num % R) + continue; + J = num / R; + if (J == 0 || J > 63) + continue; + + dev_dbg(dev, "R * J / P = %d * %d / %d\n", R, J, P); + pcm512x->real_pll = pll_rate; + goto done; + } + /* no luck */ + } + + R = 1; + + if (num > 0xffffffffUL / 10000) + goto fallback; + + /* Try to find an exact pll_rate using the D > 0 case */ + common = gcd(10000 * num, den); + num = 10000 * num / common; + den /= common; + dev_dbg(dev, "num %lu den %lu common %lu\n", num, den, common); + + for (P = den; P <= 15; P++) { + if (pllin_rate / P < 6667000 || 200000000 < pllin_rate / P) + continue; + if (num * P % den) + continue; + K = num * P / den; + /* J == 12 is ok if D == 0 */ + if (K < 40000 || K > 120000) + continue; + + J = K / 10000; + D = K % 10000; + dev_dbg(dev, "J.D / P = %d.%04d / %d\n", J, D, P); + pcm512x->real_pll = pll_rate; + goto done; + } + + /* Fall back to an approximate pll_rate */ + +fallback: + /* find smallest possible P */ + P = DIV_ROUND_UP(pllin_rate, 20000000); + if (!P) + P = 1; + else if (P > 15) { + dev_err(dev, "Need a slower clock as pll-input\n"); + return -EINVAL; + } + if (pllin_rate / P < 6667000) { + dev_err(dev, "Need a faster clock as pll-input\n"); + return -EINVAL; + } + K = DIV_ROUND_CLOSEST_ULL(10000ULL * pll_rate * P, pllin_rate); + if (K < 40000) + K = 40000; + /* J == 12 is ok if D == 0 */ + if (K > 120000) + K = 120000; + J = K / 10000; + D = K % 10000; + dev_dbg(dev, "J.D / P ~ %d.%04d / %d\n", J, D, P); + pcm512x->real_pll = DIV_ROUND_DOWN_ULL((u64)K * pllin_rate, 10000 * P); + +done: + pcm512x->pll_r = R; + pcm512x->pll_j = J; + pcm512x->pll_d = D; + pcm512x->pll_p = P; + return 0; +} + static int pcm512x_set_dividers(struct snd_soc_dai *dai, struct snd_pcm_hw_params *params) { struct device *dev = dai->dev; struct snd_soc_codec *codec = dai->codec; struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + unsigned long pllin_rate = 0; + unsigned long pll_rate; unsigned long sck_rate; unsigned long mck_rate; unsigned long bclk_rate; @@ -475,11 +691,74 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, return -EINVAL; } - sck_rate = clk_get_rate(pcm512x->sclk); - bclk_div = params->rate_den * 64 / lrclk_div; - bclk_rate = DIV_ROUND_CLOSEST(sck_rate, bclk_div); + if (!pcm512x->pll_out) { + sck_rate = clk_get_rate(pcm512x->sclk); + bclk_div = params->rate_den * 64 / lrclk_div; + bclk_rate = DIV_ROUND_CLOSEST(sck_rate, bclk_div); - mck_rate = sck_rate; + mck_rate = sck_rate; + } else { + ret = snd_soc_params_to_bclk(params); + if (ret < 0) { + dev_err(dev, "Failed to find suitable BCLK: %d\n", ret); + return ret; + } + if (ret == 0) { + dev_err(dev, "No BCLK?\n"); + return -EINVAL; + } + bclk_rate = ret; + + pllin_rate = clk_get_rate(pcm512x->sclk); + + sck_rate = pcm512x_find_sck(dai, bclk_rate); + if (!sck_rate) + return -EINVAL; + pll_rate = 4 * sck_rate; + + ret = pcm512x_find_pll_coeff(dai, pllin_rate, pll_rate); + if (ret != 0) + return ret; + + ret = regmap_write(pcm512x->regmap, + PCM512x_PLL_COEFF_0, pcm512x->pll_p - 1); + if (ret != 0) { + dev_err(dev, "Failed to write PLL P: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, + PCM512x_PLL_COEFF_1, pcm512x->pll_j); + if (ret != 0) { + dev_err(dev, "Failed to write PLL J: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, + PCM512x_PLL_COEFF_2, pcm512x->pll_d >> 8); + if (ret != 0) { + dev_err(dev, "Failed to write PLL D msb: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, + PCM512x_PLL_COEFF_3, pcm512x->pll_d & 0xff); + if (ret != 0) { + dev_err(dev, "Failed to write PLL D lsb: %d\n", ret); + return ret; + } + + ret = regmap_write(pcm512x->regmap, + PCM512x_PLL_COEFF_4, pcm512x->pll_r - 1); + if (ret != 0) { + dev_err(dev, "Failed to write PLL R: %d\n", ret); + return ret; + } + + mck_rate = pcm512x->real_pll; + + bclk_div = DIV_ROUND_CLOSEST(sck_rate, bclk_rate); + } if (bclk_div > 128) { dev_err(dev, "Failed to find BCLK divider\n"); @@ -616,6 +895,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, struct snd_soc_codec *codec = dai->codec; struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); int alen; + int gpio; int ret; dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n", @@ -676,26 +956,55 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, return ret; } - ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, - PCM512x_IDFS | PCM512x_IDBK - | PCM512x_IDSK | PCM512x_IDCH - | PCM512x_IDCM | PCM512x_DCAS - | PCM512x_IPLK, - PCM512x_IDFS | PCM512x_IDBK - | PCM512x_IDSK | PCM512x_IDCH - | PCM512x_DCAS | PCM512x_IPLK); - if (ret != 0) { - dev_err(codec->dev, - "Failed to ignore auto-clock failures: %d\n", - ret); - return ret; - } + if (pcm512x->pll_out) { + ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_A, 0x11); + if (ret != 0) { + dev_err(codec->dev, "Failed to set FLEX_A: %d\n", ret); + return ret; + } - ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, - PCM512x_PLLE, 0); - if (ret != 0) { - dev_err(codec->dev, "Failed to disable pll: %d\n", ret); - return ret; + ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_B, 0xff); + if (ret != 0) { + dev_err(codec->dev, "Failed to set FLEX_B: %d\n", ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, + PCM512x_IDFS | PCM512x_IDBK + | PCM512x_IDSK | PCM512x_IDCH + | PCM512x_IDCM | PCM512x_DCAS + | PCM512x_IPLK, + PCM512x_IDFS | PCM512x_IDBK + | PCM512x_IDSK | PCM512x_IDCH + | PCM512x_DCAS); + if (ret != 0) { + dev_err(codec->dev, + "Failed to ignore auto-clock failures: %d\n", + ret); + return ret; + } + } else { + ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, + PCM512x_IDFS | PCM512x_IDBK + | PCM512x_IDSK | PCM512x_IDCH + | PCM512x_IDCM | PCM512x_DCAS + | PCM512x_IPLK, + PCM512x_IDFS | PCM512x_IDBK + | PCM512x_IDSK | PCM512x_IDCH + | PCM512x_DCAS | PCM512x_IPLK); + if (ret != 0) { + dev_err(codec->dev, + "Failed to ignore auto-clock failures: %d\n", + ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, + PCM512x_PLLE, 0); + if (ret != 0) { + dev_err(codec->dev, "Failed to disable pll: %d\n", ret); + return ret; + } } ret = pcm512x_set_dividers(dai, params); @@ -709,6 +1018,33 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, return ret; } + if (pcm512x->pll_out) { + ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_REF, + PCM512x_SREF, PCM512x_SREF_GPIO); + if (ret != 0) { + dev_err(codec->dev, + "Failed to set gpio as pllref: %d\n", ret); + return ret; + } + + gpio = PCM512x_GREF_GPIO1 + pcm512x->pll_in - 1; + ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_PLLIN, + PCM512x_GREF, gpio); + if (ret != 0) { + dev_err(codec->dev, + "Failed to set gpio %d as pllin: %d\n", + pcm512x->pll_in, ret); + return ret; + } + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, + PCM512x_PLLE, PCM512x_PLLE); + if (ret != 0) { + dev_err(codec->dev, "Failed to enable pll: %d\n", ret); + return ret; + } + } + ret = regmap_update_bits(pcm512x->regmap, PCM512x_BCLK_LRCLK_CFG, PCM512x_BCKP | PCM512x_BCKO | PCM512x_LRKO, PCM512x_BCKO | PCM512x_LRKO); @@ -725,6 +1061,45 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, return ret; } + if (pcm512x->pll_out) { + gpio = PCM512x_G1OE << (pcm512x->pll_out - 1); + ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN, + gpio, gpio); + if (ret != 0) { + dev_err(codec->dev, "Failed to enable gpio %d: %d\n", + pcm512x->pll_out, ret); + return ret; + } + + gpio = PCM512x_GPIO_OUTPUT_1 + pcm512x->pll_out - 1; + ret = regmap_update_bits(pcm512x->regmap, gpio, + PCM512x_GxSL, PCM512x_GxSL_PLLCK); + if (ret != 0) { + dev_err(codec->dev, "Failed to output pll on %d: %d\n", + ret, pcm512x->pll_out); + return ret; + } + + gpio = PCM512x_G1OE << (4 - 1); + ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN, + gpio, gpio); + if (ret != 0) { + dev_err(codec->dev, "Failed to enable gpio %d: %d\n", + 4, ret); + return ret; + } + + gpio = PCM512x_GPIO_OUTPUT_1 + 4 - 1; + ret = regmap_update_bits(pcm512x->regmap, gpio, + PCM512x_GxSL, PCM512x_GxSL_PLLLK); + if (ret != 0) { + dev_err(codec->dev, + "Failed to output pll lock on %d: %d\n", + ret, 4); + return ret; + } + } + ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, PCM512x_RQSY, PCM512x_RQSY_HALT); if (ret != 0) { @@ -815,6 +1190,7 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) { struct pcm512x_priv *pcm512x; int i, ret; + u32 val; pcm512x = devm_kzalloc(dev, sizeof(struct pcm512x_priv), GFP_KERNEL); if (!pcm512x) @@ -892,6 +1268,42 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) pm_runtime_enable(dev); pm_runtime_idle(dev); +#ifdef CONFIG_OF + if (dev->of_node) { + const struct device_node *np = dev->of_node; + + if (of_property_read_u32(np, "pll-in", &val) >= 0) { + if (val > 6) { + dev_err(dev, "Invalid pll-in\n"); + ret = -EINVAL; + goto err_clk; + } + pcm512x->pll_in = val; + } + + if (of_property_read_u32(np, "pll-out", &val) >= 0) { + if (val > 6) { + dev_err(dev, "Invalid pll-out\n"); + ret = -EINVAL; + goto err_clk; + } + pcm512x->pll_out = val; + } + + if (!pcm512x->pll_in != !pcm512x->pll_out) { + dev_err(dev, + "Error: both pll-in and pll-out, or none\n"); + ret = -EINVAL; + goto err_clk; + } + if (pcm512x->pll_in && pcm512x->pll_in == pcm512x->pll_out) { + dev_err(dev, "Error: pll-in == pll-out\n"); + ret = -EINVAL; + goto err_clk; + } + } +#endif + ret = snd_soc_register_codec(dev, &pcm512x_codec_driver, &pcm512x_dai, 1); if (ret != 0) { diff --git a/sound/soc/codecs/pcm512x.h b/sound/soc/codecs/pcm512x.h index fa538d5aabf2..eba5adc2cdb1 100644 --- a/sound/soc/codecs/pcm512x.h +++ b/sound/soc/codecs/pcm512x.h @@ -38,6 +38,7 @@ #define PCM512x_MASTER_MODE (PCM512x_PAGE_BASE(0) + 12) #define PCM512x_PLL_REF (PCM512x_PAGE_BASE(0) + 13) #define PCM512x_DAC_REF (PCM512x_PAGE_BASE(0) + 14) +#define PCM512x_GPIO_PLLIN (PCM512x_PAGE_BASE(0) + 18) #define PCM512x_SYNCHRONIZE (PCM512x_PAGE_BASE(0) + 19) #define PCM512x_PLL_COEFF_0 (PCM512x_PAGE_BASE(0) + 20) #define PCM512x_PLL_COEFF_1 (PCM512x_PAGE_BASE(0) + 21) @@ -79,6 +80,7 @@ #define PCM512x_RATE_DET_2 (PCM512x_PAGE_BASE(0) + 92) #define PCM512x_RATE_DET_3 (PCM512x_PAGE_BASE(0) + 93) #define PCM512x_RATE_DET_4 (PCM512x_PAGE_BASE(0) + 94) +#define PCM512x_CLOCK_STATUS (PCM512x_PAGE_BASE(0) + 95) #define PCM512x_ANALOG_MUTE_DET (PCM512x_PAGE_BASE(0) + 108) #define PCM512x_GPIN (PCM512x_PAGE_BASE(0) + 119) #define PCM512x_DIGITAL_MUTE_DET (PCM512x_PAGE_BASE(0) + 120) @@ -93,7 +95,10 @@ #define PCM512x_CRAM_CTRL (PCM512x_PAGE_BASE(44) + 1) -#define PCM512x_MAX_REGISTER (PCM512x_PAGE_BASE(44) + 1) +#define PCM512x_FLEX_A (PCM512x_PAGE_BASE(253) + 63) +#define PCM512x_FLEX_B (PCM512x_PAGE_BASE(253) + 64) + +#define PCM512x_MAX_REGISTER (PCM512x_PAGE_BASE(253) + 64) /* Page 0, Register 1 - reset */ #define PCM512x_RSTR (1 << 0) @@ -121,6 +126,14 @@ #define PCM512x_DEMP (1 << 4) #define PCM512x_DEMP_SHIFT 4 +/* Page 0, Register 8 - GPIO output enable */ +#define PCM512x_G1OE (1 << 0) +#define PCM512x_G2OE (1 << 1) +#define PCM512x_G3OE (1 << 2) +#define PCM512x_G4OE (1 << 3) +#define PCM512x_G5OE (1 << 4) +#define PCM512x_G6OE (1 << 5) + /* Page 0, Register 9 - BCK, LRCLK configuration */ #define PCM512x_LRKO (1 << 0) #define PCM512x_LRKO_SHIFT 0 @@ -150,6 +163,16 @@ #define PCM512x_SDAC_SCK (3 << 4) #define PCM512x_SDAC_BCK (4 << 4) +/* Page 0, Register 18 - GPIO source for PLL */ +#define PCM512x_GREF (7 << 0) +#define PCM512x_GREF_SHIFT 0 +#define PCM512x_GREF_GPIO1 (0 << 0) +#define PCM512x_GREF_GPIO2 (1 << 0) +#define PCM512x_GREF_GPIO3 (2 << 0) +#define PCM512x_GREF_GPIO4 (3 << 0) +#define PCM512x_GREF_GPIO5 (4 << 0) +#define PCM512x_GREF_GPIO6 (5 << 0) + /* Page 0, Register 19 - synchronize */ #define PCM512x_RQSY (1 << 0) #define PCM512x_RQSY_RESUME (0 << 0) @@ -209,6 +232,25 @@ #define PCM512x_AMLE_SHIFT 1 #define PCM512x_AMRE_SHIFT 0 +/* Page 0, Register 80-85, GPIO output selection */ +#define PCM512x_GxSL (31 << 0) +#define PCM512x_GxSL_SHIFT 0 +#define PCM512x_GxSL_OFF (0 << 0) +#define PCM512x_GxSL_DSP (1 << 0) +#define PCM512x_GxSL_REG (2 << 0) +#define PCM512x_GxSL_AMUTB (3 << 0) +#define PCM512x_GxSL_AMUTL (4 << 0) +#define PCM512x_GxSL_AMUTR (5 << 0) +#define PCM512x_GxSL_CLKI (6 << 0) +#define PCM512x_GxSL_SDOUT (7 << 0) +#define PCM512x_GxSL_ANMUL (8 << 0) +#define PCM512x_GxSL_ANMUR (9 << 0) +#define PCM512x_GxSL_PLLLK (10 << 0) +#define PCM512x_GxSL_CPCLK (11 << 0) +#define PCM512x_GxSL_UV0_7 (14 << 0) +#define PCM512x_GxSL_UV0_3 (15 << 0) +#define PCM512x_GxSL_PLLCK (16 << 0) + /* Page 1, Register 2 - analog volume control */ #define PCM512x_RAGN_SHIFT 0 #define PCM512x_LAGN_SHIFT 4 -- cgit From 7c4e1119a99c5a54d38d67a66070c081fda52634 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 28 Jan 2015 15:16:11 +0100 Subject: ASoC: pcm512x: Avoid the PLL for the DAC clock, if possible The PLL introduces jitter, which in turn introduces noice if used to clock the DAC. Thus, avoid the PLL output, and use the PLL input to drive the DAC clock, if possible. This is described for the PCM5142/PCM5242 chips in the answers to the forum post "PCM5142/PCM5242 DAC clock source" at the TI E2E community pages (1). (1) http://e2e.ti.com/support/data_converters/audio_converters/f/64/t/389994 Signed-off-by: Peter Rosin Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 119 +++++++++++++++++++++++++++++++++++---------- sound/soc/codecs/pcm512x.h | 4 +- 2 files changed, 96 insertions(+), 27 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 66dd036f0141..8b474196d52a 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -105,6 +105,7 @@ static const struct reg_default pcm512x_reg_defaults[] = { { PCM512x_VCOM_CTRL_2, 0x01 }, { PCM512x_BCLK_LRCLK_CFG, 0x00 }, { PCM512x_MASTER_MODE, 0x7c }, + { PCM512x_GPIO_DACIN, 0x00 }, { PCM512x_GPIO_PLLIN, 0x00 }, { PCM512x_SYNCHRONIZE, 0x10 }, { PCM512x_PLL_COEFF_0, 0x00 }, @@ -138,6 +139,7 @@ static bool pcm512x_readable(struct device *dev, unsigned int reg) case PCM512x_MASTER_MODE: case PCM512x_PLL_REF: case PCM512x_DAC_REF: + case PCM512x_GPIO_DACIN: case PCM512x_GPIO_PLLIN: case PCM512x_SYNCHRONIZE: case PCM512x_PLL_COEFF_0: @@ -659,6 +661,37 @@ done: return 0; } +static unsigned long pcm512x_pllin_dac_rate(struct snd_soc_dai *dai, + unsigned long osr_rate, + unsigned long pllin_rate) +{ + struct snd_soc_codec *codec = dai->codec; + struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + unsigned long dac_rate; + + if (!pcm512x->pll_out) + return 0; /* no PLL to bypass, force SCK as DAC input */ + + if (pllin_rate % osr_rate) + return 0; /* futile, quit early */ + + /* run DAC no faster than 6144000 Hz */ + for (dac_rate = rounddown(6144000, osr_rate); + dac_rate; + dac_rate -= osr_rate) { + + if (pllin_rate / dac_rate > 128) + return 0; /* DAC divider would be too big */ + + if (!(pllin_rate % dac_rate)) + return dac_rate; + + dac_rate -= osr_rate; + } + + return 0; +} + static int pcm512x_set_dividers(struct snd_soc_dai *dai, struct snd_pcm_hw_params *params) { @@ -672,6 +705,7 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, unsigned long bclk_rate; unsigned long sample_rate; unsigned long osr_rate; + unsigned long dacsrc_rate; int bclk_div; int lrclk_div; int dsp_div; @@ -679,11 +713,10 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, unsigned long dac_rate; int ncp_div; int osr_div; - unsigned long dac_mul; - unsigned long sck_mul; int ret; int idac; int fssp; + int gpio; lrclk_div = snd_soc_params_to_frame_size(params); if (lrclk_div == 0) { @@ -772,31 +805,72 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, /* run DSP no faster than 50 MHz */ dsp_div = mck_rate > 50000000 ? 2 : 1; - /* run DAC no faster than 6144000 Hz */ - dac_mul = 6144000 / osr_rate; - sck_mul = sck_rate / osr_rate; - for (; dac_mul; dac_mul--) { - if (!(sck_mul % dac_mul)) - break; - } - if (!dac_mul) { - dev_err(dev, "Failed to find DAC rate\n"); - return -EINVAL; - } + dac_rate = pcm512x_pllin_dac_rate(dai, osr_rate, pllin_rate); + if (dac_rate) { + /* the desired clock rate is "compatible" with the pll input + * clock, so use that clock as dac input instead of the pll + * output clock since the pll will introduce jitter and thus + * noise. + */ + dev_dbg(dev, "using pll input as dac input\n"); + ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, + PCM512x_SDAC, PCM512x_SDAC_GPIO); + if (ret != 0) { + dev_err(codec->dev, + "Failed to set gpio as dacref: %d\n", ret); + return ret; + } - dac_rate = dac_mul * osr_rate; - dev_dbg(dev, "dac_rate %lu sample_rate %lu\n", dac_rate, sample_rate); + gpio = PCM512x_GREF_GPIO1 + pcm512x->pll_in - 1; + ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_DACIN, + PCM512x_GREF, gpio); + if (ret != 0) { + dev_err(codec->dev, + "Failed to set gpio %d as dacin: %d\n", + pcm512x->pll_in, ret); + return ret; + } + + dacsrc_rate = pllin_rate; + } else { + /* run DAC no faster than 6144000 Hz */ + unsigned long dac_mul = 6144000 / osr_rate; + unsigned long sck_mul = sck_rate / osr_rate; + + for (; dac_mul; dac_mul--) { + if (!(sck_mul % dac_mul)) + break; + } + if (!dac_mul) { + dev_err(dev, "Failed to find DAC rate\n"); + return -EINVAL; + } - dac_div = DIV_ROUND_CLOSEST(sck_rate, dac_rate); + dac_rate = dac_mul * osr_rate; + dev_dbg(dev, "dac_rate %lu sample_rate %lu\n", + dac_rate, sample_rate); + + ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, + PCM512x_SDAC, PCM512x_SDAC_SCK); + if (ret != 0) { + dev_err(codec->dev, + "Failed to set sck as dacref: %d\n", ret); + return ret; + } + + dacsrc_rate = sck_rate; + } + + dac_div = DIV_ROUND_CLOSEST(dacsrc_rate, dac_rate); if (dac_div > 128) { dev_err(dev, "Failed to find DAC divider\n"); return -EINVAL; } - ncp_div = DIV_ROUND_CLOSEST(sck_rate / dac_div, 1536000); - if (ncp_div > 128 || sck_rate / dac_div / ncp_div > 2048000) { + ncp_div = DIV_ROUND_CLOSEST(dacsrc_rate / dac_div, 1536000); + if (ncp_div > 128 || dacsrc_rate / dac_div / ncp_div > 2048000) { /* run NCP no faster than 2048000 Hz, but why? */ - ncp_div = DIV_ROUND_UP(sck_rate / dac_div, 2048000); + ncp_div = DIV_ROUND_UP(dacsrc_rate / dac_div, 2048000); if (ncp_div > 128) { dev_err(dev, "Failed to find NCP divider\n"); return -EINVAL; @@ -1011,13 +1085,6 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, if (ret != 0) return ret; - ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, - PCM512x_SDAC, PCM512x_SDAC_SCK); - if (ret != 0) { - dev_err(codec->dev, "Failed to set sck as dacref: %d\n", ret); - return ret; - } - if (pcm512x->pll_out) { ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_REF, PCM512x_SREF, PCM512x_SREF_GPIO); diff --git a/sound/soc/codecs/pcm512x.h b/sound/soc/codecs/pcm512x.h index eba5adc2cdb1..b7c310207223 100644 --- a/sound/soc/codecs/pcm512x.h +++ b/sound/soc/codecs/pcm512x.h @@ -38,6 +38,7 @@ #define PCM512x_MASTER_MODE (PCM512x_PAGE_BASE(0) + 12) #define PCM512x_PLL_REF (PCM512x_PAGE_BASE(0) + 13) #define PCM512x_DAC_REF (PCM512x_PAGE_BASE(0) + 14) +#define PCM512x_GPIO_DACIN (PCM512x_PAGE_BASE(0) + 16) #define PCM512x_GPIO_PLLIN (PCM512x_PAGE_BASE(0) + 18) #define PCM512x_SYNCHRONIZE (PCM512x_PAGE_BASE(0) + 19) #define PCM512x_PLL_COEFF_0 (PCM512x_PAGE_BASE(0) + 20) @@ -162,8 +163,9 @@ #define PCM512x_SDAC_PLL (1 << 4) #define PCM512x_SDAC_SCK (3 << 4) #define PCM512x_SDAC_BCK (4 << 4) +#define PCM512x_SDAC_GPIO (5 << 4) -/* Page 0, Register 18 - GPIO source for PLL */ +/* Page 0, Register 16, 18 - GPIO source for DAC, PLL */ #define PCM512x_GREF (7 << 0) #define PCM512x_GREF_SHIFT 0 #define PCM512x_GREF_GPIO1 (0 << 0) -- cgit From d11c2978bfbe97a4c29bd78b491c14f2debb36cd Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 28 Jan 2015 15:16:12 +0100 Subject: ASoC: pcm512x: Support SND_SOC_DAIFMT_CBM_CFS Signed-off-by: Peter Rosin Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 8b474196d52a..51b279e3f465 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -464,6 +464,7 @@ static int pcm512x_dai_startup(struct snd_pcm_substream *substream, switch (pcm512x->fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: + case SND_SOC_DAIFMT_CBM_CFS: return pcm512x_dai_startup_master(substream, dai); case SND_SOC_DAIFMT_CBS_CFS: @@ -970,6 +971,8 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); int alen; int gpio; + int clock_output; + int master_mode; int ret; dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n", @@ -1018,6 +1021,12 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, } return 0; case SND_SOC_DAIFMT_CBM_CFM: + clock_output = PCM512x_BCKO | PCM512x_LRKO; + master_mode = PCM512x_RLRK | PCM512x_RBCK; + break; + case SND_SOC_DAIFMT_CBM_CFS: + clock_output = PCM512x_BCKO; + master_mode = PCM512x_RBCK; break; default: return -EINVAL; @@ -1114,7 +1123,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_BCLK_LRCLK_CFG, PCM512x_BCKP | PCM512x_BCKO | PCM512x_LRKO, - PCM512x_BCKO | PCM512x_LRKO); + clock_output); if (ret != 0) { dev_err(codec->dev, "Failed to enable clock output: %d\n", ret); return ret; @@ -1122,7 +1131,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_MASTER_MODE, PCM512x_RLRK | PCM512x_RBCK, - PCM512x_RLRK | PCM512x_RBCK); + master_mode); if (ret != 0) { dev_err(codec->dev, "Failed to enable master mode: %d\n", ret); return ret; -- cgit From b1a5fad5f8c063abfd9bd22f7de8de82927c7d54 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Tue, 27 Jan 2015 11:36:39 +0800 Subject: ASoC: wm8904: add dt ids table The WM8904 and WM8918 has the same data type, while the WM8912 has different data type. So, use the data in dt ids table to distinguish them. Signed-off-by: Alexander Morozov [voice.shen@atmel.com: add code to distinguish device type] Signed-off-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/codecs/wm8904.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 4d2d2b1380d5..a80bc528431a 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -2098,6 +2098,24 @@ static const struct regmap_config wm8904_regmap = { .num_reg_defaults = ARRAY_SIZE(wm8904_reg_defaults), }; +#ifdef CONFIG_OF +static enum wm8904_type wm8904_data = WM8904; +static enum wm8904_type wm8912_data = WM8912; + +static const struct of_device_id wm8904_of_match[] = { + { + .compatible = "wlf,wm8904", + .data = &wm8904_data, + }, { + .compatible = "wlf,wm8912", + .data = &wm8912_data, + }, { + /* sentinel */ + } +}; +MODULE_DEVICE_TABLE(of, wm8904_of_match); +#endif + static int wm8904_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -2125,7 +2143,17 @@ static int wm8904_i2c_probe(struct i2c_client *i2c, return ret; } - wm8904->devtype = id->driver_data; + if (i2c->dev.of_node) { + const struct of_device_id *match; + + match = of_match_node(wm8904_of_match, i2c->dev.of_node); + if (match == NULL) + return -EINVAL; + wm8904->devtype = *((enum wm8904_type *)match->data); + } else { + wm8904->devtype = id->driver_data; + } + i2c_set_clientdata(i2c, wm8904); wm8904->pdata = i2c->dev.platform_data; @@ -2259,6 +2287,7 @@ static struct i2c_driver wm8904_i2c_driver = { .driver = { .name = "wm8904", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(wm8904_of_match), }, .probe = wm8904_i2c_probe, .remove = wm8904_i2c_remove, -- cgit From 0416980d0a2bc10acff1c2329159577036e5666b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 12:29:05 +0100 Subject: ALSA: line6: Fix volume calculation for big-endian Signed-off-by: Takashi Iwai --- sound/usb/line6/playback.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 1708c05f14db..ae41124c351e 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -31,14 +31,16 @@ static void change_volume(struct urb *urb_out, int volume[], return; /* maximum volume - no change */ if (bytes_per_frame == 4) { - short *p, *buf_end; + __le16 *p, *buf_end; - p = (short *)urb_out->transfer_buffer; + p = (__le16 *)urb_out->transfer_buffer; buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); for (; p < buf_end; ++p) { - int val = (*p * volume[chn & 1]) >> 8; - *p = clamp(val, 0x7fff, -0x8000); + short pv = le16_to_cpu(*p); + int val = (pv * volume[chn & 1]) >> 8; + pv = clamp(val, 0x7fff, -0x8000); + *p = cpu_to_le16(pv); ++chn; } } else if (bytes_per_frame == 6) { @@ -114,15 +116,18 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal, return; /* zero volume - no change */ if (bytes_per_frame == 4) { - short *pi, *po, *buf_end; + __le16 *pi, *po, *buf_end; - pi = (short *)signal; - po = (short *)urb_out->transfer_buffer; + pi = (__le16 *)signal; + po = (__le16 *)urb_out->transfer_buffer; buf_end = po + urb_out->transfer_buffer_length / sizeof(*po); for (; po < buf_end; ++pi, ++po) { - int val = *po + ((*pi * volume) >> 8); - *po = clamp(val, 0x7fff, -0x8000); + short pov = le16_to_cpu(*po); + short piv = le16_to_cpu(*pi); + int val = pov + ((piv * volume) >> 8); + pov = clamp(val, 0x7fff, -0x8000); + *po = cpu_to_le16(pov); } } -- cgit From cddbd4f17078530b4914a42f6d7f3e543b5fad0e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 14:43:11 +0100 Subject: ALSA: line6: Tidy up and typo fixes in comments Just reformatting the comments and typos fixed, no functional changes. Particularly, - avoid the kerneldoc marker "/**", - reduce multiple comment lines into single lines, - corrected wrongly referred function names Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 2 +- sound/usb/line6/driver.h | 73 ++++++++++++++-------------------------------- sound/usb/line6/midi.h | 32 +++++--------------- sound/usb/line6/pcm.h | 52 +++++++++------------------------ sound/usb/line6/pod.c | 32 +++++--------------- sound/usb/line6/podhd.c | 4 +-- sound/usb/line6/toneport.c | 24 ++++----------- sound/usb/line6/variax.c | 20 ++++--------- 8 files changed, 65 insertions(+), 174 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index a0436993a167..f46da99c44b3 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -44,7 +44,7 @@ static const char line6_request_version[] = { 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7 }; -/** +/* Class for asynchronous messages. */ struct message { diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index fce10f12f0d3..80d42a0fd889 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -60,26 +60,20 @@ extern const unsigned char line6_midi_id[3]; static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3; static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4; -/** +/* Common properties of Line 6 devices. */ struct line6_properties { - /** - Card id string (maximum 16 characters). - This can be used to address the device in ALSA programs as - "default:CARD=" - */ + /* Card id string (maximum 16 characters). + * This can be used to address the device in ALSA programs as + * "default:CARD=" + */ const char *id; - /** - Card short name (maximum 32 characters). - */ + /* Card short name (maximum 32 characters) */ const char *name; - /** - Bit vector defining this device's capabilities in the - line6usb driver. - */ + /* Bit vector defining this device's capabilities in line6usb driver */ int capabilities; int altsetting; @@ -90,70 +84,47 @@ struct line6_properties { unsigned ep_audio_w; }; -/** +/* Common data shared by all Line 6 devices. Corresponds to a pair of USB endpoints. */ struct usb_line6 { - /** - USB device. - */ + /* USB device */ struct usb_device *usbdev; - /** - Properties. - */ + /* Properties */ const struct line6_properties *properties; - /** - Interval (ms). - */ + /* Interval (ms) */ int interval; - /** - Maximum size of USB packet. - */ + /* Maximum size of USB packet */ int max_packet_size; - /** - Device representing the USB interface. - */ + /* Device representing the USB interface */ struct device *ifcdev; - /** - Line 6 sound card data structure. - Each device has at least MIDI or PCM. - */ + /* Line 6 sound card data structure. + * Each device has at least MIDI or PCM. + */ struct snd_card *card; - /** - Line 6 PCM device data structure. - */ + /* Line 6 PCM device data structure */ struct snd_line6_pcm *line6pcm; - /** - Line 6 MIDI device data structure. - */ + /* Line 6 MIDI device data structure */ struct snd_line6_midi *line6midi; - /** - URB for listening to PODxt Pro control endpoint. - */ + /* URB for listening to PODxt Pro control endpoint */ struct urb *urb_listen; - /** - Buffer for listening to PODxt Pro control endpoint. - */ + /* Buffer for listening to PODxt Pro control endpoint */ unsigned char *buffer_listen; - /** - Buffer for message to be processed. - */ + /* Buffer for message to be processed */ unsigned char *buffer_message; - /** - Length of message to be processed. - */ + /* Length of message to be processed */ int message_length; void (*process_message)(struct usb_line6 *); diff --git a/sound/usb/line6/midi.h b/sound/usb/line6/midi.h index 9d9467b2613c..cf82d69e2747 100644 --- a/sound/usb/line6/midi.h +++ b/sound/usb/line6/midi.h @@ -19,44 +19,28 @@ #define MIDI_BUFFER_SIZE 1024 struct snd_line6_midi { - /** - Pointer back to the Line 6 driver data structure. - */ + /* Pointer back to the Line 6 driver data structure */ struct usb_line6 *line6; - /** - MIDI substream for receiving (or NULL if not active). - */ + /* MIDI substream for receiving (or NULL if not active) */ struct snd_rawmidi_substream *substream_receive; - /** - MIDI substream for transmitting (or NULL if not active). - */ + /* MIDI substream for transmitting (or NULL if not active) */ struct snd_rawmidi_substream *substream_transmit; - /** - Number of currently active MIDI send URBs. - */ + /* Number of currently active MIDI send URBs */ int num_active_send_urbs; - /** - Spin lock to protect MIDI buffer handling. - */ + /* Spin lock to protect MIDI buffer handling */ spinlock_t lock; - /** - Wait queue for MIDI transmission. - */ + /* Wait queue for MIDI transmission */ wait_queue_head_t send_wait; - /** - Buffer for incoming MIDI stream. - */ + /* Buffer for incoming MIDI stream */ struct midi_buffer midibuf_in; - /** - Buffer for outgoing MIDI stream. - */ + /* Buffer for outgoing MIDI stream */ struct midi_buffer midibuf_out; }; diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index 42d3e6fc2c61..19c12f0a9008 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -66,8 +66,8 @@ the running flag indicates whether the stream is running. For monitor or impulse operations, the driver needs to call - snd_line6_duplex_acquire() or snd_line6_duplex_release() with the - appropriate LINE6_STREAM_* flag. + line6_pcm_acquire() or line6_pcm_release() with the appropriate + LINE6_STREAM_* flag. */ /* stream types */ @@ -139,19 +139,13 @@ struct line6_pcm_stream { }; struct snd_line6_pcm { - /** - Pointer back to the Line 6 driver data structure. - */ + /* Pointer back to the Line 6 driver data structure */ struct usb_line6 *line6; - /** - Properties. - */ + /* Properties. */ struct line6_pcm_properties *properties; - /** - ALSA pcm stream - */ + /* ALSA pcm stream */ struct snd_pcm *pcm; /* protection to state changes of in/out streams */ @@ -161,49 +155,31 @@ struct snd_line6_pcm { struct line6_pcm_stream in; struct line6_pcm_stream out; - /** - Previously captured frame (for software monitoring). - */ + /* Previously captured frame (for software monitoring) */ unsigned char *prev_fbuf; - /** - Size of previously captured frame (for software monitoring). - */ + /* Size of previously captured frame (for software monitoring) */ int prev_fsize; - /** - Maximum size of USB packet. - */ + /* Maximum size of USB packet */ int max_packet_size; - /** - PCM playback volume (left and right). - */ + /* PCM playback volume (left and right) */ int volume_playback[2]; - /** - PCM monitor volume. - */ + /* PCM monitor volume */ int volume_monitor; - /** - Volume of impulse response test signal (if zero, test is disabled). - */ + /* Volume of impulse response test signal (if zero, test is disabled) */ int impulse_volume; - /** - Period of impulse response test signal. - */ + /* Period of impulse response test signal */ int impulse_period; - /** - Counter for impulse response test signal. - */ + /* Counter for impulse response test signal */ int impulse_count; - /** - Several status bits (see LINE6_FLAG_*). - */ + /* Several status bits (see LINE6_FLAG_*) */ unsigned long flags; }; diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 6f7cd585f2d8..bc20cf141719 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -58,44 +58,28 @@ enum { }; struct usb_line6_pod { - /** - Generic Line 6 USB data. - */ + /* Generic Line 6 USB data */ struct usb_line6 line6; - /** - Instrument monitor level. - */ + /* Instrument monitor level */ int monitor_level; - /** - Timer for device initializaton. - */ + /* Timer for device initialization */ struct timer_list startup_timer; - /** - Work handler for device initializaton. - */ + /* Work handler for device initialization */ struct work_struct startup_work; - /** - Current progress in startup procedure. - */ + /* Current progress in startup procedure */ int startup_progress; - /** - Serial number of device. - */ + /* Serial number of device */ int serial_number; - /** - Firmware version (x 100). - */ + /* Firmware version (x 100) */ int firmware_version; - /** - Device ID. - */ + /* Device ID */ int device_id; }; diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 43c39886597e..c4e83ab33a21 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -27,9 +27,7 @@ enum { }; struct usb_line6_podhd { - /** - Generic Line 6 USB data. - */ + /* Generic Line 6 USB data */ struct usb_line6 line6; }; diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 819e06b3f3db..9024acb2b850 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -43,34 +43,22 @@ struct toneport_led { }; struct usb_line6_toneport { - /** - Generic Line 6 USB data. - */ + /* Generic Line 6 USB data */ struct usb_line6 line6; - /** - Source selector. - */ + /* Source selector */ int source; - /** - Serial number of device. - */ + /* Serial number of device */ int serial_number; - /** - Firmware version (x 100). - */ + /* Firmware version (x 100) */ int firmware_version; - /** - Timer for delayed PCM startup. - */ + /* Timer for delayed PCM startup */ struct timer_list timer; - /** - Device type. - */ + /* Device type */ enum line6_device_type type; /* LED instances */ diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index 9701ffa61365..44042cbdef01 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -42,30 +42,20 @@ enum { }; struct usb_line6_variax { - /** - Generic Line 6 USB data. - */ + /* Generic Line 6 USB data */ struct usb_line6 line6; - /** - Buffer for activation code. - */ + /* Buffer for activation code */ unsigned char *buffer_activate; - /** - Handler for device initializaton. - */ + /* Handler for device initialization */ struct work_struct startup_work; - /** - Timers for device initializaton. - */ + /* Timers for device initialization */ struct timer_list startup_timer1; struct timer_list startup_timer2; - /** - Current progress in startup procedure. - */ + /* Current progress in startup procedure */ int startup_progress; }; -- cgit From fd9301d33fef67e6dbcab29f3666c76efd97b762 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 14:45:22 +0100 Subject: ALSA: line6: Remove revision.h The definition is no longer used. Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 1 - sound/usb/line6/revision.h | 4 ---- 2 files changed, 5 deletions(-) delete mode 100644 sound/usb/line6/revision.h (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index f46da99c44b3..786b38159ad6 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -22,7 +22,6 @@ #include "driver.h" #include "midi.h" #include "playback.h" -#include "revision.h" #include "usbdefs.h" #define DRIVER_AUTHOR "Markus Grabner " diff --git a/sound/usb/line6/revision.h b/sound/usb/line6/revision.h deleted file mode 100644 index b4eee2b73831..000000000000 --- a/sound/usb/line6/revision.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef DRIVER_REVISION -/* current subversion revision */ -#define DRIVER_REVISION " (904)" -#endif -- cgit From 129b3be6895c01e137dbb88c699f9f706bdc6c9d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 14:50:08 +0100 Subject: ALSA: line6: Move the contents of usbdefs.h into driver.h Most of them are rather relevant with the definitions in driver.h, and there are only a few lines, so just rip it off. Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 1 - sound/usb/line6/driver.h | 16 ++++++++++++++++ sound/usb/line6/midi.c | 1 - sound/usb/line6/pcm.h | 1 - sound/usb/line6/pod.c | 1 - sound/usb/line6/podhd.c | 1 - sound/usb/line6/toneport.c | 1 - sound/usb/line6/usbdefs.h | 27 --------------------------- sound/usb/line6/variax.c | 1 - 9 files changed, 16 insertions(+), 34 deletions(-) delete mode 100644 sound/usb/line6/usbdefs.h (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 786b38159ad6..2328ec9a1ca8 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -22,7 +22,6 @@ #include "driver.h" #include "midi.h" #include "playback.h" -#include "usbdefs.h" #define DRIVER_AUTHOR "Markus Grabner " #define DRIVER_DESC "Line 6 USB Driver" diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index 80d42a0fd889..fa877a345860 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -20,6 +20,12 @@ #define DRIVER_NAME "line6usb" +#define USB_INTERVALS_PER_SECOND 1000 + +/* Fallback USB interval and max packet size values */ +#define LINE6_FALLBACK_INTERVAL 10 +#define LINE6_FALLBACK_MAXPACKETSIZE 16 + #define LINE6_TIMEOUT 1 #define LINE6_BUFSIZE_LISTEN 32 #define LINE6_MESSAGE_MAXLEN 256 @@ -84,6 +90,16 @@ struct line6_properties { unsigned ep_audio_w; }; +/* Capability bits */ +enum { + /* device supports settings parameter via USB */ + LINE6_CAP_CONTROL = 1 << 0, + /* device supports PCM input/output via USB */ + LINE6_CAP_PCM = 1 << 1, + /* device support hardware monitoring */ + LINE6_CAP_HWMON = 1 << 2, +}; + /* Common data shared by all Line 6 devices. Corresponds to a pair of USB endpoints. diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index beeedf9a2cbe..cebea9b7f769 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -17,7 +17,6 @@ #include "driver.h" #include "midi.h" -#include "usbdefs.h" #define line6_rawmidi_substream_midi(substream) \ ((struct snd_line6_midi *)((substream)->rmidi->private_data)) diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index 19c12f0a9008..3a3cfba40ec7 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -19,7 +19,6 @@ #include #include "driver.h" -#include "usbdefs.h" /* number of URBs */ #define LINE6_ISO_BUFFERS 2 diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index bc20cf141719..3f7ff661b3dd 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -21,7 +21,6 @@ #include "capture.h" #include "driver.h" #include "playback.h" -#include "usbdefs.h" /* Locate name in binary program dump diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index c4e83ab33a21..5e4e02c1f4b5 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -17,7 +17,6 @@ #include "driver.h" #include "pcm.h" -#include "usbdefs.h" enum { LINE6_PODHD300, diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 9024acb2b850..cffcd7f83bfd 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -21,7 +21,6 @@ #include "capture.h" #include "driver.h" #include "playback.h" -#include "usbdefs.h" enum line6_device_type { LINE6_GUITARPORT, diff --git a/sound/usb/line6/usbdefs.h b/sound/usb/line6/usbdefs.h deleted file mode 100644 index 5ef7bcd24e18..000000000000 --- a/sound/usb/line6/usbdefs.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Line 6 Linux USB driver - * - * Copyright (C) 2005-2008 Markus Grabner (grabner@icg.tugraz.at) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2. - * - */ - -#ifndef USBDEFS_H -#define USBDEFS_H - -#define USB_INTERVALS_PER_SECOND 1000 - -/* device supports settings parameter via USB */ -#define LINE6_CAP_CONTROL (1 << 0) -/* device supports PCM input/output via USB */ -#define LINE6_CAP_PCM (1 << 1) -/* device support hardware monitoring */ -#define LINE6_CAP_HWMON (1 << 2) - -#define LINE6_FALLBACK_INTERVAL 10 -#define LINE6_FALLBACK_MAXPACKETSIZE 16 - -#endif diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index 44042cbdef01..9dfbe7916d99 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -17,7 +17,6 @@ #include #include "driver.h" -#include "usbdefs.h" #define VARIAX_STARTUP_DELAY1 1000 #define VARIAX_STARTUP_DELAY3 100 -- cgit From b3313476dd7d9950f3a2e8050a962602bc6dc9fc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 15:00:01 +0100 Subject: ALSA: line6: Remove struct usb_line6_podhd It's identical with struct usb_line6. Signed-off-by: Takashi Iwai --- sound/usb/line6/podhd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 5e4e02c1f4b5..4ebe6ef43073 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -25,11 +25,6 @@ enum { LINE6_PODHD500_1, }; -struct usb_line6_podhd { - /* Generic Line 6 USB data */ - struct usb_line6 line6; -}; - #define PODHD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */ static struct snd_ratden podhd_ratden = { @@ -176,7 +171,7 @@ static int podhd_probe(struct usb_interface *interface, { return line6_probe(interface, id, &podhd_properties_table[id->driver_info], - podhd_init, sizeof(struct usb_line6_podhd)); + podhd_init, sizeof(struct usb_line6)); } static struct usb_driver podhd_driver = { -- cgit From 72f18d00757e182c1adeb747ea39a66f1b54698b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 15:03:31 +0100 Subject: ALSA: line6: Remove invalid capability bits for PODxt Live Variax PODxt Live Variax doesn't have PCM and HWMON but only MIDI. Signed-off-by: Takashi Iwai --- sound/usb/line6/variax.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index 9dfbe7916d99..b1c1de65d584 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -259,9 +259,7 @@ static const struct line6_properties variax_properties_table[] = { [LINE6_PODXTLIVE_VARIAX] = { .id = "PODxtLive", .name = "PODxt Live", - .capabilities = LINE6_CAP_CONTROL - | LINE6_CAP_PCM - | LINE6_CAP_HWMON, + .capabilities = LINE6_CAP_CONTROL, .altsetting = 1, .ep_ctrl_r = 0x86, .ep_ctrl_w = 0x05, -- cgit From 1263f61179821df60cca4bccdb69e2f71fdebaa7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jan 2015 15:08:59 +0100 Subject: ALSA: line6: Remove snd_line6_ prefix of pcm property fields It's just superfluous and doesn't give any better readability. Signed-off-by: Takashi Iwai --- sound/usb/line6/capture.c | 5 ++--- sound/usb/line6/pcm.h | 4 ++-- sound/usb/line6/playback.c | 11 +++++------ sound/usb/line6/pod.c | 6 +++--- sound/usb/line6/podhd.c | 6 +++--- sound/usb/line6/toneport.c | 6 +++--- 6 files changed, 18 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 4183c5f5edc2..f518fbbe88de 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -216,12 +216,11 @@ static int snd_line6_capture_open(struct snd_pcm_substream *substream) err = snd_pcm_hw_constraint_ratdens(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - (&line6pcm-> - properties->snd_line6_rates)); + &line6pcm->properties->rates); if (err < 0) return err; - runtime->hw = line6pcm->properties->snd_line6_capture_hw; + runtime->hw = line6pcm->properties->capture_hw; return 0; } diff --git a/sound/usb/line6/pcm.h b/sound/usb/line6/pcm.h index 3a3cfba40ec7..508410adbd51 100644 --- a/sound/usb/line6/pcm.h +++ b/sound/usb/line6/pcm.h @@ -83,8 +83,8 @@ enum { }; struct line6_pcm_properties { - struct snd_pcm_hardware snd_line6_playback_hw, snd_line6_capture_hw; - struct snd_pcm_hw_constraint_ratdens snd_line6_rates; + struct snd_pcm_hardware playback_hw, capture_hw; + struct snd_pcm_hw_constraint_ratdens rates; int bytes_per_frame; }; diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index ae41124c351e..05dee690f487 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -148,10 +148,10 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) int ret; const int bytes_per_frame = line6pcm->properties->bytes_per_frame; const int frame_increment = - line6pcm->properties->snd_line6_rates.rats[0].num_min; + line6pcm->properties->rates.rats[0].num_min; const int frame_factor = - line6pcm->properties->snd_line6_rates.rats[0].den * - (USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL); + line6pcm->properties->rates.rats[0].den * + (USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL); struct urb *urb_out; index = @@ -370,12 +370,11 @@ static int snd_line6_playback_open(struct snd_pcm_substream *substream) struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); err = snd_pcm_hw_constraint_ratdens(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - (&line6pcm-> - properties->snd_line6_rates)); + &line6pcm->properties->rates); if (err < 0) return err; - runtime->hw = line6pcm->properties->snd_line6_playback_hw; + runtime->hw = line6pcm->properties->playback_hw; return 0; } diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 3f7ff661b3dd..61aadd7d4b7f 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -129,7 +129,7 @@ static struct snd_ratden pod_ratden = { }; static struct line6_pcm_properties pod_pcm_properties = { - .snd_line6_playback_hw = { + .playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -147,7 +147,7 @@ static struct line6_pcm_properties pod_pcm_properties = { .period_bytes_max = 8192, .periods_min = 1, .periods_max = 1024}, - .snd_line6_capture_hw = { + .capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -164,7 +164,7 @@ static struct line6_pcm_properties pod_pcm_properties = { .period_bytes_max = 8192, .periods_min = 1, .periods_max = 1024}, - .snd_line6_rates = { + .rates = { .nrats = 1, .rats = &pod_ratden}, .bytes_per_frame = POD_BYTES_PER_FRAME diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 4ebe6ef43073..9c3c7441fd11 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -35,7 +35,7 @@ static struct snd_ratden podhd_ratden = { }; static struct line6_pcm_properties podhd_pcm_properties = { - .snd_line6_playback_hw = { + .playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -53,7 +53,7 @@ static struct line6_pcm_properties podhd_pcm_properties = { .period_bytes_max = 8192, .periods_min = 1, .periods_max = 1024}, - .snd_line6_capture_hw = { + .capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -70,7 +70,7 @@ static struct line6_pcm_properties podhd_pcm_properties = { .period_bytes_max = 8192, .periods_min = 1, .periods_max = 1024}, - .snd_line6_rates = { + .rates = { .nrats = 1, .rats = &podhd_ratden}, .bytes_per_frame = PODHD_BYTES_PER_FRAME diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index cffcd7f83bfd..b107cf481819 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -76,7 +76,7 @@ static struct snd_ratden toneport_ratden = { }; static struct line6_pcm_properties toneport_pcm_properties = { - .snd_line6_playback_hw = { + .playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -94,7 +94,7 @@ static struct line6_pcm_properties toneport_pcm_properties = { .period_bytes_max = 8192, .periods_min = 1, .periods_max = 1024}, - .snd_line6_capture_hw = { + .capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -111,7 +111,7 @@ static struct line6_pcm_properties toneport_pcm_properties = { .period_bytes_max = 8192, .periods_min = 1, .periods_max = 1024}, - .snd_line6_rates = { + .rates = { .nrats = 1, .rats = &toneport_ratden}, .bytes_per_frame = 4 -- cgit From a850ef8afd3cd1eecd2e136f8dca0c06599eade8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 13 Jan 2015 10:58:31 +0100 Subject: ALSA: ak4114: Move EXPORT_SYMBOL() after each function ... just to follow the standard coding style. Acked-by: Jaroslav Kysela Tested-by: Pavel Hofman Signed-off-by: Takashi Iwai --- sound/i2c/other/ak4114.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index b70e6eccbd03..f6ee1e7a9bbd 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -122,6 +122,7 @@ int snd_ak4114_create(struct snd_card *card, snd_ak4114_free(chip); return err < 0 ? err : -EIO; } +EXPORT_SYMBOL(snd_ak4114_create); void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char mask, unsigned char val) { @@ -131,6 +132,7 @@ void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char reg_write(chip, reg, (chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val); } +EXPORT_SYMBOL(snd_ak4114_reg_write); static void ak4114_init_regs(struct ak4114 *chip) { @@ -159,6 +161,7 @@ void snd_ak4114_reinit(struct ak4114 *chip) if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); } +EXPORT_SYMBOL(snd_ak4114_reinit); static unsigned int external_rate(unsigned char rcs1) { @@ -503,6 +506,7 @@ int snd_ak4114_build(struct ak4114 *ak4114, schedule_delayed_work(&ak4114->work, HZ / 10); return 0; } +EXPORT_SYMBOL(snd_ak4114_build); /* notify kcontrols if any parameters are changed */ static void ak4114_notify(struct ak4114 *ak4114, @@ -558,6 +562,7 @@ int snd_ak4114_external_rate(struct ak4114 *ak4114) rcs1 = reg_read(ak4114, AK4114_REG_RCS1); return external_rate(rcs1); } +EXPORT_SYMBOL(snd_ak4114_external_rate); int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags) { @@ -605,6 +610,7 @@ int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags) } return res; } +EXPORT_SYMBOL(snd_ak4114_check_rate_and_errors); static void ak4114_stats(struct work_struct *work) { @@ -615,10 +621,3 @@ static void ak4114_stats(struct work_struct *work) if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); } - -EXPORT_SYMBOL(snd_ak4114_create); -EXPORT_SYMBOL(snd_ak4114_reg_write); -EXPORT_SYMBOL(snd_ak4114_reinit); -EXPORT_SYMBOL(snd_ak4114_build); -EXPORT_SYMBOL(snd_ak4114_external_rate); -EXPORT_SYMBOL(snd_ak4114_check_rate_and_errors); -- cgit From 1293617cddc40971917150e3f5bf66b7306e2e7e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 13 Jan 2015 11:24:08 +0100 Subject: ALSA: ak411x: Add PM helper functions Define snd_ak4114_suspend() and snd_ak4114_resume() functions to handle PM properly, stopping and restarting the work at PM. Currently only ice1712/juli.c deals with the PM and ak4114, so fix the calls there appropriately. The same PM functions are defined in ak4113.c, too, although they aren't currently called yet (ice1712/quartet.c may be enhanced to support PM later). Acked-by: Jaroslav Kysela Tested-by: Pavel Hofman Signed-off-by: Takashi Iwai --- sound/i2c/other/ak4113.c | 16 ++++++++++++++++ sound/i2c/other/ak4114.c | 16 ++++++++++++++++ sound/pci/ice1712/juli.c | 4 +++- 3 files changed, 35 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c index c6bba99a90b2..c2b14d981fa1 100644 --- a/sound/i2c/other/ak4113.c +++ b/sound/i2c/other/ak4113.c @@ -636,3 +636,19 @@ static void ak4113_stats(struct work_struct *work) if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); } + +#ifdef CONFIG_PM +void snd_ak4113_suspend(struct ak4113 *chip) +{ + atomic_inc(&chip->wq_processing); /* don't schedule new work */ + cancel_delayed_work_sync(&chip->work); +} +EXPORT_SYMBOL(snd_ak4113_suspend); + +void snd_ak4113_resume(struct ak4113 *chip) +{ + atomic_dec(&chip->wq_processing); + snd_ak4113_reinit(chip); +} +EXPORT_SYMBOL(snd_ak4113_resume); +#endif diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index f6ee1e7a9bbd..ee639f57b664 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -621,3 +621,19 @@ static void ak4114_stats(struct work_struct *work) if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); } + +#ifdef CONFIG_PM +void snd_ak4114_suspend(struct ak4114 *chip) +{ + atomic_inc(&chip->wq_processing); /* don't schedule new work */ + cancel_delayed_work_sync(&chip->work); +} +EXPORT_SYMBOL(snd_ak4114_suspend); + +void snd_ak4114_resume(struct ak4114 *chip) +{ + atomic_dec(&chip->wq_processing); + snd_ak4114_reinit(chip); +} +EXPORT_SYMBOL(snd_ak4114_resume); +#endif diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index a1536c1a7ed4..4f0213427152 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -491,15 +491,17 @@ static int juli_resume(struct snd_ice1712 *ice) /* akm4358 un-reset, un-mute */ snd_akm4xxx_reset(ak, 0); /* reinit ak4114 */ - snd_ak4114_reinit(spec->ak4114); + snd_ak4114_resume(spec->ak4114); return 0; } static int juli_suspend(struct snd_ice1712 *ice) { struct snd_akm4xxx *ak = ice->akm; + struct juli_spec *spec = ice->spec; /* akm4358 reset and soft-mute */ snd_akm4xxx_reset(ak, 1); + snd_ak4114_suspend(spec->ak4114); return 0; } #endif -- cgit From 1781e78c63317c04e6ae6a076acfd53236f420bc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 16 Jan 2015 13:03:28 +0100 Subject: ALSA: ak411x: Fix race of reinit() calls Protect the call with a mutex, as this may be called in parallel (either from the PCM rate change and the clock change). Acked-by: Jaroslav Kysela Tested-by: Pavel Hofman Signed-off-by: Takashi Iwai --- sound/i2c/other/ak4113.c | 3 +++ sound/i2c/other/ak4114.c | 3 +++ 2 files changed, 6 insertions(+) (limited to 'sound') diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c index c2b14d981fa1..88844881cbff 100644 --- a/sound/i2c/other/ak4113.c +++ b/sound/i2c/other/ak4113.c @@ -89,6 +89,7 @@ int snd_ak4113_create(struct snd_card *card, ak4113_read_t *read, chip->private_data = private_data; INIT_DELAYED_WORK(&chip->work, ak4113_stats); atomic_set(&chip->wq_processing, 0); + mutex_init(&chip->reinit_mutex); for (reg = 0; reg < AK4113_WRITABLE_REGS ; reg++) chip->regmap[reg] = pgm[reg]; @@ -141,7 +142,9 @@ void snd_ak4113_reinit(struct ak4113 *chip) { if (atomic_inc_return(&chip->wq_processing) == 1) cancel_delayed_work_sync(&chip->work); + mutex_lock(&chip->reinit_mutex); ak4113_init_regs(chip); + mutex_unlock(&chip->reinit_mutex); /* bring up statistics / event queing */ if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index ee639f57b664..5a4cf3fab4ae 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -100,6 +100,7 @@ int snd_ak4114_create(struct snd_card *card, chip->private_data = private_data; INIT_DELAYED_WORK(&chip->work, ak4114_stats); atomic_set(&chip->wq_processing, 0); + mutex_init(&chip->reinit_mutex); for (reg = 0; reg < 6; reg++) chip->regmap[reg] = pgm[reg]; @@ -156,7 +157,9 @@ void snd_ak4114_reinit(struct ak4114 *chip) { if (atomic_inc_return(&chip->wq_processing) == 1) cancel_delayed_work_sync(&chip->work); + mutex_lock(&chip->reinit_mutex); ak4114_init_regs(chip); + mutex_unlock(&chip->reinit_mutex); /* bring up statistics / event queing */ if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); -- cgit From f9a7ba326938f03b9305af8d31c360fce10cd4df Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 28 Jan 2015 22:30:01 +0100 Subject: ASoC: davinci: fix DM365_EVM codec selection An earlier bug fix of mine made the SND_DM365_VOICE_CODEC symbol tristate to avoid creating an undefined reference from the davinci-vcif.c driver to the davinci_soc_platform_register function that may be in a module. However, this may now lead to a different error on randconfig kernels: "warning: SND_DM365_VOICE_CODEC creates inconsistent choice state" This happens because we now have a choice statement with one bool and one tristate option, and the latter might not support being set to 'y' because of dependencies. This new change turns the other option into 'tristate' as well, which avoids the problem. Signed-off-by: Arnd Bergmann Fixes: 19926c6de0c3 ("ASoC: davinci: vcif must be a module if SND_DAVINCI_SOC is") Signed-off-by: Mark Brown --- sound/soc/davinci/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig index 8e948c63f3d9..2b81ca418d2a 100644 --- a/sound/soc/davinci/Kconfig +++ b/sound/soc/davinci/Kconfig @@ -58,13 +58,12 @@ choice depends on MACH_DAVINCI_DM365_EVM config SND_DM365_AIC3X_CODEC - bool "Audio Codec - AIC3101" + tristate "Audio Codec - AIC3101" help Say Y if you want to add support for AIC3101 audio codec config SND_DM365_VOICE_CODEC tristate "Voice Codec - CQ93VC" - depends on SND_DAVINCI_SOC select MFD_DAVINCI_VOICECODEC select SND_DAVINCI_SOC_VCIF select SND_SOC_CQ0093VC -- cgit From 4c121129c9dcb43b33d1cd568c8f2636e72597b0 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 28 Jan 2015 22:31:30 +0100 Subject: ASoC: rt5677: fix SPI dependency The rt5677 codec has gained code that requires SPI to work correctly, but there is no provision in Kconfig to prevent the driver from being used when SPI is disabled or a loadable module, resulting in this build error: sound/built-in.o: In function `rt5677_spi_write': :(.text+0xa7ba0): undefined reference to `spi_sync' sound/built-in.o: In function `rt5677_spi_driver_init': :(.init.text+0x253c): undefined reference to `spi_register_driver' ERROR: "spi_sync" [sound/soc/codecs/snd-soc-rt5677-spi.ko] undefined! ERROR: "spi_register_driver" [sound/soc/codecs/snd-soc-rt5677-spi.ko] undefined! This makes the SPI portion of the driver depend on the SPI subsystem, and disables the function that uses SPI for firmware download if SPI is disabled. The latter may not be the correct solution, but I could not come up with a better one. Signed-off-by: Arnd Bergmann Fixes: af48f1d08a54741 ("ASoC: rt5677: Support DSP function for VAD application") Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 2 +- sound/soc/codecs/rt5677.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 8349f982a586..ef2c70e77d91 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -525,7 +525,7 @@ config SND_SOC_RT5677 config SND_SOC_RT5677_SPI tristate - default SND_SOC_RT5677 + default SND_SOC_RT5677 && SPI #Freescale sgtl5000 codec config SND_SOC_SGTL5000 diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 88de759fb7fc..75d2d73be545 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -702,6 +702,9 @@ static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on) static bool activity; int ret; + if (!IS_ENABLED(CONFIG_SND_SOC_RT5677_SPI)) + return -ENXIO; + if (on && !activity) { activity = true; -- cgit From 2599a9609c588d040c53e7eaed00e696effd28bf Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Thu, 29 Jan 2015 12:21:55 +0100 Subject: ASoC: pcm512x: Fixup warning splat Reported-by: kbuild test robot Signed-off-by: Peter Rosin Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 51b279e3f465..067d11743c31 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -1266,7 +1266,6 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) { struct pcm512x_priv *pcm512x; int i, ret; - u32 val; pcm512x = devm_kzalloc(dev, sizeof(struct pcm512x_priv), GFP_KERNEL); if (!pcm512x) @@ -1347,6 +1346,7 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) #ifdef CONFIG_OF if (dev->of_node) { const struct device_node *np = dev->of_node; + u32 val; if (of_property_read_u32(np, "pll-in", &val) >= 0) { if (val > 6) { -- cgit From 9c7da1a57bb5938f1d874c8cd5e50d2494830d08 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Thu, 29 Jan 2015 12:21:56 +0100 Subject: ASoC: pcm512x: Use the correct range constraints for S24_LE This was overlooked in the late change to remove the I2S padding bits from S24_LE mode. The patch also limits S32_LE mode to 384kHz, the maximum according to the datasheets. Signed-off-by: Peter Rosin Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 067d11743c31..884784fb1566 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -356,36 +356,37 @@ static const struct snd_pcm_hw_constraint_list constraints_slave = { .list = pcm512x_dai_rates, }; -static const struct snd_interval pcm512x_dai_ranges_64bpf[] = { - { - .min = 8000, - .max = 195312, - }, { - .min = 250000, - .max = 390625, - }, -}; - -static struct snd_pcm_hw_constraint_ranges constraints_64bpf = { - .count = ARRAY_SIZE(pcm512x_dai_ranges_64bpf), - .ranges = pcm512x_dai_ranges_64bpf, -}; - static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { - struct snd_pcm_hw_constraint_ranges *r = rule->private; + struct snd_interval ranges[2]; int frame_size; frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) return frame_size; - if (frame_size != 64) + switch (frame_size) { + case 32: + /* No hole when the frame size is 32. */ return 0; + case 48: + case 64: + /* There is only one hole in the range of supported + * rates, but it moves with the frame size. + */ + memset(ranges, 0, sizeof(ranges)); + ranges[0].min = 8000; + ranges[0].max = 25000000 / frame_size / 2; + ranges[1].min = DIV_ROUND_UP(16000000, frame_size); + ranges[1].max = 384000; + break; + default: + return -EINVAL; + } return snd_interval_ranges(hw_param_interval(params, rule->var), - r->count, r->ranges, r->mask); + ARRAY_SIZE(ranges), ranges, 0); } static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream, @@ -407,7 +408,7 @@ static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream, return snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, pcm512x_hw_rule_rate, - (void *)&constraints_64bpf, + NULL, SNDRV_PCM_HW_PARAM_FRAME_BITS, SNDRV_PCM_HW_PARAM_CHANNELS, -1); -- cgit From eb5271497f212f9e2323adc0a2fd8a9358e751e4 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Thu, 29 Jan 2015 11:16:29 +0100 Subject: ASoC: atmel_ssc_dai: Support SND_SOC_DAIFMT_CBM_CFS on I2S Signed-off-by: Peter Rosin Acked-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/atmel/atmel_ssc_dai.c | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'sound') diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 3cd70597d109..f55f3aab8bdd 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -485,6 +485,54 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | SSC_BF(TFMR_DATLEN, (bits - 1)); break; + case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFS: + /* I2S format, CODEC supplies BCLK, SSC supplies LRCLK. */ + if (bits > 16 && !ssc->pdata->has_fslen_ext) { + dev_err(dai->dev, + "sample size %d is too large for SSC device\n", + bits); + return -EINVAL; + } + + fslen_ext = (bits - 1) / 16; + fslen = (bits - 1) % 16; + + rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period) + | SSC_BF(RCMR_STTDLY, START_DELAY) + | SSC_BF(RCMR_START, SSC_START_FALLING_RF) + | SSC_BF(RCMR_CKI, SSC_CKI_RISING) + | SSC_BF(RCMR_CKO, SSC_CKO_NONE) + | SSC_BF(RCMR_CKS, ssc->clk_from_rk_pin ? + SSC_CKS_PIN : SSC_CKS_CLOCK); + + rfmr = SSC_BF(RFMR_FSLEN_EXT, fslen_ext) + | SSC_BF(RFMR_FSEDGE, SSC_FSEDGE_POSITIVE) + | SSC_BF(RFMR_FSOS, SSC_FSOS_NEGATIVE) + | SSC_BF(RFMR_FSLEN, fslen) + | SSC_BF(RFMR_DATNB, (channels - 1)) + | SSC_BIT(RFMR_MSBF) + | SSC_BF(RFMR_LOOP, 0) + | SSC_BF(RFMR_DATLEN, (bits - 1)); + + tcmr = SSC_BF(TCMR_PERIOD, ssc_p->tcmr_period) + | SSC_BF(TCMR_STTDLY, START_DELAY) + | SSC_BF(TCMR_START, SSC_START_FALLING_RF) + | SSC_BF(TCMR_CKI, SSC_CKI_FALLING) + | SSC_BF(TCMR_CKO, SSC_CKO_NONE) + | SSC_BF(TCMR_CKS, ssc->clk_from_rk_pin ? + SSC_CKS_CLOCK : SSC_CKS_PIN); + + tfmr = SSC_BF(TFMR_FSLEN_EXT, fslen_ext) + | SSC_BF(TFMR_FSEDGE, SSC_FSEDGE_NEGATIVE) + | SSC_BF(TFMR_FSDEN, 0) + | SSC_BF(TFMR_FSOS, SSC_FSOS_NEGATIVE) + | SSC_BF(TFMR_FSLEN, fslen) + | SSC_BF(TFMR_DATNB, (channels - 1)) + | SSC_BIT(TFMR_MSBF) + | SSC_BF(TFMR_DATDEF, 0) + | SSC_BF(TFMR_DATLEN, (bits - 1)); + break; + case SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS: /* * DSP/PCM Mode A format, SSC provides BCLK and LRC clocks. -- cgit From 7c47cd7ffd5e8fca28258e6e04207ad154d719e4 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 29 Jan 2015 17:13:46 +0100 Subject: ASoC: pxa: make TTC DKB tristate In a rare combination of Kconfig settings, the 88pm860x-codec module may be selected as a loadable module, while it's also being used by the ttb-dkb code that is built-in, resulting in a link error: sound/built-in.o: In function `ttc_pm860x_init': :(.text+0x3e888): undefined reference to `pm860x_hs_jack_detect' :(.text+0x3e898): undefined reference to `pm860x_mic_jack_detect' Changing ttb-tkb to a tristate option tells Kconfig that 88pm86x actually needs to be built-in if ttc-dkb is also built-in. Signed-off-by: Arnd Bergmann Signed-off-by: Mark Brown --- sound/soc/pxa/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index 2434b6d61675..39cea80846c3 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig @@ -140,7 +140,7 @@ config SND_PXA910_SOC Marvell PXA910 reference platform. config SND_SOC_TTC_DKB - bool "SoC Audio support for TTC DKB" + tristate "SoC Audio support for TTC DKB" depends on SND_PXA910_SOC && MACH_TTC_DKB && I2C=y select PXA_SSP select SND_PXA_SOC_SSP -- cgit From 2ca087bc9edafd7cd1e89d0ac61a31067985bd15 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 30 Jan 2015 09:32:43 +0200 Subject: ASoC: rx51: Correct DAPM route for capture "Mic Bias" is DAPM_SUPPLY so it has to be connected in the route accordingly. Fixes audio capture on the board. Reported-by: Pavel Machek Signed-off-by: Peter Ujfalusi Tested-by: Pavel Machek Signed-off-by: Mark Brown --- sound/soc/omap/rx51.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 04896d6252a2..7f299357c2d2 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -250,14 +250,14 @@ static const struct snd_soc_dapm_route audio_map[] = { {"FM Transmitter", NULL, "LLOUT"}, {"FM Transmitter", NULL, "RLOUT"}, - {"DMic Rate 64", NULL, "Mic Bias"}, - {"Mic Bias", NULL, "DMic"}, + {"DMic Rate 64", NULL, "DMic"}, + {"DMic", NULL, "Mic Bias"}, {"b LINE2R", NULL, "MONO_LOUT"}, {"Earphone", NULL, "b HPLOUT"}, - {"LINE1L", NULL, "b Mic Bias"}, - {"b Mic Bias", NULL, "HS Mic"} + {"LINE1L", NULL, "HS Mic"}, + {"HS Mic", NULL, "b Mic Bias"}, }; static const char * const spk_function[] = {"Off", "On"}; -- cgit From cbaadf0f90d6d406a36bb389fbdea524d6d89d8d Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Fri, 30 Jan 2015 17:38:43 +0800 Subject: ASoC: atmel_ssc_dai: refactor the startup and shutdown In startup function, enable ssc clock and in shutdown function, disable clock. And also remove disable ssc in shutdown function, as ssc is disabled in prepare function. Signed-off-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/atmel/atmel_ssc_dai.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'sound') diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index f55f3aab8bdd..76a9754370e8 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -204,6 +204,13 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream, pr_debug("atmel_ssc_startup: SSC_SR=0x%u\n", ssc_readl(ssc_p->ssc->regs, SR)); + /* Enable PMC peripheral clock for this SSC */ + pr_debug("atmel_ssc_dai: Starting clock\n"); + clk_enable(ssc_p->ssc->clk); + + /* Reset the SSC to keep it at a clean status */ + ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { dir = 0; dir_mask = SSC_DIR_MASK_PLAYBACK; @@ -250,11 +257,6 @@ static void atmel_ssc_shutdown(struct snd_pcm_substream *substream, dma_params = ssc_p->dma_params[dir]; if (dma_params != NULL) { - ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_disable); - pr_debug("atmel_ssc_shutdown: %s disabled SSC_SR=0x%08x\n", - (dir ? "receive" : "transmit"), - ssc_readl(ssc_p->ssc->regs, SR)); - dma_params->ssc = NULL; dma_params->substream = NULL; ssc_p->dma_params[dir] = NULL; @@ -266,10 +268,6 @@ static void atmel_ssc_shutdown(struct snd_pcm_substream *substream, ssc_p->dir_mask &= ~dir_mask; if (!ssc_p->dir_mask) { if (ssc_p->initialized) { - /* Shutdown the SSC clock. */ - pr_debug("atmel_ssc_dai: Stopping clock\n"); - clk_disable(ssc_p->ssc->clk); - free_irq(ssc_p->ssc->irq, ssc_p); ssc_p->initialized = 0; } @@ -280,6 +278,10 @@ static void atmel_ssc_shutdown(struct snd_pcm_substream *substream, ssc_p->cmr_div = ssc_p->tcmr_period = ssc_p->rcmr_period = 0; } spin_unlock_irq(&ssc_p->lock); + + /* Shutdown the SSC clock. */ + pr_debug("atmel_ssc_dai: Stopping clock\n"); + clk_disable(ssc_p->ssc->clk); } @@ -625,14 +627,6 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, rcmr, rfmr, tcmr, tfmr); if (!ssc_p->initialized) { - - /* Enable PMC peripheral clock for this SSC */ - pr_debug("atmel_ssc_dai: Starting clock\n"); - clk_enable(ssc_p->ssc->clk); - - /* Reset the SSC and its PDC registers */ - ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); - ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0); ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0); ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0); -- cgit From 3fd5b30c577bdd51168f38cf4f2d322619015a53 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Fri, 30 Jan 2015 17:38:44 +0800 Subject: ASoC: atmel_ssc_dai: only clean PDC when using PDC Only using PDC, it needs to clean PDC registers. Signed-off-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/atmel/atmel_ssc_dai.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 76a9754370e8..379ac2a6ab16 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -627,15 +627,17 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, rcmr, rfmr, tcmr, tfmr); if (!ssc_p->initialized) { - ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_RNCR, 0); - - ssc_writel(ssc_p->ssc->regs, PDC_TPR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_TCR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_TNPR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_TNCR, 0); + if (!ssc_p->ssc->pdata->use_dma) { + ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_RNCR, 0); + + ssc_writel(ssc_p->ssc->regs, PDC_TPR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_TCR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_TNPR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_TNCR, 0); + } ret = request_irq(ssc_p->ssc->irq, atmel_ssc_interrupt, 0, ssc_p->name, ssc_p); -- cgit From 642adf5f9a9c8dd8f730c4f034608e4d086abab8 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Sun, 1 Feb 2015 01:01:08 -0600 Subject: ALSA: line6: Remove unused line6_midibuf_status() This function has not been used since merging the driver into the kernel (and a good while before that.) [Removed the corresponding line in midibuf.h, too -- tiwai] Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/midibuf.c | 7 ------- sound/usb/line6/midibuf.h | 1 - 2 files changed, 8 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/midibuf.c b/sound/usb/line6/midibuf.c index b5c4d79de031..3b8b59b34908 100644 --- a/sound/usb/line6/midibuf.c +++ b/sound/usb/line6/midibuf.c @@ -67,13 +67,6 @@ int line6_midibuf_init(struct midi_buffer *this, int size, int split) return 0; } -void line6_midibuf_status(struct midi_buffer *this) -{ - pr_debug("midibuf size=%d split=%d pos_read=%d pos_write=%d full=%d command_prev=%02x\n", - this->size, this->split, this->pos_read, this->pos_write, - this->full, this->command_prev); -} - int line6_midibuf_bytes_free(struct midi_buffer *this) { return diff --git a/sound/usb/line6/midibuf.h b/sound/usb/line6/midibuf.h index 05dbf11a4d63..1d9b59ac1e59 100644 --- a/sound/usb/line6/midibuf.h +++ b/sound/usb/line6/midibuf.h @@ -31,7 +31,6 @@ extern int line6_midibuf_read(struct midi_buffer *mb, unsigned char *data, extern void line6_midibuf_reset(struct midi_buffer *mb); extern int line6_midibuf_skip_message(struct midi_buffer *mb, unsigned short mask); -extern void line6_midibuf_status(struct midi_buffer *mb); extern int line6_midibuf_write(struct midi_buffer *mb, unsigned char *data, int length); -- cgit From 58647286abcd2b7ca940b33cc0817443b8851f36 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Sun, 1 Feb 2015 01:01:09 -0600 Subject: ALSA: line6: Remove unused line6_midibuf_skip_message() Use of this function ended with commits 3e58c868db1d ("staging: line6: drop midi_mask_receive") and af89d2897a71 ("staging: line6: drop midi_mask_transmit".) [Removed the corresponding line in midibuf.h, too -- tiwai] Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/midibuf.c | 11 ----------- sound/usb/line6/midibuf.h | 2 -- 2 files changed, 13 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/midibuf.c b/sound/usb/line6/midibuf.c index 3b8b59b34908..36a610ba342e 100644 --- a/sound/usb/line6/midibuf.c +++ b/sound/usb/line6/midibuf.c @@ -245,17 +245,6 @@ int line6_midibuf_ignore(struct midi_buffer *this, int length) return length; } -int line6_midibuf_skip_message(struct midi_buffer *this, unsigned short mask) -{ - int cmd = this->command_prev; - - if ((cmd >= 0x80) && (cmd < 0xf0)) - if ((mask & (1 << (cmd & 0x0f))) == 0) - return 1; - - return 0; -} - void line6_midibuf_destroy(struct midi_buffer *this) { kfree(this->buf); diff --git a/sound/usb/line6/midibuf.h b/sound/usb/line6/midibuf.h index 1d9b59ac1e59..6ea21ffb6627 100644 --- a/sound/usb/line6/midibuf.h +++ b/sound/usb/line6/midibuf.h @@ -29,8 +29,6 @@ extern int line6_midibuf_init(struct midi_buffer *mb, int size, int split); extern int line6_midibuf_read(struct midi_buffer *mb, unsigned char *data, int length); extern void line6_midibuf_reset(struct midi_buffer *mb); -extern int line6_midibuf_skip_message(struct midi_buffer *mb, - unsigned short mask); extern int line6_midibuf_write(struct midi_buffer *mb, unsigned char *data, int length); -- cgit From 56bbd86c2e47d4f7707cb329fc008487c940ca27 Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Mon, 2 Feb 2015 14:44:46 +0800 Subject: ASoC: atmel-pcm-dma: won't check direction when configure dma As DMA framework request DMA using direction only in prep_slave function, (The At91 xdma driver has adapted to this request). So won't check direction when do DMA configuration. Signed-off-by: Bo Shen Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-pcm-dma.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index 33fb3bb133df..b8e7bad05eb1 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -105,13 +105,11 @@ static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream, return ret; } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - slave_config->dst_addr = ssc->phybase + SSC_THR; - slave_config->dst_maxburst = 1; - } else { - slave_config->src_addr = ssc->phybase + SSC_RHR; - slave_config->src_maxburst = 1; - } + slave_config->dst_addr = ssc->phybase + SSC_THR; + slave_config->dst_maxburst = 1; + + slave_config->src_addr = ssc->phybase + SSC_RHR; + slave_config->src_maxburst = 1; prtd->dma_intr_handler = atmel_pcm_dma_irq; -- cgit From 92b7952da8279189aad352efbf9f2e7001de9524 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 15:53:51 +0100 Subject: ALSA: Allow to pass the device object to snd_register_device*() This is a preliminary patch for the further work on embedding struct device into each sound device instance. It changes snd_register_device*() helpers to receive the device object directly for skipping creating a device there. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/hwdep.c | 3 ++- sound/core/pcm.c | 2 +- sound/core/sound.c | 54 ++++++++++++++++++++++++++++++++++-------------------- 3 files changed, 37 insertions(+), 22 deletions(-) (limited to 'sound') diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 69459e5f712e..85096a150eda 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -433,7 +433,8 @@ static int snd_hwdep_dev_register(struct snd_device *device) dev = snd_card_get_device_link(hwdep->card); err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device, - &snd_hwdep_f_ops, hwdep, name, dev); + &snd_hwdep_f_ops, hwdep, + NULL, dev, name); if (err < 0) { dev_err(dev, "unable to register hardware dependent device %i:%i\n", diff --git a/sound/core/pcm.c b/sound/core/pcm.c index cfc56c806964..dba5180e5b80 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1115,7 +1115,7 @@ static int snd_pcm_dev_register(struct snd_device *device) err = snd_register_device_for_dev(devtype, pcm->card, pcm->device, &snd_pcm_f_ops[cidx], - pcm, str, dev); + pcm, NULL, dev, str); if (err < 0) { list_del(&pcm->list); mutex_unlock(®ister_mutex); diff --git a/sound/core/sound.c b/sound/core/sound.c index f1333060bf1c..ea1af1acdbe9 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -248,8 +248,9 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * @dev: the device index * @f_ops: the file operations * @private_data: user pointer for f_ops->open() - * @name: the device file name - * @device: the &struct device to link this new device to + * @device: the device to register, NULL to create a new one + * @parent: the &struct device to link this new device to (only for device=NULL) + * @name: the device file name (only for device=NULL) * * Registers an ALSA device file for the given card. * The operators have to be set in reg parameter. @@ -258,14 +259,13 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) */ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, const struct file_operations *f_ops, - void *private_data, - const char *name, struct device *device) + void *private_data, struct device *device, + struct device *parent, const char *name) { int minor; + int err = 0; struct snd_minor *preg; - if (snd_BUG_ON(!name)) - return -EINVAL; preg = kmalloc(sizeof *preg, GFP_KERNEL); if (preg == NULL) return -ENOMEM; @@ -284,23 +284,32 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, minor = -EBUSY; #endif if (minor < 0) { - mutex_unlock(&sound_mutex); - kfree(preg); - return minor; + err = minor; + goto error; } - snd_minors[minor] = preg; - preg->dev = device_create(sound_class, device, MKDEV(major, minor), - private_data, "%s", name); - if (IS_ERR(preg->dev)) { - snd_minors[minor] = NULL; - mutex_unlock(&sound_mutex); - minor = PTR_ERR(preg->dev); - kfree(preg); - return minor; + + if (device) { + preg->created = false; + preg->dev = device; + device->devt = MKDEV(major, minor); + err = device_add(device); + } else { + preg->created = true; + preg->dev = device_create(sound_class, parent, + MKDEV(major, minor), private_data, + "%s", name); + if (IS_ERR(preg->dev)) + err = PTR_ERR(preg->dev); } + if (err < 0) + goto error; + snd_minors[minor] = preg; + error: mutex_unlock(&sound_mutex); - return 0; + if (err < 0) + kfree(preg); + return err; } EXPORT_SYMBOL(snd_register_device_for_dev); @@ -337,6 +346,7 @@ static int find_snd_minor(int type, struct snd_card *card, int dev) int snd_unregister_device(int type, struct snd_card *card, int dev) { int minor; + struct snd_minor *preg; mutex_lock(&sound_mutex); minor = find_snd_minor(type, card, dev); @@ -345,7 +355,11 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) return -EINVAL; } - device_destroy(sound_class, MKDEV(major, minor)); + preg = snd_minors[minor]; + if (preg && !preg->created) + device_del(preg->dev); + else + device_destroy(sound_class, MKDEV(major, minor)); kfree(snd_minors[minor]); snd_minors[minor] = NULL; -- cgit From 23c18d4bfd73ee24070849faf98b3ab01263a3c4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 19 Feb 2014 14:30:29 +0100 Subject: ALSA: control: Provide a helper to look for the preferred subdevice Instead of open-coding the search over the control file loop, provide a helper function for the preferred subdevice assigned to the current process. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/control.c | 27 ++++++++++++++++++++++++--- sound/core/pcm.c | 15 +++------------ sound/core/rawmidi.c | 14 ++------------ 3 files changed, 29 insertions(+), 27 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index bb96a467e88d..cd246a0bcd55 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -50,7 +50,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file) unsigned long flags; struct snd_card *card; struct snd_ctl_file *ctl; - int err; + int i, err; err = nonseekable_open(inode, file); if (err < 0) @@ -79,8 +79,8 @@ static int snd_ctl_open(struct inode *inode, struct file *file) init_waitqueue_head(&ctl->change_sleep); spin_lock_init(&ctl->read_lock); ctl->card = card; - ctl->prefer_pcm_subdevice = -1; - ctl->prefer_rawmidi_subdevice = -1; + for (i = 0; i < SND_CTL_SUBDEV_ITEMS; i++) + ctl->preferred_subdevice[i] = -1; ctl->pid = get_pid(task_pid(current)); file->private_data = ctl; write_lock_irqsave(&card->ctl_files_rwlock, flags); @@ -1607,6 +1607,27 @@ static int snd_ctl_fasync(int fd, struct file * file, int on) return fasync_helper(fd, file, on, &ctl->fasync); } +/* return the preferred subdevice number if already assigned; + * otherwise return -1 + */ +int snd_ctl_get_preferred_subdevice(struct snd_card *card, int type) +{ + struct snd_ctl_file *kctl; + int subdevice = -1; + + read_lock(&card->ctl_files_rwlock); + list_for_each_entry(kctl, &card->ctl_files, list) { + if (kctl->pid == task_pid(current)) { + subdevice = kctl->preferred_subdevice[type]; + if (subdevice != -1) + break; + } + } + read_unlock(&card->ctl_files_rwlock); + return subdevice; +} +EXPORT_SYMBOL_GPL(snd_ctl_get_preferred_subdevice); + /* * ioctl32 compat */ diff --git a/sound/core/pcm.c b/sound/core/pcm.c index dba5180e5b80..1b7c473720fa 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -161,7 +161,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, if (get_user(val, (int __user *)arg)) return -EFAULT; - control->prefer_pcm_subdevice = val; + control->preferred_subdevice[SND_CTL_SUBDEV_PCM] = val; return 0; } } @@ -901,9 +901,8 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, struct snd_pcm_str * pstr; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; - struct snd_ctl_file *kctl; struct snd_card *card; - int prefer_subdevice = -1; + int prefer_subdevice; size_t size; if (snd_BUG_ON(!pcm || !rsubstream)) @@ -914,15 +913,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, return -ENODEV; card = pcm->card; - read_lock(&card->ctl_files_rwlock); - list_for_each_entry(kctl, &card->ctl_files, list) { - if (kctl->pid == task_pid(current)) { - prefer_subdevice = kctl->prefer_pcm_subdevice; - if (prefer_subdevice != -1) - break; - } - } - read_unlock(&card->ctl_files_rwlock); + prefer_subdevice = snd_ctl_get_preferred_subdevice(card, SND_CTL_SUBDEV_PCM); switch (stream) { case SNDRV_PCM_STREAM_PLAYBACK: diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 6fc71a4c8a51..be18162c380f 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -369,7 +369,6 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) struct snd_rawmidi *rmidi; struct snd_rawmidi_file *rawmidi_file = NULL; wait_queue_t wait; - struct snd_ctl_file *kctl; if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK)) return -EINVAL; /* invalid combination */ @@ -413,16 +412,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) init_waitqueue_entry(&wait, current); add_wait_queue(&rmidi->open_wait, &wait); while (1) { - subdevice = -1; - read_lock(&card->ctl_files_rwlock); - list_for_each_entry(kctl, &card->ctl_files, list) { - if (kctl->pid == task_pid(current)) { - subdevice = kctl->prefer_rawmidi_subdevice; - if (subdevice != -1) - break; - } - } - read_unlock(&card->ctl_files_rwlock); + subdevice = snd_ctl_get_preferred_subdevice(card, SND_CTL_SUBDEV_RAWMIDI); err = rawmidi_open_priv(rmidi, subdevice, fflags, rawmidi_file); if (err >= 0) break; @@ -862,7 +852,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, if (get_user(val, (int __user *)argp)) return -EFAULT; - control->prefer_rawmidi_subdevice = val; + control->preferred_subdevice[SND_CTL_SUBDEV_RAWMIDI] = val; return 0; } case SNDRV_CTL_IOCTL_RAWMIDI_INFO: -- cgit From 4b440be667c6187717c99e4d427119fa415ced29 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 21:32:47 +0100 Subject: ALSA: Add a helper to initialize device Introduce a new helper function snd_device_initialize() to initialize the device object for sound devices. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/init.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sound') diff --git a/sound/core/init.c b/sound/core/init.c index 074875d68c15..96194599e82e 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -157,6 +157,29 @@ static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int), return mask; /* unchanged */ } +/* the default release callback set in snd_device_initialize() below; + * this is just NOP for now, as almost all jobs are already done in + * dev_free callback of snd_device chain instead. + */ +static void default_release(struct device *dev) +{ +} + +/** + * snd_device_initialize - Initialize struct device for sound devices + * @dev: device to initialize + * @card: card to assign, optional + */ +void snd_device_initialize(struct device *dev, struct snd_card *card) +{ + device_initialize(dev); + if (card) + dev->parent = &card->card_dev; + dev->class = sound_class; + dev->release = default_release; +} +EXPORT_SYMBOL_GPL(snd_device_initialize); + static int snd_card_do_free(struct snd_card *card); static const struct attribute_group *card_dev_attr_groups[]; -- cgit From 0fcd9f4b3c60382205e5819c456aa9ea17b6f20f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 16:41:27 +0100 Subject: ALSA: control: Embed struct device This patch embeds a struct device for the control device into the card object and avoid the device creation at registration time. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/control.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index cd246a0bcd55..e214fabbc671 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1660,19 +1660,10 @@ static const struct file_operations snd_ctl_f_ops = static int snd_ctl_dev_register(struct snd_device *device) { struct snd_card *card = device->device_data; - int err, cardnum; - char name[16]; - if (snd_BUG_ON(!card)) - return -ENXIO; - cardnum = card->number; - if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS)) - return -ENXIO; - sprintf(name, "controlC%i", cardnum); - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, - &snd_ctl_f_ops, card, name)) < 0) - return err; - return 0; + return snd_register_device_for_dev(SNDRV_DEVICE_TYPE_CONTROL, card, + -1, &snd_ctl_f_ops, card, + &card->ctl_dev, NULL, NULL); } /* @@ -1682,13 +1673,6 @@ static int snd_ctl_dev_disconnect(struct snd_device *device) { struct snd_card *card = device->device_data; struct snd_ctl_file *ctl; - int err, cardnum; - - if (snd_BUG_ON(!card)) - return -ENXIO; - cardnum = card->number; - if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS)) - return -ENXIO; read_lock(&card->ctl_files_rwlock); list_for_each_entry(ctl, &card->ctl_files, list) { @@ -1697,10 +1681,7 @@ static int snd_ctl_dev_disconnect(struct snd_device *device) } read_unlock(&card->ctl_files_rwlock); - if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, - card, -1)) < 0) - return err; - return 0; + return snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1); } /* @@ -1717,6 +1698,7 @@ static int snd_ctl_dev_free(struct snd_device *device) snd_ctl_remove(card, control); } up_write(&card->controls_rwsem); + put_device(&card->ctl_dev); return 0; } @@ -1731,10 +1713,20 @@ int snd_ctl_create(struct snd_card *card) .dev_register = snd_ctl_dev_register, .dev_disconnect = snd_ctl_dev_disconnect, }; + int err; if (snd_BUG_ON(!card)) return -ENXIO; - return snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); + if (snd_BUG_ON(card->number < 0 || card->number >= SNDRV_CARDS)) + return -ENXIO; + + snd_device_initialize(&card->ctl_dev, card); + dev_set_name(&card->ctl_dev, "controlC%d", card->number); + + err = snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); + if (err < 0) + put_device(&card->ctl_dev); + return err; } /* -- cgit From 7b46160000197209f7ebca8b92bdbb75795c473f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 17:13:32 +0100 Subject: ALSA: hwdep: Embed struct device Like the previous patch, this one embeds the device object into hwdep object. For a proper object lifecycle, it's freed in the release callback. This also allows us to create sysfs entries via passing to the groups field of the device without explicit function calls. Since each driver can see the device and touch its groups field directly, we don't need to delegate in hwdep core any longer. So, remove the groups field from snd_hwdep, and let the user (in this case only hda_hwdep.c) modify the device groups. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/hwdep.c | 82 ++++++++++++++++++----------------------------- sound/pci/hda/hda_hwdep.c | 7 ++-- 2 files changed, 37 insertions(+), 52 deletions(-) (limited to 'sound') diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 85096a150eda..506387ba645d 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -38,7 +38,6 @@ MODULE_LICENSE("GPL"); static LIST_HEAD(snd_hwdep_devices); static DEFINE_MUTEX(register_mutex); -static int snd_hwdep_free(struct snd_hwdep *hwdep); static int snd_hwdep_dev_free(struct snd_device *device); static int snd_hwdep_dev_register(struct snd_device *device); static int snd_hwdep_dev_disconnect(struct snd_device *device); @@ -345,6 +344,11 @@ static const struct file_operations snd_hwdep_f_ops = .mmap = snd_hwdep_mmap, }; +static void release_hwdep_device(struct device *dev) +{ + kfree(container_of(dev, struct snd_hwdep, dev)); +} + /** * snd_hwdep_new - create a new hwdep instance * @card: the card instance @@ -378,48 +382,49 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, dev_err(card->dev, "hwdep: cannot allocate\n"); return -ENOMEM; } + + init_waitqueue_head(&hwdep->open_wait); + mutex_init(&hwdep->open_mutex); hwdep->card = card; hwdep->device = device; if (id) strlcpy(hwdep->id, id, sizeof(hwdep->id)); + + snd_device_initialize(&hwdep->dev, card); + hwdep->dev.release = release_hwdep_device; + dev_set_name(&hwdep->dev, "hwC%iD%i", card->number, device); #ifdef CONFIG_SND_OSSEMUL hwdep->oss_type = -1; #endif - if ((err = snd_device_new(card, SNDRV_DEV_HWDEP, hwdep, &ops)) < 0) { - snd_hwdep_free(hwdep); + + err = snd_device_new(card, SNDRV_DEV_HWDEP, hwdep, &ops); + if (err < 0) { + put_device(&hwdep->dev); return err; } - init_waitqueue_head(&hwdep->open_wait); - mutex_init(&hwdep->open_mutex); + if (rhwdep) *rhwdep = hwdep; return 0; } EXPORT_SYMBOL(snd_hwdep_new); -static int snd_hwdep_free(struct snd_hwdep *hwdep) +static int snd_hwdep_dev_free(struct snd_device *device) { + struct snd_hwdep *hwdep = device->device_data; if (!hwdep) return 0; if (hwdep->private_free) hwdep->private_free(hwdep); - kfree(hwdep); + put_device(&hwdep->dev); return 0; } -static int snd_hwdep_dev_free(struct snd_device *device) -{ - struct snd_hwdep *hwdep = device->device_data; - return snd_hwdep_free(hwdep); -} - static int snd_hwdep_dev_register(struct snd_device *device) { struct snd_hwdep *hwdep = device->device_data; struct snd_card *card = hwdep->card; - struct device *dev; int err; - char name[32]; mutex_lock(®ister_mutex); if (snd_hwdep_search(card, hwdep->device)) { @@ -427,54 +432,31 @@ static int snd_hwdep_dev_register(struct snd_device *device) return -EBUSY; } list_add_tail(&hwdep->list, &snd_hwdep_devices); - sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); - dev = hwdep->dev; - if (!dev) - dev = snd_card_get_device_link(hwdep->card); err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device, &snd_hwdep_f_ops, hwdep, - NULL, dev, name); + &hwdep->dev, NULL, NULL); if (err < 0) { - dev_err(dev, - "unable to register hardware dependent device %i:%i\n", - card->number, hwdep->device); + dev_err(&hwdep->dev, "unable to register\n"); list_del(&hwdep->list); mutex_unlock(®ister_mutex); return err; } - if (hwdep->groups) { - struct device *d = snd_get_device(SNDRV_DEVICE_TYPE_HWDEP, - hwdep->card, hwdep->device); - if (d) { - if (hwdep->private_data) - dev_set_drvdata(d, hwdep->private_data); - err = sysfs_create_groups(&d->kobj, hwdep->groups); - if (err < 0) - dev_warn(dev, - "hwdep %d:%d: cannot create sysfs groups\n", - card->number, hwdep->device); - put_device(d); - } - } - #ifdef CONFIG_SND_OSSEMUL hwdep->ossreg = 0; if (hwdep->oss_type >= 0) { - if ((hwdep->oss_type == SNDRV_OSS_DEVICE_TYPE_DMFM) && (hwdep->device != 0)) { - dev_warn(dev, + if (hwdep->oss_type == SNDRV_OSS_DEVICE_TYPE_DMFM && + hwdep->device) + dev_warn(&hwdep->dev, "only hwdep device 0 can be registered as OSS direct FM device!\n"); - } else { - if (snd_register_oss_device(hwdep->oss_type, - card, hwdep->device, - &snd_hwdep_f_ops, hwdep) < 0) { - dev_err(dev, - "unable to register OSS compatibility device %i:%i\n", - card->number, hwdep->device); - } else - hwdep->ossreg = 1; - } + else if (snd_register_oss_device(hwdep->oss_type, + card, hwdep->device, + &snd_hwdep_f_ops, hwdep) < 0) + dev_warn(&hwdep->dev, + "unable to register OSS compatibility device\n"); + else + hwdep->ossreg = 1; } #endif mutex_unlock(®ister_mutex); diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index 014a7849e8fd..11b5a42b4ec8 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c @@ -109,7 +109,6 @@ int snd_hda_create_hwdep(struct hda_codec *codec) hwdep->iface = SNDRV_HWDEP_IFACE_HDA; hwdep->private_data = codec; hwdep->exclusive = 1; - hwdep->groups = snd_hda_dev_attr_groups; hwdep->ops.open = hda_hwdep_open; hwdep->ops.ioctl = hda_hwdep_ioctl; @@ -118,7 +117,11 @@ int snd_hda_create_hwdep(struct hda_codec *codec) #endif /* link to codec */ - hwdep->dev = &codec->dev; + hwdep->dev.parent = &codec->dev; + + /* for sysfs */ + hwdep->dev.groups = snd_hda_dev_attr_groups; + dev_set_drvdata(&hwdep->dev, codec); return 0; } -- cgit From ef46c7af93f98d07cd0ed891f93a26d135785526 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 17:32:26 +0100 Subject: ALSA: pcm: Embed struct device Like previous patches, at this time we embed the struct device into PCM object. However, this needs a bit more caution: struct snd_pcm doesn't own one device but two, for both playback and capture! Thus not struct snd_pcm but struct snd_pcm_str object contains the device. Along with this change, pcm->dev field is dropped for avoiding confusion. It was meant to point to a non-standard parent. But, since now we can touch each struct device directly, we can manipulate the parent field easily there, too. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/aoa/soundbus/i2sbus/pcm.c | 5 ++++- sound/core/pcm.c | 38 +++++++++++++-------------------- sound/pci/hda/hda_controller.c | 3 ++- sound/soc/intel/sst-mfld-platform-pcm.c | 1 - 4 files changed, 21 insertions(+), 26 deletions(-) (limited to 'sound') diff --git a/sound/aoa/soundbus/i2sbus/pcm.c b/sound/aoa/soundbus/i2sbus/pcm.c index 7b74a4ba75f8..a02b7b8d3532 100644 --- a/sound/aoa/soundbus/i2sbus/pcm.c +++ b/sound/aoa/soundbus/i2sbus/pcm.c @@ -968,7 +968,6 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card, printk(KERN_DEBUG "i2sbus: failed to create pcm\n"); goto out_put_ci_module; } - dev->pcm->dev = &dev->ofdev.dev; } /* ALSA yet again sucks. @@ -988,6 +987,8 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card, goto out_put_ci_module; snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, &i2sbus_playback_ops); + dev->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].dev.parent = + &dev->ofdev.dev; i2sdev->out.created = 1; } @@ -1003,6 +1004,8 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card, goto out_put_ci_module; snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, &i2sbus_record_ops); + dev->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].dev.parent = + &dev->ofdev.dev; i2sdev->in.created = 1; } diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 1b7c473720fa..4d5120f7a8ab 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -673,6 +673,8 @@ static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substrea static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { return 0; } #endif /* CONFIG_SND_VERBOSE_PROCFS */ +static const struct attribute_group *pcm_dev_attr_groups[]; + /** * snd_pcm_new_stream - create a new PCM stream * @pcm: the pcm instance @@ -698,7 +700,15 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) pstr->stream = stream; pstr->pcm = pcm; pstr->substream_count = substream_count; - if (substream_count > 0 && !pcm->internal) { + if (!substream_count) + return 0; + + snd_device_initialize(&pstr->dev, pcm->card); + pstr->dev.groups = pcm_dev_attr_groups; + dev_set_name(&pstr->dev, "pcmC%iD%i%c", pcm->card->number, pcm->device, + stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c'); + + if (!pcm->internal) { err = snd_pcm_stream_proc_init(pstr); if (err < 0) { pcm_err(pcm, "Error in snd_pcm_stream_proc_init\n"); @@ -868,6 +878,8 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) kfree(setup); } #endif + if (pstr->substream_count) + put_device(&pstr->dev); } static int snd_pcm_free(struct snd_pcm *pcm) @@ -1069,9 +1081,7 @@ static int snd_pcm_dev_register(struct snd_device *device) int cidx, err; struct snd_pcm_substream *substream; struct snd_pcm_notify *notify; - char str[16]; struct snd_pcm *pcm; - struct device *dev; if (snd_BUG_ON(!device || !device->device_data)) return -ENXIO; @@ -1088,42 +1098,24 @@ static int snd_pcm_dev_register(struct snd_device *device) continue; switch (cidx) { case SNDRV_PCM_STREAM_PLAYBACK: - sprintf(str, "pcmC%iD%ip", pcm->card->number, pcm->device); devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK; break; case SNDRV_PCM_STREAM_CAPTURE: - sprintf(str, "pcmC%iD%ic", pcm->card->number, pcm->device); devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; break; } - /* device pointer to use, pcm->dev takes precedence if - * it is assigned, otherwise fall back to card's device - * if possible */ - dev = pcm->dev; - if (!dev) - dev = snd_card_get_device_link(pcm->card); /* register pcm */ err = snd_register_device_for_dev(devtype, pcm->card, pcm->device, &snd_pcm_f_ops[cidx], - pcm, NULL, dev, str); + pcm, &pcm->streams[cidx].dev, + NULL, NULL); if (err < 0) { list_del(&pcm->list); mutex_unlock(®ister_mutex); return err; } - dev = snd_get_device(devtype, pcm->card, pcm->device); - if (dev) { - err = sysfs_create_groups(&dev->kobj, - pcm_dev_attr_groups); - if (err < 0) - dev_warn(dev, - "pcm %d:%d: cannot create sysfs groups\n", - pcm->card->number, pcm->device); - put_device(dev); - } - for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) snd_pcm_timer_init(substream); } diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 0cfc9c8c4b4e..712ec5ceba46 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -939,7 +939,8 @@ static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, chip->card->dev, size, MAX_PREALLOC_SIZE); /* link to codec */ - pcm->dev = &codec->dev; + for (s = 0; s < 2; s++) + pcm->streams[s].dev.parent = &codec->dev; return 0; } diff --git a/sound/soc/intel/sst-mfld-platform-pcm.c b/sound/soc/intel/sst-mfld-platform-pcm.c index a1a8d9d91539..2d80c4e12997 100644 --- a/sound/soc/intel/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/sst-mfld-platform-pcm.c @@ -645,7 +645,6 @@ static struct snd_pcm_ops sst_platform_ops = { static void sst_pcm_free(struct snd_pcm *pcm) { - dev_dbg(pcm->dev, "sst_pcm_free called\n"); snd_pcm_lib_preallocate_free_for_all(pcm); } -- cgit From aee5012fbb77dad6179c44d83d531ad62dd8098a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 17:55:52 +0100 Subject: ALSA: rawmidi: Embed struct device Like previous patches, this changes the device management for rawmidi, embedding the struct device into struct snd_rawmidi. The required change is more or less same as hwdep device. The currently unused dev field is reused as the new embedded struct field now. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/rawmidi.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index be18162c380f..932396c81035 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1443,6 +1443,11 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, return 0; } +static void release_rawmidi_device(struct device *dev) +{ + kfree(container_of(dev, struct snd_rawmidi, dev)); +} + /** * snd_rawmidi_new - create a rawmidi instance * @card: the card instance @@ -1487,6 +1492,11 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, if (id != NULL) strlcpy(rmidi->id, id, sizeof(rmidi->id)); + + snd_device_initialize(&rmidi->dev, card); + rmidi->dev.release = release_rawmidi_device; + dev_set_name(&rmidi->dev, "midiC%iD%i", card->number, device); + if ((err = snd_rawmidi_alloc_substreams(rmidi, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT], SNDRV_RAWMIDI_STREAM_INPUT, @@ -1538,7 +1548,7 @@ static int snd_rawmidi_free(struct snd_rawmidi *rmidi) snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]); if (rmidi->private_free) rmidi->private_free(rmidi); - kfree(rmidi); + put_device(&rmidi->dev); return 0; } @@ -1571,12 +1581,12 @@ static int snd_rawmidi_dev_register(struct snd_device *device) return -EBUSY; } list_add_tail(&rmidi->list, &snd_rawmidi_devices); - sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device); - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, - rmidi->card, rmidi->device, - &snd_rawmidi_f_ops, rmidi, name)) < 0) { - rmidi_err(rmidi, "unable to register rawmidi device %i:%i\n", - rmidi->card->number, rmidi->device); + err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_RAWMIDI, + rmidi->card, rmidi->device, + &snd_rawmidi_f_ops, rmidi, + &rmidi->dev, NULL, NULL); + if (err < 0) { + rmidi_err(rmidi, "unable to register\n"); list_del(&rmidi->list); mutex_unlock(®ister_mutex); return err; -- cgit From 07cc3e8bd57cd9d9f8f30c30ed859a55a7d8f4d3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jan 2015 15:31:52 +0100 Subject: ALSA: rawmidi: Use rawmidi device file for kernel messages ... instead of card's device. This will be helpful to distinguish errors from multiple rawmidi devices on a single card. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/rawmidi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 932396c81035..bccbf7e375d6 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -57,11 +57,11 @@ static LIST_HEAD(snd_rawmidi_devices); static DEFINE_MUTEX(register_mutex); #define rmidi_err(rmidi, fmt, args...) \ - dev_err((rmidi)->card->dev, fmt, ##args) + dev_err(&(rmidi)->dev, fmt, ##args) #define rmidi_warn(rmidi, fmt, args...) \ - dev_warn((rmidi)->card->dev, fmt, ##args) + dev_warn(&(rmidi)->dev, fmt, ##args) #define rmidi_dbg(rmidi, fmt, args...) \ - dev_dbg((rmidi)->card->dev, fmt, ##args) + dev_dbg(&(rmidi)->dev, fmt, ##args) static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) { -- cgit From 7c35860d1ae555a040f561c7cfdde066053787f0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 18:09:05 +0100 Subject: ALSA: timer: Propagate the error at initialization ... instead of just printing errors. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/timer.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/core/timer.c b/sound/core/timer.c index 777a45e08e53..28b673d4f812 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1942,6 +1942,15 @@ static const struct file_operations snd_timer_f_ops = .fasync = snd_timer_user_fasync, }; +/* unregister the system timer */ +static void snd_timer_free_all(void) +{ + struct snd_timer *timer, *n; + + list_for_each_entry_safe(timer, n, &snd_timer_list, device_list) + snd_timer_free(timer); +} + /* * ENTRY functions */ @@ -1955,25 +1964,28 @@ static int __init alsa_timer_init(void) "system timer"); #endif - if ((err = snd_timer_register_system()) < 0) + err = snd_timer_register_system(); + if (err < 0) { pr_err("ALSA: unable to register system timer (%i)\n", err); - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, - &snd_timer_f_ops, NULL, "timer")) < 0) + return err; + } + + err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, + &snd_timer_f_ops, NULL, "timer"); + if (err < 0) { pr_err("ALSA: unable to register timer device (%i)\n", err); + snd_timer_free_all(); + return err; + } + snd_timer_proc_init(); return 0; } static void __exit alsa_timer_exit(void) { - struct list_head *p, *n; - snd_unregister_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0); - /* unregister the system timer */ - list_for_each_safe(p, n, &snd_timer_list) { - struct snd_timer *timer = list_entry(p, struct snd_timer, device_list); - snd_timer_free(timer); - } + snd_timer_free_all(); snd_timer_proc_done(); #ifdef SNDRV_OSS_INFO_DEV_TIMERS snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1); -- cgit From 89da061f0a556f1324d8ac84f1012107bf08d2e1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 18:12:26 +0100 Subject: ALSA: timer: Handle the device directly This is a relatively straightforward change, using the struct device directly for managing the ALSA timer device. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/timer.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/core/timer.c b/sound/core/timer.c index 28b673d4f812..dae40ac11e04 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1951,6 +1951,8 @@ static void snd_timer_free_all(void) snd_timer_free(timer); } +static struct device timer_dev; + /* * ENTRY functions */ @@ -1959,6 +1961,9 @@ static int __init alsa_timer_init(void) { int err; + snd_device_initialize(&timer_dev, NULL); + dev_set_name(&timer_dev, "timer"); + #ifdef SNDRV_OSS_INFO_DEV_TIMERS snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1, "system timer"); @@ -1967,14 +1972,17 @@ static int __init alsa_timer_init(void) err = snd_timer_register_system(); if (err < 0) { pr_err("ALSA: unable to register system timer (%i)\n", err); + put_device(&timer_dev); return err; } - err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, - &snd_timer_f_ops, NULL, "timer"); + err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, + &snd_timer_f_ops, NULL, + &timer_dev, NULL, NULL); if (err < 0) { pr_err("ALSA: unable to register timer device (%i)\n", err); snd_timer_free_all(); + put_device(&timer_dev); return err; } @@ -1986,6 +1994,7 @@ static void __exit alsa_timer_exit(void) { snd_unregister_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0); snd_timer_free_all(); + put_device(&timer_dev); snd_timer_proc_done(); #ifdef SNDRV_OSS_INFO_DEV_TIMERS snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1); -- cgit From 5205388d2d6dbdc5cb743c4e3f61acb9a5e5794f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jan 2015 08:04:21 +0100 Subject: ALSA: seq: Handle the device directly Like the previous change for the timer device, this patch changes the device management for the ALSA sequencer device using the struct device directly. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/seq/seq_clientmgr.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 225c73152ee9..65b320ec66f1 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2571,6 +2571,8 @@ static const struct file_operations snd_seq_f_ops = .compat_ioctl = snd_seq_ioctl_compat, }; +static struct device seq_dev; + /* * register sequencer device */ @@ -2578,12 +2580,18 @@ int __init snd_sequencer_device_init(void) { int err; + snd_device_initialize(&seq_dev, NULL); + dev_set_name(&seq_dev, "seq"); + if (mutex_lock_interruptible(®ister_mutex)) return -ERESTARTSYS; - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, - &snd_seq_f_ops, NULL, "seq")) < 0) { + err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, + &snd_seq_f_ops, NULL, + &seq_dev, NULL, NULL); + if (err < 0) { mutex_unlock(®ister_mutex); + put_device(&seq_dev); return err; } @@ -2600,4 +2608,5 @@ int __init snd_sequencer_device_init(void) void __exit snd_sequencer_device_done(void) { snd_unregister_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0); + put_device(&seq_dev); } -- cgit From 04c5d5a430fca046cffac099a3f41e74816939da Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jan 2015 08:16:35 +0100 Subject: ALSA: compress: Embed struct device Like previous patches, this one embeds the struct device into struct snd_compr. As the dev field wasn't used beforehand, it's reused as the new device struct. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/compress_offload.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 89028fab64fd..cb58c3f7f80c 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -868,12 +868,13 @@ static int snd_compress_dev_register(struct snd_device *device) return -EBADFD; compr = device->device_data; - sprintf(str, "comprC%iD%i", compr->card->number, compr->device); pr_debug("reg %s for device %s, direction %d\n", str, compr->name, compr->direction); /* register compressed device */ - ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS, compr->card, - compr->device, &snd_compr_file_ops, compr, str); + ret = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_COMPRESS, + compr->card, compr->device, + &snd_compr_file_ops, compr, + &compr->dev, NULL, NULL); if (ret < 0) { pr_err("snd_register_device failed\n %d", ret); return ret; @@ -892,6 +893,15 @@ static int snd_compress_dev_disconnect(struct snd_device *device) return 0; } +static int snd_compress_dev_free(struct snd_device *device) +{ + struct snd_compr *compr; + + compr = device->device_data; + put_device(&compr->dev); + return 0; +} + /* * snd_compress_new: create new compress device * @card: sound card pointer @@ -903,7 +913,7 @@ int snd_compress_new(struct snd_card *card, int device, int dirn, struct snd_compr *compr) { static struct snd_device_ops ops = { - .dev_free = NULL, + .dev_free = snd_compress_dev_free, .dev_register = snd_compress_dev_register, .dev_disconnect = snd_compress_dev_disconnect, }; @@ -911,6 +921,10 @@ int snd_compress_new(struct snd_card *card, int device, compr->card = card; compr->device = device; compr->direction = dirn; + + snd_device_initialize(&compr->dev, card); + dev_set_name(&compr->dev, "comprC%iD%i", card->number, device); + return snd_device_new(card, SNDRV_DEV_COMPRESS, compr, &ops); } EXPORT_SYMBOL_GPL(snd_compress_new); @@ -948,7 +962,7 @@ int snd_compress_register(struct snd_compr *device) { int retval; - if (device->name == NULL || device->dev == NULL || device->ops == NULL) + if (device->name == NULL || device->ops == NULL) return -EINVAL; pr_debug("Registering compressed device %s\n", device->name); -- cgit From 40a4b263854346fe7c7d1c3964c106296f690816 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jan 2015 08:34:58 +0100 Subject: ALSA: Simplify snd_device_register() variants Now that all callers have been replaced with snd_device_register_for_dev(), let's drop the obsolete device registration code and concentrate only on the code handling struct device directly. That said, - remove the old snd_device_register(), - rename snd_device_register_for_dev() with snd_device_register(), - drop superfluous arguments from snd_device_register(), - change snd_unregister_device() to pass the device pointer directly Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/compress_offload.c | 10 +++---- sound/core/control.c | 7 ++--- sound/core/hwdep.c | 9 +++--- sound/core/pcm.c | 21 ++++---------- sound/core/rawmidi.c | 11 ++++--- sound/core/seq/seq_clientmgr.c | 7 ++--- sound/core/sound.c | 65 ++++++++++++++++-------------------------- sound/core/timer.c | 7 ++--- 8 files changed, 51 insertions(+), 86 deletions(-) (limited to 'sound') diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index cb58c3f7f80c..b123c42e7dc8 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -871,10 +871,9 @@ static int snd_compress_dev_register(struct snd_device *device) pr_debug("reg %s for device %s, direction %d\n", str, compr->name, compr->direction); /* register compressed device */ - ret = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_COMPRESS, - compr->card, compr->device, - &snd_compr_file_ops, compr, - &compr->dev, NULL, NULL); + ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS, + compr->card, compr->device, + &snd_compr_file_ops, compr, &compr->dev); if (ret < 0) { pr_err("snd_register_device failed\n %d", ret); return ret; @@ -888,8 +887,7 @@ static int snd_compress_dev_disconnect(struct snd_device *device) struct snd_compr *compr; compr = device->device_data; - snd_unregister_device(SNDRV_DEVICE_TYPE_COMPRESS, compr->card, - compr->device); + snd_unregister_device(&compr->dev); return 0; } diff --git a/sound/core/control.c b/sound/core/control.c index e214fabbc671..60caba1f2211 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1661,9 +1661,8 @@ static int snd_ctl_dev_register(struct snd_device *device) { struct snd_card *card = device->device_data; - return snd_register_device_for_dev(SNDRV_DEVICE_TYPE_CONTROL, card, - -1, &snd_ctl_f_ops, card, - &card->ctl_dev, NULL, NULL); + return snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, + &snd_ctl_f_ops, card, &card->ctl_dev); } /* @@ -1681,7 +1680,7 @@ static int snd_ctl_dev_disconnect(struct snd_device *device) } read_unlock(&card->ctl_files_rwlock); - return snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1); + return snd_unregister_device(&card->ctl_dev); } /* diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 506387ba645d..84244a5143cf 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -432,10 +432,9 @@ static int snd_hwdep_dev_register(struct snd_device *device) return -EBUSY; } list_add_tail(&hwdep->list, &snd_hwdep_devices); - err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_HWDEP, - hwdep->card, hwdep->device, - &snd_hwdep_f_ops, hwdep, - &hwdep->dev, NULL, NULL); + err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, + hwdep->card, hwdep->device, + &snd_hwdep_f_ops, hwdep, &hwdep->dev); if (err < 0) { dev_err(&hwdep->dev, "unable to register\n"); list_del(&hwdep->list); @@ -480,7 +479,7 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device) if (hwdep->ossreg) snd_unregister_oss_device(hwdep->oss_type, hwdep->card, hwdep->device); #endif - snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); + snd_unregister_device(&hwdep->dev); list_del_init(&hwdep->list); mutex_unlock(&hwdep->open_mutex); mutex_unlock(®ister_mutex); diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 4d5120f7a8ab..0345e53a340c 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1105,11 +1105,9 @@ static int snd_pcm_dev_register(struct snd_device *device) break; } /* register pcm */ - err = snd_register_device_for_dev(devtype, pcm->card, - pcm->device, - &snd_pcm_f_ops[cidx], - pcm, &pcm->streams[cidx].dev, - NULL, NULL); + err = snd_register_device(devtype, pcm->card, pcm->device, + &snd_pcm_f_ops[cidx], pcm, + &pcm->streams[cidx].dev); if (err < 0) { list_del(&pcm->list); mutex_unlock(®ister_mutex); @@ -1132,7 +1130,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) struct snd_pcm *pcm = device->device_data; struct snd_pcm_notify *notify; struct snd_pcm_substream *substream; - int cidx, devtype; + int cidx; mutex_lock(®ister_mutex); if (list_empty(&pcm->list)) @@ -1155,16 +1153,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) notify->n_disconnect(pcm); } for (cidx = 0; cidx < 2; cidx++) { - devtype = -1; - switch (cidx) { - case SNDRV_PCM_STREAM_PLAYBACK: - devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK; - break; - case SNDRV_PCM_STREAM_CAPTURE: - devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; - break; - } - snd_unregister_device(devtype, pcm->card, pcm->device); + snd_unregister_device(&pcm->streams[cidx].dev); if (pcm->streams[cidx].chmap_kctl) { snd_ctl_remove(pcm->card, pcm->streams[cidx].chmap_kctl); pcm->streams[cidx].chmap_kctl = NULL; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index bccbf7e375d6..b5a748596fc4 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1581,10 +1581,9 @@ static int snd_rawmidi_dev_register(struct snd_device *device) return -EBUSY; } list_add_tail(&rmidi->list, &snd_rawmidi_devices); - err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_RAWMIDI, - rmidi->card, rmidi->device, - &snd_rawmidi_f_ops, rmidi, - &rmidi->dev, NULL, NULL); + err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, + rmidi->card, rmidi->device, + &snd_rawmidi_f_ops, rmidi, &rmidi->dev); if (err < 0) { rmidi_err(rmidi, "unable to register\n"); list_del(&rmidi->list); @@ -1593,7 +1592,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device) } if (rmidi->ops && rmidi->ops->dev_register && (err = rmidi->ops->dev_register(rmidi)) < 0) { - snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); + snd_unregister_device(&rmidi->dev); list_del(&rmidi->list); mutex_unlock(®ister_mutex); return err; @@ -1681,7 +1680,7 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device) rmidi->ossreg = 0; } #endif /* CONFIG_SND_OSSEMUL */ - snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); + snd_unregister_device(&rmidi->dev); mutex_unlock(&rmidi->open_mutex); mutex_unlock(®ister_mutex); return 0; diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 65b320ec66f1..2b62cd021bc5 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2586,9 +2586,8 @@ int __init snd_sequencer_device_init(void) if (mutex_lock_interruptible(®ister_mutex)) return -ERESTARTSYS; - err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, - &snd_seq_f_ops, NULL, - &seq_dev, NULL, NULL); + err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, + &snd_seq_f_ops, NULL, &seq_dev); if (err < 0) { mutex_unlock(®ister_mutex); put_device(&seq_dev); @@ -2607,6 +2606,6 @@ int __init snd_sequencer_device_init(void) */ void __exit snd_sequencer_device_done(void) { - snd_unregister_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0); + snd_unregister_device(&seq_dev); put_device(&seq_dev); } diff --git a/sound/core/sound.c b/sound/core/sound.c index ea1af1acdbe9..2e8aeb18d76b 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -242,30 +242,30 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) #endif /** - * snd_register_device_for_dev - Register the ALSA device file for the card + * snd_register_device - Register the ALSA device file for the card * @type: the device type, SNDRV_DEVICE_TYPE_XXX * @card: the card instance * @dev: the device index * @f_ops: the file operations * @private_data: user pointer for f_ops->open() - * @device: the device to register, NULL to create a new one - * @parent: the &struct device to link this new device to (only for device=NULL) - * @name: the device file name (only for device=NULL) + * @device: the device to register * * Registers an ALSA device file for the given card. * The operators have to be set in reg parameter. * * Return: Zero if successful, or a negative error code on failure. */ -int snd_register_device_for_dev(int type, struct snd_card *card, int dev, - const struct file_operations *f_ops, - void *private_data, struct device *device, - struct device *parent, const char *name) +int snd_register_device(int type, struct snd_card *card, int dev, + const struct file_operations *f_ops, + void *private_data, struct device *device) { int minor; int err = 0; struct snd_minor *preg; + if (snd_BUG_ON(!device)) + return -EINVAL; + preg = kmalloc(sizeof *preg, GFP_KERNEL); if (preg == NULL) return -ENOMEM; @@ -288,19 +288,9 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, goto error; } - if (device) { - preg->created = false; - preg->dev = device; - device->devt = MKDEV(major, minor); - err = device_add(device); - } else { - preg->created = true; - preg->dev = device_create(sound_class, parent, - MKDEV(major, minor), private_data, - "%s", name); - if (IS_ERR(preg->dev)) - err = PTR_ERR(preg->dev); - } + preg->dev = device; + device->devt = MKDEV(major, minor); + err = device_add(device); if (err < 0) goto error; @@ -311,8 +301,7 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, kfree(preg); return err; } - -EXPORT_SYMBOL(snd_register_device_for_dev); +EXPORT_SYMBOL(snd_register_device); /* find the matching minor record * return the index of snd_minor, or -1 if not found @@ -334,39 +323,33 @@ static int find_snd_minor(int type, struct snd_card *card, int dev) /** * snd_unregister_device - unregister the device on the given card - * @type: the device type, SNDRV_DEVICE_TYPE_XXX - * @card: the card instance - * @dev: the device index + * @dev: the device instance * * Unregisters the device file already registered via * snd_register_device(). * * Return: Zero if successful, or a negative error code on failure. */ -int snd_unregister_device(int type, struct snd_card *card, int dev) +int snd_unregister_device(struct device *dev) { int minor; struct snd_minor *preg; mutex_lock(&sound_mutex); - minor = find_snd_minor(type, card, dev); - if (minor < 0) { - mutex_unlock(&sound_mutex); - return -EINVAL; + for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) { + preg = snd_minors[minor]; + if (preg && preg->dev == dev) { + snd_minors[minor] = NULL; + device_del(dev); + kfree(preg); + break; + } } - - preg = snd_minors[minor]; - if (preg && !preg->created) - device_del(preg->dev); - else - device_destroy(sound_class, MKDEV(major, minor)); - - kfree(snd_minors[minor]); - snd_minors[minor] = NULL; mutex_unlock(&sound_mutex); + if (minor >= ARRAY_SIZE(snd_minors)) + return -ENOENT; return 0; } - EXPORT_SYMBOL(snd_unregister_device); /** diff --git a/sound/core/timer.c b/sound/core/timer.c index dae40ac11e04..9f0c703ef081 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1976,9 +1976,8 @@ static int __init alsa_timer_init(void) return err; } - err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, - &snd_timer_f_ops, NULL, - &timer_dev, NULL, NULL); + err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, + &snd_timer_f_ops, NULL, &timer_dev); if (err < 0) { pr_err("ALSA: unable to register timer device (%i)\n", err); snd_timer_free_all(); @@ -1992,7 +1991,7 @@ static int __init alsa_timer_init(void) static void __exit alsa_timer_exit(void) { - snd_unregister_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0); + snd_unregister_device(&timer_dev); snd_timer_free_all(); put_device(&timer_dev); snd_timer_proc_done(); -- cgit From 830953c0724b42be30a74febcde6c89c706ed286 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jan 2015 08:39:40 +0100 Subject: ALSA: Drop snd_get_device() helper Since the device is no longer hidden but embedded into each component, we no longer need snd_get_device(). Let's drop it and relevant codes. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/sound.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'sound') diff --git a/sound/core/sound.c b/sound/core/sound.c index 2e8aeb18d76b..185cec01ee25 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -303,24 +303,6 @@ int snd_register_device(int type, struct snd_card *card, int dev, } EXPORT_SYMBOL(snd_register_device); -/* find the matching minor record - * return the index of snd_minor, or -1 if not found - */ -static int find_snd_minor(int type, struct snd_card *card, int dev) -{ - int cardnum, minor; - struct snd_minor *mptr; - - cardnum = card ? card->number : -1; - for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) - if ((mptr = snd_minors[minor]) != NULL && - mptr->type == type && - mptr->card == cardnum && - mptr->device == dev) - return minor; - return -1; -} - /** * snd_unregister_device - unregister the device on the given card * @dev: the device instance @@ -352,31 +334,6 @@ int snd_unregister_device(struct device *dev) } EXPORT_SYMBOL(snd_unregister_device); -/** - * snd_get_device - get the assigned device to the given type and device number - * @type: the device type, SNDRV_DEVICE_TYPE_XXX - * @card:the card instance - * @dev: the device index - * - * The caller needs to release it via put_device() after using it. - */ -struct device *snd_get_device(int type, struct snd_card *card, int dev) -{ - int minor; - struct device *d = NULL; - - mutex_lock(&sound_mutex); - minor = find_snd_minor(type, card, dev); - if (minor >= 0) { - d = snd_minors[minor]->dev; - if (d) - get_device(d); - } - mutex_unlock(&sound_mutex); - return d; -} -EXPORT_SYMBOL(snd_get_device); - #ifdef CONFIG_PROC_FS /* * INFO PART -- cgit From 2f91ab86ec2500590c9dcfcc7f089d3255d72404 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 2 Feb 2015 14:49:41 +0200 Subject: ASoC: davinci-evm: Do not include edma headers The machine driver has no business with the underlying dma. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-evm.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 158cb3d1db70..d1a8b6e3ac3b 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -25,8 +24,6 @@ #include #include -#include - #include "davinci-pcm.h" #include "davinci-i2s.h" -- cgit From 67d35e5bc375b03ed3ad88b7dc4469ed5d3d69e9 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 2 Feb 2015 14:49:42 +0200 Subject: ASoC: davinci-evm: Do not include davinci-pcm.h and davinci-i2s.h There is no need for them to be included. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-evm.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index d1a8b6e3ac3b..b6bb5947a8a8 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -24,9 +24,6 @@ #include #include -#include "davinci-pcm.h" -#include "davinci-i2s.h" - struct snd_soc_card_drvdata_davinci { struct clk *mclk; unsigned sysclk; -- cgit From 8f511ffb6b82f6914779a47039cccf91e953aa1f Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 2 Feb 2015 14:38:32 +0200 Subject: ASoC: davicni-mcasp: Mark the common irq line as shared On DA830 devices McASP0,1 and 2 shares a single combined interrupt request line. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 95eef582331b..a5e4fe0359ce 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1461,7 +1461,8 @@ static int davinci_mcasp_probe(struct platform_device *pdev) dev_name(&pdev->dev)); ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, davinci_mcasp_common_irq_handler, - IRQF_ONESHOT, irq_name, mcasp); + IRQF_ONESHOT | IRQF_SHARED, + irq_name, mcasp); if (ret) { dev_err(&pdev->dev, "common IRQ request failed\n"); goto err; -- cgit From caa1d794cca96c16e4a2f81697f3d15a588c4b02 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 2 Feb 2015 14:38:33 +0200 Subject: ASoC: davinci-mcasp: Fix DIT only McASP instance support One of the McASP instances in DM646x line of DMSoC only supports DIT mode. This means that the given IP does not have support for rx and all the rx related resources are missing, like irq and DMA request. The driver should not fail if any or all of the RX resource is missing when the op_mode is set to DIT mode. Since RX is not possible in DIT mode, we can just ignore the rx resources when the McASP is used in DIT mode. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 72 +++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'sound') diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index a5e4fe0359ce..de3b155a5011 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1327,16 +1327,19 @@ static struct davinci_mcasp_pdata *davinci_mcasp_set_pdata_from_of( pdata->tx_dma_channel = dma_spec.args[0]; - ret = of_property_match_string(np, "dma-names", "rx"); - if (ret < 0) - goto nodata; + /* RX is not valid in DIT mode */ + if (pdata->op_mode != DAVINCI_MCASP_DIT_MODE) { + ret = of_property_match_string(np, "dma-names", "rx"); + if (ret < 0) + goto nodata; - ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret, - &dma_spec); - if (ret < 0) - goto nodata; + ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret, + &dma_spec); + if (ret < 0) + goto nodata; - pdata->rx_dma_channel = dma_spec.args[0]; + pdata->rx_dma_channel = dma_spec.args[0]; + } ret = of_property_read_u32(np, "tx-num-evt", &val); if (ret >= 0) @@ -1532,19 +1535,34 @@ static int davinci_mcasp_probe(struct platform_device *pdev) else dma_data->filter_data = &dma_params->channel; - dma_params = &mcasp->dma_params[SNDRV_PCM_STREAM_CAPTURE]; - dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE]; - dma_params->asp_chan_q = pdata->asp_chan_q; - dma_params->ram_chan_q = pdata->ram_chan_q; - dma_params->sram_pool = pdata->sram_pool; - dma_params->sram_size = pdata->sram_size_capture; - if (dat) - dma_params->dma_addr = dat->start; - else - dma_params->dma_addr = mem->start + pdata->rx_dma_offset; - - /* Unconditional dmaengine stuff */ - dma_data->addr = dma_params->dma_addr; + /* RX is not valid in DIT mode */ + if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) { + dma_params = &mcasp->dma_params[SNDRV_PCM_STREAM_CAPTURE]; + dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE]; + dma_params->asp_chan_q = pdata->asp_chan_q; + dma_params->ram_chan_q = pdata->ram_chan_q; + dma_params->sram_pool = pdata->sram_pool; + dma_params->sram_size = pdata->sram_size_capture; + if (dat) + dma_params->dma_addr = dat->start; + else + dma_params->dma_addr = mem->start + pdata->rx_dma_offset; + + /* Unconditional dmaengine stuff */ + dma_data->addr = dma_params->dma_addr; + + res = platform_get_resource(pdev, IORESOURCE_DMA, 1); + if (res) + dma_params->channel = res->start; + else + dma_params->channel = pdata->rx_dma_channel; + + /* dmaengine filter data for DT and non-DT boot */ + if (pdev->dev.of_node) + dma_data->filter_data = "rx"; + else + dma_data->filter_data = &dma_params->channel; + } if (mcasp->version < MCASP_VERSION_3) { mcasp->fifo_base = DAVINCI_MCASP_V2_AFIFO_BASE; @@ -1554,18 +1572,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev) mcasp->fifo_base = DAVINCI_MCASP_V3_AFIFO_BASE; } - res = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (res) - dma_params->channel = res->start; - else - dma_params->channel = pdata->rx_dma_channel; - - /* dmaengine filter data for DT and non-DT boot */ - if (pdev->dev.of_node) - dma_data->filter_data = "rx"; - else - dma_data->filter_data = &dma_params->channel; - dev_set_drvdata(&pdev->dev, mcasp); mcasp_reparent_fck(pdev); -- cgit From d1f83d6ef43bf1b4a3d19805098b3a9724047479 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 2 Feb 2015 04:53:53 +0000 Subject: ASoC: rsnd: call missing snd_ctl_remove() Current Renesas R-Car sound driver is using snd_ctl_xxx() functions, but it didn't call snd_ctl free_one() / snd_ctl_remove(). This patch call these functions. Reported-by: Nguyen Viet Dung Reported-by: Bui Duc Phuc Reported-by: Cao Minh Hiep Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 11 ++++++++++- sound/soc/sh/rcar/dvc.c | 15 +++++++++++++++ sound/soc/sh/rcar/rsnd.h | 5 +++++ 3 files changed, 30 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index f0bb137da31b..6fb38b879bb6 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1046,14 +1046,23 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod, return -ENOMEM; ret = snd_ctl_add(card, kctrl); - if (ret < 0) + if (ret < 0) { + snd_ctl_free_one(kctrl); return ret; + } cfg->update = update; + cfg->card = card; + cfg->kctrl = kctrl; return 0; } +void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg) +{ + snd_ctl_remove(cfg->card, cfg->kctrl); +} + int rsnd_kctrl_new_m(struct rsnd_mod *mod, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 38a5f334a6a7..d7f9ed959c4e 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -127,6 +127,20 @@ static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod, return 0; } +static int rsnd_dvc_remove_gen2(struct rsnd_mod *mod, + struct rsnd_priv *priv) +{ + struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); + + rsnd_kctrl_remove(dvc->volume); + rsnd_kctrl_remove(dvc->mute); + rsnd_kctrl_remove(dvc->ren); + rsnd_kctrl_remove(dvc->rup); + rsnd_kctrl_remove(dvc->rdown); + + return 0; +} + static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, struct rsnd_priv *priv) { @@ -258,6 +272,7 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, static struct rsnd_mod_ops rsnd_dvc_ops = { .name = DVC_NAME, .probe = rsnd_dvc_probe_gen2, + .remove = rsnd_dvc_remove_gen2, .init = rsnd_dvc_init, .quit = rsnd_dvc_quit, .start = rsnd_dvc_start, diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index b57d8ace012a..e7914bd610e2 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -436,6 +436,8 @@ struct rsnd_kctrl_cfg { u32 *val; const char * const *texts; void (*update)(struct rsnd_mod *mod); + struct snd_card *card; + struct snd_kcontrol *kctrl; }; #define RSND_DVC_CHANNELS 2 @@ -449,6 +451,9 @@ struct rsnd_kctrl_cfg_s { u32 val; }; +void _rsnd_kctrl_remove(struct rsnd_kctrl_cfg *cfg); +#define rsnd_kctrl_remove(_cfg) _rsnd_kctrl_remove(&((_cfg).cfg)) + int rsnd_kctrl_new_m(struct rsnd_mod *mod, struct snd_soc_pcm_runtime *rtd, const unsigned char *name, -- cgit From d7c42ff8c34f1c291fcd45c7d56d41aba68c4b13 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 2 Feb 2015 04:54:07 +0000 Subject: ASoC: rsnd: call missing snd_soc_unregiter_component/platform() Current Renesas R-Car sound driver doesn't call snd_soc_unregiter_component/platform() in .remove. This patch call these functions. Reported-by: Nguyen Viet Dung Reported-by: Bui Duc Phuc Reported-by: Cao Minh Hiep Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 6fb38b879bb6..1b53605f7154 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1299,6 +1299,9 @@ static int rsnd_remove(struct platform_device *pdev) ret |= rsnd_dai_call(remove, &rdai->capture, priv); } + snd_soc_unregister_component(&pdev->dev); + snd_soc_unregister_platform(&pdev->dev); + return ret; } -- cgit From 842aaa0cbf66621f00d641f5abfd2db40c61320b Mon Sep 17 00:00:00 2001 From: "Fang, Yang A" Date: Sat, 31 Jan 2015 15:22:40 -0800 Subject: ASoC: Intel: Add support rt5645 in sst driver Added entry in sst driver to support rt5645 codec for intel Braswell platform. Signed-off-by: Fang, Yang A Signed-off-by: Mark Brown --- sound/soc/intel/sst/sst_acpi.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/sst/sst_acpi.c b/sound/soc/intel/sst/sst_acpi.c index df2b5cc23766..21b22e6a1ccb 100644 --- a/sound/soc/intel/sst/sst_acpi.c +++ b/sound/soc/intel/sst/sst_acpi.c @@ -352,6 +352,8 @@ static struct sst_machines sst_acpi_bytcr[] = { static struct sst_machines sst_acpi_chv[] = { {"10EC5670", "cht-bsw", "cht-bsw-rt5672", NULL, "fw_sst_22a8.bin", &chv_platform_data }, + {"10EC5645", "cht-bsw", "cht-bsw-rt5645", NULL, "fw_sst_22a8.bin", + &chv_platform_data }, {}, }; -- cgit From d29697dc3b92cb12a80632a5ade4fa26fd98225e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jan 2015 20:16:37 +0100 Subject: ASoC: Add sysfs entries via static attribute groups Instead of calling device_create_file() manually, assign the static attribute group entries at the device registration. This simplifies the error handling and avoids the possible races. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 58 ++++++++++++++++++++++++++++++---------------------- sound/soc/soc-dapm.c | 14 ++++--------- 2 files changed, 38 insertions(+), 34 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 985052b3fbed..54925dc84a96 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -191,6 +191,39 @@ static ssize_t pmdown_time_set(struct device *dev, static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set); +static struct attribute *soc_dev_attrs[] = { + &dev_attr_codec_reg.attr, + &dev_attr_pmdown_time.attr, + NULL +}; + +static umode_t soc_dev_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int idx) +{ + struct device *dev = kobj_to_dev(kobj); + struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); + + if (attr == &dev_attr_pmdown_time.attr) + return attr->mode; /* always visible */ + return rtd->codec ? attr->mode : 0; /* enabled only with codec */ +} + +static const struct attribute_group soc_dapm_dev_group = { + .attrs = soc_dapm_dev_attrs, + .is_visible = soc_dev_attr_is_visible, +}; + +static const struct attribute_group soc_dev_roup = { + .attrs = soc_dev_attrs, + .is_visible = soc_dev_attr_is_visible, +}; + +static const struct attribute_group *soc_dev_attr_groups[] = { + &soc_dapm_dev_group, + &soc_dev_roup, + NULL +}; + #ifdef CONFIG_DEBUG_FS static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) @@ -949,8 +982,6 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) /* unregister the rtd device */ if (rtd->dev_registered) { - device_remove_file(rtd->dev, &dev_attr_pmdown_time); - device_remove_file(rtd->dev, &dev_attr_codec_reg); device_unregister(rtd->dev); rtd->dev_registered = 0; } @@ -1120,6 +1151,7 @@ static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd, device_initialize(rtd->dev); rtd->dev->parent = rtd->card->dev; rtd->dev->release = rtd_release; + rtd->dev->groups = soc_dev_attr_groups; dev_set_name(rtd->dev, "%s", name); dev_set_drvdata(rtd->dev, rtd); mutex_init(&rtd->pcm_mutex); @@ -1136,23 +1168,6 @@ static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd, return ret; } rtd->dev_registered = 1; - - if (rtd->codec) { - /* add DAPM sysfs entries for this codec */ - ret = snd_soc_dapm_sys_add(rtd->dev); - if (ret < 0) - dev_err(rtd->dev, - "ASoC: failed to add codec dapm sysfs entries: %d\n", - ret); - - /* add codec sysfs entries */ - ret = device_create_file(rtd->dev, &dev_attr_codec_reg); - if (ret < 0) - dev_err(rtd->dev, - "ASoC: failed to add codec sysfs files: %d\n", - ret); - } - return 0; } @@ -1308,11 +1323,6 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) } #endif - ret = device_create_file(rtd->dev, &dev_attr_pmdown_time); - if (ret < 0) - dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n", - ret); - if (cpu_dai->driver->compress_dai) { /*create compress_device"*/ ret = soc_new_compress(rtd, num); diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index c5136bb1f982..6c5cf7d1ff54 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2127,15 +2127,10 @@ static ssize_t dapm_widget_show(struct device *dev, static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); -int snd_soc_dapm_sys_add(struct device *dev) -{ - return device_create_file(dev, &dev_attr_dapm_widget); -} - -static void snd_soc_dapm_sys_remove(struct device *dev) -{ - device_remove_file(dev, &dev_attr_dapm_widget); -} +struct attribute *soc_dapm_dev_attrs[] = { + &dev_attr_dapm_widget.attr, + NULL +}; static void dapm_free_path(struct snd_soc_dapm_path *path) { @@ -3903,7 +3898,6 @@ void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card) */ void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm) { - snd_soc_dapm_sys_remove(dapm->dev); dapm_debugfs_cleanup(dapm); dapm_free_widgets(dapm); list_del(&dapm->list); -- cgit From 695758c6c4d67955f7d73bc9fd39288acfd4b222 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Tue, 3 Feb 2015 02:38:39 -0500 Subject: ALSA: line6: use msecs_to_jiffies for conversion This is only an API consolidation and should make things more readable it replaces var * HZ / 1000 by msecs_to_jiffies(var). Signed-off-by: Nicholas Mc Guire Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 2328ec9a1ca8..3cf12ccdd72e 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -166,7 +166,7 @@ void line6_start_timer(struct timer_list *timer, unsigned int msecs, void (*function)(unsigned long), unsigned long data) { setup_timer(timer, function, data); - mod_timer(timer, jiffies + msecs * HZ / 1000); + mod_timer(timer, jiffies + msecs_to_jiffies(msecs)); } EXPORT_SYMBOL_GPL(line6_start_timer); -- cgit From 6ccd93bdb989507717edb375d40534f1177822c5 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Tue, 3 Feb 2015 02:38:56 -0500 Subject: ALSA: line6: fixup of line6_start_timer argument type line6_start_timer passes an unsigned int as argument to be used in mod_timer which is then used by mod_timer as unsigned long, this just fixes up the argument type. This change helps make static code checkers happy. Signed-off-by: Nicholas Mc Guire Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 2 +- sound/usb/line6/driver.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 3cf12ccdd72e..e2a2603a1ca3 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -162,7 +162,7 @@ static int line6_send_raw_message_async_part(struct message *msg, /* Setup and start timer. */ -void line6_start_timer(struct timer_list *timer, unsigned int msecs, +void line6_start_timer(struct timer_list *timer, unsigned long msecs, void (*function)(unsigned long), unsigned long data) { setup_timer(timer, function, data); diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index fa877a345860..2276b78f3562 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -159,7 +159,7 @@ extern int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, int size); extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); -extern void line6_start_timer(struct timer_list *timer, unsigned int msecs, +extern void line6_start_timer(struct timer_list *timer, unsigned long msecs, void (*function)(unsigned long), unsigned long data); extern int line6_version_request_async(struct usb_line6 *line6); -- cgit From 9503112d909cbbc2865a28c2586c436254169da8 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Mon, 2 Feb 2015 16:48:05 +0200 Subject: ASoC: tlv320aic3x: Add support for tlv320aic3104 Disables GPIO support and LINE2 input and renames Mic3 input to Mic2, if tlv320aic3104 mode is seleced. Devicetree binding document is updated accordingly. Signed-off-by: Jyri Sarha Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic3x.c | 345 +++++++++++++++++++++++++++++------------ 1 file changed, 244 insertions(+), 101 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index b7ebce054b4e..cb92cdba0324 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -87,6 +87,7 @@ struct aic3x_priv { #define AIC3X_MODEL_3X 0 #define AIC3X_MODEL_33 1 #define AIC3X_MODEL_3007 2 +#define AIC3X_MODEL_3104 3 u16 model; /* Selects the micbias voltage */ @@ -316,52 +317,37 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { * only for swapped L-to-R and R-to-L routes. See below stereo controls * for direct L-to-L and R-to-R routes. */ - SOC_SINGLE_TLV("Left Line Mixer Line2R Bypass Volume", - LINE2R_2_LLOPM_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Left Line Mixer PGAR Bypass Volume", PGAR_2_LLOPM_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Left Line Mixer DACR1 Playback Volume", DACR1_2_LLOPM_VOL, 0, 118, 1, output_stage_tlv), - SOC_SINGLE_TLV("Right Line Mixer Line2L Bypass Volume", - LINE2L_2_RLOPM_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Right Line Mixer PGAL Bypass Volume", PGAL_2_RLOPM_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Right Line Mixer DACL1 Playback Volume", DACL1_2_RLOPM_VOL, 0, 118, 1, output_stage_tlv), - SOC_SINGLE_TLV("Left HP Mixer Line2R Bypass Volume", - LINE2R_2_HPLOUT_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Left HP Mixer PGAR Bypass Volume", PGAR_2_HPLOUT_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Left HP Mixer DACR1 Playback Volume", DACR1_2_HPLOUT_VOL, 0, 118, 1, output_stage_tlv), - SOC_SINGLE_TLV("Right HP Mixer Line2L Bypass Volume", - LINE2L_2_HPROUT_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Right HP Mixer PGAL Bypass Volume", PGAL_2_HPROUT_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Right HP Mixer DACL1 Playback Volume", DACL1_2_HPROUT_VOL, 0, 118, 1, output_stage_tlv), - SOC_SINGLE_TLV("Left HPCOM Mixer Line2R Bypass Volume", - LINE2R_2_HPLCOM_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Left HPCOM Mixer PGAR Bypass Volume", PGAR_2_HPLCOM_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Left HPCOM Mixer DACR1 Playback Volume", DACR1_2_HPLCOM_VOL, 0, 118, 1, output_stage_tlv), - SOC_SINGLE_TLV("Right HPCOM Mixer Line2L Bypass Volume", - LINE2L_2_HPRCOM_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Right HPCOM Mixer PGAL Bypass Volume", PGAL_2_HPRCOM_VOL, 0, 118, 1, output_stage_tlv), SOC_SINGLE_TLV("Right HPCOM Mixer DACL1 Playback Volume", DACL1_2_HPRCOM_VOL, 0, 118, 1, output_stage_tlv), /* Stereo output controls for direct L-to-L and R-to-R routes */ - SOC_DOUBLE_R_TLV("Line Line2 Bypass Volume", - LINE2L_2_LLOPM_VOL, LINE2R_2_RLOPM_VOL, - 0, 118, 1, output_stage_tlv), SOC_DOUBLE_R_TLV("Line PGA Bypass Volume", PGAL_2_LLOPM_VOL, PGAR_2_RLOPM_VOL, 0, 118, 1, output_stage_tlv), @@ -369,9 +355,6 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { DACL1_2_LLOPM_VOL, DACR1_2_RLOPM_VOL, 0, 118, 1, output_stage_tlv), - SOC_DOUBLE_R_TLV("HP Line2 Bypass Volume", - LINE2L_2_HPLOUT_VOL, LINE2R_2_HPROUT_VOL, - 0, 118, 1, output_stage_tlv), SOC_DOUBLE_R_TLV("HP PGA Bypass Volume", PGAL_2_HPLOUT_VOL, PGAR_2_HPROUT_VOL, 0, 118, 1, output_stage_tlv), @@ -379,9 +362,6 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { DACL1_2_HPLOUT_VOL, DACR1_2_HPROUT_VOL, 0, 118, 1, output_stage_tlv), - SOC_DOUBLE_R_TLV("HPCOM Line2 Bypass Volume", - LINE2L_2_HPLCOM_VOL, LINE2R_2_HPRCOM_VOL, - 0, 118, 1, output_stage_tlv), SOC_DOUBLE_R_TLV("HPCOM PGA Bypass Volume", PGAL_2_HPLCOM_VOL, PGAR_2_HPRCOM_VOL, 0, 118, 1, output_stage_tlv), @@ -424,6 +404,45 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { SOC_ENUM("Output Driver Ramp-up step", aic3x_rampup_step_enum), }; +/* For other than tlv320aic3104 */ +static const struct snd_kcontrol_new aic3x_extra_snd_controls[] = { + /* + * Output controls that map to output mixer switches. Note these are + * only for swapped L-to-R and R-to-L routes. See below stereo controls + * for direct L-to-L and R-to-R routes. + */ + SOC_SINGLE_TLV("Left Line Mixer Line2R Bypass Volume", + LINE2R_2_LLOPM_VOL, 0, 118, 1, output_stage_tlv), + + SOC_SINGLE_TLV("Right Line Mixer Line2L Bypass Volume", + LINE2L_2_RLOPM_VOL, 0, 118, 1, output_stage_tlv), + + SOC_SINGLE_TLV("Left HP Mixer Line2R Bypass Volume", + LINE2R_2_HPLOUT_VOL, 0, 118, 1, output_stage_tlv), + + SOC_SINGLE_TLV("Right HP Mixer Line2L Bypass Volume", + LINE2L_2_HPROUT_VOL, 0, 118, 1, output_stage_tlv), + + SOC_SINGLE_TLV("Left HPCOM Mixer Line2R Bypass Volume", + LINE2R_2_HPLCOM_VOL, 0, 118, 1, output_stage_tlv), + + SOC_SINGLE_TLV("Right HPCOM Mixer Line2L Bypass Volume", + LINE2L_2_HPRCOM_VOL, 0, 118, 1, output_stage_tlv), + + /* Stereo output controls for direct L-to-L and R-to-R routes */ + SOC_DOUBLE_R_TLV("Line Line2 Bypass Volume", + LINE2L_2_LLOPM_VOL, LINE2R_2_RLOPM_VOL, + 0, 118, 1, output_stage_tlv), + + SOC_DOUBLE_R_TLV("HP Line2 Bypass Volume", + LINE2L_2_HPLOUT_VOL, LINE2R_2_HPROUT_VOL, + 0, 118, 1, output_stage_tlv), + + SOC_DOUBLE_R_TLV("HPCOM Line2 Bypass Volume", + LINE2L_2_HPLCOM_VOL, LINE2R_2_HPRCOM_VOL, + 0, 118, 1, output_stage_tlv), +}; + static const struct snd_kcontrol_new aic3x_mono_controls[] = { SOC_DOUBLE_R_TLV("Mono Line2 Bypass Volume", LINE2L_2_MONOLOPM_VOL, LINE2R_2_MONOLOPM_VOL, @@ -464,22 +483,24 @@ SOC_DAPM_ENUM("Route", aic3x_right_hpcom_enum); /* Left Line Mixer */ static const struct snd_kcontrol_new aic3x_left_line_mixer_controls[] = { - SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_LLOPM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAL Bypass Switch", PGAL_2_LLOPM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACL1 Switch", DACL1_2_LLOPM_VOL, 7, 1, 0), - SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_LLOPM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAR Bypass Switch", PGAR_2_LLOPM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACR1 Switch", DACR1_2_LLOPM_VOL, 7, 1, 0), + /* Not on tlv320aic3104 */ + SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_LLOPM_VOL, 7, 1, 0), + SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_LLOPM_VOL, 7, 1, 0), }; /* Right Line Mixer */ static const struct snd_kcontrol_new aic3x_right_line_mixer_controls[] = { - SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_RLOPM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAL Bypass Switch", PGAL_2_RLOPM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACL1 Switch", DACL1_2_RLOPM_VOL, 7, 1, 0), - SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_RLOPM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAR Bypass Switch", PGAR_2_RLOPM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACR1 Switch", DACR1_2_RLOPM_VOL, 7, 1, 0), + /* Not on tlv320aic3104 */ + SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_RLOPM_VOL, 7, 1, 0), + SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_RLOPM_VOL, 7, 1, 0), }; /* Mono Mixer */ @@ -494,42 +515,46 @@ static const struct snd_kcontrol_new aic3x_mono_mixer_controls[] = { /* Left HP Mixer */ static const struct snd_kcontrol_new aic3x_left_hp_mixer_controls[] = { - SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_HPLOUT_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAL Bypass Switch", PGAL_2_HPLOUT_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACL1 Switch", DACL1_2_HPLOUT_VOL, 7, 1, 0), - SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_HPLOUT_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAR Bypass Switch", PGAR_2_HPLOUT_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACR1 Switch", DACR1_2_HPLOUT_VOL, 7, 1, 0), + /* Not on tlv320aic3104 */ + SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_HPLOUT_VOL, 7, 1, 0), + SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_HPLOUT_VOL, 7, 1, 0), }; /* Right HP Mixer */ static const struct snd_kcontrol_new aic3x_right_hp_mixer_controls[] = { - SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_HPROUT_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAL Bypass Switch", PGAL_2_HPROUT_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACL1 Switch", DACL1_2_HPROUT_VOL, 7, 1, 0), - SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_HPROUT_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAR Bypass Switch", PGAR_2_HPROUT_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACR1 Switch", DACR1_2_HPROUT_VOL, 7, 1, 0), + /* Not on tlv320aic3104 */ + SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_HPROUT_VOL, 7, 1, 0), + SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_HPROUT_VOL, 7, 1, 0), }; /* Left HPCOM Mixer */ static const struct snd_kcontrol_new aic3x_left_hpcom_mixer_controls[] = { - SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_HPLCOM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAL Bypass Switch", PGAL_2_HPLCOM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACL1 Switch", DACL1_2_HPLCOM_VOL, 7, 1, 0), - SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_HPLCOM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAR Bypass Switch", PGAR_2_HPLCOM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACR1 Switch", DACR1_2_HPLCOM_VOL, 7, 1, 0), + /* Not on tlv320aic3104 */ + SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_HPLCOM_VOL, 7, 1, 0), + SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_HPLCOM_VOL, 7, 1, 0), }; /* Right HPCOM Mixer */ static const struct snd_kcontrol_new aic3x_right_hpcom_mixer_controls[] = { - SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_HPRCOM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAL Bypass Switch", PGAL_2_HPRCOM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACL1 Switch", DACL1_2_HPRCOM_VOL, 7, 1, 0), - SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_HPRCOM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("PGAR Bypass Switch", PGAR_2_HPRCOM_VOL, 7, 1, 0), SOC_DAPM_SINGLE("DACR1 Switch", DACR1_2_HPRCOM_VOL, 7, 1, 0), + /* Not on tlv320aic3104 */ + SOC_DAPM_SINGLE("Line2L Bypass Switch", LINE2L_2_HPRCOM_VOL, 7, 1, 0), + SOC_DAPM_SINGLE("Line2R Bypass Switch", LINE2R_2_HPRCOM_VOL, 7, 1, 0), }; /* Left PGA Mixer */ @@ -550,6 +575,22 @@ static const struct snd_kcontrol_new aic3x_right_pga_mixer_controls[] = { SOC_DAPM_SINGLE_AIC3X("Mic3R Switch", MIC3LR_2_RADC_CTRL, 0, 1, 1), }; +/* Left PGA Mixer for tlv320aic3104 */ +static const struct snd_kcontrol_new aic3104_left_pga_mixer_controls[] = { + SOC_DAPM_SINGLE_AIC3X("Line1L Switch", LINE1L_2_LADC_CTRL, 3, 1, 1), + SOC_DAPM_SINGLE_AIC3X("Line1R Switch", LINE1R_2_LADC_CTRL, 3, 1, 1), + SOC_DAPM_SINGLE_AIC3X("Mic2L Switch", MIC3LR_2_LADC_CTRL, 4, 1, 1), + SOC_DAPM_SINGLE_AIC3X("Mic2R Switch", MIC3LR_2_LADC_CTRL, 0, 1, 1), +}; + +/* Right PGA Mixer for tlv320aic3104 */ +static const struct snd_kcontrol_new aic3104_right_pga_mixer_controls[] = { + SOC_DAPM_SINGLE_AIC3X("Line1R Switch", LINE1R_2_RADC_CTRL, 3, 1, 1), + SOC_DAPM_SINGLE_AIC3X("Line1L Switch", LINE1L_2_RADC_CTRL, 3, 1, 1), + SOC_DAPM_SINGLE_AIC3X("Mic2L Switch", MIC3LR_2_RADC_CTRL, 4, 1, 1), + SOC_DAPM_SINGLE_AIC3X("Mic2R Switch", MIC3LR_2_RADC_CTRL, 0, 1, 1), +}; + /* Left Line1 Mux */ static const struct snd_kcontrol_new aic3x_left_line1l_mux_controls = SOC_DAPM_ENUM("Route", aic3x_line1l_2_l_enum); @@ -593,26 +634,56 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { /* Inputs to Left ADC */ SND_SOC_DAPM_ADC("Left ADC", "Left Capture", LINE1L_2_LADC_CTRL, 2, 0), - SND_SOC_DAPM_MIXER("Left PGA Mixer", SND_SOC_NOPM, 0, 0, - &aic3x_left_pga_mixer_controls[0], - ARRAY_SIZE(aic3x_left_pga_mixer_controls)), SND_SOC_DAPM_MUX("Left Line1L Mux", SND_SOC_NOPM, 0, 0, &aic3x_left_line1l_mux_controls), SND_SOC_DAPM_MUX("Left Line1R Mux", SND_SOC_NOPM, 0, 0, &aic3x_left_line1r_mux_controls), - SND_SOC_DAPM_MUX("Left Line2L Mux", SND_SOC_NOPM, 0, 0, - &aic3x_left_line2_mux_controls), /* Inputs to Right ADC */ SND_SOC_DAPM_ADC("Right ADC", "Right Capture", LINE1R_2_RADC_CTRL, 2, 0), - SND_SOC_DAPM_MIXER("Right PGA Mixer", SND_SOC_NOPM, 0, 0, - &aic3x_right_pga_mixer_controls[0], - ARRAY_SIZE(aic3x_right_pga_mixer_controls)), SND_SOC_DAPM_MUX("Right Line1L Mux", SND_SOC_NOPM, 0, 0, &aic3x_right_line1l_mux_controls), SND_SOC_DAPM_MUX("Right Line1R Mux", SND_SOC_NOPM, 0, 0, &aic3x_right_line1r_mux_controls), + + /* Mic Bias */ + SND_SOC_DAPM_SUPPLY("Mic Bias", MICBIAS_CTRL, 6, 0, + mic_bias_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + + SND_SOC_DAPM_OUTPUT("LLOUT"), + SND_SOC_DAPM_OUTPUT("RLOUT"), + SND_SOC_DAPM_OUTPUT("HPLOUT"), + SND_SOC_DAPM_OUTPUT("HPROUT"), + SND_SOC_DAPM_OUTPUT("HPLCOM"), + SND_SOC_DAPM_OUTPUT("HPRCOM"), + + SND_SOC_DAPM_INPUT("LINE1L"), + SND_SOC_DAPM_INPUT("LINE1R"), + + /* + * Virtual output pin to detection block inside codec. This can be + * used to keep codec bias on if gpio or detection features are needed. + * Force pin on or construct a path with an input jack and mic bias + * widgets. + */ + SND_SOC_DAPM_OUTPUT("Detection"), +}; + +/* For other than tlv320aic3104 */ +static const struct snd_soc_dapm_widget aic3x_extra_dapm_widgets[] = { + /* Inputs to Left ADC */ + SND_SOC_DAPM_MIXER("Left PGA Mixer", SND_SOC_NOPM, 0, 0, + &aic3x_left_pga_mixer_controls[0], + ARRAY_SIZE(aic3x_left_pga_mixer_controls)), + SND_SOC_DAPM_MUX("Left Line2L Mux", SND_SOC_NOPM, 0, 0, + &aic3x_left_line2_mux_controls), + + /* Inputs to Right ADC */ + SND_SOC_DAPM_MIXER("Right PGA Mixer", SND_SOC_NOPM, 0, 0, + &aic3x_right_pga_mixer_controls[0], + ARRAY_SIZE(aic3x_right_pga_mixer_controls)), SND_SOC_DAPM_MUX("Right Line2R Mux", SND_SOC_NOPM, 0, 0, &aic3x_right_line2_mux_controls), @@ -637,11 +708,6 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { SND_SOC_DAPM_REG(snd_soc_dapm_micbias, "DMic Rate 32", AIC3X_ASD_INTF_CTRLA, 0, 3, 3, 0), - /* Mic Bias */ - SND_SOC_DAPM_SUPPLY("Mic Bias", MICBIAS_CTRL, 6, 0, - mic_bias_event, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), - /* Output mixers */ SND_SOC_DAPM_MIXER("Left Line Mixer", SND_SOC_NOPM, 0, 0, &aic3x_left_line_mixer_controls[0], @@ -662,27 +728,46 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { &aic3x_right_hpcom_mixer_controls[0], ARRAY_SIZE(aic3x_right_hpcom_mixer_controls)), - SND_SOC_DAPM_OUTPUT("LLOUT"), - SND_SOC_DAPM_OUTPUT("RLOUT"), - SND_SOC_DAPM_OUTPUT("HPLOUT"), - SND_SOC_DAPM_OUTPUT("HPROUT"), - SND_SOC_DAPM_OUTPUT("HPLCOM"), - SND_SOC_DAPM_OUTPUT("HPRCOM"), - SND_SOC_DAPM_INPUT("MIC3L"), SND_SOC_DAPM_INPUT("MIC3R"), - SND_SOC_DAPM_INPUT("LINE1L"), - SND_SOC_DAPM_INPUT("LINE1R"), SND_SOC_DAPM_INPUT("LINE2L"), SND_SOC_DAPM_INPUT("LINE2R"), +}; - /* - * Virtual output pin to detection block inside codec. This can be - * used to keep codec bias on if gpio or detection features are needed. - * Force pin on or construct a path with an input jack and mic bias - * widgets. - */ - SND_SOC_DAPM_OUTPUT("Detection"), +/* For tlv320aic3104 */ +static const struct snd_soc_dapm_widget aic3104_extra_dapm_widgets[] = { + /* Inputs to Left ADC */ + SND_SOC_DAPM_MIXER("Left PGA Mixer", SND_SOC_NOPM, 0, 0, + &aic3104_left_pga_mixer_controls[0], + ARRAY_SIZE(aic3104_left_pga_mixer_controls)), + + /* Inputs to Right ADC */ + SND_SOC_DAPM_MIXER("Right PGA Mixer", SND_SOC_NOPM, 0, 0, + &aic3104_right_pga_mixer_controls[0], + ARRAY_SIZE(aic3104_right_pga_mixer_controls)), + + /* Output mixers */ + SND_SOC_DAPM_MIXER("Left Line Mixer", SND_SOC_NOPM, 0, 0, + &aic3x_left_line_mixer_controls[0], + ARRAY_SIZE(aic3x_left_line_mixer_controls) - 2), + SND_SOC_DAPM_MIXER("Right Line Mixer", SND_SOC_NOPM, 0, 0, + &aic3x_right_line_mixer_controls[0], + ARRAY_SIZE(aic3x_right_line_mixer_controls) - 2), + SND_SOC_DAPM_MIXER("Left HP Mixer", SND_SOC_NOPM, 0, 0, + &aic3x_left_hp_mixer_controls[0], + ARRAY_SIZE(aic3x_left_hp_mixer_controls) - 2), + SND_SOC_DAPM_MIXER("Right HP Mixer", SND_SOC_NOPM, 0, 0, + &aic3x_right_hp_mixer_controls[0], + ARRAY_SIZE(aic3x_right_hp_mixer_controls) - 2), + SND_SOC_DAPM_MIXER("Left HPCOM Mixer", SND_SOC_NOPM, 0, 0, + &aic3x_left_hpcom_mixer_controls[0], + ARRAY_SIZE(aic3x_left_hpcom_mixer_controls) - 2), + SND_SOC_DAPM_MIXER("Right HPCOM Mixer", SND_SOC_NOPM, 0, 0, + &aic3x_right_hpcom_mixer_controls[0], + ARRAY_SIZE(aic3x_right_hpcom_mixer_controls) - 2), + + SND_SOC_DAPM_INPUT("MIC2L"), + SND_SOC_DAPM_INPUT("MIC2R"), }; static const struct snd_soc_dapm_widget aic3x_dapm_mono_widgets[] = { @@ -712,17 +797,10 @@ static const struct snd_soc_dapm_route intercon[] = { {"Left Line1R Mux", "single-ended", "LINE1R"}, {"Left Line1R Mux", "differential", "LINE1R"}, - {"Left Line2L Mux", "single-ended", "LINE2L"}, - {"Left Line2L Mux", "differential", "LINE2L"}, - {"Left PGA Mixer", "Line1L Switch", "Left Line1L Mux"}, {"Left PGA Mixer", "Line1R Switch", "Left Line1R Mux"}, - {"Left PGA Mixer", "Line2L Switch", "Left Line2L Mux"}, - {"Left PGA Mixer", "Mic3L Switch", "MIC3L"}, - {"Left PGA Mixer", "Mic3R Switch", "MIC3R"}, {"Left ADC", NULL, "Left PGA Mixer"}, - {"Left ADC", NULL, "GPIO1 dmic modclk"}, /* Right Input */ {"Right Line1R Mux", "single-ended", "LINE1R"}, @@ -730,25 +808,10 @@ static const struct snd_soc_dapm_route intercon[] = { {"Right Line1L Mux", "single-ended", "LINE1L"}, {"Right Line1L Mux", "differential", "LINE1L"}, - {"Right Line2R Mux", "single-ended", "LINE2R"}, - {"Right Line2R Mux", "differential", "LINE2R"}, - {"Right PGA Mixer", "Line1L Switch", "Right Line1L Mux"}, {"Right PGA Mixer", "Line1R Switch", "Right Line1R Mux"}, - {"Right PGA Mixer", "Line2R Switch", "Right Line2R Mux"}, - {"Right PGA Mixer", "Mic3L Switch", "MIC3L"}, - {"Right PGA Mixer", "Mic3R Switch", "MIC3R"}, {"Right ADC", NULL, "Right PGA Mixer"}, - {"Right ADC", NULL, "GPIO1 dmic modclk"}, - - /* - * Logical path between digital mic enable and GPIO1 modulator clock - * output function - */ - {"GPIO1 dmic modclk", NULL, "DMic Rate 128"}, - {"GPIO1 dmic modclk", NULL, "DMic Rate 64"}, - {"GPIO1 dmic modclk", NULL, "DMic Rate 32"}, /* Left DAC Output */ {"Left DAC Mux", "DAC_L1", "Left DAC"}, @@ -761,10 +824,8 @@ static const struct snd_soc_dapm_route intercon[] = { {"Right DAC Mux", "DAC_R3", "Right DAC"}, /* Left Line Output */ - {"Left Line Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, {"Left Line Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, {"Left Line Mixer", "DACL1 Switch", "Left DAC Mux"}, - {"Left Line Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, {"Left Line Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, {"Left Line Mixer", "DACR1 Switch", "Right DAC Mux"}, @@ -773,10 +834,8 @@ static const struct snd_soc_dapm_route intercon[] = { {"LLOUT", NULL, "Left Line Out"}, /* Right Line Output */ - {"Right Line Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, {"Right Line Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, {"Right Line Mixer", "DACL1 Switch", "Left DAC Mux"}, - {"Right Line Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, {"Right Line Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, {"Right Line Mixer", "DACR1 Switch", "Right DAC Mux"}, @@ -785,10 +844,8 @@ static const struct snd_soc_dapm_route intercon[] = { {"RLOUT", NULL, "Right Line Out"}, /* Left HP Output */ - {"Left HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, {"Left HP Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, {"Left HP Mixer", "DACL1 Switch", "Left DAC Mux"}, - {"Left HP Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, {"Left HP Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, {"Left HP Mixer", "DACR1 Switch", "Right DAC Mux"}, @@ -797,10 +854,8 @@ static const struct snd_soc_dapm_route intercon[] = { {"HPLOUT", NULL, "Left HP Out"}, /* Right HP Output */ - {"Right HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, {"Right HP Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, {"Right HP Mixer", "DACL1 Switch", "Left DAC Mux"}, - {"Right HP Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, {"Right HP Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, {"Right HP Mixer", "DACR1 Switch", "Right DAC Mux"}, @@ -809,10 +864,8 @@ static const struct snd_soc_dapm_route intercon[] = { {"HPROUT", NULL, "Right HP Out"}, /* Left HPCOM Output */ - {"Left HPCOM Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, {"Left HPCOM Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, {"Left HPCOM Mixer", "DACL1 Switch", "Left DAC Mux"}, - {"Left HPCOM Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, {"Left HPCOM Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, {"Left HPCOM Mixer", "DACR1 Switch", "Right DAC Mux"}, @@ -823,10 +876,8 @@ static const struct snd_soc_dapm_route intercon[] = { {"HPLCOM", NULL, "Left HP Com"}, /* Right HPCOM Output */ - {"Right HPCOM Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, {"Right HPCOM Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, {"Right HPCOM Mixer", "DACL1 Switch", "Left DAC Mux"}, - {"Right HPCOM Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, {"Right HPCOM Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, {"Right HPCOM Mixer", "DACR1 Switch", "Right DAC Mux"}, @@ -839,6 +890,72 @@ static const struct snd_soc_dapm_route intercon[] = { {"HPRCOM", NULL, "Right HP Com"}, }; +/* For other than tlv320aic3104 */ +static const struct snd_soc_dapm_route intercon_extra[] = { + /* Left Input */ + {"Left Line2L Mux", "single-ended", "LINE2L"}, + {"Left Line2L Mux", "differential", "LINE2L"}, + + {"Left PGA Mixer", "Line2L Switch", "Left Line2L Mux"}, + {"Left PGA Mixer", "Mic3L Switch", "MIC3L"}, + {"Left PGA Mixer", "Mic3R Switch", "MIC3R"}, + + {"Left ADC", NULL, "GPIO1 dmic modclk"}, + + /* Right Input */ + {"Right Line2R Mux", "single-ended", "LINE2R"}, + {"Right Line2R Mux", "differential", "LINE2R"}, + + {"Right PGA Mixer", "Line2R Switch", "Right Line2R Mux"}, + {"Right PGA Mixer", "Mic3L Switch", "MIC3L"}, + {"Right PGA Mixer", "Mic3R Switch", "MIC3R"}, + + {"Right ADC", NULL, "GPIO1 dmic modclk"}, + + /* + * Logical path between digital mic enable and GPIO1 modulator clock + * output function + */ + {"GPIO1 dmic modclk", NULL, "DMic Rate 128"}, + {"GPIO1 dmic modclk", NULL, "DMic Rate 64"}, + {"GPIO1 dmic modclk", NULL, "DMic Rate 32"}, + + /* Left Line Output */ + {"Left Line Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, + {"Left Line Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, + + /* Right Line Output */ + {"Right Line Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, + {"Right Line Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, + + /* Left HP Output */ + {"Left HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, + {"Left HP Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, + + /* Right HP Output */ + {"Right HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, + {"Right HP Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, + + /* Left HPCOM Output */ + {"Left HPCOM Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, + {"Left HPCOM Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, + + /* Right HPCOM Output */ + {"Right HPCOM Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, + {"Right HPCOM Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, +}; + +/* For other than tlv320aic3104 */ +static const struct snd_soc_dapm_route intercon_extra_3104[] = { + /* Left Input */ + {"Left PGA Mixer", "Mic2L Switch", "MIC2L"}, + {"Left PGA Mixer", "Mic2R Switch", "MIC2R"}, + + /* Right Input */ + {"Right PGA Mixer", "Mic2L Switch", "MIC2L"}, + {"Right PGA Mixer", "Mic2R Switch", "MIC2R"}, +}; + static const struct snd_soc_dapm_route intercon_mono[] = { /* Mono Output */ {"Mono Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, @@ -867,17 +984,31 @@ static int aic3x_add_widgets(struct snd_soc_codec *codec) switch (aic3x->model) { case AIC3X_MODEL_3X: case AIC3X_MODEL_33: + snd_soc_dapm_new_controls(dapm, aic3x_extra_dapm_widgets, + ARRAY_SIZE(aic3x_extra_dapm_widgets)); + snd_soc_dapm_add_routes(dapm, intercon_extra, + ARRAY_SIZE(intercon_extra)); snd_soc_dapm_new_controls(dapm, aic3x_dapm_mono_widgets, ARRAY_SIZE(aic3x_dapm_mono_widgets)); snd_soc_dapm_add_routes(dapm, intercon_mono, ARRAY_SIZE(intercon_mono)); break; case AIC3X_MODEL_3007: + snd_soc_dapm_new_controls(dapm, aic3x_extra_dapm_widgets, + ARRAY_SIZE(aic3x_extra_dapm_widgets)); + snd_soc_dapm_add_routes(dapm, intercon_extra, + ARRAY_SIZE(intercon_extra)); snd_soc_dapm_new_controls(dapm, aic3007_dapm_widgets, ARRAY_SIZE(aic3007_dapm_widgets)); snd_soc_dapm_add_routes(dapm, intercon_3007, ARRAY_SIZE(intercon_3007)); break; + case AIC3X_MODEL_3104: + snd_soc_dapm_new_controls(dapm, aic3104_extra_dapm_widgets, + ARRAY_SIZE(aic3104_extra_dapm_widgets)); + snd_soc_dapm_add_routes(dapm, intercon_extra_3104, + ARRAY_SIZE(intercon_extra_3104)); + break; } return 0; @@ -1438,23 +1569,33 @@ static int aic3x_probe(struct snd_soc_codec *codec) aic3x_init(codec); if (aic3x->setup) { - /* setup GPIO functions */ - snd_soc_write(codec, AIC3X_GPIO1_REG, - (aic3x->setup->gpio_func[0] & 0xf) << 4); - snd_soc_write(codec, AIC3X_GPIO2_REG, - (aic3x->setup->gpio_func[1] & 0xf) << 4); + if (aic3x->model != AIC3X_MODEL_3104) { + /* setup GPIO functions */ + snd_soc_write(codec, AIC3X_GPIO1_REG, + (aic3x->setup->gpio_func[0] & 0xf) << 4); + snd_soc_write(codec, AIC3X_GPIO2_REG, + (aic3x->setup->gpio_func[1] & 0xf) << 4); + } else { + dev_warn(codec->dev, "GPIO functionality is not supported on tlv320aic3104\n"); + } } switch (aic3x->model) { case AIC3X_MODEL_3X: case AIC3X_MODEL_33: + snd_soc_add_codec_controls(codec, aic3x_extra_snd_controls, + ARRAY_SIZE(aic3x_extra_snd_controls)); snd_soc_add_codec_controls(codec, aic3x_mono_controls, ARRAY_SIZE(aic3x_mono_controls)); break; case AIC3X_MODEL_3007: + snd_soc_add_codec_controls(codec, aic3x_extra_snd_controls, + ARRAY_SIZE(aic3x_extra_snd_controls)); snd_soc_add_codec_controls(codec, &aic3x_classd_amp_gain_ctrl, 1); break; + case AIC3X_MODEL_3104: + break; } /* set mic bias voltage */ @@ -1522,6 +1663,7 @@ static const struct i2c_device_id aic3x_i2c_id[] = { { "tlv320aic33", AIC3X_MODEL_33 }, { "tlv320aic3007", AIC3X_MODEL_3007 }, { "tlv320aic3106", AIC3X_MODEL_3X }, + { "tlv320aic3104", AIC3X_MODEL_3104 }, { } }; MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id); @@ -1673,6 +1815,7 @@ static const struct of_device_id tlv320aic3x_of_match[] = { { .compatible = "ti,tlv320aic33" }, { .compatible = "ti,tlv320aic3007" }, { .compatible = "ti,tlv320aic3106" }, + { .compatible = "ti,tlv320aic3104" }, {}, }; MODULE_DEVICE_TABLE(of, tlv320aic3x_of_match); -- cgit From b8255930e0fbda841890ff6bb7154aa5fd62e143 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Wed, 4 Feb 2015 12:15:46 +0200 Subject: ASoC: tlv320aic3x: Fix bad comment before intercon_extra_3104 definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The intercon_extra_3104 is obviously for tlv320aic3104. Reported-by: Benoît Thébaudeau Signed-off-by: Jyri Sarha Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic3x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index cb92cdba0324..ed35e8f1f04c 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -945,7 +945,7 @@ static const struct snd_soc_dapm_route intercon_extra[] = { {"Right HPCOM Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, }; -/* For other than tlv320aic3104 */ +/* For tlv320aic3104 */ static const struct snd_soc_dapm_route intercon_extra_3104[] = { /* Left Input */ {"Left PGA Mixer", "Mic2L Switch", "MIC2L"}, -- cgit From c41cda1dbe50816d839c32271007c7b832d4d14a Mon Sep 17 00:00:00 2001 From: Jie Yang Date: Wed, 4 Feb 2015 20:23:13 +0800 Subject: ASoC: Intel: initial scalar variable ba Reported by Coverity: CID 1267985 CID 1267986 Fix these two Defects: Uninitialized scalar variable. Signed-off-by: Jie Yang Signed-off-by: Mark Brown --- sound/soc/intel/sst-firmware.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c index cad6ea179cea..dcc145f81ec9 100644 --- a/sound/soc/intel/sst-firmware.c +++ b/sound/soc/intel/sst-firmware.c @@ -786,6 +786,7 @@ int sst_module_alloc_blocks(struct sst_module *module) struct sst_block_allocator ba; int ret; + memset(&ba, 0, sizeof(ba)); ba.size = module->size; ba.type = module->type; ba.offset = module->offset; @@ -859,6 +860,7 @@ int sst_module_runtime_alloc_blocks(struct sst_module_runtime *runtime, if (module->persistent_size == 0) return 0; + memset(&ba, 0, sizeof(ba)); ba.size = module->persistent_size; ba.type = SST_MEM_DRAM; -- cgit From e7a0332f716d92b9a80c46fbd7d624c502984ca7 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Wed, 4 Feb 2015 17:29:30 +0000 Subject: ASoC: ts3a227e: fix sparse warning this patch fixes following sparse warning: ts3a227e.c:222:5: warning: symbol 'ts3a227e_enable_jack_detect' was not declared. Should it be static? Signed-off-by: Lad, Prabhakar Signed-off-by: Mark Brown --- sound/soc/codecs/ts3a227e.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index 1d1205702d23..6528bfe5c2ff 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -20,6 +20,8 @@ #include #include +#include "ts3a227e.h" + struct ts3a227e { struct regmap *regmap; struct snd_soc_jack *jack; -- cgit From 26b0aad80a86d39b8c3a3189fbaf477ef92a64ff Mon Sep 17 00:00:00 2001 From: Zubair Lutfullah Kakakhel Date: Tue, 3 Feb 2015 10:55:57 +0000 Subject: ASoC: jz4740: Add dynamic sampling rate support to jz4740-i2s The div clock register is not modified during jz4740_i2s_hw_params. Hence, default sampling rates are actually used regardless of sampling rates input from userspace. This patch adds support to calculate the value of the divider from the parameters passed from userspace and update the relevant div registers Signed-off-by: Zubair Lutfullah Kakakhel Acked-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/jz4740/jz4740-i2s.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index d3d45c6f064f..b7a7e8295d3c 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -83,6 +83,8 @@ #define JZ_AIC_I2S_STATUS_BUSY BIT(2) #define JZ_AIC_CLK_DIV_MASK 0xf +#define I2SDIV_DV_SHIFT 8 +#define I2SDIV_DV_MASK (0xf << I2SDIV_DV_SHIFT) struct jz4740_i2s { struct resource *mem; @@ -237,10 +239,14 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); unsigned int sample_size; - uint32_t ctrl; + uint32_t ctrl, div_reg; + int div; ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL); + div_reg = jz4740_i2s_read(i2s, JZ_REG_AIC_CLK_DIV); + div = clk_get_rate(i2s->clk_i2s) / (64 * params_rate(params)); + switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: sample_size = 0; @@ -264,7 +270,10 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; } + div_reg &= ~I2SDIV_DV_MASK; + div_reg |= (div - 1) << I2SDIV_DV_SHIFT; jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); + jz4740_i2s_write(i2s, JZ_REG_AIC_CLK_DIV, div_reg); return 0; } -- cgit From f2610571fd82417f44825f3b705fd651e3788ceb Mon Sep 17 00:00:00 2001 From: Zubair Lutfullah Kakakhel Date: Tue, 3 Feb 2015 10:55:59 +0000 Subject: ASoC: jz4740: Add DT support to jz4740-i2s driver This patch adds device tree support for the jz4740 driver. Signed-off-by: Zubair Lutfullah Kakakhel Acked-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/jz4740/jz4740-i2s.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sound') diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index b7a7e8295d3c..07f77815a586 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -14,6 +14,8 @@ #include #include +#include +#include #include #include #include @@ -424,6 +426,13 @@ static const struct snd_soc_component_driver jz4740_i2s_component = { .name = "jz4740-i2s", }; +#ifdef CONFIG_OF +static const struct of_device_id jz4740_of_matches[] = { + { .compatible = "ingenic,jz4740-i2s" }, + { /* sentinel */ } +}; +#endif + static int jz4740_i2s_dev_probe(struct platform_device *pdev) { struct jz4740_i2s *i2s; @@ -464,6 +473,7 @@ static struct platform_driver jz4740_i2s_driver = { .probe = jz4740_i2s_dev_probe, .driver = { .name = "jz4740-i2s", + .of_match_table = of_match_ptr(jz4740_of_matches) }, }; -- cgit From cd311dd123f5ae5c6da71bdfa9a379a694eb9917 Mon Sep 17 00:00:00 2001 From: Jie Yang Date: Thu, 5 Feb 2015 22:56:48 +0800 Subject: ASoC: Intel: add a status for runtime suspend/resume For runtime suspend/resume, it is some different with suspend/resume, e.g. codec power supply won't be switch off, codec jack detection still working(to wake up system from Jack event), won't call call snd_soc_suspend/resume, etc. So here, we add a platform PM status, HSW_PM_STATE_RTD3, to make the status more clear, when in idle, it will enter this status, to transfer from HSW_PM_STATE_RTD3 to HSW_PM_STATE_D3, we will do those extra jobs, and vice versa for resuming. Signed-off-by: Jie Yang Signed-off-by: Mark Brown --- sound/soc/intel/sst-haswell-pcm.c | 70 ++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index ad7f4a51e138..78fa01be57f2 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c @@ -119,8 +119,9 @@ struct hsw_pcm_data { }; enum hsw_pm_state { - HSW_PM_STATE_D3 = 0, - HSW_PM_STATE_D0 = 1, + HSW_PM_STATE_D0 = 0, + HSW_PM_STATE_RTD3 = 1, + HSW_PM_STATE_D3 = 2, }; /* private data for the driver */ @@ -1035,12 +1036,12 @@ static int hsw_pcm_runtime_suspend(struct device *dev) struct hsw_priv_data *pdata = dev_get_drvdata(dev); struct sst_hsw *hsw = pdata->hsw; - if (pdata->pm_state == HSW_PM_STATE_D3) + if (pdata->pm_state >= HSW_PM_STATE_RTD3) return 0; sst_hsw_dsp_runtime_suspend(hsw); sst_hsw_dsp_runtime_sleep(hsw); - pdata->pm_state = HSW_PM_STATE_D3; + pdata->pm_state = HSW_PM_STATE_RTD3; return 0; } @@ -1051,7 +1052,7 @@ static int hsw_pcm_runtime_resume(struct device *dev) struct sst_hsw *hsw = pdata->hsw; int ret; - if (pdata->pm_state == HSW_PM_STATE_D0) + if (pdata->pm_state != HSW_PM_STATE_RTD3) return 0; ret = sst_hsw_dsp_load(hsw); @@ -1091,7 +1092,7 @@ static void hsw_pcm_complete(struct device *dev) struct hsw_pcm_data *pcm_data; int i, err; - if (pdata->pm_state == HSW_PM_STATE_D0) + if (pdata->pm_state != HSW_PM_STATE_D3) return; err = sst_hsw_dsp_load(hsw); @@ -1139,41 +1140,42 @@ static int hsw_pcm_prepare(struct device *dev) if (pdata->pm_state == HSW_PM_STATE_D3) return 0; - /* suspend all active streams */ - for (i = 0; i < ARRAY_SIZE(mod_map); i++) { - pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; + else if (pdata->pm_state == HSW_PM_STATE_D0) { + /* suspend all active streams */ + for (i = 0; i < ARRAY_SIZE(mod_map); i++) { + pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; + + if (!pcm_data->substream) + continue; + dev_dbg(dev, "suspending pcm %d\n", i); + snd_pcm_suspend_all(pcm_data->hsw_pcm); + + /* We need to wait until the DSP FW stops the streams */ + msleep(2); + } - if (!pcm_data->substream) - continue; - dev_dbg(dev, "suspending pcm %d\n", i); - snd_pcm_suspend_all(pcm_data->hsw_pcm); + /* preserve persistent memory */ + for (i = 0; i < ARRAY_SIZE(mod_map); i++) { + pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; + + if (!pcm_data->substream) + continue; - /* We need to wait until the DSP FW stops the streams */ - msleep(2); + dev_dbg(dev, "saving context pcm %d\n", i); + err = sst_module_runtime_save(pcm_data->runtime, + &pcm_data->context); + if (err < 0) + dev_err(dev, "failed to save context for PCM %d\n", i); + } + /* enter D3 state and stall */ + sst_hsw_dsp_runtime_suspend(hsw); + /* put the DSP to sleep */ + sst_hsw_dsp_runtime_sleep(hsw); } snd_soc_suspend(pdata->soc_card->dev); snd_soc_poweroff(pdata->soc_card->dev); - /* enter D3 state and stall */ - sst_hsw_dsp_runtime_suspend(hsw); - - /* preserve persistent memory */ - for (i = 0; i < ARRAY_SIZE(mod_map); i++) { - pcm_data = &pdata->pcm[mod_map[i].dai_id][mod_map[i].stream]; - - if (!pcm_data->substream) - continue; - - dev_dbg(dev, "saving context pcm %d\n", i); - err = sst_module_runtime_save(pcm_data->runtime, - &pcm_data->context); - if (err < 0) - dev_err(dev, "failed to save context for PCM %d\n", i); - } - - /* put the DSP to sleep */ - sst_hsw_dsp_runtime_sleep(hsw); pdata->pm_state = HSW_PM_STATE_D3; return 0; -- cgit From 79080a8b42a08fb68a1ea2e036e54a4749edbd43 Mon Sep 17 00:00:00 2001 From: "Fang, Yang A" Date: Wed, 4 Feb 2015 18:19:31 -0800 Subject: ASoC: rt5645: add API to select ASRC clock source This patch defines an API to select the clock source for specified filters. Signed-off-by: Fang, Yang A Acked-by: Kevin Strasser Signed-off-by: Mark Brown --- sound/soc/codecs/rt5645.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt5645.h | 72 ++++++++++++++++++----------------------- 2 files changed, 112 insertions(+), 41 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 21b2d72b4ea8..debf16c5b549 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -613,6 +613,87 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, } +/** + * rt5645_sel_asrc_clk_src - select ASRC clock source for a set of filters + * @codec: SoC audio codec device. + * @filter_mask: mask of filters. + * @clk_src: clock source + * + * The ASRC function is for asynchronous MCLK and LRCK. Also, since RT5645 can + * only support standard 32fs or 64fs i2s format, ASRC should be enabled to + * support special i2s clock format such as Intel's 100fs(100 * sampling rate). + * ASRC function will track i2s clock and generate a corresponding system clock + * for codec. This function provides an API to select the clock source for a + * set of filters specified by the mask. And the codec driver will turn on ASRC + * for these filters if ASRC is selected as their clock source. + */ +int rt5645_sel_asrc_clk_src(struct snd_soc_codec *codec, + unsigned int filter_mask, unsigned int clk_src) +{ + unsigned int asrc2_mask = 0; + unsigned int asrc2_value = 0; + unsigned int asrc3_mask = 0; + unsigned int asrc3_value = 0; + + switch (clk_src) { + case RT5645_CLK_SEL_SYS: + case RT5645_CLK_SEL_I2S1_ASRC: + case RT5645_CLK_SEL_I2S2_ASRC: + case RT5645_CLK_SEL_SYS2: + break; + + default: + return -EINVAL; + } + + if (filter_mask & RT5645_DA_STEREO_FILTER) { + asrc2_mask |= RT5645_DA_STO_CLK_SEL_MASK; + asrc2_value = (asrc2_value & ~RT5645_DA_STO_CLK_SEL_MASK) + | (clk_src << RT5645_DA_STO_CLK_SEL_SFT); + } + + if (filter_mask & RT5645_DA_MONO_L_FILTER) { + asrc2_mask |= RT5645_DA_MONOL_CLK_SEL_MASK; + asrc2_value = (asrc2_value & ~RT5645_DA_MONOL_CLK_SEL_MASK) + | (clk_src << RT5645_DA_MONOL_CLK_SEL_SFT); + } + + if (filter_mask & RT5645_DA_MONO_R_FILTER) { + asrc2_mask |= RT5645_DA_MONOR_CLK_SEL_MASK; + asrc2_value = (asrc2_value & ~RT5645_DA_MONOR_CLK_SEL_MASK) + | (clk_src << RT5645_DA_MONOR_CLK_SEL_SFT); + } + + if (filter_mask & RT5645_AD_STEREO_FILTER) { + asrc2_mask |= RT5645_AD_STO1_CLK_SEL_MASK; + asrc2_value = (asrc2_value & ~RT5645_AD_STO1_CLK_SEL_MASK) + | (clk_src << RT5645_AD_STO1_CLK_SEL_SFT); + } + + if (filter_mask & RT5645_AD_MONO_L_FILTER) { + asrc3_mask |= RT5645_AD_MONOL_CLK_SEL_MASK; + asrc3_value = (asrc3_value & ~RT5645_AD_MONOL_CLK_SEL_MASK) + | (clk_src << RT5645_AD_MONOL_CLK_SEL_SFT); + } + + if (filter_mask & RT5645_AD_MONO_R_FILTER) { + asrc3_mask |= RT5645_AD_MONOR_CLK_SEL_MASK; + asrc3_value = (asrc3_value & ~RT5645_AD_MONOR_CLK_SEL_MASK) + | (clk_src << RT5645_AD_MONOR_CLK_SEL_SFT); + } + + if (asrc2_mask) + snd_soc_update_bits(codec, RT5645_ASRC_2, + asrc2_mask, asrc2_value); + + if (asrc3_mask) + snd_soc_update_bits(codec, RT5645_ASRC_3, + asrc3_mask, asrc3_value); + + return 0; +} +EXPORT_SYMBOL_GPL(rt5645_sel_asrc_clk_src); + /* Digital Mixer */ static const struct snd_kcontrol_new rt5645_sto1_adc_l_mix[] = { SOC_DAPM_SINGLE("ADC1 Switch", RT5645_STO1_ADC_MIXER, diff --git a/sound/soc/codecs/rt5645.h b/sound/soc/codecs/rt5645.h index 74542310d3f0..dbfd98c22f4d 100644 --- a/sound/soc/codecs/rt5645.h +++ b/sound/soc/codecs/rt5645.h @@ -1120,50 +1120,27 @@ #define RT5645_DMIC_2_M_NOR (0x0 << 8) #define RT5645_DMIC_2_M_ASYN (0x1 << 8) +/* ASRC clock source selection (0x84, 0x85) */ +#define RT5645_CLK_SEL_SYS (0x0) +#define RT5645_CLK_SEL_I2S1_ASRC (0x1) +#define RT5645_CLK_SEL_I2S2_ASRC (0x2) +#define RT5645_CLK_SEL_SYS2 (0x5) + /* ASRC Control 2 (0x84) */ -#define RT5645_MDA_L_M_MASK (0x1 << 15) -#define RT5645_MDA_L_M_SFT 15 -#define RT5645_MDA_L_M_NOR (0x0 << 15) -#define RT5645_MDA_L_M_ASYN (0x1 << 15) -#define RT5645_MDA_R_M_MASK (0x1 << 14) -#define RT5645_MDA_R_M_SFT 14 -#define RT5645_MDA_R_M_NOR (0x0 << 14) -#define RT5645_MDA_R_M_ASYN (0x1 << 14) -#define RT5645_MAD_L_M_MASK (0x1 << 13) -#define RT5645_MAD_L_M_SFT 13 -#define RT5645_MAD_L_M_NOR (0x0 << 13) -#define RT5645_MAD_L_M_ASYN (0x1 << 13) -#define RT5645_MAD_R_M_MASK (0x1 << 12) -#define RT5645_MAD_R_M_SFT 12 -#define RT5645_MAD_R_M_NOR (0x0 << 12) -#define RT5645_MAD_R_M_ASYN (0x1 << 12) -#define RT5645_ADC_M_MASK (0x1 << 11) -#define RT5645_ADC_M_SFT 11 -#define RT5645_ADC_M_NOR (0x0 << 11) -#define RT5645_ADC_M_ASYN (0x1 << 11) -#define RT5645_STO_DAC_M_MASK (0x1 << 5) -#define RT5645_STO_DAC_M_SFT 5 -#define RT5645_STO_DAC_M_NOR (0x0 << 5) -#define RT5645_STO_DAC_M_ASYN (0x1 << 5) -#define RT5645_I2S1_R_D_MASK (0x1 << 4) -#define RT5645_I2S1_R_D_SFT 4 -#define RT5645_I2S1_R_D_DIS (0x0 << 4) -#define RT5645_I2S1_R_D_EN (0x1 << 4) -#define RT5645_I2S2_R_D_MASK (0x1 << 3) -#define RT5645_I2S2_R_D_SFT 3 -#define RT5645_I2S2_R_D_DIS (0x0 << 3) -#define RT5645_I2S2_R_D_EN (0x1 << 3) -#define RT5645_PRE_SCLK_MASK (0x3) -#define RT5645_PRE_SCLK_SFT 0 -#define RT5645_PRE_SCLK_512 (0x0) -#define RT5645_PRE_SCLK_1024 (0x1) -#define RT5645_PRE_SCLK_2048 (0x2) +#define RT5645_DA_STO_CLK_SEL_MASK (0xf << 12) +#define RT5645_DA_STO_CLK_SEL_SFT 12 +#define RT5645_DA_MONOL_CLK_SEL_MASK (0xf << 8) +#define RT5645_DA_MONOL_CLK_SEL_SFT 8 +#define RT5645_DA_MONOR_CLK_SEL_MASK (0xf << 4) +#define RT5645_DA_MONOR_CLK_SEL_SFT 4 +#define RT5645_AD_STO1_CLK_SEL_MASK (0xf << 0) +#define RT5645_AD_STO1_CLK_SEL_SFT 0 /* ASRC Control 3 (0x85) */ -#define RT5645_I2S1_RATE_MASK (0xf << 12) -#define RT5645_I2S1_RATE_SFT 12 -#define RT5645_I2S2_RATE_MASK (0xf << 8) -#define RT5645_I2S2_RATE_SFT 8 +#define RT5645_AD_MONOL_CLK_SEL_MASK (0xf << 4) +#define RT5645_AD_MONOL_CLK_SEL_SFT 4 +#define RT5645_AD_MONOR_CLK_SEL_MASK (0xf << 0) +#define RT5645_AD_MONOR_CLK_SEL_SFT 0 /* ASRC Control 4 (0x89) */ #define RT5645_I2S1_PD_MASK (0x7 << 12) @@ -2189,6 +2166,19 @@ enum { CODEC_TYPE_RT5650, }; +/* filter mask */ +enum { + RT5645_DA_STEREO_FILTER = 0x1, + RT5645_DA_MONO_L_FILTER = (0x1 << 1), + RT5645_DA_MONO_R_FILTER = (0x1 << 2), + RT5645_AD_STEREO_FILTER = (0x1 << 3), + RT5645_AD_MONO_L_FILTER = (0x1 << 4), + RT5645_AD_MONO_R_FILTER = (0x1 << 5), +}; + +int rt5645_sel_asrc_clk_src(struct snd_soc_codec *codec, + unsigned int filter_mask, unsigned int clk_src); + struct rt5645_priv { struct snd_soc_codec *codec; struct rt5645_platform_data pdata; -- cgit From e18acdc04ab2c4125ed4020db7f49a8dc35d1979 Mon Sep 17 00:00:00 2001 From: "Fang, Yang A" Date: Wed, 4 Feb 2015 18:19:32 -0800 Subject: ASoC: Intel: Add Cherrytrail & Braswell machine driver cht_bsw_rt5645 Add machine driver for two Intel Cherryview-based platforms, Cherrytrail and Braswell, with RT5645 codec Signed-off-by: Fang, Yang A Acked-by: Vinod Koul Acked-by: Kevin Strasser Signed-off-by: Mark Brown --- sound/soc/intel/Kconfig | 11 ++ sound/soc/intel/Makefile | 2 + sound/soc/intel/cht_bsw_rt5645.c | 327 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 340 insertions(+) create mode 100644 sound/soc/intel/cht_bsw_rt5645.c (limited to 'sound') diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig index f06fcf1e21a5..12093fdfd678 100644 --- a/sound/soc/intel/Kconfig +++ b/sound/soc/intel/Kconfig @@ -110,3 +110,14 @@ config SND_SOC_INTEL_CHT_BSW_RT5672_MACH platforms with RT5672 audio codec. Say Y if you have such a device If unsure select "N". + +config SND_SOC_INTEL_CHT_BSW_RT5645_MACH + tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5645 codec" + depends on X86_INTEL_LPSS + select SND_SOC_RT5645 + select SND_SST_MFLD_PLATFORM + select SND_SST_IPC_ACPI + help + This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell + platforms with RT5645 audio codec. + If unsure select "N". diff --git a/sound/soc/intel/Makefile b/sound/soc/intel/Makefile index e928ec385300..a8e53c45c6b6 100644 --- a/sound/soc/intel/Makefile +++ b/sound/soc/intel/Makefile @@ -28,6 +28,7 @@ snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o snd-soc-sst-broadwell-objs := broadwell.o snd-soc-sst-bytcr-dpcm-rt5640-objs := bytcr_dpcm_rt5640.o snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o +snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o @@ -35,6 +36,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-dpcm-rt5640.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o +obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o # DSP driver obj-$(CONFIG_SND_SST_IPC) += sst/ diff --git a/sound/soc/intel/cht_bsw_rt5645.c b/sound/soc/intel/cht_bsw_rt5645.c new file mode 100644 index 000000000000..b6f8377b6e33 --- /dev/null +++ b/sound/soc/intel/cht_bsw_rt5645.c @@ -0,0 +1,327 @@ +/* + * cht-bsw-rt5645.c - ASoc Machine driver for Intel Cherryview-based platforms + * Cherrytrail and Braswell, with RT5645 codec. + * + * Copyright (C) 2015 Intel Corp + * Author: Fang, Yang A + * N,Harshapriya + * This file is modified from cht_bsw_rt5672.c + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#include +#include +#include +#include +#include +#include +#include +#include "../codecs/rt5645.h" +#include "sst-atom-controls.h" + +#define CHT_PLAT_CLK_3_HZ 19200000 +#define CHT_CODEC_DAI "rt5645-aif1" + +struct cht_mc_private { + struct snd_soc_jack hp_jack; + struct snd_soc_jack mic_jack; +}; + +static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card) +{ + int i; + + for (i = 0; i < card->num_rtd; i++) { + struct snd_soc_pcm_runtime *rtd; + + rtd = card->rtd + i; + if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI, + strlen(CHT_CODEC_DAI))) + return rtd->codec_dai; + } + return NULL; +} + +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; + + codec_dai = cht_get_codec_dai(card); + if (!codec_dai) { + dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); + return -EIO; + } + + if (!SND_SOC_DAPM_EVENT_OFF(event)) + return 0; + + /* Set codec sysclk source to its internal clock because codec PLL will + * be off when idle and MCLK will also be off by ACPI when codec is + * runtime suspended. Codec needs clock for jack detection and button + * press. + */ + ret = snd_soc_dai_set_sysclk(codec_dai, RT5645_SCLK_S_RCCLK, + 0, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(card->dev, "can't set codec sysclk: %d\n", ret); + return ret; + } + + return 0; +} + +static const struct snd_soc_dapm_widget cht_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), + SND_SOC_DAPM_SPK("Ext Spk", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_POST_PMD), +}; + +static const struct snd_soc_dapm_route cht_audio_map[] = { + {"IN1P", NULL, "Headset Mic"}, + {"IN1N", NULL, "Headset Mic"}, + {"DMIC L1", NULL, "Int Mic"}, + {"DMIC R1", NULL, "Int Mic"}, + {"Headphone", NULL, "HPOL"}, + {"Headphone", NULL, "HPOR"}, + {"Ext Spk", NULL, "SPOL"}, + {"Ext Spk", NULL, "SPOR"}, + {"AIF1 Playback", NULL, "ssp2 Tx"}, + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx" }, + {"codec_in1", NULL, "ssp2 Rx" }, + {"ssp2 Rx", NULL, "AIF1 Capture"}, + {"Headphone", NULL, "Platform Clock"}, + {"Headset Mic", NULL, "Platform Clock"}, + {"Int Mic", NULL, "Platform Clock"}, + {"Ext Spk", NULL, "Platform Clock"}, +}; + +static const struct snd_kcontrol_new cht_mc_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Int Mic"), + SOC_DAPM_PIN_SWITCH("Ext Spk"), +}; + +static int cht_aif1_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; + + /* set codec PLL source to the 19.2MHz platform clock (MCLK) */ + ret = snd_soc_dai_set_pll(codec_dai, 0, RT5645_PLL1_S_MCLK, + CHT_PLAT_CLK_3_HZ, params_rate(params) * 512); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec pll: %d\n", ret); + return ret; + } + + ret = snd_soc_dai_set_sysclk(codec_dai, RT5645_SCLK_S_PLL1, + params_rate(params) * 512, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); + return ret; + } + + return 0; +} + +static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) +{ + int ret; + struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_dai *codec_dai = runtime->codec_dai; + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); + + /* Select clk_i2s1_asrc as ASRC clock source */ + rt5645_sel_asrc_clk_src(codec, + RT5645_DA_STEREO_FILTER | + RT5645_DA_MONO_L_FILTER | + RT5645_DA_MONO_R_FILTER | + RT5645_AD_STEREO_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(runtime->dev, "can't set codec TDM slot %d\n", ret); + return ret; + } + + ret = snd_soc_jack_new(codec, "Headphone Jack", + SND_JACK_HEADPHONE, + &ctx->hp_jack); + if (ret) { + dev_err(runtime->dev, "HP jack creation failed %d\n", ret); + return ret; + } + + ret = snd_soc_jack_new(codec, "Mic Jack", + SND_JACK_MICROPHONE, + &ctx->mic_jack); + if (ret) { + dev_err(runtime->dev, "Mic jack creation failed %d\n", ret); + return ret; + } + + rt5645_set_jack_detect(codec, &ctx->hp_jack, &ctx->mic_jack); + + return ret; +} + +static int cht_codec_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 DSP will covert the FE rate to 48k, stereo, 24bits */ + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + + /* set SSP2 to 24-bit */ + snd_mask_set(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - + SNDRV_PCM_HW_PARAM_FIRST_MASK], + SNDRV_PCM_FORMAT_S24_LE); + return 0; +} + +static unsigned int rates_48000[] = { + 48000, +}; + +static struct snd_pcm_hw_constraint_list constraints_48000 = { + .count = ARRAY_SIZE(rates_48000), + .list = rates_48000, +}; + +static int cht_aif1_startup(struct snd_pcm_substream *substream) +{ + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &constraints_48000); +} + +static struct snd_soc_ops cht_aif1_ops = { + .startup = cht_aif1_startup, +}; + +static struct snd_soc_ops cht_be_ssp2_ops = { + .hw_params = cht_aif1_hw_params, +}; + +static struct snd_soc_dai_link cht_dailink[] = { + [MERR_DPCM_AUDIO] = { + .name = "Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "media-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + .ignore_suspend = 1, + .dynamic = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &cht_aif1_ops, + }, + [MERR_DPCM_COMPR] = { + .name = "Compressed Port", + .stream_name = "Compress", + .cpu_dai_name = "compress-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + }, + /* CODEC<->CODEC link */ + /* back ends */ + { + .name = "SSP2-Codec", + .be_id = 1, + .cpu_dai_name = "ssp2-port", + .platform_name = "sst-mfld-platform", + .no_pcm = 1, + .codec_dai_name = "rt5645-aif1", + .codec_name = "i2c-10EC5645:00", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF + | SND_SOC_DAIFMT_CBS_CFS, + .init = cht_codec_init, + .be_hw_params_fixup = cht_codec_fixup, + .ignore_suspend = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &cht_be_ssp2_ops, + }, +}; + +/* SoC card */ +static struct snd_soc_card snd_soc_card_cht = { + .name = "chtrt5645", + .dai_link = cht_dailink, + .num_links = ARRAY_SIZE(cht_dailink), + .dapm_widgets = cht_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cht_dapm_widgets), + .dapm_routes = cht_audio_map, + .num_dapm_routes = ARRAY_SIZE(cht_audio_map), + .controls = cht_mc_controls, + .num_controls = ARRAY_SIZE(cht_mc_controls), +}; + +static int snd_cht_mc_probe(struct platform_device *pdev) +{ + int ret_val = 0; + struct cht_mc_private *drv; + + drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC); + if (!drv) + return -ENOMEM; + + snd_soc_card_cht.dev = &pdev->dev; + snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); + ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); + if (ret_val) { + dev_err(&pdev->dev, + "snd_soc_register_card failed %d\n", ret_val); + return ret_val; + } + platform_set_drvdata(pdev, &snd_soc_card_cht); + return ret_val; +} + +static struct platform_driver snd_cht_mc_driver = { + .driver = { + .owner = THIS_MODULE, + .name = "cht-bsw-rt5645", + .pm = &snd_soc_pm_ops, + }, + .probe = snd_cht_mc_probe, +}; + +module_platform_driver(snd_cht_mc_driver) + +MODULE_DESCRIPTION("ASoC Intel(R) Braswell Machine driver"); +MODULE_AUTHOR("Fang, Yang A,N,Harshapriya"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:cht-bsw-rt5645"); -- cgit From e948262ad01fc683d893abe10d1161231b2a6457 Mon Sep 17 00:00:00 2001 From: Kevin Strasser Date: Wed, 4 Feb 2015 11:35:07 -0800 Subject: ASoC: Intel: fix sst firmware path All sst firmware is provided under the intel directory of the linux-firmware tree. By default this directory structure is kept when installing on a target system. Change the path to expect a default linux-firmware installation. Signed-off-by: Kevin Strasser Signed-off-by: Mark Brown --- sound/soc/intel/sst/sst_acpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst/sst_acpi.c b/sound/soc/intel/sst/sst_acpi.c index 21b22e6a1ccb..378ef3c3042c 100644 --- a/sound/soc/intel/sst/sst_acpi.c +++ b/sound/soc/intel/sst/sst_acpi.c @@ -343,16 +343,16 @@ static int sst_acpi_remove(struct platform_device *pdev) } static struct sst_machines sst_acpi_bytcr[] = { - {"10EC5640", "T100", "bytt100_rt5640", NULL, "fw_sst_0f28.bin", + {"10EC5640", "T100", "bytt100_rt5640", NULL, "intel/fw_sst_0f28.bin", &byt_rvp_platform_data }, {}, }; /* Cherryview-based platforms: CherryTrail and Braswell */ static struct sst_machines sst_acpi_chv[] = { - {"10EC5670", "cht-bsw", "cht-bsw-rt5672", NULL, "fw_sst_22a8.bin", + {"10EC5670", "cht-bsw", "cht-bsw-rt5672", NULL, "intel/fw_sst_22a8.bin", &chv_platform_data }, - {"10EC5645", "cht-bsw", "cht-bsw-rt5645", NULL, "fw_sst_22a8.bin", + {"10EC5645", "cht-bsw", "cht-bsw-rt5645", NULL, "intel/fw_sst_22a8.bin", &chv_platform_data }, {}, }; -- cgit From 28d1ad09c50c758d3e295fa7ff90a4712e1254ea Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 5 Feb 2015 16:40:33 +0800 Subject: ASoC: rt286: Fix potencial crash in jd function We assign rt286->codec in rt286_probe. If rt286_jack_detect is invoked before rt286_probe, rt286->codec will be NULL and cause a kernel panic. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt286.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index 847cc4b9bee5..f14d335b07b1 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -305,6 +305,8 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic) *hp = false; *mic = false; + if (!rt286->codec) + return -EINVAL; if (rt286->pdata.cbj_en) { regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); *hp = buf & 0x80000000; -- cgit From 2cc3f2347022969f00a429951ce489d35a9b4ea8 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 5 Feb 2015 16:40:34 +0800 Subject: ASoC: rt286: Add customize setting for Dell Dino The patch add the customize setting for Dell Dino project. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt286.c | 25 ++++++++++++++++++++++++- sound/soc/codecs/rt286.h | 7 +++++++ 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index 847cc4b9bee5..1fbebaf6dbf4 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -1188,6 +1188,17 @@ static struct dmi_system_id force_combo_jack_table[] = { { } }; +static struct dmi_system_id dmi_dell_dino[] = { + { + .ident = "Dell Dino", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_BOARD_NAME, "0144P8") + } + }, + { } +}; + static int rt286_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -1223,7 +1234,8 @@ static int rt286_i2c_probe(struct i2c_client *i2c, if (pdata) rt286->pdata = *pdata; - if (dmi_check_system(force_combo_jack_table)) + if (dmi_check_system(force_combo_jack_table) || + dmi_check_system(dmi_dell_dino)) rt286->pdata.cbj_en = true; regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3); @@ -1262,6 +1274,17 @@ static int rt286_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL3, 0xf777, 0x4737); regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL4, 0x00ff, 0x003f); + if (dmi_check_system(dmi_dell_dino)) { + regmap_update_bits(rt286->regmap, + RT286_SET_GPIO_MASK, 0x40, 0x40); + regmap_update_bits(rt286->regmap, + RT286_SET_GPIO_DIRECTION, 0x40, 0x40); + regmap_update_bits(rt286->regmap, + RT286_SET_GPIO_DATA, 0x40, 0x40); + regmap_update_bits(rt286->regmap, + RT286_GPIO_CTRL, 0xc, 0x8); + } + if (rt286->i2c->irq) { ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286); diff --git a/sound/soc/codecs/rt286.h b/sound/soc/codecs/rt286.h index b539b7320a79..7130edb152ef 100644 --- a/sound/soc/codecs/rt286.h +++ b/sound/soc/codecs/rt286.h @@ -117,6 +117,12 @@ VERB_CMD(AC_VERB_SET_COEF_INDEX, RT286_VENDOR_REGISTERS, 0) #define RT286_PROC_COEF\ VERB_CMD(AC_VERB_SET_PROC_COEF, RT286_VENDOR_REGISTERS, 0) +#define RT286_SET_GPIO_MASK\ + VERB_CMD(AC_VERB_SET_GPIO_MASK, RT286_AUDIO_FUNCTION_GROUP, 0) +#define RT286_SET_GPIO_DIRECTION\ + VERB_CMD(AC_VERB_SET_GPIO_DIRECTION, RT286_AUDIO_FUNCTION_GROUP, 0) +#define RT286_SET_GPIO_DATA\ + VERB_CMD(AC_VERB_SET_GPIO_DATA, RT286_AUDIO_FUNCTION_GROUP, 0) /* Index registers */ #define RT286_A_BIAS_CTRL1 0x01 @@ -131,6 +137,7 @@ #define RT286_POWER_CTRL3 0x0f #define RT286_MIC1_DET_CTRL 0x19 #define RT286_MISC_CTRL1 0x20 +#define RT286_GPIO_CTRL 0x29 #define RT286_IRQ_CTRL 0x33 #define RT286_PLL_CTRL1 0x49 #define RT286_CBJ_CTRL1 0x4f -- cgit From 4227de2a7e5f0ff6a58e919a9c4f2bb06e882f48 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 5 Feb 2015 12:23:33 +0100 Subject: ALSA: hda - Set up GPIO for Toshiba Satellite S50D Toshiba Satellite S50D laptop with an IDT codec uses the GPIO4 (0x10) as the master EAPD. Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=915858 Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 605d14003d25..6d36c5b78805 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -99,6 +99,7 @@ enum { STAC_HP_ENVY_BASS, STAC_HP_BNB13_EQ, STAC_HP_ENVY_TS_BASS, + STAC_92HD83XXX_GPIO10_EAPD, STAC_92HD83XXX_MODELS }; @@ -2141,6 +2142,19 @@ static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec, spec->headset_jack = 1; } +static void stac92hd83xxx_fixup_gpio10_eapd(struct hda_codec *codec, + const struct hda_fixup *fix, + int action) +{ + struct sigmatel_spec *spec = codec->spec; + + if (action != HDA_FIXUP_ACT_PRE_PROBE) + return; + spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = + spec->gpio_data = 0x10; + spec->eapd_switch = 0; +} + static const struct hda_verb hp_bnb13_eq_verbs[] = { /* 44.1KHz base */ { 0x22, 0x7A6, 0x3E }, @@ -2656,6 +2670,10 @@ static const struct hda_fixup stac92hd83xxx_fixups[] = { {} }, }, + [STAC_92HD83XXX_GPIO10_EAPD] = { + .type = HDA_FIXUP_FUNC, + .v.func = stac92hd83xxx_fixup_gpio10_eapd, + }, }; static const struct hda_model_fixup stac92hd83xxx_models[] = { @@ -2861,6 +2879,8 @@ static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = { SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x148a, "HP Mini", STAC_92HD83XXX_HP_LED), SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP), + SND_PCI_QUIRK(PCI_VENDOR_ID_TOSHIBA, 0xfa91, + "Toshiba Satellite S50D", STAC_92HD83XXX_GPIO10_EAPD), {} /* terminator */ }; -- cgit From 6bbc7fed849597ec35ffdcaf677910dd11d71d08 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jan 2015 12:27:43 +0100 Subject: ALSA: Add a helper to add a new attribute group to card For assigning sysfs entries for a card device from the driver, introduce a new helper function, snd_card_add_dev_attr(). In this way, we can avoid the possible race between the device registration and the sysfs addition / removal. The driver can pass a new attribute group to add freely. This has to be called before snd_card_register(). Currently, up to two extra groups can be added. More than that, it'll return an error. Signed-off-by: Takashi Iwai --- sound/core/init.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/core/init.c b/sound/core/init.c index 96194599e82e..35419054821c 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -181,7 +181,7 @@ void snd_device_initialize(struct device *dev, struct snd_card *card) EXPORT_SYMBOL_GPL(snd_device_initialize); static int snd_card_do_free(struct snd_card *card); -static const struct attribute_group *card_dev_attr_groups[]; +static const struct attribute_group card_dev_attr_group; static void release_card_device(struct device *dev) { @@ -269,7 +269,8 @@ int snd_card_new(struct device *parent, int idx, const char *xid, card->card_dev.parent = parent; card->card_dev.class = sound_class; card->card_dev.release = release_card_device; - card->card_dev.groups = card_dev_attr_groups; + card->card_dev.groups = card->dev_groups; + card->dev_groups[0] = &card_dev_attr_group; err = kobject_set_name(&card->card_dev.kobj, "card%d", idx); if (err < 0) goto __error; @@ -700,14 +701,32 @@ static struct attribute *card_dev_attrs[] = { NULL }; -static struct attribute_group card_dev_attr_group = { +static const struct attribute_group card_dev_attr_group = { .attrs = card_dev_attrs, }; -static const struct attribute_group *card_dev_attr_groups[] = { - &card_dev_attr_group, - NULL +/** + * snd_card_add_dev_attr - Append a new sysfs attribute group to card + * @card: card instance + * @group: attribute group to append + */ +int snd_card_add_dev_attr(struct snd_card *card, + const struct attribute_group *group) +{ + int i; + + /* loop for (arraysize-1) here to keep NULL at the last entry */ + for (i = 0; i < ARRAY_SIZE(card->dev_groups) - 1; i++) { + if (!card->dev_groups[i]) { + card->dev_groups[i] = group; + return 0; + } + } + + dev_err(card->dev, "Too many groups assigned\n"); + return -ENOSPC; }; +EXPORT_SYMBOL_GPL(snd_card_add_dev_attr); /** * snd_card_register - register the soundcard -- cgit From 02fc76f6a7dbc6cdc3613957f5f1ed435eab5959 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jan 2015 12:36:17 +0100 Subject: ALSA: line6: Create sysfs via snd_card_add_dev_attr() Use the new helper function to create sysfs entries in the card more gracefully without races. Signed-off-by: Takashi Iwai --- sound/usb/line6/pod.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 61aadd7d4b7f..69aa3c42d5e8 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -330,6 +330,18 @@ static DEVICE_ATTR_RO(device_id); static DEVICE_ATTR_RO(firmware_version); static DEVICE_ATTR_RO(serial_number); +static struct attribute *pod_dev_attrs[] = { + &dev_attr_device_id.attr, + &dev_attr_firmware_version.attr, + &dev_attr_serial_number.attr, + NULL +}; + +static const struct attribute_group pod_dev_attr_group = { + .name = "pod", + .attrs = pod_dev_attrs, +}; + /* control info callback */ static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) @@ -387,34 +399,10 @@ static void line6_pod_disconnect(struct usb_line6 *line6) struct usb_line6_pod *pod = (struct usb_line6_pod *)line6; struct device *dev = line6->ifcdev; - /* remove sysfs entries: */ - device_remove_file(dev, &dev_attr_device_id); - device_remove_file(dev, &dev_attr_firmware_version); - device_remove_file(dev, &dev_attr_serial_number); - del_timer_sync(&pod->startup_timer); cancel_work_sync(&pod->startup_work); } -/* - Create sysfs entries. -*/ -static int pod_create_files2(struct device *dev) -{ - int err; - - err = device_create_file(dev, &dev_attr_device_id); - if (err < 0) - return err; - err = device_create_file(dev, &dev_attr_firmware_version); - if (err < 0) - return err; - err = device_create_file(dev, &dev_attr_serial_number); - if (err < 0) - return err; - return 0; -} - /* Try to init POD device. */ @@ -431,7 +419,7 @@ static int pod_init(struct usb_line6 *line6, INIT_WORK(&pod->startup_work, pod_startup4); /* create sysfs entries: */ - err = pod_create_files2(line6->ifcdev); + err = snd_card_add_dev_attr(line6->card, &pod_dev_attr_group); if (err < 0) return err; -- cgit From 9b6ff3fb9644b962b39816c571e38ddc1412fea0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 6 Feb 2015 10:12:14 +0100 Subject: ALSA: line6: Get rid of unused variable in pod.c Signed-off-by: Takashi Iwai --- sound/usb/line6/pod.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 69aa3c42d5e8..feec7070eaca 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -397,7 +397,6 @@ static struct snd_kcontrol_new pod_control_monitor = { static void line6_pod_disconnect(struct usb_line6 *line6) { struct usb_line6_pod *pod = (struct usb_line6_pod *)line6; - struct device *dev = line6->ifcdev; del_timer_sync(&pod->startup_timer); cancel_work_sync(&pod->startup_work); -- cgit From af5adf129369125bba8fa7ca594a7abaf226b27c Mon Sep 17 00:00:00 2001 From: Kenneth Westfield Date: Thu, 5 Feb 2015 12:53:40 -0800 Subject: ASoC: max98357a: Add MAX98357A codec driver Add codec driver for the Maxim MAX98357A DAC. Signed-off-by: Kenneth Westfield Acked-by: Banajit Goswami Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 4 ++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/max98357a.c | 138 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 sound/soc/codecs/max98357a.c (limited to 'sound') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 8349f982a586..6ecac1e4428e 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -69,6 +69,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_MAX98088 if I2C select SND_SOC_MAX98090 if I2C select SND_SOC_MAX98095 if I2C + select SND_SOC_MAX98357A select SND_SOC_MAX9850 if I2C select SND_SOC_MAX9768 if I2C select SND_SOC_MAX9877 if I2C @@ -456,6 +457,9 @@ config SND_SOC_MAX98090 config SND_SOC_MAX98095 tristate +config SND_SOC_MAX98357A + tristate + config SND_SOC_MAX9850 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index bbdfd1e1c182..69b8666d187a 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -64,6 +64,7 @@ snd-soc-max9768-objs := max9768.o snd-soc-max98088-objs := max98088.o snd-soc-max98090-objs := max98090.o snd-soc-max98095-objs := max98095.o +snd-soc-max98357a-objs := max98357a.o snd-soc-max9850-objs := max9850.o snd-soc-mc13783-objs := mc13783.o snd-soc-ml26124-objs := ml26124.o @@ -245,6 +246,7 @@ obj-$(CONFIG_SND_SOC_MAX9768) += snd-soc-max9768.o obj-$(CONFIG_SND_SOC_MAX98088) += snd-soc-max98088.o obj-$(CONFIG_SND_SOC_MAX98090) += snd-soc-max98090.o obj-$(CONFIG_SND_SOC_MAX98095) += snd-soc-max98095.o +obj-$(CONFIG_SND_SOC_MAX98357A) += snd-soc-max98357a.o obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c new file mode 100644 index 000000000000..98b915314d7a --- /dev/null +++ b/sound/soc/codecs/max98357a.c @@ -0,0 +1,138 @@ +/* Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * max98357a.c -- MAX98357A ALSA SoC Codec driver + */ + +#include +#include +#include + +#define DRV_NAME "max98357a" + +static int max98357a_daiops_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) +{ + struct gpio_desc *sdmode = snd_soc_dai_get_drvdata(dai); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + gpiod_set_value(sdmode, 1); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + gpiod_set_value(sdmode, 0); + break; + } + + return 0; +} + +static const struct snd_soc_dapm_widget max98357a_dapm_widgets[] = { + SND_SOC_DAPM_DAC("SDMode", NULL, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_OUTPUT("Speaker"), +}; + +static const struct snd_soc_dapm_route max98357a_dapm_routes[] = { + {"Speaker", NULL, "SDMode"}, +}; + +static int max98357a_codec_probe(struct snd_soc_codec *codec) +{ + struct gpio_desc *sdmode; + + sdmode = devm_gpiod_get(codec->dev, "sdmode"); + if (IS_ERR(sdmode)) { + dev_err(codec->dev, "%s() unable to get sdmode GPIO: %ld\n", + __func__, PTR_ERR(sdmode)); + return PTR_ERR(sdmode); + } + gpiod_direction_output(sdmode, 0); + snd_soc_codec_set_drvdata(codec, sdmode); + + return 0; +} + +static struct snd_soc_codec_driver max98357a_codec_driver = { + .probe = max98357a_codec_probe, + .dapm_widgets = max98357a_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98357a_dapm_widgets), + .dapm_routes = max98357a_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(max98357a_dapm_routes), +}; + +static struct snd_soc_dai_ops max98357a_dai_ops = { + .trigger = max98357a_daiops_trigger, +}; + +static struct snd_soc_dai_driver max98357a_dai_driver = { + .name = DRV_NAME, + .playback = { + .stream_name = DRV_NAME "-playback", + .formats = SNDRV_PCM_FMTBIT_S16 | + SNDRV_PCM_FMTBIT_S24 | + SNDRV_PCM_FMTBIT_S32, + .rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000, + .rate_min = 8000, + .rate_max = 96000, + .channels_min = 1, + .channels_max = 2, + }, + .ops = &max98357a_dai_ops, +}; + +static int max98357a_platform_probe(struct platform_device *pdev) +{ + int ret; + + ret = snd_soc_register_codec(&pdev->dev, &max98357a_codec_driver, + &max98357a_dai_driver, 1); + if (ret) + dev_err(&pdev->dev, "%s() error registering codec driver: %d\n", + __func__, ret); + + return ret; +} + +static int max98357a_platform_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + + return 0; +} + +#ifdef CONFIG_OF +static const struct of_device_id max98357a_device_id[] = { + { .compatible = "maxim," DRV_NAME, }, + {} +}; +#endif + +static struct platform_driver max98357a_platform_driver = { + .driver = { + .name = DRV_NAME, + .of_match_table = of_match_ptr(max98357a_device_id), + }, + .probe = max98357a_platform_probe, + .remove = max98357a_platform_remove, +}; +module_platform_driver(max98357a_platform_driver); + +MODULE_DESCRIPTION("Maxim MAX98357A Codec Driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); +MODULE_DEVICE_TABLE(of, max98357a_device_id); -- cgit From 6cf2cf31507522c199cf7974245bec9ac94cd9ea Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 19 Jan 2015 11:41:41 +0100 Subject: ASoC: samsung: Remove goni or aquila with the WM8994 Commit 28c8331d386a ("ARM: S5PV210: Remove support for board files") removed the Kconfig symbols MACH_GONI and MACH_AQUILA. As a result the dependencies of SND_SOC_GONI_AQUILA_WM8994 can never be met. So remove the unbuildable "SoC I2S Audio support for AQUILA/GONI - WM8994". Signed-off-by: Paul Bolle Signed-off-by: Mark Brown --- sound/soc/samsung/Kconfig | 11 -- sound/soc/samsung/Makefile | 2 - sound/soc/samsung/goni_wm8994.c | 289 ---------------------------------------- 3 files changed, 302 deletions(-) delete mode 100644 sound/soc/samsung/goni_wm8994.c (limited to 'sound') diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index e817a2f43ea8..3cebf6ca03df 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig @@ -146,17 +146,6 @@ config SND_SOC_SMARTQ select SND_SAMSUNG_I2S select SND_SOC_WM8750 -config SND_SOC_GONI_AQUILA_WM8994 - tristate "SoC I2S Audio support for AQUILA/GONI - WM8994" - depends on SND_SOC_SAMSUNG && (MACH_GONI || MACH_AQUILA) - depends on I2C=y - select SND_SAMSUNG_I2S - select MFD_WM8994 - select SND_SOC_WM8994 - help - Say Y if you want to add support for SoC audio on goni or aquila - with the WM8994. - config SND_SOC_SAMSUNG_SMDK_SPDIF tristate "SoC S/PDIF Audio support for SMDK" depends on SND_SOC_SAMSUNG diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile index 31e3dba7e3b5..052fe71be518 100644 --- a/sound/soc/samsung/Makefile +++ b/sound/soc/samsung/Makefile @@ -35,7 +35,6 @@ snd-soc-smdk-wm8994-objs := smdk_wm8994.o snd-soc-snow-objs := snow.o snd-soc-smdk-wm9713-objs := smdk_wm9713.o snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o -snd-soc-goni-wm8994-objs := goni_wm8994.o snd-soc-smdk-spdif-objs := smdk_spdif.o snd-soc-smdk-wm8580pcm-objs := smdk_wm8580pcm.o snd-soc-smdk-wm8994pcm-objs := smdk_wm8994pcm.o @@ -63,7 +62,6 @@ obj-$(CONFIG_SND_SOC_SNOW) += snd-soc-snow.o obj-$(CONFIG_SND_SOC_SAMSUNG_SMDK_WM9713) += snd-soc-smdk-wm9713.o obj-$(CONFIG_SND_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o obj-$(CONFIG_SND_SOC_SAMSUNG_SMDK_SPDIF) += snd-soc-smdk-spdif.o -obj-$(CONFIG_SND_SOC_GONI_AQUILA_WM8994) += snd-soc-goni-wm8994.o obj-$(CONFIG_SND_SOC_SMDK_WM8580_PCM) += snd-soc-smdk-wm8580pcm.o obj-$(CONFIG_SND_SOC_SMDK_WM8994_PCM) += snd-soc-smdk-wm8994pcm.o obj-$(CONFIG_SND_SOC_SPEYSIDE) += snd-soc-speyside.o diff --git a/sound/soc/samsung/goni_wm8994.c b/sound/soc/samsung/goni_wm8994.c deleted file mode 100644 index fad56b9e7369..000000000000 --- a/sound/soc/samsung/goni_wm8994.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * goni_wm8994.c - * - * Copyright (C) 2010 Samsung Electronics Co.Ltd - * Author: Chanwoo Choi - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - */ - -#include -#include -#include - -#include -#include - -#include "../codecs/wm8994.h" - -#define MACHINE_NAME 0 -#define CPU_VOICE_DAI 1 - -static const char *aquila_str[] = { - [MACHINE_NAME] = "aquila", - [CPU_VOICE_DAI] = "aquila-voice-dai", -}; - -static struct snd_soc_card goni; -static struct platform_device *goni_snd_device; - -/* 3.5 pie jack */ -static struct snd_soc_jack jack; - -/* 3.5 pie jack detection DAPM pins */ -static struct snd_soc_jack_pin jack_pins[] = { - { - .pin = "Headset Mic", - .mask = SND_JACK_MICROPHONE, - }, { - .pin = "Headset Stereophone", - .mask = SND_JACK_HEADPHONE | SND_JACK_MECHANICAL | - SND_JACK_AVOUT, - }, -}; - -/* 3.5 pie jack detection gpios */ -static struct snd_soc_jack_gpio jack_gpios[] = { - { - .gpio = S5PV210_GPH0(6), - .name = "DET_3.5", - .report = SND_JACK_HEADSET | SND_JACK_MECHANICAL | - SND_JACK_AVOUT, - .debounce_time = 200, - }, -}; - -static const struct snd_soc_dapm_widget goni_dapm_widgets[] = { - SND_SOC_DAPM_SPK("Ext Left Spk", NULL), - SND_SOC_DAPM_SPK("Ext Right Spk", NULL), - SND_SOC_DAPM_SPK("Ext Rcv", NULL), - SND_SOC_DAPM_HP("Headset Stereophone", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_MIC("Main Mic", NULL), - SND_SOC_DAPM_MIC("2nd Mic", NULL), - SND_SOC_DAPM_LINE("Radio In", NULL), -}; - -static const struct snd_soc_dapm_route goni_dapm_routes[] = { - {"Ext Left Spk", NULL, "SPKOUTLP"}, - {"Ext Left Spk", NULL, "SPKOUTLN"}, - - {"Ext Right Spk", NULL, "SPKOUTRP"}, - {"Ext Right Spk", NULL, "SPKOUTRN"}, - - {"Ext Rcv", NULL, "HPOUT2N"}, - {"Ext Rcv", NULL, "HPOUT2P"}, - - {"Headset Stereophone", NULL, "HPOUT1L"}, - {"Headset Stereophone", NULL, "HPOUT1R"}, - - {"IN1RN", NULL, "Headset Mic"}, - {"IN1RP", NULL, "Headset Mic"}, - - {"IN1RN", NULL, "2nd Mic"}, - {"IN1RP", NULL, "2nd Mic"}, - - {"IN1LN", NULL, "Main Mic"}, - {"IN1LP", NULL, "Main Mic"}, - - {"IN2LN", NULL, "Radio In"}, - {"IN2RN", NULL, "Radio In"}, -}; - -static int goni_wm8994_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - int ret; - - /* set endpoints to not connected */ - snd_soc_dapm_nc_pin(dapm, "IN2LP:VXRN"); - snd_soc_dapm_nc_pin(dapm, "IN2RP:VXRP"); - snd_soc_dapm_nc_pin(dapm, "LINEOUT1N"); - snd_soc_dapm_nc_pin(dapm, "LINEOUT1P"); - snd_soc_dapm_nc_pin(dapm, "LINEOUT2N"); - snd_soc_dapm_nc_pin(dapm, "LINEOUT2P"); - - if (machine_is_aquila()) { - snd_soc_dapm_nc_pin(dapm, "SPKOUTRN"); - snd_soc_dapm_nc_pin(dapm, "SPKOUTRP"); - } - - /* Headset jack detection */ - ret = snd_soc_jack_new(codec, "Headset Jack", - SND_JACK_HEADSET | SND_JACK_MECHANICAL | SND_JACK_AVOUT, - &jack); - if (ret) - return ret; - - ret = snd_soc_jack_add_pins(&jack, ARRAY_SIZE(jack_pins), jack_pins); - if (ret) - return ret; - - ret = snd_soc_jack_add_gpios(&jack, ARRAY_SIZE(jack_gpios), jack_gpios); - if (ret) - return ret; - - return 0; -} - -static int goni_hifi_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; - unsigned int pll_out = 24000000; - int ret = 0; - - /* set the codec FLL */ - ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, 0, pll_out, - params_rate(params) * 256); - if (ret < 0) - return ret; - - /* set the codec system clock */ - ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, - params_rate(params) * 256, SND_SOC_CLOCK_IN); - if (ret < 0) - return ret; - - return 0; -} - -static struct snd_soc_ops goni_hifi_ops = { - .hw_params = goni_hifi_hw_params, -}; - -static int goni_voice_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; - unsigned int pll_out = 24000000; - int ret = 0; - - if (params_rate(params) != 8000) - return -EINVAL; - - /* set the codec FLL */ - ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL2, 0, pll_out, - params_rate(params) * 256); - if (ret < 0) - return ret; - - /* set the codec system clock */ - ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL2, - params_rate(params) * 256, SND_SOC_CLOCK_IN); - if (ret < 0) - return ret; - - return 0; -} - -static struct snd_soc_dai_driver voice_dai = { - .name = "goni-voice-dai", - .id = 0, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000, - .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000, - .formats = SNDRV_PCM_FMTBIT_S16_LE,}, -}; - -static const struct snd_soc_component_driver voice_component = { - .name = "goni-voice", -}; - -static struct snd_soc_ops goni_voice_ops = { - .hw_params = goni_voice_hw_params, -}; - -static struct snd_soc_dai_link goni_dai[] = { -{ - .name = "WM8994", - .stream_name = "WM8994 HiFi", - .cpu_dai_name = "samsung-i2s.0", - .codec_dai_name = "wm8994-aif1", - .platform_name = "samsung-i2s.0", - .codec_name = "wm8994-codec.0-001a", - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM, - .init = goni_wm8994_init, - .ops = &goni_hifi_ops, -}, { - .name = "WM8994 Voice", - .stream_name = "Voice", - .cpu_dai_name = "goni-voice-dai", - .codec_dai_name = "wm8994-aif2", - .codec_name = "wm8994-codec.0-001a", - .dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_IB_IF | - SND_SOC_DAIFMT_CBM_CFM, - .ops = &goni_voice_ops, -}, -}; - -static struct snd_soc_card goni = { - .name = "goni", - .owner = THIS_MODULE, - .dai_link = goni_dai, - .num_links = ARRAY_SIZE(goni_dai), - - .dapm_widgets = goni_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(goni_dapm_widgets), - .dapm_routes = goni_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(goni_dapm_routes), -}; - -static int __init goni_init(void) -{ - int ret; - - if (machine_is_aquila()) { - voice_dai.name = aquila_str[CPU_VOICE_DAI]; - goni_dai[1].cpu_dai_name = aquila_str[CPU_VOICE_DAI]; - goni.name = aquila_str[MACHINE_NAME]; - } else if (!machine_is_goni()) - return -ENODEV; - - goni_snd_device = platform_device_alloc("soc-audio", -1); - if (!goni_snd_device) - return -ENOMEM; - - /* register voice DAI here */ - ret = devm_snd_soc_register_component(&goni_snd_device->dev, - &voice_component, &voice_dai, 1); - if (ret) { - platform_device_put(goni_snd_device); - return ret; - } - - platform_set_drvdata(goni_snd_device, &goni); - ret = platform_device_add(goni_snd_device); - - if (ret) - platform_device_put(goni_snd_device); - - return ret; -} - -static void __exit goni_exit(void) -{ - platform_device_unregister(goni_snd_device); -} - -module_init(goni_init); -module_exit(goni_exit); - -/* Module information */ -MODULE_DESCRIPTION("ALSA SoC WM8994 GONI(S5PV210)"); -MODULE_AUTHOR("Chanwoo Choi "); -MODULE_LICENSE("GPL"); -- cgit From 279e17ae81c17b40ae7a6c9e10f386a7aac7aa55 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Sat, 7 Feb 2015 23:40:52 +0100 Subject: ASoC: Intel: sst: Fix firmware name size handling Function sst_acpi_probe() uses plain strcpy for setting member firmware_name of a struct intel_sst_drv from member firmware of a struct sst_machines. Thereby the destination array has got a length of 20 byte while the source may hold 32 byte. Since eg. commit 64b9c90b8600 ("ASoC: Intel: Fix BYTCR firmware name") increased strings from "fw_sst_0f28.bin" to "intel/fw_sst_0f28.bin" there is an actual possibility that the 20 byte array at the end of struct intel_sst_drv is overrun. Thus increase the size of the destination and use the same define for both structs. Detected by Coverity CID 1260087. Signed-off-by: Christian Engelmayer Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/intel/sst/sst.h | 3 ++- sound/soc/intel/sst/sst_acpi.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst/sst.h b/sound/soc/intel/sst/sst.h index 7f4bbfcbc6f5..562bc483d6b7 100644 --- a/sound/soc/intel/sst/sst.h +++ b/sound/soc/intel/sst/sst.h @@ -58,6 +58,7 @@ enum sst_algo_ops { #define SST_BLOCK_TIMEOUT 1000 #define FW_SIGNATURE_SIZE 4 +#define FW_NAME_SIZE 32 /* stream states */ enum sst_stream_states { @@ -426,7 +427,7 @@ struct intel_sst_drv { * Holder for firmware name. Due to async call it needs to be * persistent till worker thread gets called */ - char firmware_name[20]; + char firmware_name[FW_NAME_SIZE]; }; /* misc definitions */ diff --git a/sound/soc/intel/sst/sst_acpi.c b/sound/soc/intel/sst/sst_acpi.c index b3360139c41a..51f83bad5319 100644 --- a/sound/soc/intel/sst/sst_acpi.c +++ b/sound/soc/intel/sst/sst_acpi.c @@ -47,7 +47,7 @@ struct sst_machines { char board[32]; char machine[32]; void (*machine_quirk)(void); - char firmware[32]; + char firmware[FW_NAME_SIZE]; struct sst_platform_info *pdata; }; -- cgit From 5985837e34ba8b0b51357a917e7587df10989a70 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Sun, 18 Jan 2015 00:38:46 +0100 Subject: ASoC: intel: sst-haswell-ipc: Remove unused functions Removes some functions that are not used anywhere: sst_hsw_stream_unmute() sst_hsw_stream_mute() msg_set_stage_type() sst_hsw_dx_get_state() sst_hsw_stream_set_write_position() sst_hsw_stream_get_vol_reg() sst_hsw_stream_get_peak_reg() sst_hsw_stream_get_pointer_reg() sst_hsw_stream_get_read_reg() sst_hsw_stream_get_mixer_id() sst_hsw_stream_get_hw_id() sst_hsw_mixer_set_volume_curve() sst_hsw_mixer_unmute() sst_hsw_mixer_mute() sst_hsw_stream_set_volume_curve() This was partially found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist Signed-off-by: Mark Brown --- sound/soc/intel/sst-haswell-ipc.c | 168 -------------------------------------- sound/soc/intel/sst-haswell-ipc.h | 31 ------- 2 files changed, 199 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c index a282179a3064..0ab1309ef274 100644 --- a/sound/soc/intel/sst-haswell-ipc.c +++ b/sound/soc/intel/sst-haswell-ipc.c @@ -338,12 +338,6 @@ static inline u32 msg_get_stage_type(u32 msg) return (msg & IPC_STG_TYPE_MASK) >> IPC_STG_TYPE_SHIFT; } -static inline u32 msg_set_stage_type(u32 msg, u32 type) -{ - return (msg & ~IPC_STG_TYPE_MASK) + - (type << IPC_STG_TYPE_SHIFT); -} - static inline u32 msg_get_stream_id(u32 msg) { return (msg & IPC_STR_ID_MASK) >> IPC_STR_ID_SHIFT; @@ -970,45 +964,6 @@ int sst_hsw_fw_get_version(struct sst_hsw *hsw, } /* Mixer Controls */ -int sst_hsw_stream_mute(struct sst_hsw *hsw, struct sst_hsw_stream *stream, - u32 stage_id, u32 channel) -{ - int ret; - - ret = sst_hsw_stream_get_volume(hsw, stream, stage_id, channel, - &stream->mute_volume[channel]); - if (ret < 0) - return ret; - - ret = sst_hsw_stream_set_volume(hsw, stream, stage_id, channel, 0); - if (ret < 0) { - dev_err(hsw->dev, "error: can't unmute stream %d channel %d\n", - stream->reply.stream_hw_id, channel); - return ret; - } - - stream->mute[channel] = 1; - return 0; -} - -int sst_hsw_stream_unmute(struct sst_hsw *hsw, struct sst_hsw_stream *stream, - u32 stage_id, u32 channel) - -{ - int ret; - - stream->mute[channel] = 0; - ret = sst_hsw_stream_set_volume(hsw, stream, stage_id, channel, - stream->mute_volume[channel]); - if (ret < 0) { - dev_err(hsw->dev, "error: can't unmute stream %d channel %d\n", - stream->reply.stream_hw_id, channel); - return ret; - } - - return 0; -} - int sst_hsw_stream_get_volume(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 *volume) { @@ -1022,17 +977,6 @@ int sst_hsw_stream_get_volume(struct sst_hsw *hsw, struct sst_hsw_stream *stream return 0; } -int sst_hsw_stream_set_volume_curve(struct sst_hsw *hsw, - struct sst_hsw_stream *stream, u64 curve_duration, - enum sst_hsw_volume_curve curve) -{ - /* curve duration in steps of 100ns */ - stream->vol_req.curve_duration = curve_duration; - stream->vol_req.curve_type = curve; - - return 0; -} - /* stream volume */ int sst_hsw_stream_set_volume(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 volume) @@ -1084,42 +1028,6 @@ int sst_hsw_stream_set_volume(struct sst_hsw *hsw, return 0; } -int sst_hsw_mixer_mute(struct sst_hsw *hsw, u32 stage_id, u32 channel) -{ - int ret; - - ret = sst_hsw_mixer_get_volume(hsw, stage_id, channel, - &hsw->mute_volume[channel]); - if (ret < 0) - return ret; - - ret = sst_hsw_mixer_set_volume(hsw, stage_id, channel, 0); - if (ret < 0) { - dev_err(hsw->dev, "error: failed to unmute mixer channel %d\n", - channel); - return ret; - } - - hsw->mute[channel] = 1; - return 0; -} - -int sst_hsw_mixer_unmute(struct sst_hsw *hsw, u32 stage_id, u32 channel) -{ - int ret; - - ret = sst_hsw_mixer_set_volume(hsw, stage_id, channel, - hsw->mixer_info.volume_register_address[channel]); - if (ret < 0) { - dev_err(hsw->dev, "error: failed to unmute mixer channel %d\n", - channel); - return ret; - } - - hsw->mute[channel] = 0; - return 0; -} - int sst_hsw_mixer_get_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel, u32 *volume) { @@ -1133,16 +1041,6 @@ int sst_hsw_mixer_get_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel, return 0; } -int sst_hsw_mixer_set_volume_curve(struct sst_hsw *hsw, - u64 curve_duration, enum sst_hsw_volume_curve curve) -{ - /* curve duration in steps of 100ns */ - hsw->curve_duration = curve_duration; - hsw->curve_type = curve; - - return 0; -} - /* global mixer volume */ int sst_hsw_mixer_set_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel, u32 volume) @@ -1451,48 +1349,6 @@ int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream) /* Stream Information - these calls could be inline but we want the IPC ABI to be opaque to client PCM drivers to cope with any future ABI changes */ -int sst_hsw_stream_get_hw_id(struct sst_hsw *hsw, - struct sst_hsw_stream *stream) -{ - return stream->reply.stream_hw_id; -} - -int sst_hsw_stream_get_mixer_id(struct sst_hsw *hsw, - struct sst_hsw_stream *stream) -{ - return stream->reply.mixer_hw_id; -} - -u32 sst_hsw_stream_get_read_reg(struct sst_hsw *hsw, - struct sst_hsw_stream *stream) -{ - return stream->reply.read_position_register_address; -} - -u32 sst_hsw_stream_get_pointer_reg(struct sst_hsw *hsw, - struct sst_hsw_stream *stream) -{ - return stream->reply.presentation_position_register_address; -} - -u32 sst_hsw_stream_get_peak_reg(struct sst_hsw *hsw, - struct sst_hsw_stream *stream, u32 channel) -{ - if (channel >= 2) - return 0; - - return stream->reply.peak_meter_register_address[channel]; -} - -u32 sst_hsw_stream_get_vol_reg(struct sst_hsw *hsw, - struct sst_hsw_stream *stream, u32 channel) -{ - if (channel >= 2) - return 0; - - return stream->reply.volume_register_address[channel]; -} - int sst_hsw_mixer_get_info(struct sst_hsw *hsw) { struct sst_hsw_ipc_stream_info_reply *reply; @@ -1630,30 +1486,6 @@ u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw, return ppos; } -int sst_hsw_stream_set_write_position(struct sst_hsw *hsw, - struct sst_hsw_stream *stream, u32 stage_id, u32 position) -{ - u32 header; - int ret; - - trace_stream_write_position(stream->reply.stream_hw_id, position); - - header = IPC_GLB_TYPE(IPC_GLB_STREAM_MESSAGE) | - IPC_STR_TYPE(IPC_STR_STAGE_MESSAGE); - header |= (stream->reply.stream_hw_id << IPC_STR_ID_SHIFT); - header |= (IPC_STG_SET_WRITE_POSITION << IPC_STG_TYPE_SHIFT); - header |= (stage_id << IPC_STG_ID_SHIFT); - stream->wpos.position = position; - - ret = ipc_tx_message_nowait(hsw, header, &stream->wpos, - sizeof(stream->wpos)); - if (ret < 0) - dev_err(hsw->dev, "error: stream %d set position %d failed\n", - stream->reply.stream_hw_id, position); - - return ret; -} - /* physical BE config */ int sst_hsw_device_set_config(struct sst_hsw *hsw, enum sst_hsw_device_id dev, enum sst_hsw_device_mclk mclk, diff --git a/sound/soc/intel/sst-haswell-ipc.h b/sound/soc/intel/sst-haswell-ipc.h index 138e894ab413..c1ad901342f2 100644 --- a/sound/soc/intel/sst-haswell-ipc.h +++ b/sound/soc/intel/sst-haswell-ipc.h @@ -376,32 +376,17 @@ int sst_hsw_fw_get_version(struct sst_hsw *hsw, u32 create_channel_map(enum sst_hsw_channel_config config); /* Stream Mixer Controls - */ -int sst_hsw_stream_mute(struct sst_hsw *hsw, struct sst_hsw_stream *stream, - u32 stage_id, u32 channel); -int sst_hsw_stream_unmute(struct sst_hsw *hsw, struct sst_hsw_stream *stream, - u32 stage_id, u32 channel); - int sst_hsw_stream_set_volume(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 volume); int sst_hsw_stream_get_volume(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 *volume); -int sst_hsw_stream_set_volume_curve(struct sst_hsw *hsw, - struct sst_hsw_stream *stream, u64 curve_duration, - enum sst_hsw_volume_curve curve); - /* Global Mixer Controls - */ -int sst_hsw_mixer_mute(struct sst_hsw *hsw, u32 stage_id, u32 channel); -int sst_hsw_mixer_unmute(struct sst_hsw *hsw, u32 stage_id, u32 channel); - int sst_hsw_mixer_set_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel, u32 volume); int sst_hsw_mixer_get_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel, u32 *volume); -int sst_hsw_mixer_set_volume_curve(struct sst_hsw *hsw, - u64 curve_duration, enum sst_hsw_volume_curve curve); - /* Stream API */ struct sst_hsw_stream *sst_hsw_stream_new(struct sst_hsw *hsw, int id, u32 (*get_write_position)(struct sst_hsw_stream *stream, void *data), @@ -440,18 +425,6 @@ int sst_hsw_stream_set_pmemory_info(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 offset, u32 size); int sst_hsw_stream_set_smemory_info(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 offset, u32 size); -int sst_hsw_stream_get_hw_id(struct sst_hsw *hsw, - struct sst_hsw_stream *stream); -int sst_hsw_stream_get_mixer_id(struct sst_hsw *hsw, - struct sst_hsw_stream *stream); -u32 sst_hsw_stream_get_read_reg(struct sst_hsw *hsw, - struct sst_hsw_stream *stream); -u32 sst_hsw_stream_get_pointer_reg(struct sst_hsw *hsw, - struct sst_hsw_stream *stream); -u32 sst_hsw_stream_get_peak_reg(struct sst_hsw *hsw, - struct sst_hsw_stream *stream, u32 channel); -u32 sst_hsw_stream_get_vol_reg(struct sst_hsw *hsw, - struct sst_hsw_stream *stream, u32 channel); int sst_hsw_mixer_get_info(struct sst_hsw *hsw); /* Stream ALSA trigger operations */ @@ -466,8 +439,6 @@ int sst_hsw_stream_get_read_pos(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 *position); int sst_hsw_stream_get_write_pos(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 *position); -int sst_hsw_stream_set_write_position(struct sst_hsw *hsw, - struct sst_hsw_stream *stream, u32 stage_id, u32 position); u32 sst_hsw_get_dsp_position(struct sst_hsw *hsw, struct sst_hsw_stream *stream); u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw, @@ -481,8 +452,6 @@ int sst_hsw_device_set_config(struct sst_hsw *hsw, /* DX Config */ int sst_hsw_dx_set_state(struct sst_hsw *hsw, enum sst_hsw_dx_state state, struct sst_hsw_ipc_dx_reply *dx); -int sst_hsw_dx_get_state(struct sst_hsw *hsw, u32 item, - u32 *offset, u32 *size, u32 *source); /* init */ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata); -- cgit From 8f6f9b2982b2c924fe2dde816e2decb3ca1d8f8f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Feb 2015 05:34:10 +0000 Subject: ASoC: core: indicate unregister debug message once Current snd_soc_unregister_card() indicates unregistered debug message when it was called. But, it should be called only when it was really unregistered. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 54925dc84a96..4bfabc776e21 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2396,8 +2396,8 @@ int snd_soc_unregister_card(struct snd_soc_card *card) card->instantiated = false; snd_soc_dapm_shutdown(card); soc_cleanup_card_resources(card); + dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); } - dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); return 0; } -- cgit From 89444601e5878042812e33da0c17807197c2669c Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Sat, 7 Feb 2015 10:43:17 -0600 Subject: ALSA: line6: Add toneport_has_source_select() Add a predicate for testing if the device supports source selection to make the conditional logic around this a bit cleaner. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/toneport.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index b107cf481819..6dd6d4f41310 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -343,6 +343,20 @@ static void toneport_remove_leds(struct usb_line6_toneport *toneport) } } +static bool toneport_has_source_select(struct usb_line6_toneport *toneport) +{ + switch (toneport->type) { + case LINE6_TONEPORT_UX1: + case LINE6_TONEPORT_UX2: + case LINE6_PODSTUDIO_UX1: + case LINE6_PODSTUDIO_UX2: + return true; + + default: + return false; + } +} + /* Setup Toneport device. */ @@ -360,17 +374,10 @@ static void toneport_setup(struct usb_line6_toneport *toneport) toneport_send_cmd(usbdev, 0x0301, 0x0000); /* initialize source select: */ - switch (toneport->type) { - case LINE6_TONEPORT_UX1: - case LINE6_TONEPORT_UX2: - case LINE6_PODSTUDIO_UX1: - case LINE6_PODSTUDIO_UX2: + if (toneport_has_source_select(toneport)) toneport_send_cmd(usbdev, toneport_source_info[toneport->source].code, 0x0000); - default: - break; - } if (toneport_has_led(toneport->type)) toneport_update_led(toneport); @@ -421,20 +428,13 @@ static int toneport_init(struct usb_line6 *line6, return err; /* register source select control: */ - switch (toneport->type) { - case LINE6_TONEPORT_UX1: - case LINE6_TONEPORT_UX2: - case LINE6_PODSTUDIO_UX1: - case LINE6_PODSTUDIO_UX2: + if (toneport_has_source_select(toneport)) { err = snd_ctl_add(line6->card, snd_ctl_new1(&toneport_control_source, line6->line6pcm)); if (err < 0) return err; - - default: - break; } line6_read_serial_number(line6, &toneport->serial_number); -- cgit From f2bd242fa114df07ab8ed0d2f445a9a313e3aaa1 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Sat, 7 Feb 2015 10:43:18 -0600 Subject: ALSA: line6: Pass toneport pointer to toneport_has_led() It is unlikely this function would ever be used in a context without a pointer to a `struct usb_line6_toneport', so grab the device type from it rather than having the caller do it. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/toneport.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 6dd6d4f41310..2420d2fc8aa2 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -278,12 +278,17 @@ static struct snd_kcontrol_new toneport_control_source = { (void cmd_0x02(byte red, byte green) */ -static bool toneport_has_led(enum line6_device_type type) +static bool toneport_has_led(struct usb_line6_toneport *toneport) { - return - (type == LINE6_GUITARPORT) || - (type == LINE6_TONEPORT_GX); + switch (toneport->type) { + case LINE6_GUITARPORT: + case LINE6_TONEPORT_GX: /* add your device here if you are missing support for the LEDs */ + return true; + + default: + return false; + } } static const char * const led_colors[2] = { "red", "green" }; @@ -379,7 +384,7 @@ static void toneport_setup(struct usb_line6_toneport *toneport) toneport_source_info[toneport->source].code, 0x0000); - if (toneport_has_led(toneport->type)) + if (toneport_has_led(toneport)) toneport_update_led(toneport); mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ); @@ -395,7 +400,7 @@ static void line6_toneport_disconnect(struct usb_line6 *line6) del_timer_sync(&toneport->timer); - if (toneport_has_led(toneport->type)) + if (toneport_has_led(toneport)) toneport_remove_leds(toneport); } @@ -440,7 +445,7 @@ static int toneport_init(struct usb_line6 *line6, line6_read_serial_number(line6, &toneport->serial_number); line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); - if (toneport_has_led(toneport->type)) { + if (toneport_has_led(toneport)) { err = toneport_init_leds(toneport); if (err < 0) return err; -- cgit From 12865cac38cc9e808ce8b479f4bb12fd00bfee7c Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Sat, 7 Feb 2015 10:43:19 -0600 Subject: ALSA: line6: Pass driver name to line6_probe() Provide a unique name for each driver instead of using "line6usb" for all of them. This will allow for different configurations based on the driver type. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 3 ++- sound/usb/line6/driver.h | 3 +-- sound/usb/line6/pod.c | 2 +- sound/usb/line6/podhd.c | 2 +- sound/usb/line6/toneport.c | 2 +- sound/usb/line6/variax.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index e2a2603a1ca3..626b0c3244cf 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -480,6 +480,7 @@ static int line6_init_cap_control(struct usb_line6 *line6) */ int line6_probe(struct usb_interface *interface, const struct usb_device_id *id, + const char *driver_name, const struct line6_properties *properties, int (*private_init)(struct usb_line6 *, const struct usb_device_id *id), size_t data_size) @@ -511,7 +512,7 @@ int line6_probe(struct usb_interface *interface, line6->ifcdev = &interface->dev; strcpy(card->id, properties->id); - strcpy(card->driver, DRIVER_NAME); + strcpy(card->driver, driver_name); strcpy(card->shortname, properties->name); sprintf(card->longname, "Line 6 %s at USB %s", properties->name, dev_name(line6->ifcdev)); diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index 2276b78f3562..92a662a0469e 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -18,8 +18,6 @@ #include "midi.h" -#define DRIVER_NAME "line6usb" - #define USB_INTERVALS_PER_SECOND 1000 /* Fallback USB interval and max packet size values */ @@ -168,6 +166,7 @@ extern int line6_write_data(struct usb_line6 *line6, int address, void *data, int line6_probe(struct usb_interface *interface, const struct usb_device_id *id, + const char *driver_name, const struct line6_properties *properties, int (*private_init)(struct usb_line6 *, const struct usb_device_id *id), size_t data_size); diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index feec7070eaca..09017bc9615b 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -561,7 +561,7 @@ static const struct line6_properties pod_properties_table[] = { static int pod_probe(struct usb_interface *interface, const struct usb_device_id *id) { - return line6_probe(interface, id, + return line6_probe(interface, id, "Line6-POD", &pod_properties_table[id->driver_info], pod_init, sizeof(struct usb_line6_pod)); } diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 9c3c7441fd11..63dcaef41ac3 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -169,7 +169,7 @@ static const struct line6_properties podhd_properties_table[] = { static int podhd_probe(struct usb_interface *interface, const struct usb_device_id *id) { - return line6_probe(interface, id, + return line6_probe(interface, id, "Line6-PODHD", &podhd_properties_table[id->driver_info], podhd_init, sizeof(struct usb_line6)); } diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 2420d2fc8aa2..1a0a485b6654 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -557,7 +557,7 @@ static const struct line6_properties toneport_properties_table[] = { static int toneport_probe(struct usb_interface *interface, const struct usb_device_id *id) { - return line6_probe(interface, id, + return line6_probe(interface, id, "Line6-TonePort", &toneport_properties_table[id->driver_info], toneport_init, sizeof(struct usb_line6_toneport)); } diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index b1c1de65d584..ddc23ddf0750 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -283,7 +283,7 @@ static const struct line6_properties variax_properties_table[] = { static int variax_probe(struct usb_interface *interface, const struct usb_device_id *id) { - return line6_probe(interface, id, + return line6_probe(interface, id, "Line6-Variax", &variax_properties_table[id->driver_info], variax_init, sizeof(struct usb_line6_variax)); } -- cgit From d34890cf4113397625a6629d71749fa638a7a734 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 8 Feb 2015 22:39:44 +0900 Subject: ALSA: control: fix failure to return numerical ID in 'add' event Currently when adding a new control, the assigned numerical ID is not set for event data, thus userspace applications cannot realize it just by event data. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 60caba1f2211..8aae6eaa3564 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -373,6 +373,7 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) card->controls_count += kcontrol->count; kcontrol->id.numid = card->last_numid + 1; card->last_numid += kcontrol->count; + id = kcontrol->id; count = kcontrol->count; up_write(&card->controls_rwsem); for (idx = 0; idx < count; idx++, id.index++, id.numid++) -- cgit From 812e85bb224a088678eb315307d367d91d0b94e2 Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Sun, 8 Feb 2015 18:35:47 +0800 Subject: ASoC: Intel: fix platform_no_drv_owner.cocci warnings sound/soc/intel/cht_bsw_rt5645.c:315:3-8: No need to set .owner here. The core will do it. Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Signed-off-by: Fengguang Wu Signed-off-by: Mark Brown --- sound/soc/intel/cht_bsw_rt5645.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/cht_bsw_rt5645.c b/sound/soc/intel/cht_bsw_rt5645.c index b6f8377b6e33..bd29617a9ab9 100644 --- a/sound/soc/intel/cht_bsw_rt5645.c +++ b/sound/soc/intel/cht_bsw_rt5645.c @@ -312,7 +312,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev) static struct platform_driver snd_cht_mc_driver = { .driver = { - .owner = THIS_MODULE, .name = "cht-bsw-rt5645", .pm = &snd_soc_pm_ops, }, -- cgit From 3efa130de40e7b2d7c7095683af9571bfef1d3a4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 9 Feb 2015 14:36:47 +0800 Subject: ASoC: max98357a: Fix build in !CONFIG_OF case Reported-by: Stephen Rothwell Signed-off-by: Mark Brown --- sound/soc/codecs/max98357a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c index 98b915314d7a..1806333ea29e 100644 --- a/sound/soc/codecs/max98357a.c +++ b/sound/soc/codecs/max98357a.c @@ -120,6 +120,7 @@ static const struct of_device_id max98357a_device_id[] = { { .compatible = "maxim," DRV_NAME, }, {} }; +MODULE_DEVICE_TABLE(of, max98357a_device_id); #endif static struct platform_driver max98357a_platform_driver = { @@ -135,4 +136,3 @@ module_platform_driver(max98357a_platform_driver); MODULE_DESCRIPTION("Maxim MAX98357A Codec Driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" DRV_NAME); -MODULE_DEVICE_TABLE(of, max98357a_device_id); -- cgit From 3ab888db095518578aac7a13e05f3969531a4f8a Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 9 Feb 2015 14:19:45 +0800 Subject: ASoC: rt286: Add rt288 codec support This patch adds support for rt288 codec. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt286.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index 1fbebaf6dbf4..9a698f01a9a5 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -34,6 +34,7 @@ #include "rt286.h" #define RT286_VENDOR_ID 0x10ec0286 +#define RT288_VENDOR_ID 0x10ec0288 struct rt286_priv { struct regmap *regmap; @@ -1168,6 +1169,7 @@ static const struct regmap_config rt286_regmap = { static const struct i2c_device_id rt286_i2c_id[] = { {"rt286", 0}, + {"rt288", 0}, {} }; MODULE_DEVICE_TABLE(i2c, rt286_i2c_id); @@ -1221,7 +1223,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c, regmap_read(rt286->regmap, RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &ret); - if (ret != RT286_VENDOR_ID) { + if (ret != RT286_VENDOR_ID && ret != RT288_VENDOR_ID) { dev_err(&i2c->dev, "Device with ID register %x is not rt286\n", ret); return -ENODEV; -- cgit From 92b133f251b5f914f3ed28bc83e5b7a40d4e22ed Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 9 Feb 2015 14:41:50 +0800 Subject: ASoC: rt5670: Set use_single_rw flag for regmap RT5670 doesn't support auto incrementing writes so driver should set the use_single_rw flag for regmap. Signed-off-by: Bard Liao Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/codecs/rt5670.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 0632b7458a53..6aa4ab24288e 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -2614,6 +2614,7 @@ static struct snd_soc_codec_driver soc_codec_dev_rt5670 = { static const struct regmap_config rt5670_regmap = { .reg_bits = 8, .val_bits = 16, + .use_single_rw = true, .max_register = RT5670_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5670_ranges) * RT5670_PR_SPACING), .volatile_reg = rt5670_volatile_register, -- cgit From e4940626defdf6c92da1052ad3f12741c1a28c90 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 9 Feb 2015 16:51:40 +0300 Subject: ALSA: off by one bug in snd_riptide_joystick_probe() The problem here is that we check: if (dev >= SNDRV_CARDS) Then we increment "dev". if (!joystick_port[dev++]) Then we use it as an offset into a array with SNDRV_CARDS elements. if (!request_region(joystick_port[dev], 8, "Riptide gameport")) { This has 3 effects: 1) If you use the module option to specify the joystick port then it has to be shifted one space over. 2) The wrong error message will be printed on failure if you have over 32 cards. 3) Static checkers will correctly complain that are off by one. Fixes: db1005ec6ff8 ('ALSA: riptide - Fix joystick resource handling') Signed-off-by: Dan Carpenter Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 29f28273b2cc..94639d6b5fb5 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -2011,32 +2011,43 @@ snd_riptide_joystick_probe(struct pci_dev *pci, const struct pci_device_id *id) { static int dev; struct gameport *gameport; + int ret; if (dev >= SNDRV_CARDS) return -ENODEV; + if (!enable[dev]) { - dev++; - return -ENOENT; + ret = -ENOENT; + goto inc_dev; } - if (!joystick_port[dev++]) - return 0; + if (!joystick_port[dev]) { + ret = 0; + goto inc_dev; + } gameport = gameport_allocate_port(); - if (!gameport) - return -ENOMEM; + if (!gameport) { + ret = -ENOMEM; + goto inc_dev; + } if (!request_region(joystick_port[dev], 8, "Riptide gameport")) { snd_printk(KERN_WARNING "Riptide: cannot grab gameport 0x%x\n", joystick_port[dev]); gameport_free_port(gameport); - return -EBUSY; + ret = -EBUSY; + goto inc_dev; } gameport->io = joystick_port[dev]; gameport_register_port(gameport); pci_set_drvdata(pci, gameport); - return 0; + + ret = 0; +inc_dev: + dev++; + return ret; } static void snd_riptide_joystick_remove(struct pci_dev *pci) -- cgit From 0d59b814353d397ff5d00ac33acd536030252a98 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 6 Feb 2015 15:55:50 -0600 Subject: ALSA: pcm: don't override timestamp unconditionally timestamp in RUNNING mode is already taken in update_hw_ptr routine, getting a new timestamp introduces offset between hw_ptr, audio_tstamp and system time Add else condition to read timestamp as fallback and only when enabled Signed-off-by: Pierre-Louis Bossart Signed-off-by: Takashi Iwai --- sound/core/pcm_native.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 932234d87927..4ecd35fbfe3f 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -720,8 +720,11 @@ int snd_pcm_status(struct snd_pcm_substream *substream, runtime->status->audio_tstamp; goto _tstamp_end; } + } 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); } - snd_pcm_gettime(runtime, &status->tstamp); _tstamp_end: status->appl_ptr = runtime->control->appl_ptr; status->hw_ptr = runtime->status->hw_ptr; -- cgit From 2b79d7a6bf341ebeffb85fc2b3577d0cfa810c49 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 6 Feb 2015 15:55:51 -0600 Subject: ALSA: pcm: allow for trigger_tstamp snapshot in .trigger Don't use generic snapshot of trigger_tstamp if low-level driver or hardware can get a more precise value for better audio/system time synchronization. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Takashi Iwai --- sound/core/pcm_native.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 4ecd35fbfe3f..b03a638b420c 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -810,7 +810,8 @@ static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) if (runtime->trigger_master == NULL) return; if (runtime->trigger_master == substream) { - snd_pcm_gettime(runtime, &runtime->trigger_tstamp); + if (!runtime->trigger_tstamp_latched) + snd_pcm_gettime(runtime, &runtime->trigger_tstamp); } else { snd_pcm_trigger_tstamp(runtime->trigger_master); runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; @@ -979,6 +980,7 @@ static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && !snd_pcm_playback_data(substream)) return -EPIPE; + runtime->trigger_tstamp_latched = false; runtime->trigger_master = substream; return 0; } -- cgit From ed610af86a717152be5aa5e29410c5183992b4f2 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 6 Feb 2015 15:55:52 -0600 Subject: ALSA: hda: read trigger_timestamp immediately after starting DMA Make sure wallclock counter and trigger timestamp are read very close to each other for better alignment. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_controller.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 27dcb142f596..dfcb5e929f9f 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -657,6 +657,9 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits); if (start) { azx_timecounter_init(substream, 0, 0); + snd_pcm_gettime(substream->runtime, &substream->runtime->trigger_tstamp); + substream->runtime->trigger_tstamp_latched = true; + if (nsync > 1) { cycle_t cycle_last; -- cgit From ea33d359c4421f369443f6fee92a1e893541eb73 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 6 Feb 2015 15:55:53 -0600 Subject: ALSA: usb: update trigger timestamp on first non-zero URB submitted The first URBs are submitted during the prepare stage. When .trigger is called, the ALSA core saves a trigger tstamp that doesn't correspond to the actual time when the samples are submitted. The trigger_tstamp is now updated when the first data are submitted to avoid any time offsets. A usb-specific trigger_tstamp_pending_update flag is used for now, at some point the flag would need to move to the ALSA core, USB is not the only interface where silent block transfers are programmed as part of the prepare stage, with actual data enabled when .trigger is called. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Takashi Iwai --- sound/usb/card.h | 2 ++ sound/usb/pcm.c | 9 +++++++++ 2 files changed, 11 insertions(+) (limited to 'sound') diff --git a/sound/usb/card.h b/sound/usb/card.h index 97acb906acc2..ef580b43f1e3 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -153,6 +153,8 @@ struct snd_usb_substream { int channel; int byte_idx; } dsd_dop; + + bool trigger_tstamp_pending_update; /* trigger timestamp being updated from initial estimate */ }; struct snd_usb_stream { diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 0d8aba5fe1a8..b4ef410e5a98 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -1464,6 +1464,14 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, subs->last_frame_number = usb_get_current_frame_number(subs->dev); subs->last_frame_number &= 0xFF; /* keep 8 LSBs */ + if (subs->trigger_tstamp_pending_update) { + /* this is the first actual URB submitted, + * update trigger timestamp to reflect actual start time + */ + snd_pcm_gettime(runtime, &runtime->trigger_tstamp); + subs->trigger_tstamp_pending_update = false; + } + spin_unlock_irqrestore(&subs->lock, flags); urb->transfer_buffer_length = bytes; if (period_elapsed) @@ -1550,6 +1558,7 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea switch (cmd) { case SNDRV_PCM_TRIGGER_START: + subs->trigger_tstamp_pending_update = true; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: subs->data_endpoint->prepare_data_urb = prepare_playback_urb; subs->data_endpoint->retire_data_urb = retire_playback_urb; -- cgit From e6ff3840dc844027bc81d0490e7bc22d03598429 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Tue, 10 Feb 2015 00:01:45 +0900 Subject: ALSA: control: fix failure to return new numerical ID in 'replace' event data In 'replace' event data, numerical ID of control is always invalid. This commit fix this bug so as the event data has renewed numerical ID for control. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 8aae6eaa3564..35324a8e83c8 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -440,6 +440,7 @@ add: card->controls_count += kcontrol->count; kcontrol->id.numid = card->last_numid + 1; card->last_numid += kcontrol->count; + id = kcontrol->id; count = kcontrol->count; up_write(&card->controls_rwsem); for (idx = 0; idx < count; idx++, id.index++, id.numid++) -- cgit From 3271cb22838882bad86f6f2405b29fa7925a08e8 Mon Sep 17 00:00:00 2001 From: TienFu Chen Date: Tue, 10 Feb 2015 09:09:41 +0100 Subject: ALSA: hda - Add docking station support for another HP machine BugLink: https://bugs.launchpad.net/bugs/1412800 Signed-off-by: TienFu Chen Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 040306194e6d..ddb93083a2af 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -4950,6 +4950,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS), + SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS), SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), -- cgit From 1b006996b6c44d9d95462e382921954756cec99b Mon Sep 17 00:00:00 2001 From: Libin Yang Date: Tue, 10 Feb 2015 10:02:47 +0800 Subject: ASoC: Intel: Clean data after SST fw fetch The BDW audio firmware DSP manages the DMA and the DMA cannot be stopped exactly at the end of the playback stream. This means stale samples may be played at PCM stop unless the driver copies silence to the subsequent periods. Signed-off-by: Libin Yang Reviewed-by: Liam Girdwood Signed-off-by: Takashi Iwai --- sound/soc/intel/sst-haswell-ipc.c | 28 +++++++++++++++++ sound/soc/intel/sst-haswell-ipc.h | 9 ++++++ sound/soc/intel/sst-haswell-pcm.c | 65 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c index 0ab1309ef274..394af5684c05 100644 --- a/sound/soc/intel/sst-haswell-ipc.c +++ b/sound/soc/intel/sst-haswell-ipc.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "sst-haswell-ipc.h" #include "sst-dsp.h" @@ -242,6 +243,9 @@ struct sst_hsw_stream { u32 (*notify_position)(struct sst_hsw_stream *stream, void *data); void *pdata; + /* record the fw read position when playback */ + snd_pcm_uframes_t old_position; + bool play_silence; struct list_head node; }; @@ -1347,6 +1351,30 @@ int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream) return 0; } +snd_pcm_uframes_t sst_hsw_stream_get_old_position(struct sst_hsw *hsw, + struct sst_hsw_stream *stream) +{ + return stream->old_position; +} + +void sst_hsw_stream_set_old_position(struct sst_hsw *hsw, + struct sst_hsw_stream *stream, snd_pcm_uframes_t val) +{ + stream->old_position = val; +} + +bool sst_hsw_stream_get_silence_start(struct sst_hsw *hsw, + struct sst_hsw_stream *stream) +{ + return stream->play_silence; +} + +void sst_hsw_stream_set_silence_start(struct sst_hsw *hsw, + struct sst_hsw_stream *stream, bool val) +{ + stream->play_silence = val; +} + /* Stream Information - these calls could be inline but we want the IPC ABI to be opaque to client PCM drivers to cope with any future ABI changes */ int sst_hsw_mixer_get_info(struct sst_hsw *hsw) diff --git a/sound/soc/intel/sst-haswell-ipc.h b/sound/soc/intel/sst-haswell-ipc.h index c1ad901342f2..858096041cb1 100644 --- a/sound/soc/intel/sst-haswell-ipc.h +++ b/sound/soc/intel/sst-haswell-ipc.h @@ -20,6 +20,7 @@ #include #include #include +#include #define SST_HSW_NO_CHANNELS 4 #define SST_HSW_MAX_DX_REGIONS 14 @@ -425,6 +426,14 @@ int sst_hsw_stream_set_pmemory_info(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 offset, u32 size); int sst_hsw_stream_set_smemory_info(struct sst_hsw *hsw, struct sst_hsw_stream *stream, u32 offset, u32 size); +snd_pcm_uframes_t sst_hsw_stream_get_old_position(struct sst_hsw *hsw, + struct sst_hsw_stream *stream); +void sst_hsw_stream_set_old_position(struct sst_hsw *hsw, + struct sst_hsw_stream *stream, snd_pcm_uframes_t val); +bool sst_hsw_stream_get_silence_start(struct sst_hsw *hsw, + struct sst_hsw_stream *stream); +void sst_hsw_stream_set_silence_start(struct sst_hsw *hsw, + struct sst_hsw_stream *stream, bool val); int sst_hsw_mixer_get_info(struct sst_hsw *hsw); /* Stream ALSA trigger operations */ diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index 78fa01be57f2..d6fa9d5514e1 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c @@ -36,6 +36,11 @@ #define HSW_PCM_COUNT 6 #define HSW_VOLUME_MAX 0x7FFFFFFF /* 0dB */ +#define SST_OLD_POSITION(d, r, o) ((d) + \ + frames_to_bytes(r, o)) +#define SST_SAMPLES(r, x) (bytes_to_samples(r, \ + frames_to_bytes(r, (x)))) + /* simple volume table */ static const u32 volume_map[] = { HSW_VOLUME_MAX >> 30, @@ -577,23 +582,34 @@ static int hsw_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(rtd->platform); struct hsw_pcm_data *pcm_data; + struct sst_hsw_stream *sst_stream; struct sst_hsw *hsw = pdata->hsw; + struct snd_pcm_runtime *runtime = substream->runtime; + snd_pcm_uframes_t pos; int dai; dai = mod_map[rtd->cpu_dai->id].dai_id; pcm_data = &pdata->pcm[dai][substream->stream]; + sst_stream = pcm_data->stream; switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + sst_hsw_stream_set_silence_start(hsw, sst_stream, false); sst_hsw_stream_resume(hsw, pcm_data->stream, 0); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + sst_hsw_stream_set_silence_start(hsw, sst_stream, false); sst_hsw_stream_pause(hsw, pcm_data->stream, 0); break; + case SNDRV_PCM_TRIGGER_DRAIN: + pos = runtime->control->appl_ptr % runtime->buffer_size; + sst_hsw_stream_set_old_position(hsw, pcm_data->stream, pos); + sst_hsw_stream_set_silence_start(hsw, sst_stream, true); + break; default: break; } @@ -607,13 +623,62 @@ static u32 hsw_notify_pointer(struct sst_hsw_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct hsw_priv_data *pdata = + snd_soc_platform_get_drvdata(rtd->platform); + struct sst_hsw *hsw = pdata->hsw; u32 pos; + snd_pcm_uframes_t position = bytes_to_frames(runtime, + sst_hsw_get_dsp_position(hsw, pcm_data->stream)); + unsigned char *dma_area = runtime->dma_area; + snd_pcm_uframes_t dma_frames = + bytes_to_frames(runtime, runtime->dma_bytes); + snd_pcm_uframes_t old_position; + ssize_t samples; pos = frames_to_bytes(runtime, (runtime->control->appl_ptr % runtime->buffer_size)); dev_vdbg(rtd->dev, "PCM: App pointer %d bytes\n", pos); + /* SST fw don't know where to stop dma + * So, SST driver need to clean the data which has been consumed + */ + if (dma_area == NULL || dma_frames <= 0 + || (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + || !sst_hsw_stream_get_silence_start(hsw, stream)) { + snd_pcm_period_elapsed(substream); + return pos; + } + + old_position = sst_hsw_stream_get_old_position(hsw, stream); + if (position > old_position) { + if (position < dma_frames) { + samples = SST_SAMPLES(runtime, position - old_position); + snd_pcm_format_set_silence(runtime->format, + SST_OLD_POSITION(dma_area, + runtime, old_position), + samples); + } else + dev_err(rtd->dev, "PCM: position is wrong\n"); + } else { + if (old_position < dma_frames) { + samples = SST_SAMPLES(runtime, + dma_frames - old_position); + snd_pcm_format_set_silence(runtime->format, + SST_OLD_POSITION(dma_area, + runtime, old_position), + samples); + } else + dev_err(rtd->dev, "PCM: dma_bytes is wrong\n"); + if (position < dma_frames) { + samples = SST_SAMPLES(runtime, position); + snd_pcm_format_set_silence(runtime->format, + dma_area, samples); + } else + dev_err(rtd->dev, "PCM: position is wrong\n"); + } + sst_hsw_stream_set_old_position(hsw, stream, position); + /* let alsa know we have play a period */ snd_pcm_period_elapsed(substream); return pos; -- cgit From e64e94df9916a1db6c85a3677e20926c99a1d0b3 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Tue, 10 Feb 2015 23:03:13 -0600 Subject: ALSA: line6: Add delay before reading status The device indicates the result of a read/write operation by making the status available on a subsequent request from the driver. This is not ready immediately, though, so the driver is currently slamming the device with hundreds of pointless requests before getting the expected response. Add a two millisecond delay before each attempt. This is approximately the behavior observed with version 4.2.7.1 of the Windows driver. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 626b0c3244cf..2f9b74e7accb 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -296,6 +296,8 @@ static void line6_data_received(struct urb *urb) line6_start_listen(line6); } +#define LINE6_READ_WRITE_STATUS_DELAY 2 /* milliseconds */ + /* Read data from device. */ @@ -319,6 +321,8 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, /* Wait for data length. We'll get 0xff until length arrives. */ do { + mdelay(LINE6_READ_WRITE_STATUS_DELAY); + ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, @@ -376,6 +380,8 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data, } do { + mdelay(LINE6_READ_WRITE_STATUS_DELAY); + ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | -- cgit From f3dfd1be08cc55f930f32e714fb1967630c47991 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Tue, 10 Feb 2015 23:03:14 -0600 Subject: ALSA: line6: Return error if device not responding Put an upper bound on how long we will wait for the device to respond to a read/write request (i.e., 100 milliseconds) and return an error if this is reached. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 2f9b74e7accb..f2ee8046271a 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -297,6 +297,7 @@ static void line6_data_received(struct urb *urb) } #define LINE6_READ_WRITE_STATUS_DELAY 2 /* milliseconds */ +#define LINE6_READ_WRITE_MAX_RETRIES 50 /* Read data from device. @@ -307,6 +308,7 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, struct usb_device *usbdev = line6->usbdev; int ret; unsigned char len; + unsigned count; /* query the serial number: */ ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, @@ -320,7 +322,7 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, } /* Wait for data length. We'll get 0xff until length arrives. */ - do { + for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67, @@ -333,9 +335,16 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, "receive length failed (error %d)\n", ret); return ret; } - } while (len == 0xff); - if (len != datalen) { + if (len != 0xff) + break; + } + + if (len == 0xff) { + dev_err(line6->ifcdev, "read failed after %d retries\n", + count); + return -EIO; + } else if (len != datalen) { /* should be equal or something went wrong */ dev_err(line6->ifcdev, "length mismatch (expected %d, got %d)\n", @@ -367,6 +376,7 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data, struct usb_device *usbdev = line6->usbdev; int ret; unsigned char status; + int count; ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, @@ -379,7 +389,7 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data, return ret; } - do { + for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) { mdelay(LINE6_READ_WRITE_STATUS_DELAY); ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), @@ -394,9 +404,16 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data, "receiving status failed (error %d)\n", ret); return ret; } - } while (status == 0xff); - if (status != 0) { + if (status != 0xff) + break; + } + + if (status == 0xff) { + dev_err(line6->ifcdev, "write failed after %d retries\n", + count); + return -EIO; + } else if (status != 0) { dev_err(line6->ifcdev, "write failed (error %d)\n", ret); return -EINVAL; } -- cgit From e474e7fd404b9e516f1c90a1c3f485e21be34c15 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Tue, 10 Feb 2015 23:03:15 -0600 Subject: ALSA: line6: Return EIO if read/write not successful Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index f2ee8046271a..6c2d418b53f1 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -349,7 +349,7 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, dev_err(line6->ifcdev, "length mismatch (expected %d, got %d)\n", (int)datalen, (int)len); - return -EINVAL; + return -EIO; } /* receive the result: */ @@ -415,7 +415,7 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data, return -EIO; } else if (status != 0) { dev_err(line6->ifcdev, "write failed (error %d)\n", ret); - return -EINVAL; + return -EIO; } return 0; -- cgit From 12b00157fd8572ee1f54b70bbf496641a1608924 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Tue, 10 Feb 2015 23:03:16 -0600 Subject: ALSA: line6: Use explicit type for serial number The serial number (aka ESN) is a 32-bit value. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 2 +- sound/usb/line6/driver.h | 2 +- sound/usb/line6/pod.c | 4 ++-- sound/usb/line6/toneport.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 6c2d418b53f1..99b63a7902f3 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -426,7 +426,7 @@ EXPORT_SYMBOL_GPL(line6_write_data); Read Line 6 device serial number. (POD, TonePort, GuitarPort) */ -int line6_read_serial_number(struct usb_line6 *line6, int *serial_number) +int line6_read_serial_number(struct usb_line6 *line6, u32 *serial_number) { return line6_read_data(line6, 0x80d0, serial_number, sizeof(*serial_number)); diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h index 92a662a0469e..5d20294d64f4 100644 --- a/sound/usb/line6/driver.h +++ b/sound/usb/line6/driver.h @@ -150,7 +150,7 @@ extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, extern int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen); extern int line6_read_serial_number(struct usb_line6 *line6, - int *serial_number); + u32 *serial_number); extern int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, int size); extern int line6_send_sysex_message(struct usb_line6 *line6, diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index 09017bc9615b..daf81d169a42 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -73,7 +73,7 @@ struct usb_line6_pod { int startup_progress; /* Serial number of device */ - int serial_number; + u32 serial_number; /* Firmware version (x 100) */ int firmware_version; @@ -247,7 +247,7 @@ static ssize_t serial_number_show(struct device *dev, struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); - return sprintf(buf, "%d\n", pod->serial_number); + return sprintf(buf, "%u\n", pod->serial_number); } /* diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index 1a0a485b6654..ddf7368c2001 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -49,7 +49,7 @@ struct usb_line6_toneport { int source; /* Serial number of device */ - int serial_number; + u32 serial_number; /* Firmware version (x 100) */ int firmware_version; -- cgit From 0e806151e86be52caa1349fa490eab8f09a2b6f5 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Tue, 10 Feb 2015 23:03:17 -0600 Subject: ALSA: line6: toneport: Use explicit type for firmware version The firmware version is a single byte so have the variable type agree. Since the address to this member is passed to the read function, using an int is not even portable. Signed-off-by: Chris Rorvick Signed-off-by: Takashi Iwai --- sound/usb/line6/toneport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index ddf7368c2001..6d4c50c9b17d 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -52,7 +52,7 @@ struct usb_line6_toneport { u32 serial_number; /* Firmware version (x 100) */ - int firmware_version; + u8 firmware_version; /* Timer for delayed PCM startup */ struct timer_list timer; -- cgit