2019-07-26 12:49:48 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
|
|
|
* soc-component.h
|
|
|
|
*
|
2020-06-04 16:08:24 +08:00
|
|
|
* Copyright (C) 2019 Renesas Electronics Corp.
|
|
|
|
* Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
|
2019-07-26 12:49:48 +08:00
|
|
|
*/
|
|
|
|
#ifndef __SOC_COMPONENT_H
|
|
|
|
#define __SOC_COMPONENT_H
|
|
|
|
|
|
|
|
#include <sound/soc.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Component probe and remove ordering levels for components with runtime
|
|
|
|
* dependencies.
|
|
|
|
*/
|
|
|
|
#define SND_SOC_COMP_ORDER_FIRST -2
|
|
|
|
#define SND_SOC_COMP_ORDER_EARLY -1
|
|
|
|
#define SND_SOC_COMP_ORDER_NORMAL 0
|
|
|
|
#define SND_SOC_COMP_ORDER_LATE 1
|
|
|
|
#define SND_SOC_COMP_ORDER_LAST 2
|
|
|
|
|
|
|
|
#define for_each_comp_order(order) \
|
|
|
|
for (order = SND_SOC_COMP_ORDER_FIRST; \
|
|
|
|
order <= SND_SOC_COMP_ORDER_LAST; \
|
|
|
|
order++)
|
|
|
|
|
|
|
|
/* component interface */
|
ASoC: soc-compress: add snd_compress_ops
Current snd_soc_component_driver has compr_ops, and each driver can
have callback via it. But, it is mainly created for ALSA, thus, it
doesn't have "component" as parameter.
Thus, each callback can't know it is called for which component.
Each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name.
--- ALSA SoC ---
...
if (component->driver->compr_ops &&
component->driver->compr_ops->open)
=> return component->driver->compr_ops->open(stream);
...
--- driver ---
static int xxx_open(struct snd_compr_stream *stream)
{
struct snd_soc_pcm_runtime *rtd = stream->private_data;
=> 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 same driver
name component.
To solve this issue, each callback need to be called with component.
We already have many component driver callbacks.
This patch adds new snd_compress_ops, and call it with "component".
--- ALSA SoC ---
...
if (component->driver->compress_ops->open)
=> return component->driver->compress_ops->open(
component, substream);
~~~~~~~~~
...
--- driver ---
static int xxx_open(struct snd_soc_component *component,
struct snd_compr_stream *stream)
{
=> /* it don't need to use snd_soc_rtdcom_lookup() */
...
}
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87v9luvdmh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-04-20 15:07:50 +08:00
|
|
|
struct snd_compress_ops {
|
|
|
|
int (*open)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream);
|
|
|
|
int (*free)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream);
|
|
|
|
int (*set_params)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream,
|
|
|
|
struct snd_compr_params *params);
|
|
|
|
int (*get_params)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream,
|
|
|
|
struct snd_codec *params);
|
|
|
|
int (*set_metadata)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream,
|
|
|
|
struct snd_compr_metadata *metadata);
|
|
|
|
int (*get_metadata)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream,
|
|
|
|
struct snd_compr_metadata *metadata);
|
|
|
|
int (*trigger)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream, int cmd);
|
|
|
|
int (*pointer)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream,
|
|
|
|
struct snd_compr_tstamp *tstamp);
|
|
|
|
int (*copy)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream, char __user *buf,
|
|
|
|
size_t count);
|
|
|
|
int (*mmap)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream,
|
|
|
|
struct vm_area_struct *vma);
|
|
|
|
int (*ack)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream, size_t bytes);
|
|
|
|
int (*get_caps)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream,
|
|
|
|
struct snd_compr_caps *caps);
|
|
|
|
int (*get_codec_caps)(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *stream,
|
|
|
|
struct snd_compr_codec_caps *codec);
|
|
|
|
};
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
struct snd_soc_component_driver {
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* Default control and setup, added after probe() is run */
|
|
|
|
const struct snd_kcontrol_new *controls;
|
|
|
|
unsigned int num_controls;
|
|
|
|
const struct snd_soc_dapm_widget *dapm_widgets;
|
|
|
|
unsigned int num_dapm_widgets;
|
|
|
|
const struct snd_soc_dapm_route *dapm_routes;
|
|
|
|
unsigned int num_dapm_routes;
|
|
|
|
|
|
|
|
int (*probe)(struct snd_soc_component *component);
|
|
|
|
void (*remove)(struct snd_soc_component *component);
|
|
|
|
int (*suspend)(struct snd_soc_component *component);
|
|
|
|
int (*resume)(struct snd_soc_component *component);
|
|
|
|
|
|
|
|
unsigned int (*read)(struct snd_soc_component *component,
|
|
|
|
unsigned int reg);
|
|
|
|
int (*write)(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int val);
|
|
|
|
|
|
|
|
/* pcm creation and destruction */
|
2019-10-02 13:30:59 +08:00
|
|
|
int (*pcm_construct)(struct snd_soc_component *component,
|
|
|
|
struct snd_soc_pcm_runtime *rtd);
|
|
|
|
void (*pcm_destruct)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm *pcm);
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
/* component wide operations */
|
|
|
|
int (*set_sysclk)(struct snd_soc_component *component,
|
|
|
|
int clk_id, int source, unsigned int freq, int dir);
|
|
|
|
int (*set_pll)(struct snd_soc_component *component, int pll_id,
|
|
|
|
int source, unsigned int freq_in, unsigned int freq_out);
|
|
|
|
int (*set_jack)(struct snd_soc_component *component,
|
|
|
|
struct snd_soc_jack *jack, void *data);
|
|
|
|
|
|
|
|
/* DT */
|
|
|
|
int (*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:49:48 +08:00
|
|
|
const char **dai_name);
|
|
|
|
int (*of_xlate_dai_id)(struct snd_soc_component *comment,
|
|
|
|
struct device_node *endpoint);
|
|
|
|
void (*seq_notifier)(struct snd_soc_component *component,
|
|
|
|
enum snd_soc_dapm_type type, int subseq);
|
|
|
|
int (*stream_event)(struct snd_soc_component *component, int event);
|
|
|
|
int (*set_bias_level)(struct snd_soc_component *component,
|
|
|
|
enum snd_soc_bias_level level);
|
|
|
|
|
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
|
|
|
int (*open)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
|
|
|
int (*close)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
|
|
|
int (*ioctl)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream,
|
|
|
|
unsigned int cmd, void *arg);
|
|
|
|
int (*hw_params)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *params);
|
|
|
|
int (*hw_free)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
|
|
|
int (*prepare)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
|
|
|
int (*trigger)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream, int cmd);
|
2019-11-22 03:07:09 +08:00
|
|
|
int (*sync_stop)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
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
|
|
|
snd_pcm_uframes_t (*pointer)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
|
|
|
int (*get_time_info)(struct snd_soc_component *component,
|
2018-04-24 20:06:08 +08:00
|
|
|
struct snd_pcm_substream *substream, struct timespec64 *system_ts,
|
|
|
|
struct timespec64 *audio_ts,
|
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
|
|
|
struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
|
|
|
|
struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
|
|
|
|
int (*copy_user)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream, int channel,
|
|
|
|
unsigned long pos, void __user *buf,
|
|
|
|
unsigned long bytes);
|
|
|
|
struct page *(*page)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream,
|
|
|
|
unsigned long offset);
|
|
|
|
int (*mmap)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream,
|
|
|
|
struct vm_area_struct *vma);
|
2021-03-12 10:38:40 +08:00
|
|
|
int (*ack)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
2021-11-16 15:45:18 +08:00
|
|
|
snd_pcm_sframes_t (*delay)(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
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
|
|
|
|
ASoC: soc-compress: add snd_compress_ops
Current snd_soc_component_driver has compr_ops, and each driver can
have callback via it. But, it is mainly created for ALSA, thus, it
doesn't have "component" as parameter.
Thus, each callback can't know it is called for which component.
Each callback currently is getting "component" by using
snd_soc_rtdcom_lookup() with driver name.
--- ALSA SoC ---
...
if (component->driver->compr_ops &&
component->driver->compr_ops->open)
=> return component->driver->compr_ops->open(stream);
...
--- driver ---
static int xxx_open(struct snd_compr_stream *stream)
{
struct snd_soc_pcm_runtime *rtd = stream->private_data;
=> 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 same driver
name component.
To solve this issue, each callback need to be called with component.
We already have many component driver callbacks.
This patch adds new snd_compress_ops, and call it with "component".
--- ALSA SoC ---
...
if (component->driver->compress_ops->open)
=> return component->driver->compress_ops->open(
component, substream);
~~~~~~~~~
...
--- driver ---
static int xxx_open(struct snd_soc_component *component,
struct snd_compr_stream *stream)
{
=> /* it don't need to use snd_soc_rtdcom_lookup() */
...
}
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87v9luvdmh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-04-20 15:07:50 +08:00
|
|
|
const struct snd_compress_ops *compress_ops;
|
2019-07-26 12:49:48 +08:00
|
|
|
|
|
|
|
/* probe ordering - for components with runtime dependencies */
|
|
|
|
int probe_order;
|
|
|
|
int remove_order;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* signal if the module handling the component should not be removed
|
|
|
|
* if a pcm is open. Setting this would prevent the module
|
|
|
|
* refcount being incremented in probe() but allow it be incremented
|
|
|
|
* when a pcm is opened and decremented when it is closed.
|
|
|
|
*/
|
|
|
|
unsigned int module_get_upon_open:1;
|
|
|
|
|
|
|
|
/* bits */
|
|
|
|
unsigned int idle_bias_on:1;
|
|
|
|
unsigned int suspend_bias_off:1;
|
|
|
|
unsigned int use_pmdown_time:1; /* care pmdown_time at stop */
|
2022-05-05 01:08:28 +08:00
|
|
|
/*
|
|
|
|
* Indicates that the component does not care about the endianness of
|
|
|
|
* PCM audio data and the core will ensure that both LE and BE variants
|
|
|
|
* of each used format are present. Typically this is because the
|
|
|
|
* component sits behind a bus that abstracts away the endian of the
|
|
|
|
* original data, ie. one for which the transmission endian is defined
|
|
|
|
* (I2S/SLIMbus/SoundWire), or the concept of endian doesn't exist (PDM,
|
|
|
|
* analogue).
|
|
|
|
*/
|
2019-07-26 12:49:48 +08:00
|
|
|
unsigned int endianness:1;
|
|
|
|
unsigned int non_legacy_dai_naming:1;
|
|
|
|
|
|
|
|
/* this component uses topology and ignore machine driver FEs */
|
|
|
|
const char *ignore_machine;
|
|
|
|
const char *topology_name_prefix;
|
|
|
|
int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
|
|
|
|
struct snd_pcm_hw_params *params);
|
|
|
|
bool use_dai_pcm_id; /* use DAI link PCM ID as PCM device number */
|
|
|
|
int be_pcm_base; /* base device ID for all BE PCMs */
|
2022-03-10 04:21:55 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
const char *debugfs_prefix;
|
|
|
|
#endif
|
2019-07-26 12:49:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct snd_soc_component {
|
|
|
|
const char *name;
|
|
|
|
int id;
|
|
|
|
const char *name_prefix;
|
|
|
|
struct device *dev;
|
|
|
|
struct snd_soc_card *card;
|
|
|
|
|
|
|
|
unsigned int active;
|
|
|
|
|
|
|
|
unsigned int suspended:1; /* is in suspend PM state */
|
|
|
|
|
|
|
|
struct list_head list;
|
|
|
|
struct list_head card_aux_list; /* for auxiliary bound components */
|
|
|
|
struct list_head card_list;
|
|
|
|
|
|
|
|
const struct snd_soc_component_driver *driver;
|
|
|
|
|
|
|
|
struct list_head dai_list;
|
|
|
|
int num_dai;
|
|
|
|
|
|
|
|
struct regmap *regmap;
|
|
|
|
int val_bytes;
|
|
|
|
|
|
|
|
struct mutex io_mutex;
|
|
|
|
|
|
|
|
/* attached dynamic objects */
|
|
|
|
struct list_head dobj_list;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DO NOT use any of the fields below in drivers, they are temporary and
|
|
|
|
* are going to be removed again soon. If you use them in driver code
|
|
|
|
* the driver will be marked as BROKEN when these fields are removed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Don't use these, use snd_soc_component_get_dapm() */
|
|
|
|
struct snd_soc_dapm_context dapm;
|
|
|
|
|
|
|
|
/* machine specific init */
|
|
|
|
int (*init)(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
|
|
|
/* function mark */
|
2021-09-01 17:52:54 +08:00
|
|
|
void *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
|
|
|
struct snd_pcm_substream *mark_open;
|
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_substream *mark_hw_params;
|
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
|
|
|
struct snd_pcm_substream *mark_trigger;
|
2020-11-19 07:50:09 +08:00
|
|
|
struct snd_compr_stream *mark_compr_open;
|
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
|
|
|
void *mark_pm;
|
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
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
struct dentry *debugfs_root;
|
|
|
|
const char *debugfs_prefix;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define for_each_component_dais(component, dai)\
|
|
|
|
list_for_each_entry(dai, &(component)->dai_list, list)
|
|
|
|
#define for_each_component_dais_safe(component, dai, _dai)\
|
|
|
|
list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
|
|
|
|
* embedded in
|
|
|
|
* @dapm: The DAPM context to cast to the component
|
|
|
|
*
|
|
|
|
* This function must only be used on DAPM contexts that are known to be part of
|
|
|
|
* a component (e.g. in a component driver). Otherwise the behavior is
|
|
|
|
* undefined.
|
|
|
|
*/
|
|
|
|
static inline struct snd_soc_component *snd_soc_dapm_to_component(
|
|
|
|
struct snd_soc_dapm_context *dapm)
|
|
|
|
{
|
|
|
|
return container_of(dapm, struct snd_soc_component, dapm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_get_dapm() - Returns the DAPM context associated with a
|
|
|
|
* component
|
|
|
|
* @component: The component for which to get the DAPM context
|
|
|
|
*/
|
|
|
|
static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
|
|
|
|
struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
return &component->dapm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level
|
|
|
|
* @component: The COMPONENT for which to initialize the DAPM bias level
|
|
|
|
* @level: The DAPM level to initialize to
|
|
|
|
*
|
|
|
|
* Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level()
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
snd_soc_component_init_bias_level(struct snd_soc_component *component,
|
|
|
|
enum snd_soc_bias_level level)
|
|
|
|
{
|
|
|
|
snd_soc_dapm_init_bias_level(
|
|
|
|
snd_soc_component_get_dapm(component), level);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level
|
|
|
|
* @component: The COMPONENT for which to get the DAPM bias level
|
|
|
|
*
|
|
|
|
* Returns: The current DAPM bias level of the COMPONENT.
|
|
|
|
*/
|
|
|
|
static inline enum snd_soc_bias_level
|
|
|
|
snd_soc_component_get_bias_level(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
return snd_soc_dapm_get_bias_level(
|
|
|
|
snd_soc_component_get_dapm(component));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level
|
|
|
|
* @component: The COMPONENT for which to set the level
|
|
|
|
* @level: The level to set to
|
|
|
|
*
|
|
|
|
* Forces the COMPONENT bias level to a specific state. See
|
|
|
|
* snd_soc_dapm_force_bias_level().
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
snd_soc_component_force_bias_level(struct snd_soc_component *component,
|
|
|
|
enum snd_soc_bias_level level)
|
|
|
|
{
|
|
|
|
return snd_soc_dapm_force_bias_level(
|
|
|
|
snd_soc_component_get_dapm(component),
|
|
|
|
level);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_dapm_kcontrol_component() - Returns the component associated to a
|
|
|
|
* kcontrol
|
|
|
|
* @kcontrol: The kcontrol
|
|
|
|
*
|
|
|
|
* This function must only be used on DAPM contexts that are known to be part of
|
|
|
|
* a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined
|
|
|
|
*/
|
|
|
|
static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component(
|
|
|
|
struct snd_kcontrol *kcontrol)
|
|
|
|
{
|
|
|
|
return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_soc_component_cache_sync() - Sync the register cache with the hardware
|
|
|
|
* @component: COMPONENT to sync
|
|
|
|
*
|
|
|
|
* Note: This function will call regcache_sync()
|
|
|
|
*/
|
|
|
|
static inline int snd_soc_component_cache_sync(
|
|
|
|
struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
return regcache_sync(component->regmap);
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:05:24 +08:00
|
|
|
static inline int snd_soc_component_is_codec(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
return component->driver->non_legacy_dai_naming;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
int snd_soc_component_init(struct snd_soc_component *component);
|
2021-04-16 10:00:26 +08:00
|
|
|
int snd_soc_component_is_dummy(struct snd_soc_component *component);
|
2020-06-04 16:06:32 +08:00
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
/* component IO */
|
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 snd_soc_component_read(struct snd_soc_component *component,
|
2019-07-26 12:49:48 +08:00
|
|
|
unsigned int reg);
|
|
|
|
int snd_soc_component_write(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int val);
|
|
|
|
int snd_soc_component_update_bits(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask,
|
|
|
|
unsigned int val);
|
|
|
|
int snd_soc_component_update_bits_async(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask,
|
|
|
|
unsigned int val);
|
|
|
|
void snd_soc_component_async_complete(struct snd_soc_component *component);
|
|
|
|
int snd_soc_component_test_bits(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask,
|
|
|
|
unsigned int value);
|
|
|
|
|
2021-01-27 01:17:48 +08:00
|
|
|
unsigned int snd_soc_component_read_field(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask);
|
|
|
|
int snd_soc_component_write_field(struct snd_soc_component *component,
|
|
|
|
unsigned int reg, unsigned int mask,
|
|
|
|
unsigned int val);
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
/* component wide operations */
|
|
|
|
int snd_soc_component_set_sysclk(struct snd_soc_component *component,
|
|
|
|
int clk_id, int source,
|
|
|
|
unsigned int freq, int dir);
|
|
|
|
int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
|
|
|
|
int source, unsigned int freq_in,
|
|
|
|
unsigned int freq_out);
|
|
|
|
int snd_soc_component_set_jack(struct snd_soc_component *component,
|
|
|
|
struct snd_soc_jack *jack, void *data);
|
|
|
|
|
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);
|
2019-07-26 12:51:39 +08:00
|
|
|
int snd_soc_component_stream_event(struct snd_soc_component *component,
|
|
|
|
int event);
|
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);
|
2019-07-26 12:51:35 +08:00
|
|
|
|
2020-06-04 16:06:22 +08:00
|
|
|
void snd_soc_component_setup_regmap(struct snd_soc_component *component);
|
2019-07-26 12:49:48 +08:00
|
|
|
#ifdef CONFIG_REGMAP
|
|
|
|
void snd_soc_component_init_regmap(struct snd_soc_component *component,
|
|
|
|
struct regmap *regmap);
|
|
|
|
void snd_soc_component_exit_regmap(struct snd_soc_component *component);
|
|
|
|
#endif
|
|
|
|
|
2019-07-26 12:49:54 +08:00
|
|
|
#define snd_soc_component_module_get_when_probe(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
|
|
|
snd_soc_component_module_get(component, NULL, 0)
|
|
|
|
#define snd_soc_component_module_get_when_open(component, substream) \
|
|
|
|
snd_soc_component_module_get(component, substream, 1)
|
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
|
|
|
#define snd_soc_component_module_put_when_remove(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
|
|
|
snd_soc_component_module_put(component, NULL, 0, 0)
|
|
|
|
#define snd_soc_component_module_put_when_close(component, substream, rollback) \
|
|
|
|
snd_soc_component_module_put(component, substream, 1, rollback)
|
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
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
dev_set_drvdata(c->dev, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
|
|
|
|
{
|
|
|
|
return dev_get_drvdata(c->dev);
|
|
|
|
}
|
|
|
|
|
2020-05-15 08:46:42 +08:00
|
|
|
static inline unsigned int
|
|
|
|
snd_soc_component_active(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
return component->active;
|
|
|
|
}
|
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
/* component pin */
|
|
|
|
int snd_soc_component_enable_pin(struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
int snd_soc_component_disable_pin(struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
int snd_soc_component_nc_pin(struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
int snd_soc_component_get_pin_status(struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
int snd_soc_component_force_enable_pin_unlocked(
|
|
|
|
struct snd_soc_component *component,
|
|
|
|
const char *pin);
|
|
|
|
|
2019-07-26 12:50:01 +08:00
|
|
|
/* component driver ops */
|
|
|
|
int snd_soc_component_open(struct snd_soc_component *component,
|
|
|
|
struct snd_pcm_substream *substream);
|
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:34 +08:00
|
|
|
void snd_soc_component_suspend(struct snd_soc_component *component);
|
2019-07-26 12:51:08 +08:00
|
|
|
void snd_soc_component_resume(struct snd_soc_component *component);
|
2019-07-26 12:51:13 +08:00
|
|
|
int snd_soc_component_is_suspended(struct snd_soc_component *component);
|
2019-07-26 12:51:17 +08:00
|
|
|
int snd_soc_component_probe(struct snd_soc_component *component);
|
2019-07-26 12:51:22 +08:00
|
|
|
void snd_soc_component_remove(struct snd_soc_component *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);
|
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);
|
2021-09-01 17:52:55 +08:00
|
|
|
int snd_soc_component_compr_open(struct snd_soc_component *component,
|
|
|
|
struct snd_compr_stream *cstream);
|
|
|
|
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:33 +08:00
|
|
|
int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd);
|
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);
|
2020-11-13 12:15:56 +08:00
|
|
|
int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_codec *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);
|
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);
|
2020-11-13 12:16:17 +08:00
|
|
|
int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes);
|
2020-11-13 12:16:24 +08:00
|
|
|
int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
|
|
|
|
struct snd_compr_tstamp *tstamp);
|
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);
|
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);
|
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);
|
2019-07-26 12:50:01 +08:00
|
|
|
|
2019-07-26 12:51:47 +08:00
|
|
|
int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
|
2019-07-26 12:51:51 +08:00
|
|
|
int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
|
|
|
|
unsigned int cmd, void *arg);
|
2019-11-22 03:07:09 +08:00
|
|
|
int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream);
|
2019-07-26 12:51:56 +08:00
|
|
|
int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream,
|
|
|
|
int channel, unsigned long pos,
|
|
|
|
void __user *buf, unsigned long bytes);
|
2019-07-26 12:52:00 +08:00
|
|
|
struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
|
|
|
|
unsigned long offset);
|
2019-07-26 12:52:04 +08:00
|
|
|
int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
|
|
|
|
struct vm_area_struct *vma);
|
2019-11-18 09:50:32 +08:00
|
|
|
int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
|
|
|
|
void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
|
2020-06-04 16:06:58 +08:00
|
|
|
int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream);
|
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: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: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);
|
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);
|
|
|
|
void snd_soc_pcm_component_pm_runtime_put(struct snd_soc_pcm_runtime *rtd,
|
|
|
|
void *stream, int rollback);
|
2021-03-12 10:38:40 +08:00
|
|
|
int snd_soc_pcm_component_ack(struct snd_pcm_substream *substream);
|
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);
|
2019-07-26 12:51:47 +08:00
|
|
|
|
2019-07-26 12:49:48 +08:00
|
|
|
#endif /* __SOC_COMPONENT_H */
|