2019-07-26 12:49:48 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
//
|
|
|
|
// soc-component.c
|
|
|
|
//
|
2020-06-04 16:08:03 +08:00
|
|
|
// Copyright 2009-2011 Wolfson Microelectronics PLC.
|
2019-07-26 12:49:48 +08:00
|
|
|
// Copyright (C) 2019 Renesas Electronics Corp.
|
2020-06-04 16:08:03 +08:00
|
|
|
//
|
|
|
|
// Mark Brown <broonie@opensource.wolfsonmicro.com>
|
2019-07-26 12:49:48 +08:00
|
|
|
// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
|
|
|
|
//
|
2019-07-26 12:49:54 +08:00
|
|
|
#include <linux/module.h>
|
ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
=> 5) pm_runtime_put/get()
This patch is for 5) pm_runtime_put/get().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when get() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* get() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ribwnb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:17 +08:00
|
|
|
#include <linux/pm_runtime.h>
|
2019-07-26 12:49:48 +08:00
|
|
|
#include <sound/soc.h>
|
2021-01-29 18:05:39 +08:00
|
|
|
#include <linux/bitops.h>
|
2019-07-26 12:49:48 +08:00
|
|
|
|
2021-10-15 00:13:30 +08:00
|
|
|
#define soc_component_ret(dai, ret) _soc_component_ret(dai, __func__, ret, -1)
|
|
|
|
#define soc_component_ret_reg_rw(dai, ret, reg) _soc_component_ret(dai, __func__, ret, reg)
|
2020-06-04 16:06:41 +08:00
|
|
|
static inline int _soc_component_ret(struct snd_soc_component *component,
|
2021-10-15 00:13:30 +08:00
|
|
|
const char *func, int ret, int reg)
|
2020-06-04 16:06:41 +08:00
|
|
|
{
|
|
|
|
/* Positive/Zero values are not errors */
|
|
|
|
if (ret >= 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Negative values might be errors */
|
|
|
|
switch (ret) {
|
|
|
|
case -EPROBE_DEFER:
|
|
|
|
case -ENOTSUPP:
|
|
|
|
break;
|
|
|
|
default:
|
2021-10-15 00:13:30 +08:00
|
|
|
if (reg == -1)
|
|
|
|
dev_err(component->dev,
|
|
|
|
"ASoC: error at %s on %s: %d\n",
|
|
|
|
func, component->name, ret);
|
|
|
|
else
|
|
|
|
dev_err(component->dev,
|
|
|
|
"ASoC: error at %s on %s for register: [0x%08x] %d\n",
|
|
|
|
func, component->name, reg, ret);
|
2020-06-04 16:06:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-01-27 01:17:48 +08:00
|
|
|
static inline int soc_component_field_shift(struct snd_soc_component *component,
|
|
|
|
unsigned int mask)
|
|
|
|
{
|
|
|
|
if (!mask) {
|
|
|
|
dev_err(component->dev, "ASoC: error field mask is zero for %s\n",
|
|
|
|
component->name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-01-29 18:05:39 +08:00
|
|
|
return (ffs(mask) - 1);
|
2021-01-27 01:17:48 +08:00
|
|
|
}
|
|
|
|
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
/*
|
|
|
|
* We might want to check substream by using list.
|
|
|
|
* In such case, we can update these macros.
|
|
|
|
*/
|
|
|
|
#define soc_component_mark_push(component, substream, tgt) ((component)->mark_##tgt = substream)
|
|
|
|
#define soc_component_mark_pop(component, substream, tgt) ((component)->mark_##tgt = NULL)
|
|
|
|
#define soc_component_mark_match(component, substream, tgt) ((component)->mark_##tgt == substream)
|
|
|
|
|
2020-06-04 16:07:54 +08:00
|
|
|
void snd_soc_component_set_aux(struct snd_soc_component *component,
|
|
|
|
struct snd_soc_aux_dev *aux)
|
|
|
|
{
|
|
|
|
component->init = (aux) ? aux->init : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int snd_soc_component_init(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (component->init)
|
|
|
|
ret = component->init(component);
|
|
|
|
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
/**
|
|
|
|
* snd_soc_component_set_sysclk - configure COMPONENT system or master clock.
|
|
|
|
* @component: COMPONENT
|
|
|
|
* @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_component_set_sysclk(struct snd_soc_component *component,
|
|
|
|
int clk_id, int source, unsigned int freq,
|
|
|
|
int dir)
|
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = -ENOTSUPP;
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
if (component->driver->set_sysclk)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->set_sysclk(component, clk_id, source,
|
2019-07-26 12:49:48 +08:00
|
|
|
freq, dir);
|
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* snd_soc_component_set_pll - configure component PLL.
|
|
|
|
* @component: COMPONENT
|
|
|
|
* @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_component_set_pll(struct snd_soc_component *component, int pll_id,
|
|
|
|
int source, unsigned int freq_in,
|
|
|
|
unsigned int freq_out)
|
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = -EINVAL;
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
if (component->driver->set_pll)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->set_pll(component, pll_id, source,
|
2019-07-26 12:49:48 +08:00
|
|
|
freq_in, freq_out);
|
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_set_pll);
|
|
|
|
|
2019-07-26 12:51:35 +08:00
|
|
|
void snd_soc_component_seq_notifier(struct snd_soc_component *component,
|
|
|
|
enum snd_soc_dapm_type type, int subseq)
|
|
|
|
{
|
|
|
|
if (component->driver->seq_notifier)
|
|
|
|
component->driver->seq_notifier(component, type, subseq);
|
|
|
|
}
|
|
|
|
|
2019-07-26 12:51:39 +08:00
|
|
|
int snd_soc_component_stream_event(struct snd_soc_component *component,
|
|
|
|
int event)
|
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2019-07-26 12:51:39 +08:00
|
|
|
if (component->driver->stream_event)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->stream_event(component, event);
|
2019-07-26 12:51:39 +08:00
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:51:39 +08:00
|
|
|
}
|
|
|
|
|
2019-07-26 12:51:43 +08:00
|
|
|
int snd_soc_component_set_bias_level(struct snd_soc_component *component,
|
|
|
|
enum snd_soc_bias_level level)
|
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2019-07-26 12:51:43 +08:00
|
|
|
if (component->driver->set_bias_level)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->set_bias_level(component, level);
|
2019-07-26 12:51:43 +08:00
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:51:43 +08:00
|
|
|
}
|
|
|
|
|
2020-06-04 16:06:11 +08:00
|
|
|
int snd_soc_component_enable_pin(struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_enable_pin(dapm, pin);
|
2020-06-04 16:06:11 +08:00
|
|
|
}
|
2019-07-26 12:49:48 +08:00
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_enable_pin);
|
|
|
|
|
|
|
|
int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_enable_pin_unlocked(dapm, pin);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_enable_pin_unlocked);
|
|
|
|
|
|
|
|
int snd_soc_component_disable_pin(struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_disable_pin(dapm, pin);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_disable_pin);
|
|
|
|
|
|
|
|
int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_disable_pin_unlocked(dapm, pin);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_disable_pin_unlocked);
|
|
|
|
|
|
|
|
int snd_soc_component_nc_pin(struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_nc_pin(dapm, pin);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_nc_pin);
|
|
|
|
|
|
|
|
int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_nc_pin_unlocked(dapm, pin);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_nc_pin_unlocked);
|
|
|
|
|
|
|
|
int snd_soc_component_get_pin_status(struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_get_pin_status(dapm, pin);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_get_pin_status);
|
|
|
|
|
|
|
|
int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_force_enable_pin(dapm, pin);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin);
|
|
|
|
|
|
|
|
int snd_soc_component_force_enable_pin_unlocked(
|
|
|
|
struct snd_soc_component *component,
|
|
|
|
const char *pin)
|
|
|
|
{
|
2021-07-27 03:41:23 +08:00
|
|
|
struct snd_soc_dapm_context *dapm =
|
|
|
|
snd_soc_component_get_dapm(component);
|
|
|
|
return snd_soc_dapm_force_enable_pin_unlocked(dapm, pin);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);
|
|
|
|
|
2023-05-12 20:28:30 +08:00
|
|
|
int snd_soc_component_notify_control(struct snd_soc_component *component,
|
|
|
|
const char * const ctl)
|
|
|
|
{
|
|
|
|
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
|
|
|
|
struct snd_kcontrol *kctl;
|
|
|
|
|
2023-10-03 23:57:09 +08:00
|
|
|
/* When updating, change also snd_soc_dapm_widget_name_cmp() */
|
2023-05-12 20:28:30 +08:00
|
|
|
if (component->name_prefix)
|
|
|
|
snprintf(name, ARRAY_SIZE(name), "%s %s", component->name_prefix, ctl);
|
|
|
|
else
|
|
|
|
snprintf(name, ARRAY_SIZE(name), "%s", ctl);
|
|
|
|
|
|
|
|
kctl = snd_soc_card_get_kcontrol(component->card, name);
|
|
|
|
if (!kctl)
|
|
|
|
return soc_component_ret(component, -EINVAL);
|
|
|
|
|
|
|
|
snd_ctl_notify(component->card->snd_card,
|
|
|
|
SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_notify_control);
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
/**
|
|
|
|
* snd_soc_component_set_jack - configure component jack.
|
|
|
|
* @component: COMPONENTs
|
|
|
|
* @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_component_set_jack(struct snd_soc_component *component,
|
|
|
|
struct snd_soc_jack *jack, void *data)
|
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = -ENOTSUPP;
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
if (component->driver->set_jack)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->set_jack(component, jack, data);
|
2019-07-26 12:49:48 +08:00
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:49:48 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_set_jack);
|
2019-07-26 12:49:54 +08:00
|
|
|
|
2023-01-23 21:59:11 +08:00
|
|
|
/**
|
|
|
|
* snd_soc_component_get_jack_type
|
|
|
|
* @component: COMPONENTs
|
|
|
|
*
|
|
|
|
* Returns the jack type of the component
|
|
|
|
* This can either be the supported type or one read from
|
|
|
|
* devicetree with the property: jack-type.
|
|
|
|
*/
|
|
|
|
int snd_soc_component_get_jack_type(
|
|
|
|
struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
int ret = -ENOTSUPP;
|
|
|
|
|
|
|
|
if (component->driver->get_jack_type)
|
|
|
|
ret = component->driver->get_jack_type(component);
|
|
|
|
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_get_jack_type);
|
|
|
|
|
2019-07-26 12:49:54 +08:00
|
|
|
int snd_soc_component_module_get(struct snd_soc_component *component,
|
2021-09-01 17:52:54 +08:00
|
|
|
void *mark, int upon_open)
|
2019-07-26 12:49:54 +08:00
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2019-07-26 12:49:54 +08:00
|
|
|
if (component->driver->module_get_upon_open == !!upon_open &&
|
|
|
|
!try_module_get(component->dev->driver->owner))
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = -ENODEV;
|
2019-07-26 12:49:54 +08:00
|
|
|
|
2021-09-01 17:52:54 +08:00
|
|
|
/* mark module if succeeded */
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
if (ret == 0)
|
2021-09-01 17:52:54 +08:00
|
|
|
soc_component_mark_push(component, mark, module);
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void snd_soc_component_module_put(struct snd_soc_component *component,
|
2021-09-01 17:52:54 +08:00
|
|
|
void *mark, int upon_open, int rollback)
|
2019-07-26 12:49:54 +08:00
|
|
|
{
|
2021-09-01 17:52:54 +08:00
|
|
|
if (rollback && !soc_component_mark_match(component, mark, module))
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
return;
|
|
|
|
|
2019-07-26 12:49:54 +08:00
|
|
|
if (component->driver->module_get_upon_open == !!upon_open)
|
|
|
|
module_put(component->dev->driver->owner);
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
|
2021-09-01 17:52:54 +08:00
|
|
|
/* remove the mark from module */
|
|
|
|
soc_component_mark_pop(component, mark, module);
|
2019-07-26 12:49:54 +08:00
|
|
|
}
|
2019-07-26 12:50:01 +08:00
|
|
|
|
|
|
|
int snd_soc_component_open(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream)
|
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
ASoC: soc-core: merge snd_pcm_ops member to component driver
Current snd_soc_component_driver has snd_pcm_ops, and each driver can
have callback via it (1).
But, it is mainly created for ALSA, thus, it doesn't have "component"
as parameter for ALSA SoC (1)(2).
Thus, each callback can't know it is called for which component.
Thus, each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name (3).
--- ALSA SoC ---
...
if (component->driver->ops &&
component->driver->ops->open)
(1) return component->driver->ops->open(substream);
...
--- driver ---
(2) static int xxx_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
(3) struct snd_soc_component *component = snd_soc_rtdcom_lookup(..);
...
}
It works today, but, will not work in the future if we support multi
CPU/Codec/Platform, because 1 rtd might have multiple components which
have same driver name.
To solve this issue, each callback needs to be called with component.
We already have many component driver callback.
This patch copies each snd_pcm_ops member under component driver,
and having "component" as parameter.
--- ALSA SoC ---
...
if (component->driver->open)
=> return component->driver->open(component, substream);
...
--- driver ---
=> static int xxx_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
...
}
*Note*
Only Intel skl-pcm has .get_time_info implementation, but ALSA SoC
framework doesn't call it so far.
To keep its implementation, this patch keeps .get_time_info,
but it is still not called.
Intel guy need to support it in the future.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tv8raf3r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-02 13:30:48 +08:00
|
|
|
if (component->driver->open)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->open(component, substream);
|
|
|
|
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
/* mark substream if succeeded */
|
|
|
|
if (ret == 0)
|
|
|
|
soc_component_mark_push(component, substream, open);
|
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:50:01 +08:00
|
|
|
}
|
2019-07-26 12:50:07 +08:00
|
|
|
|
|
|
|
int snd_soc_component_close(struct snd_soc_component *component,
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
struct snd_pcm_substream *substream,
|
|
|
|
int rollback)
|
2019-07-26 12:50:07 +08:00
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
if (rollback && !soc_component_mark_match(component, substream, open))
|
|
|
|
return 0;
|
|
|
|
|
ASoC: soc-core: merge snd_pcm_ops member to component driver
Current snd_soc_component_driver has snd_pcm_ops, and each driver can
have callback via it (1).
But, it is mainly created for ALSA, thus, it doesn't have "component"
as parameter for ALSA SoC (1)(2).
Thus, each callback can't know it is called for which component.
Thus, each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name (3).
--- ALSA SoC ---
...
if (component->driver->ops &&
component->driver->ops->open)
(1) return component->driver->ops->open(substream);
...
--- driver ---
(2) static int xxx_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
(3) struct snd_soc_component *component = snd_soc_rtdcom_lookup(..);
...
}
It works today, but, will not work in the future if we support multi
CPU/Codec/Platform, because 1 rtd might have multiple components which
have same driver name.
To solve this issue, each callback needs to be called with component.
We already have many component driver callback.
This patch copies each snd_pcm_ops member under component driver,
and having "component" as parameter.
--- ALSA SoC ---
...
if (component->driver->open)
=> return component->driver->open(component, substream);
...
--- driver ---
=> static int xxx_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
...
}
*Note*
Only Intel skl-pcm has .get_time_info implementation, but ALSA SoC
framework doesn't call it so far.
To keep its implementation, this patch keeps .get_time_info,
but it is still not called.
Intel guy need to support it in the future.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tv8raf3r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-02 13:30:48 +08:00
|
|
|
if (component->driver->close)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->close(component, substream);
|
|
|
|
|
ASoC: soc-component: add mark for soc_pcm_components_open/close()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
=> 3) snd_soc_component_module_get/put()
=> 4) snd_soc_component_open/close()
5) pm_runtime_put/get()
This patch is for 3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when open() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* open() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:04 +08:00
|
|
|
/* remove marked substream */
|
|
|
|
soc_component_mark_pop(component, substream, open);
|
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:50:07 +08:00
|
|
|
}
|
2019-07-26 12:50:13 +08:00
|
|
|
|
2019-07-26 12:50:34 +08:00
|
|
|
void snd_soc_component_suspend(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
if (component->driver->suspend)
|
|
|
|
component->driver->suspend(component);
|
|
|
|
component->suspended = 1;
|
|
|
|
}
|
2019-07-26 12:51:08 +08:00
|
|
|
|
|
|
|
void snd_soc_component_resume(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
if (component->driver->resume)
|
|
|
|
component->driver->resume(component);
|
|
|
|
component->suspended = 0;
|
|
|
|
}
|
2019-07-26 12:51:13 +08:00
|
|
|
|
|
|
|
int snd_soc_component_is_suspended(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
return component->suspended;
|
|
|
|
}
|
2019-07-26 12:51:17 +08:00
|
|
|
|
|
|
|
int snd_soc_component_probe(struct snd_soc_component *component)
|
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2019-07-26 12:51:17 +08:00
|
|
|
if (component->driver->probe)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->probe(component);
|
2019-07-26 12:51:17 +08:00
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:51:17 +08:00
|
|
|
}
|
2019-07-26 12:51:22 +08:00
|
|
|
|
|
|
|
void snd_soc_component_remove(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
if (component->driver->remove)
|
|
|
|
component->driver->remove(component);
|
|
|
|
}
|
2019-07-26 12:51:26 +08:00
|
|
|
|
|
|
|
int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
|
|
|
|
struct device_node *ep)
|
|
|
|
{
|
2020-06-04 16:06:41 +08:00
|
|
|
int ret = -ENOTSUPP;
|
|
|
|
|
2019-07-26 12:51:26 +08:00
|
|
|
if (component->driver->of_xlate_dai_id)
|
2020-06-04 16:06:41 +08:00
|
|
|
ret = component->driver->of_xlate_dai_id(component, ep);
|
2019-07-26 12:51:26 +08:00
|
|
|
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-07-26 12:51:26 +08:00
|
|
|
}
|
2019-07-26 12:51:31 +08:00
|
|
|
|
|
|
|
int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
|
2021-02-21 23:30:24 +08:00
|
|
|
const struct of_phandle_args *args,
|
2019-07-26 12:51:31 +08:00
|
|
|
const char **dai_name)
|
|
|
|
{
|
|
|
|
if (component->driver->of_xlate_dai_name)
|
2020-07-23 22:20:20 +08:00
|
|
|
return component->driver->of_xlate_dai_name(component,
|
|
|
|
args, dai_name);
|
|
|
|
/*
|
|
|
|
* Don't use soc_component_ret here because we may not want to report
|
|
|
|
* the error just yet. If a device has more than one component, the
|
|
|
|
* first may not match and we don't want spam the log with this.
|
|
|
|
*/
|
|
|
|
return -ENOTSUPP;
|
2019-07-26 12:51:31 +08:00
|
|
|
}
|
2019-07-26 12:51:47 +08:00
|
|
|
|
2020-06-04 16:06:22 +08:00
|
|
|
void snd_soc_component_setup_regmap(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
int val_bytes = regmap_get_val_bytes(component->regmap);
|
|
|
|
|
|
|
|
/* Errors are legitimate for non-integer byte multiples */
|
|
|
|
if (val_bytes > 0)
|
|
|
|
component->val_bytes = val_bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_REGMAP
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_init_regmap() - Initialize regmap instance for the
|
|
|
|
* component
|
|
|
|
* @component: The component for which to initialize the regmap instance
|
|
|
|
* @regmap: The regmap instance that should be used by the component
|
|
|
|
*
|
|
|
|
* This function allows deferred assignment of the regmap instance that is
|
|
|
|
* associated with the component. Only use this if the regmap instance is not
|
|
|
|
* yet ready when the component is registered. The function must also be called
|
|
|
|
* before the first IO attempt of the component.
|
|
|
|
*/
|
|
|
|
void snd_soc_component_init_regmap(struct snd_soc_component *component,
|
|
|
|
struct regmap *regmap)
|
|
|
|
{
|
|
|
|
component->regmap = regmap;
|
|
|
|
snd_soc_component_setup_regmap(component);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_exit_regmap() - De-initialize regmap instance for the
|
|
|
|
* component
|
|
|
|
* @component: The component for which to de-initialize the regmap instance
|
|
|
|
*
|
|
|
|
* Calls regmap_exit() on the regmap instance associated to the component and
|
|
|
|
* removes the regmap instance from the component.
|
|
|
|
*
|
|
|
|
* This function should only be used if snd_soc_component_init_regmap() was used
|
|
|
|
* to initialize the regmap instance.
|
|
|
|
*/
|
|
|
|
void snd_soc_component_exit_regmap(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
regmap_exit(component->regmap);
|
|
|
|
component->regmap = NULL;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2021-09-01 17:52:55 +08:00
|
|
|
int snd_soc_component_compr_open(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *cstream)
|
2020-11-13 12:15:20 +08:00
|
|
|
{
|
2021-09-01 17:52:55 +08:00
|
|
|
int ret = 0;
|
2020-11-13 12:15:20 +08:00
|
|
|
|
2021-09-01 17:52:55 +08:00
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->open)
|
|
|
|
ret = component->driver->compress_ops->open(component, cstream);
|
|
|
|
|
|
|
|
/* mark substream if succeeded */
|
|
|
|
if (ret == 0)
|
2020-11-19 07:50:09 +08:00
|
|
|
soc_component_mark_push(component, cstream, compr_open);
|
2020-11-13 12:15:20 +08:00
|
|
|
|
2021-09-01 17:52:55 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2020-11-13 12:15:20 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_open);
|
|
|
|
|
2021-09-01 17:52:55 +08:00
|
|
|
void snd_soc_component_compr_free(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *cstream,
|
2020-11-19 07:50:09 +08:00
|
|
|
int rollback)
|
2020-11-13 12:15:26 +08:00
|
|
|
{
|
2021-09-01 17:52:55 +08:00
|
|
|
if (rollback && !soc_component_mark_match(component, cstream, compr_open))
|
|
|
|
return;
|
2020-11-13 12:15:26 +08:00
|
|
|
|
2021-09-01 17:52:55 +08:00
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->free)
|
|
|
|
component->driver->compress_ops->free(component, cstream);
|
2020-11-19 07:50:09 +08:00
|
|
|
|
2021-09-01 17:52:55 +08:00
|
|
|
/* remove marked substream */
|
|
|
|
soc_component_mark_pop(component, cstream, compr_open);
|
2020-11-13 12:15:26 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_free);
|
|
|
|
|
2020-11-13 12:15:33 +08:00
|
|
|
int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->trigger) {
|
|
|
|
ret = component->driver->compress_ops->trigger(
|
|
|
|
component, cstream, cmd);
|
|
|
|
if (ret < 0)
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_trigger);
|
|
|
|
|
2020-11-13 12:15:49 +08:00
|
|
|
int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_compr_params *params)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->set_params) {
|
|
|
|
ret = component->driver->compress_ops->set_params(
|
|
|
|
component, cstream, params);
|
|
|
|
if (ret < 0)
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_params);
|
|
|
|
|
2020-11-13 12:15:56 +08:00
|
|
|
int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_codec *params)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->get_params) {
|
|
|
|
ret = component->driver->compress_ops->get_params(
|
|
|
|
component, cstream, params);
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_params);
|
|
|
|
|
2020-11-13 12:16:03 +08:00
|
|
|
int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_compr_caps *caps)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret = 0;
|
|
|
|
|
2023-04-06 08:16:10 +08:00
|
|
|
snd_soc_dpcm_mutex_lock(rtd);
|
2020-11-13 12:16:03 +08:00
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->get_caps) {
|
|
|
|
ret = component->driver->compress_ops->get_caps(
|
|
|
|
component, cstream, caps);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-06 08:16:10 +08:00
|
|
|
snd_soc_dpcm_mutex_unlock(rtd);
|
2020-11-13 12:16:03 +08:00
|
|
|
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_caps);
|
|
|
|
|
2020-11-13 12:16:11 +08:00
|
|
|
int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_compr_codec_caps *codec)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret = 0;
|
|
|
|
|
2023-04-06 08:16:10 +08:00
|
|
|
snd_soc_dpcm_mutex_lock(rtd);
|
2020-11-13 12:16:11 +08:00
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->get_codec_caps) {
|
|
|
|
ret = component->driver->compress_ops->get_codec_caps(
|
|
|
|
component, cstream, codec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-06 08:16:10 +08:00
|
|
|
snd_soc_dpcm_mutex_unlock(rtd);
|
2020-11-13 12:16:11 +08:00
|
|
|
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_codec_caps);
|
|
|
|
|
2020-11-13 12:16:17 +08:00
|
|
|
int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->ack) {
|
|
|
|
ret = component->driver->compress_ops->ack(
|
|
|
|
component, cstream, bytes);
|
|
|
|
if (ret < 0)
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_ack);
|
|
|
|
|
2020-11-13 12:16:24 +08:00
|
|
|
int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_compr_tstamp *tstamp)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->pointer) {
|
|
|
|
ret = component->driver->compress_ops->pointer(
|
|
|
|
component, cstream, tstamp);
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_pointer);
|
|
|
|
|
2020-11-13 12:16:30 +08:00
|
|
|
int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
|
|
|
|
char __user *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret = 0;
|
|
|
|
|
2023-04-06 08:16:10 +08:00
|
|
|
snd_soc_dpcm_mutex_lock(rtd);
|
2020-11-13 12:16:30 +08:00
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->copy) {
|
|
|
|
ret = component->driver->compress_ops->copy(
|
|
|
|
component, cstream, buf, count);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-06 08:16:10 +08:00
|
|
|
snd_soc_dpcm_mutex_unlock(rtd);
|
2020-11-13 12:16:30 +08:00
|
|
|
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_copy);
|
|
|
|
|
2020-11-13 12:16:36 +08:00
|
|
|
int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_compr_metadata *metadata)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->set_metadata) {
|
|
|
|
ret = component->driver->compress_ops->set_metadata(
|
|
|
|
component, cstream, metadata);
|
|
|
|
if (ret < 0)
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_metadata);
|
|
|
|
|
2020-11-13 12:16:41 +08:00
|
|
|
int snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_compr_metadata *metadata)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->compress_ops &&
|
|
|
|
component->driver->compress_ops->get_metadata) {
|
|
|
|
ret = component->driver->compress_ops->get_metadata(
|
|
|
|
component, cstream, metadata);
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_metadata);
|
|
|
|
|
2020-06-16 13:19:52 +08:00
|
|
|
static unsigned int soc_component_read_no_lock(
|
|
|
|
struct snd_soc_component *component,
|
|
|
|
unsigned int reg)
|
2020-06-04 16:08:03 +08:00
|
|
|
{
|
|
|
|
int ret;
|
ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc,
but these has been merged into snd_soc_component_read/write().
Internally, it is using regmap or driver function.
In read case, each styles are like below
regmap
ret = regmap_read(..., reg, &val);
driver function
val = xxx->read(..., reg);
Because of this kind of different style, to keep same read style,
when we merged each read function into snd_soc_component_read(),
we created snd_soc_component_read32(), like below.
commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32")
(1) val = snd_soc_component_read32(component, reg);
(2) ret = snd_soc_component_read(component, reg, &val);
Many drivers are using snd_soc_component_read32(), and
some drivers are using snd_soc_component_read() today.
In generally, we don't check read function successes,
because, we will have many other issues at initial timing
if read function didn't work.
Now we can use soc_component_err() when error case.
This means, it is easy to notice if error occurred.
This patch aggressively merge snd_soc_component_read() and _read32(),
and makes snd_soc_component_read/write() as generally style.
This patch do
1) merge snd_soc_component_read() and snd_soc_component_read32()
2) it uses soc_component_err() when error case (easy to notice)
3) keeps read32 for now by #define
4) update snd_soc_component_read() for all drivers
Because _read() user drivers are not too many, this patch changes
all user drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-16 13:19:41 +08:00
|
|
|
unsigned int val = 0;
|
2020-06-04 16:08:03 +08:00
|
|
|
|
|
|
|
if (component->regmap)
|
ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc,
but these has been merged into snd_soc_component_read/write().
Internally, it is using regmap or driver function.
In read case, each styles are like below
regmap
ret = regmap_read(..., reg, &val);
driver function
val = xxx->read(..., reg);
Because of this kind of different style, to keep same read style,
when we merged each read function into snd_soc_component_read(),
we created snd_soc_component_read32(), like below.
commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32")
(1) val = snd_soc_component_read32(component, reg);
(2) ret = snd_soc_component_read(component, reg, &val);
Many drivers are using snd_soc_component_read32(), and
some drivers are using snd_soc_component_read() today.
In generally, we don't check read function successes,
because, we will have many other issues at initial timing
if read function didn't work.
Now we can use soc_component_err() when error case.
This means, it is easy to notice if error occurred.
This patch aggressively merge snd_soc_component_read() and _read32(),
and makes snd_soc_component_read/write() as generally style.
This patch do
1) merge snd_soc_component_read() and snd_soc_component_read32()
2) it uses soc_component_err() when error case (easy to notice)
3) keeps read32 for now by #define
4) update snd_soc_component_read() for all drivers
Because _read() user drivers are not too many, this patch changes
all user drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-16 13:19:41 +08:00
|
|
|
ret = regmap_read(component->regmap, reg, &val);
|
2020-06-04 16:08:03 +08:00
|
|
|
else if (component->driver->read) {
|
|
|
|
ret = 0;
|
ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc,
but these has been merged into snd_soc_component_read/write().
Internally, it is using regmap or driver function.
In read case, each styles are like below
regmap
ret = regmap_read(..., reg, &val);
driver function
val = xxx->read(..., reg);
Because of this kind of different style, to keep same read style,
when we merged each read function into snd_soc_component_read(),
we created snd_soc_component_read32(), like below.
commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32")
(1) val = snd_soc_component_read32(component, reg);
(2) ret = snd_soc_component_read(component, reg, &val);
Many drivers are using snd_soc_component_read32(), and
some drivers are using snd_soc_component_read() today.
In generally, we don't check read function successes,
because, we will have many other issues at initial timing
if read function didn't work.
Now we can use soc_component_err() when error case.
This means, it is easy to notice if error occurred.
This patch aggressively merge snd_soc_component_read() and _read32(),
and makes snd_soc_component_read/write() as generally style.
This patch do
1) merge snd_soc_component_read() and snd_soc_component_read32()
2) it uses soc_component_err() when error case (easy to notice)
3) keeps read32 for now by #define
4) update snd_soc_component_read() for all drivers
Because _read() user drivers are not too many, this patch changes
all user drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-16 13:19:41 +08:00
|
|
|
val = component->driver->read(component, reg);
|
2020-06-04 16:08:03 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = -EIO;
|
|
|
|
|
|
|
|
if (ret < 0)
|
2021-10-15 00:13:30 +08:00
|
|
|
return soc_component_ret_reg_rw(component, ret, reg);
|
2020-06-04 16:08:03 +08:00
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
2020-06-16 13:19:52 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_read() - Read register value
|
|
|
|
* @component: Component to read from
|
|
|
|
* @reg: Register to read
|
|
|
|
*
|
|
|
|
* Return: read value
|
|
|
|
*/
|
|
|
|
unsigned int snd_soc_component_read(struct snd_soc_component *component,
|
|
|
|
unsigned int reg)
|
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
mutex_lock(&component->io_mutex);
|
|
|
|
val = soc_component_read_no_lock(component, reg);
|
|
|
|
mutex_unlock(&component->io_mutex);
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc,
but these has been merged into snd_soc_component_read/write().
Internally, it is using regmap or driver function.
In read case, each styles are like below
regmap
ret = regmap_read(..., reg, &val);
driver function
val = xxx->read(..., reg);
Because of this kind of different style, to keep same read style,
when we merged each read function into snd_soc_component_read(),
we created snd_soc_component_read32(), like below.
commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32")
(1) val = snd_soc_component_read32(component, reg);
(2) ret = snd_soc_component_read(component, reg, &val);
Many drivers are using snd_soc_component_read32(), and
some drivers are using snd_soc_component_read() today.
In generally, we don't check read function successes,
because, we will have many other issues at initial timing
if read function didn't work.
Now we can use soc_component_err() when error case.
This means, it is easy to notice if error occurred.
This patch aggressively merge snd_soc_component_read() and _read32(),
and makes snd_soc_component_read/write() as generally style.
This patch do
1) merge snd_soc_component_read() and snd_soc_component_read32()
2) it uses soc_component_err() when error case (easy to notice)
3) keeps read32 for now by #define
4) update snd_soc_component_read() for all drivers
Because _read() user drivers are not too many, this patch changes
all user drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-16 13:19:41 +08:00
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_read);
|
2020-06-04 16:08:03 +08:00
|
|
|
|
2020-06-16 13:19:52 +08:00
|
|
|
static int soc_component_write_no_lock(
|
|
|
|
struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int val)
|
|
|
|
{
|
|
|
|
int ret = -EIO;
|
|
|
|
|
|
|
|
if (component->regmap)
|
|
|
|
ret = regmap_write(component->regmap, reg, val);
|
|
|
|
else if (component->driver->write)
|
|
|
|
ret = component->driver->write(component, reg, val);
|
|
|
|
|
2021-10-15 00:13:30 +08:00
|
|
|
return soc_component_ret_reg_rw(component, ret, reg);
|
2020-06-16 13:19:52 +08:00
|
|
|
}
|
|
|
|
|
2020-06-04 16:08:03 +08:00
|
|
|
/**
|
|
|
|
* snd_soc_component_write() - Write register value
|
|
|
|
* @component: Component to write to
|
|
|
|
* @reg: Register to write
|
|
|
|
* @val: Value to write to the register
|
|
|
|
*
|
|
|
|
* Return: 0 on success, a negative error code otherwise.
|
|
|
|
*/
|
|
|
|
int snd_soc_component_write(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int val)
|
|
|
|
{
|
2020-06-16 13:19:52 +08:00
|
|
|
int ret;
|
2020-06-04 16:08:03 +08:00
|
|
|
|
2020-06-16 13:19:52 +08:00
|
|
|
mutex_lock(&component->io_mutex);
|
|
|
|
ret = soc_component_write_no_lock(component, reg, val);
|
|
|
|
mutex_unlock(&component->io_mutex);
|
2020-06-04 16:08:03 +08:00
|
|
|
|
2020-06-16 13:19:52 +08:00
|
|
|
return ret;
|
2020-06-04 16:08:03 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_write);
|
|
|
|
|
|
|
|
static int snd_soc_component_update_bits_legacy(
|
|
|
|
struct snd_soc_component *component, unsigned int reg,
|
|
|
|
unsigned int mask, unsigned int val, bool *change)
|
|
|
|
{
|
|
|
|
unsigned int old, new;
|
ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc,
but these has been merged into snd_soc_component_read/write().
Internally, it is using regmap or driver function.
In read case, each styles are like below
regmap
ret = regmap_read(..., reg, &val);
driver function
val = xxx->read(..., reg);
Because of this kind of different style, to keep same read style,
when we merged each read function into snd_soc_component_read(),
we created snd_soc_component_read32(), like below.
commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32")
(1) val = snd_soc_component_read32(component, reg);
(2) ret = snd_soc_component_read(component, reg, &val);
Many drivers are using snd_soc_component_read32(), and
some drivers are using snd_soc_component_read() today.
In generally, we don't check read function successes,
because, we will have many other issues at initial timing
if read function didn't work.
Now we can use soc_component_err() when error case.
This means, it is easy to notice if error occurred.
This patch aggressively merge snd_soc_component_read() and _read32(),
and makes snd_soc_component_read/write() as generally style.
This patch do
1) merge snd_soc_component_read() and snd_soc_component_read32()
2) it uses soc_component_err() when error case (easy to notice)
3) keeps read32 for now by #define
4) update snd_soc_component_read() for all drivers
Because _read() user drivers are not too many, this patch changes
all user drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-16 13:19:41 +08:00
|
|
|
int ret = 0;
|
2020-06-04 16:08:03 +08:00
|
|
|
|
|
|
|
mutex_lock(&component->io_mutex);
|
|
|
|
|
2020-06-16 13:19:52 +08:00
|
|
|
old = soc_component_read_no_lock(component, reg);
|
2020-06-04 16:08:03 +08:00
|
|
|
|
|
|
|
new = (old & ~mask) | (val & mask);
|
|
|
|
*change = old != new;
|
|
|
|
if (*change)
|
2020-06-16 13:19:52 +08:00
|
|
|
ret = soc_component_write_no_lock(component, reg, new);
|
ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc,
but these has been merged into snd_soc_component_read/write().
Internally, it is using regmap or driver function.
In read case, each styles are like below
regmap
ret = regmap_read(..., reg, &val);
driver function
val = xxx->read(..., reg);
Because of this kind of different style, to keep same read style,
when we merged each read function into snd_soc_component_read(),
we created snd_soc_component_read32(), like below.
commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32")
(1) val = snd_soc_component_read32(component, reg);
(2) ret = snd_soc_component_read(component, reg, &val);
Many drivers are using snd_soc_component_read32(), and
some drivers are using snd_soc_component_read() today.
In generally, we don't check read function successes,
because, we will have many other issues at initial timing
if read function didn't work.
Now we can use soc_component_err() when error case.
This means, it is easy to notice if error occurred.
This patch aggressively merge snd_soc_component_read() and _read32(),
and makes snd_soc_component_read/write() as generally style.
This patch do
1) merge snd_soc_component_read() and snd_soc_component_read32()
2) it uses soc_component_err() when error case (easy to notice)
3) keeps read32 for now by #define
4) update snd_soc_component_read() for all drivers
Because _read() user drivers are not too many, this patch changes
all user drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-16 13:19:41 +08:00
|
|
|
|
2020-06-04 16:08:03 +08:00
|
|
|
mutex_unlock(&component->io_mutex);
|
|
|
|
|
2021-10-15 00:13:30 +08:00
|
|
|
return soc_component_ret_reg_rw(component, ret, reg);
|
2020-06-04 16:08:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_update_bits() - Perform read/modify/write cycle
|
|
|
|
* @component: Component to update
|
|
|
|
* @reg: Register to update
|
|
|
|
* @mask: Mask that specifies which bits to update
|
|
|
|
* @val: New value for the bits specified by mask
|
|
|
|
*
|
|
|
|
* Return: 1 if the operation was successful and the value of the register
|
|
|
|
* changed, 0 if the operation was successful, but the value did not change.
|
|
|
|
* Returns a negative error code otherwise.
|
|
|
|
*/
|
|
|
|
int snd_soc_component_update_bits(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask, unsigned int val)
|
|
|
|
{
|
|
|
|
bool change;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (component->regmap)
|
|
|
|
ret = regmap_update_bits_check(component->regmap, reg, mask,
|
|
|
|
val, &change);
|
|
|
|
else
|
|
|
|
ret = snd_soc_component_update_bits_legacy(component, reg,
|
|
|
|
mask, val, &change);
|
|
|
|
|
|
|
|
if (ret < 0)
|
2021-10-15 00:13:30 +08:00
|
|
|
return soc_component_ret_reg_rw(component, ret, reg);
|
2020-06-04 16:08:03 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_update_bits);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_update_bits_async() - Perform asynchronous
|
|
|
|
* read/modify/write cycle
|
|
|
|
* @component: Component to update
|
|
|
|
* @reg: Register to update
|
|
|
|
* @mask: Mask that specifies which bits to update
|
|
|
|
* @val: New value for the bits specified by mask
|
|
|
|
*
|
|
|
|
* This function is similar to snd_soc_component_update_bits(), but the update
|
|
|
|
* operation is scheduled asynchronously. This means it may not be completed
|
|
|
|
* when the function returns. To make sure that all scheduled updates have been
|
|
|
|
* completed snd_soc_component_async_complete() must be called.
|
|
|
|
*
|
|
|
|
* Return: 1 if the operation was successful and the value of the register
|
|
|
|
* changed, 0 if the operation was successful, but the value did not change.
|
|
|
|
* Returns a negative error code otherwise.
|
|
|
|
*/
|
|
|
|
int snd_soc_component_update_bits_async(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask, unsigned int val)
|
|
|
|
{
|
|
|
|
bool change;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (component->regmap)
|
|
|
|
ret = regmap_update_bits_check_async(component->regmap, reg,
|
|
|
|
mask, val, &change);
|
|
|
|
else
|
|
|
|
ret = snd_soc_component_update_bits_legacy(component, reg,
|
|
|
|
mask, val, &change);
|
|
|
|
|
|
|
|
if (ret < 0)
|
2021-10-15 00:13:30 +08:00
|
|
|
return soc_component_ret_reg_rw(component, ret, reg);
|
2020-06-04 16:08:03 +08:00
|
|
|
return change;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_update_bits_async);
|
|
|
|
|
2021-01-27 01:17:48 +08:00
|
|
|
/**
|
|
|
|
* snd_soc_component_read_field() - Read register field value
|
|
|
|
* @component: Component to read from
|
|
|
|
* @reg: Register to read
|
|
|
|
* @mask: mask of the register field
|
|
|
|
*
|
|
|
|
* Return: read value of register field.
|
|
|
|
*/
|
|
|
|
unsigned int snd_soc_component_read_field(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask)
|
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
|
|
|
|
val = snd_soc_component_read(component, reg);
|
|
|
|
|
|
|
|
val = (val & mask) >> soc_component_field_shift(component, mask);
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_read_field);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_write_field() - write to register field
|
|
|
|
* @component: Component to write to
|
|
|
|
* @reg: Register to write
|
|
|
|
* @mask: mask of the register field to update
|
|
|
|
* @val: value of the field to write
|
|
|
|
*
|
|
|
|
* Return: 1 for change, otherwise 0.
|
|
|
|
*/
|
|
|
|
int snd_soc_component_write_field(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask,
|
|
|
|
unsigned int val)
|
|
|
|
{
|
|
|
|
|
|
|
|
val = (val << soc_component_field_shift(component, mask)) & mask;
|
|
|
|
|
|
|
|
return snd_soc_component_update_bits(component, reg, mask, val);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_write_field);
|
|
|
|
|
2020-06-04 16:08:03 +08:00
|
|
|
/**
|
|
|
|
* snd_soc_component_async_complete() - Ensure asynchronous I/O has completed
|
|
|
|
* @component: Component for which to wait
|
|
|
|
*
|
|
|
|
* This function blocks until all asynchronous I/O which has previously been
|
|
|
|
* scheduled using snd_soc_component_update_bits_async() has completed.
|
|
|
|
*/
|
|
|
|
void snd_soc_component_async_complete(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
if (component->regmap)
|
|
|
|
regmap_async_complete(component->regmap);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_async_complete);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_test_bits - Test register for change
|
|
|
|
* @component: component
|
|
|
|
* @reg: Register to test
|
|
|
|
* @mask: Mask that specifies which bits to test
|
|
|
|
* @value: Value to test against
|
|
|
|
*
|
|
|
|
* Tests a register with a new value and checks if the new value is
|
|
|
|
* different from the old value.
|
|
|
|
*
|
|
|
|
* Return: 1 for change, otherwise 0.
|
|
|
|
*/
|
|
|
|
int snd_soc_component_test_bits(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask, unsigned int value)
|
|
|
|
{
|
|
|
|
unsigned int old, new;
|
|
|
|
|
ASoC: soc-component: merge snd_soc_component_read() and snd_soc_component_read32()
We had read/write function for Codec, Platform, etc,
but these has been merged into snd_soc_component_read/write().
Internally, it is using regmap or driver function.
In read case, each styles are like below
regmap
ret = regmap_read(..., reg, &val);
driver function
val = xxx->read(..., reg);
Because of this kind of different style, to keep same read style,
when we merged each read function into snd_soc_component_read(),
we created snd_soc_component_read32(), like below.
commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32")
(1) val = snd_soc_component_read32(component, reg);
(2) ret = snd_soc_component_read(component, reg, &val);
Many drivers are using snd_soc_component_read32(), and
some drivers are using snd_soc_component_read() today.
In generally, we don't check read function successes,
because, we will have many other issues at initial timing
if read function didn't work.
Now we can use soc_component_err() when error case.
This means, it is easy to notice if error occurred.
This patch aggressively merge snd_soc_component_read() and _read32(),
and makes snd_soc_component_read/write() as generally style.
This patch do
1) merge snd_soc_component_read() and snd_soc_component_read32()
2) it uses soc_component_err() when error case (easy to notice)
3) keeps read32 for now by #define
4) update snd_soc_component_read() for all drivers
Because _read() user drivers are not too many, this patch changes
all user drivers.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-16 13:19:41 +08:00
|
|
|
old = snd_soc_component_read(component, reg);
|
2020-06-04 16:08:03 +08:00
|
|
|
new = (old & ~mask) | value;
|
|
|
|
return old != new;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_soc_component_test_bits);
|
|
|
|
|
2019-07-26 12:51:47 +08:00
|
|
|
int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
|
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2019-07-26 12:51:47 +08:00
|
|
|
struct snd_soc_component *component;
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
int i;
|
2019-07-26 12:51:47 +08:00
|
|
|
|
ASoC: soc-core: add for_each_rtd_components() and replace
ALSA SoC has for_each_rtdcom() which is link list for
rtd-component which is called as rtdcom. The relationship image is like below
rtdcom rtdcom rtdcom
component component component
rtd->component_list -> list -> list -> list ...
Here, the pointer get via normal link list is rtdcom,
Thus, current for_each loop is like below, and need to get
component via rtdcom->component
for_each_rtdcom(rtd, rtdcom) {
component = rtdcom->component;
...
}
but usually, user want to get pointer from for_each_xxx is component
directly, like below.
for_each_rtd_component(rtd, rtdcom, component) {
...
}
This patch expands list_for_each_entry manually, and enable to get
component directly from for_each macro.
Because of it, the macro becoming difficult to read,
but macro itself becoming useful.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878spm64m4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-15 11:59:31 +08:00
|
|
|
/* FIXME: use 1st pointer */
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
for_each_rtd_components(rtd, i, component)
|
ASoC: soc-core: merge snd_pcm_ops member to component driver
Current snd_soc_component_driver has snd_pcm_ops, and each driver can
have callback via it (1).
But, it is mainly created for ALSA, thus, it doesn't have "component"
as parameter for ALSA SoC (1)(2).
Thus, each callback can't know it is called for which component.
Thus, each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name (3).
--- ALSA SoC ---
...
if (component->driver->ops &&
component->driver->ops->open)
(1) return component->driver->ops->open(substream);
...
--- driver ---
(2) static int xxx_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
(3) struct snd_soc_component *component = snd_soc_rtdcom_lookup(..);
...
}
It works today, but, will not work in the future if we support multi
CPU/Codec/Platform, because 1 rtd might have multiple components which
have same driver name.
To solve this issue, each callback needs to be called with component.
We already have many component driver callback.
This patch copies each snd_pcm_ops member under component driver,
and having "component" as parameter.
--- ALSA SoC ---
...
if (component->driver->open)
=> return component->driver->open(component, substream);
...
--- driver ---
=> static int xxx_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
...
}
*Note*
Only Intel skl-pcm has .get_time_info implementation, but ALSA SoC
framework doesn't call it so far.
To keep its implementation, this patch keeps .get_time_info,
but it is still not called.
Intel guy need to support it in the future.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tv8raf3r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-02 13:30:48 +08:00
|
|
|
if (component->driver->pointer)
|
|
|
|
return component->driver->pointer(component, substream);
|
2019-07-26 12:51:47 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-07-26 12:51:51 +08:00
|
|
|
|
2022-05-13 17:05:32 +08:00
|
|
|
static bool snd_soc_component_is_codec_on_rtd(struct snd_soc_pcm_runtime *rtd,
|
|
|
|
struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
struct snd_soc_dai *dai;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for_each_rtd_codec_dais(rtd, i, dai) {
|
|
|
|
if (dai->component == component)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-16 15:45:18 +08:00
|
|
|
void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,
|
|
|
|
snd_pcm_sframes_t *cpu_delay,
|
|
|
|
snd_pcm_sframes_t *codec_delay)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
snd_pcm_sframes_t delay;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We're looking for the delay through the full audio path so it needs to
|
|
|
|
* be the maximum of the Components doing transmit and the maximum of the
|
|
|
|
* Components doing receive (ie, all CPUs and all CODECs) rather than
|
|
|
|
* just the maximum of all Components.
|
|
|
|
*/
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (!component->driver->delay)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
delay = component->driver->delay(component, substream);
|
|
|
|
|
2022-05-13 17:05:32 +08:00
|
|
|
if (snd_soc_component_is_codec_on_rtd(rtd, component))
|
2021-11-16 15:45:18 +08:00
|
|
|
*codec_delay = max(*codec_delay, delay);
|
|
|
|
else
|
|
|
|
*cpu_delay = max(*cpu_delay, delay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-26 12:51:51 +08:00
|
|
|
int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
|
|
|
|
unsigned int cmd, void *arg)
|
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2019-07-26 12:51:51 +08:00
|
|
|
struct snd_soc_component *component;
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
int i;
|
2019-07-26 12:51:51 +08:00
|
|
|
|
ASoC: soc-core: add for_each_rtd_components() and replace
ALSA SoC has for_each_rtdcom() which is link list for
rtd-component which is called as rtdcom. The relationship image is like below
rtdcom rtdcom rtdcom
component component component
rtd->component_list -> list -> list -> list ...
Here, the pointer get via normal link list is rtdcom,
Thus, current for_each loop is like below, and need to get
component via rtdcom->component
for_each_rtdcom(rtd, rtdcom) {
component = rtdcom->component;
...
}
but usually, user want to get pointer from for_each_xxx is component
directly, like below.
for_each_rtd_component(rtd, rtdcom, component) {
...
}
This patch expands list_for_each_entry manually, and enable to get
component directly from for_each macro.
Because of it, the macro becoming difficult to read,
but macro itself becoming useful.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878spm64m4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-15 11:59:31 +08:00
|
|
|
/* FIXME: use 1st ioctl */
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
for_each_rtd_components(rtd, i, component)
|
ASoC: soc-core: merge snd_pcm_ops member to component driver
Current snd_soc_component_driver has snd_pcm_ops, and each driver can
have callback via it (1).
But, it is mainly created for ALSA, thus, it doesn't have "component"
as parameter for ALSA SoC (1)(2).
Thus, each callback can't know it is called for which component.
Thus, each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name (3).
--- ALSA SoC ---
...
if (component->driver->ops &&
component->driver->ops->open)
(1) return component->driver->ops->open(substream);
...
--- driver ---
(2) static int xxx_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
(3) struct snd_soc_component *component = snd_soc_rtdcom_lookup(..);
...
}
It works today, but, will not work in the future if we support multi
CPU/Codec/Platform, because 1 rtd might have multiple components which
have same driver name.
To solve this issue, each callback needs to be called with component.
We already have many component driver callback.
This patch copies each snd_pcm_ops member under component driver,
and having "component" as parameter.
--- ALSA SoC ---
...
if (component->driver->open)
=> return component->driver->open(component, substream);
...
--- driver ---
=> static int xxx_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
...
}
*Note*
Only Intel skl-pcm has .get_time_info implementation, but ALSA SoC
framework doesn't call it so far.
To keep its implementation, this patch keeps .get_time_info,
but it is still not called.
Intel guy need to support it in the future.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tv8raf3r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-02 13:30:48 +08:00
|
|
|
if (component->driver->ioctl)
|
2020-06-04 16:06:41 +08:00
|
|
|
return soc_component_ret(
|
|
|
|
component,
|
|
|
|
component->driver->ioctl(component,
|
|
|
|
substream, cmd, arg));
|
2019-07-26 12:51:51 +08:00
|
|
|
|
|
|
|
return snd_pcm_lib_ioctl(substream, cmd, arg);
|
|
|
|
}
|
2019-07-26 12:51:56 +08:00
|
|
|
|
2019-11-22 03:07:09 +08:00
|
|
|
int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream)
|
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2019-11-22 03:07:09 +08:00
|
|
|
struct snd_soc_component *component;
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
int i, ret;
|
2019-11-22 03:07:09 +08:00
|
|
|
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
for_each_rtd_components(rtd, i, component) {
|
2020-02-28 09:48:35 +08:00
|
|
|
if (component->driver->sync_stop) {
|
2019-11-22 03:07:09 +08:00
|
|
|
ret = component->driver->sync_stop(component,
|
|
|
|
substream);
|
|
|
|
if (ret < 0)
|
2020-07-16 13:07:08 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-11-22 03:07:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-08-16 03:01:29 +08:00
|
|
|
int snd_soc_pcm_component_copy(struct snd_pcm_substream *substream,
|
|
|
|
int channel, unsigned long pos,
|
2023-08-31 21:04:57 +08:00
|
|
|
struct iov_iter *iter, unsigned long bytes)
|
2023-08-16 03:01:29 +08:00
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* FIXME. it returns 1st copy now */
|
|
|
|
for_each_rtd_components(rtd, i, component)
|
|
|
|
if (component->driver->copy)
|
|
|
|
return soc_component_ret(component,
|
|
|
|
component->driver->copy(component, substream,
|
2023-08-31 21:04:57 +08:00
|
|
|
channel, pos, iter, bytes));
|
2023-08-16 03:01:29 +08:00
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2019-07-26 12:52:00 +08:00
|
|
|
struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
|
|
|
|
unsigned long offset)
|
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2019-07-26 12:52:00 +08:00
|
|
|
struct snd_soc_component *component;
|
|
|
|
struct page *page;
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
int i;
|
2019-07-26 12:52:00 +08:00
|
|
|
|
ASoC: soc-core: add for_each_rtd_components() and replace
ALSA SoC has for_each_rtdcom() which is link list for
rtd-component which is called as rtdcom. The relationship image is like below
rtdcom rtdcom rtdcom
component component component
rtd->component_list -> list -> list -> list ...
Here, the pointer get via normal link list is rtdcom,
Thus, current for_each loop is like below, and need to get
component via rtdcom->component
for_each_rtdcom(rtd, rtdcom) {
component = rtdcom->component;
...
}
but usually, user want to get pointer from for_each_xxx is component
directly, like below.
for_each_rtd_component(rtd, rtdcom, component) {
...
}
This patch expands list_for_each_entry manually, and enable to get
component directly from for_each macro.
Because of it, the macro becoming difficult to read,
but macro itself becoming useful.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878spm64m4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-15 11:59:31 +08:00
|
|
|
/* FIXME. it returns 1st page now */
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
for_each_rtd_components(rtd, i, component) {
|
ASoC: soc-core: merge snd_pcm_ops member to component driver
Current snd_soc_component_driver has snd_pcm_ops, and each driver can
have callback via it (1).
But, it is mainly created for ALSA, thus, it doesn't have "component"
as parameter for ALSA SoC (1)(2).
Thus, each callback can't know it is called for which component.
Thus, each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name (3).
--- ALSA SoC ---
...
if (component->driver->ops &&
component->driver->ops->open)
(1) return component->driver->ops->open(substream);
...
--- driver ---
(2) static int xxx_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
(3) struct snd_soc_component *component = snd_soc_rtdcom_lookup(..);
...
}
It works today, but, will not work in the future if we support multi
CPU/Codec/Platform, because 1 rtd might have multiple components which
have same driver name.
To solve this issue, each callback needs to be called with component.
We already have many component driver callback.
This patch copies each snd_pcm_ops member under component driver,
and having "component" as parameter.
--- ALSA SoC ---
...
if (component->driver->open)
=> return component->driver->open(component, substream);
...
--- driver ---
=> static int xxx_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
...
}
*Note*
Only Intel skl-pcm has .get_time_info implementation, but ALSA SoC
framework doesn't call it so far.
To keep its implementation, this patch keeps .get_time_info,
but it is still not called.
Intel guy need to support it in the future.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tv8raf3r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-02 13:30:48 +08:00
|
|
|
if (component->driver->page) {
|
|
|
|
page = component->driver->page(component,
|
|
|
|
substream, offset);
|
|
|
|
if (page)
|
|
|
|
return page;
|
|
|
|
}
|
2019-07-26 12:52:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-07-26 12:52:04 +08:00
|
|
|
|
|
|
|
int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
|
|
|
|
struct vm_area_struct *vma)
|
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2019-07-26 12:52:04 +08:00
|
|
|
struct snd_soc_component *component;
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
int i;
|
2019-07-26 12:52:04 +08:00
|
|
|
|
ASoC: soc-core: add for_each_rtd_components() and replace
ALSA SoC has for_each_rtdcom() which is link list for
rtd-component which is called as rtdcom. The relationship image is like below
rtdcom rtdcom rtdcom
component component component
rtd->component_list -> list -> list -> list ...
Here, the pointer get via normal link list is rtdcom,
Thus, current for_each loop is like below, and need to get
component via rtdcom->component
for_each_rtdcom(rtd, rtdcom) {
component = rtdcom->component;
...
}
but usually, user want to get pointer from for_each_xxx is component
directly, like below.
for_each_rtd_component(rtd, rtdcom, component) {
...
}
This patch expands list_for_each_entry manually, and enable to get
component directly from for_each macro.
Because of it, the macro becoming difficult to read,
but macro itself becoming useful.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878spm64m4.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-15 11:59:31 +08:00
|
|
|
/* FIXME. it returns 1st mmap now */
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
for_each_rtd_components(rtd, i, component)
|
ASoC: soc-core: merge snd_pcm_ops member to component driver
Current snd_soc_component_driver has snd_pcm_ops, and each driver can
have callback via it (1).
But, it is mainly created for ALSA, thus, it doesn't have "component"
as parameter for ALSA SoC (1)(2).
Thus, each callback can't know it is called for which component.
Thus, each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name (3).
--- ALSA SoC ---
...
if (component->driver->ops &&
component->driver->ops->open)
(1) return component->driver->ops->open(substream);
...
--- driver ---
(2) static int xxx_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
(3) struct snd_soc_component *component = snd_soc_rtdcom_lookup(..);
...
}
It works today, but, will not work in the future if we support multi
CPU/Codec/Platform, because 1 rtd might have multiple components which
have same driver name.
To solve this issue, each callback needs to be called with component.
We already have many component driver callback.
This patch copies each snd_pcm_ops member under component driver,
and having "component" as parameter.
--- ALSA SoC ---
...
if (component->driver->open)
=> return component->driver->open(component, substream);
...
--- driver ---
=> static int xxx_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
...
}
*Note*
Only Intel skl-pcm has .get_time_info implementation, but ALSA SoC
framework doesn't call it so far.
To keep its implementation, this patch keeps .get_time_info,
but it is still not called.
Intel guy need to support it in the future.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tv8raf3r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-02 13:30:48 +08:00
|
|
|
if (component->driver->mmap)
|
2020-07-16 13:07:08 +08:00
|
|
|
return soc_component_ret(
|
2020-06-04 16:06:41 +08:00
|
|
|
component,
|
|
|
|
component->driver->mmap(component,
|
|
|
|
substream, vma));
|
2019-07-26 12:52:04 +08:00
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2019-07-26 12:52:08 +08:00
|
|
|
|
2019-11-18 09:50:32 +08:00
|
|
|
int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd)
|
2019-07-26 12:52:08 +08:00
|
|
|
{
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int ret;
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
int i;
|
2019-07-26 12:52:08 +08:00
|
|
|
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
for_each_rtd_components(rtd, i, component) {
|
2019-10-02 13:30:59 +08:00
|
|
|
if (component->driver->pcm_construct) {
|
|
|
|
ret = component->driver->pcm_construct(component, rtd);
|
|
|
|
if (ret < 0)
|
2020-07-16 13:07:08 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2019-10-02 13:30:59 +08:00
|
|
|
}
|
2019-07-26 12:52:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-07-26 12:52:12 +08:00
|
|
|
|
2019-11-18 09:50:32 +08:00
|
|
|
void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd)
|
2019-07-26 12:52:12 +08:00
|
|
|
{
|
|
|
|
struct snd_soc_component *component;
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
int i;
|
2019-07-26 12:52:12 +08:00
|
|
|
|
2020-01-07 15:09:56 +08:00
|
|
|
if (!rtd->pcm)
|
|
|
|
return;
|
|
|
|
|
ASoC: soc-core: remove snd_soc_rtdcom_list
Current ALSA SoC is using struct snd_soc_rtdcom_list to
connecting component to rtd by using list_head.
struct snd_soc_rtdcom_list {
struct snd_soc_component *component;
struct list_head list; /* rtd::component_list */
};
struct snd_soc_pcm_runtime {
...
struct list_head component_list; /* list of connected components */
...
};
The CPU/Codec/Platform component which will be connected to rtd (a)
is indicated via dai_link at snd_soc_add_pcm_runtime()
int snd_soc_add_pcm_runtime(...)
{
...
/* Find CPU from registered CPUs */
rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus);
...
(a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component);
...
/* Find CODEC from registered CODECs */
(b) for_each_link_codecs(dai_link, i, codec) {
rtd->codec_dais[i] = snd_soc_find_dai(codec);
...
(a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component);
}
...
/* Find PLATFORM from registered PLATFORMs */
(b) for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
...
(a) snd_soc_rtdcom_add(rtd, component);
}
}
}
It shows, it is possible to know how many components will be
connected to rtd by using
dai_link->num_cpus
dai_link->num_codecs
dai_link->num_platforms
If so, we can use component pointer array instead of list_head,
in such case, code can be more simple.
This patch removes struct snd_soc_rtdcom_list that is only
of temporary value, and convert to pointer array.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10 10:35:21 +08:00
|
|
|
for_each_rtd_components(rtd, i, component)
|
2019-10-02 13:30:59 +08:00
|
|
|
if (component->driver->pcm_destruct)
|
2019-11-18 09:50:32 +08:00
|
|
|
component->driver->pcm_destruct(component, rtd->pcm);
|
2019-07-26 12:52:12 +08:00
|
|
|
}
|
2020-06-04 16:06:58 +08:00
|
|
|
|
|
|
|
int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream)
|
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2020-06-04 16:06:58 +08:00
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->prepare) {
|
|
|
|
ret = component->driver->prepare(component, substream);
|
|
|
|
if (ret < 0)
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2020-06-04 16:07:11 +08:00
|
|
|
|
|
|
|
int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
|
ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
=> 2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
This patch is for 2) snd_soc_pcm_component_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-29 12:31:41 +08:00
|
|
|
struct snd_pcm_hw_params *params)
|
2020-06-04 16:07:11 +08:00
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2020-06-04 16:07:11 +08:00
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (component->driver->hw_params) {
|
|
|
|
ret = component->driver->hw_params(component,
|
|
|
|
substream, params);
|
ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
=> 2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
This patch is for 2) snd_soc_pcm_component_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-29 12:31:41 +08:00
|
|
|
if (ret < 0)
|
2020-06-04 16:07:11 +08:00
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
=> 2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
This patch is for 2) snd_soc_pcm_component_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-29 12:31:41 +08:00
|
|
|
/* mark substream if succeeded */
|
|
|
|
soc_component_mark_push(component, substream, hw_params);
|
2020-06-04 16:07:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2020-06-04 16:07:24 +08:00
|
|
|
|
|
|
|
void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream,
|
ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
=> 2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
This patch is for 2) snd_soc_pcm_component_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-29 12:31:41 +08:00
|
|
|
int rollback)
|
2020-06-04 16:07:24 +08:00
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2020-06-04 16:07:24 +08:00
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
=> 2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
This patch is for 2) snd_soc_pcm_component_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-29 12:31:41 +08:00
|
|
|
if (rollback && !soc_component_mark_match(component, substream, hw_params))
|
|
|
|
continue;
|
2020-06-04 16:07:24 +08:00
|
|
|
|
|
|
|
if (component->driver->hw_free) {
|
|
|
|
ret = component->driver->hw_free(component, substream);
|
|
|
|
if (ret < 0)
|
|
|
|
soc_component_ret(component, ret);
|
|
|
|
}
|
ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()
soc_pcm_hw_params() does rollback when failed (A),
but, it is almost same as soc_pcm_hw_free().
static int soc_pcm_hw_params(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return ret;
^ component_err:
| ...
| interface_err:
(A) ...
| codec_err:
| ...
v return ret;
}
The difference is
soc_pcm_hw_free() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_hw_free() and rollback.
Now, soc_pcm_hw_params/free() are handling
1) snd_soc_link_hw_params/free()
=> 2) snd_soc_pcm_component_hw_params/free()
3) snd_soc_dai_hw_params/free()
This patch is for 2) snd_soc_pcm_component_hw_params/free().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when hw_params() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *previous* hw_params() only now,
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-29 12:31:41 +08:00
|
|
|
|
|
|
|
/* remove marked substream */
|
|
|
|
soc_component_mark_pop(component, substream, hw_params);
|
2020-06-04 16:07:24 +08:00
|
|
|
}
|
|
|
|
}
|
2020-06-04 16:07:40 +08:00
|
|
|
|
ASoC: soc-pcm: care trigger rollback
soc_pcm_trigger() calls DAI/Component/Link trigger,
but some of them might be failed.
static int soc_pcm_trigger(...)
{
...
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
ret = snd_soc_link_trigger(substream, cmd);
if (ret < 0)
break;
(*) ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_dai_trigger(substream, cmd);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
ret = snd_soc_pcm_dai_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_link_trigger(substream, cmd);
break;
}
...
}
For example, if soc_pcm_trigger() failed at (*) point,
we need to rollback previous succeeded trigger.
This patch adds trigger mark for DAI/Component/Link,
and do STOP if START/RESUME/PAUSE_RELEASE were failed.
Because it need to use new rollback parameter,
we need to modify DAI/Component/Link trigger functions in the same time.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6uycssd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-01 07:51:33 +08:00
|
|
|
static int soc_component_trigger(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream,
|
|
|
|
int cmd)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (component->driver->trigger)
|
|
|
|
ret = component->driver->trigger(component, substream, cmd);
|
|
|
|
|
|
|
|
return soc_component_ret(component, ret);
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:07:40 +08:00
|
|
|
int snd_soc_pcm_component_trigger(struct snd_pcm_substream *substream,
|
ASoC: soc-pcm: care trigger rollback
soc_pcm_trigger() calls DAI/Component/Link trigger,
but some of them might be failed.
static int soc_pcm_trigger(...)
{
...
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
ret = snd_soc_link_trigger(substream, cmd);
if (ret < 0)
break;
(*) ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_dai_trigger(substream, cmd);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
ret = snd_soc_pcm_dai_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_link_trigger(substream, cmd);
break;
}
...
}
For example, if soc_pcm_trigger() failed at (*) point,
we need to rollback previous succeeded trigger.
This patch adds trigger mark for DAI/Component/Link,
and do STOP if START/RESUME/PAUSE_RELEASE were failed.
Because it need to use new rollback parameter,
we need to modify DAI/Component/Link trigger functions in the same time.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6uycssd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-01 07:51:33 +08:00
|
|
|
int cmd, int rollback)
|
2020-06-04 16:07:40 +08:00
|
|
|
{
|
2020-07-20 09:17:39 +08:00
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
2020-06-04 16:07:40 +08:00
|
|
|
struct snd_soc_component *component;
|
ASoC: soc-pcm: care trigger rollback
soc_pcm_trigger() calls DAI/Component/Link trigger,
but some of them might be failed.
static int soc_pcm_trigger(...)
{
...
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
ret = snd_soc_link_trigger(substream, cmd);
if (ret < 0)
break;
(*) ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_dai_trigger(substream, cmd);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
ret = snd_soc_pcm_dai_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_link_trigger(substream, cmd);
break;
}
...
}
For example, if soc_pcm_trigger() failed at (*) point,
we need to rollback previous succeeded trigger.
This patch adds trigger mark for DAI/Component/Link,
and do STOP if START/RESUME/PAUSE_RELEASE were failed.
Because it need to use new rollback parameter,
we need to modify DAI/Component/Link trigger functions in the same time.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6uycssd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-01 07:51:33 +08:00
|
|
|
int i, r, ret = 0;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SNDRV_PCM_TRIGGER_START:
|
|
|
|
case SNDRV_PCM_TRIGGER_RESUME:
|
|
|
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
ret = soc_component_trigger(component, substream, cmd);
|
2020-06-04 16:07:40 +08:00
|
|
|
if (ret < 0)
|
ASoC: soc-pcm: care trigger rollback
soc_pcm_trigger() calls DAI/Component/Link trigger,
but some of them might be failed.
static int soc_pcm_trigger(...)
{
...
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
ret = snd_soc_link_trigger(substream, cmd);
if (ret < 0)
break;
(*) ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_dai_trigger(substream, cmd);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
ret = snd_soc_pcm_dai_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_link_trigger(substream, cmd);
break;
}
...
}
For example, if soc_pcm_trigger() failed at (*) point,
we need to rollback previous succeeded trigger.
This patch adds trigger mark for DAI/Component/Link,
and do STOP if START/RESUME/PAUSE_RELEASE were failed.
Because it need to use new rollback parameter,
we need to modify DAI/Component/Link trigger functions in the same time.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6uycssd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-01 07:51:33 +08:00
|
|
|
break;
|
|
|
|
soc_component_mark_push(component, substream, trigger);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
|
|
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
|
|
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (rollback && !soc_component_mark_match(component, substream, trigger))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
r = soc_component_trigger(component, substream, cmd);
|
|
|
|
if (r < 0)
|
|
|
|
ret = r; /* use last ret */
|
|
|
|
soc_component_mark_pop(component, substream, trigger);
|
2020-06-04 16:07:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ASoC: soc-pcm: care trigger rollback
soc_pcm_trigger() calls DAI/Component/Link trigger,
but some of them might be failed.
static int soc_pcm_trigger(...)
{
...
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
ret = snd_soc_link_trigger(substream, cmd);
if (ret < 0)
break;
(*) ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_dai_trigger(substream, cmd);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
ret = snd_soc_pcm_dai_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_pcm_component_trigger(substream, cmd);
if (ret < 0)
break;
ret = snd_soc_link_trigger(substream, cmd);
break;
}
...
}
For example, if soc_pcm_trigger() failed at (*) point,
we need to rollback previous succeeded trigger.
This patch adds trigger mark for DAI/Component/Link,
and do STOP if START/RESUME/PAUSE_RELEASE were failed.
Because it need to use new rollback parameter,
we need to modify DAI/Component/Link trigger functions in the same time.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6uycssd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-01 07:51:33 +08:00
|
|
|
return ret;
|
2020-06-04 16:07:40 +08:00
|
|
|
}
|
ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
=> 5) pm_runtime_put/get()
This patch is for 5) pm_runtime_put/get().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when get() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* get() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ribwnb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:17 +08:00
|
|
|
|
|
|
|
int snd_soc_pcm_component_pm_runtime_get(struct snd_soc_pcm_runtime *rtd,
|
|
|
|
void *stream)
|
|
|
|
{
|
|
|
|
struct snd_soc_component *component;
|
2021-08-16 12:56:19 +08:00
|
|
|
int i;
|
ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
=> 5) pm_runtime_put/get()
This patch is for 5) pm_runtime_put/get().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when get() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* get() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ribwnb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:17 +08:00
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
2022-10-04 19:51:21 +08:00
|
|
|
int ret = pm_runtime_get_sync(component->dev);
|
|
|
|
if (ret < 0 && ret != -EACCES) {
|
|
|
|
pm_runtime_put_noidle(component->dev);
|
ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
=> 5) pm_runtime_put/get()
This patch is for 5) pm_runtime_put/get().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when get() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* get() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ribwnb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:17 +08:00
|
|
|
return soc_component_ret(component, ret);
|
2022-10-04 19:51:21 +08:00
|
|
|
}
|
ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put()
soc_pcm_open() does rollback when failed (A),
but, it is almost same as soc_pcm_close().
static int soc_pcm_open(xxx)
{
...
if (ret < 0)
goto xxx_err;
...
return 0;
^ config_err:
| ...
| rtd_startup_err:
(A) ...
| component_err:
| ...
v return ret;
}
The difference is
soc_pcm_close() is for all dai/component/substream,
rollback is for succeeded part only.
This kind of duplicated code can be a hotbed of bugs,
thus, we want to share soc_pcm_close() and rollback.
Now, soc_pcm_open/close() are handling
1) snd_soc_dai_startup/shutdown()
2) snd_soc_link_startup/shutdown()
3) snd_soc_component_module_get/put()
4) snd_soc_component_open/close()
=> 5) pm_runtime_put/get()
This patch is for 5) pm_runtime_put/get().
The idea of having bit-flag or counter is not enough for this purpose.
For example if one DAI is used for 2xPlaybacks for some reasons,
and if 1st Playback was succeeded but 2nd Playback was failed,
2nd Playback rollback doesn't need to call shutdown.
But it has succeeded bit-flag or counter via 1st Playback,
thus, 2nd Playback rollback will call unneeded shutdown.
And 1st Playback's necessary shutdown will not be called,
because bit-flag or counter was cleared by wrong 2nd Playback rollback.
To avoid such case, this patch marks substream pointer when get() was
succeeded. If rollback needed, it will check rollback flag and marked
substream pointer.
One note here is that it cares *current* get() only now.
but we might want to check *whole* marked substream in the future.
This patch is using macro named "push/pop", so that it can be easily
update.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ribwnb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28 08:01:17 +08:00
|
|
|
/* mark stream if succeeded */
|
|
|
|
soc_component_mark_push(component, stream, pm);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void snd_soc_pcm_component_pm_runtime_put(struct snd_soc_pcm_runtime *rtd,
|
|
|
|
void *stream, int rollback)
|
|
|
|
{
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for_each_rtd_components(rtd, i, component) {
|
|
|
|
if (rollback && !soc_component_mark_match(component, stream, pm))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pm_runtime_mark_last_busy(component->dev);
|
|
|
|
pm_runtime_put_autosuspend(component->dev);
|
|
|
|
|
|
|
|
/* remove marked stream */
|
|
|
|
soc_component_mark_pop(component, stream, pm);
|
|
|
|
}
|
|
|
|
}
|
2021-03-12 10:38:40 +08:00
|
|
|
|
|
|
|
int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
|
|
|
struct snd_soc_component *component;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* FIXME: use 1st pointer */
|
|
|
|
for_each_rtd_components(rtd, i, component)
|
|
|
|
if (component->driver->ack)
|
|
|
|
return component->driver->ack(component, substream);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|