summaryrefslogtreecommitdiffstats
path: root/include/sound
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-04-22 07:23:13 -0400
committerMark Brown <broonie@linaro.org>2014-04-22 08:23:35 -0400
commite2c330b9b5665006c99327c05bc22f7a8e471043 (patch)
tree2cee0640f32ee9ceeaeb3939ecad1fe127db9ba7 /include/sound
parent2b17ef4071d37ef5e357a4ec75686315cfa9d3e6 (diff)
ASoC: Move IO abstraction to the component level
We currently have two very similar IO abstractions in ASoC, one for CODECs, the other for platforms. Moving this to the component level will allow us to unify those two. It will also enable us to move the standard kcontrol helpers as well as DAPM support to the component level. The new component level abstraction layer is primarily build around regmap. There is a per component pointer for the regmap instance for the underlying device. There are four new function snd_soc_component_read(), snd_soc_component_write(), snd_soc_component_update_bits() and snd_soc_component_update_bits_async(). They have the same signature as their regmap counter-part and will internally forward the call one-to-one to regmap. If the component it not using regmap it will fallback to using the custom IO callbacks. This is done to be able to support drivers that haven't been converted to regmap yet, but it is expected that this will eventually be removed in the future once all component drivers have been converted to regmap. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'include/sound')
-rw-r--r--include/sound/soc-dapm.h1
-rw-r--r--include/sound/soc.h31
2 files changed, 25 insertions, 7 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index ef78f562f4a8..75020f52acdd 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -606,6 +606,7 @@ struct snd_soc_dapm_context {
606 enum snd_soc_dapm_type, int); 606 enum snd_soc_dapm_type, int);
607 607
608 struct device *dev; /* from parent - for debug */ 608 struct device *dev; /* from parent - for debug */
609 struct snd_soc_component *component; /* parent component */
609 struct snd_soc_codec *codec; /* parent codec */ 610 struct snd_soc_codec *codec; /* parent codec */
610 struct snd_soc_platform *platform; /* parent platform */ 611 struct snd_soc_platform *platform; /* parent platform */
611 struct snd_soc_card *card; /* parent card */ 612 struct snd_soc_card *card; /* parent card */
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 8148c98b5f8f..a4179e73369a 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -393,8 +393,6 @@ int devm_snd_soc_register_component(struct device *dev,
393 const struct snd_soc_component_driver *cmpnt_drv, 393 const struct snd_soc_component_driver *cmpnt_drv,
394 struct snd_soc_dai_driver *dai_drv, int num_dai); 394 struct snd_soc_dai_driver *dai_drv, int num_dai);
395void snd_soc_unregister_component(struct device *dev); 395void snd_soc_unregister_component(struct device *dev);
396int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
397 struct regmap *regmap);
398int snd_soc_cache_sync(struct snd_soc_codec *codec); 396int snd_soc_cache_sync(struct snd_soc_codec *codec);
399int snd_soc_cache_init(struct snd_soc_codec *codec); 397int snd_soc_cache_init(struct snd_soc_codec *codec);
400int snd_soc_cache_exit(struct snd_soc_codec *codec); 398int snd_soc_cache_exit(struct snd_soc_codec *codec);
@@ -672,6 +670,14 @@ struct snd_soc_component {
672 const struct snd_soc_component_driver *driver; 670 const struct snd_soc_component_driver *driver;
673 671
674 struct list_head dai_list; 672 struct list_head dai_list;
673
674 int (*read)(struct snd_soc_component *, unsigned int, unsigned int *);
675 int (*write)(struct snd_soc_component *, unsigned int, unsigned int);
676
677 struct regmap *regmap;
678 int val_bytes;
679
680 struct mutex io_mutex;
675}; 681};
676 682
677/* SoC Audio Codec device */ 683/* SoC Audio Codec device */
@@ -696,18 +702,14 @@ struct snd_soc_codec {
696 unsigned int ac97_registered:1; /* Codec has been AC97 registered */ 702 unsigned int ac97_registered:1; /* Codec has been AC97 registered */
697 unsigned int ac97_created:1; /* Codec has been created by SoC */ 703 unsigned int ac97_created:1; /* Codec has been created by SoC */
698 unsigned int cache_init:1; /* codec cache has been initialized */ 704 unsigned int cache_init:1; /* codec cache has been initialized */
699 unsigned int using_regmap:1; /* using regmap access */
700 u32 cache_only; /* Suppress writes to hardware */ 705 u32 cache_only; /* Suppress writes to hardware */
701 u32 cache_sync; /* Cache needs to be synced to hardware */ 706 u32 cache_sync; /* Cache needs to be synced to hardware */
702 707
703 /* codec IO */ 708 /* codec IO */
704 void *control_data; /* codec control (i2c/3wire) data */ 709 void *control_data; /* codec control (i2c/3wire) data */
705 hw_write_t hw_write; 710 hw_write_t hw_write;
706 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
707 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
708 void *reg_cache; 711 void *reg_cache;
709 struct mutex cache_rw_mutex; 712 struct mutex cache_rw_mutex;
710 int val_bytes;
711 713
712 /* component */ 714 /* component */
713 struct snd_soc_component component; 715 struct snd_soc_component component;
@@ -824,7 +826,6 @@ struct snd_soc_platform {
824 int id; 826 int id;
825 struct device *dev; 827 struct device *dev;
826 const struct snd_soc_platform_driver *driver; 828 const struct snd_soc_platform_driver *driver;
827 struct mutex mutex;
828 829
829 unsigned int suspended:1; /* platform is suspended */ 830 unsigned int suspended:1; /* platform is suspended */
830 unsigned int probed:1; 831 unsigned int probed:1;
@@ -1129,6 +1130,22 @@ unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
1129int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, 1130int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
1130 unsigned int val); 1131 unsigned int val);
1131 1132
1133/* component IO */
1134int snd_soc_component_read(struct snd_soc_component *component,
1135 unsigned int reg, unsigned int *val);
1136int snd_soc_component_write(struct snd_soc_component *component,
1137 unsigned int reg, unsigned int val);
1138int snd_soc_component_update_bits(struct snd_soc_component *component,
1139 unsigned int reg, unsigned int mask, unsigned int val);
1140int snd_soc_component_update_bits_async(struct snd_soc_component *component,
1141 unsigned int reg, unsigned int mask, unsigned int val);
1142void snd_soc_component_async_complete(struct snd_soc_component *component);
1143int snd_soc_component_test_bits(struct snd_soc_component *component,
1144 unsigned int reg, unsigned int mask, unsigned int value);
1145
1146int snd_soc_component_init_io(struct snd_soc_component *component,
1147 struct regmap *regmap);
1148
1132/* device driver data */ 1149/* device driver data */
1133 1150
1134static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, 1151static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,