Skip to contentSkip to conversation

ASoC: Laying the groundwork for compress_type overriding

PATCH Applied Dimitris Papastamos 4 participants 7 messages Dec 2, 2010 – Dec 3, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

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
index 4a9195c5..838ad36 100644
@@ -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
index 5143984..081221d 100644
@@ -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
index eb950f7..1f142ae 100644
@@ -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
#2 lore raw

PATCH 2/3 ASoC: Change the base value of compress_type

In reply to Dimitris Papastamos

Ensure 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
index 838ad36..a26cdf9 100644
@@ -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
#3 lore raw

PATCH 3/3 ASoC: soc-core: Generalize snd_soc_prefix_map and rename to snd_soc_codec_conf

In reply to Dimitris Papastamos

The 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
index a26cdf9..4409e97 100644
@@ -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
index 1f142ae..a6565eb 100644
@@ -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
Acked-by on v1 3/3
#4 lore raw

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_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 +0 -0
index a26cdf9..4409e97 100644

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.

Acked-by on the v1 series
#5 lore raw
In reply to Dimitris Papastamos
Quoted 5 lines · Dimitris Papastamos

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.

Quoted 7 lines

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

_______________________________________________

All

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
Applied
#6 lore raw
In reply to Dimitris Papastamos
Quoted 4 lines · Dimitris Papastamos

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.

Applied, thanks.