diff options
Diffstat (limited to 'include/sound/soc.h')
-rw-r--r-- | include/sound/soc.h | 117 |
1 files changed, 91 insertions, 26 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 0b83168d8ff4..c0b65fc90783 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -393,14 +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); |
395 | void snd_soc_unregister_component(struct device *dev); | 395 | void snd_soc_unregister_component(struct device *dev); |
396 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, | ||
397 | unsigned int reg); | ||
398 | int snd_soc_codec_readable_register(struct snd_soc_codec *codec, | ||
399 | unsigned int reg); | ||
400 | int snd_soc_codec_writable_register(struct snd_soc_codec *codec, | ||
401 | unsigned int reg); | ||
402 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | ||
403 | struct regmap *regmap); | ||
404 | int snd_soc_cache_sync(struct snd_soc_codec *codec); | 396 | int snd_soc_cache_sync(struct snd_soc_codec *codec); |
405 | int snd_soc_cache_init(struct snd_soc_codec *codec); | 397 | int snd_soc_cache_init(struct snd_soc_codec *codec); |
406 | int snd_soc_cache_exit(struct snd_soc_codec *codec); | 398 | int snd_soc_cache_exit(struct snd_soc_codec *codec); |
@@ -469,12 +461,12 @@ static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | |||
469 | #endif | 461 | #endif |
470 | 462 | ||
471 | /* codec register bit access */ | 463 | /* codec register bit access */ |
472 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, | 464 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg, |
473 | unsigned int mask, unsigned int value); | 465 | unsigned int mask, unsigned int value); |
474 | int snd_soc_update_bits_locked(struct snd_soc_codec *codec, | 466 | int snd_soc_update_bits_locked(struct snd_soc_codec *codec, |
475 | unsigned short reg, unsigned int mask, | 467 | unsigned int reg, unsigned int mask, |
476 | unsigned int value); | 468 | unsigned int value); |
477 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, | 469 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, |
478 | unsigned int mask, unsigned int value); | 470 | unsigned int mask, unsigned int value); |
479 | 471 | ||
480 | int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, | 472 | int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, |
@@ -668,6 +660,7 @@ struct snd_soc_component { | |||
668 | unsigned int active; | 660 | unsigned int active; |
669 | 661 | ||
670 | unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ | 662 | unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ |
663 | unsigned int registered_as_component:1; | ||
671 | 664 | ||
672 | struct list_head list; | 665 | struct list_head list; |
673 | 666 | ||
@@ -677,6 +670,14 @@ struct snd_soc_component { | |||
677 | const struct snd_soc_component_driver *driver; | 670 | const struct snd_soc_component_driver *driver; |
678 | 671 | ||
679 | 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; | ||
680 | }; | 681 | }; |
681 | 682 | ||
682 | /* SoC Audio Codec device */ | 683 | /* SoC Audio Codec device */ |
@@ -692,9 +693,6 @@ struct snd_soc_codec { | |||
692 | struct list_head list; | 693 | struct list_head list; |
693 | struct list_head card_list; | 694 | struct list_head card_list; |
694 | int num_dai; | 695 | int num_dai; |
695 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); | ||
696 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | ||
697 | int (*writable_register)(struct snd_soc_codec *, unsigned int); | ||
698 | 696 | ||
699 | /* runtime */ | 697 | /* runtime */ |
700 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ | 698 | struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ |
@@ -704,18 +702,14 @@ struct snd_soc_codec { | |||
704 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ | 702 | unsigned int ac97_registered:1; /* Codec has been AC97 registered */ |
705 | unsigned int ac97_created:1; /* Codec has been created by SoC */ | 703 | unsigned int ac97_created:1; /* Codec has been created by SoC */ |
706 | unsigned int cache_init:1; /* codec cache has been initialized */ | 704 | unsigned int cache_init:1; /* codec cache has been initialized */ |
707 | unsigned int using_regmap:1; /* using regmap access */ | ||
708 | u32 cache_only; /* Suppress writes to hardware */ | 705 | u32 cache_only; /* Suppress writes to hardware */ |
709 | u32 cache_sync; /* Cache needs to be synced to hardware */ | 706 | u32 cache_sync; /* Cache needs to be synced to hardware */ |
710 | 707 | ||
711 | /* codec IO */ | 708 | /* codec IO */ |
712 | void *control_data; /* codec control (i2c/3wire) data */ | 709 | void *control_data; /* codec control (i2c/3wire) data */ |
713 | hw_write_t hw_write; | 710 | hw_write_t hw_write; |
714 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | ||
715 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | ||
716 | void *reg_cache; | 711 | void *reg_cache; |
717 | struct mutex cache_rw_mutex; | 712 | struct mutex cache_rw_mutex; |
718 | int val_bytes; | ||
719 | 713 | ||
720 | /* component */ | 714 | /* component */ |
721 | struct snd_soc_component component; | 715 | struct snd_soc_component component; |
@@ -754,13 +748,9 @@ struct snd_soc_codec_driver { | |||
754 | unsigned int freq_in, unsigned int freq_out); | 748 | unsigned int freq_in, unsigned int freq_out); |
755 | 749 | ||
756 | /* codec IO */ | 750 | /* codec IO */ |
751 | struct regmap *(*get_regmap)(struct device *); | ||
757 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | 752 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); |
758 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | 753 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); |
759 | int (*display_register)(struct snd_soc_codec *, char *, | ||
760 | size_t, unsigned int); | ||
761 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); | ||
762 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | ||
763 | int (*writable_register)(struct snd_soc_codec *, unsigned int); | ||
764 | unsigned int reg_cache_size; | 754 | unsigned int reg_cache_size; |
765 | short reg_cache_step; | 755 | short reg_cache_step; |
766 | short reg_word_size; | 756 | short reg_word_size; |
@@ -791,6 +781,7 @@ struct snd_soc_platform_driver { | |||
791 | int (*remove)(struct snd_soc_platform *); | 781 | int (*remove)(struct snd_soc_platform *); |
792 | int (*suspend)(struct snd_soc_dai *dai); | 782 | int (*suspend)(struct snd_soc_dai *dai); |
793 | int (*resume)(struct snd_soc_dai *dai); | 783 | int (*resume)(struct snd_soc_dai *dai); |
784 | struct snd_soc_component_driver component_driver; | ||
794 | 785 | ||
795 | /* pcm creation and destruction */ | 786 | /* pcm creation and destruction */ |
796 | int (*pcm_new)(struct snd_soc_pcm_runtime *); | 787 | int (*pcm_new)(struct snd_soc_pcm_runtime *); |
@@ -835,7 +826,6 @@ struct snd_soc_platform { | |||
835 | int id; | 826 | int id; |
836 | struct device *dev; | 827 | struct device *dev; |
837 | const struct snd_soc_platform_driver *driver; | 828 | const struct snd_soc_platform_driver *driver; |
838 | struct mutex mutex; | ||
839 | 829 | ||
840 | unsigned int suspended:1; /* platform is suspended */ | 830 | unsigned int suspended:1; /* platform is suspended */ |
841 | unsigned int probed:1; | 831 | unsigned int probed:1; |
@@ -844,6 +834,8 @@ struct snd_soc_platform { | |||
844 | struct list_head list; | 834 | struct list_head list; |
845 | struct list_head card_list; | 835 | struct list_head card_list; |
846 | 836 | ||
837 | struct snd_soc_component component; | ||
838 | |||
847 | struct snd_soc_dapm_context dapm; | 839 | struct snd_soc_dapm_context dapm; |
848 | 840 | ||
849 | #ifdef CONFIG_DEBUG_FS | 841 | #ifdef CONFIG_DEBUG_FS |
@@ -1120,10 +1112,39 @@ static inline struct snd_soc_codec *snd_soc_component_to_codec( | |||
1120 | return container_of(component, struct snd_soc_codec, component); | 1112 | return container_of(component, struct snd_soc_codec, component); |
1121 | } | 1113 | } |
1122 | 1114 | ||
1115 | /** | ||
1116 | * snd_soc_component_to_platform() - Casts a component to the platform it is embedded in | ||
1117 | * @component: The component to cast to a platform | ||
1118 | * | ||
1119 | * This function must only be used on components that are known to be platforms. | ||
1120 | * Otherwise the behavior is undefined. | ||
1121 | */ | ||
1122 | static inline struct snd_soc_platform *snd_soc_component_to_platform( | ||
1123 | struct snd_soc_component *component) | ||
1124 | { | ||
1125 | return container_of(component, struct snd_soc_platform, component); | ||
1126 | } | ||
1127 | |||
1123 | /* codec IO */ | 1128 | /* codec IO */ |
1124 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); | 1129 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); |
1125 | unsigned int snd_soc_write(struct snd_soc_codec *codec, | 1130 | int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, |
1126 | unsigned int reg, unsigned int val); | 1131 | unsigned int val); |
1132 | |||
1133 | /* component IO */ | ||
1134 | int snd_soc_component_read(struct snd_soc_component *component, | ||
1135 | unsigned int reg, unsigned int *val); | ||
1136 | int snd_soc_component_write(struct snd_soc_component *component, | ||
1137 | unsigned int reg, unsigned int val); | ||
1138 | int snd_soc_component_update_bits(struct snd_soc_component *component, | ||
1139 | unsigned int reg, unsigned int mask, unsigned int val); | ||
1140 | int snd_soc_component_update_bits_async(struct snd_soc_component *component, | ||
1141 | unsigned int reg, unsigned int mask, unsigned int val); | ||
1142 | void snd_soc_component_async_complete(struct snd_soc_component *component); | ||
1143 | int snd_soc_component_test_bits(struct snd_soc_component *component, | ||
1144 | unsigned int reg, unsigned int mask, unsigned int value); | ||
1145 | |||
1146 | int snd_soc_component_init_io(struct snd_soc_component *component, | ||
1147 | struct regmap *regmap); | ||
1127 | 1148 | ||
1128 | /* device driver data */ | 1149 | /* device driver data */ |
1129 | 1150 | ||
@@ -1228,6 +1249,50 @@ static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec) | |||
1228 | return snd_soc_component_is_active(&codec->component); | 1249 | return snd_soc_component_is_active(&codec->component); |
1229 | } | 1250 | } |
1230 | 1251 | ||
1252 | /** | ||
1253 | * snd_soc_kcontrol_component() - Returns the component that registered the | ||
1254 | * control | ||
1255 | * @kcontrol: The control for which to get the component | ||
1256 | * | ||
1257 | * Note: This function will work correctly if the control has been registered | ||
1258 | * for a component. Either with snd_soc_add_codec_controls() or | ||
1259 | * snd_soc_add_platform_controls() or via table based setup for either a | ||
1260 | * CODEC, a platform or component driver. Otherwise the behavior is undefined. | ||
1261 | */ | ||
1262 | static inline struct snd_soc_component *snd_soc_kcontrol_component( | ||
1263 | struct snd_kcontrol *kcontrol) | ||
1264 | { | ||
1265 | return snd_kcontrol_chip(kcontrol); | ||
1266 | } | ||
1267 | |||
1268 | /** | ||
1269 | * snd_soc_kcontrol_codec() - Returns the CODEC that registered the control | ||
1270 | * @kcontrol: The control for which to get the CODEC | ||
1271 | * | ||
1272 | * Note: This function will only work correctly if the control has been | ||
1273 | * registered with snd_soc_add_codec_controls() or via table based setup of | ||
1274 | * snd_soc_codec_driver. Otherwise the behavior is undefined. | ||
1275 | */ | ||
1276 | static inline struct snd_soc_codec *snd_soc_kcontrol_codec( | ||
1277 | struct snd_kcontrol *kcontrol) | ||
1278 | { | ||
1279 | return snd_soc_component_to_codec(snd_soc_kcontrol_component(kcontrol)); | ||
1280 | } | ||
1281 | |||
1282 | /** | ||
1283 | * snd_soc_kcontrol_platform() - Returns the platform that registerd the control | ||
1284 | * @kcontrol: The control for which to get the platform | ||
1285 | * | ||
1286 | * Note: This function will only work correctly if the control has been | ||
1287 | * registered with snd_soc_add_platform_controls() or via table based setup of | ||
1288 | * a snd_soc_platform_driver. Otherwise the behavior is undefined. | ||
1289 | */ | ||
1290 | static inline struct snd_soc_platform *snd_soc_kcontrol_platform( | ||
1291 | struct snd_kcontrol *kcontrol) | ||
1292 | { | ||
1293 | return snd_soc_component_to_platform(snd_soc_kcontrol_component(kcontrol)); | ||
1294 | } | ||
1295 | |||
1231 | int snd_soc_util_init(void); | 1296 | int snd_soc_util_init(void); |
1232 | void snd_soc_util_exit(void); | 1297 | void snd_soc_util_exit(void); |
1233 | 1298 | ||