[alsa-devel] [PATCH 0/x][RFC] ASoC: replace codec/platform to component
Hi Mark
Finally, all prepare patch-set were accepted. These are [RFC] of codec/platform replace to component patch-set. It will be almost 200 patches in total. Thus, to avoid patch bomb (in case of rejection), I pickuped few patches and post these as [RFC].
Main is replacing codec/platform to component
xxx_codec_xxx() -> xxx_component_xxx() xxx_platform_xxx() -> xxx_component_xxx()
Note1 is that it is using devm_ version register function, and removed unregister from .remove (sometimes, removes .remove function itself)
- snd_soc_register_xxx() + devm_snd_soc_register_component() ... - snd_soc_unregister_xxx()
Note2 is that rtd->platform will be removed, thus it will be replaced to snd_soc_rtdcom_lookup() with driver name
- rtd->platform + snd_soc_rtdcom_lookup(rtd, DRV_NAME)
Note3 is that codec driver needs to have some flags which is needed for Codec
-static const struct snd_soc_codec_driver xxx_codec; +static const struct snd_soc_component_driver xxx_codec = { + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +};
here, .idle_bias_on was originally .idle_bias_off .pmdown_time was originally .ignore_pmdown_time .endianness is needed for Codec endianness check .non_legacy_dai_naming is needed for Codec DAI name matching
Note4 is that some driver is controlling CPU/Platform in one driver as 2 component. Now we can merge these into one component.
- snd_soc_register_platform(xxx) // for Platform - snd_soc_register_component(xxx) // for CPU + snd_soc_register_component(xxx) // for CPU/Platform
Note4 is that [1/x] patch which removes (!rtd->platform) check from soc-core is needed for all platforms. This check is no longer needed for component version.
If these [RFC] were OK, I will post all replacement patch-set. I think good timing to posting is around next -rc1 or merge-window
About removing all unneeded codec/platform patch-set, when is good timing ? +1 version: includes replacement patch-set +2 version: includes remove patch-set or +1 version: includes both replacement/remove patch-set
Best regards --- Kuninori Morimoto
Now, we are ready to replace rtd->platform to rtdcom list. From this patch, rtd->platform check is no longer needed. It will be replaced into rtdcom.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 5 ----- 1 file changed, 5 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 07881d8..83f3fe3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1190,11 +1190,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
rtd->platform = platform; } - if (!rtd->platform) { - dev_err(card->dev, "ASoC: platform %s not registered\n", - dai_link->platform_name); - goto _err_defer; - }
soc_add_pcm_runtime(card, rtd); return 0;
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index bcd3da2..e237858 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -284,7 +284,7 @@ static int dummy_dma_open(struct snd_pcm_substream *substream) .ioctl = snd_pcm_lib_ioctl, };
-static const struct snd_soc_platform_driver dummy_platform = { +static const struct snd_soc_component_driver dummy_platform = { .ops = &dummy_dma_ops, };
@@ -342,7 +342,8 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) if (ret < 0) return ret;
- ret = snd_soc_register_platform(&pdev->dev, &dummy_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, + NULL, 0); if (ret < 0) { snd_soc_unregister_codec(&pdev->dev); return ret; @@ -353,7 +354,6 @@ static int snd_soc_dummy_probe(struct platform_device *pdev)
static int snd_soc_dummy_remove(struct platform_device *pdev) { - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev);
return 0;
The patch
ASoC: soc-utils: replace platform to component
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 2d59ebd3e2531c48298e7bee6e621e04fccc4a72 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Mon, 29 Jan 2018 02:40:52 +0000 Subject: [PATCH] ASoC: soc-utils: replace platform to component
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/soc-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index bcd3da2739e2..e237858c9ed4 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -284,7 +284,7 @@ static const struct snd_pcm_ops dummy_dma_ops = { .ioctl = snd_pcm_lib_ioctl, };
-static const struct snd_soc_platform_driver dummy_platform = { +static const struct snd_soc_component_driver dummy_platform = { .ops = &dummy_dma_ops, };
@@ -342,7 +342,8 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) if (ret < 0) return ret;
- ret = snd_soc_register_platform(&pdev->dev, &dummy_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, + NULL, 0); if (ret < 0) { snd_soc_unregister_codec(&pdev->dev); return ret; @@ -353,7 +354,6 @@ static int snd_soc_dummy_probe(struct platform_device *pdev)
static int snd_soc_dummy_remove(struct platform_device *pdev) { - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev);
return 0;
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-generic-dmaengine-pcm.c | 51 ++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-)
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index d537864..804b654 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -24,6 +24,8 @@
#include <sound/dmaengine_pcm.h>
+#define DRV_NAME "snd_dmaengine_pcm" + /* * The platforms dmaengine driver does not support reporting the amount of * bytes that are still left to transfer. @@ -33,13 +35,13 @@ struct dmaengine_pcm { struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; const struct snd_dmaengine_pcm_config *config; - struct snd_soc_platform platform; + struct snd_soc_component component; unsigned int flags; };
-static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p) +static struct dmaengine_pcm *soc_component_to_pcm(struct snd_soc_component *p) { - return container_of(p, struct dmaengine_pcm, platform); + return container_of(p, struct dmaengine_pcm, component); }
static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, @@ -88,7 +90,8 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); int (*prepare_slave_config)(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, @@ -119,7 +122,8 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct device *dma_dev = dmaengine_dma_dev(pcm, substream); struct dma_chan *chan = pcm->chan[substream->stream]; struct snd_dmaengine_dai_dma_data *dma_data; @@ -206,7 +210,8 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea static int dmaengine_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = pcm->chan[substream->stream]; int ret;
@@ -221,7 +226,8 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( struct snd_soc_pcm_runtime *rtd, struct snd_pcm_substream *substream) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct snd_dmaengine_dai_dma_data *dma_data; dma_filter_fn fn = NULL;
@@ -260,9 +266,10 @@ static bool dmaengine_pcm_can_report_residue(struct device *dev,
static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); const struct snd_dmaengine_pcm_config *config = pcm->config; - struct device *dev = rtd->platform->dev; + struct device *dev = component->dev; struct snd_dmaengine_dai_dma_data *dma_data; struct snd_pcm_substream *substream; size_t prealloc_buffer_size; @@ -296,7 +303,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) }
if (!pcm->chan[i]) { - dev_err(rtd->platform->dev, + dev_err(component->dev, "Missing dma channel for stream: %d\n", i); return -EINVAL; } @@ -320,7 +327,8 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) return snd_dmaengine_pcm_pointer_no_residue(substream); @@ -338,10 +346,9 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( .pointer = dmaengine_pcm_pointer, };
-static const struct snd_soc_platform_driver dmaengine_pcm_platform = { - .component_driver = { - .probe_order = SND_SOC_COMP_ORDER_LATE, - }, +static const struct snd_soc_component_driver dmaengine_pcm_component = { + .name = DRV_NAME, + .probe_order = SND_SOC_COMP_ORDER_LATE, .ops = &dmaengine_pcm_ops, .pcm_new = dmaengine_pcm_new, }; @@ -438,8 +445,8 @@ int snd_dmaengine_pcm_register(struct device *dev, if (ret) goto err_free_dma;
- ret = snd_soc_add_platform(dev, &pcm->platform, - &dmaengine_pcm_platform); + ret = snd_soc_add_component(dev, &pcm->component, + &dmaengine_pcm_component, NULL, 0); if (ret) goto err_free_dma;
@@ -461,16 +468,16 @@ int snd_dmaengine_pcm_register(struct device *dev, */ void snd_dmaengine_pcm_unregister(struct device *dev) { - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct dmaengine_pcm *pcm;
- platform = snd_soc_lookup_platform(dev); - if (!platform) + component = snd_soc_lookup_component(dev, DRV_NAME); + if (!component) return;
- pcm = soc_platform_to_pcm(platform); + pcm = soc_component_to_pcm(component);
- snd_soc_remove_platform(platform); + snd_soc_unregister_component(dev); dmaengine_pcm_release_chan(pcm); kfree(pcm); }
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/intel/atom/sst-atom-controls.c | 36 +++++++++++------------ sound/soc/intel/atom/sst-mfld-platform-compress.c | 4 +-- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 32 ++++++-------------- sound/soc/intel/atom/sst-mfld-platform.h | 4 ++- 4 files changed, 32 insertions(+), 44 deletions(-)
diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c index 0f3604b..3672d36 100644 --- a/sound/soc/intel/atom/sst-atom-controls.c +++ b/sound/soc/intel/atom/sst-atom-controls.c @@ -1414,11 +1414,11 @@ static int sst_fill_module_list(struct snd_kcontrol *kctl, * name. First part of control name contains the pipe name (widget name). */ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, - struct snd_soc_platform *platform) + struct snd_soc_component *component) { struct snd_kcontrol *kctl; int index, ret = 0; - struct snd_card *card = platform->component.card->snd_card; + struct snd_card *card = component->card->snd_card; char *idx;
down_read(&card->controls_rwsem); @@ -1468,13 +1468,13 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, /** * sst_fill_linked_widgets - fill the parent pointer for the linked widget */ -static void sst_fill_linked_widgets(struct snd_soc_platform *platform, +static void sst_fill_linked_widgets(struct snd_soc_component *component, struct sst_ids *ids) { struct snd_soc_dapm_widget *w; unsigned int len = strlen(ids->parent_wname);
- list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (!strncmp(ids->parent_wname, w->name, len)) { ids->parent_w = w; break; @@ -1485,41 +1485,41 @@ static void sst_fill_linked_widgets(struct snd_soc_platform *platform, /** * sst_map_modules_to_pipe - fill algo/gains list for all pipes */ -static int sst_map_modules_to_pipe(struct snd_soc_platform *platform) +static int sst_map_modules_to_pipe(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; int ret = 0;
- list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_sst_dapm_widget(w) && (w->priv)) { struct sst_ids *ids = w->priv;
- dev_dbg(platform->dev, "widget type=%d name=%s\n", + dev_dbg(component->dev, "widget type=%d name=%s\n", w->id, w->name); INIT_LIST_HEAD(&ids->algo_list); INIT_LIST_HEAD(&ids->gain_list); - ret = sst_fill_widget_module_info(w, platform); + ret = sst_fill_widget_module_info(w, component);
if (ret < 0) return ret;
/* fill linked widgets */ if (ids->parent_wname != NULL) - sst_fill_linked_widgets(platform, ids); + sst_fill_linked_widgets(component, ids); } } return 0; }
-int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component) { int i, ret = 0; struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(&platform->component); - struct sst_data *drv = snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_dapm(component); + struct sst_data *drv = snd_soc_component_get_drvdata(component); unsigned int gains = ARRAY_SIZE(sst_gain_controls)/3;
- drv->byte_stream = devm_kzalloc(platform->dev, + drv->byte_stream = devm_kzalloc(component->dev, SST_MAX_BIN_BYTES, GFP_KERNEL); if (!drv->byte_stream) return -ENOMEM; @@ -1537,26 +1537,26 @@ int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) sst_gains[i].ramp_duration = SST_GAIN_RAMP_DURATION_DEFAULT; }
- ret = snd_soc_add_platform_controls(platform, sst_gain_controls, + ret = snd_soc_add_component_controls(component, sst_gain_controls, ARRAY_SIZE(sst_gain_controls)); if (ret) return ret;
/* Initialize algo control params */ - ret = sst_algo_control_init(platform->dev); + ret = sst_algo_control_init(component->dev); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_algo_controls, + ret = snd_soc_add_component_controls(component, sst_algo_controls, ARRAY_SIZE(sst_algo_controls)); if (ret) return ret;
- ret = snd_soc_add_platform_controls(platform, sst_slot_controls, + ret = snd_soc_add_component_controls(component, sst_slot_controls, ARRAY_SIZE(sst_slot_controls)); if (ret) return ret;
- ret = sst_map_modules_to_pipe(platform); + ret = sst_map_modules_to_pipe(component);
return ret; } diff --git a/sound/soc/intel/atom/sst-mfld-platform-compress.c b/sound/soc/intel/atom/sst-mfld-platform-compress.c index 1dbcab5..6a44b19 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-compress.c +++ b/sound/soc/intel/atom/sst-mfld-platform-compress.c @@ -107,8 +107,8 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, struct snd_sst_params str_params; struct sst_compress_cb cb; struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; - struct sst_data *ctx = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_data *ctx = snd_soc_component_get_drvdata(component);
stream = cstream->runtime->private_data; /* construct fw structure for this*/ diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 43e7fdd..6c36da5 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -697,26 +697,22 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) return retval; }
-static int sst_soc_probe(struct snd_soc_platform *platform) +static int sst_soc_probe(struct snd_soc_component *component) { - struct sst_data *drv = dev_get_drvdata(platform->dev); + struct sst_data *drv = dev_get_drvdata(component->dev);
- drv->soc_card = platform->component.card; - return sst_dsp_init_v2_dpcm(platform); + drv->soc_card = component->card; + return sst_dsp_init_v2_dpcm(component); }
-static const struct snd_soc_platform_driver sst_soc_platform_drv = { +static const struct snd_soc_component_driver sst_soc_platform_drv = { + .name = DRV_NAME, .probe = sst_soc_probe, .ops = &sst_platform_ops, .compr_ops = &sst_platform_compr_ops, .pcm_new = sst_pcm_new, };
-static const struct snd_soc_component_driver sst_component = { - .name = "sst", -}; - - static int sst_platform_probe(struct platform_device *pdev) { struct sst_data *drv; @@ -740,26 +736,16 @@ static int sst_platform_probe(struct platform_device *pdev) mutex_init(&drv->lock); dev_set_drvdata(&pdev->dev, drv);
- ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv); - if (ret) { - dev_err(&pdev->dev, "registering soc platform failed\n"); - return ret; - } - - ret = snd_soc_register_component(&pdev->dev, &sst_component, + ret = devm_snd_soc_register_component(&pdev->dev, &sst_soc_platform_drv, sst_platform_dai, ARRAY_SIZE(sst_platform_dai)); - if (ret) { + if (ret) dev_err(&pdev->dev, "registering cpu dais failed\n"); - snd_soc_unregister_platform(&pdev->dev); - } + return ret; }
static int sst_platform_remove(struct platform_device *pdev) { - - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); dev_dbg(&pdev->dev, "sst_platform_remove success\n"); return 0; } diff --git a/sound/soc/intel/atom/sst-mfld-platform.h b/sound/soc/intel/atom/sst-mfld-platform.h index 31a58c2..5f729df 100644 --- a/sound/soc/intel/atom/sst-mfld-platform.h +++ b/sound/soc/intel/atom/sst-mfld-platform.h @@ -27,6 +27,8 @@ extern struct sst_device *sst; extern const struct snd_compr_ops sst_platform_compr_ops;
+#define DRV_NAME "sst" + #define SST_MONO 1 #define SST_STEREO 2 #define SST_MAX_CAP 5 @@ -155,7 +157,7 @@ struct sst_device {
struct sst_data;
-int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform); +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component); int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute); int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable); int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable);
The patch
ASoC: intel: atom: replace platform to component
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 6840962b0a19c2716f01f4274f24e153c8ca045c Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Mon, 29 Jan 2018 02:41:28 +0000 Subject: [PATCH] ASoC: intel: atom: replace platform to component
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Tested-by: "Kp, Jeeja" jeeja.kp@intel.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/intel/atom/sst-atom-controls.c | 36 +++++++++++------------ sound/soc/intel/atom/sst-mfld-platform-compress.c | 4 +-- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 32 ++++++-------------- sound/soc/intel/atom/sst-mfld-platform.h | 4 ++- 4 files changed, 32 insertions(+), 44 deletions(-)
diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c index 0f3604b55942..3672d36b4b66 100644 --- a/sound/soc/intel/atom/sst-atom-controls.c +++ b/sound/soc/intel/atom/sst-atom-controls.c @@ -1414,11 +1414,11 @@ static int sst_fill_module_list(struct snd_kcontrol *kctl, * name. First part of control name contains the pipe name (widget name). */ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, - struct snd_soc_platform *platform) + struct snd_soc_component *component) { struct snd_kcontrol *kctl; int index, ret = 0; - struct snd_card *card = platform->component.card->snd_card; + struct snd_card *card = component->card->snd_card; char *idx;
down_read(&card->controls_rwsem); @@ -1468,13 +1468,13 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, /** * sst_fill_linked_widgets - fill the parent pointer for the linked widget */ -static void sst_fill_linked_widgets(struct snd_soc_platform *platform, +static void sst_fill_linked_widgets(struct snd_soc_component *component, struct sst_ids *ids) { struct snd_soc_dapm_widget *w; unsigned int len = strlen(ids->parent_wname);
- list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (!strncmp(ids->parent_wname, w->name, len)) { ids->parent_w = w; break; @@ -1485,41 +1485,41 @@ static void sst_fill_linked_widgets(struct snd_soc_platform *platform, /** * sst_map_modules_to_pipe - fill algo/gains list for all pipes */ -static int sst_map_modules_to_pipe(struct snd_soc_platform *platform) +static int sst_map_modules_to_pipe(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; int ret = 0;
- list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_sst_dapm_widget(w) && (w->priv)) { struct sst_ids *ids = w->priv;
- dev_dbg(platform->dev, "widget type=%d name=%s\n", + dev_dbg(component->dev, "widget type=%d name=%s\n", w->id, w->name); INIT_LIST_HEAD(&ids->algo_list); INIT_LIST_HEAD(&ids->gain_list); - ret = sst_fill_widget_module_info(w, platform); + ret = sst_fill_widget_module_info(w, component);
if (ret < 0) return ret;
/* fill linked widgets */ if (ids->parent_wname != NULL) - sst_fill_linked_widgets(platform, ids); + sst_fill_linked_widgets(component, ids); } } return 0; }
-int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component) { int i, ret = 0; struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(&platform->component); - struct sst_data *drv = snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_dapm(component); + struct sst_data *drv = snd_soc_component_get_drvdata(component); unsigned int gains = ARRAY_SIZE(sst_gain_controls)/3;
- drv->byte_stream = devm_kzalloc(platform->dev, + drv->byte_stream = devm_kzalloc(component->dev, SST_MAX_BIN_BYTES, GFP_KERNEL); if (!drv->byte_stream) return -ENOMEM; @@ -1537,26 +1537,26 @@ int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) sst_gains[i].ramp_duration = SST_GAIN_RAMP_DURATION_DEFAULT; }
- ret = snd_soc_add_platform_controls(platform, sst_gain_controls, + ret = snd_soc_add_component_controls(component, sst_gain_controls, ARRAY_SIZE(sst_gain_controls)); if (ret) return ret;
/* Initialize algo control params */ - ret = sst_algo_control_init(platform->dev); + ret = sst_algo_control_init(component->dev); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_algo_controls, + ret = snd_soc_add_component_controls(component, sst_algo_controls, ARRAY_SIZE(sst_algo_controls)); if (ret) return ret;
- ret = snd_soc_add_platform_controls(platform, sst_slot_controls, + ret = snd_soc_add_component_controls(component, sst_slot_controls, ARRAY_SIZE(sst_slot_controls)); if (ret) return ret;
- ret = sst_map_modules_to_pipe(platform); + ret = sst_map_modules_to_pipe(component);
return ret; } diff --git a/sound/soc/intel/atom/sst-mfld-platform-compress.c b/sound/soc/intel/atom/sst-mfld-platform-compress.c index 1dbcab5a6ff0..6a44b19423cf 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-compress.c +++ b/sound/soc/intel/atom/sst-mfld-platform-compress.c @@ -107,8 +107,8 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, struct snd_sst_params str_params; struct sst_compress_cb cb; struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; - struct sst_data *ctx = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_data *ctx = snd_soc_component_get_drvdata(component);
stream = cstream->runtime->private_data; /* construct fw structure for this*/ diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 43e7fdd19f29..6c36da560877 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -697,26 +697,22 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) return retval; }
-static int sst_soc_probe(struct snd_soc_platform *platform) +static int sst_soc_probe(struct snd_soc_component *component) { - struct sst_data *drv = dev_get_drvdata(platform->dev); + struct sst_data *drv = dev_get_drvdata(component->dev);
- drv->soc_card = platform->component.card; - return sst_dsp_init_v2_dpcm(platform); + drv->soc_card = component->card; + return sst_dsp_init_v2_dpcm(component); }
-static const struct snd_soc_platform_driver sst_soc_platform_drv = { +static const struct snd_soc_component_driver sst_soc_platform_drv = { + .name = DRV_NAME, .probe = sst_soc_probe, .ops = &sst_platform_ops, .compr_ops = &sst_platform_compr_ops, .pcm_new = sst_pcm_new, };
-static const struct snd_soc_component_driver sst_component = { - .name = "sst", -}; - - static int sst_platform_probe(struct platform_device *pdev) { struct sst_data *drv; @@ -740,26 +736,16 @@ static int sst_platform_probe(struct platform_device *pdev) mutex_init(&drv->lock); dev_set_drvdata(&pdev->dev, drv);
- ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv); - if (ret) { - dev_err(&pdev->dev, "registering soc platform failed\n"); - return ret; - } - - ret = snd_soc_register_component(&pdev->dev, &sst_component, + ret = devm_snd_soc_register_component(&pdev->dev, &sst_soc_platform_drv, sst_platform_dai, ARRAY_SIZE(sst_platform_dai)); - if (ret) { + if (ret) dev_err(&pdev->dev, "registering cpu dais failed\n"); - snd_soc_unregister_platform(&pdev->dev); - } + return ret; }
static int sst_platform_remove(struct platform_device *pdev) { - - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); dev_dbg(&pdev->dev, "sst_platform_remove success\n"); return 0; } diff --git a/sound/soc/intel/atom/sst-mfld-platform.h b/sound/soc/intel/atom/sst-mfld-platform.h index 31a58c25472c..5f729df57bb5 100644 --- a/sound/soc/intel/atom/sst-mfld-platform.h +++ b/sound/soc/intel/atom/sst-mfld-platform.h @@ -27,6 +27,8 @@ extern struct sst_device *sst; extern const struct snd_compr_ops sst_platform_compr_ops;
+#define DRV_NAME "sst" + #define SST_MONO 1 #define SST_STEREO 2 #define SST_MAX_CAP 5 @@ -155,7 +157,7 @@ struct sst_device {
struct sst_data;
-int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform); +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component); int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute); int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable); int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable);
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/fsi.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index c3aaf47..3bae06d 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1764,7 +1764,7 @@ static snd_pcm_uframes_t fsi_pointer(struct snd_pcm_substream *substream) };
/* - * snd_soc_platform + * snd_soc_component */
#define PREALLOC_BUFFER (32 * 1024) @@ -1818,13 +1818,10 @@ static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd) }, };
-static const struct snd_soc_platform_driver fsi_soc_platform = { - .ops = &fsi_pcm_ops, - .pcm_new = fsi_pcm_new, -}; - static const struct snd_soc_component_driver fsi_soc_component = { .name = "fsi", + .ops = &fsi_pcm_ops, + .pcm_new = fsi_pcm_new, };
/* @@ -2007,23 +2004,15 @@ static int fsi_probe(struct platform_device *pdev) goto exit_fsib; }
- ret = snd_soc_register_platform(&pdev->dev, &fsi_soc_platform); - if (ret < 0) { - dev_err(&pdev->dev, "cannot snd soc register\n"); - goto exit_fsib; - } - - ret = snd_soc_register_component(&pdev->dev, &fsi_soc_component, + ret = devm_snd_soc_register_component(&pdev->dev, &fsi_soc_component, fsi_soc_dai, ARRAY_SIZE(fsi_soc_dai)); if (ret < 0) { dev_err(&pdev->dev, "cannot snd component register\n"); - goto exit_snd_soc; + goto exit_fsib; }
return ret;
-exit_snd_soc: - snd_soc_unregister_platform(&pdev->dev); exit_fsib: pm_runtime_disable(&pdev->dev); fsi_stream_remove(&master->fsib); @@ -2041,9 +2030,6 @@ static int fsi_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
- snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - fsi_stream_remove(&master->fsia); fsi_stream_remove(&master->fsib);
The patch
ASoC: sh: fsi: replace platform to component
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 f5a82fa6016ad1c2a3f45a4d44eab2ac48daf130 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Mon, 29 Jan 2018 02:43:26 +0000 Subject: [PATCH] ASoC: sh: fsi: replace platform to component
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/sh/fsi.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index c3aaf4788557..3bae06dd121f 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1764,7 +1764,7 @@ static const struct snd_pcm_ops fsi_pcm_ops = { };
/* - * snd_soc_platform + * snd_soc_component */
#define PREALLOC_BUFFER (32 * 1024) @@ -1818,13 +1818,10 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = { }, };
-static const struct snd_soc_platform_driver fsi_soc_platform = { - .ops = &fsi_pcm_ops, - .pcm_new = fsi_pcm_new, -}; - static const struct snd_soc_component_driver fsi_soc_component = { .name = "fsi", + .ops = &fsi_pcm_ops, + .pcm_new = fsi_pcm_new, };
/* @@ -2007,23 +2004,15 @@ static int fsi_probe(struct platform_device *pdev) goto exit_fsib; }
- ret = snd_soc_register_platform(&pdev->dev, &fsi_soc_platform); - if (ret < 0) { - dev_err(&pdev->dev, "cannot snd soc register\n"); - goto exit_fsib; - } - - ret = snd_soc_register_component(&pdev->dev, &fsi_soc_component, + ret = devm_snd_soc_register_component(&pdev->dev, &fsi_soc_component, fsi_soc_dai, ARRAY_SIZE(fsi_soc_dai)); if (ret < 0) { dev_err(&pdev->dev, "cannot snd component register\n"); - goto exit_snd_soc; + goto exit_fsib; }
return ret;
-exit_snd_soc: - snd_soc_unregister_platform(&pdev->dev); exit_fsib: pm_runtime_disable(&pdev->dev); fsi_stream_remove(&master->fsib); @@ -2041,9 +2030,6 @@ static int fsi_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
- snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - fsi_stream_remove(&master->fsia); fsi_stream_remove(&master->fsib);
Now we can replace Codec to Component. Let's do it.
Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-utils.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index e237858..1e0f802 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -288,7 +288,12 @@ static int dummy_dma_open(struct snd_pcm_substream *substream) .ops = &dummy_dma_ops, };
-static const struct snd_soc_codec_driver dummy_codec; +static const struct snd_soc_component_driver dummy_codec = { + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +};
#define STUB_RATES SNDRV_PCM_RATE_8000_192000 #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ @@ -338,33 +343,22 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) { int ret;
- ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &dummy_codec, &dummy_dai, 1); if (ret < 0) return ret;
ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, NULL, 0); - if (ret < 0) { - snd_soc_unregister_codec(&pdev->dev); - return ret; - }
return ret; }
-static int snd_soc_dummy_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - - return 0; -} - static struct platform_driver soc_dummy_driver = { .driver = { .name = "snd-soc-dummy", }, .probe = snd_soc_dummy_probe, - .remove = snd_soc_dummy_remove, };
static struct platform_device *soc_dummy_dev;
Now we can replace Codec to Component. Let's do it.
Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
To keep compatibilty, this patch adds snd_soc_xxx_ac97_codec() macro. These will be removed when all codec code was removed.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 13 ++++++-- sound/soc/codecs/ac97.c | 46 +++++++++++++-------------- sound/soc/soc-ac97.c | 84 ++++++++++++++++++++++++++----------------------- 3 files changed, 77 insertions(+), 66 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 22f479e..92ef770 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -586,10 +586,17 @@ 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 -struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec); -struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, +#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); -void snd_soc_free_ac97_codec(struct snd_ac97 *ac97); +void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops); int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops, diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index 440b4ce..432206b 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c @@ -36,8 +36,8 @@ static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; @@ -65,7 +65,7 @@ static int ac97_prepare(struct snd_pcm_substream *substream, .ops = &ac97_dai_ops, };
-static int ac97_soc_probe(struct snd_soc_codec *codec) +static int ac97_soc_probe(struct snd_soc_component *component) { struct snd_ac97 *ac97; struct snd_ac97_bus *ac97_bus; @@ -73,7 +73,7 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) int ret;
/* add codec as bus device for standard ac97 */ - ret = snd_ac97_bus(codec->component.card->snd_card, 0, soc_ac97_ops, + ret = snd_ac97_bus(component->card->snd_card, 0, soc_ac97_ops, NULL, &ac97_bus); if (ret < 0) return ret; @@ -83,25 +83,25 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) if (ret < 0) return ret;
- snd_soc_codec_set_drvdata(codec, ac97); + snd_soc_component_set_drvdata(component, ac97);
return 0; }
#ifdef CONFIG_PM -static int ac97_soc_suspend(struct snd_soc_codec *codec) +static int ac97_soc_suspend(struct snd_soc_component *component) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_ac97_suspend(ac97);
return 0; }
-static int ac97_soc_resume(struct snd_soc_codec *codec) +static int ac97_soc_resume(struct snd_soc_component *component) {
- struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_ac97_resume(ac97);
@@ -112,28 +112,28 @@ static int ac97_soc_resume(struct snd_soc_codec *codec) #define ac97_soc_resume NULL #endif
-static const struct snd_soc_codec_driver soc_codec_dev_ac97 = { - .probe = ac97_soc_probe, - .suspend = ac97_soc_suspend, - .resume = ac97_soc_resume, - - .component_driver = { - .dapm_widgets = ac97_widgets, - .num_dapm_widgets = ARRAY_SIZE(ac97_widgets), - .dapm_routes = ac97_routes, - .num_dapm_routes = ARRAY_SIZE(ac97_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ac97 = { + .probe = ac97_soc_probe, + .suspend = ac97_soc_suspend, + .resume = ac97_soc_resume, + .dapm_widgets = ac97_widgets, + .num_dapm_widgets = ARRAY_SIZE(ac97_widgets), + .dapm_routes = ac97_routes, + .num_dapm_routes = ARRAY_SIZE(ac97_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int ac97_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ac97, &ac97_dai, 1); + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ac97, &ac97_dai, 1); }
static int ac97_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; }
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c index 36dae41..3f424f2 100644 --- a/sound/soc/soc-ac97.c +++ b/sound/soc/soc-ac97.c @@ -44,7 +44,7 @@ struct snd_ac97_gpio_priv { struct gpio_chip gpio_chip; #endif unsigned int gpios_set; - struct snd_soc_codec *codec; + struct snd_soc_component *component; };
static struct snd_ac97_bus soc_ac97_bus = { @@ -57,11 +57,11 @@ static void soc_ac97_device_release(struct device *dev) }
#ifdef CONFIG_GPIOLIB -static inline struct snd_soc_codec *gpio_to_codec(struct gpio_chip *chip) +static inline struct snd_soc_component *gpio_to_component(struct gpio_chip *chip) { struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
- return gpio_priv->codec; + return gpio_priv->component; }
static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) @@ -75,20 +75,22 @@ static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip);
- dev_dbg(codec->dev, "set gpio %d to output\n", offset); - return snd_soc_update_bits(codec, AC97_GPIO_CFG, + dev_dbg(component->dev, "set gpio %d to output\n", offset); + return snd_soc_component_update_bits(component, AC97_GPIO_CFG, 1 << offset, 1 << offset); }
static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip); int ret;
- ret = snd_soc_read(codec, AC97_GPIO_STATUS); - dev_dbg(codec->dev, "get gpio %d : %d\n", offset, + if (snd_soc_component_read(component, AC97_GPIO_STATUS, &ret) < 0) + ret = -1; + + dev_dbg(component->dev, "get gpio %d : %d\n", offset, ret < 0 ? ret : ret & (1 << offset));
return ret < 0 ? ret : !!(ret & (1 << offset)); @@ -98,22 +100,24 @@ static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip);
gpio_priv->gpios_set &= ~(1 << offset); gpio_priv->gpios_set |= (!!value) << offset; - snd_soc_write(codec, AC97_GPIO_STATUS, gpio_priv->gpios_set); - dev_dbg(codec->dev, "set gpio %d to %d\n", offset, !!value); + snd_soc_component_write(component, AC97_GPIO_STATUS, + gpio_priv->gpios_set); + dev_dbg(component->dev, "set gpio %d to %d\n", offset, !!value); }
static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip);
- dev_dbg(codec->dev, "set gpio %d to output\n", offset); + dev_dbg(component->dev, "set gpio %d to output\n", offset); snd_soc_ac97_gpio_set(chip, offset, value); - return snd_soc_update_bits(codec, AC97_GPIO_CFG, 1 << offset, 0); + return snd_soc_component_update_bits(component, AC97_GPIO_CFG, + 1 << offset, 0); }
static const struct gpio_chip snd_soc_ac97_gpio_chip = { @@ -128,24 +132,24 @@ static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip, };
static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_ac97_gpio_priv *gpio_priv; int ret;
- gpio_priv = devm_kzalloc(codec->dev, sizeof(*gpio_priv), GFP_KERNEL); + gpio_priv = devm_kzalloc(component->dev, sizeof(*gpio_priv), GFP_KERNEL); if (!gpio_priv) return -ENOMEM; ac97->gpio_priv = gpio_priv; - gpio_priv->codec = codec; + gpio_priv->component = component; gpio_priv->gpio_chip = snd_soc_ac97_gpio_chip; gpio_priv->gpio_chip.ngpio = AC97_NUM_GPIOS; - gpio_priv->gpio_chip.parent = codec->dev; + gpio_priv->gpio_chip.parent = component->dev; gpio_priv->gpio_chip.base = -1;
ret = gpiochip_add_data(&gpio_priv->gpio_chip, gpio_priv); if (ret != 0) - dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); + dev_err(component->dev, "Failed to add GPIOs: %d\n", ret); return ret; }
@@ -155,7 +159,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) } #else static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } @@ -166,8 +170,8 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) #endif
/** - * snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device - * @codec: The CODEC for which to create the AC'97 device + * snd_soc_alloc_ac97_component() - Allocate new a AC'97 device + * @component: The COMPONENT for which to create the AC'97 device * * Allocated a new snd_ac97 device and intializes it, but does not yet register * it. The caller is responsible to either call device_add(&ac97->dev) to @@ -175,7 +179,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) * * Returns: A snd_ac97 device or a PTR_ERR in case of an error. */ -struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) +struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component) { struct snd_ac97 *ac97;
@@ -187,26 +191,26 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) ac97->num = 0;
ac97->dev.bus = &ac97_bus_type; - ac97->dev.parent = codec->component.card->dev; + ac97->dev.parent = component->card->dev; ac97->dev.release = soc_ac97_device_release;
dev_set_name(&ac97->dev, "%d-%d:%s", - codec->component.card->snd_card->number, 0, - codec->component.name); + component->card->snd_card->number, 0, + component->name);
device_initialize(&ac97->dev);
return ac97; } -EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); +EXPORT_SYMBOL(snd_soc_alloc_ac97_component);
/** - * snd_soc_new_ac97_codec - initailise AC97 device - * @codec: audio codec + * snd_soc_new_ac97_component - initailise AC97 device + * @component: audio component * @id: The expected device ID * @id_mask: Mask that is applied to the device ID before comparing with @id * - * Initialises AC97 codec resources for use by ad-hoc devices only. + * Initialises AC97 component resources for use by ad-hoc devices only. * * If @id is not 0 this function will reset the device, then read the ID from * the device and check if it matches the expected ID. If it doesn't match an @@ -214,20 +218,20 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) * * Returns: A PTR_ERR() on failure or a valid snd_ac97 struct on success. */ -struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, +struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, unsigned int id, unsigned int id_mask) { struct snd_ac97 *ac97; int ret;
- ac97 = snd_soc_alloc_ac97_codec(codec); + ac97 = snd_soc_alloc_ac97_component(component); if (IS_ERR(ac97)) return ac97;
if (id) { ret = snd_ac97_reset(ac97, false, id, id_mask); if (ret < 0) { - dev_err(codec->dev, "Failed to reset AC97 device: %d\n", + dev_err(component->dev, "Failed to reset AC97 device: %d\n", ret); goto err_put_device; } @@ -237,7 +241,7 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, if (ret) goto err_put_device;
- ret = snd_soc_ac97_init_gpio(ac97, codec); + ret = snd_soc_ac97_init_gpio(ac97, component); if (ret) goto err_put_device;
@@ -247,22 +251,22 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, put_device(&ac97->dev); return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); +EXPORT_SYMBOL_GPL(snd_soc_new_ac97_component);
/** - * snd_soc_free_ac97_codec - free AC97 codec device + * snd_soc_free_ac97_component - free AC97 component device * @ac97: snd_ac97 device to be freed * - * Frees AC97 codec device resources. + * Frees AC97 component device resources. */ -void snd_soc_free_ac97_codec(struct snd_ac97 *ac97) +void snd_soc_free_ac97_component(struct snd_ac97 *ac97) { snd_soc_ac97_free_gpio(ac97); device_del(&ac97->dev); ac97->bus = NULL; put_device(&ac97->dev); } -EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); +EXPORT_SYMBOL_GPL(snd_soc_free_ac97_component);
static struct snd_ac97_reset_cfg snd_ac97_rst_cfg;
Now we can replace Codec to Component. Let's do it.
Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm0010.c | 181 +++++++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 92 deletions(-)
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 0147d2f..ab1ad33 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c @@ -90,7 +90,7 @@ enum wm0010_state { };
struct wm0010_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component;
struct mutex lock; struct device *dev; @@ -157,9 +157,9 @@ static const char *wm0010_state_to_str(enum wm0010_state state) }
/* Called with wm0010->lock held */ -static void wm0010_halt(struct snd_soc_codec *codec) +static void wm0010_halt(struct snd_soc_component *component) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned long flags; enum wm0010_state state;
@@ -193,7 +193,7 @@ static void wm0010_halt(struct snd_soc_codec *codec)
struct wm0010_boot_xfer { struct list_head list; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct completion *done; struct spi_message m; struct spi_transfer t; @@ -218,13 +218,13 @@ static void wm0010_mark_boot_failure(struct wm0010_priv *wm0010) static void wm0010_boot_xfer_complete(void *data) { struct wm0010_boot_xfer *xfer = data; - struct snd_soc_codec *codec = xfer->codec; - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = xfer->component; + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); u32 *out32 = xfer->t.rx_buf; int i;
if (xfer->m.status != 0) { - dev_err(codec->dev, "SPI transfer failed: %d\n", + dev_err(component->dev, "SPI transfer failed: %d\n", xfer->m.status); wm0010_mark_boot_failure(wm0010); if (xfer->done) @@ -233,11 +233,11 @@ static void wm0010_boot_xfer_complete(void *data) }
for (i = 0; i < xfer->t.len / 4; i++) { - dev_dbg(codec->dev, "%d: %04x\n", i, out32[i]); + dev_dbg(component->dev, "%d: %04x\n", i, out32[i]);
switch (be32_to_cpu(out32[i])) { case 0xe0e0e0e0: - dev_err(codec->dev, + dev_err(component->dev, "%d: ROM error reported in stage 2\n", i); wm0010_mark_boot_failure(wm0010); break; @@ -245,82 +245,82 @@ static void wm0010_boot_xfer_complete(void *data) case 0x55555555: if (wm0010->state < WM0010_STAGE2) break; - dev_err(codec->dev, + dev_err(component->dev, "%d: ROM bootloader running in stage 2\n", i); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0000: - dev_dbg(codec->dev, "Stage2 loader running\n"); + dev_dbg(component->dev, "Stage2 loader running\n"); break;
case 0x0fed0007: - dev_dbg(codec->dev, "CODE_HDR packet received\n"); + dev_dbg(component->dev, "CODE_HDR packet received\n"); break;
case 0x0fed0008: - dev_dbg(codec->dev, "CODE_DATA packet received\n"); + dev_dbg(component->dev, "CODE_DATA packet received\n"); break;
case 0x0fed0009: - dev_dbg(codec->dev, "Download complete\n"); + dev_dbg(component->dev, "Download complete\n"); break;
case 0x0fed000c: - dev_dbg(codec->dev, "Application start\n"); + dev_dbg(component->dev, "Application start\n"); break;
case 0x0fed000e: - dev_dbg(codec->dev, "PLL packet received\n"); + dev_dbg(component->dev, "PLL packet received\n"); wm0010->pll_running = true; break;
case 0x0fed0025: - dev_err(codec->dev, "Device reports image too long\n"); + dev_err(component->dev, "Device reports image too long\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed002c: - dev_err(codec->dev, "Device reports bad SPI packet\n"); + dev_err(component->dev, "Device reports bad SPI packet\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0031: - dev_err(codec->dev, "Device reports SPI read overflow\n"); + dev_err(component->dev, "Device reports SPI read overflow\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0032: - dev_err(codec->dev, "Device reports SPI underclock\n"); + dev_err(component->dev, "Device reports SPI underclock\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0033: - dev_err(codec->dev, "Device reports bad header packet\n"); + dev_err(component->dev, "Device reports bad header packet\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0034: - dev_err(codec->dev, "Device reports invalid packet type\n"); + dev_err(component->dev, "Device reports invalid packet type\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0035: - dev_err(codec->dev, "Device reports data before header error\n"); + dev_err(component->dev, "Device reports data before header error\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0038: - dev_err(codec->dev, "Device reports invalid PLL packet\n"); + dev_err(component->dev, "Device reports invalid PLL packet\n"); break;
case 0x0fed003a: - dev_err(codec->dev, "Device reports packet alignment error\n"); + dev_err(component->dev, "Device reports packet alignment error\n"); wm0010_mark_boot_failure(wm0010); break;
default: - dev_err(codec->dev, "Unrecognised return 0x%x\n", + dev_err(component->dev, "Unrecognised return 0x%x\n", be32_to_cpu(out32[i])); wm0010_mark_boot_failure(wm0010); break; @@ -342,10 +342,10 @@ static void byte_swap_64(u64 *data_in, u64 *data_out, u32 len) data_out[i] = cpu_to_be64(le64_to_cpu(data_in[i])); }
-static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) +static int wm0010_firmware_load(const char *name, struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); struct list_head xfer_list; struct wm0010_boot_xfer *xfer; int ret; @@ -359,9 +359,9 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
INIT_LIST_HEAD(&xfer_list);
- ret = request_firmware(&fw, name, codec->dev); + ret = request_firmware(&fw, name, component->dev); if (ret != 0) { - dev_err(codec->dev, "Failed to request application(%s): %d\n", + dev_err(component->dev, "Failed to request application(%s): %d\n", name, ret); return ret; } @@ -377,25 +377,25 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
/* First record should be INFO */ if (rec->command != DFW_CMD_INFO) { - dev_err(codec->dev, "First record not INFO\r\n"); + dev_err(component->dev, "First record not INFO\r\n"); ret = -EINVAL; goto abort; }
if (inforec->info_version != INFO_VERSION) { - dev_err(codec->dev, + dev_err(component->dev, "Unsupported version (%02d) of INFO record\r\n", inforec->info_version); ret = -EINVAL; goto abort; }
- dev_dbg(codec->dev, "Version v%02d INFO record found\r\n", + dev_dbg(component->dev, "Version v%02d INFO record found\r\n", inforec->info_version);
/* Check it's a DSP file */ if (dsp != DEVICE_ID_WM0010) { - dev_err(codec->dev, "Not a WM0010 firmware file.\r\n"); + dev_err(component->dev, "Not a WM0010 firmware file.\r\n"); ret = -EINVAL; goto abort; } @@ -405,7 +405,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) rec = (void *)&rec->data[rec->length];
while (offset < fw->size) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Packet: command %d, data length = 0x%x\r\n", rec->command, rec->length); len = rec->length + 8; @@ -416,7 +416,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) goto abort; }
- xfer->codec = codec; + xfer->component = component; list_add_tail(&xfer->list, &xfer_list);
out = kzalloc(len, GFP_KERNEL | GFP_DMA); @@ -460,18 +460,18 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) rec = (void *)&rec->data[rec->length];
if (offset >= fw->size) { - dev_dbg(codec->dev, "All transfers scheduled\n"); + dev_dbg(component->dev, "All transfers scheduled\n"); xfer->done = &done; }
ret = spi_async(spi, &xfer->m); if (ret != 0) { - dev_err(codec->dev, "Write failed: %d\n", ret); + dev_err(component->dev, "Write failed: %d\n", ret); goto abort1; }
if (wm0010->boot_failed) { - dev_dbg(codec->dev, "Boot fail!\n"); + dev_dbg(component->dev, "Boot fail!\n"); ret = -EINVAL; goto abort1; } @@ -496,10 +496,10 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) return ret; }
-static int wm0010_stage2_load(struct snd_soc_codec *codec) +static int wm0010_stage2_load(struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); const struct firmware *fw; struct spi_message m; struct spi_transfer t; @@ -508,14 +508,14 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) int i; int ret = 0;
- ret = request_firmware(&fw, "wm0010_stage2.bin", codec->dev); + ret = request_firmware(&fw, "wm0010_stage2.bin", component->dev); if (ret != 0) { - dev_err(codec->dev, "Failed to request stage2 loader: %d\n", + dev_err(component->dev, "Failed to request stage2 loader: %d\n", ret); return ret; }
- dev_dbg(codec->dev, "Downloading %zu byte stage 2 loader\n", fw->size); + dev_dbg(component->dev, "Downloading %zu byte stage 2 loader\n", fw->size);
/* Copy to local buffer first as vmalloc causes problems for dma */ img = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); @@ -541,19 +541,19 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) t.speed_hz = wm0010->sysclk / 10; spi_message_add_tail(&t, &m);
- dev_dbg(codec->dev, "Starting initial download at %dHz\n", + dev_dbg(component->dev, "Starting initial download at %dHz\n", t.speed_hz);
ret = spi_sync(spi, &m); if (ret != 0) { - dev_err(codec->dev, "Initial download failed: %d\n", ret); + dev_err(component->dev, "Initial download failed: %d\n", ret); goto abort; }
/* Look for errors from the boot ROM */ for (i = 0; i < fw->size; i++) { if (out[i] != 0x55) { - dev_err(codec->dev, "Boot ROM error: %x in %d\n", + dev_err(component->dev, "Boot ROM error: %x in %d\n", out[i], i); wm0010_mark_boot_failure(wm0010); ret = -EBUSY; @@ -570,10 +570,10 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) return ret; }
-static int wm0010_boot(struct snd_soc_codec *codec) +static int wm0010_boot(struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned long flags; int ret; struct spi_message m; @@ -590,7 +590,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) spin_unlock_irqrestore(&wm0010->irq_lock, flags);
if (wm0010->sysclk > 26000000) { - dev_err(codec->dev, "Max DSP clock frequency is 26MHz\n"); + dev_err(component->dev, "Max DSP clock frequency is 26MHz\n"); ret = -ECANCELED; goto err; } @@ -598,7 +598,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) mutex_lock(&wm0010->lock); wm0010->pll_running = false;
- dev_dbg(codec->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq); + dev_dbg(component->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq);
ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies), wm0010->core_supplies); @@ -623,19 +623,19 @@ static int wm0010_boot(struct snd_soc_codec *codec)
if (!wait_for_completion_timeout(&wm0010->boot_completion, msecs_to_jiffies(20))) - dev_err(codec->dev, "Failed to get interrupt from DSP\n"); + dev_err(component->dev, "Failed to get interrupt from DSP\n");
spin_lock_irqsave(&wm0010->irq_lock, flags); wm0010->state = WM0010_BOOTROM; spin_unlock_irqrestore(&wm0010->irq_lock, flags);
- ret = wm0010_stage2_load(codec); + ret = wm0010_stage2_load(component); if (ret) goto abort;
if (!wait_for_completion_timeout(&wm0010->boot_completion, msecs_to_jiffies(20))) - dev_err(codec->dev, "Failed to get interrupt from DSP loader.\n"); + dev_err(component->dev, "Failed to get interrupt from DSP loader.\n");
spin_lock_irqsave(&wm0010->irq_lock, flags); wm0010->state = WM0010_STAGE2; @@ -676,14 +676,14 @@ static int wm0010_boot(struct snd_soc_codec *codec)
ret = spi_sync(spi, &m); if (ret) { - dev_err(codec->dev, "First PLL write failed: %d\n", ret); + dev_err(component->dev, "First PLL write failed: %d\n", ret); goto abort_swap; }
/* Use a second send of the message to get the return status */ ret = spi_sync(spi, &m); if (ret) { - dev_err(codec->dev, "Second PLL write failed: %d\n", ret); + dev_err(component->dev, "Second PLL write failed: %d\n", ret); goto abort_swap; }
@@ -692,7 +692,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) /* Look for PLL active code from the DSP */ for (i = 0; i < len / 4; i++) { if (*p == 0x0e00ed0f) { - dev_dbg(codec->dev, "PLL packet received\n"); + dev_dbg(component->dev, "PLL packet received\n"); wm0010->pll_running = true; break; } @@ -702,9 +702,9 @@ static int wm0010_boot(struct snd_soc_codec *codec) kfree(img_swap); kfree(out); } else - dev_dbg(codec->dev, "Not enabling DSP PLL."); + dev_dbg(component->dev, "Not enabling DSP PLL.");
- ret = wm0010_firmware_load("wm0010.dfw", codec); + ret = wm0010_firmware_load("wm0010.dfw", component);
if (ret != 0) goto abort; @@ -723,7 +723,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) kfree(out); abort: /* Put the chip back into reset */ - wm0010_halt(codec); + wm0010_halt(component); mutex_unlock(&wm0010->lock); return ret;
@@ -735,22 +735,22 @@ static int wm0010_boot(struct snd_soc_codec *codec) return ret; }
-static int wm0010_set_bias_level(struct snd_soc_codec *codec, +static int wm0010_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
switch (level) { case SND_SOC_BIAS_ON: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) - wm0010_boot(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) + wm0010_boot(component); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { mutex_lock(&wm0010->lock); - wm0010_halt(codec); + wm0010_halt(component); mutex_unlock(&wm0010->lock); } break; @@ -761,10 +761,10 @@ static int wm0010_set_bias_level(struct snd_soc_codec *codec, return 0; }
-static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, +static int wm0010_set_sysclk(struct snd_soc_component *component, int source, int clk_id, unsigned int freq, int dir) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned int i;
wm0010->sysclk = freq; @@ -783,20 +783,19 @@ static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, return 0; }
-static int wm0010_probe(struct snd_soc_codec *codec); - -static const struct snd_soc_codec_driver soc_codec_dev_wm0010 = { - .probe = wm0010_probe, - .set_bias_level = wm0010_set_bias_level, - .set_sysclk = wm0010_set_sysclk, - .idle_bias_off = true, - - .component_driver = { - .dapm_widgets = wm0010_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets), - .dapm_routes = wm0010_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes), - }, +static int wm0010_probe(struct snd_soc_component *component); + +static const struct snd_soc_component_driver soc_component_dev_wm0010 = { + .probe = wm0010_probe, + .set_bias_level = wm0010_set_bias_level, + .set_sysclk = wm0010_set_sysclk, + .dapm_widgets = wm0010_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets), + .dapm_routes = wm0010_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
#define WM0010_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) @@ -860,11 +859,11 @@ static irqreturn_t wm0010_irq(int irq, void *data) return IRQ_NONE; }
-static int wm0010_probe(struct snd_soc_codec *codec) +static int wm0010_probe(struct snd_soc_component *component) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
- wm0010->codec = codec; + wm0010->component = component;
return 0; } @@ -967,8 +966,8 @@ static int wm0010_spi_probe(struct spi_device *spi) else wm0010->board_max_spi_speed = 0;
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm0010, wm0010_dai, + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm0010, wm0010_dai, ARRAY_SIZE(wm0010_dai)); if (ret < 0) return ret; @@ -980,8 +979,6 @@ static int wm0010_spi_remove(struct spi_device *spi) { struct wm0010_priv *wm0010 = spi_get_drvdata(spi);
- snd_soc_unregister_codec(&spi->dev); - gpio_set_value_cansleep(wm0010->gpio_reset, wm0010->gpio_reset_value);
participants (2)
-
Kuninori Morimoto
-
Mark Brown