[alsa-devel] [PATCH 00/10] ASoC: remove old platform/codec code
Hi Mark
We are now using component base ASoC. Thus, old platform/codec code are no longer needed. These removes it.
Then, I very surprised that platform code was already removed :) But, it seems this patch didn't care about documentation and platform specific callback (= .pcm_new/free). 4), 7) handle it.
One concern is that it completely removed "platform_list_show" for debugfs. But, I think we want to keep it as "component_list_show" (My original patch did it). 6) reborned it.
8) - 10) are cleanup which can be done *after* removing platform/codec.
Kuninori Morimoto (10): 1) ASoC: remove codec hw_write/control_data 2) ASoC: remove codec reg_cache 3) ASoC: remove .get_regmap 4) ASoC: remove unneeded .pcm_new/free 5) ASoC: remove Codec related code 6) ASoC: add component_list_show() 7) ASoC: convert platform explanation to component 8) ASoC: soc.h: merge CONFIG_DEBUG_FS 9) ASoC: soc-core: remove snd_soc_component_add_unlocked() 10) ASoC: soc-core: remove legacy_dai_naming from snd_soc_register_dais()
Documentation/sound/soc/platform.rst | 30 +- include/sound/soc-dai.h | 1 - include/sound/soc.h | 289 +---------------- sound/soc/Makefile | 2 +- sound/soc/soc-cache.c | 53 ---- sound/soc/soc-core.c | 585 ++--------------------------------- sound/soc/soc-io.c | 62 ---- sound/soc/soc-jack.c | 22 -- sound/soc/soc-pcm.c | 13 +- 9 files changed, 50 insertions(+), 1007 deletions(-) delete mode 100644 sound/soc/soc-cache.c
Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
No one is using codec hw_write/control_data any more. Let's remove these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 2 -- 1 file changed, 2 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 9ea99e5..0e1cb84 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -932,8 +932,6 @@ struct snd_soc_codec { unsigned int cache_init:1; /* codec cache has been initialized */
/* codec IO */ - void *control_data; /* codec control (i2c/3wire) data */ - hw_write_t hw_write; void *reg_cache;
/* component */
On Tue, May 08, 2018 at 03:18:11AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
No one is using codec hw_write/control_data any more. Let's remove these.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Codec reg_cache is legacy feature, almost all driver are now using common regmap, and very few driver had been used this legacy feature. Because of this background, it is now implemented on each driver internally now. So now, no one is using codec reg_cache. Let's remove it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 13 ---- sound/soc/Makefile | 2 +- sound/soc/soc-cache.c | 53 ------------- sound/soc/soc-core.c | 207 -------------------------------------------------- 4 files changed, 1 insertion(+), 274 deletions(-) delete mode 100644 sound/soc/soc-cache.c
diff --git a/include/sound/soc.h b/include/sound/soc.h index 0e1cb84..7233d3a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -471,8 +471,6 @@ int devm_snd_soc_register_component(struct device *dev, void snd_soc_unregister_component(struct device *dev); struct snd_soc_component *snd_soc_lookup_component(struct device *dev, const char *driver_name); -int snd_soc_cache_init(struct snd_soc_codec *codec); -int snd_soc_cache_exit(struct snd_soc_codec *codec);
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); #ifdef CONFIG_SND_SOC_COMPRESS @@ -904,7 +902,6 @@ struct snd_soc_component { int (*init)(struct snd_soc_component *component);
#ifdef CONFIG_DEBUG_FS - void (*init_debugfs)(struct snd_soc_component *component); const char *debugfs_prefix; #endif }; @@ -928,12 +925,6 @@ struct snd_soc_codec {
struct list_head list;
- /* runtime */ - unsigned int cache_init:1; /* codec cache has been initialized */ - - /* codec IO */ - void *reg_cache; - /* component */ struct snd_soc_component component; }; @@ -960,10 +951,6 @@ struct snd_soc_codec_driver { struct regmap *(*get_regmap)(struct device *); unsigned int (*read)(struct snd_soc_codec *, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); - unsigned int reg_cache_size; - short reg_cache_step; - short reg_word_size; - const void *reg_cache_default;
/* codec bias level */ int (*set_bias_level)(struct snd_soc_codec *, diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 8d92492..06389a5 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o +snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-utils.o snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c deleted file mode 100644 index 07f4335..0000000 --- a/sound/soc/soc-cache.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * soc-cache.c -- ASoC register cache helpers - * - * Copyright 2009 Wolfson Microelectronics PLC. - * - * Author: Mark Brown broonie@opensource.wolfsonmicro.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; either version 2 of the License, or (at your - * option) any later version. - */ - -#include <sound/soc.h> -#include <linux/export.h> -#include <linux/slab.h> - -int snd_soc_cache_init(struct snd_soc_codec *codec) -{ - const struct snd_soc_codec_driver *codec_drv = codec->driver; - size_t reg_size; - - reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; - - if (!reg_size) - return 0; - - dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", - codec->component.name); - - if (codec_drv->reg_cache_default) - codec->reg_cache = kmemdup(codec_drv->reg_cache_default, - reg_size, GFP_KERNEL); - else - codec->reg_cache = kzalloc(reg_size, GFP_KERNEL); - if (!codec->reg_cache) - return -ENOMEM; - - return 0; -} - -/* - * NOTE: keep in mind that this function might be called - * multiple times. - */ -int snd_soc_cache_exit(struct snd_soc_codec *codec) -{ - dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n", - codec->component.name); - kfree(codec->reg_cache); - codec->reg_cache = NULL; - return 0; -} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4b068cc..9608116 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -82,98 +82,6 @@ NULL, /* terminator */ };
-/* returns the minimum number of bytes needed to represent - * a particular given value */ -static int min_bytes_needed(unsigned long val) -{ - int c = 0; - int i; - - for (i = (sizeof val * 8) - 1; i >= 0; --i, ++c) - if (val & (1UL << i)) - break; - c = (sizeof val * 8) - c; - if (!c || (c % 8)) - c = (c + 8) / 8; - else - c /= 8; - return c; -} - -/* fill buf which is 'len' bytes with a formatted - * string of the form 'reg: value\n' */ -static int format_register_str(struct snd_soc_codec *codec, - unsigned int reg, char *buf, size_t len) -{ - int wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2; - int regsize = codec->driver->reg_word_size * 2; - int ret; - - /* +2 for ': ' and + 1 for '\n' */ - if (wordsize + regsize + 2 + 1 != len) - return -EINVAL; - - sprintf(buf, "%.*x: ", wordsize, reg); - buf += wordsize + 2; - - ret = snd_soc_read(codec, reg); - if (ret < 0) - memset(buf, 'X', regsize); - else - sprintf(buf, "%.*x", regsize, ret); - buf[regsize] = '\n'; - /* no NUL-termination needed */ - return 0; -} - -/* codec register dump */ -static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf, - size_t count, loff_t pos) -{ - int i, step = 1; - int wordsize, regsize; - int len; - size_t total = 0; - loff_t p = 0; - - wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2; - regsize = codec->driver->reg_word_size * 2; - - len = wordsize + regsize + 2 + 1; - - if (!codec->driver->reg_cache_size) - return 0; - - if (codec->driver->reg_cache_step) - step = codec->driver->reg_cache_step; - - for (i = 0; i < codec->driver->reg_cache_size; i += step) { - /* only support larger than PAGE_SIZE bytes debugfs - * entries for the default case */ - if (p >= pos) { - if (total + len >= count - 1) - break; - format_register_str(codec, i, buf + total, len); - total += len; - } - p += len; - } - - total = min(total, count - 1); - - return total; -} - -static ssize_t codec_reg_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); - - return soc_codec_reg_show(rtd->codec, buf, PAGE_SIZE, 0); -} - -static DEVICE_ATTR_RO(codec_reg); - static ssize_t pmdown_time_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -199,7 +107,6 @@ 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 }; @@ -232,71 +139,6 @@ static umode_t soc_dev_attr_is_visible(struct kobject *kobj, };
#ifdef CONFIG_DEBUG_FS -static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - ssize_t ret; - struct snd_soc_codec *codec = file->private_data; - char *buf; - - if (*ppos < 0 || !count) - return -EINVAL; - - buf = kmalloc(count, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - ret = soc_codec_reg_show(codec, buf, count, *ppos); - if (ret >= 0) { - if (copy_to_user(user_buf, buf, ret)) { - kfree(buf); - return -EFAULT; - } - *ppos += ret; - } - - kfree(buf); - return ret; -} - -static ssize_t codec_reg_write_file(struct file *file, - const char __user *user_buf, size_t count, loff_t *ppos) -{ - char buf[32]; - size_t buf_size; - char *start = buf; - unsigned long reg, value; - struct snd_soc_codec *codec = file->private_data; - int ret; - - buf_size = min(count, (sizeof(buf)-1)); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - buf[buf_size] = 0; - - while (*start == ' ') - start++; - reg = simple_strtoul(start, &start, 16); - while (*start == ' ') - start++; - ret = kstrtoul(start, 16, &value); - if (ret) - return ret; - - /* Userspace has been fiddling around behind the kernel's back */ - add_taint(TAINT_USER, LOCKDEP_NOW_UNRELIABLE); - - snd_soc_write(codec, reg, value); - return buf_size; -} - -static const struct file_operations codec_reg_fops = { - .open = simple_open, - .read = codec_reg_read_file, - .write = codec_reg_write_file, - .llseek = default_llseek, -}; - static void soc_init_component_debugfs(struct snd_soc_component *component) { if (!component->card->debugfs_card_root) @@ -325,9 +167,6 @@ static void soc_init_component_debugfs(struct snd_soc_component *component)
snd_soc_dapm_debugfs_init(snd_soc_component_get_dapm(component), component->debugfs_root); - - if (component->init_debugfs) - component->init_debugfs(component); }
static void soc_cleanup_component_debugfs(struct snd_soc_component *component) @@ -335,19 +174,6 @@ static void soc_cleanup_component_debugfs(struct snd_soc_component *component) debugfs_remove_recursive(component->debugfs_root); }
-static void soc_init_codec_debugfs(struct snd_soc_component *component) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - struct dentry *debugfs_reg; - - debugfs_reg = debugfs_create_file("codec_reg", 0644, - codec->component.debugfs_root, - codec, &codec_reg_fops); - if (!debugfs_reg) - dev_warn(codec->dev, - "ASoC: Failed to create codec register debugfs file\n"); -} - static int codec_list_show(struct seq_file *m, void *v) { struct snd_soc_codec *codec; @@ -431,8 +257,6 @@ static void snd_soc_debugfs_exit(void)
#else
-#define soc_init_codec_debugfs NULL - static inline void soc_init_component_debugfs( struct snd_soc_component *component) { @@ -1805,24 +1629,6 @@ static void soc_remove_aux_devices(struct snd_soc_card *card) } }
-static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) -{ - int ret; - - if (codec->cache_init) - return 0; - - ret = snd_soc_cache_init(codec); - if (ret < 0) { - dev_err(codec->dev, - "ASoC: Failed to set cache compression type: %d\n", - ret); - return ret; - } - codec->cache_init = 1; - 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 @@ -2045,7 +1851,6 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
static int snd_soc_instantiate_card(struct snd_soc_card *card) { - struct snd_soc_codec *codec; struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; int ret, i, order; @@ -2071,15 +1876,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) for (i = 0; i < card->num_links; i++) snd_soc_add_dai_link(card, card->dai_link+i);
- /* initialize the register cache for each available codec */ - list_for_each_entry(codec, &codec_list, list) { - if (codec->cache_init) - continue; - ret = snd_soc_init_codec_cache(codec); - if (ret < 0) - goto base_error; - } - /* card bind complete so register a sound card */ ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, card->owner, 0, &card->snd_card); @@ -3591,10 +3387,8 @@ int snd_soc_register_codec(struct device *dev, dapm->set_bias_level = snd_soc_codec_set_bias_level; codec->dev = dev; codec->driver = codec_drv; - codec->component.val_bytes = codec_drv->reg_word_size;
#ifdef CONFIG_DEBUG_FS - codec->component.init_debugfs = soc_init_codec_debugfs; codec->component.debugfs_prefix = "codec"; #endif
@@ -3658,7 +3452,6 @@ void snd_soc_unregister_codec(struct device *dev) codec->component.name);
snd_soc_component_cleanup(&codec->component); - snd_soc_cache_exit(codec); kfree(codec); } EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
On Tue, May 08, 2018 at 03:18:38AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Codec reg_cache is legacy feature, almost all driver are now using common regmap, and very few driver had been used this legacy feature. Because of this background, it is now implemented on each driver internally now. So now, no one is using codec reg_cache. Let's remove it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
The patch
ASoC: remove codec reg_cache
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From d1021c88526273644a711d481fd1117a67b6ae20 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 8 May 2018 03:18:38 +0000 Subject: [PATCH] ASoC: remove codec reg_cache
Codec reg_cache is legacy feature, almost all driver are now using common regmap, and very few driver had been used this legacy feature. Because of this background, it is now implemented on each driver internally now. So now, no one is using codec reg_cache. Let's remove it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/soc.h | 13 --- sound/soc/Makefile | 2 +- sound/soc/soc-cache.c | 53 ----------- sound/soc/soc-core.c | 207 ------------------------------------------ 4 files changed, 1 insertion(+), 274 deletions(-) delete mode 100644 sound/soc/soc-cache.c
diff --git a/include/sound/soc.h b/include/sound/soc.h index 0e1cb847f8f8..7233d3a206b2 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -471,8 +471,6 @@ int devm_snd_soc_register_component(struct device *dev, void snd_soc_unregister_component(struct device *dev); struct snd_soc_component *snd_soc_lookup_component(struct device *dev, const char *driver_name); -int snd_soc_cache_init(struct snd_soc_codec *codec); -int snd_soc_cache_exit(struct snd_soc_codec *codec);
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); #ifdef CONFIG_SND_SOC_COMPRESS @@ -904,7 +902,6 @@ struct snd_soc_component { int (*init)(struct snd_soc_component *component);
#ifdef CONFIG_DEBUG_FS - void (*init_debugfs)(struct snd_soc_component *component); const char *debugfs_prefix; #endif }; @@ -928,12 +925,6 @@ struct snd_soc_codec {
struct list_head list;
- /* runtime */ - unsigned int cache_init:1; /* codec cache has been initialized */ - - /* codec IO */ - void *reg_cache; - /* component */ struct snd_soc_component component; }; @@ -960,10 +951,6 @@ struct snd_soc_codec_driver { struct regmap *(*get_regmap)(struct device *); unsigned int (*read)(struct snd_soc_codec *, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); - unsigned int reg_cache_size; - short reg_cache_step; - short reg_word_size; - const void *reg_cache_default;
/* codec bias level */ int (*set_bias_level)(struct snd_soc_codec *, diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 8d92492183d2..06389a5385d7 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o +snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-utils.o snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c deleted file mode 100644 index 07f43356f963..000000000000 --- a/sound/soc/soc-cache.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * soc-cache.c -- ASoC register cache helpers - * - * Copyright 2009 Wolfson Microelectronics PLC. - * - * Author: Mark Brown broonie@opensource.wolfsonmicro.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; either version 2 of the License, or (at your - * option) any later version. - */ - -#include <sound/soc.h> -#include <linux/export.h> -#include <linux/slab.h> - -int snd_soc_cache_init(struct snd_soc_codec *codec) -{ - const struct snd_soc_codec_driver *codec_drv = codec->driver; - size_t reg_size; - - reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; - - if (!reg_size) - return 0; - - dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", - codec->component.name); - - if (codec_drv->reg_cache_default) - codec->reg_cache = kmemdup(codec_drv->reg_cache_default, - reg_size, GFP_KERNEL); - else - codec->reg_cache = kzalloc(reg_size, GFP_KERNEL); - if (!codec->reg_cache) - return -ENOMEM; - - return 0; -} - -/* - * NOTE: keep in mind that this function might be called - * multiple times. - */ -int snd_soc_cache_exit(struct snd_soc_codec *codec) -{ - dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n", - codec->component.name); - kfree(codec->reg_cache); - codec->reg_cache = NULL; - return 0; -} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4b068ccf4e13..96081160fd24 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -82,98 +82,6 @@ static const char * const dmi_blacklist[] = { NULL, /* terminator */ };
-/* returns the minimum number of bytes needed to represent - * a particular given value */ -static int min_bytes_needed(unsigned long val) -{ - int c = 0; - int i; - - for (i = (sizeof val * 8) - 1; i >= 0; --i, ++c) - if (val & (1UL << i)) - break; - c = (sizeof val * 8) - c; - if (!c || (c % 8)) - c = (c + 8) / 8; - else - c /= 8; - return c; -} - -/* fill buf which is 'len' bytes with a formatted - * string of the form 'reg: value\n' */ -static int format_register_str(struct snd_soc_codec *codec, - unsigned int reg, char *buf, size_t len) -{ - int wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2; - int regsize = codec->driver->reg_word_size * 2; - int ret; - - /* +2 for ': ' and + 1 for '\n' */ - if (wordsize + regsize + 2 + 1 != len) - return -EINVAL; - - sprintf(buf, "%.*x: ", wordsize, reg); - buf += wordsize + 2; - - ret = snd_soc_read(codec, reg); - if (ret < 0) - memset(buf, 'X', regsize); - else - sprintf(buf, "%.*x", regsize, ret); - buf[regsize] = '\n'; - /* no NUL-termination needed */ - return 0; -} - -/* codec register dump */ -static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf, - size_t count, loff_t pos) -{ - int i, step = 1; - int wordsize, regsize; - int len; - size_t total = 0; - loff_t p = 0; - - wordsize = min_bytes_needed(codec->driver->reg_cache_size) * 2; - regsize = codec->driver->reg_word_size * 2; - - len = wordsize + regsize + 2 + 1; - - if (!codec->driver->reg_cache_size) - return 0; - - if (codec->driver->reg_cache_step) - step = codec->driver->reg_cache_step; - - for (i = 0; i < codec->driver->reg_cache_size; i += step) { - /* only support larger than PAGE_SIZE bytes debugfs - * entries for the default case */ - if (p >= pos) { - if (total + len >= count - 1) - break; - format_register_str(codec, i, buf + total, len); - total += len; - } - p += len; - } - - total = min(total, count - 1); - - return total; -} - -static ssize_t codec_reg_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); - - return soc_codec_reg_show(rtd->codec, buf, PAGE_SIZE, 0); -} - -static DEVICE_ATTR_RO(codec_reg); - static ssize_t pmdown_time_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -199,7 +107,6 @@ 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 }; @@ -232,71 +139,6 @@ static const struct attribute_group *soc_dev_attr_groups[] = { };
#ifdef CONFIG_DEBUG_FS -static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - ssize_t ret; - struct snd_soc_codec *codec = file->private_data; - char *buf; - - if (*ppos < 0 || !count) - return -EINVAL; - - buf = kmalloc(count, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - ret = soc_codec_reg_show(codec, buf, count, *ppos); - if (ret >= 0) { - if (copy_to_user(user_buf, buf, ret)) { - kfree(buf); - return -EFAULT; - } - *ppos += ret; - } - - kfree(buf); - return ret; -} - -static ssize_t codec_reg_write_file(struct file *file, - const char __user *user_buf, size_t count, loff_t *ppos) -{ - char buf[32]; - size_t buf_size; - char *start = buf; - unsigned long reg, value; - struct snd_soc_codec *codec = file->private_data; - int ret; - - buf_size = min(count, (sizeof(buf)-1)); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - buf[buf_size] = 0; - - while (*start == ' ') - start++; - reg = simple_strtoul(start, &start, 16); - while (*start == ' ') - start++; - ret = kstrtoul(start, 16, &value); - if (ret) - return ret; - - /* Userspace has been fiddling around behind the kernel's back */ - add_taint(TAINT_USER, LOCKDEP_NOW_UNRELIABLE); - - snd_soc_write(codec, reg, value); - return buf_size; -} - -static const struct file_operations codec_reg_fops = { - .open = simple_open, - .read = codec_reg_read_file, - .write = codec_reg_write_file, - .llseek = default_llseek, -}; - static void soc_init_component_debugfs(struct snd_soc_component *component) { if (!component->card->debugfs_card_root) @@ -325,9 +167,6 @@ static void soc_init_component_debugfs(struct snd_soc_component *component)
snd_soc_dapm_debugfs_init(snd_soc_component_get_dapm(component), component->debugfs_root); - - if (component->init_debugfs) - component->init_debugfs(component); }
static void soc_cleanup_component_debugfs(struct snd_soc_component *component) @@ -335,19 +174,6 @@ static void soc_cleanup_component_debugfs(struct snd_soc_component *component) debugfs_remove_recursive(component->debugfs_root); }
-static void soc_init_codec_debugfs(struct snd_soc_component *component) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - struct dentry *debugfs_reg; - - debugfs_reg = debugfs_create_file("codec_reg", 0644, - codec->component.debugfs_root, - codec, &codec_reg_fops); - if (!debugfs_reg) - dev_warn(codec->dev, - "ASoC: Failed to create codec register debugfs file\n"); -} - static int codec_list_show(struct seq_file *m, void *v) { struct snd_soc_codec *codec; @@ -431,8 +257,6 @@ static void snd_soc_debugfs_exit(void)
#else
-#define soc_init_codec_debugfs NULL - static inline void soc_init_component_debugfs( struct snd_soc_component *component) { @@ -1805,24 +1629,6 @@ static void soc_remove_aux_devices(struct snd_soc_card *card) } }
-static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) -{ - int ret; - - if (codec->cache_init) - return 0; - - ret = snd_soc_cache_init(codec); - if (ret < 0) { - dev_err(codec->dev, - "ASoC: Failed to set cache compression type: %d\n", - ret); - return ret; - } - codec->cache_init = 1; - 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 @@ -2045,7 +1851,6 @@ EXPORT_SYMBOL_GPL(snd_soc_set_dmi_name);
static int snd_soc_instantiate_card(struct snd_soc_card *card) { - struct snd_soc_codec *codec; struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *dai_link; int ret, i, order; @@ -2071,15 +1876,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) for (i = 0; i < card->num_links; i++) snd_soc_add_dai_link(card, card->dai_link+i);
- /* initialize the register cache for each available codec */ - list_for_each_entry(codec, &codec_list, list) { - if (codec->cache_init) - continue; - ret = snd_soc_init_codec_cache(codec); - if (ret < 0) - goto base_error; - } - /* card bind complete so register a sound card */ ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, card->owner, 0, &card->snd_card); @@ -3591,10 +3387,8 @@ int snd_soc_register_codec(struct device *dev, dapm->set_bias_level = snd_soc_codec_set_bias_level; codec->dev = dev; codec->driver = codec_drv; - codec->component.val_bytes = codec_drv->reg_word_size;
#ifdef CONFIG_DEBUG_FS - codec->component.init_debugfs = soc_init_codec_debugfs; codec->component.debugfs_prefix = "codec"; #endif
@@ -3658,7 +3452,6 @@ void snd_soc_unregister_codec(struct device *dev) codec->component.name);
snd_soc_component_cleanup(&codec->component); - snd_soc_cache_exit(codec); kfree(codec); } EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
To setup regmap, ALSA SoC has snd_soc_component_init_regmap() and .get_regmap. But these are duplicated feature. Now, no one is using .get_regmap, let's remove it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 2 -- sound/soc/soc-core.c | 3 --- 2 files changed, 5 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 7233d3a..309bb70 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -947,8 +947,6 @@ struct snd_soc_codec_driver { int (*set_jack)(struct snd_soc_codec *codec, struct snd_soc_jack *jack, void *data);
- /* codec IO */ - struct regmap *(*get_regmap)(struct device *); unsigned int (*read)(struct snd_soc_codec *, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9608116..e5af15a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3392,9 +3392,6 @@ int snd_soc_register_codec(struct device *dev, codec->component.debugfs_prefix = "codec"; #endif
- if (codec_drv->get_regmap) - codec->component.regmap = codec_drv->get_regmap(dev); - for (i = 0; i < num_dai; i++) { convert_endianness_formats(&dai_drv[i].playback); convert_endianness_formats(&dai_drv[i].capture);
On Tue, May 08, 2018 at 03:19:16AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
To setup regmap, ALSA SoC has snd_soc_component_init_regmap() and .get_regmap. But these are duplicated feature. Now, no one is using .get_regmap, let's remove it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
commit ef050bece1b55 ("ASoC: Remove platform code now everything is componentised") removed platform code, but it didn't remove .pcm_new/free which existed only for platform. This patch remove these
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 2 -- sound/soc/soc-core.c | 18 ------------------ sound/soc/soc-pcm.c | 8 ++++---- 3 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 309bb70..1311855 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -886,8 +886,6 @@ struct snd_soc_component { void (*remove)(struct snd_soc_component *); int (*suspend)(struct snd_soc_component *); int (*resume)(struct snd_soc_component *); - int (*pcm_new)(struct snd_soc_component *, struct snd_soc_pcm_runtime *); - void (*pcm_free)(struct snd_soc_component *, struct snd_pcm *);
int (*set_sysclk)(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e5af15a..3b78868 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2943,22 +2943,6 @@ static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm, return component->driver->stream_event(component, event); }
-static int snd_soc_component_drv_pcm_new(struct snd_soc_component *component, - struct snd_soc_pcm_runtime *rtd) -{ - if (component->driver->pcm_new) - return component->driver->pcm_new(rtd); - - return 0; -} - -static void snd_soc_component_drv_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - if (component->driver->pcm_free) - component->driver->pcm_free(pcm); -} - static int snd_soc_component_set_bias_level(struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level) { @@ -2987,8 +2971,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, component->set_sysclk = component->driver->set_sysclk; component->set_pll = component->driver->set_pll; component->set_jack = component->driver->set_jack; - component->pcm_new = snd_soc_component_drv_pcm_new; - component->pcm_free = snd_soc_component_drv_pcm_free;
dapm = snd_soc_component_get_dapm(component); dapm->dev = dev; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index da5a2dc..3f63754 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2745,8 +2745,8 @@ static void soc_pcm_private_free(struct snd_pcm *pcm) for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
- if (component->pcm_free) - component->pcm_free(component, pcm); + if (component->driver->pcm_free) + component->driver->pcm_free(pcm); } }
@@ -3012,10 +3012,10 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
- if (!component->pcm_new) + if (!component->driver->pcm_new) continue;
- ret = component->pcm_new(component, rtd); + ret = component->driver->pcm_new(rtd); if (ret < 0) { dev_err(component->dev, "ASoC: pcm constructor failed: %d\n",
On Tue, May 08, 2018 at 03:19:49AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
commit ef050bece1b55 ("ASoC: Remove platform code now everything is componentised") removed platform code, but it didn't remove .pcm_new/free which existed only for platform. This patch remove these
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
The patch
ASoC: remove unneeded .pcm_new/free
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 11fb14f8c5b8f016ea0dae2237854331071cad42 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 8 May 2018 03:19:49 +0000 Subject: [PATCH] ASoC: remove unneeded .pcm_new/free
commit ef050bece1b55 ("ASoC: Remove platform code now everything is componentised") removed platform code, but it didn't remove .pcm_new/free which existed only for platform. This patch remove these
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/soc.h | 2 -- sound/soc/soc-core.c | 18 ------------------ sound/soc/soc-pcm.c | 8 ++++---- 3 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 309bb70bcb1e..131185563532 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -886,8 +886,6 @@ struct snd_soc_component { void (*remove)(struct snd_soc_component *); int (*suspend)(struct snd_soc_component *); int (*resume)(struct snd_soc_component *); - int (*pcm_new)(struct snd_soc_component *, struct snd_soc_pcm_runtime *); - void (*pcm_free)(struct snd_soc_component *, struct snd_pcm *);
int (*set_sysclk)(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e5af15aa1c28..3b78868969d5 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2943,22 +2943,6 @@ static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm, return component->driver->stream_event(component, event); }
-static int snd_soc_component_drv_pcm_new(struct snd_soc_component *component, - struct snd_soc_pcm_runtime *rtd) -{ - if (component->driver->pcm_new) - return component->driver->pcm_new(rtd); - - return 0; -} - -static void snd_soc_component_drv_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - if (component->driver->pcm_free) - component->driver->pcm_free(pcm); -} - static int snd_soc_component_set_bias_level(struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level) { @@ -2987,8 +2971,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, component->set_sysclk = component->driver->set_sysclk; component->set_pll = component->driver->set_pll; component->set_jack = component->driver->set_jack; - component->pcm_new = snd_soc_component_drv_pcm_new; - component->pcm_free = snd_soc_component_drv_pcm_free;
dapm = snd_soc_component_get_dapm(component); dapm->dev = dev; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index da5a2dcb6520..3f6375499102 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2745,8 +2745,8 @@ static void soc_pcm_private_free(struct snd_pcm *pcm) for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
- if (component->pcm_free) - component->pcm_free(component, pcm); + if (component->driver->pcm_free) + component->driver->pcm_free(pcm); } }
@@ -3012,10 +3012,10 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
- if (!component->pcm_new) + if (!component->driver->pcm_new) continue;
- ret = component->pcm_new(component, rtd); + ret = component->driver->pcm_new(rtd); if (ret < 0) { dev_err(component->dev, "ASoC: pcm constructor failed: %d\n",
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Now no one is using Codec related code. Let's remove all
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dai.h | 1 - include/sound/soc.h | 265 -------------------------------------- sound/soc/soc-core.c | 331 ++---------------------------------------------- sound/soc/soc-io.c | 62 --------- sound/soc/soc-jack.c | 22 ---- sound/soc/soc-pcm.c | 5 - 6 files changed, 11 insertions(+), 675 deletions(-)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 35ebb0b..568f6a7 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -313,7 +313,6 @@ struct snd_soc_dai { unsigned int sample_bits;
/* parent platform/codec */ - struct snd_soc_codec *codec; struct snd_soc_component *component;
/* CODEC TDM slot masks and params (for fixup) */ diff --git a/include/sound/soc.h b/include/sound/soc.h index 1311855..21861f3 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -402,8 +402,6 @@ enum snd_soc_bias_level { struct snd_soc_dai; struct snd_soc_dai_driver; struct snd_soc_dai_link; -struct snd_soc_codec; -struct snd_soc_codec_driver; struct snd_soc_component; struct snd_soc_component_driver; struct soc_enum; @@ -428,13 +426,6 @@ enum snd_soc_card_subclass { SND_SOC_CARD_CLASS_RUNTIME = 1, };
-int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, - int source, unsigned int freq, int dir); -int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, - unsigned int freq_in, unsigned int freq_out); -int snd_soc_codec_set_jack(struct snd_soc_codec *codec, - struct snd_soc_jack *jack, void *data); - int snd_soc_register_card(struct snd_soc_card *card); int snd_soc_unregister_card(struct snd_soc_card *card); int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card); @@ -453,10 +444,6 @@ static inline int snd_soc_resume(struct device *dev) } #endif int snd_soc_poweroff(struct device *dev); -int snd_soc_register_codec(struct device *dev, - const struct snd_soc_codec_driver *codec_drv, - struct snd_soc_dai_driver *dai_drv, int num_dai); -void snd_soc_unregister_codec(struct device *dev); int snd_soc_add_component(struct device *dev, struct snd_soc_component *component, const struct snd_soc_component_driver *component_driver, @@ -559,23 +546,7 @@ static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, } #endif
-/* codec register bit access */ -int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg, - unsigned int mask, unsigned int value); -int snd_soc_update_bits_locked(struct snd_soc_codec *codec, - unsigned int reg, unsigned int mask, - unsigned int value); -int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, - unsigned int mask, unsigned int value); - #ifdef CONFIG_SND_SOC_AC97_BUS -#define snd_soc_alloc_ac97_codec(codec) \ - snd_soc_alloc_ac97_component(&codec->component) -#define snd_soc_new_ac97_codec(codec, id, id_mask) \ - snd_soc_new_ac97_component(&codec->component, id, id_mask) -#define snd_soc_free_ac97_codec(ac97) \ - snd_soc_free_ac97_component(ac97) - struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component); struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, unsigned int id, unsigned int id_mask); @@ -609,8 +580,6 @@ struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, const char *name); int snd_soc_add_component_controls(struct snd_soc_component *component, const struct snd_kcontrol_new *controls, unsigned int num_controls); -int snd_soc_add_codec_controls(struct snd_soc_codec *codec, - const struct snd_kcontrol_new *controls, unsigned int num_controls); int snd_soc_add_card_controls(struct snd_soc_card *soc_card, const struct snd_kcontrol_new *controls, int num_controls); int snd_soc_add_dai_controls(struct snd_soc_dai *dai, @@ -843,8 +812,6 @@ struct snd_soc_component {
unsigned int active;
- unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ - unsigned int registered_as_component:1; unsigned int suspended:1; /* is in suspend PM state */
struct list_head list; @@ -856,9 +823,6 @@ struct snd_soc_component { struct list_head dai_list; int num_dai;
- int (*read)(struct snd_soc_component *, unsigned int, unsigned int *); - int (*write)(struct snd_soc_component *, unsigned int, unsigned int); - struct regmap *regmap; int val_bytes;
@@ -880,22 +844,6 @@ struct snd_soc_component { /* Don't use these, use snd_soc_component_get_dapm() */ struct snd_soc_dapm_context dapm;
- struct snd_soc_codec *codec; - - int (*probe)(struct snd_soc_component *); - void (*remove)(struct snd_soc_component *); - int (*suspend)(struct snd_soc_component *); - int (*resume)(struct snd_soc_component *); - - int (*set_sysclk)(struct snd_soc_component *component, - int clk_id, int source, unsigned int freq, int dir); - int (*set_pll)(struct snd_soc_component *component, int pll_id, - int source, unsigned int freq_in, unsigned int freq_out); - int (*set_jack)(struct snd_soc_component *component, - struct snd_soc_jack *jack, void *data); - int (*set_bias_level)(struct snd_soc_component *component, - enum snd_soc_bias_level level); - /* machine specific init */ int (*init)(struct snd_soc_component *component);
@@ -916,50 +864,6 @@ struct snd_soc_component* #define for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) \ list_for_each_entry_safe(rtdcom1, rtdcom2, &(rtd)->component_list, list)
-/* SoC Audio Codec device */ -struct snd_soc_codec { - struct device *dev; - const struct snd_soc_codec_driver *driver; - - struct list_head list; - - /* component */ - struct snd_soc_component component; -}; - -/* codec driver */ -struct snd_soc_codec_driver { - - /* driver ops */ - int (*probe)(struct snd_soc_codec *); - int (*remove)(struct snd_soc_codec *); - int (*suspend)(struct snd_soc_codec *); - int (*resume)(struct snd_soc_codec *); - struct snd_soc_component_driver component_driver; - - /* codec wide operations */ - int (*set_sysclk)(struct snd_soc_codec *codec, - int clk_id, int source, unsigned int freq, int dir); - int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, - unsigned int freq_in, unsigned int freq_out); - int (*set_jack)(struct snd_soc_codec *codec, - struct snd_soc_jack *jack, void *data); - - unsigned int (*read)(struct snd_soc_codec *, unsigned int); - int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); - - /* codec bias level */ - int (*set_bias_level)(struct snd_soc_codec *, - enum snd_soc_bias_level level); - bool idle_bias_off; - bool suspend_bias_off; - - void (*seq_notifier)(struct snd_soc_dapm_context *, - enum snd_soc_dapm_type, int); - - bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ -}; - struct snd_soc_dai_link_component { const char *name; struct device_node *of_node; @@ -1213,7 +1117,6 @@ struct snd_soc_pcm_runtime { /* runtime devices */ struct snd_pcm *pcm; struct snd_compr *compr; - struct snd_soc_codec *codec; struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai;
@@ -1282,19 +1185,6 @@ struct soc_enum { };
/** - * snd_soc_component_to_codec() - Casts a component to the CODEC it is embedded in - * @component: The component to cast to a CODEC - * - * This function must only be used on components that are known to be CODECs. - * Otherwise the behavior is undefined. - */ -static inline struct snd_soc_codec *snd_soc_component_to_codec( - struct snd_soc_component *component) -{ - return container_of(component, struct snd_soc_codec, component); -} - -/** * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is * embedded in * @dapm: The DAPM context to cast to the component @@ -1310,19 +1200,6 @@ static inline struct snd_soc_component *snd_soc_dapm_to_component( }
/** - * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in - * @dapm: The DAPM context to cast to the CODEC - * - * This function must only be used on DAPM contexts that are known to be part of - * a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined. - */ -static inline struct snd_soc_codec *snd_soc_dapm_to_codec( - struct snd_soc_dapm_context *dapm) -{ - return snd_soc_component_to_codec(snd_soc_dapm_to_component(dapm)); -} - -/** * snd_soc_component_get_dapm() - Returns the DAPM context associated with a * component * @component: The component for which to get the DAPM context @@ -1334,31 +1211,6 @@ static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm( }
/** - * snd_soc_codec_get_dapm() - Returns the DAPM context for the CODEC - * @codec: The CODEC for which to get the DAPM context - * - * Note: Use this function instead of directly accessing the CODEC's dapm field - */ -static inline struct snd_soc_dapm_context *snd_soc_codec_get_dapm( - struct snd_soc_codec *codec) -{ - return snd_soc_component_get_dapm(&codec->component); -} - -/** - * snd_soc_dapm_init_bias_level() - Initialize CODEC DAPM bias level - * @codec: The CODEC for which to initialize the DAPM bias level - * @level: The DAPM level to initialize to - * - * Initializes the CODEC DAPM bias level. See snd_soc_dapm_init_bias_level(). - */ -static inline void snd_soc_codec_init_bias_level(struct snd_soc_codec *codec, - enum snd_soc_bias_level level) -{ - snd_soc_dapm_init_bias_level(snd_soc_codec_get_dapm(codec), level); -} - -/** * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level * @component: The COMPONENT for which to initialize the DAPM bias level * @level: The DAPM level to initialize to @@ -1374,18 +1226,6 @@ static inline void snd_soc_codec_init_bias_level(struct snd_soc_codec *codec, }
/** - * snd_soc_dapm_get_bias_level() - Get current CODEC DAPM bias level - * @codec: The CODEC for which to get the DAPM bias level - * - * Returns: The current DAPM bias level of the CODEC. - */ -static inline enum snd_soc_bias_level snd_soc_codec_get_bias_level( - struct snd_soc_codec *codec) -{ - return snd_soc_dapm_get_bias_level(snd_soc_codec_get_dapm(codec)); -} - -/** * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level * @component: The COMPONENT for which to get the DAPM bias level * @@ -1399,21 +1239,6 @@ static inline enum snd_soc_bias_level snd_soc_codec_get_bias_level( }
/** - * snd_soc_codec_force_bias_level() - Set the CODEC DAPM bias level - * @codec: The CODEC for which to set the level - * @level: The level to set to - * - * Forces the CODEC bias level to a specific state. See - * snd_soc_dapm_force_bias_level(). - */ -static inline int snd_soc_codec_force_bias_level(struct snd_soc_codec *codec, - enum snd_soc_bias_level level) -{ - return snd_soc_dapm_force_bias_level(snd_soc_codec_get_dapm(codec), - level); -} - -/** * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level * @component: The COMPONENT for which to set the level * @level: The level to set to @@ -1431,19 +1256,6 @@ static inline int snd_soc_codec_force_bias_level(struct snd_soc_codec *codec, }
/** - * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol - * @kcontrol: The kcontrol - * - * This function must only be used on DAPM contexts that are known to be part of - * a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined. - */ -static inline struct snd_soc_codec *snd_soc_dapm_kcontrol_codec( - struct snd_kcontrol *kcontrol) -{ - return snd_soc_dapm_to_codec(snd_soc_dapm_kcontrol_dapm(kcontrol)); -} - -/** * snd_soc_dapm_kcontrol_component() - Returns the component associated to a kcontrol * @kcontrol: The kcontrol * @@ -1456,22 +1268,6 @@ static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component( return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol)); }
-/* codec IO */ -unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); -int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int val); - -/** - * snd_soc_cache_sync() - Sync the register cache with the hardware - * @codec: CODEC to sync - * - * Note: This function will call regcache_sync() - */ -static inline int snd_soc_cache_sync(struct snd_soc_codec *codec) -{ - return regcache_sync(codec->component.regmap); -} - /** * snd_soc_component_cache_sync() - Sync the register cache with the hardware * @component: COMPONENT to sync @@ -1514,37 +1310,6 @@ void snd_soc_component_init_regmap(struct snd_soc_component *component, struct regmap *regmap); void snd_soc_component_exit_regmap(struct snd_soc_component *component);
-/** - * snd_soc_codec_init_regmap() - Initialize regmap instance for the CODEC - * @codec: The CODEC for which to initialize the regmap instance - * @regmap: The regmap instance that should be used by the CODEC - * - * This function allows deferred assignment of the regmap instance that is - * associated with the CODEC. Only use this if the regmap instance is not yet - * ready when the CODEC is registered. The function must also be called before - * the first IO attempt of the CODEC. - */ -static inline void snd_soc_codec_init_regmap(struct snd_soc_codec *codec, - struct regmap *regmap) -{ - snd_soc_component_init_regmap(&codec->component, regmap); -} - -/** - * snd_soc_codec_exit_regmap() - De-initialize regmap instance for the CODEC - * @codec: The CODEC for which to de-initialize the regmap instance - * - * Calls regmap_exit() on the regmap instance associated to the CODEC and - * removes the regmap instance from the CODEC. - * - * This function should only be used if snd_soc_codec_init_regmap() was used to - * initialize the regmap instance. - */ -static inline void snd_soc_codec_exit_regmap(struct snd_soc_codec *codec) -{ - snd_soc_component_exit_regmap(&codec->component); -} - #endif
/* device driver data */ @@ -1571,17 +1336,6 @@ static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c) return dev_get_drvdata(c->dev); }
-static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, - void *data) -{ - snd_soc_component_set_drvdata(&codec->component, data); -} - -static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) -{ - return snd_soc_component_get_drvdata(&codec->component); -} - static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) { INIT_LIST_HEAD(&card->widgets); @@ -1633,11 +1387,6 @@ static inline bool snd_soc_component_is_active( return component->active != 0; }
-static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec) -{ - return snd_soc_component_is_active(&codec->component); -} - /** * snd_soc_kcontrol_component() - Returns the component that registered the * control @@ -1654,20 +1403,6 @@ static inline struct snd_soc_component *snd_soc_kcontrol_component( return snd_kcontrol_chip(kcontrol); }
-/** - * snd_soc_kcontrol_codec() - Returns the CODEC that registered the control - * @kcontrol: The control for which to get the CODEC - * - * Note: This function will only work correctly if the control has been - * registered with snd_soc_add_codec_controls() or via table based setup of - * snd_soc_codec_driver. Otherwise the behavior is undefined. - */ -static inline struct snd_soc_codec *snd_soc_kcontrol_codec( - struct snd_kcontrol *kcontrol) -{ - return snd_soc_component_to_codec(snd_soc_kcontrol_component(kcontrol)); -} - int snd_soc_util_init(void); void snd_soc_util_exit(void);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3b78868..a4cb141 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -56,7 +56,6 @@ #endif
static DEFINE_MUTEX(client_mutex); -static LIST_HEAD(codec_list); static LIST_HEAD(component_list);
/* @@ -174,21 +173,6 @@ static void soc_cleanup_component_debugfs(struct snd_soc_component *component) debugfs_remove_recursive(component->debugfs_root); }
-static int codec_list_show(struct seq_file *m, void *v) -{ - struct snd_soc_codec *codec; - - mutex_lock(&client_mutex); - - list_for_each_entry(codec, &codec_list, list) - seq_printf(m, "%s\n", codec->component.name); - - mutex_unlock(&client_mutex); - - return 0; -} -DEFINE_SHOW_ATTRIBUTE(codec_list); - static int dai_list_show(struct seq_file *m, void *v) { struct snd_soc_component *component; @@ -241,10 +225,6 @@ static void snd_soc_debugfs_init(void) return; }
- if (!debugfs_create_file("codecs", 0444, snd_soc_debugfs_root, NULL, - &codec_list_fops)) - pr_warn("ASoC: Failed to create CODEC list debugfs file\n"); - if (!debugfs_create_file("dais", 0444, snd_soc_debugfs_root, NULL, &dai_list_fops)) pr_warn("ASoC: Failed to create DAI list debugfs file\n"); @@ -536,8 +516,8 @@ int snd_soc_suspend(struct device *dev) }
case SND_SOC_BIAS_OFF: - if (component->suspend) - component->suspend(component); + if (component->driver->suspend) + component->driver->suspend(component); component->suspended = 1; if (component->regmap) regcache_mark_dirty(component->regmap); @@ -608,8 +588,8 @@ static void soc_resume_deferred(struct work_struct *work)
list_for_each_entry(component, &card->component_dev_list, card_list) { if (component->suspended) { - if (component->resume) - component->resume(component); + if (component->driver->resume) + component->driver->resume(component); component->suspended = 0; } } @@ -892,7 +872,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
/* Single codec links expect codec and codec_dai in runtime data */ rtd->codec_dai = codec_dais[0]; - rtd->codec = rtd->codec_dai->codec;
/* if there's no platform we match on the empty platform */ platform_name = dai_link->platform_name; @@ -931,8 +910,8 @@ static void soc_remove_component(struct snd_soc_component *component)
list_del(&component->card_list);
- if (component->remove) - component->remove(component); + if (component->driver->remove) + component->driver->remove(component);
snd_soc_dapm_free(snd_soc_component_get_dapm(component));
@@ -1271,8 +1250,8 @@ static int soc_probe_component(struct snd_soc_card *card, } }
- if (component->probe) { - ret = component->probe(component); + if (component->driver->probe) { + ret = component->driver->probe(component); if (ret < 0) { dev_err(component->dev, "ASoC: failed to probe component %d\n", ret); @@ -1663,8 +1642,7 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
/* Flip the polarity for the "CPU" end of a CODEC<->CODEC link */ /* the component which has non_legacy_dai_naming is Codec */ - if (cpu_dai->codec || - cpu_dai->component->driver->non_legacy_dai_naming) { + if (cpu_dai->component->driver->non_legacy_dai_naming) { unsigned int inv_dai_fmt;
inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK; @@ -2257,25 +2235,6 @@ int snd_soc_add_component_controls(struct snd_soc_component *component, EXPORT_SYMBOL_GPL(snd_soc_add_component_controls);
/** - * snd_soc_add_codec_controls - add an array of controls to a codec. - * Convenience function to add a list of controls. Many codecs were - * duplicating this code. - * - * @codec: codec to add controls to - * @controls: array of controls to add - * @num_controls: number of elements in the array - * - * Return 0 for success, else error. - */ -int snd_soc_add_codec_controls(struct snd_soc_codec *codec, - const struct snd_kcontrol_new *controls, unsigned int num_controls) -{ - return snd_soc_add_component_controls(&codec->component, controls, - num_controls); -} -EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); - -/** * snd_soc_add_card_controls - add an array of controls to a SoC card. * Convenience function to add a list of controls. * @@ -2336,27 +2295,6 @@ int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
/** - * snd_soc_codec_set_sysclk - configure CODEC system or master clock. - * @codec: CODEC - * @clk_id: DAI specific clock ID - * @source: Source for the clock - * @freq: new clock frequency in Hz - * @dir: new clock direction - input/output. - * - * Configures the CODEC master (MCLK) or system (SYSCLK) clocking. - */ -int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, - int source, unsigned int freq, int dir) -{ - if (codec->driver->set_sysclk) - return codec->driver->set_sysclk(codec, clk_id, source, - freq, dir); - else - return -ENOTSUPP; -} -EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk); - -/** * snd_soc_component_set_sysclk - configure COMPONENT system or master clock. * @component: COMPONENT * @clk_id: DAI specific clock ID @@ -2369,11 +2307,6 @@ int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, int snd_soc_component_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - /* will be removed */ - if (component->set_sysclk) - return component->set_sysclk(component, clk_id, source, - freq, dir); - if (component->driver->set_sysclk) return component->driver->set_sysclk(component, clk_id, source, freq, dir); @@ -2425,27 +2358,6 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
/* - * snd_soc_codec_set_pll - configure codec PLL. - * @codec: CODEC - * @pll_id: DAI specific PLL ID - * @source: DAI specific source for the PLL - * @freq_in: PLL input clock frequency in Hz - * @freq_out: requested PLL output clock frequency in Hz - * - * Configures and enables PLL to generate output clock based on input clock. - */ -int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, - unsigned int freq_in, unsigned int freq_out) -{ - if (codec->driver->set_pll) - return codec->driver->set_pll(codec, pll_id, source, - freq_in, freq_out); - else - return -EINVAL; -} -EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll); - -/* * snd_soc_component_set_pll - configure component PLL. * @component: COMPONENT * @pll_id: DAI specific PLL ID @@ -2459,11 +2371,6 @@ int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - /* will be removed */ - if (component->set_pll) - return component->set_pll(component, pll_id, source, - freq_in, freq_out); - if (component->driver->set_pll) return component->driver->set_pll(component, pll_id, source, freq_in, freq_out); @@ -2964,13 +2871,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
component->dev = dev; component->driver = driver; - component->probe = component->driver->probe; - component->remove = component->driver->remove; - component->suspend = component->driver->suspend; - component->resume = component->driver->resume; - component->set_sysclk = component->driver->set_sysclk; - component->set_pll = component->driver->set_pll; - component->set_jack = component->driver->set_jack;
dapm = snd_soc_component_get_dapm(component); dapm->dev = dev; @@ -3041,7 +2941,7 @@ void snd_soc_component_exit_regmap(struct snd_soc_component *component)
static void snd_soc_component_add_unlocked(struct snd_soc_component *component) { - if (!component->write && !component->read) { + if (!component->driver->write && !component->driver->read) { if (!component->regmap) component->regmap = dev_get_regmap(component->dev, NULL); if (component->regmap) @@ -3123,9 +3023,6 @@ int snd_soc_add_component(struct device *dev, if (ret) goto err_free;
- component->ignore_pmdown_time = true; - component->registered_as_component = true; - if (component_driver->endianness) { for (i = 0; i < num_dai; i++) { convert_endianness_formats(&dai_drv[i].playback); @@ -3180,8 +3077,7 @@ static int __snd_soc_unregister_component(struct device *dev)
mutex_lock(&client_mutex); list_for_each_entry(component, &component_list, list) { - if (dev != component->dev || - !component->registered_as_component) + if (dev != component->dev) continue;
snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); @@ -3230,211 +3126,6 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev, } EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
-static int snd_soc_codec_drv_probe(struct snd_soc_component *component) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - return codec->driver->probe(codec); -} - -static void snd_soc_codec_drv_remove(struct snd_soc_component *component) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - codec->driver->remove(codec); -} - -static int snd_soc_codec_drv_suspend(struct snd_soc_component *component) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - return codec->driver->suspend(codec); -} - -static int snd_soc_codec_drv_resume(struct snd_soc_component *component) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - return codec->driver->resume(codec); -} - -static int snd_soc_codec_drv_write(struct snd_soc_component *component, - unsigned int reg, unsigned int val) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - return codec->driver->write(codec, reg, val); -} - -static int snd_soc_codec_drv_read(struct snd_soc_component *component, - unsigned int reg, unsigned int *val) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - *val = codec->driver->read(codec, reg); - - return 0; -} - -static int snd_soc_codec_set_sysclk_(struct snd_soc_component *component, - int clk_id, int source, unsigned int freq, int dir) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - return snd_soc_codec_set_sysclk(codec, clk_id, source, freq, dir); -} - -static int snd_soc_codec_set_pll_(struct snd_soc_component *component, - int pll_id, int source, unsigned int freq_in, - unsigned int freq_out) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - return snd_soc_codec_set_pll(codec, pll_id, source, freq_in, freq_out); -} - -static int snd_soc_codec_set_jack_(struct snd_soc_component *component, - struct snd_soc_jack *jack, void *data) -{ - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - - return snd_soc_codec_set_jack(codec, jack, data); -} - -static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm, - enum snd_soc_bias_level level) -{ - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - - return codec->driver->set_bias_level(codec, level); -} - -/** - * snd_soc_register_codec - Register a codec with the ASoC core - * - * @dev: The parent device for this codec - * @codec_drv: Codec driver - * @dai_drv: The associated DAI driver - * @num_dai: Number of DAIs - */ -int snd_soc_register_codec(struct device *dev, - const struct snd_soc_codec_driver *codec_drv, - struct snd_soc_dai_driver *dai_drv, - int num_dai) -{ - struct snd_soc_dapm_context *dapm; - struct snd_soc_codec *codec; - struct snd_soc_dai *dai; - int ret, i; - - dev_dbg(dev, "codec register %s\n", dev_name(dev)); - - codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (codec == NULL) - return -ENOMEM; - - codec->component.codec = codec; - - ret = snd_soc_component_initialize(&codec->component, - &codec_drv->component_driver, dev); - if (ret) - goto err_free; - - if (codec_drv->probe) - codec->component.probe = snd_soc_codec_drv_probe; - if (codec_drv->remove) - codec->component.remove = snd_soc_codec_drv_remove; - if (codec_drv->suspend) - codec->component.suspend = snd_soc_codec_drv_suspend; - if (codec_drv->resume) - codec->component.resume = snd_soc_codec_drv_resume; - if (codec_drv->write) - codec->component.write = snd_soc_codec_drv_write; - if (codec_drv->read) - codec->component.read = snd_soc_codec_drv_read; - if (codec_drv->set_sysclk) - codec->component.set_sysclk = snd_soc_codec_set_sysclk_; - if (codec_drv->set_pll) - codec->component.set_pll = snd_soc_codec_set_pll_; - if (codec_drv->set_jack) - codec->component.set_jack = snd_soc_codec_set_jack_; - codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; - - dapm = snd_soc_codec_get_dapm(codec); - dapm->idle_bias_off = codec_drv->idle_bias_off; - dapm->suspend_bias_off = codec_drv->suspend_bias_off; - if (codec_drv->seq_notifier) - dapm->seq_notifier = codec_drv->seq_notifier; - if (codec_drv->set_bias_level) - dapm->set_bias_level = snd_soc_codec_set_bias_level; - codec->dev = dev; - codec->driver = codec_drv; - -#ifdef CONFIG_DEBUG_FS - codec->component.debugfs_prefix = "codec"; -#endif - - for (i = 0; i < num_dai; i++) { - convert_endianness_formats(&dai_drv[i].playback); - convert_endianness_formats(&dai_drv[i].capture); - } - - ret = snd_soc_register_dais(&codec->component, dai_drv, num_dai, false); - if (ret < 0) { - dev_err(dev, "ASoC: Failed to register DAIs: %d\n", ret); - goto err_cleanup; - } - - list_for_each_entry(dai, &codec->component.dai_list, list) - dai->codec = codec; - - mutex_lock(&client_mutex); - snd_soc_component_add_unlocked(&codec->component); - list_add(&codec->list, &codec_list); - mutex_unlock(&client_mutex); - - dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n", - codec->component.name); - return 0; - -err_cleanup: - snd_soc_component_cleanup(&codec->component); -err_free: - kfree(codec); - return ret; -} -EXPORT_SYMBOL_GPL(snd_soc_register_codec); - -/** - * snd_soc_unregister_codec - Unregister a codec from the ASoC core - * - * @dev: codec to unregister - */ -void snd_soc_unregister_codec(struct device *dev) -{ - struct snd_soc_codec *codec; - - mutex_lock(&client_mutex); - list_for_each_entry(codec, &codec_list, list) { - if (dev == codec->dev) - goto found; - } - mutex_unlock(&client_mutex); - return; - -found: - list_del(&codec->list); - snd_soc_component_del_unlocked(&codec->component); - mutex_unlock(&client_mutex); - - dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", - codec->component.name); - - snd_soc_component_cleanup(&codec->component); - kfree(codec); -} -EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); - /* Retrieve a card's name from device tree */ int snd_soc_of_parse_card_name(struct snd_soc_card *card, const char *propname) diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index c92a04b..026cd53 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -32,8 +32,6 @@ int snd_soc_component_read(struct snd_soc_component *component,
if (component->regmap) ret = regmap_read(component->regmap, reg, val); - else if (component->read) - ret = component->read(component, reg, val); else if (component->driver->read) { *val = component->driver->read(component, reg); ret = 0; @@ -72,8 +70,6 @@ int snd_soc_component_write(struct snd_soc_component *component, { if (component->regmap) return regmap_write(component->regmap, reg, val); - else if (component->write) - return component->write(component, reg, val); else if (component->driver->write) return component->driver->write(component, reg, val); else @@ -209,61 +205,3 @@ int snd_soc_component_test_bits(struct snd_soc_component *component, return old != new; } EXPORT_SYMBOL_GPL(snd_soc_component_test_bits); - -unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg) -{ - unsigned int val; - int ret; - - ret = snd_soc_component_read(&codec->component, reg, &val); - if (ret < 0) - return -1; - - return val; -} -EXPORT_SYMBOL_GPL(snd_soc_read); - -int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int val) -{ - return snd_soc_component_write(&codec->component, reg, val); -} -EXPORT_SYMBOL_GPL(snd_soc_write); - -/** - * snd_soc_update_bits - update codec register bits - * @codec: audio codec - * @reg: codec register - * @mask: register mask - * @value: new value - * - * Writes new register value. - * - * Returns 1 for change, 0 for no change, or negative error code. - */ -int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg, - unsigned int mask, unsigned int value) -{ - return snd_soc_component_update_bits(&codec->component, reg, mask, - value); -} -EXPORT_SYMBOL_GPL(snd_soc_update_bits); - -/** - * snd_soc_test_bits - test register for change - * @codec: audio codec - * @reg: codec register - * @mask: register mask - * @value: new value - * - * Tests a register with a new value and checks if the new value is - * different from the old value. - * - * Returns 1 for change else 0. - */ -int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, - unsigned int mask, unsigned int value) -{ - return snd_soc_component_test_bits(&codec->component, reg, mask, value); -} -EXPORT_SYMBOL_GPL(snd_soc_test_bits); diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 99902ae1..b2b16044 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -29,24 +29,6 @@ struct jack_gpio_tbl { };
/** - * snd_soc_codec_set_jack - configure codec jack. - * @codec: CODEC - * @jack: structure to use for the jack - * @data: can be used if codec driver need extra data for configuring jack - * - * Configures and enables jack detection function. - */ -int snd_soc_codec_set_jack(struct snd_soc_codec *codec, - struct snd_soc_jack *jack, void *data) -{ - if (codec->driver->set_jack) - return codec->driver->set_jack(codec, jack, data); - else - return -ENOTSUPP; -} -EXPORT_SYMBOL_GPL(snd_soc_codec_set_jack); - -/** * snd_soc_component_set_jack - configure component jack. * @component: COMPONENTs * @jack: structure to use for the jack @@ -57,10 +39,6 @@ int snd_soc_codec_set_jack(struct snd_soc_codec *codec, int snd_soc_component_set_jack(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { - /* will be removed */ - if (component->set_jack) - return component->set_jack(component, jack, data); - if (component->driver->set_jack) return component->driver->set_jack(component, jack, data);
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 3f63754..87c9af2 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -135,7 +135,6 @@ bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; - int i; bool ignore = true;
if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) @@ -147,10 +146,6 @@ bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) ignore &= !component->driver->use_pmdown_time; }
- /* this will be removed */ - for (i = 0; i < rtd->num_codecs; i++) - ignore &= rtd->codec_dais[i]->component->ignore_pmdown_time; - return ignore; }
On Tue, May 08, 2018 at 03:20:24AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Now no one is using Codec related code. Let's remove all
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
commit ef050bece1b55 ("ASoC: Remove platform code now everything is componentised") removed platform code, then platform_list_show() was removed, too. But we want to keep it as component_list_show. This patch add it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a4cb141..f22ef34 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -190,6 +190,21 @@ static int dai_list_show(struct seq_file *m, void *v) } DEFINE_SHOW_ATTRIBUTE(dai_list);
+static int component_list_show(struct seq_file *m, void *v) +{ + struct snd_soc_component *component; + + mutex_lock(&client_mutex); + + list_for_each_entry(component, &component_list, list) + seq_printf(m, "%s\n", component->name); + + mutex_unlock(&client_mutex); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(component_list); + static void soc_init_card_debugfs(struct snd_soc_card *card) { if (!snd_soc_debugfs_root) @@ -228,6 +243,10 @@ static void snd_soc_debugfs_init(void) if (!debugfs_create_file("dais", 0444, snd_soc_debugfs_root, NULL, &dai_list_fops)) pr_warn("ASoC: Failed to create DAI list debugfs file\n"); + + if (!debugfs_create_file("components", 0444, snd_soc_debugfs_root, NULL, + &component_list_fops)) + pr_warn("ASoC: Failed to create component list debugfs file\n"); }
static void snd_soc_debugfs_exit(void)
On Tue, May 08, 2018 at 03:21:00AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
commit ef050bece1b55 ("ASoC: Remove platform code now everything is componentised") removed platform code, then platform_list_show() was removed, too. But we want to keep it as component_list_show. This patch add it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
The patch
ASoC: add component_list_show()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From db795f9b924eaf9c86ff6ba025d7ae2f3457ef05 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 8 May 2018 03:21:00 +0000 Subject: [PATCH] ASoC: add component_list_show()
commit ef050bece1b55 ("ASoC: Remove platform code now everything is componentised") removed platform code, then platform_list_show() was removed, too. But we want to keep it as component_list_show. This patch add it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a4cb141b8f38..f22ef347eead 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -190,6 +190,21 @@ static int dai_list_show(struct seq_file *m, void *v) } DEFINE_SHOW_ATTRIBUTE(dai_list);
+static int component_list_show(struct seq_file *m, void *v) +{ + struct snd_soc_component *component; + + mutex_lock(&client_mutex); + + list_for_each_entry(component, &component_list, list) + seq_printf(m, "%s\n", component->name); + + mutex_unlock(&client_mutex); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(component_list); + static void soc_init_card_debugfs(struct snd_soc_card *card) { if (!snd_soc_debugfs_root) @@ -228,6 +243,10 @@ static void snd_soc_debugfs_init(void) if (!debugfs_create_file("dais", 0444, snd_soc_debugfs_root, NULL, &dai_list_fops)) pr_warn("ASoC: Failed to create DAI list debugfs file\n"); + + if (!debugfs_create_file("components", 0444, snd_soc_debugfs_root, NULL, + &component_list_fops)) + pr_warn("ASoC: Failed to create component list debugfs file\n"); }
static void snd_soc_debugfs_exit(void)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
commit ef050bece1b55 ("ASoC: Remove platform code now everything is componentised") removed platform code, but it didn't care about platform documentation. This patch convert platform explanation to component
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- Documentation/sound/soc/platform.rst | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/Documentation/sound/soc/platform.rst b/Documentation/sound/soc/platform.rst index d557490..cc81707 100644 --- a/Documentation/sound/soc/platform.rst +++ b/Documentation/sound/soc/platform.rst @@ -23,30 +23,26 @@ The platform DMA driver optionally supports the following ALSA operations:- };
The platform driver exports its DMA functionality via struct -snd_soc_platform_driver:- +snd_soc_component_driver:- ::
- struct snd_soc_platform_driver { - char *name; + struct snd_soc_component_driver { + const char *name;
- int (*probe)(struct platform_device *pdev); - int (*remove)(struct platform_device *pdev); - int (*suspend)(struct platform_device *pdev, struct snd_soc_cpu_dai *cpu_dai); - int (*resume)(struct platform_device *pdev, struct snd_soc_cpu_dai *cpu_dai); + ... + int (*probe)(struct snd_soc_component *); + void (*remove)(struct snd_soc_component *); + int (*suspend)(struct snd_soc_component *); + int (*resume)(struct snd_soc_component *);
/* pcm creation and destruction */ - int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *, struct snd_pcm *); + int (*pcm_new)(struct snd_soc_pcm_runtime *); void (*pcm_free)(struct snd_pcm *);
- /* - * For platform caused delay reporting. - * Optional. - */ - snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *, - struct snd_soc_dai *); - - /* platform stream ops */ - struct snd_pcm_ops *pcm_ops; + ... + const struct snd_pcm_ops *ops; + const struct snd_compr_ops *compr_ops; + ... };
Please refer to the ALSA driver documentation for details of audio DMA.
On Tue, May 08, 2018 at 03:21:24AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
commit ef050bece1b55 ("ASoC: Remove platform code now everything is componentised") removed platform code, but it didn't care about platform documentation. This patch convert platform explanation to component
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 21861f3..600a7eb 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -831,10 +831,6 @@ struct snd_soc_component { /* attached dynamic objects */ struct list_head dobj_list;
-#ifdef CONFIG_DEBUG_FS - struct dentry *debugfs_root; -#endif - /* * DO NOT use any of the fields below in drivers, they are temporary and * are going to be removed again soon. If you use them in driver code the @@ -848,6 +844,7 @@ struct snd_soc_component { int (*init)(struct snd_soc_component *component);
#ifdef CONFIG_DEBUG_FS + struct dentry *debugfs_root; const char *debugfs_prefix; #endif };
On Tue, May 08, 2018 at 03:21:46AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
The patch
ASoC: soc.h: merge CONFIG_DEBUG_FS
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From c8306238faf596ffdb01e5c96e0532be37a4a2a6 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 8 May 2018 03:21:46 +0000 Subject: [PATCH] ASoC: soc.h: merge CONFIG_DEBUG_FS
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com Signed-off-by: Mark Brown broonie@kernel.org --- include/sound/soc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 21861f366dcb..600a7ebd10c0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -831,10 +831,6 @@ struct snd_soc_component { /* attached dynamic objects */ struct list_head dobj_list;
-#ifdef CONFIG_DEBUG_FS - struct dentry *debugfs_root; -#endif - /* * DO NOT use any of the fields below in drivers, they are temporary and * are going to be removed again soon. If you use them in driver code the @@ -848,6 +844,7 @@ struct snd_soc_component { int (*init)(struct snd_soc_component *component);
#ifdef CONFIG_DEBUG_FS + struct dentry *debugfs_root; const char *debugfs_prefix; #endif };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
There is no user to call snd_soc_component_add_unlocked() anymore. Let's merge snd_soc_component_add_unlocked() and snd_soc_component_add().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index f22ef34..2d3abb3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2958,8 +2958,10 @@ void snd_soc_component_exit_regmap(struct snd_soc_component *component)
#endif
-static void snd_soc_component_add_unlocked(struct snd_soc_component *component) +static void snd_soc_component_add(struct snd_soc_component *component) { + mutex_lock(&client_mutex); + if (!component->driver->write && !component->driver->read) { if (!component->regmap) component->regmap = dev_get_regmap(component->dev, NULL); @@ -2969,12 +2971,7 @@ static void snd_soc_component_add_unlocked(struct snd_soc_component *component)
list_add(&component->list, &component_list); INIT_LIST_HEAD(&component->dobj_list); -}
-static void snd_soc_component_add(struct snd_soc_component *component) -{ - mutex_lock(&client_mutex); - snd_soc_component_add_unlocked(component); mutex_unlock(&client_mutex); }
On Tue, May 08, 2018 at 03:22:11AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
There is no user to call snd_soc_component_add_unlocked() anymore. Let's merge snd_soc_component_add_unlocked() and snd_soc_component_add().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
The patch
ASoC: soc-core: remove snd_soc_component_add_unlocked()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 359c71eeacbdd93d7870035af9a830140798fc67 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Tue, 8 May 2018 03:22:11 +0000 Subject: [PATCH] ASoC: soc-core: remove snd_soc_component_add_unlocked()
There is no user to call snd_soc_component_add_unlocked() anymore. Let's merge snd_soc_component_add_unlocked() and snd_soc_component_add().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index f22ef347eead..2d3abb3f1231 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2958,8 +2958,10 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
#endif
-static void snd_soc_component_add_unlocked(struct snd_soc_component *component) +static void snd_soc_component_add(struct snd_soc_component *component) { + mutex_lock(&client_mutex); + if (!component->driver->write && !component->driver->read) { if (!component->regmap) component->regmap = dev_get_regmap(component->dev, NULL); @@ -2969,12 +2971,7 @@ static void snd_soc_component_add_unlocked(struct snd_soc_component *component)
list_add(&component->list, &component_list); INIT_LIST_HEAD(&component->dobj_list); -}
-static void snd_soc_component_add(struct snd_soc_component *component) -{ - mutex_lock(&client_mutex); - snd_soc_component_add_unlocked(component); mutex_unlock(&client_mutex); }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
We can get legacy dai name flag from component driver. Thus, there is no need to have its parameter on snd_soc_register_dais(). Let's remove unneeded parameter
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2d3abb3..3d56f1f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2783,8 +2783,7 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component, * parent's name. */ static int snd_soc_register_dais(struct snd_soc_component *component, - struct snd_soc_dai_driver *dai_drv, size_t count, - bool legacy_dai_naming) + struct snd_soc_dai_driver *dai_drv, size_t count) { struct device *dev = component->dev; struct snd_soc_dai *dai; @@ -2796,7 +2795,7 @@ static int snd_soc_register_dais(struct snd_soc_component *component, for (i = 0; i < count; i++) {
dai = soc_add_dai(component, dai_drv + i, - count == 1 && legacy_dai_naming); + count == 1 && !component->driver->non_legacy_dai_naming); if (dai == NULL) { ret = -ENOMEM; goto err; @@ -3046,8 +3045,7 @@ int snd_soc_add_component(struct device *dev, } }
- ret = snd_soc_register_dais(component, dai_drv, num_dai, - !component_driver->non_legacy_dai_naming); + ret = snd_soc_register_dais(component, dai_drv, num_dai); if (ret < 0) { dev_err(dev, "ASoC: Failed to register DAIs: %d\n", ret); goto err_cleanup;
On Tue, May 08, 2018 at 03:23:01AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
We can get legacy dai name flag from component driver. Thus, there is no need to have its parameter on snd_soc_register_dais(). Let's remove unneeded parameter
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Reviewed-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
participants (3)
-
Charles Keepax
-
Kuninori Morimoto
-
Mark Brown