ASoC: Laying the groundwork for compress_type overriding
cover ASoC: Laying the groundwork for compress_type overriding
This patch series is to prepare ASoC for allowing the compress_type of the codec to be overriden by the machine driver. Typically this will be done by providing an snd_soc_codec_conf struct which will contain the new compress_type in the machine driver.
Dimitris Papastamos (3):
ASoC: Add compress_type as a member to snd_soc_codec
ASoC: Change the base value of compress_type
ASoC: soc-core: Generalize snd_soc_prefix_map and rename to
snd_soc_codec_conf
PATCH 1/3 ASoC: Add compress_type as a member to snd_soc_codec
We need to keep a copy of the compress_type supplied by the codec driver so that we can override it if necessary with whatever the machine driver has provided us with. The reason for not modifying the codec->driver struct directly is that ideally we'd like to keep it const.
Adjust the code in soc-cache and soc-core to make use of the compress_type member in the snd_soc_codec struct.
--- include/sound/soc.h | 1 + sound/soc/soc-cache.c | 4 ++-- sound/soc/soc-core.c | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-)
include/sound/soc.h +1 -0
@@ -460,6 +460,7 @@ struct snd_soc_codec {struct list_head list;struct list_head card_list;int num_dai; +enum snd_soc_compress_type compress_type;/* runtime */ struct snd_ac97 *ac97;/* for ad-hoc ac97 devices */
sound/soc/soc-cache.c +2 -2
@@ -1550,11 +1550,11 @@ int snd_soc_cache_init(struct snd_soc_codec *codec)int i;for (i =0 ; i <ARRAY_SIZE (cache_types); ++i) -if (cache_types[i].id == codec->driver->compress_type) +if (cache_types[i].id == codec->compress_type)break ;if (i ==ARRAY_SIZE (cache_types)) {dev_err (codec->dev,"Could not match compress type: %d\n" , - codec->driver->compress_type); + codec->compress_type);return -EINVAL ; }
sound/soc/soc-core.c +5 -0
@@ -3446,6 +3446,11 @@ int snd_soc_register_codec(struct device *dev,return -ENOMEM ; } +if (codec_drv->compress_type) + codec->compress_type = codec_drv->compress_type; +else + codec->compress_type =SND_SOC_FLAT_COMPRESSION ; +INIT_LIST_HEAD (&codec->dapm.widgets);INIT_LIST_HEAD (&codec->dapm.paths); codec->dapm.bias_level =SND_SOC_BIAS_OFF ;
Signature · 1 line
1.7.3.2
PATCH 2/3 ASoC: Change the base value of compress_type
In reply to Dimitris PapastamosEnsure that the base value of compress_type starts at 1 so that we know whether the machine driver has provided a compress_type for overriding the codec supplied one.
--- include/sound/soc.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/sound/soc.h +1 -1
@@ -256,7 +256,7 @@ enum snd_soc_control_type { };enum snd_soc_compress_type { -SND_SOC_FLAT_COMPRESSION , +SND_SOC_FLAT_COMPRESSION =1 ,SND_SOC_LZO_COMPRESSION ,SND_SOC_RBTREE_COMPRESSION };
Signature · 1 line
1.7.3.2
PATCH 3/3 ASoC: soc-core: Generalize snd_soc_prefix_map and rename to snd_soc_codec_conf
In reply to Dimitris PapastamosThe snd_soc_codec_conf struct now holds codec specific configuration information.
A new configuration option has been added to allow machine drivers to override the compression type set by the codec driver.
In the absence of providing an snd_soc_codec_conf struct or when providing one but not setting the compress_type member to anything, the one supplied by the codec driver will be used instead. In all other cases the one set in the snd_soc_codec_conf struct takes effect.
--- include/sound/soc.h | 22 +++++++++++++++------- sound/soc/soc-core.c | 6 +++--- 2 files changed, 18 insertions(+), 10 deletions(-)
include/sound/soc.h +15 -7
@@ -579,9 +579,20 @@ struct snd_soc_dai_link {struct snd_soc_ops *ops; }; -struct snd_soc_prefix_map { +struct snd_soc_codec_conf {const char *dev_name; + +/* +* optional map of kcontrol, widget and path name prefixes that are +* associated per device +*/ const char *name_prefix; + +/* +* set this to the desired compression type if you want to +* override the one supplied in codec->driver->compress_type +*/ +enum snd_soc_compress_type compress_type; };struct snd_soc_aux_dev {
@@ -626,12 +637,9 @@ struct snd_soc_card {struct snd_soc_pcm_runtime *rtd;int num_rtd; -/* -* optional map of kcontrol, widget and path name prefixes that are -* associated per device -*/ -struct snd_soc_prefix_map *prefix_map; -int num_prefixes; +/* optional codec specific configuration */ +struct snd_soc_codec_conf *codec_conf; +int num_configs;/* * optional auxiliary devices such as amplifiers or codecs with DAI
sound/soc/soc-core.c +3 -3
@@ -1401,11 +1401,11 @@ static void soc_set_name_prefix(struct snd_soc_card *card, {int i; -if (card->prefix_map ==NULL ) +if (card->codec_conf ==NULL )return ; -for (i =0 ; i < card->num_prefixes; i++) { -struct snd_soc_prefix_map *map = &card->prefix_map[i]; +for (i =0 ; i < card->num_configs; i++) { +struct snd_soc_codec_conf *map = &card->codec_conf[i];if (map->dev_name && !strcmp (codec->name, map->dev_name)) { codec->name_prefix = map->name_prefix;break ;
Signature · 1 line
1.7.3.2
Re: [PATCH 3/3] ASoC: soc-core: Generalize snd_soc_prefix_map and rename to snd_soc_codec_conf
Quoted 22 lines · On Thu, 2 Dec 2010 14:53:03 +0000 Dimitris Papastamos…
The
snd_soc_codec_confstruct now holds codec specific configuration information.A new configuration option has been added to allow machine drivers to override the compression type set by the codec driver.
In the absence of providing an
snd_soc_codec_confstruct or when providing one but not setting thecompress_typemember to anything, the one supplied by the codec driver will be used instead. In all other cases the one set in thesnd_soc_codec_confstruct takes effect.Signed-off-by Dimitris Papastamos <[email protected]>--- include/sound/soc.h | 22 +++++++++++++++------- sound/soc/soc-core.c | 6 +++--- 2 files changed, 18 insertions(+), 10 deletions(-)include/sound/soc.h +0
-0
include/sound/soc.h struct snd_soc_dai_link { · line 583
Quoted 6 lines
include/sound/soc.h +1
-1@@ -579,9 +579,20 @@ struct snd_soc_dai_link {struct snd_soc_ops *ops; }; -struct snd_soc_prefix_map { +struct snd_soc_codec_conf {const char *dev_name;
No any objections from my side. Good to generalize this struct.
Quoted 5 lines · Dimitris Papastamos
This patch series is to prepare ASoC for allowing the
compress_typeof the codec to be overriden by the machine driver. Typically this will be done by providing ansnd_soc_codec_confstruct which will contain the newcompress_typein the machine driver.
Quoted 7 lines
Dimitris Papastamos (3):
ASoC: Addcompress_typeas a member tosnd_soc_codec
ASoC: Change the base value ofcompress_type
ASoC: soc-core: Generalizesnd_soc_prefix_mapand rename to
snd_soc_codec_conf_______________________________________________
All
Signature · 3 lines
Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk
Mark Brown
AppliedQuoted 4 lines · Dimitris Papastamos
This patch series is to prepare ASoC for allowing the
compress_typeof the codec to be overriden by the machine driver. Typically this will be done by providing ansnd_soc_codec_confstruct which will contain the newcompress_typein the machine driver.
Applied, thanks.