diff options
68 files changed, 2659 insertions, 848 deletions
diff --git a/Documentation/devicetree/bindings/sound/st,sta350.txt b/Documentation/devicetree/bindings/sound/st,sta350.txt new file mode 100644 index 000000000000..950188891abd --- /dev/null +++ b/Documentation/devicetree/bindings/sound/st,sta350.txt | |||
@@ -0,0 +1,107 @@ | |||
1 | STA350 audio CODEC | ||
2 | |||
3 | The driver for this device only supports I2C. | ||
4 | |||
5 | Required properties: | ||
6 | |||
7 | - compatible: "st,sta350" | ||
8 | - reg: the I2C address of the device for I2C | ||
9 | - reset-gpios: a GPIO spec for the reset pin. If specified, it will be | ||
10 | deasserted before communication to the codec starts. | ||
11 | |||
12 | - power-down-gpios: a GPIO spec for the power down pin. If specified, | ||
13 | it will be deasserted before communication to the codec | ||
14 | starts. | ||
15 | |||
16 | - vdd-dig-supply: regulator spec, providing 3.3V | ||
17 | - vdd-pll-supply: regulator spec, providing 3.3V | ||
18 | - vcc-supply: regulator spec, providing 5V - 26V | ||
19 | |||
20 | Optional properties: | ||
21 | |||
22 | - st,output-conf: number, Selects the output configuration: | ||
23 | 0: 2-channel (full-bridge) power, 2-channel data-out | ||
24 | 1: 2 (half-bridge). 1 (full-bridge) on-board power | ||
25 | 2: 2 Channel (Full-Bridge) Power, 1 Channel FFX | ||
26 | 3: 1 Channel Mono-Parallel | ||
27 | If parameter is missing, mode 0 will be enabled. | ||
28 | |||
29 | - st,ch1-output-mapping: Channel 1 output mapping | ||
30 | - st,ch2-output-mapping: Channel 2 output mapping | ||
31 | - st,ch3-output-mapping: Channel 3 output mapping | ||
32 | 0: Channel 1 | ||
33 | 1: Channel 2 | ||
34 | 2: Channel 3 | ||
35 | If parameter is missing, channel 1 is choosen. | ||
36 | |||
37 | - st,thermal-warning-recover: | ||
38 | If present, thermal warning recovery is enabled. | ||
39 | |||
40 | - st,thermal-warning-adjustment: | ||
41 | If present, thermal warning adjustment is enabled. | ||
42 | |||
43 | - st,fault-detect-recovery: | ||
44 | If present, then fault recovery will be enabled. | ||
45 | |||
46 | - st,ffx-power-output-mode: string | ||
47 | The FFX power output mode selects how the FFX output timing is | ||
48 | configured. Must be one of these values: | ||
49 | - "drop-compensation" | ||
50 | - "tapered-compensation" | ||
51 | - "full-power-mode" | ||
52 | - "variable-drop-compensation" (default) | ||
53 | |||
54 | - st,drop-compensation-ns: number | ||
55 | Only required for "st,ffx-power-output-mode" == | ||
56 | "variable-drop-compensation". | ||
57 | Specifies the drop compensation in nanoseconds. | ||
58 | The value must be in the range of 0..300, and only | ||
59 | multiples of 20 are allowed. Default is 140ns. | ||
60 | |||
61 | - st,overcurrent-warning-adjustment: | ||
62 | If present, overcurrent warning adjustment is enabled. | ||
63 | |||
64 | - st,max-power-use-mpcc: | ||
65 | If present, then MPCC bits are used for MPC coefficients, | ||
66 | otherwise standard MPC coefficients are used. | ||
67 | |||
68 | - st,max-power-corr: | ||
69 | If present, power bridge correction for THD reduction near maximum | ||
70 | power output is enabled. | ||
71 | |||
72 | - st,am-reduction-mode: | ||
73 | If present, FFX mode runs in AM reduction mode, otherwise normal | ||
74 | FFX mode is used. | ||
75 | |||
76 | - st,odd-pwm-speed-mode: | ||
77 | If present, PWM speed mode run on odd speed mode (341.3 kHz) on all | ||
78 | channels. If not present, normal PWM spped mode (384 kHz) will be used. | ||
79 | |||
80 | - st,distortion-compensation: | ||
81 | If present, distortion compensation variable uses DCC coefficient. | ||
82 | If not present, preset DC coefficient is used. | ||
83 | |||
84 | - st,invalid-input-detect-mute: | ||
85 | If not present, automatic invalid input detect mute is enabled. | ||
86 | |||
87 | |||
88 | |||
89 | Example: | ||
90 | |||
91 | codec: sta350@38 { | ||
92 | compatible = "st,sta350"; | ||
93 | reg = <0x1c>; | ||
94 | reset-gpios = <&gpio1 19 0>; | ||
95 | power-down-gpios = <&gpio1 16 0>; | ||
96 | st,output-conf = <0x3>; // set output to 2-channel | ||
97 | // (full-bridge) power, | ||
98 | // 2-channel data-out | ||
99 | st,ch1-output-mapping = <0>; // set channel 1 output ch 1 | ||
100 | st,ch2-output-mapping = <0>; // set channel 2 output ch 1 | ||
101 | st,ch3-output-mapping = <0>; // set channel 3 output ch 1 | ||
102 | st,max-power-correction; // enables power bridge | ||
103 | // correction for THD reduction | ||
104 | // near maximum power output | ||
105 | st,invalid-input-detect-mute; // mute if no valid digital | ||
106 | // audio signal is provided. | ||
107 | }; | ||
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 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 | ||
diff --git a/include/sound/sta350.h b/include/sound/sta350.h new file mode 100644 index 000000000000..3a3298106b22 --- /dev/null +++ b/include/sound/sta350.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Platform data for ST STA350 ASoC codec driver. | ||
3 | * | ||
4 | * Copyright: 2014 Raumfeld GmbH | ||
5 | * Author: Sven Brandau <info@brandau.biz> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | #ifndef __LINUX_SND__STA350_H | ||
13 | #define __LINUX_SND__STA350_H | ||
14 | |||
15 | #define STA350_OCFG_2CH 0 | ||
16 | #define STA350_OCFG_2_1CH 1 | ||
17 | #define STA350_OCFG_1CH 3 | ||
18 | |||
19 | #define STA350_OM_CH1 0 | ||
20 | #define STA350_OM_CH2 1 | ||
21 | #define STA350_OM_CH3 2 | ||
22 | |||
23 | #define STA350_THERMAL_ADJUSTMENT_ENABLE 1 | ||
24 | #define STA350_THERMAL_RECOVERY_ENABLE 2 | ||
25 | #define STA350_FAULT_DETECT_RECOVERY_BYPASS 1 | ||
26 | |||
27 | #define STA350_FFX_PM_DROP_COMP 0 | ||
28 | #define STA350_FFX_PM_TAPERED_COMP 1 | ||
29 | #define STA350_FFX_PM_FULL_POWER 2 | ||
30 | #define STA350_FFX_PM_VARIABLE_DROP_COMP 3 | ||
31 | |||
32 | |||
33 | struct sta350_platform_data { | ||
34 | u8 output_conf; | ||
35 | u8 ch1_output_mapping; | ||
36 | u8 ch2_output_mapping; | ||
37 | u8 ch3_output_mapping; | ||
38 | u8 ffx_power_output_mode; | ||
39 | u8 drop_compensation_ns; | ||
40 | unsigned int thermal_warning_recovery:1; | ||
41 | unsigned int thermal_warning_adjustment:1; | ||
42 | unsigned int fault_detect_recovery:1; | ||
43 | unsigned int oc_warning_adjustment:1; | ||
44 | unsigned int max_power_use_mpcc:1; | ||
45 | unsigned int max_power_correction:1; | ||
46 | unsigned int am_reduction_mode:1; | ||
47 | unsigned int odd_pwm_speed_mode:1; | ||
48 | unsigned int distortion_compensation:1; | ||
49 | unsigned int invalid_input_detect_mute:1; | ||
50 | }; | ||
51 | |||
52 | #endif /* __LINUX_SND__STA350_H */ | ||
diff --git a/include/trace/events/asoc.h b/include/trace/events/asoc.h index 03996b2bb04f..c75c795a377b 100644 --- a/include/trace/events/asoc.h +++ b/include/trace/events/asoc.h | |||
@@ -11,102 +11,10 @@ | |||
11 | 11 | ||
12 | struct snd_soc_jack; | 12 | struct snd_soc_jack; |
13 | struct snd_soc_codec; | 13 | struct snd_soc_codec; |
14 | struct snd_soc_platform; | ||
15 | struct snd_soc_card; | 14 | struct snd_soc_card; |
16 | struct snd_soc_dapm_widget; | 15 | struct snd_soc_dapm_widget; |
17 | struct snd_soc_dapm_path; | 16 | struct snd_soc_dapm_path; |
18 | 17 | ||
19 | /* | ||
20 | * Log register events | ||
21 | */ | ||
22 | DECLARE_EVENT_CLASS(snd_soc_reg, | ||
23 | |||
24 | TP_PROTO(struct snd_soc_codec *codec, unsigned int reg, | ||
25 | unsigned int val), | ||
26 | |||
27 | TP_ARGS(codec, reg, val), | ||
28 | |||
29 | TP_STRUCT__entry( | ||
30 | __string( name, codec->name ) | ||
31 | __field( int, id ) | ||
32 | __field( unsigned int, reg ) | ||
33 | __field( unsigned int, val ) | ||
34 | ), | ||
35 | |||
36 | TP_fast_assign( | ||
37 | __assign_str(name, codec->name); | ||
38 | __entry->id = codec->id; | ||
39 | __entry->reg = reg; | ||
40 | __entry->val = val; | ||
41 | ), | ||
42 | |||
43 | TP_printk("codec=%s.%d reg=%x val=%x", __get_str(name), | ||
44 | (int)__entry->id, (unsigned int)__entry->reg, | ||
45 | (unsigned int)__entry->val) | ||
46 | ); | ||
47 | |||
48 | DEFINE_EVENT(snd_soc_reg, snd_soc_reg_write, | ||
49 | |||
50 | TP_PROTO(struct snd_soc_codec *codec, unsigned int reg, | ||
51 | unsigned int val), | ||
52 | |||
53 | TP_ARGS(codec, reg, val) | ||
54 | |||
55 | ); | ||
56 | |||
57 | DEFINE_EVENT(snd_soc_reg, snd_soc_reg_read, | ||
58 | |||
59 | TP_PROTO(struct snd_soc_codec *codec, unsigned int reg, | ||
60 | unsigned int val), | ||
61 | |||
62 | TP_ARGS(codec, reg, val) | ||
63 | |||
64 | ); | ||
65 | |||
66 | DECLARE_EVENT_CLASS(snd_soc_preg, | ||
67 | |||
68 | TP_PROTO(struct snd_soc_platform *platform, unsigned int reg, | ||
69 | unsigned int val), | ||
70 | |||
71 | TP_ARGS(platform, reg, val), | ||
72 | |||
73 | TP_STRUCT__entry( | ||
74 | __string( name, platform->name ) | ||
75 | __field( int, id ) | ||
76 | __field( unsigned int, reg ) | ||
77 | __field( unsigned int, val ) | ||
78 | ), | ||
79 | |||
80 | TP_fast_assign( | ||
81 | __assign_str(name, platform->name); | ||
82 | __entry->id = platform->id; | ||
83 | __entry->reg = reg; | ||
84 | __entry->val = val; | ||
85 | ), | ||
86 | |||
87 | TP_printk("platform=%s.%d reg=%x val=%x", __get_str(name), | ||
88 | (int)__entry->id, (unsigned int)__entry->reg, | ||
89 | (unsigned int)__entry->val) | ||
90 | ); | ||
91 | |||
92 | DEFINE_EVENT(snd_soc_preg, snd_soc_preg_write, | ||
93 | |||
94 | TP_PROTO(struct snd_soc_platform *platform, unsigned int reg, | ||
95 | unsigned int val), | ||
96 | |||
97 | TP_ARGS(platform, reg, val) | ||
98 | |||
99 | ); | ||
100 | |||
101 | DEFINE_EVENT(snd_soc_preg, snd_soc_preg_read, | ||
102 | |||
103 | TP_PROTO(struct snd_soc_platform *platform, unsigned int reg, | ||
104 | unsigned int val), | ||
105 | |||
106 | TP_ARGS(platform, reg, val) | ||
107 | |||
108 | ); | ||
109 | |||
110 | DECLARE_EVENT_CLASS(snd_soc_card, | 18 | DECLARE_EVENT_CLASS(snd_soc_card, |
111 | 19 | ||
112 | TP_PROTO(struct snd_soc_card *card, int val), | 20 | TP_PROTO(struct snd_soc_card *card, int val), |
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index b07e17160f94..3c4b10ff48c1 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c | |||
@@ -276,7 +276,7 @@ static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, | |||
276 | { | 276 | { |
277 | struct soc_mixer_control *mc = | 277 | struct soc_mixer_control *mc = |
278 | (struct soc_mixer_control *)kcontrol->private_value; | 278 | (struct soc_mixer_control *)kcontrol->private_value; |
279 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 279 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
280 | unsigned int reg = mc->reg; | 280 | unsigned int reg = mc->reg; |
281 | unsigned int reg2 = mc->rreg; | 281 | unsigned int reg2 = mc->rreg; |
282 | int val[2], val2[2], i; | 282 | int val[2], val2[2], i; |
@@ -300,7 +300,7 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol, | |||
300 | { | 300 | { |
301 | struct soc_mixer_control *mc = | 301 | struct soc_mixer_control *mc = |
302 | (struct soc_mixer_control *)kcontrol->private_value; | 302 | (struct soc_mixer_control *)kcontrol->private_value; |
303 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 303 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
304 | unsigned int reg = mc->reg; | 304 | unsigned int reg = mc->reg; |
305 | unsigned int reg2 = mc->rreg; | 305 | unsigned int reg2 = mc->rreg; |
306 | int err; | 306 | int err; |
@@ -333,7 +333,7 @@ static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol, | |||
333 | { | 333 | { |
334 | struct soc_mixer_control *mc = | 334 | struct soc_mixer_control *mc = |
335 | (struct soc_mixer_control *)kcontrol->private_value; | 335 | (struct soc_mixer_control *)kcontrol->private_value; |
336 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 336 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
337 | unsigned int reg = mc->reg; | 337 | unsigned int reg = mc->reg; |
338 | unsigned int reg2 = mc->rreg; | 338 | unsigned int reg2 = mc->rreg; |
339 | unsigned int shift = mc->shift; | 339 | unsigned int shift = mc->shift; |
@@ -353,7 +353,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, | |||
353 | { | 353 | { |
354 | struct soc_mixer_control *mc = | 354 | struct soc_mixer_control *mc = |
355 | (struct soc_mixer_control *)kcontrol->private_value; | 355 | (struct soc_mixer_control *)kcontrol->private_value; |
356 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 356 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
357 | unsigned int reg = mc->reg; | 357 | unsigned int reg = mc->reg; |
358 | unsigned int reg2 = mc->rreg; | 358 | unsigned int reg2 = mc->rreg; |
359 | unsigned int shift = mc->shift; | 359 | unsigned int shift = mc->shift; |
@@ -1327,10 +1327,6 @@ static int pm860x_probe(struct snd_soc_codec *codec) | |||
1327 | 1327 | ||
1328 | pm860x->codec = codec; | 1328 | pm860x->codec = codec; |
1329 | 1329 | ||
1330 | ret = snd_soc_codec_set_cache_io(codec, pm860x->regmap); | ||
1331 | if (ret) | ||
1332 | return ret; | ||
1333 | |||
1334 | for (i = 0; i < 4; i++) { | 1330 | for (i = 0; i < 4; i++) { |
1335 | ret = request_threaded_irq(pm860x->irq[i], NULL, | 1331 | ret = request_threaded_irq(pm860x->irq[i], NULL, |
1336 | pm860x_codec_handler, IRQF_ONESHOT, | 1332 | pm860x_codec_handler, IRQF_ONESHOT, |
@@ -1362,10 +1358,18 @@ static int pm860x_remove(struct snd_soc_codec *codec) | |||
1362 | return 0; | 1358 | return 0; |
1363 | } | 1359 | } |
1364 | 1360 | ||
1361 | static struct regmap *pm860x_get_regmap(struct device *dev) | ||
1362 | { | ||
1363 | struct pm860x_priv *pm860x = dev_get_drvdata(dev); | ||
1364 | |||
1365 | return pm860x->regmap; | ||
1366 | } | ||
1367 | |||
1365 | static struct snd_soc_codec_driver soc_codec_dev_pm860x = { | 1368 | static struct snd_soc_codec_driver soc_codec_dev_pm860x = { |
1366 | .probe = pm860x_probe, | 1369 | .probe = pm860x_probe, |
1367 | .remove = pm860x_remove, | 1370 | .remove = pm860x_remove, |
1368 | .set_bias_level = pm860x_set_bias_level, | 1371 | .set_bias_level = pm860x_set_bias_level, |
1372 | .get_regmap = pm860x_get_regmap, | ||
1369 | 1373 | ||
1370 | .controls = pm860x_snd_controls, | 1374 | .controls = pm860x_snd_controls, |
1371 | .num_controls = ARRAY_SIZE(pm860x_snd_controls), | 1375 | .num_controls = ARRAY_SIZE(pm860x_snd_controls), |
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index f0e840137887..c7b853f520cf 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -80,6 +80,7 @@ config SND_SOC_ALL_CODECS | |||
80 | select SND_SOC_SSM2602_SPI if SPI_MASTER | 80 | select SND_SOC_SSM2602_SPI if SPI_MASTER |
81 | select SND_SOC_SSM2602_I2C if I2C | 81 | select SND_SOC_SSM2602_I2C if I2C |
82 | select SND_SOC_STA32X if I2C | 82 | select SND_SOC_STA32X if I2C |
83 | select SND_SOC_STA350 if I2C | ||
83 | select SND_SOC_STA529 if I2C | 84 | select SND_SOC_STA529 if I2C |
84 | select SND_SOC_STAC9766 if SND_SOC_AC97_BUS | 85 | select SND_SOC_STAC9766 if SND_SOC_AC97_BUS |
85 | select SND_SOC_TAS5086 if I2C | 86 | select SND_SOC_TAS5086 if I2C |
@@ -435,6 +436,10 @@ config SND_SOC_SSM2602_I2C | |||
435 | config SND_SOC_STA32X | 436 | config SND_SOC_STA32X |
436 | tristate | 437 | tristate |
437 | 438 | ||
439 | config SND_SOC_STA350 | ||
440 | tristate "STA350 speaker amplifier" | ||
441 | depends on I2C | ||
442 | |||
438 | config SND_SOC_STA529 | 443 | config SND_SOC_STA529 |
439 | tristate | 444 | tristate |
440 | 445 | ||
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 3c4d275d064b..efdb4d060201 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -74,6 +74,7 @@ snd-soc-ssm2602-objs := ssm2602.o | |||
74 | snd-soc-ssm2602-spi-objs := ssm2602-spi.o | 74 | snd-soc-ssm2602-spi-objs := ssm2602-spi.o |
75 | snd-soc-ssm2602-i2c-objs := ssm2602-i2c.o | 75 | snd-soc-ssm2602-i2c-objs := ssm2602-i2c.o |
76 | snd-soc-sta32x-objs := sta32x.o | 76 | snd-soc-sta32x-objs := sta32x.o |
77 | snd-soc-sta350-objs := sta350.o | ||
77 | snd-soc-sta529-objs := sta529.o | 78 | snd-soc-sta529-objs := sta529.o |
78 | snd-soc-stac9766-objs := stac9766.o | 79 | snd-soc-stac9766-objs := stac9766.o |
79 | snd-soc-tas5086-objs := tas5086.o | 80 | snd-soc-tas5086-objs := tas5086.o |
@@ -221,6 +222,7 @@ obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o | |||
221 | obj-$(CONFIG_SND_SOC_SSM2602_SPI) += snd-soc-ssm2602-spi.o | 222 | obj-$(CONFIG_SND_SOC_SSM2602_SPI) += snd-soc-ssm2602-spi.o |
222 | obj-$(CONFIG_SND_SOC_SSM2602_I2C) += snd-soc-ssm2602-i2c.o | 223 | obj-$(CONFIG_SND_SOC_SSM2602_I2C) += snd-soc-ssm2602-i2c.o |
223 | obj-$(CONFIG_SND_SOC_STA32X) += snd-soc-sta32x.o | 224 | obj-$(CONFIG_SND_SOC_STA32X) += snd-soc-sta32x.o |
225 | obj-$(CONFIG_SND_SOC_STA350) += snd-soc-sta350.o | ||
224 | obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o | 226 | obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o |
225 | obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o | 227 | obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o |
226 | obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o | 228 | obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o |
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 1ad92cbf0b24..1fb4402bf72d 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c | |||
@@ -1139,7 +1139,7 @@ static void anc_configure(struct snd_soc_codec *codec, | |||
1139 | static int sid_status_control_get(struct snd_kcontrol *kcontrol, | 1139 | static int sid_status_control_get(struct snd_kcontrol *kcontrol, |
1140 | struct snd_ctl_elem_value *ucontrol) | 1140 | struct snd_ctl_elem_value *ucontrol) |
1141 | { | 1141 | { |
1142 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1142 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1143 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); | 1143 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); |
1144 | 1144 | ||
1145 | mutex_lock(&codec->mutex); | 1145 | mutex_lock(&codec->mutex); |
@@ -1153,7 +1153,7 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol, | |||
1153 | static int sid_status_control_put(struct snd_kcontrol *kcontrol, | 1153 | static int sid_status_control_put(struct snd_kcontrol *kcontrol, |
1154 | struct snd_ctl_elem_value *ucontrol) | 1154 | struct snd_ctl_elem_value *ucontrol) |
1155 | { | 1155 | { |
1156 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1156 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1157 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); | 1157 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); |
1158 | unsigned int param, sidconf, val; | 1158 | unsigned int param, sidconf, val; |
1159 | int status = 1; | 1159 | int status = 1; |
@@ -1208,7 +1208,7 @@ out: | |||
1208 | static int anc_status_control_get(struct snd_kcontrol *kcontrol, | 1208 | static int anc_status_control_get(struct snd_kcontrol *kcontrol, |
1209 | struct snd_ctl_elem_value *ucontrol) | 1209 | struct snd_ctl_elem_value *ucontrol) |
1210 | { | 1210 | { |
1211 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1211 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1212 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); | 1212 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); |
1213 | 1213 | ||
1214 | mutex_lock(&codec->mutex); | 1214 | mutex_lock(&codec->mutex); |
@@ -1221,7 +1221,7 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol, | |||
1221 | static int anc_status_control_put(struct snd_kcontrol *kcontrol, | 1221 | static int anc_status_control_put(struct snd_kcontrol *kcontrol, |
1222 | struct snd_ctl_elem_value *ucontrol) | 1222 | struct snd_ctl_elem_value *ucontrol) |
1223 | { | 1223 | { |
1224 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1224 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1225 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); | 1225 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); |
1226 | struct device *dev = codec->dev; | 1226 | struct device *dev = codec->dev; |
1227 | bool apply_fir, apply_iir; | 1227 | bool apply_fir, apply_iir; |
@@ -1306,7 +1306,7 @@ static int filter_control_info(struct snd_kcontrol *kcontrol, | |||
1306 | static int filter_control_get(struct snd_kcontrol *kcontrol, | 1306 | static int filter_control_get(struct snd_kcontrol *kcontrol, |
1307 | struct snd_ctl_elem_value *ucontrol) | 1307 | struct snd_ctl_elem_value *ucontrol) |
1308 | { | 1308 | { |
1309 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1309 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1310 | struct filter_control *fc = | 1310 | struct filter_control *fc = |
1311 | (struct filter_control *)kcontrol->private_value; | 1311 | (struct filter_control *)kcontrol->private_value; |
1312 | unsigned int i; | 1312 | unsigned int i; |
@@ -1322,7 +1322,7 @@ static int filter_control_get(struct snd_kcontrol *kcontrol, | |||
1322 | static int filter_control_put(struct snd_kcontrol *kcontrol, | 1322 | static int filter_control_put(struct snd_kcontrol *kcontrol, |
1323 | struct snd_ctl_elem_value *ucontrol) | 1323 | struct snd_ctl_elem_value *ucontrol) |
1324 | { | 1324 | { |
1325 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1325 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1326 | struct filter_control *fc = | 1326 | struct filter_control *fc = |
1327 | (struct filter_control *)kcontrol->private_value; | 1327 | (struct filter_control *)kcontrol->private_value; |
1328 | unsigned int i; | 1328 | unsigned int i; |
diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index 5062e34ee8dc..cf170b5ef426 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c | |||
@@ -315,7 +315,7 @@ static int adav80x_set_deemph(struct snd_soc_codec *codec) | |||
315 | static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, | 315 | static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, |
316 | struct snd_ctl_elem_value *ucontrol) | 316 | struct snd_ctl_elem_value *ucontrol) |
317 | { | 317 | { |
318 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 318 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
319 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); | 319 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); |
320 | unsigned int deemph = ucontrol->value.enumerated.item[0]; | 320 | unsigned int deemph = ucontrol->value.enumerated.item[0]; |
321 | 321 | ||
@@ -330,7 +330,7 @@ static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, | |||
330 | static int adav80x_get_deemph(struct snd_kcontrol *kcontrol, | 330 | static int adav80x_get_deemph(struct snd_kcontrol *kcontrol, |
331 | struct snd_ctl_elem_value *ucontrol) | 331 | struct snd_ctl_elem_value *ucontrol) |
332 | { | 332 | { |
333 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 333 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
334 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); | 334 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); |
335 | 335 | ||
336 | ucontrol->value.enumerated.item[0] = adav80x->deemph; | 336 | ucontrol->value.enumerated.item[0] = adav80x->deemph; |
diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index 868c0e2da1ec..7afe8f482088 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c | |||
@@ -74,7 +74,7 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec) | |||
74 | static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, | 74 | static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, |
75 | struct snd_ctl_elem_value *ucontrol) | 75 | struct snd_ctl_elem_value *ucontrol) |
76 | { | 76 | { |
77 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 77 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
78 | struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); | 78 | struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); |
79 | int deemph = ucontrol->value.enumerated.item[0]; | 79 | int deemph = ucontrol->value.enumerated.item[0]; |
80 | 80 | ||
@@ -89,7 +89,7 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, | |||
89 | static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, | 89 | static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, |
90 | struct snd_ctl_elem_value *ucontrol) | 90 | struct snd_ctl_elem_value *ucontrol) |
91 | { | 91 | { |
92 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 92 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
93 | struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); | 93 | struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); |
94 | 94 | ||
95 | ucontrol->value.enumerated.item[0] = ak4641->deemph; | 95 | ucontrol->value.enumerated.item[0] = ak4641->deemph; |
diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 1e25c7af853b..5ee48c8e4849 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c | |||
@@ -139,8 +139,6 @@ static int cq93vc_probe(struct snd_soc_codec *codec) | |||
139 | 139 | ||
140 | davinci_vc->cq93vc.codec = codec; | 140 | davinci_vc->cq93vc.codec = codec; |
141 | 141 | ||
142 | snd_soc_codec_set_cache_io(codec, davinci_vc->regmap); | ||
143 | |||
144 | /* Off, with power on */ | 142 | /* Off, with power on */ |
145 | cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 143 | cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
146 | 144 | ||
@@ -154,11 +152,19 @@ static int cq93vc_remove(struct snd_soc_codec *codec) | |||
154 | return 0; | 152 | return 0; |
155 | } | 153 | } |
156 | 154 | ||
155 | static struct regmap *cq93vc_get_regmap(struct device *dev) | ||
156 | { | ||
157 | struct davinci_vc *davinci_vc = codec->dev->platform_data; | ||
158 | |||
159 | return davinci_vc->regmap; | ||
160 | } | ||
161 | |||
157 | static struct snd_soc_codec_driver soc_codec_dev_cq93vc = { | 162 | static struct snd_soc_codec_driver soc_codec_dev_cq93vc = { |
158 | .set_bias_level = cq93vc_set_bias_level, | 163 | .set_bias_level = cq93vc_set_bias_level, |
159 | .probe = cq93vc_probe, | 164 | .probe = cq93vc_probe, |
160 | .remove = cq93vc_remove, | 165 | .remove = cq93vc_remove, |
161 | .resume = cq93vc_resume, | 166 | .resume = cq93vc_resume, |
167 | .get_regmap = cq93vc_get_regmap, | ||
162 | .controls = cq93vc_snd_controls, | 168 | .controls = cq93vc_snd_controls, |
163 | .num_controls = ARRAY_SIZE(cq93vc_snd_controls), | 169 | .num_controls = ARRAY_SIZE(cq93vc_snd_controls), |
164 | }; | 170 | }; |
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 3920e6264948..9947a9583679 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c | |||
@@ -438,7 +438,7 @@ static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute) | |||
438 | static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol, | 438 | static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol, |
439 | struct snd_ctl_elem_value *ucontrol) | 439 | struct snd_ctl_elem_value *ucontrol) |
440 | { | 440 | { |
441 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 441 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
442 | struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); | 442 | struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); |
443 | int left = !ucontrol->value.integer.value[0]; | 443 | int left = !ucontrol->value.integer.value[0]; |
444 | int right = !ucontrol->value.integer.value[1]; | 444 | int right = !ucontrol->value.integer.value[1]; |
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index aef4965750c7..93cec52f4733 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c | |||
@@ -284,7 +284,7 @@ static int cs4271_set_deemph(struct snd_soc_codec *codec) | |||
284 | static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, | 284 | static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, |
285 | struct snd_ctl_elem_value *ucontrol) | 285 | struct snd_ctl_elem_value *ucontrol) |
286 | { | 286 | { |
287 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 287 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
288 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); | 288 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); |
289 | 289 | ||
290 | ucontrol->value.enumerated.item[0] = cs4271->deemph; | 290 | ucontrol->value.enumerated.item[0] = cs4271->deemph; |
@@ -294,7 +294,7 @@ static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, | |||
294 | static int cs4271_put_deemph(struct snd_kcontrol *kcontrol, | 294 | static int cs4271_put_deemph(struct snd_kcontrol *kcontrol, |
295 | struct snd_ctl_elem_value *ucontrol) | 295 | struct snd_ctl_elem_value *ucontrol) |
296 | { | 296 | { |
297 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 297 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
298 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); | 298 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); |
299 | 299 | ||
300 | cs4271->deemph = ucontrol->value.enumerated.item[0]; | 300 | cs4271->deemph = ucontrol->value.enumerated.item[0]; |
diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 6c0da2baa154..23acaa0263dc 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c | |||
@@ -55,7 +55,7 @@ struct cs42l51_private { | |||
55 | static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, | 55 | static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, |
56 | struct snd_ctl_elem_value *ucontrol) | 56 | struct snd_ctl_elem_value *ucontrol) |
57 | { | 57 | { |
58 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 58 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
59 | unsigned long value = snd_soc_read(codec, CS42L51_PCM_MIXER)&3; | 59 | unsigned long value = snd_soc_read(codec, CS42L51_PCM_MIXER)&3; |
60 | 60 | ||
61 | switch (value) { | 61 | switch (value) { |
@@ -83,7 +83,7 @@ static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, | |||
83 | static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol, | 83 | static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol, |
84 | struct snd_ctl_elem_value *ucontrol) | 84 | struct snd_ctl_elem_value *ucontrol) |
85 | { | 85 | { |
86 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 86 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
87 | unsigned char val; | 87 | unsigned char val; |
88 | 88 | ||
89 | switch (ucontrol->value.integer.value[0]) { | 89 | switch (ucontrol->value.integer.value[0]) { |
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 137e8ebc092c..21810e5f3321 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c | |||
@@ -335,7 +335,7 @@ static SOC_ENUM_SINGLE_DECL(da7210_hp_mode_sel, | |||
335 | static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, | 335 | static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, |
336 | struct snd_ctl_elem_value *ucontrol) | 336 | struct snd_ctl_elem_value *ucontrol) |
337 | { | 337 | { |
338 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 338 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
339 | 339 | ||
340 | if (ucontrol->value.integer.value[0]) { | 340 | if (ucontrol->value.integer.value[0]) { |
341 | /* Check if noise suppression is enabled */ | 341 | /* Check if noise suppression is enabled */ |
@@ -358,7 +358,7 @@ static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, | |||
358 | static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, | 358 | static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, |
359 | struct snd_ctl_elem_value *ucontrol) | 359 | struct snd_ctl_elem_value *ucontrol) |
360 | { | 360 | { |
361 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 361 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
362 | u8 val; | 362 | u8 val; |
363 | 363 | ||
364 | if (ucontrol->value.integer.value[0]) { | 364 | if (ucontrol->value.integer.value[0]) { |
diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 738fa18a50d2..9ec577f0edb4 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c | |||
@@ -345,7 +345,7 @@ static void da7213_alc_calib(struct snd_soc_codec *codec) | |||
345 | static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, | 345 | static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, |
346 | struct snd_ctl_elem_value *ucontrol) | 346 | struct snd_ctl_elem_value *ucontrol) |
347 | { | 347 | { |
348 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 348 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
349 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 349 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); |
350 | int ret; | 350 | int ret; |
351 | 351 | ||
@@ -361,7 +361,7 @@ static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, | |||
361 | static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, | 361 | static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, |
362 | struct snd_ctl_elem_value *ucontrol) | 362 | struct snd_ctl_elem_value *ucontrol) |
363 | { | 363 | { |
364 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 364 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
365 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 365 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); |
366 | 366 | ||
367 | /* Force ALC offset calibration if enabling ALC */ | 367 | /* Force ALC offset calibration if enabling ALC */ |
diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c index 48f3fef68484..2fae31cb0067 100644 --- a/sound/soc/codecs/da732x.c +++ b/sound/soc/codecs/da732x.c | |||
@@ -332,7 +332,7 @@ static SOC_ENUM_SINGLE_DECL(da732x_adc2_voice_filter_enum, | |||
332 | static int da732x_hpf_set(struct snd_kcontrol *kcontrol, | 332 | static int da732x_hpf_set(struct snd_kcontrol *kcontrol, |
333 | struct snd_ctl_elem_value *ucontrol) | 333 | struct snd_ctl_elem_value *ucontrol) |
334 | { | 334 | { |
335 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 335 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
336 | struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; | 336 | struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; |
337 | unsigned int reg = enum_ctrl->reg; | 337 | unsigned int reg = enum_ctrl->reg; |
338 | unsigned int sel = ucontrol->value.integer.value[0]; | 338 | unsigned int sel = ucontrol->value.integer.value[0]; |
@@ -360,7 +360,7 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol, | |||
360 | static int da732x_hpf_get(struct snd_kcontrol *kcontrol, | 360 | static int da732x_hpf_get(struct snd_kcontrol *kcontrol, |
361 | struct snd_ctl_elem_value *ucontrol) | 361 | struct snd_ctl_elem_value *ucontrol) |
362 | { | 362 | { |
363 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 363 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
364 | struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; | 364 | struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; |
365 | unsigned int reg = enum_ctrl->reg; | 365 | unsigned int reg = enum_ctrl->reg; |
366 | int val; | 366 | int val; |
diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c index 4ff06b50fbba..ad19cc56702b 100644 --- a/sound/soc/codecs/da9055.c +++ b/sound/soc/codecs/da9055.c | |||
@@ -484,7 +484,7 @@ static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) | |||
484 | static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol, | 484 | static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol, |
485 | struct snd_ctl_elem_value *ucontrol) | 485 | struct snd_ctl_elem_value *ucontrol) |
486 | { | 486 | { |
487 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 487 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
488 | u8 reg_val, adc_left, adc_right, mic_left, mic_right; | 488 | u8 reg_val, adc_left, adc_right, mic_left, mic_right; |
489 | int avg_left_data, avg_right_data, offset_l, offset_r; | 489 | int avg_left_data, avg_right_data, offset_l, offset_r; |
490 | 490 | ||
diff --git a/sound/soc/codecs/lm4857.c b/sound/soc/codecs/lm4857.c index 4f048db9f55f..a924bb9d7886 100644 --- a/sound/soc/codecs/lm4857.c +++ b/sound/soc/codecs/lm4857.c | |||
@@ -49,7 +49,7 @@ static const struct reg_default lm4857_default_regs[] = { | |||
49 | static int lm4857_get_mode(struct snd_kcontrol *kcontrol, | 49 | static int lm4857_get_mode(struct snd_kcontrol *kcontrol, |
50 | struct snd_ctl_elem_value *ucontrol) | 50 | struct snd_ctl_elem_value *ucontrol) |
51 | { | 51 | { |
52 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 52 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
53 | struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec); | 53 | struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec); |
54 | 54 | ||
55 | ucontrol->value.integer.value[0] = lm4857->mode; | 55 | ucontrol->value.integer.value[0] = lm4857->mode; |
@@ -60,7 +60,7 @@ static int lm4857_get_mode(struct snd_kcontrol *kcontrol, | |||
60 | static int lm4857_set_mode(struct snd_kcontrol *kcontrol, | 60 | static int lm4857_set_mode(struct snd_kcontrol *kcontrol, |
61 | struct snd_ctl_elem_value *ucontrol) | 61 | struct snd_ctl_elem_value *ucontrol) |
62 | { | 62 | { |
63 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 63 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
64 | struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec); | 64 | struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec); |
65 | uint8_t value = ucontrol->value.integer.value[0]; | 65 | uint8_t value = ucontrol->value.integer.value[0]; |
66 | 66 | ||
diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c index ec481fc428c7..e1c196a41930 100644 --- a/sound/soc/codecs/max9768.c +++ b/sound/soc/codecs/max9768.c | |||
@@ -43,7 +43,7 @@ static struct reg_default max9768_default_regs[] = { | |||
43 | static int max9768_get_gpio(struct snd_kcontrol *kcontrol, | 43 | static int max9768_get_gpio(struct snd_kcontrol *kcontrol, |
44 | struct snd_ctl_elem_value *ucontrol) | 44 | struct snd_ctl_elem_value *ucontrol) |
45 | { | 45 | { |
46 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 46 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
47 | struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); | 47 | struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); |
48 | int val = gpio_get_value_cansleep(max9768->mute_gpio); | 48 | int val = gpio_get_value_cansleep(max9768->mute_gpio); |
49 | 49 | ||
@@ -55,7 +55,7 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol, | |||
55 | static int max9768_set_gpio(struct snd_kcontrol *kcontrol, | 55 | static int max9768_set_gpio(struct snd_kcontrol *kcontrol, |
56 | struct snd_ctl_elem_value *ucontrol) | 56 | struct snd_ctl_elem_value *ucontrol) |
57 | { | 57 | { |
58 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 58 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
59 | struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); | 59 | struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); |
60 | 60 | ||
61 | gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); | 61 | gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); |
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index ef7cf89f5623..9134982807b5 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c | |||
@@ -635,7 +635,7 @@ static SOC_ENUM_SINGLE_DECL(max98088_dai1_adc_filter_enum, | |||
635 | static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol, | 635 | static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol, |
636 | struct snd_ctl_elem_value *ucontrol) | 636 | struct snd_ctl_elem_value *ucontrol) |
637 | { | 637 | { |
638 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 638 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
639 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 639 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
640 | unsigned int sel = ucontrol->value.integer.value[0]; | 640 | unsigned int sel = ucontrol->value.integer.value[0]; |
641 | 641 | ||
@@ -649,7 +649,7 @@ static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol, | |||
649 | static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol, | 649 | static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol, |
650 | struct snd_ctl_elem_value *ucontrol) | 650 | struct snd_ctl_elem_value *ucontrol) |
651 | { | 651 | { |
652 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 652 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
653 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 653 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
654 | 654 | ||
655 | ucontrol->value.integer.value[0] = max98088->mic1pre; | 655 | ucontrol->value.integer.value[0] = max98088->mic1pre; |
@@ -659,7 +659,7 @@ static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol, | |||
659 | static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol, | 659 | static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol, |
660 | struct snd_ctl_elem_value *ucontrol) | 660 | struct snd_ctl_elem_value *ucontrol) |
661 | { | 661 | { |
662 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 662 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
663 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 663 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
664 | unsigned int sel = ucontrol->value.integer.value[0]; | 664 | unsigned int sel = ucontrol->value.integer.value[0]; |
665 | 665 | ||
@@ -673,7 +673,7 @@ static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol, | |||
673 | static int max98088_mic2pre_get(struct snd_kcontrol *kcontrol, | 673 | static int max98088_mic2pre_get(struct snd_kcontrol *kcontrol, |
674 | struct snd_ctl_elem_value *ucontrol) | 674 | struct snd_ctl_elem_value *ucontrol) |
675 | { | 675 | { |
676 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 676 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
677 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 677 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
678 | 678 | ||
679 | ucontrol->value.integer.value[0] = max98088->mic2pre; | 679 | ucontrol->value.integer.value[0] = max98088->mic2pre; |
@@ -1750,7 +1750,7 @@ static void max98088_setup_eq2(struct snd_soc_codec *codec) | |||
1750 | static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, | 1750 | static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, |
1751 | struct snd_ctl_elem_value *ucontrol) | 1751 | struct snd_ctl_elem_value *ucontrol) |
1752 | { | 1752 | { |
1753 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1753 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1754 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 1754 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
1755 | struct max98088_pdata *pdata = max98088->pdata; | 1755 | struct max98088_pdata *pdata = max98088->pdata; |
1756 | int channel = max98088_get_channel(codec, kcontrol->id.name); | 1756 | int channel = max98088_get_channel(codec, kcontrol->id.name); |
@@ -1782,7 +1782,7 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, | |||
1782 | static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol, | 1782 | static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol, |
1783 | struct snd_ctl_elem_value *ucontrol) | 1783 | struct snd_ctl_elem_value *ucontrol) |
1784 | { | 1784 | { |
1785 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1785 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1786 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 1786 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
1787 | int channel = max98088_get_channel(codec, kcontrol->id.name); | 1787 | int channel = max98088_get_channel(codec, kcontrol->id.name); |
1788 | struct max98088_cdata *cdata; | 1788 | struct max98088_cdata *cdata; |
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index c58dce473e55..57fc4c315033 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c | |||
@@ -428,7 +428,7 @@ static const unsigned int max98090_rcv_lout_tlv[] = { | |||
428 | static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, | 428 | static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, |
429 | struct snd_ctl_elem_value *ucontrol) | 429 | struct snd_ctl_elem_value *ucontrol) |
430 | { | 430 | { |
431 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 431 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
432 | struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); | 432 | struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); |
433 | struct soc_mixer_control *mc = | 433 | struct soc_mixer_control *mc = |
434 | (struct soc_mixer_control *)kcontrol->private_value; | 434 | (struct soc_mixer_control *)kcontrol->private_value; |
@@ -468,7 +468,7 @@ static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, | |||
468 | static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, | 468 | static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, |
469 | struct snd_ctl_elem_value *ucontrol) | 469 | struct snd_ctl_elem_value *ucontrol) |
470 | { | 470 | { |
471 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 471 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
472 | struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); | 472 | struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); |
473 | struct soc_mixer_control *mc = | 473 | struct soc_mixer_control *mc = |
474 | (struct soc_mixer_control *)kcontrol->private_value; | 474 | (struct soc_mixer_control *)kcontrol->private_value; |
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 03f0536e6f61..5d4c621dbf99 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c | |||
@@ -612,7 +612,7 @@ static SOC_ENUM_SINGLE_DECL(max98095_dai3_dac_filter_enum, | |||
612 | static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol, | 612 | static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol, |
613 | struct snd_ctl_elem_value *ucontrol) | 613 | struct snd_ctl_elem_value *ucontrol) |
614 | { | 614 | { |
615 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 615 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
616 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 616 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
617 | unsigned int sel = ucontrol->value.integer.value[0]; | 617 | unsigned int sel = ucontrol->value.integer.value[0]; |
618 | 618 | ||
@@ -626,7 +626,7 @@ static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol, | |||
626 | static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol, | 626 | static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol, |
627 | struct snd_ctl_elem_value *ucontrol) | 627 | struct snd_ctl_elem_value *ucontrol) |
628 | { | 628 | { |
629 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 629 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
630 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 630 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
631 | 631 | ||
632 | ucontrol->value.integer.value[0] = max98095->mic1pre; | 632 | ucontrol->value.integer.value[0] = max98095->mic1pre; |
@@ -636,7 +636,7 @@ static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol, | |||
636 | static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol, | 636 | static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol, |
637 | struct snd_ctl_elem_value *ucontrol) | 637 | struct snd_ctl_elem_value *ucontrol) |
638 | { | 638 | { |
639 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 639 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
640 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 640 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
641 | unsigned int sel = ucontrol->value.integer.value[0]; | 641 | unsigned int sel = ucontrol->value.integer.value[0]; |
642 | 642 | ||
@@ -650,7 +650,7 @@ static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol, | |||
650 | static int max98095_mic2pre_get(struct snd_kcontrol *kcontrol, | 650 | static int max98095_mic2pre_get(struct snd_kcontrol *kcontrol, |
651 | struct snd_ctl_elem_value *ucontrol) | 651 | struct snd_ctl_elem_value *ucontrol) |
652 | { | 652 | { |
653 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 653 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
654 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 654 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
655 | 655 | ||
656 | ucontrol->value.integer.value[0] = max98095->mic2pre; | 656 | ucontrol->value.integer.value[0] = max98095->mic2pre; |
@@ -1737,7 +1737,7 @@ static int max98095_get_eq_channel(const char *name) | |||
1737 | static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, | 1737 | static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, |
1738 | struct snd_ctl_elem_value *ucontrol) | 1738 | struct snd_ctl_elem_value *ucontrol) |
1739 | { | 1739 | { |
1740 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1740 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1741 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 1741 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
1742 | struct max98095_pdata *pdata = max98095->pdata; | 1742 | struct max98095_pdata *pdata = max98095->pdata; |
1743 | int channel = max98095_get_eq_channel(kcontrol->id.name); | 1743 | int channel = max98095_get_eq_channel(kcontrol->id.name); |
@@ -1801,7 +1801,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, | |||
1801 | static int max98095_get_eq_enum(struct snd_kcontrol *kcontrol, | 1801 | static int max98095_get_eq_enum(struct snd_kcontrol *kcontrol, |
1802 | struct snd_ctl_elem_value *ucontrol) | 1802 | struct snd_ctl_elem_value *ucontrol) |
1803 | { | 1803 | { |
1804 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1804 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1805 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 1805 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
1806 | int channel = max98095_get_eq_channel(kcontrol->id.name); | 1806 | int channel = max98095_get_eq_channel(kcontrol->id.name); |
1807 | struct max98095_cdata *cdata; | 1807 | struct max98095_cdata *cdata; |
@@ -1891,7 +1891,7 @@ static int max98095_get_bq_channel(struct snd_soc_codec *codec, | |||
1891 | static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, | 1891 | static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, |
1892 | struct snd_ctl_elem_value *ucontrol) | 1892 | struct snd_ctl_elem_value *ucontrol) |
1893 | { | 1893 | { |
1894 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1894 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1895 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 1895 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
1896 | struct max98095_pdata *pdata = max98095->pdata; | 1896 | struct max98095_pdata *pdata = max98095->pdata; |
1897 | int channel = max98095_get_bq_channel(codec, kcontrol->id.name); | 1897 | int channel = max98095_get_bq_channel(codec, kcontrol->id.name); |
@@ -1952,7 +1952,7 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, | |||
1952 | static int max98095_get_bq_enum(struct snd_kcontrol *kcontrol, | 1952 | static int max98095_get_bq_enum(struct snd_kcontrol *kcontrol, |
1953 | struct snd_ctl_elem_value *ucontrol) | 1953 | struct snd_ctl_elem_value *ucontrol) |
1954 | { | 1954 | { |
1955 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1955 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1956 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | 1956 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); |
1957 | int channel = max98095_get_bq_channel(codec, kcontrol->id.name); | 1957 | int channel = max98095_get_bq_channel(codec, kcontrol->id.name); |
1958 | struct max98095_cdata *cdata; | 1958 | struct max98095_cdata *cdata; |
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index 2c59b1fb69dc..9029e20514e1 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c | |||
@@ -608,14 +608,6 @@ static struct snd_kcontrol_new mc13783_control_list[] = { | |||
608 | static int mc13783_probe(struct snd_soc_codec *codec) | 608 | static int mc13783_probe(struct snd_soc_codec *codec) |
609 | { | 609 | { |
610 | struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); | 610 | struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); |
611 | int ret; | ||
612 | |||
613 | ret = snd_soc_codec_set_cache_io(codec, | ||
614 | dev_get_regmap(codec->dev->parent, NULL)); | ||
615 | if (ret != 0) { | ||
616 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | ||
617 | return ret; | ||
618 | } | ||
619 | 611 | ||
620 | /* these are the reset values */ | 612 | /* these are the reset values */ |
621 | mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); | 613 | mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); |
@@ -735,9 +727,15 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = { | |||
735 | } | 727 | } |
736 | }; | 728 | }; |
737 | 729 | ||
730 | static struct regmap *mc13783_get_regmap(struct device *dev) | ||
731 | { | ||
732 | return dev_get_regmap(dev->parent, NULL); | ||
733 | } | ||
734 | |||
738 | static struct snd_soc_codec_driver soc_codec_dev_mc13783 = { | 735 | static struct snd_soc_codec_driver soc_codec_dev_mc13783 = { |
739 | .probe = mc13783_probe, | 736 | .probe = mc13783_probe, |
740 | .remove = mc13783_remove, | 737 | .remove = mc13783_remove, |
738 | .get_regmap = mc13783_get_regmap, | ||
741 | .controls = mc13783_control_list, | 739 | .controls = mc13783_control_list, |
742 | .num_controls = ARRAY_SIZE(mc13783_control_list), | 740 | .num_controls = ARRAY_SIZE(mc13783_control_list), |
743 | .dapm_widgets = mc13783_dapm_widgets, | 741 | .dapm_widgets = mc13783_dapm_widgets, |
diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c index e427544183d7..a722a023c262 100644 --- a/sound/soc/codecs/pcm1681.c +++ b/sound/soc/codecs/pcm1681.c | |||
@@ -115,7 +115,7 @@ static int pcm1681_set_deemph(struct snd_soc_codec *codec) | |||
115 | static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, | 115 | static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, |
116 | struct snd_ctl_elem_value *ucontrol) | 116 | struct snd_ctl_elem_value *ucontrol) |
117 | { | 117 | { |
118 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 118 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
119 | struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); | 119 | struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); |
120 | 120 | ||
121 | ucontrol->value.enumerated.item[0] = priv->deemph; | 121 | ucontrol->value.enumerated.item[0] = priv->deemph; |
@@ -126,7 +126,7 @@ static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, | |||
126 | static int pcm1681_put_deemph(struct snd_kcontrol *kcontrol, | 126 | static int pcm1681_put_deemph(struct snd_kcontrol *kcontrol, |
127 | struct snd_ctl_elem_value *ucontrol) | 127 | struct snd_ctl_elem_value *ucontrol) |
128 | { | 128 | { |
129 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 129 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
130 | struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); | 130 | struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); |
131 | 131 | ||
132 | priv->deemph = ucontrol->value.enumerated.item[0]; | 132 | priv->deemph = ucontrol->value.enumerated.item[0]; |
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index d4c229f0233f..30e234708579 100644 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c | |||
@@ -188,7 +188,7 @@ static unsigned int mic_bst_tlv[] = { | |||
188 | static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, | 188 | static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, |
189 | struct snd_ctl_elem_value *ucontrol) | 189 | struct snd_ctl_elem_value *ucontrol) |
190 | { | 190 | { |
191 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 191 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
192 | struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); | 192 | struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); |
193 | 193 | ||
194 | ucontrol->value.integer.value[0] = rt5631->dmic_used_flag; | 194 | ucontrol->value.integer.value[0] = rt5631->dmic_used_flag; |
@@ -199,7 +199,7 @@ static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, | |||
199 | static int rt5631_dmic_put(struct snd_kcontrol *kcontrol, | 199 | static int rt5631_dmic_put(struct snd_kcontrol *kcontrol, |
200 | struct snd_ctl_elem_value *ucontrol) | 200 | struct snd_ctl_elem_value *ucontrol) |
201 | { | 201 | { |
202 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 202 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
203 | struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); | 203 | struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); |
204 | 204 | ||
205 | rt5631->dmic_used_flag = ucontrol->value.integer.value[0]; | 205 | rt5631->dmic_used_flag = ucontrol->value.integer.value[0]; |
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index d3ed1be5a186..b56caefcf664 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c | |||
@@ -296,7 +296,7 @@ static int dac_info_volsw(struct snd_kcontrol *kcontrol, | |||
296 | static int dac_get_volsw(struct snd_kcontrol *kcontrol, | 296 | static int dac_get_volsw(struct snd_kcontrol *kcontrol, |
297 | struct snd_ctl_elem_value *ucontrol) | 297 | struct snd_ctl_elem_value *ucontrol) |
298 | { | 298 | { |
299 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 299 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
300 | int reg; | 300 | int reg; |
301 | int l; | 301 | int l; |
302 | int r; | 302 | int r; |
@@ -349,7 +349,7 @@ static int dac_get_volsw(struct snd_kcontrol *kcontrol, | |||
349 | static int dac_put_volsw(struct snd_kcontrol *kcontrol, | 349 | static int dac_put_volsw(struct snd_kcontrol *kcontrol, |
350 | struct snd_ctl_elem_value *ucontrol) | 350 | struct snd_ctl_elem_value *ucontrol) |
351 | { | 351 | { |
352 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 352 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
353 | int reg; | 353 | int reg; |
354 | int l; | 354 | int l; |
355 | int r; | 355 | int r; |
diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index 244c097cd905..f26befb0c297 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c | |||
@@ -208,13 +208,6 @@ out: | |||
208 | return err; | 208 | return err; |
209 | } | 209 | } |
210 | 210 | ||
211 | static int si476x_codec_probe(struct snd_soc_codec *codec) | ||
212 | { | ||
213 | struct regmap *regmap = dev_get_regmap(codec->dev->parent, NULL); | ||
214 | |||
215 | return snd_soc_codec_set_cache_io(codec, regmap); | ||
216 | } | ||
217 | |||
218 | static struct snd_soc_dai_ops si476x_dai_ops = { | 211 | static struct snd_soc_dai_ops si476x_dai_ops = { |
219 | .hw_params = si476x_codec_hw_params, | 212 | .hw_params = si476x_codec_hw_params, |
220 | .set_fmt = si476x_codec_set_dai_fmt, | 213 | .set_fmt = si476x_codec_set_dai_fmt, |
@@ -238,8 +231,13 @@ static struct snd_soc_dai_driver si476x_dai = { | |||
238 | .ops = &si476x_dai_ops, | 231 | .ops = &si476x_dai_ops, |
239 | }; | 232 | }; |
240 | 233 | ||
234 | static struct regmap *si476x_get_regmap(struct device *dev) | ||
235 | { | ||
236 | return dev_get_regmap(dev->parent, NULL); | ||
237 | } | ||
238 | |||
241 | static struct snd_soc_codec_driver soc_codec_dev_si476x = { | 239 | static struct snd_soc_codec_driver soc_codec_dev_si476x = { |
242 | .probe = si476x_codec_probe, | 240 | .get_regmap = si476x_get_regmap, |
243 | .dapm_widgets = si476x_dapm_widgets, | 241 | .dapm_widgets = si476x_dapm_widgets, |
244 | .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets), | 242 | .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets), |
245 | .dapm_routes = si476x_dapm_routes, | 243 | .dapm_routes = si476x_dapm_routes, |
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 12577749b17b..0579d187135b 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c | |||
@@ -243,7 +243,7 @@ static int sta32x_coefficient_info(struct snd_kcontrol *kcontrol, | |||
243 | static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, | 243 | static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, |
244 | struct snd_ctl_elem_value *ucontrol) | 244 | struct snd_ctl_elem_value *ucontrol) |
245 | { | 245 | { |
246 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 246 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
247 | int numcoef = kcontrol->private_value >> 16; | 247 | int numcoef = kcontrol->private_value >> 16; |
248 | int index = kcontrol->private_value & 0xffff; | 248 | int index = kcontrol->private_value & 0xffff; |
249 | unsigned int cfud; | 249 | unsigned int cfud; |
@@ -272,7 +272,7 @@ static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, | |||
272 | static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, | 272 | static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, |
273 | struct snd_ctl_elem_value *ucontrol) | 273 | struct snd_ctl_elem_value *ucontrol) |
274 | { | 274 | { |
275 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 275 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
276 | struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); | 276 | struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); |
277 | int numcoef = kcontrol->private_value >> 16; | 277 | int numcoef = kcontrol->private_value >> 16; |
278 | int index = kcontrol->private_value & 0xffff; | 278 | int index = kcontrol->private_value & 0xffff; |
diff --git a/sound/soc/codecs/sta350.c b/sound/soc/codecs/sta350.c new file mode 100644 index 000000000000..12ebbaf5d95f --- /dev/null +++ b/sound/soc/codecs/sta350.c | |||
@@ -0,0 +1,1266 @@ | |||
1 | /* | ||
2 | * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system | ||
3 | * | ||
4 | * Copyright: 2014 Raumfeld GmbH | ||
5 | * Author: Sven Brandau <info@brandau.biz> | ||
6 | * | ||
7 | * based on code from: | ||
8 | * Raumfeld GmbH | ||
9 | * Johannes Stezenbach <js@sig21.net> | ||
10 | * Wolfson Microelectronics PLC. | ||
11 | * Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
12 | * Freescale Semiconductor, Inc. | ||
13 | * Timur Tabi <timur@freescale.com> | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify it | ||
16 | * under the terms of the GNU General Public License as published by the | ||
17 | * Free Software Foundation; either version 2 of the License, or (at your | ||
18 | * option) any later version. | ||
19 | */ | ||
20 | |||
21 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s:%d: " fmt, __func__, __LINE__ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/moduleparam.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/pm.h> | ||
28 | #include <linux/i2c.h> | ||
29 | #include <linux/of_device.h> | ||
30 | #include <linux/of_gpio.h> | ||
31 | #include <linux/regmap.h> | ||
32 | #include <linux/regulator/consumer.h> | ||
33 | #include <linux/gpio/consumer.h> | ||
34 | #include <linux/slab.h> | ||
35 | #include <sound/core.h> | ||
36 | #include <sound/pcm.h> | ||
37 | #include <sound/pcm_params.h> | ||
38 | #include <sound/soc.h> | ||
39 | #include <sound/soc-dapm.h> | ||
40 | #include <sound/initval.h> | ||
41 | #include <sound/tlv.h> | ||
42 | |||
43 | #include <sound/sta350.h> | ||
44 | #include "sta350.h" | ||
45 | |||
46 | #define STA350_RATES (SNDRV_PCM_RATE_32000 | \ | ||
47 | SNDRV_PCM_RATE_44100 | \ | ||
48 | SNDRV_PCM_RATE_48000 | \ | ||
49 | SNDRV_PCM_RATE_88200 | \ | ||
50 | SNDRV_PCM_RATE_96000 | \ | ||
51 | SNDRV_PCM_RATE_176400 | \ | ||
52 | SNDRV_PCM_RATE_192000) | ||
53 | |||
54 | #define STA350_FORMATS \ | ||
55 | (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \ | ||
56 | SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \ | ||
57 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \ | ||
58 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \ | ||
59 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE | \ | ||
60 | SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE) | ||
61 | |||
62 | /* Power-up register defaults */ | ||
63 | static const struct reg_default sta350_regs[] = { | ||
64 | { 0x0, 0x63 }, | ||
65 | { 0x1, 0x80 }, | ||
66 | { 0x2, 0xdf }, | ||
67 | { 0x3, 0x40 }, | ||
68 | { 0x4, 0xc2 }, | ||
69 | { 0x5, 0x5c }, | ||
70 | { 0x6, 0x00 }, | ||
71 | { 0x7, 0xff }, | ||
72 | { 0x8, 0x60 }, | ||
73 | { 0x9, 0x60 }, | ||
74 | { 0xa, 0x60 }, | ||
75 | { 0xb, 0x00 }, | ||
76 | { 0xc, 0x00 }, | ||
77 | { 0xd, 0x00 }, | ||
78 | { 0xe, 0x00 }, | ||
79 | { 0xf, 0x40 }, | ||
80 | { 0x10, 0x80 }, | ||
81 | { 0x11, 0x77 }, | ||
82 | { 0x12, 0x6a }, | ||
83 | { 0x13, 0x69 }, | ||
84 | { 0x14, 0x6a }, | ||
85 | { 0x15, 0x69 }, | ||
86 | { 0x16, 0x00 }, | ||
87 | { 0x17, 0x00 }, | ||
88 | { 0x18, 0x00 }, | ||
89 | { 0x19, 0x00 }, | ||
90 | { 0x1a, 0x00 }, | ||
91 | { 0x1b, 0x00 }, | ||
92 | { 0x1c, 0x00 }, | ||
93 | { 0x1d, 0x00 }, | ||
94 | { 0x1e, 0x00 }, | ||
95 | { 0x1f, 0x00 }, | ||
96 | { 0x20, 0x00 }, | ||
97 | { 0x21, 0x00 }, | ||
98 | { 0x22, 0x00 }, | ||
99 | { 0x23, 0x00 }, | ||
100 | { 0x24, 0x00 }, | ||
101 | { 0x25, 0x00 }, | ||
102 | { 0x26, 0x00 }, | ||
103 | { 0x27, 0x2a }, | ||
104 | { 0x28, 0xc0 }, | ||
105 | { 0x29, 0xf3 }, | ||
106 | { 0x2a, 0x33 }, | ||
107 | { 0x2b, 0x00 }, | ||
108 | { 0x2c, 0x0c }, | ||
109 | { 0x31, 0x00 }, | ||
110 | { 0x36, 0x00 }, | ||
111 | { 0x37, 0x00 }, | ||
112 | { 0x38, 0x00 }, | ||
113 | { 0x39, 0x01 }, | ||
114 | { 0x3a, 0xee }, | ||
115 | { 0x3b, 0xff }, | ||
116 | { 0x3c, 0x7e }, | ||
117 | { 0x3d, 0xc0 }, | ||
118 | { 0x3e, 0x26 }, | ||
119 | { 0x3f, 0x00 }, | ||
120 | { 0x48, 0x00 }, | ||
121 | { 0x49, 0x00 }, | ||
122 | { 0x4a, 0x00 }, | ||
123 | { 0x4b, 0x04 }, | ||
124 | { 0x4c, 0x00 }, | ||
125 | }; | ||
126 | |||
127 | static const struct regmap_range sta350_write_regs_range[] = { | ||
128 | regmap_reg_range(STA350_CONFA, STA350_AUTO2), | ||
129 | regmap_reg_range(STA350_C1CFG, STA350_FDRC2), | ||
130 | regmap_reg_range(STA350_EQCFG, STA350_EVOLRES), | ||
131 | regmap_reg_range(STA350_NSHAPE, STA350_MISC2), | ||
132 | }; | ||
133 | |||
134 | static const struct regmap_range sta350_read_regs_range[] = { | ||
135 | regmap_reg_range(STA350_CONFA, STA350_AUTO2), | ||
136 | regmap_reg_range(STA350_C1CFG, STA350_STATUS), | ||
137 | regmap_reg_range(STA350_EQCFG, STA350_EVOLRES), | ||
138 | regmap_reg_range(STA350_NSHAPE, STA350_MISC2), | ||
139 | }; | ||
140 | |||
141 | static const struct regmap_range sta350_volatile_regs_range[] = { | ||
142 | regmap_reg_range(STA350_CFADDR2, STA350_CFUD), | ||
143 | regmap_reg_range(STA350_STATUS, STA350_STATUS), | ||
144 | }; | ||
145 | |||
146 | static const struct regmap_access_table sta350_write_regs = { | ||
147 | .yes_ranges = sta350_write_regs_range, | ||
148 | .n_yes_ranges = ARRAY_SIZE(sta350_write_regs_range), | ||
149 | }; | ||
150 | |||
151 | static const struct regmap_access_table sta350_read_regs = { | ||
152 | .yes_ranges = sta350_read_regs_range, | ||
153 | .n_yes_ranges = ARRAY_SIZE(sta350_read_regs_range), | ||
154 | }; | ||
155 | |||
156 | static const struct regmap_access_table sta350_volatile_regs = { | ||
157 | .yes_ranges = sta350_volatile_regs_range, | ||
158 | .n_yes_ranges = ARRAY_SIZE(sta350_volatile_regs_range), | ||
159 | }; | ||
160 | |||
161 | /* regulator power supply names */ | ||
162 | static const char * const sta350_supply_names[] = { | ||
163 | "vdd-dig", /* digital supply, 3.3V */ | ||
164 | "vdd-pll", /* pll supply, 3.3V */ | ||
165 | "vcc" /* power amp supply, 5V - 26V */ | ||
166 | }; | ||
167 | |||
168 | /* codec private data */ | ||
169 | struct sta350_priv { | ||
170 | struct regmap *regmap; | ||
171 | struct regulator_bulk_data supplies[ARRAY_SIZE(sta350_supply_names)]; | ||
172 | struct sta350_platform_data *pdata; | ||
173 | |||
174 | unsigned int mclk; | ||
175 | unsigned int format; | ||
176 | |||
177 | u32 coef_shadow[STA350_COEF_COUNT]; | ||
178 | int shutdown; | ||
179 | |||
180 | struct gpio_desc *gpiod_nreset; | ||
181 | struct gpio_desc *gpiod_power_down; | ||
182 | |||
183 | struct mutex coeff_lock; | ||
184 | }; | ||
185 | |||
186 | static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12750, 50, 1); | ||
187 | static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1); | ||
188 | static const DECLARE_TLV_DB_SCALE(tone_tlv, -1200, 200, 0); | ||
189 | |||
190 | static const char * const sta350_drc_ac[] = { | ||
191 | "Anti-Clipping", "Dynamic Range Compression" | ||
192 | }; | ||
193 | static const char * const sta350_auto_gc_mode[] = { | ||
194 | "User", "AC no clipping", "AC limited clipping (10%)", | ||
195 | "DRC nighttime listening mode" | ||
196 | }; | ||
197 | static const char * const sta350_auto_xo_mode[] = { | ||
198 | "User", "80Hz", "100Hz", "120Hz", "140Hz", "160Hz", "180Hz", | ||
199 | "200Hz", "220Hz", "240Hz", "260Hz", "280Hz", "300Hz", "320Hz", | ||
200 | "340Hz", "360Hz" | ||
201 | }; | ||
202 | static const char * const sta350_binary_output[] = { | ||
203 | "FFX 3-state output - normal operation", "Binary output" | ||
204 | }; | ||
205 | static const char * const sta350_limiter_select[] = { | ||
206 | "Limiter Disabled", "Limiter #1", "Limiter #2" | ||
207 | }; | ||
208 | static const char * const sta350_limiter_attack_rate[] = { | ||
209 | "3.1584", "2.7072", "2.2560", "1.8048", "1.3536", "0.9024", | ||
210 | "0.4512", "0.2256", "0.1504", "0.1123", "0.0902", "0.0752", | ||
211 | "0.0645", "0.0564", "0.0501", "0.0451" | ||
212 | }; | ||
213 | static const char * const sta350_limiter_release_rate[] = { | ||
214 | "0.5116", "0.1370", "0.0744", "0.0499", "0.0360", "0.0299", | ||
215 | "0.0264", "0.0208", "0.0198", "0.0172", "0.0147", "0.0137", | ||
216 | "0.0134", "0.0117", "0.0110", "0.0104" | ||
217 | }; | ||
218 | static const char * const sta350_noise_shaper_type[] = { | ||
219 | "Third order", "Fourth order" | ||
220 | }; | ||
221 | |||
222 | static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_attack_tlv, | ||
223 | 0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0), | ||
224 | 8, 16, TLV_DB_SCALE_ITEM(300, 100, 0), | ||
225 | ); | ||
226 | |||
227 | static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_release_tlv, | ||
228 | 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0), | ||
229 | 1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0), | ||
230 | 2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0), | ||
231 | 3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0), | ||
232 | 8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0), | ||
233 | ); | ||
234 | |||
235 | static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_attack_tlv, | ||
236 | 0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0), | ||
237 | 8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0), | ||
238 | 14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0), | ||
239 | ); | ||
240 | |||
241 | static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_release_tlv, | ||
242 | 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0), | ||
243 | 1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0), | ||
244 | 3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0), | ||
245 | 5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0), | ||
246 | 13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0), | ||
247 | ); | ||
248 | |||
249 | static SOC_ENUM_SINGLE_DECL(sta350_drc_ac_enum, | ||
250 | STA350_CONFD, STA350_CONFD_DRC_SHIFT, | ||
251 | sta350_drc_ac); | ||
252 | static SOC_ENUM_SINGLE_DECL(sta350_noise_shaper_enum, | ||
253 | STA350_CONFE, STA350_CONFE_NSBW_SHIFT, | ||
254 | sta350_noise_shaper_type); | ||
255 | static SOC_ENUM_SINGLE_DECL(sta350_auto_gc_enum, | ||
256 | STA350_AUTO1, STA350_AUTO1_AMGC_SHIFT, | ||
257 | sta350_auto_gc_mode); | ||
258 | static SOC_ENUM_SINGLE_DECL(sta350_auto_xo_enum, | ||
259 | STA350_AUTO2, STA350_AUTO2_XO_SHIFT, | ||
260 | sta350_auto_xo_mode); | ||
261 | static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch1_enum, | ||
262 | STA350_C1CFG, STA350_CxCFG_BO_SHIFT, | ||
263 | sta350_binary_output); | ||
264 | static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch2_enum, | ||
265 | STA350_C2CFG, STA350_CxCFG_BO_SHIFT, | ||
266 | sta350_binary_output); | ||
267 | static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch3_enum, | ||
268 | STA350_C3CFG, STA350_CxCFG_BO_SHIFT, | ||
269 | sta350_binary_output); | ||
270 | static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch1_enum, | ||
271 | STA350_C1CFG, STA350_CxCFG_LS_SHIFT, | ||
272 | sta350_limiter_select); | ||
273 | static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch2_enum, | ||
274 | STA350_C2CFG, STA350_CxCFG_LS_SHIFT, | ||
275 | sta350_limiter_select); | ||
276 | static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch3_enum, | ||
277 | STA350_C3CFG, STA350_CxCFG_LS_SHIFT, | ||
278 | sta350_limiter_select); | ||
279 | static SOC_ENUM_SINGLE_DECL(sta350_limiter1_attack_rate_enum, | ||
280 | STA350_L1AR, STA350_LxA_SHIFT, | ||
281 | sta350_limiter_attack_rate); | ||
282 | static SOC_ENUM_SINGLE_DECL(sta350_limiter2_attack_rate_enum, | ||
283 | STA350_L2AR, STA350_LxA_SHIFT, | ||
284 | sta350_limiter_attack_rate); | ||
285 | static SOC_ENUM_SINGLE_DECL(sta350_limiter1_release_rate_enum, | ||
286 | STA350_L1AR, STA350_LxR_SHIFT, | ||
287 | sta350_limiter_release_rate); | ||
288 | static SOC_ENUM_SINGLE_DECL(sta350_limiter2_release_rate_enum, | ||
289 | STA350_L2AR, STA350_LxR_SHIFT, | ||
290 | sta350_limiter_release_rate); | ||
291 | |||
292 | /* | ||
293 | * byte array controls for setting biquad, mixer, scaling coefficients; | ||
294 | * for biquads all five coefficients need to be set in one go, | ||
295 | * mixer and pre/postscale coefs can be set individually; | ||
296 | * each coef is 24bit, the bytes are ordered in the same way | ||
297 | * as given in the STA350 data sheet (big endian; b1, b2, a1, a2, b0) | ||
298 | */ | ||
299 | |||
300 | static int sta350_coefficient_info(struct snd_kcontrol *kcontrol, | ||
301 | struct snd_ctl_elem_info *uinfo) | ||
302 | { | ||
303 | int numcoef = kcontrol->private_value >> 16; | ||
304 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; | ||
305 | uinfo->count = 3 * numcoef; | ||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | static int sta350_coefficient_get(struct snd_kcontrol *kcontrol, | ||
310 | struct snd_ctl_elem_value *ucontrol) | ||
311 | { | ||
312 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
313 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
314 | int numcoef = kcontrol->private_value >> 16; | ||
315 | int index = kcontrol->private_value & 0xffff; | ||
316 | unsigned int cfud, val; | ||
317 | int i, ret = 0; | ||
318 | |||
319 | mutex_lock(&sta350->coeff_lock); | ||
320 | |||
321 | /* preserve reserved bits in STA350_CFUD */ | ||
322 | regmap_read(sta350->regmap, STA350_CFUD, &cfud); | ||
323 | cfud &= 0xf0; | ||
324 | /* | ||
325 | * chip documentation does not say if the bits are self clearing, | ||
326 | * so do it explicitly | ||
327 | */ | ||
328 | regmap_write(sta350->regmap, STA350_CFUD, cfud); | ||
329 | |||
330 | regmap_write(sta350->regmap, STA350_CFADDR2, index); | ||
331 | if (numcoef == 1) { | ||
332 | regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x04); | ||
333 | } else if (numcoef == 5) { | ||
334 | regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x08); | ||
335 | } else { | ||
336 | ret = -EINVAL; | ||
337 | goto exit_unlock; | ||
338 | } | ||
339 | |||
340 | for (i = 0; i < 3 * numcoef; i++) { | ||
341 | regmap_read(sta350->regmap, STA350_B1CF1 + i, &val); | ||
342 | ucontrol->value.bytes.data[i] = val; | ||
343 | } | ||
344 | |||
345 | exit_unlock: | ||
346 | mutex_unlock(&sta350->coeff_lock); | ||
347 | |||
348 | return ret; | ||
349 | } | ||
350 | |||
351 | static int sta350_coefficient_put(struct snd_kcontrol *kcontrol, | ||
352 | struct snd_ctl_elem_value *ucontrol) | ||
353 | { | ||
354 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
355 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
356 | int numcoef = kcontrol->private_value >> 16; | ||
357 | int index = kcontrol->private_value & 0xffff; | ||
358 | unsigned int cfud; | ||
359 | int i; | ||
360 | |||
361 | /* preserve reserved bits in STA350_CFUD */ | ||
362 | regmap_read(sta350->regmap, STA350_CFUD, &cfud); | ||
363 | cfud &= 0xf0; | ||
364 | /* | ||
365 | * chip documentation does not say if the bits are self clearing, | ||
366 | * so do it explicitly | ||
367 | */ | ||
368 | regmap_write(sta350->regmap, STA350_CFUD, cfud); | ||
369 | |||
370 | regmap_write(sta350->regmap, STA350_CFADDR2, index); | ||
371 | for (i = 0; i < numcoef && (index + i < STA350_COEF_COUNT); i++) | ||
372 | sta350->coef_shadow[index + i] = | ||
373 | (ucontrol->value.bytes.data[3 * i] << 16) | ||
374 | | (ucontrol->value.bytes.data[3 * i + 1] << 8) | ||
375 | | (ucontrol->value.bytes.data[3 * i + 2]); | ||
376 | for (i = 0; i < 3 * numcoef; i++) | ||
377 | regmap_write(sta350->regmap, STA350_B1CF1 + i, | ||
378 | ucontrol->value.bytes.data[i]); | ||
379 | if (numcoef == 1) | ||
380 | regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01); | ||
381 | else if (numcoef == 5) | ||
382 | regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x02); | ||
383 | else | ||
384 | return -EINVAL; | ||
385 | |||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | static int sta350_sync_coef_shadow(struct snd_soc_codec *codec) | ||
390 | { | ||
391 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
392 | unsigned int cfud; | ||
393 | int i; | ||
394 | |||
395 | /* preserve reserved bits in STA350_CFUD */ | ||
396 | regmap_read(sta350->regmap, STA350_CFUD, &cfud); | ||
397 | cfud &= 0xf0; | ||
398 | |||
399 | for (i = 0; i < STA350_COEF_COUNT; i++) { | ||
400 | regmap_write(sta350->regmap, STA350_CFADDR2, i); | ||
401 | regmap_write(sta350->regmap, STA350_B1CF1, | ||
402 | (sta350->coef_shadow[i] >> 16) & 0xff); | ||
403 | regmap_write(sta350->regmap, STA350_B1CF2, | ||
404 | (sta350->coef_shadow[i] >> 8) & 0xff); | ||
405 | regmap_write(sta350->regmap, STA350_B1CF3, | ||
406 | (sta350->coef_shadow[i]) & 0xff); | ||
407 | /* | ||
408 | * chip documentation does not say if the bits are | ||
409 | * self-clearing, so do it explicitly | ||
410 | */ | ||
411 | regmap_write(sta350->regmap, STA350_CFUD, cfud); | ||
412 | regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01); | ||
413 | } | ||
414 | return 0; | ||
415 | } | ||
416 | |||
417 | static int sta350_cache_sync(struct snd_soc_codec *codec) | ||
418 | { | ||
419 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
420 | unsigned int mute; | ||
421 | int rc; | ||
422 | |||
423 | /* mute during register sync */ | ||
424 | regmap_read(sta350->regmap, STA350_CFUD, &mute); | ||
425 | regmap_write(sta350->regmap, STA350_MMUTE, mute | STA350_MMUTE_MMUTE); | ||
426 | sta350_sync_coef_shadow(codec); | ||
427 | rc = regcache_sync(sta350->regmap); | ||
428 | regmap_write(sta350->regmap, STA350_MMUTE, mute); | ||
429 | return rc; | ||
430 | } | ||
431 | |||
432 | #define SINGLE_COEF(xname, index) \ | ||
433 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | ||
434 | .info = sta350_coefficient_info, \ | ||
435 | .get = sta350_coefficient_get,\ | ||
436 | .put = sta350_coefficient_put, \ | ||
437 | .private_value = index | (1 << 16) } | ||
438 | |||
439 | #define BIQUAD_COEFS(xname, index) \ | ||
440 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | ||
441 | .info = sta350_coefficient_info, \ | ||
442 | .get = sta350_coefficient_get,\ | ||
443 | .put = sta350_coefficient_put, \ | ||
444 | .private_value = index | (5 << 16) } | ||
445 | |||
446 | static const struct snd_kcontrol_new sta350_snd_controls[] = { | ||
447 | SOC_SINGLE_TLV("Master Volume", STA350_MVOL, 0, 0xff, 1, mvol_tlv), | ||
448 | /* VOL */ | ||
449 | SOC_SINGLE_TLV("Ch1 Volume", STA350_C1VOL, 0, 0xff, 1, chvol_tlv), | ||
450 | SOC_SINGLE_TLV("Ch2 Volume", STA350_C2VOL, 0, 0xff, 1, chvol_tlv), | ||
451 | SOC_SINGLE_TLV("Ch3 Volume", STA350_C3VOL, 0, 0xff, 1, chvol_tlv), | ||
452 | /* CONFD */ | ||
453 | SOC_SINGLE("High Pass Filter Bypass Switch", | ||
454 | STA350_CONFD, STA350_CONFD_HPB_SHIFT, 1, 1), | ||
455 | SOC_SINGLE("De-emphasis Filter Switch", | ||
456 | STA350_CONFD, STA350_CONFD_DEMP_SHIFT, 1, 0), | ||
457 | SOC_SINGLE("DSP Bypass Switch", | ||
458 | STA350_CONFD, STA350_CONFD_DSPB_SHIFT, 1, 0), | ||
459 | SOC_SINGLE("Post-scale Link Switch", | ||
460 | STA350_CONFD, STA350_CONFD_PSL_SHIFT, 1, 0), | ||
461 | SOC_SINGLE("Biquad Coefficient Link Switch", | ||
462 | STA350_CONFD, STA350_CONFD_BQL_SHIFT, 1, 0), | ||
463 | SOC_ENUM("Compressor/Limiter Switch", sta350_drc_ac_enum), | ||
464 | SOC_ENUM("Noise Shaper Bandwidth", sta350_noise_shaper_enum), | ||
465 | SOC_SINGLE("Zero-detect Mute Enable Switch", | ||
466 | STA350_CONFD, STA350_CONFD_ZDE_SHIFT, 1, 0), | ||
467 | SOC_SINGLE("Submix Mode Switch", | ||
468 | STA350_CONFD, STA350_CONFD_SME_SHIFT, 1, 0), | ||
469 | /* CONFE */ | ||
470 | SOC_SINGLE("Zero Cross Switch", STA350_CONFE, STA350_CONFE_ZCE_SHIFT, 1, 0), | ||
471 | SOC_SINGLE("Soft Ramp Switch", STA350_CONFE, STA350_CONFE_SVE_SHIFT, 1, 0), | ||
472 | /* MUTE */ | ||
473 | SOC_SINGLE("Master Switch", STA350_MMUTE, STA350_MMUTE_MMUTE_SHIFT, 1, 1), | ||
474 | SOC_SINGLE("Ch1 Switch", STA350_MMUTE, STA350_MMUTE_C1M_SHIFT, 1, 1), | ||
475 | SOC_SINGLE("Ch2 Switch", STA350_MMUTE, STA350_MMUTE_C2M_SHIFT, 1, 1), | ||
476 | SOC_SINGLE("Ch3 Switch", STA350_MMUTE, STA350_MMUTE_C3M_SHIFT, 1, 1), | ||
477 | /* AUTOx */ | ||
478 | SOC_ENUM("Automode GC", sta350_auto_gc_enum), | ||
479 | SOC_ENUM("Automode XO", sta350_auto_xo_enum), | ||
480 | /* CxCFG */ | ||
481 | SOC_SINGLE("Ch1 Tone Control Bypass Switch", | ||
482 | STA350_C1CFG, STA350_CxCFG_TCB_SHIFT, 1, 0), | ||
483 | SOC_SINGLE("Ch2 Tone Control Bypass Switch", | ||
484 | STA350_C2CFG, STA350_CxCFG_TCB_SHIFT, 1, 0), | ||
485 | SOC_SINGLE("Ch1 EQ Bypass Switch", | ||
486 | STA350_C1CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0), | ||
487 | SOC_SINGLE("Ch2 EQ Bypass Switch", | ||
488 | STA350_C2CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0), | ||
489 | SOC_SINGLE("Ch1 Master Volume Bypass Switch", | ||
490 | STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0), | ||
491 | SOC_SINGLE("Ch2 Master Volume Bypass Switch", | ||
492 | STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0), | ||
493 | SOC_SINGLE("Ch3 Master Volume Bypass Switch", | ||
494 | STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0), | ||
495 | SOC_ENUM("Ch1 Binary Output Select", sta350_binary_output_ch1_enum), | ||
496 | SOC_ENUM("Ch2 Binary Output Select", sta350_binary_output_ch2_enum), | ||
497 | SOC_ENUM("Ch3 Binary Output Select", sta350_binary_output_ch3_enum), | ||
498 | SOC_ENUM("Ch1 Limiter Select", sta350_limiter_ch1_enum), | ||
499 | SOC_ENUM("Ch2 Limiter Select", sta350_limiter_ch2_enum), | ||
500 | SOC_ENUM("Ch3 Limiter Select", sta350_limiter_ch3_enum), | ||
501 | /* TONE */ | ||
502 | SOC_SINGLE_RANGE_TLV("Bass Tone Control Volume", | ||
503 | STA350_TONE, STA350_TONE_BTC_SHIFT, 1, 13, 0, tone_tlv), | ||
504 | SOC_SINGLE_RANGE_TLV("Treble Tone Control Volume", | ||
505 | STA350_TONE, STA350_TONE_TTC_SHIFT, 1, 13, 0, tone_tlv), | ||
506 | SOC_ENUM("Limiter1 Attack Rate (dB/ms)", sta350_limiter1_attack_rate_enum), | ||
507 | SOC_ENUM("Limiter2 Attack Rate (dB/ms)", sta350_limiter2_attack_rate_enum), | ||
508 | SOC_ENUM("Limiter1 Release Rate (dB/ms)", sta350_limiter1_release_rate_enum), | ||
509 | SOC_ENUM("Limiter2 Release Rate (dB/ms)", sta350_limiter2_release_rate_enum), | ||
510 | |||
511 | /* | ||
512 | * depending on mode, the attack/release thresholds have | ||
513 | * two different enum definitions; provide both | ||
514 | */ | ||
515 | SOC_SINGLE_TLV("Limiter1 Attack Threshold (AC Mode)", | ||
516 | STA350_L1ATRT, STA350_LxA_SHIFT, | ||
517 | 16, 0, sta350_limiter_ac_attack_tlv), | ||
518 | SOC_SINGLE_TLV("Limiter2 Attack Threshold (AC Mode)", | ||
519 | STA350_L2ATRT, STA350_LxA_SHIFT, | ||
520 | 16, 0, sta350_limiter_ac_attack_tlv), | ||
521 | SOC_SINGLE_TLV("Limiter1 Release Threshold (AC Mode)", | ||
522 | STA350_L1ATRT, STA350_LxR_SHIFT, | ||
523 | 16, 0, sta350_limiter_ac_release_tlv), | ||
524 | SOC_SINGLE_TLV("Limiter2 Release Threshold (AC Mode)", | ||
525 | STA350_L2ATRT, STA350_LxR_SHIFT, | ||
526 | 16, 0, sta350_limiter_ac_release_tlv), | ||
527 | SOC_SINGLE_TLV("Limiter1 Attack Threshold (DRC Mode)", | ||
528 | STA350_L1ATRT, STA350_LxA_SHIFT, | ||
529 | 16, 0, sta350_limiter_drc_attack_tlv), | ||
530 | SOC_SINGLE_TLV("Limiter2 Attack Threshold (DRC Mode)", | ||
531 | STA350_L2ATRT, STA350_LxA_SHIFT, | ||
532 | 16, 0, sta350_limiter_drc_attack_tlv), | ||
533 | SOC_SINGLE_TLV("Limiter1 Release Threshold (DRC Mode)", | ||
534 | STA350_L1ATRT, STA350_LxR_SHIFT, | ||
535 | 16, 0, sta350_limiter_drc_release_tlv), | ||
536 | SOC_SINGLE_TLV("Limiter2 Release Threshold (DRC Mode)", | ||
537 | STA350_L2ATRT, STA350_LxR_SHIFT, | ||
538 | 16, 0, sta350_limiter_drc_release_tlv), | ||
539 | |||
540 | BIQUAD_COEFS("Ch1 - Biquad 1", 0), | ||
541 | BIQUAD_COEFS("Ch1 - Biquad 2", 5), | ||
542 | BIQUAD_COEFS("Ch1 - Biquad 3", 10), | ||
543 | BIQUAD_COEFS("Ch1 - Biquad 4", 15), | ||
544 | BIQUAD_COEFS("Ch2 - Biquad 1", 20), | ||
545 | BIQUAD_COEFS("Ch2 - Biquad 2", 25), | ||
546 | BIQUAD_COEFS("Ch2 - Biquad 3", 30), | ||
547 | BIQUAD_COEFS("Ch2 - Biquad 4", 35), | ||
548 | BIQUAD_COEFS("High-pass", 40), | ||
549 | BIQUAD_COEFS("Low-pass", 45), | ||
550 | SINGLE_COEF("Ch1 - Prescale", 50), | ||
551 | SINGLE_COEF("Ch2 - Prescale", 51), | ||
552 | SINGLE_COEF("Ch1 - Postscale", 52), | ||
553 | SINGLE_COEF("Ch2 - Postscale", 53), | ||
554 | SINGLE_COEF("Ch3 - Postscale", 54), | ||
555 | SINGLE_COEF("Thermal warning - Postscale", 55), | ||
556 | SINGLE_COEF("Ch1 - Mix 1", 56), | ||
557 | SINGLE_COEF("Ch1 - Mix 2", 57), | ||
558 | SINGLE_COEF("Ch2 - Mix 1", 58), | ||
559 | SINGLE_COEF("Ch2 - Mix 2", 59), | ||
560 | SINGLE_COEF("Ch3 - Mix 1", 60), | ||
561 | SINGLE_COEF("Ch3 - Mix 2", 61), | ||
562 | }; | ||
563 | |||
564 | static const struct snd_soc_dapm_widget sta350_dapm_widgets[] = { | ||
565 | SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0), | ||
566 | SND_SOC_DAPM_OUTPUT("LEFT"), | ||
567 | SND_SOC_DAPM_OUTPUT("RIGHT"), | ||
568 | SND_SOC_DAPM_OUTPUT("SUB"), | ||
569 | }; | ||
570 | |||
571 | static const struct snd_soc_dapm_route sta350_dapm_routes[] = { | ||
572 | { "LEFT", NULL, "DAC" }, | ||
573 | { "RIGHT", NULL, "DAC" }, | ||
574 | { "SUB", NULL, "DAC" }, | ||
575 | { "DAC", NULL, "Playback" }, | ||
576 | }; | ||
577 | |||
578 | /* MCLK interpolation ratio per fs */ | ||
579 | static struct { | ||
580 | int fs; | ||
581 | int ir; | ||
582 | } interpolation_ratios[] = { | ||
583 | { 32000, 0 }, | ||
584 | { 44100, 0 }, | ||
585 | { 48000, 0 }, | ||
586 | { 88200, 1 }, | ||
587 | { 96000, 1 }, | ||
588 | { 176400, 2 }, | ||
589 | { 192000, 2 }, | ||
590 | }; | ||
591 | |||
592 | /* MCLK to fs clock ratios */ | ||
593 | static int mcs_ratio_table[3][6] = { | ||
594 | { 768, 512, 384, 256, 128, 576 }, | ||
595 | { 384, 256, 192, 128, 64, 0 }, | ||
596 | { 192, 128, 96, 64, 32, 0 }, | ||
597 | }; | ||
598 | |||
599 | /** | ||
600 | * sta350_set_dai_sysclk - configure MCLK | ||
601 | * @codec_dai: the codec DAI | ||
602 | * @clk_id: the clock ID (ignored) | ||
603 | * @freq: the MCLK input frequency | ||
604 | * @dir: the clock direction (ignored) | ||
605 | * | ||
606 | * The value of MCLK is used to determine which sample rates are supported | ||
607 | * by the STA350, based on the mcs_ratio_table. | ||
608 | * | ||
609 | * This function must be called by the machine driver's 'startup' function, | ||
610 | * otherwise the list of supported sample rates will not be available in | ||
611 | * time for ALSA. | ||
612 | */ | ||
613 | static int sta350_set_dai_sysclk(struct snd_soc_dai *codec_dai, | ||
614 | int clk_id, unsigned int freq, int dir) | ||
615 | { | ||
616 | struct snd_soc_codec *codec = codec_dai->codec; | ||
617 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
618 | |||
619 | dev_dbg(codec->dev, "mclk=%u\n", freq); | ||
620 | sta350->mclk = freq; | ||
621 | |||
622 | return 0; | ||
623 | } | ||
624 | |||
625 | /** | ||
626 | * sta350_set_dai_fmt - configure the codec for the selected audio format | ||
627 | * @codec_dai: the codec DAI | ||
628 | * @fmt: a SND_SOC_DAIFMT_x value indicating the data format | ||
629 | * | ||
630 | * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the | ||
631 | * codec accordingly. | ||
632 | */ | ||
633 | static int sta350_set_dai_fmt(struct snd_soc_dai *codec_dai, | ||
634 | unsigned int fmt) | ||
635 | { | ||
636 | struct snd_soc_codec *codec = codec_dai->codec; | ||
637 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
638 | unsigned int confb = 0; | ||
639 | |||
640 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
641 | case SND_SOC_DAIFMT_CBS_CFS: | ||
642 | break; | ||
643 | default: | ||
644 | return -EINVAL; | ||
645 | } | ||
646 | |||
647 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
648 | case SND_SOC_DAIFMT_I2S: | ||
649 | case SND_SOC_DAIFMT_RIGHT_J: | ||
650 | case SND_SOC_DAIFMT_LEFT_J: | ||
651 | sta350->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; | ||
652 | break; | ||
653 | default: | ||
654 | return -EINVAL; | ||
655 | } | ||
656 | |||
657 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
658 | case SND_SOC_DAIFMT_NB_NF: | ||
659 | confb |= STA350_CONFB_C2IM; | ||
660 | break; | ||
661 | case SND_SOC_DAIFMT_NB_IF: | ||
662 | confb |= STA350_CONFB_C1IM; | ||
663 | break; | ||
664 | default: | ||
665 | return -EINVAL; | ||
666 | } | ||
667 | |||
668 | return regmap_update_bits(sta350->regmap, STA350_CONFB, | ||
669 | STA350_CONFB_C1IM | STA350_CONFB_C2IM, confb); | ||
670 | } | ||
671 | |||
672 | /** | ||
673 | * sta350_hw_params - program the STA350 with the given hardware parameters. | ||
674 | * @substream: the audio stream | ||
675 | * @params: the hardware parameters to set | ||
676 | * @dai: the SOC DAI (ignored) | ||
677 | * | ||
678 | * This function programs the hardware with the values provided. | ||
679 | * Specifically, the sample rate and the data format. | ||
680 | */ | ||
681 | static int sta350_hw_params(struct snd_pcm_substream *substream, | ||
682 | struct snd_pcm_hw_params *params, | ||
683 | struct snd_soc_dai *dai) | ||
684 | { | ||
685 | struct snd_soc_codec *codec = dai->codec; | ||
686 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
687 | int i, mcs = -EINVAL, ir = -EINVAL; | ||
688 | unsigned int confa, confb; | ||
689 | unsigned int rate, ratio; | ||
690 | int ret; | ||
691 | |||
692 | if (!sta350->mclk) { | ||
693 | dev_err(codec->dev, | ||
694 | "sta350->mclk is unset. Unable to determine ratio\n"); | ||
695 | return -EIO; | ||
696 | } | ||
697 | |||
698 | rate = params_rate(params); | ||
699 | ratio = sta350->mclk / rate; | ||
700 | dev_dbg(codec->dev, "rate: %u, ratio: %u\n", rate, ratio); | ||
701 | |||
702 | for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { | ||
703 | if (interpolation_ratios[i].fs == rate) { | ||
704 | ir = interpolation_ratios[i].ir; | ||
705 | break; | ||
706 | } | ||
707 | } | ||
708 | |||
709 | if (ir < 0) { | ||
710 | dev_err(codec->dev, "Unsupported samplerate: %u\n", rate); | ||
711 | return -EINVAL; | ||
712 | } | ||
713 | |||
714 | for (i = 0; i < 6; i++) { | ||
715 | if (mcs_ratio_table[ir][i] == ratio) { | ||
716 | mcs = i; | ||
717 | break; | ||
718 | } | ||
719 | } | ||
720 | |||
721 | if (mcs < 0) { | ||
722 | dev_err(codec->dev, "Unresolvable ratio: %u\n", ratio); | ||
723 | return -EINVAL; | ||
724 | } | ||
725 | |||
726 | confa = (ir << STA350_CONFA_IR_SHIFT) | | ||
727 | (mcs << STA350_CONFA_MCS_SHIFT); | ||
728 | confb = 0; | ||
729 | |||
730 | switch (params_width(params)) { | ||
731 | case 24: | ||
732 | dev_dbg(codec->dev, "24bit\n"); | ||
733 | /* fall through */ | ||
734 | case 32: | ||
735 | dev_dbg(codec->dev, "24bit or 32bit\n"); | ||
736 | switch (sta350->format) { | ||
737 | case SND_SOC_DAIFMT_I2S: | ||
738 | confb |= 0x0; | ||
739 | break; | ||
740 | case SND_SOC_DAIFMT_LEFT_J: | ||
741 | confb |= 0x1; | ||
742 | break; | ||
743 | case SND_SOC_DAIFMT_RIGHT_J: | ||
744 | confb |= 0x2; | ||
745 | break; | ||
746 | } | ||
747 | |||
748 | break; | ||
749 | case 20: | ||
750 | dev_dbg(codec->dev, "20bit\n"); | ||
751 | switch (sta350->format) { | ||
752 | case SND_SOC_DAIFMT_I2S: | ||
753 | confb |= 0x4; | ||
754 | break; | ||
755 | case SND_SOC_DAIFMT_LEFT_J: | ||
756 | confb |= 0x5; | ||
757 | break; | ||
758 | case SND_SOC_DAIFMT_RIGHT_J: | ||
759 | confb |= 0x6; | ||
760 | break; | ||
761 | } | ||
762 | |||
763 | break; | ||
764 | case 18: | ||
765 | dev_dbg(codec->dev, "18bit\n"); | ||
766 | switch (sta350->format) { | ||
767 | case SND_SOC_DAIFMT_I2S: | ||
768 | confb |= 0x8; | ||
769 | break; | ||
770 | case SND_SOC_DAIFMT_LEFT_J: | ||
771 | confb |= 0x9; | ||
772 | break; | ||
773 | case SND_SOC_DAIFMT_RIGHT_J: | ||
774 | confb |= 0xa; | ||
775 | break; | ||
776 | } | ||
777 | |||
778 | break; | ||
779 | case 16: | ||
780 | dev_dbg(codec->dev, "16bit\n"); | ||
781 | switch (sta350->format) { | ||
782 | case SND_SOC_DAIFMT_I2S: | ||
783 | confb |= 0x0; | ||
784 | break; | ||
785 | case SND_SOC_DAIFMT_LEFT_J: | ||
786 | confb |= 0xd; | ||
787 | break; | ||
788 | case SND_SOC_DAIFMT_RIGHT_J: | ||
789 | confb |= 0xe; | ||
790 | break; | ||
791 | } | ||
792 | |||
793 | break; | ||
794 | default: | ||
795 | return -EINVAL; | ||
796 | } | ||
797 | |||
798 | ret = regmap_update_bits(sta350->regmap, STA350_CONFA, | ||
799 | STA350_CONFA_MCS_MASK | STA350_CONFA_IR_MASK, | ||
800 | confa); | ||
801 | if (ret < 0) | ||
802 | return ret; | ||
803 | |||
804 | ret = regmap_update_bits(sta350->regmap, STA350_CONFB, | ||
805 | STA350_CONFB_SAI_MASK | STA350_CONFB_SAIFB, | ||
806 | confb); | ||
807 | if (ret < 0) | ||
808 | return ret; | ||
809 | |||
810 | return 0; | ||
811 | } | ||
812 | |||
813 | static int sta350_startup_sequence(struct sta350_priv *sta350) | ||
814 | { | ||
815 | if (sta350->gpiod_power_down) | ||
816 | gpiod_set_value(sta350->gpiod_power_down, 1); | ||
817 | |||
818 | if (sta350->gpiod_nreset) { | ||
819 | gpiod_set_value(sta350->gpiod_nreset, 0); | ||
820 | mdelay(1); | ||
821 | gpiod_set_value(sta350->gpiod_nreset, 1); | ||
822 | mdelay(1); | ||
823 | } | ||
824 | |||
825 | return 0; | ||
826 | } | ||
827 | |||
828 | /** | ||
829 | * sta350_set_bias_level - DAPM callback | ||
830 | * @codec: the codec device | ||
831 | * @level: DAPM power level | ||
832 | * | ||
833 | * This is called by ALSA to put the codec into low power mode | ||
834 | * or to wake it up. If the codec is powered off completely | ||
835 | * all registers must be restored after power on. | ||
836 | */ | ||
837 | static int sta350_set_bias_level(struct snd_soc_codec *codec, | ||
838 | enum snd_soc_bias_level level) | ||
839 | { | ||
840 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
841 | int ret; | ||
842 | |||
843 | dev_dbg(codec->dev, "level = %d\n", level); | ||
844 | switch (level) { | ||
845 | case SND_SOC_BIAS_ON: | ||
846 | break; | ||
847 | |||
848 | case SND_SOC_BIAS_PREPARE: | ||
849 | /* Full power on */ | ||
850 | regmap_update_bits(sta350->regmap, STA350_CONFF, | ||
851 | STA350_CONFF_PWDN | STA350_CONFF_EAPD, | ||
852 | STA350_CONFF_PWDN | STA350_CONFF_EAPD); | ||
853 | break; | ||
854 | |||
855 | case SND_SOC_BIAS_STANDBY: | ||
856 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | ||
857 | ret = regulator_bulk_enable( | ||
858 | ARRAY_SIZE(sta350->supplies), | ||
859 | sta350->supplies); | ||
860 | if (ret < 0) { | ||
861 | dev_err(codec->dev, | ||
862 | "Failed to enable supplies: %d\n", | ||
863 | ret); | ||
864 | return ret; | ||
865 | } | ||
866 | sta350_startup_sequence(sta350); | ||
867 | sta350_cache_sync(codec); | ||
868 | } | ||
869 | |||
870 | /* Power down */ | ||
871 | regmap_update_bits(sta350->regmap, STA350_CONFF, | ||
872 | STA350_CONFF_PWDN | STA350_CONFF_EAPD, | ||
873 | 0); | ||
874 | |||
875 | break; | ||
876 | |||
877 | case SND_SOC_BIAS_OFF: | ||
878 | /* The chip runs through the power down sequence for us */ | ||
879 | regmap_update_bits(sta350->regmap, STA350_CONFF, | ||
880 | STA350_CONFF_PWDN | STA350_CONFF_EAPD, 0); | ||
881 | |||
882 | /* power down: low */ | ||
883 | if (sta350->gpiod_power_down) | ||
884 | gpiod_set_value(sta350->gpiod_power_down, 0); | ||
885 | |||
886 | if (sta350->gpiod_nreset) | ||
887 | gpiod_set_value(sta350->gpiod_nreset, 0); | ||
888 | |||
889 | regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), | ||
890 | sta350->supplies); | ||
891 | break; | ||
892 | } | ||
893 | codec->dapm.bias_level = level; | ||
894 | return 0; | ||
895 | } | ||
896 | |||
897 | static const struct snd_soc_dai_ops sta350_dai_ops = { | ||
898 | .hw_params = sta350_hw_params, | ||
899 | .set_sysclk = sta350_set_dai_sysclk, | ||
900 | .set_fmt = sta350_set_dai_fmt, | ||
901 | }; | ||
902 | |||
903 | static struct snd_soc_dai_driver sta350_dai = { | ||
904 | .name = "sta350-hifi", | ||
905 | .playback = { | ||
906 | .stream_name = "Playback", | ||
907 | .channels_min = 2, | ||
908 | .channels_max = 2, | ||
909 | .rates = STA350_RATES, | ||
910 | .formats = STA350_FORMATS, | ||
911 | }, | ||
912 | .ops = &sta350_dai_ops, | ||
913 | }; | ||
914 | |||
915 | #ifdef CONFIG_PM | ||
916 | static int sta350_suspend(struct snd_soc_codec *codec) | ||
917 | { | ||
918 | sta350_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
919 | return 0; | ||
920 | } | ||
921 | |||
922 | static int sta350_resume(struct snd_soc_codec *codec) | ||
923 | { | ||
924 | sta350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
925 | return 0; | ||
926 | } | ||
927 | #else | ||
928 | #define sta350_suspend NULL | ||
929 | #define sta350_resume NULL | ||
930 | #endif | ||
931 | |||
932 | static int sta350_probe(struct snd_soc_codec *codec) | ||
933 | { | ||
934 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
935 | struct sta350_platform_data *pdata = sta350->pdata; | ||
936 | int i, ret = 0, thermal = 0; | ||
937 | |||
938 | ret = regulator_bulk_enable(ARRAY_SIZE(sta350->supplies), | ||
939 | sta350->supplies); | ||
940 | if (ret < 0) { | ||
941 | dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); | ||
942 | return ret; | ||
943 | } | ||
944 | |||
945 | ret = sta350_startup_sequence(sta350); | ||
946 | if (ret < 0) { | ||
947 | dev_err(codec->dev, "Failed to startup device\n"); | ||
948 | return ret; | ||
949 | } | ||
950 | |||
951 | /* CONFA */ | ||
952 | if (!pdata->thermal_warning_recovery) | ||
953 | thermal |= STA350_CONFA_TWAB; | ||
954 | if (!pdata->thermal_warning_adjustment) | ||
955 | thermal |= STA350_CONFA_TWRB; | ||
956 | if (!pdata->fault_detect_recovery) | ||
957 | thermal |= STA350_CONFA_FDRB; | ||
958 | regmap_update_bits(sta350->regmap, STA350_CONFA, | ||
959 | STA350_CONFA_TWAB | STA350_CONFA_TWRB | | ||
960 | STA350_CONFA_FDRB, | ||
961 | thermal); | ||
962 | |||
963 | /* CONFC */ | ||
964 | regmap_update_bits(sta350->regmap, STA350_CONFC, | ||
965 | STA350_CONFC_OM_MASK, | ||
966 | pdata->ffx_power_output_mode | ||
967 | << STA350_CONFC_OM_SHIFT); | ||
968 | regmap_update_bits(sta350->regmap, STA350_CONFC, | ||
969 | STA350_CONFC_CSZ_MASK, | ||
970 | pdata->drop_compensation_ns | ||
971 | << STA350_CONFC_CSZ_SHIFT); | ||
972 | regmap_update_bits(sta350->regmap, | ||
973 | STA350_CONFC, | ||
974 | STA350_CONFC_OCRB, | ||
975 | pdata->oc_warning_adjustment ? | ||
976 | STA350_CONFC_OCRB : 0); | ||
977 | |||
978 | /* CONFE */ | ||
979 | regmap_update_bits(sta350->regmap, STA350_CONFE, | ||
980 | STA350_CONFE_MPCV, | ||
981 | pdata->max_power_use_mpcc ? | ||
982 | STA350_CONFE_MPCV : 0); | ||
983 | regmap_update_bits(sta350->regmap, STA350_CONFE, | ||
984 | STA350_CONFE_MPC, | ||
985 | pdata->max_power_correction ? | ||
986 | STA350_CONFE_MPC : 0); | ||
987 | regmap_update_bits(sta350->regmap, STA350_CONFE, | ||
988 | STA350_CONFE_AME, | ||
989 | pdata->am_reduction_mode ? | ||
990 | STA350_CONFE_AME : 0); | ||
991 | regmap_update_bits(sta350->regmap, STA350_CONFE, | ||
992 | STA350_CONFE_PWMS, | ||
993 | pdata->odd_pwm_speed_mode ? | ||
994 | STA350_CONFE_PWMS : 0); | ||
995 | regmap_update_bits(sta350->regmap, STA350_CONFE, | ||
996 | STA350_CONFE_DCCV, | ||
997 | pdata->distortion_compensation ? | ||
998 | STA350_CONFE_DCCV : 0); | ||
999 | /* CONFF */ | ||
1000 | regmap_update_bits(sta350->regmap, STA350_CONFF, | ||
1001 | STA350_CONFF_IDE, | ||
1002 | pdata->invalid_input_detect_mute ? | ||
1003 | STA350_CONFF_IDE : 0); | ||
1004 | regmap_update_bits(sta350->regmap, STA350_CONFF, | ||
1005 | STA350_CONFF_OCFG_MASK, | ||
1006 | pdata->output_conf | ||
1007 | << STA350_CONFF_OCFG_SHIFT); | ||
1008 | |||
1009 | /* channel to output mapping */ | ||
1010 | regmap_update_bits(sta350->regmap, STA350_C1CFG, | ||
1011 | STA350_CxCFG_OM_MASK, | ||
1012 | pdata->ch1_output_mapping | ||
1013 | << STA350_CxCFG_OM_SHIFT); | ||
1014 | regmap_update_bits(sta350->regmap, STA350_C2CFG, | ||
1015 | STA350_CxCFG_OM_MASK, | ||
1016 | pdata->ch2_output_mapping | ||
1017 | << STA350_CxCFG_OM_SHIFT); | ||
1018 | regmap_update_bits(sta350->regmap, STA350_C3CFG, | ||
1019 | STA350_CxCFG_OM_MASK, | ||
1020 | pdata->ch3_output_mapping | ||
1021 | << STA350_CxCFG_OM_SHIFT); | ||
1022 | |||
1023 | /* initialize coefficient shadow RAM with reset values */ | ||
1024 | for (i = 4; i <= 49; i += 5) | ||
1025 | sta350->coef_shadow[i] = 0x400000; | ||
1026 | for (i = 50; i <= 54; i++) | ||
1027 | sta350->coef_shadow[i] = 0x7fffff; | ||
1028 | sta350->coef_shadow[55] = 0x5a9df7; | ||
1029 | sta350->coef_shadow[56] = 0x7fffff; | ||
1030 | sta350->coef_shadow[59] = 0x7fffff; | ||
1031 | sta350->coef_shadow[60] = 0x400000; | ||
1032 | sta350->coef_shadow[61] = 0x400000; | ||
1033 | |||
1034 | sta350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1035 | /* Bias level configuration will have done an extra enable */ | ||
1036 | regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); | ||
1037 | |||
1038 | return 0; | ||
1039 | } | ||
1040 | |||
1041 | static int sta350_remove(struct snd_soc_codec *codec) | ||
1042 | { | ||
1043 | struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); | ||
1044 | |||
1045 | sta350_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
1046 | regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); | ||
1047 | |||
1048 | return 0; | ||
1049 | } | ||
1050 | |||
1051 | static const struct snd_soc_codec_driver sta350_codec = { | ||
1052 | .probe = sta350_probe, | ||
1053 | .remove = sta350_remove, | ||
1054 | .suspend = sta350_suspend, | ||
1055 | .resume = sta350_resume, | ||
1056 | .set_bias_level = sta350_set_bias_level, | ||
1057 | .controls = sta350_snd_controls, | ||
1058 | .num_controls = ARRAY_SIZE(sta350_snd_controls), | ||
1059 | .dapm_widgets = sta350_dapm_widgets, | ||
1060 | .num_dapm_widgets = ARRAY_SIZE(sta350_dapm_widgets), | ||
1061 | .dapm_routes = sta350_dapm_routes, | ||
1062 | .num_dapm_routes = ARRAY_SIZE(sta350_dapm_routes), | ||
1063 | }; | ||
1064 | |||
1065 | static const struct regmap_config sta350_regmap = { | ||
1066 | .reg_bits = 8, | ||
1067 | .val_bits = 8, | ||
1068 | .max_register = STA350_MISC2, | ||
1069 | .reg_defaults = sta350_regs, | ||
1070 | .num_reg_defaults = ARRAY_SIZE(sta350_regs), | ||
1071 | .cache_type = REGCACHE_RBTREE, | ||
1072 | .wr_table = &sta350_write_regs, | ||
1073 | .rd_table = &sta350_read_regs, | ||
1074 | .volatile_table = &sta350_volatile_regs, | ||
1075 | }; | ||
1076 | |||
1077 | #ifdef CONFIG_OF | ||
1078 | static const struct of_device_id st350_dt_ids[] = { | ||
1079 | { .compatible = "st,sta350", }, | ||
1080 | { } | ||
1081 | }; | ||
1082 | MODULE_DEVICE_TABLE(of, st350_dt_ids); | ||
1083 | |||
1084 | static const char * const sta350_ffx_modes[] = { | ||
1085 | [STA350_FFX_PM_DROP_COMP] = "drop-compensation", | ||
1086 | [STA350_FFX_PM_TAPERED_COMP] = "tapered-compensation", | ||
1087 | [STA350_FFX_PM_FULL_POWER] = "full-power-mode", | ||
1088 | [STA350_FFX_PM_VARIABLE_DROP_COMP] = "variable-drop-compensation", | ||
1089 | }; | ||
1090 | |||
1091 | static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350) | ||
1092 | { | ||
1093 | struct device_node *np = dev->of_node; | ||
1094 | struct sta350_platform_data *pdata; | ||
1095 | const char *ffx_power_mode; | ||
1096 | u16 tmp; | ||
1097 | |||
1098 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
1099 | if (!pdata) | ||
1100 | return -ENOMEM; | ||
1101 | |||
1102 | of_property_read_u8(np, "st,output-conf", | ||
1103 | &pdata->output_conf); | ||
1104 | of_property_read_u8(np, "st,ch1-output-mapping", | ||
1105 | &pdata->ch1_output_mapping); | ||
1106 | of_property_read_u8(np, "st,ch2-output-mapping", | ||
1107 | &pdata->ch2_output_mapping); | ||
1108 | of_property_read_u8(np, "st,ch3-output-mapping", | ||
1109 | &pdata->ch3_output_mapping); | ||
1110 | |||
1111 | if (of_get_property(np, "st,thermal-warning-recovery", NULL)) | ||
1112 | pdata->thermal_warning_recovery = 1; | ||
1113 | if (of_get_property(np, "st,thermal-warning-adjustment", NULL)) | ||
1114 | pdata->thermal_warning_adjustment = 1; | ||
1115 | if (of_get_property(np, "st,fault-detect-recovery", NULL)) | ||
1116 | pdata->fault_detect_recovery = 1; | ||
1117 | |||
1118 | pdata->ffx_power_output_mode = STA350_FFX_PM_VARIABLE_DROP_COMP; | ||
1119 | if (!of_property_read_string(np, "st,ffx-power-output-mode", | ||
1120 | &ffx_power_mode)) { | ||
1121 | int i, mode = -EINVAL; | ||
1122 | |||
1123 | for (i = 0; i < ARRAY_SIZE(sta350_ffx_modes); i++) | ||
1124 | if (!strcasecmp(ffx_power_mode, sta350_ffx_modes[i])) | ||
1125 | mode = i; | ||
1126 | |||
1127 | if (mode < 0) | ||
1128 | dev_warn(dev, "Unsupported ffx output mode: %s\n", | ||
1129 | ffx_power_mode); | ||
1130 | else | ||
1131 | pdata->ffx_power_output_mode = mode; | ||
1132 | } | ||
1133 | |||
1134 | tmp = 140; | ||
1135 | of_property_read_u16(np, "st,drop-compensation-ns", &tmp); | ||
1136 | pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20; | ||
1137 | |||
1138 | if (of_get_property(np, "st,overcurrent-warning-adjustment", NULL)) | ||
1139 | pdata->oc_warning_adjustment = 1; | ||
1140 | |||
1141 | /* CONFE */ | ||
1142 | if (of_get_property(np, "st,max-power-use-mpcc", NULL)) | ||
1143 | pdata->max_power_use_mpcc = 1; | ||
1144 | |||
1145 | if (of_get_property(np, "st,max-power-correction", NULL)) | ||
1146 | pdata->max_power_correction = 1; | ||
1147 | |||
1148 | if (of_get_property(np, "st,am-reduction-mode", NULL)) | ||
1149 | pdata->am_reduction_mode = 1; | ||
1150 | |||
1151 | if (of_get_property(np, "st,odd-pwm-speed-mode", NULL)) | ||
1152 | pdata->odd_pwm_speed_mode = 1; | ||
1153 | |||
1154 | if (of_get_property(np, "st,distortion-compensation", NULL)) | ||
1155 | pdata->distortion_compensation = 1; | ||
1156 | |||
1157 | /* CONFF */ | ||
1158 | if (of_get_property(np, "st,invalid-input-detect-mute", NULL)) | ||
1159 | pdata->invalid_input_detect_mute = 1; | ||
1160 | |||
1161 | sta350->pdata = pdata; | ||
1162 | |||
1163 | return 0; | ||
1164 | } | ||
1165 | #endif | ||
1166 | |||
1167 | static int sta350_i2c_probe(struct i2c_client *i2c, | ||
1168 | const struct i2c_device_id *id) | ||
1169 | { | ||
1170 | struct device *dev = &i2c->dev; | ||
1171 | struct sta350_priv *sta350; | ||
1172 | int ret, i; | ||
1173 | |||
1174 | sta350 = devm_kzalloc(dev, sizeof(struct sta350_priv), GFP_KERNEL); | ||
1175 | if (!sta350) | ||
1176 | return -ENOMEM; | ||
1177 | |||
1178 | mutex_init(&sta350->coeff_lock); | ||
1179 | sta350->pdata = dev_get_platdata(dev); | ||
1180 | |||
1181 | #ifdef CONFIG_OF | ||
1182 | if (dev->of_node) { | ||
1183 | ret = sta350_probe_dt(dev, sta350); | ||
1184 | if (ret < 0) | ||
1185 | return ret; | ||
1186 | } | ||
1187 | #endif | ||
1188 | |||
1189 | /* GPIOs */ | ||
1190 | sta350->gpiod_nreset = devm_gpiod_get(dev, "reset"); | ||
1191 | if (IS_ERR(sta350->gpiod_nreset)) { | ||
1192 | ret = PTR_ERR(sta350->gpiod_nreset); | ||
1193 | if (ret != -ENOENT && ret != -ENOSYS) | ||
1194 | return ret; | ||
1195 | |||
1196 | sta350->gpiod_nreset = NULL; | ||
1197 | } else { | ||
1198 | gpiod_direction_output(sta350->gpiod_nreset, 0); | ||
1199 | } | ||
1200 | |||
1201 | sta350->gpiod_power_down = devm_gpiod_get(dev, "power-down"); | ||
1202 | if (IS_ERR(sta350->gpiod_power_down)) { | ||
1203 | ret = PTR_ERR(sta350->gpiod_power_down); | ||
1204 | if (ret != -ENOENT && ret != -ENOSYS) | ||
1205 | return ret; | ||
1206 | |||
1207 | sta350->gpiod_power_down = NULL; | ||
1208 | } else { | ||
1209 | gpiod_direction_output(sta350->gpiod_power_down, 0); | ||
1210 | } | ||
1211 | |||
1212 | /* regulators */ | ||
1213 | for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++) | ||
1214 | sta350->supplies[i].supply = sta350_supply_names[i]; | ||
1215 | |||
1216 | ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(sta350->supplies), | ||
1217 | sta350->supplies); | ||
1218 | if (ret < 0) { | ||
1219 | dev_err(dev, "Failed to request supplies: %d\n", ret); | ||
1220 | return ret; | ||
1221 | } | ||
1222 | |||
1223 | sta350->regmap = devm_regmap_init_i2c(i2c, &sta350_regmap); | ||
1224 | if (IS_ERR(sta350->regmap)) { | ||
1225 | ret = PTR_ERR(sta350->regmap); | ||
1226 | dev_err(dev, "Failed to init regmap: %d\n", ret); | ||
1227 | return ret; | ||
1228 | } | ||
1229 | |||
1230 | i2c_set_clientdata(i2c, sta350); | ||
1231 | |||
1232 | ret = snd_soc_register_codec(dev, &sta350_codec, &sta350_dai, 1); | ||
1233 | if (ret < 0) | ||
1234 | dev_err(dev, "Failed to register codec (%d)\n", ret); | ||
1235 | |||
1236 | return ret; | ||
1237 | } | ||
1238 | |||
1239 | static int sta350_i2c_remove(struct i2c_client *client) | ||
1240 | { | ||
1241 | snd_soc_unregister_codec(&client->dev); | ||
1242 | return 0; | ||
1243 | } | ||
1244 | |||
1245 | static const struct i2c_device_id sta350_i2c_id[] = { | ||
1246 | { "sta350", 0 }, | ||
1247 | { } | ||
1248 | }; | ||
1249 | MODULE_DEVICE_TABLE(i2c, sta350_i2c_id); | ||
1250 | |||
1251 | static struct i2c_driver sta350_i2c_driver = { | ||
1252 | .driver = { | ||
1253 | .name = "sta350", | ||
1254 | .owner = THIS_MODULE, | ||
1255 | .of_match_table = of_match_ptr(st350_dt_ids), | ||
1256 | }, | ||
1257 | .probe = sta350_i2c_probe, | ||
1258 | .remove = sta350_i2c_remove, | ||
1259 | .id_table = sta350_i2c_id, | ||
1260 | }; | ||
1261 | |||
1262 | module_i2c_driver(sta350_i2c_driver); | ||
1263 | |||
1264 | MODULE_DESCRIPTION("ASoC STA350 driver"); | ||
1265 | MODULE_AUTHOR("Sven Brandau <info@brandau.biz>"); | ||
1266 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/sta350.h b/sound/soc/codecs/sta350.h new file mode 100644 index 000000000000..c3248f0fad2c --- /dev/null +++ b/sound/soc/codecs/sta350.h | |||
@@ -0,0 +1,228 @@ | |||
1 | /* | ||
2 | * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system | ||
3 | * | ||
4 | * Copyright: 2011 Raumfeld GmbH | ||
5 | * Author: Sven Brandau <info@brandau.biz> | ||
6 | * | ||
7 | * based on code from: | ||
8 | * Raumfeld GmbH | ||
9 | * Johannes Stezenbach <js@sig21.net> | ||
10 | * Wolfson Microelectronics PLC. | ||
11 | * Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify it | ||
14 | * under the terms of the GNU General Public License as published by the | ||
15 | * Free Software Foundation; either version 2 of the License, or (at your | ||
16 | * option) any later version. | ||
17 | */ | ||
18 | #ifndef _ASOC_STA_350_H | ||
19 | #define _ASOC_STA_350_H | ||
20 | |||
21 | /* STA50 register addresses */ | ||
22 | |||
23 | #define STA350_REGISTER_COUNT 0x4D | ||
24 | #define STA350_COEF_COUNT 62 | ||
25 | |||
26 | #define STA350_CONFA 0x00 | ||
27 | #define STA350_CONFB 0x01 | ||
28 | #define STA350_CONFC 0x02 | ||
29 | #define STA350_CONFD 0x03 | ||
30 | #define STA350_CONFE 0x04 | ||
31 | #define STA350_CONFF 0x05 | ||
32 | #define STA350_MMUTE 0x06 | ||
33 | #define STA350_MVOL 0x07 | ||
34 | #define STA350_C1VOL 0x08 | ||
35 | #define STA350_C2VOL 0x09 | ||
36 | #define STA350_C3VOL 0x0a | ||
37 | #define STA350_AUTO1 0x0b | ||
38 | #define STA350_AUTO2 0x0c | ||
39 | #define STA350_AUTO3 0x0d | ||
40 | #define STA350_C1CFG 0x0e | ||
41 | #define STA350_C2CFG 0x0f | ||
42 | #define STA350_C3CFG 0x10 | ||
43 | #define STA350_TONE 0x11 | ||
44 | #define STA350_L1AR 0x12 | ||
45 | #define STA350_L1ATRT 0x13 | ||
46 | #define STA350_L2AR 0x14 | ||
47 | #define STA350_L2ATRT 0x15 | ||
48 | #define STA350_CFADDR2 0x16 | ||
49 | #define STA350_B1CF1 0x17 | ||
50 | #define STA350_B1CF2 0x18 | ||
51 | #define STA350_B1CF3 0x19 | ||
52 | #define STA350_B2CF1 0x1a | ||
53 | #define STA350_B2CF2 0x1b | ||
54 | #define STA350_B2CF3 0x1c | ||
55 | #define STA350_A1CF1 0x1d | ||
56 | #define STA350_A1CF2 0x1e | ||
57 | #define STA350_A1CF3 0x1f | ||
58 | #define STA350_A2CF1 0x20 | ||
59 | #define STA350_A2CF2 0x21 | ||
60 | #define STA350_A2CF3 0x22 | ||
61 | #define STA350_B0CF1 0x23 | ||
62 | #define STA350_B0CF2 0x24 | ||
63 | #define STA350_B0CF3 0x25 | ||
64 | #define STA350_CFUD 0x26 | ||
65 | #define STA350_MPCC1 0x27 | ||
66 | #define STA350_MPCC2 0x28 | ||
67 | #define STA350_DCC1 0x29 | ||
68 | #define STA350_DCC2 0x2a | ||
69 | #define STA350_FDRC1 0x2b | ||
70 | #define STA350_FDRC2 0x2c | ||
71 | #define STA350_STATUS 0x2d | ||
72 | /* reserved: 0x2d - 0x30 */ | ||
73 | #define STA350_EQCFG 0x31 | ||
74 | #define STA350_EATH1 0x32 | ||
75 | #define STA350_ERTH1 0x33 | ||
76 | #define STA350_EATH2 0x34 | ||
77 | #define STA350_ERTH2 0x35 | ||
78 | #define STA350_CONFX 0x36 | ||
79 | #define STA350_SVCA 0x37 | ||
80 | #define STA350_SVCB 0x38 | ||
81 | #define STA350_RMS0A 0x39 | ||
82 | #define STA350_RMS0B 0x3a | ||
83 | #define STA350_RMS0C 0x3b | ||
84 | #define STA350_RMS1A 0x3c | ||
85 | #define STA350_RMS1B 0x3d | ||
86 | #define STA350_RMS1C 0x3e | ||
87 | #define STA350_EVOLRES 0x3f | ||
88 | /* reserved: 0x40 - 0x47 */ | ||
89 | #define STA350_NSHAPE 0x48 | ||
90 | #define STA350_CTXB4B1 0x49 | ||
91 | #define STA350_CTXB7B5 0x4a | ||
92 | #define STA350_MISC1 0x4b | ||
93 | #define STA350_MISC2 0x4c | ||
94 | |||
95 | /* 0x00 CONFA */ | ||
96 | #define STA350_CONFA_MCS_MASK 0x03 | ||
97 | #define STA350_CONFA_MCS_SHIFT 0 | ||
98 | #define STA350_CONFA_IR_MASK 0x18 | ||
99 | #define STA350_CONFA_IR_SHIFT 3 | ||
100 | #define STA350_CONFA_TWRB BIT(5) | ||
101 | #define STA350_CONFA_TWAB BIT(6) | ||
102 | #define STA350_CONFA_FDRB BIT(7) | ||
103 | |||
104 | /* 0x01 CONFB */ | ||
105 | #define STA350_CONFB_SAI_MASK 0x0f | ||
106 | #define STA350_CONFB_SAI_SHIFT 0 | ||
107 | #define STA350_CONFB_SAIFB BIT(4) | ||
108 | #define STA350_CONFB_DSCKE BIT(5) | ||
109 | #define STA350_CONFB_C1IM BIT(6) | ||
110 | #define STA350_CONFB_C2IM BIT(7) | ||
111 | |||
112 | /* 0x02 CONFC */ | ||
113 | #define STA350_CONFC_OM_MASK 0x03 | ||
114 | #define STA350_CONFC_OM_SHIFT 0 | ||
115 | #define STA350_CONFC_CSZ_MASK 0x3c | ||
116 | #define STA350_CONFC_CSZ_SHIFT 2 | ||
117 | #define STA350_CONFC_OCRB BIT(7) | ||
118 | |||
119 | /* 0x03 CONFD */ | ||
120 | #define STA350_CONFD_HPB_SHIFT 0 | ||
121 | #define STA350_CONFD_DEMP_SHIFT 1 | ||
122 | #define STA350_CONFD_DSPB_SHIFT 2 | ||
123 | #define STA350_CONFD_PSL_SHIFT 3 | ||
124 | #define STA350_CONFD_BQL_SHIFT 4 | ||
125 | #define STA350_CONFD_DRC_SHIFT 5 | ||
126 | #define STA350_CONFD_ZDE_SHIFT 6 | ||
127 | #define STA350_CONFD_SME_SHIFT 7 | ||
128 | |||
129 | /* 0x04 CONFE */ | ||
130 | #define STA350_CONFE_MPCV BIT(0) | ||
131 | #define STA350_CONFE_MPCV_SHIFT 0 | ||
132 | #define STA350_CONFE_MPC BIT(1) | ||
133 | #define STA350_CONFE_MPC_SHIFT 1 | ||
134 | #define STA350_CONFE_NSBW BIT(2) | ||
135 | #define STA350_CONFE_NSBW_SHIFT 2 | ||
136 | #define STA350_CONFE_AME BIT(3) | ||
137 | #define STA350_CONFE_AME_SHIFT 3 | ||
138 | #define STA350_CONFE_PWMS BIT(4) | ||
139 | #define STA350_CONFE_PWMS_SHIFT 4 | ||
140 | #define STA350_CONFE_DCCV BIT(5) | ||
141 | #define STA350_CONFE_DCCV_SHIFT 5 | ||
142 | #define STA350_CONFE_ZCE BIT(6) | ||
143 | #define STA350_CONFE_ZCE_SHIFT 6 | ||
144 | #define STA350_CONFE_SVE BIT(7) | ||
145 | #define STA350_CONFE_SVE_SHIFT 7 | ||
146 | |||
147 | /* 0x05 CONFF */ | ||
148 | #define STA350_CONFF_OCFG_MASK 0x03 | ||
149 | #define STA350_CONFF_OCFG_SHIFT 0 | ||
150 | #define STA350_CONFF_IDE BIT(2) | ||
151 | #define STA350_CONFF_BCLE BIT(3) | ||
152 | #define STA350_CONFF_LDTE BIT(4) | ||
153 | #define STA350_CONFF_ECLE BIT(5) | ||
154 | #define STA350_CONFF_PWDN BIT(6) | ||
155 | #define STA350_CONFF_EAPD BIT(7) | ||
156 | |||
157 | /* 0x06 MMUTE */ | ||
158 | #define STA350_MMUTE_MMUTE 0x01 | ||
159 | #define STA350_MMUTE_MMUTE_SHIFT 0 | ||
160 | #define STA350_MMUTE_C1M 0x02 | ||
161 | #define STA350_MMUTE_C1M_SHIFT 1 | ||
162 | #define STA350_MMUTE_C2M 0x04 | ||
163 | #define STA350_MMUTE_C2M_SHIFT 2 | ||
164 | #define STA350_MMUTE_C3M 0x08 | ||
165 | #define STA350_MMUTE_C3M_SHIFT 3 | ||
166 | #define STA350_MMUTE_LOC_MASK 0xC0 | ||
167 | #define STA350_MMUTE_LOC_SHIFT 6 | ||
168 | |||
169 | /* 0x0b AUTO1 */ | ||
170 | #define STA350_AUTO1_AMGC_MASK 0x30 | ||
171 | #define STA350_AUTO1_AMGC_SHIFT 4 | ||
172 | |||
173 | /* 0x0c AUTO2 */ | ||
174 | #define STA350_AUTO2_AMAME 0x01 | ||
175 | #define STA350_AUTO2_AMAM_MASK 0x0e | ||
176 | #define STA350_AUTO2_AMAM_SHIFT 1 | ||
177 | #define STA350_AUTO2_XO_MASK 0xf0 | ||
178 | #define STA350_AUTO2_XO_SHIFT 4 | ||
179 | |||
180 | /* 0x0d AUTO3 */ | ||
181 | #define STA350_AUTO3_PEQ_MASK 0x1f | ||
182 | #define STA350_AUTO3_PEQ_SHIFT 0 | ||
183 | |||
184 | /* 0x0e 0x0f 0x10 CxCFG */ | ||
185 | #define STA350_CxCFG_TCB_SHIFT 0 | ||
186 | #define STA350_CxCFG_EQBP_SHIFT 1 | ||
187 | #define STA350_CxCFG_VBP_SHIFT 2 | ||
188 | #define STA350_CxCFG_BO_SHIFT 3 | ||
189 | #define STA350_CxCFG_LS_SHIFT 4 | ||
190 | #define STA350_CxCFG_OM_MASK 0xc0 | ||
191 | #define STA350_CxCFG_OM_SHIFT 6 | ||
192 | |||
193 | /* 0x11 TONE */ | ||
194 | #define STA350_TONE_BTC_SHIFT 0 | ||
195 | #define STA350_TONE_TTC_SHIFT 4 | ||
196 | |||
197 | /* 0x12 0x13 0x14 0x15 limiter attack/release */ | ||
198 | #define STA350_LxA_SHIFT 0 | ||
199 | #define STA350_LxR_SHIFT 4 | ||
200 | |||
201 | /* 0x26 CFUD */ | ||
202 | #define STA350_CFUD_W1 0x01 | ||
203 | #define STA350_CFUD_WA 0x02 | ||
204 | #define STA350_CFUD_R1 0x04 | ||
205 | #define STA350_CFUD_RA 0x08 | ||
206 | |||
207 | |||
208 | /* biquad filter coefficient table offsets */ | ||
209 | #define STA350_C1_BQ_BASE 0 | ||
210 | #define STA350_C2_BQ_BASE 20 | ||
211 | #define STA350_CH_BQ_NUM 4 | ||
212 | #define STA350_BQ_NUM_COEF 5 | ||
213 | #define STA350_XO_HP_BQ_BASE 40 | ||
214 | #define STA350_XO_LP_BQ_BASE 45 | ||
215 | #define STA350_C1_PRESCALE 50 | ||
216 | #define STA350_C2_PRESCALE 51 | ||
217 | #define STA350_C1_POSTSCALE 52 | ||
218 | #define STA350_C2_POSTSCALE 53 | ||
219 | #define STA350_C3_POSTSCALE 54 | ||
220 | #define STA350_TW_POSTSCALE 55 | ||
221 | #define STA350_C1_MIX1 56 | ||
222 | #define STA350_C1_MIX2 57 | ||
223 | #define STA350_C2_MIX1 58 | ||
224 | #define STA350_C2_MIX2 59 | ||
225 | #define STA350_C3_MIX1 60 | ||
226 | #define STA350_C3_MIX2 61 | ||
227 | |||
228 | #endif /* _ASOC_STA_350_H */ | ||
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index a895a5e4bdf2..d48491a4a19d 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c | |||
@@ -272,7 +272,7 @@ static int tas5086_set_deemph(struct snd_soc_codec *codec) | |||
272 | static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, | 272 | static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, |
273 | struct snd_ctl_elem_value *ucontrol) | 273 | struct snd_ctl_elem_value *ucontrol) |
274 | { | 274 | { |
275 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 275 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
276 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 276 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); |
277 | 277 | ||
278 | ucontrol->value.enumerated.item[0] = priv->deemph; | 278 | ucontrol->value.enumerated.item[0] = priv->deemph; |
@@ -283,7 +283,7 @@ static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, | |||
283 | static int tas5086_put_deemph(struct snd_kcontrol *kcontrol, | 283 | static int tas5086_put_deemph(struct snd_kcontrol *kcontrol, |
284 | struct snd_ctl_elem_value *ucontrol) | 284 | struct snd_ctl_elem_value *ucontrol) |
285 | { | 285 | { |
286 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 286 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
287 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 287 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); |
288 | 288 | ||
289 | priv->deemph = ucontrol->value.enumerated.item[0]; | 289 | priv->deemph = ucontrol->value.enumerated.item[0]; |
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 20864ee8793b..686b8b85b956 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c | |||
@@ -82,7 +82,7 @@ static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0); | |||
82 | static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, | 82 | static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, |
83 | struct snd_ctl_elem_value *ucontrol) | 83 | struct snd_ctl_elem_value *ucontrol) |
84 | { | 84 | { |
85 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 85 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
86 | u16 val, reg; | 86 | u16 val, reg; |
87 | 87 | ||
88 | val = (ucontrol->value.integer.value[0] & 0x07); | 88 | val = (ucontrol->value.integer.value[0] & 0x07); |
@@ -105,7 +105,7 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, | |||
105 | static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, | 105 | static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, |
106 | struct snd_ctl_elem_value *ucontrol) | 106 | struct snd_ctl_elem_value *ucontrol) |
107 | { | 107 | { |
108 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 108 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
109 | u16 val; | 109 | u16 val; |
110 | 110 | ||
111 | val = snd_soc_read(codec, TLV320AIC23_ANLG) & (0x1C0); | 111 | val = snd_soc_read(codec, TLV320AIC23_ANLG) & (0x1C0); |
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 6bfc8a17331b..517055ab65ef 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c | |||
@@ -442,7 +442,7 @@ static int dac33_playback_event(struct snd_soc_dapm_widget *w, | |||
442 | static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, | 442 | static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, |
443 | struct snd_ctl_elem_value *ucontrol) | 443 | struct snd_ctl_elem_value *ucontrol) |
444 | { | 444 | { |
445 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 445 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
446 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 446 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
447 | 447 | ||
448 | ucontrol->value.integer.value[0] = dac33->fifo_mode; | 448 | ucontrol->value.integer.value[0] = dac33->fifo_mode; |
@@ -453,7 +453,7 @@ static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, | |||
453 | static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol, | 453 | static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol, |
454 | struct snd_ctl_elem_value *ucontrol) | 454 | struct snd_ctl_elem_value *ucontrol) |
455 | { | 455 | { |
456 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 456 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
457 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 457 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
458 | int ret = 0; | 458 | int ret = 0; |
459 | 459 | ||
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 975e0f760ac1..69e12a311ba2 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -830,7 +830,7 @@ static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol, | |||
830 | { | 830 | { |
831 | struct soc_mixer_control *mc = | 831 | struct soc_mixer_control *mc = |
832 | (struct soc_mixer_control *)kcontrol->private_value; | 832 | (struct soc_mixer_control *)kcontrol->private_value; |
833 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 833 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
834 | unsigned int reg = mc->reg; | 834 | unsigned int reg = mc->reg; |
835 | unsigned int shift = mc->shift; | 835 | unsigned int shift = mc->shift; |
836 | unsigned int rshift = mc->rshift; | 836 | unsigned int rshift = mc->rshift; |
@@ -859,7 +859,7 @@ static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol, | |||
859 | { | 859 | { |
860 | struct soc_mixer_control *mc = | 860 | struct soc_mixer_control *mc = |
861 | (struct soc_mixer_control *)kcontrol->private_value; | 861 | (struct soc_mixer_control *)kcontrol->private_value; |
862 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 862 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
863 | unsigned int reg = mc->reg; | 863 | unsigned int reg = mc->reg; |
864 | unsigned int shift = mc->shift; | 864 | unsigned int shift = mc->shift; |
865 | unsigned int rshift = mc->rshift; | 865 | unsigned int rshift = mc->rshift; |
@@ -888,7 +888,7 @@ static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, | |||
888 | { | 888 | { |
889 | struct soc_mixer_control *mc = | 889 | struct soc_mixer_control *mc = |
890 | (struct soc_mixer_control *)kcontrol->private_value; | 890 | (struct soc_mixer_control *)kcontrol->private_value; |
891 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 891 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
892 | unsigned int reg = mc->reg; | 892 | unsigned int reg = mc->reg; |
893 | unsigned int reg2 = mc->rreg; | 893 | unsigned int reg2 = mc->rreg; |
894 | unsigned int shift = mc->shift; | 894 | unsigned int shift = mc->shift; |
@@ -915,7 +915,7 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, | |||
915 | { | 915 | { |
916 | struct soc_mixer_control *mc = | 916 | struct soc_mixer_control *mc = |
917 | (struct soc_mixer_control *)kcontrol->private_value; | 917 | (struct soc_mixer_control *)kcontrol->private_value; |
918 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 918 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
919 | unsigned int reg = mc->reg; | 919 | unsigned int reg = mc->reg; |
920 | unsigned int reg2 = mc->rreg; | 920 | unsigned int reg2 = mc->rreg; |
921 | unsigned int shift = mc->shift; | 921 | unsigned int shift = mc->shift; |
@@ -956,7 +956,7 @@ static SOC_ENUM_SINGLE_DECL(twl4030_op_modes_enum, | |||
956 | static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, | 956 | static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, |
957 | struct snd_ctl_elem_value *ucontrol) | 957 | struct snd_ctl_elem_value *ucontrol) |
958 | { | 958 | { |
959 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 959 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
960 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); | 960 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); |
961 | 961 | ||
962 | if (twl4030->configured) { | 962 | if (twl4030->configured) { |
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index bd3a20647fdf..0f6067f04e29 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c | |||
@@ -484,7 +484,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(twl6040_power_mode_enum, | |||
484 | static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, | 484 | static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, |
485 | struct snd_ctl_elem_value *ucontrol) | 485 | struct snd_ctl_elem_value *ucontrol) |
486 | { | 486 | { |
487 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 487 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
488 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | 488 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |
489 | 489 | ||
490 | ucontrol->value.enumerated.item[0] = priv->hs_power_mode; | 490 | ucontrol->value.enumerated.item[0] = priv->hs_power_mode; |
@@ -495,7 +495,7 @@ static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, | |||
495 | static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, | 495 | static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, |
496 | struct snd_ctl_elem_value *ucontrol) | 496 | struct snd_ctl_elem_value *ucontrol) |
497 | { | 497 | { |
498 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 498 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
499 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | 499 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |
500 | int high_perf = ucontrol->value.enumerated.item[0]; | 500 | int high_perf = ucontrol->value.enumerated.item[0]; |
501 | int ret = 0; | 501 | int ret = 0; |
@@ -512,7 +512,7 @@ static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, | |||
512 | static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, | 512 | static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, |
513 | struct snd_ctl_elem_value *ucontrol) | 513 | struct snd_ctl_elem_value *ucontrol) |
514 | { | 514 | { |
515 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 515 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
516 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | 516 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |
517 | 517 | ||
518 | ucontrol->value.enumerated.item[0] = priv->pll_power_mode; | 518 | ucontrol->value.enumerated.item[0] = priv->pll_power_mode; |
@@ -523,7 +523,7 @@ static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, | |||
523 | static int twl6040_pll_put_enum(struct snd_kcontrol *kcontrol, | 523 | static int twl6040_pll_put_enum(struct snd_kcontrol *kcontrol, |
524 | struct snd_ctl_elem_value *ucontrol) | 524 | struct snd_ctl_elem_value *ucontrol) |
525 | { | 525 | { |
526 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 526 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
527 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | 527 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |
528 | 528 | ||
529 | priv->pll_power_mode = ucontrol->value.enumerated.item[0]; | 529 | priv->pll_power_mode = ucontrol->value.enumerated.item[0]; |
diff --git a/sound/soc/codecs/wl1273.c b/sound/soc/codecs/wl1273.c index 6be5f80b65f1..4ead0dc02b87 100644 --- a/sound/soc/codecs/wl1273.c +++ b/sound/soc/codecs/wl1273.c | |||
@@ -172,7 +172,7 @@ out: | |||
172 | static int snd_wl1273_get_audio_route(struct snd_kcontrol *kcontrol, | 172 | static int snd_wl1273_get_audio_route(struct snd_kcontrol *kcontrol, |
173 | struct snd_ctl_elem_value *ucontrol) | 173 | struct snd_ctl_elem_value *ucontrol) |
174 | { | 174 | { |
175 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 175 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
176 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); | 176 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); |
177 | 177 | ||
178 | ucontrol->value.integer.value[0] = wl1273->mode; | 178 | ucontrol->value.integer.value[0] = wl1273->mode; |
@@ -190,7 +190,7 @@ static const char * const wl1273_audio_route[] = { "Bt", "FmRx", "FmTx" }; | |||
190 | static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol, | 190 | static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol, |
191 | struct snd_ctl_elem_value *ucontrol) | 191 | struct snd_ctl_elem_value *ucontrol) |
192 | { | 192 | { |
193 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 193 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
194 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); | 194 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); |
195 | 195 | ||
196 | if (wl1273->mode == ucontrol->value.integer.value[0]) | 196 | if (wl1273->mode == ucontrol->value.integer.value[0]) |
@@ -214,7 +214,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(wl1273_enum, wl1273_audio_route); | |||
214 | static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol, | 214 | static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol, |
215 | struct snd_ctl_elem_value *ucontrol) | 215 | struct snd_ctl_elem_value *ucontrol) |
216 | { | 216 | { |
217 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 217 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
218 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); | 218 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); |
219 | 219 | ||
220 | dev_dbg(codec->dev, "%s: enter.\n", __func__); | 220 | dev_dbg(codec->dev, "%s: enter.\n", __func__); |
@@ -227,7 +227,7 @@ static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol, | |||
227 | static int snd_wl1273_fm_audio_put(struct snd_kcontrol *kcontrol, | 227 | static int snd_wl1273_fm_audio_put(struct snd_kcontrol *kcontrol, |
228 | struct snd_ctl_elem_value *ucontrol) | 228 | struct snd_ctl_elem_value *ucontrol) |
229 | { | 229 | { |
230 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 230 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
231 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); | 231 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); |
232 | int val, r = 0; | 232 | int val, r = 0; |
233 | 233 | ||
@@ -251,7 +251,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(wl1273_audio_enum, wl1273_audio_strings); | |||
251 | static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol, | 251 | static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol, |
252 | struct snd_ctl_elem_value *ucontrol) | 252 | struct snd_ctl_elem_value *ucontrol) |
253 | { | 253 | { |
254 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 254 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
255 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); | 255 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); |
256 | 256 | ||
257 | dev_dbg(codec->dev, "%s: enter.\n", __func__); | 257 | dev_dbg(codec->dev, "%s: enter.\n", __func__); |
@@ -264,7 +264,7 @@ static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol, | |||
264 | static int snd_wl1273_fm_volume_put(struct snd_kcontrol *kcontrol, | 264 | static int snd_wl1273_fm_volume_put(struct snd_kcontrol *kcontrol, |
265 | struct snd_ctl_elem_value *ucontrol) | 265 | struct snd_ctl_elem_value *ucontrol) |
266 | { | 266 | { |
267 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 267 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
268 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); | 268 | struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); |
269 | int r; | 269 | int r; |
270 | 270 | ||
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 83a2c872925c..a4c352cc3464 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c | |||
@@ -607,7 +607,7 @@ static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) | |||
607 | static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, | 607 | static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, |
608 | struct snd_ctl_elem_value *ucontrol) | 608 | struct snd_ctl_elem_value *ucontrol) |
609 | { | 609 | { |
610 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 610 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
611 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); | 611 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); |
612 | 612 | ||
613 | ucontrol->value.enumerated.item[0] = wm2000->anc_active; | 613 | ucontrol->value.enumerated.item[0] = wm2000->anc_active; |
@@ -618,7 +618,7 @@ static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, | |||
618 | static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, | 618 | static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, |
619 | struct snd_ctl_elem_value *ucontrol) | 619 | struct snd_ctl_elem_value *ucontrol) |
620 | { | 620 | { |
621 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 621 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
622 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); | 622 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); |
623 | int anc_active = ucontrol->value.enumerated.item[0]; | 623 | int anc_active = ucontrol->value.enumerated.item[0]; |
624 | int ret; | 624 | int ret; |
@@ -640,7 +640,7 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, | |||
640 | static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, | 640 | static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, |
641 | struct snd_ctl_elem_value *ucontrol) | 641 | struct snd_ctl_elem_value *ucontrol) |
642 | { | 642 | { |
643 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 643 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
644 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); | 644 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); |
645 | 645 | ||
646 | ucontrol->value.enumerated.item[0] = wm2000->spk_ena; | 646 | ucontrol->value.enumerated.item[0] = wm2000->spk_ena; |
@@ -651,7 +651,7 @@ static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, | |||
651 | static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, | 651 | static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, |
652 | struct snd_ctl_elem_value *ucontrol) | 652 | struct snd_ctl_elem_value *ucontrol) |
653 | { | 653 | { |
654 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 654 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
655 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); | 655 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); |
656 | int val = ucontrol->value.enumerated.item[0]; | 656 | int val = ucontrol->value.enumerated.item[0]; |
657 | int ret; | 657 | int ret; |
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index dcf1d12cfef8..7a046536ea68 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c | |||
@@ -1760,10 +1760,6 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec) | |||
1760 | struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); | 1760 | struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); |
1761 | int ret; | 1761 | int ret; |
1762 | 1762 | ||
1763 | ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); | ||
1764 | if (ret != 0) | ||
1765 | return ret; | ||
1766 | |||
1767 | ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 2); | 1763 | ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 2); |
1768 | if (ret != 0) | 1764 | if (ret != 0) |
1769 | return ret; | 1765 | return ret; |
@@ -1802,9 +1798,17 @@ static unsigned int wm5102_digital_vu[] = { | |||
1802 | ARIZONA_DAC_DIGITAL_VOLUME_5R, | 1798 | ARIZONA_DAC_DIGITAL_VOLUME_5R, |
1803 | }; | 1799 | }; |
1804 | 1800 | ||
1801 | static struct regmap *wm5102_get_regmap(struct device *dev) | ||
1802 | { | ||
1803 | struct wm5102_priv *priv = dev_get_drvdata(dev); | ||
1804 | |||
1805 | return priv->core.arizona->regmap; | ||
1806 | } | ||
1807 | |||
1805 | static struct snd_soc_codec_driver soc_codec_dev_wm5102 = { | 1808 | static struct snd_soc_codec_driver soc_codec_dev_wm5102 = { |
1806 | .probe = wm5102_codec_probe, | 1809 | .probe = wm5102_codec_probe, |
1807 | .remove = wm5102_codec_remove, | 1810 | .remove = wm5102_codec_remove, |
1811 | .get_regmap = wm5102_get_regmap, | ||
1808 | 1812 | ||
1809 | .idle_bias_off = true, | 1813 | .idle_bias_off = true, |
1810 | 1814 | ||
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index df5a38dd8328..97eb1bc5bea7 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c | |||
@@ -1589,10 +1589,6 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec) | |||
1589 | 1589 | ||
1590 | priv->core.arizona->dapm = &codec->dapm; | 1590 | priv->core.arizona->dapm = &codec->dapm; |
1591 | 1591 | ||
1592 | ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); | ||
1593 | if (ret != 0) | ||
1594 | return ret; | ||
1595 | |||
1596 | arizona_init_spk(codec); | 1592 | arizona_init_spk(codec); |
1597 | arizona_init_gpio(codec); | 1593 | arizona_init_gpio(codec); |
1598 | 1594 | ||
@@ -1633,9 +1629,17 @@ static unsigned int wm5110_digital_vu[] = { | |||
1633 | ARIZONA_DAC_DIGITAL_VOLUME_6R, | 1629 | ARIZONA_DAC_DIGITAL_VOLUME_6R, |
1634 | }; | 1630 | }; |
1635 | 1631 | ||
1632 | static struct regmap *wm5110_get_regmap(struct device *dev) | ||
1633 | { | ||
1634 | struct wm5110_priv *priv = dev_get_drvdata(dev); | ||
1635 | |||
1636 | return priv->core.arizona->regmap; | ||
1637 | } | ||
1638 | |||
1636 | static struct snd_soc_codec_driver soc_codec_dev_wm5110 = { | 1639 | static struct snd_soc_codec_driver soc_codec_dev_wm5110 = { |
1637 | .probe = wm5110_codec_probe, | 1640 | .probe = wm5110_codec_probe, |
1638 | .remove = wm5110_codec_remove, | 1641 | .remove = wm5110_codec_remove, |
1642 | .get_regmap = wm5110_get_regmap, | ||
1639 | 1643 | ||
1640 | .idle_bias_off = true, | 1644 | .idle_bias_off = true, |
1641 | 1645 | ||
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 757256bf7672..392285edb595 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c | |||
@@ -302,7 +302,7 @@ static int pga_event(struct snd_soc_dapm_widget *w, | |||
302 | static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, | 302 | static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, |
303 | struct snd_ctl_elem_value *ucontrol) | 303 | struct snd_ctl_elem_value *ucontrol) |
304 | { | 304 | { |
305 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 305 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
306 | struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); | 306 | struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); |
307 | struct wm8350_output *out = NULL; | 307 | struct wm8350_output *out = NULL; |
308 | struct soc_mixer_control *mc = | 308 | struct soc_mixer_control *mc = |
@@ -345,7 +345,7 @@ static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, | |||
345 | static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol, | 345 | static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol, |
346 | struct snd_ctl_elem_value *ucontrol) | 346 | struct snd_ctl_elem_value *ucontrol) |
347 | { | 347 | { |
348 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 348 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
349 | struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); | 349 | struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); |
350 | struct wm8350_output *out1 = &wm8350_priv->out1; | 350 | struct wm8350_output *out1 = &wm8350_priv->out1; |
351 | struct wm8350_output *out2 = &wm8350_priv->out2; | 351 | struct wm8350_output *out2 = &wm8350_priv->out2; |
@@ -1505,8 +1505,6 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) | |||
1505 | if (ret != 0) | 1505 | if (ret != 0) |
1506 | return ret; | 1506 | return ret; |
1507 | 1507 | ||
1508 | snd_soc_codec_set_cache_io(codec, wm8350->regmap); | ||
1509 | |||
1510 | /* Put the codec into reset if it wasn't already */ | 1508 | /* Put the codec into reset if it wasn't already */ |
1511 | wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); | 1509 | wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); |
1512 | 1510 | ||
@@ -1608,11 +1606,19 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec) | |||
1608 | return 0; | 1606 | return 0; |
1609 | } | 1607 | } |
1610 | 1608 | ||
1609 | static struct regmap *wm8350_get_regmap(struct device *dev) | ||
1610 | { | ||
1611 | struct wm8350 *wm8350 = dev_get_platdata(dev); | ||
1612 | |||
1613 | return wm8350->regmap; | ||
1614 | } | ||
1615 | |||
1611 | static struct snd_soc_codec_driver soc_codec_dev_wm8350 = { | 1616 | static struct snd_soc_codec_driver soc_codec_dev_wm8350 = { |
1612 | .probe = wm8350_codec_probe, | 1617 | .probe = wm8350_codec_probe, |
1613 | .remove = wm8350_codec_remove, | 1618 | .remove = wm8350_codec_remove, |
1614 | .suspend = wm8350_suspend, | 1619 | .suspend = wm8350_suspend, |
1615 | .resume = wm8350_resume, | 1620 | .resume = wm8350_resume, |
1621 | .get_regmap = wm8350_get_regmap, | ||
1616 | .set_bias_level = wm8350_set_bias_level, | 1622 | .set_bias_level = wm8350_set_bias_level, |
1617 | 1623 | ||
1618 | .controls = wm8350_snd_controls, | 1624 | .controls = wm8350_snd_controls, |
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 146564feaea0..06e913d3fea1 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c | |||
@@ -93,7 +93,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); | |||
93 | static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, | 93 | static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, |
94 | struct snd_ctl_elem_value *ucontrol) | 94 | struct snd_ctl_elem_value *ucontrol) |
95 | { | 95 | { |
96 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 96 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
97 | struct soc_mixer_control *mc = | 97 | struct soc_mixer_control *mc = |
98 | (struct soc_mixer_control *)kcontrol->private_value; | 98 | (struct soc_mixer_control *)kcontrol->private_value; |
99 | int reg = mc->reg; | 99 | int reg = mc->reg; |
@@ -1318,8 +1318,6 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) | |||
1318 | priv->wm8400 = wm8400; | 1318 | priv->wm8400 = wm8400; |
1319 | priv->codec = codec; | 1319 | priv->codec = codec; |
1320 | 1320 | ||
1321 | snd_soc_codec_set_cache_io(codec, wm8400->regmap); | ||
1322 | |||
1323 | ret = devm_regulator_bulk_get(wm8400->dev, | 1321 | ret = devm_regulator_bulk_get(wm8400->dev, |
1324 | ARRAY_SIZE(power), &power[0]); | 1322 | ARRAY_SIZE(power), &power[0]); |
1325 | if (ret != 0) { | 1323 | if (ret != 0) { |
@@ -1361,11 +1359,19 @@ static int wm8400_codec_remove(struct snd_soc_codec *codec) | |||
1361 | return 0; | 1359 | return 0; |
1362 | } | 1360 | } |
1363 | 1361 | ||
1362 | static struct regmap *wm8400_get_regmap(struct device *dev) | ||
1363 | { | ||
1364 | struct wm8400 *wm8400 = dev_get_platdata(dev); | ||
1365 | |||
1366 | return wm8400->regmap; | ||
1367 | } | ||
1368 | |||
1364 | static struct snd_soc_codec_driver soc_codec_dev_wm8400 = { | 1369 | static struct snd_soc_codec_driver soc_codec_dev_wm8400 = { |
1365 | .probe = wm8400_codec_probe, | 1370 | .probe = wm8400_codec_probe, |
1366 | .remove = wm8400_codec_remove, | 1371 | .remove = wm8400_codec_remove, |
1367 | .suspend = wm8400_suspend, | 1372 | .suspend = wm8400_suspend, |
1368 | .resume = wm8400_resume, | 1373 | .resume = wm8400_resume, |
1374 | .get_regmap = wm8400_get_regmap, | ||
1369 | .set_bias_level = wm8400_set_bias_level, | 1375 | .set_bias_level = wm8400_set_bias_level, |
1370 | 1376 | ||
1371 | .controls = wm8400_snd_controls, | 1377 | .controls = wm8400_snd_controls, |
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index af7ed8b5d4e1..7665ff6aea6d 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c | |||
@@ -252,7 +252,7 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol, | |||
252 | { | 252 | { |
253 | struct soc_mixer_control *mc = | 253 | struct soc_mixer_control *mc = |
254 | (struct soc_mixer_control *)kcontrol->private_value; | 254 | (struct soc_mixer_control *)kcontrol->private_value; |
255 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 255 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
256 | struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); | 256 | struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); |
257 | unsigned int reg = mc->reg; | 257 | unsigned int reg = mc->reg; |
258 | unsigned int reg2 = mc->rreg; | 258 | unsigned int reg2 = mc->rreg; |
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index d74f43975b90..763b265d9528 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -119,7 +119,7 @@ static int wm8731_set_deemph(struct snd_soc_codec *codec) | |||
119 | static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, | 119 | static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, |
120 | struct snd_ctl_elem_value *ucontrol) | 120 | struct snd_ctl_elem_value *ucontrol) |
121 | { | 121 | { |
122 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 122 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
123 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); | 123 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); |
124 | 124 | ||
125 | ucontrol->value.enumerated.item[0] = wm8731->deemph; | 125 | ucontrol->value.enumerated.item[0] = wm8731->deemph; |
@@ -130,7 +130,7 @@ static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, | |||
130 | static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, | 130 | static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, |
131 | struct snd_ctl_elem_value *ucontrol) | 131 | struct snd_ctl_elem_value *ucontrol) |
132 | { | 132 | { |
133 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 133 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
134 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); | 134 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); |
135 | int deemph = ucontrol->value.enumerated.item[0]; | 135 | int deemph = ucontrol->value.enumerated.item[0]; |
136 | int ret = 0; | 136 | int ret = 0; |
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index cbb8d55052a4..53e57b4049a8 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c | |||
@@ -234,7 +234,7 @@ SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase), | |||
234 | static int wm8753_get_dai(struct snd_kcontrol *kcontrol, | 234 | static int wm8753_get_dai(struct snd_kcontrol *kcontrol, |
235 | struct snd_ctl_elem_value *ucontrol) | 235 | struct snd_ctl_elem_value *ucontrol) |
236 | { | 236 | { |
237 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 237 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
238 | struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); | 238 | struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); |
239 | 239 | ||
240 | ucontrol->value.integer.value[0] = wm8753->dai_func; | 240 | ucontrol->value.integer.value[0] = wm8753->dai_func; |
@@ -244,7 +244,7 @@ static int wm8753_get_dai(struct snd_kcontrol *kcontrol, | |||
244 | static int wm8753_set_dai(struct snd_kcontrol *kcontrol, | 244 | static int wm8753_set_dai(struct snd_kcontrol *kcontrol, |
245 | struct snd_ctl_elem_value *ucontrol) | 245 | struct snd_ctl_elem_value *ucontrol) |
246 | { | 246 | { |
247 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 247 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
248 | struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); | 248 | struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); |
249 | u16 ioctl; | 249 | u16 ioctl; |
250 | 250 | ||
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index ee76f0fb4299..589455c3bfcd 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c | |||
@@ -106,7 +106,7 @@ static int txsrc_get(struct snd_kcontrol *kcontrol, | |||
106 | struct snd_soc_codec *codec; | 106 | struct snd_soc_codec *codec; |
107 | unsigned int src; | 107 | unsigned int src; |
108 | 108 | ||
109 | codec = snd_kcontrol_chip(kcontrol); | 109 | codec = snd_soc_kcontrol_codec(kcontrol); |
110 | src = snd_soc_read(codec, WM8804_SPDTX4); | 110 | src = snd_soc_read(codec, WM8804_SPDTX4); |
111 | if (src & 0x40) | 111 | if (src & 0x40) |
112 | ucontrol->value.integer.value[0] = 1; | 112 | ucontrol->value.integer.value[0] = 1; |
@@ -122,7 +122,7 @@ static int txsrc_put(struct snd_kcontrol *kcontrol, | |||
122 | struct snd_soc_codec *codec; | 122 | struct snd_soc_codec *codec; |
123 | unsigned int src, txpwr; | 123 | unsigned int src, txpwr; |
124 | 124 | ||
125 | codec = snd_kcontrol_chip(kcontrol); | 125 | codec = snd_soc_kcontrol_codec(kcontrol); |
126 | 126 | ||
127 | if (ucontrol->value.integer.value[0] != 0 | 127 | if (ucontrol->value.integer.value[0] != 0 |
128 | && ucontrol->value.integer.value[0] != 1) | 128 | && ucontrol->value.integer.value[0] != 1) |
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index b0084a127d18..b84940c359a1 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -439,7 +439,7 @@ static int wm8903_set_deemph(struct snd_soc_codec *codec) | |||
439 | static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, | 439 | static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, |
440 | struct snd_ctl_elem_value *ucontrol) | 440 | struct snd_ctl_elem_value *ucontrol) |
441 | { | 441 | { |
442 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 442 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
443 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); | 443 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); |
444 | 444 | ||
445 | ucontrol->value.enumerated.item[0] = wm8903->deemph; | 445 | ucontrol->value.enumerated.item[0] = wm8903->deemph; |
@@ -450,7 +450,7 @@ static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, | |||
450 | static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, | 450 | static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, |
451 | struct snd_ctl_elem_value *ucontrol) | 451 | struct snd_ctl_elem_value *ucontrol) |
452 | { | 452 | { |
453 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 453 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
454 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); | 454 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); |
455 | int deemph = ucontrol->value.enumerated.item[0]; | 455 | int deemph = ucontrol->value.enumerated.item[0]; |
456 | int ret = 0; | 456 | int ret = 0; |
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 49c35c36935e..f7c549949c54 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c | |||
@@ -391,7 +391,7 @@ static void wm8904_set_drc(struct snd_soc_codec *codec) | |||
391 | static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, | 391 | static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, |
392 | struct snd_ctl_elem_value *ucontrol) | 392 | struct snd_ctl_elem_value *ucontrol) |
393 | { | 393 | { |
394 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 394 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
395 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); | 395 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
396 | struct wm8904_pdata *pdata = wm8904->pdata; | 396 | struct wm8904_pdata *pdata = wm8904->pdata; |
397 | int value = ucontrol->value.integer.value[0]; | 397 | int value = ucontrol->value.integer.value[0]; |
@@ -409,7 +409,7 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, | |||
409 | static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol, | 409 | static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol, |
410 | struct snd_ctl_elem_value *ucontrol) | 410 | struct snd_ctl_elem_value *ucontrol) |
411 | { | 411 | { |
412 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 412 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
413 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); | 413 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
414 | 414 | ||
415 | ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; | 415 | ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; |
@@ -462,7 +462,7 @@ static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) | |||
462 | static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, | 462 | static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, |
463 | struct snd_ctl_elem_value *ucontrol) | 463 | struct snd_ctl_elem_value *ucontrol) |
464 | { | 464 | { |
465 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 465 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
466 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); | 466 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
467 | struct wm8904_pdata *pdata = wm8904->pdata; | 467 | struct wm8904_pdata *pdata = wm8904->pdata; |
468 | int value = ucontrol->value.integer.value[0]; | 468 | int value = ucontrol->value.integer.value[0]; |
@@ -480,7 +480,7 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, | |||
480 | static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, | 480 | static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, |
481 | struct snd_ctl_elem_value *ucontrol) | 481 | struct snd_ctl_elem_value *ucontrol) |
482 | { | 482 | { |
483 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 483 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
484 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); | 484 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
485 | 485 | ||
486 | ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; | 486 | ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; |
@@ -520,7 +520,7 @@ static int wm8904_set_deemph(struct snd_soc_codec *codec) | |||
520 | static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, | 520 | static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, |
521 | struct snd_ctl_elem_value *ucontrol) | 521 | struct snd_ctl_elem_value *ucontrol) |
522 | { | 522 | { |
523 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 523 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
524 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); | 524 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
525 | 525 | ||
526 | ucontrol->value.enumerated.item[0] = wm8904->deemph; | 526 | ucontrol->value.enumerated.item[0] = wm8904->deemph; |
@@ -530,7 +530,7 @@ static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, | |||
530 | static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, | 530 | static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, |
531 | struct snd_ctl_elem_value *ucontrol) | 531 | struct snd_ctl_elem_value *ucontrol) |
532 | { | 532 | { |
533 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 533 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
534 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); | 534 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
535 | int deemph = ucontrol->value.enumerated.item[0]; | 535 | int deemph = ucontrol->value.enumerated.item[0]; |
536 | 536 | ||
@@ -570,7 +570,7 @@ static SOC_ENUM_SINGLE_DECL(hpf_mode, WM8904_ADC_DIGITAL_0, 5, | |||
570 | static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol, | 570 | static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol, |
571 | struct snd_ctl_elem_value *ucontrol) | 571 | struct snd_ctl_elem_value *ucontrol) |
572 | { | 572 | { |
573 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 573 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
574 | unsigned int val; | 574 | unsigned int val; |
575 | int ret; | 575 | int ret; |
576 | 576 | ||
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index fecd4e4f4c57..7e443c4f6f85 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c | |||
@@ -390,7 +390,7 @@ static int wm8955_set_deemph(struct snd_soc_codec *codec) | |||
390 | static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, | 390 | static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, |
391 | struct snd_ctl_elem_value *ucontrol) | 391 | struct snd_ctl_elem_value *ucontrol) |
392 | { | 392 | { |
393 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 393 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
394 | struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); | 394 | struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); |
395 | 395 | ||
396 | ucontrol->value.enumerated.item[0] = wm8955->deemph; | 396 | ucontrol->value.enumerated.item[0] = wm8955->deemph; |
@@ -400,7 +400,7 @@ static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, | |||
400 | static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, | 400 | static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, |
401 | struct snd_ctl_elem_value *ucontrol) | 401 | struct snd_ctl_elem_value *ucontrol) |
402 | { | 402 | { |
403 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 403 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
404 | struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); | 404 | struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); |
405 | int deemph = ucontrol->value.enumerated.item[0]; | 405 | int deemph = ucontrol->value.enumerated.item[0]; |
406 | 406 | ||
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index 7ac2e511403c..b2ebb104d879 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c | |||
@@ -456,7 +456,7 @@ static int wm8958_dsp2_busy(struct wm8994_priv *wm8994, int aif) | |||
456 | static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, | 456 | static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, |
457 | struct snd_ctl_elem_value *ucontrol) | 457 | struct snd_ctl_elem_value *ucontrol) |
458 | { | 458 | { |
459 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 459 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
460 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 460 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
461 | struct wm8994 *control = wm8994->wm8994; | 461 | struct wm8994 *control = wm8994->wm8994; |
462 | int value = ucontrol->value.integer.value[0]; | 462 | int value = ucontrol->value.integer.value[0]; |
@@ -478,7 +478,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, | |||
478 | static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol, | 478 | static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol, |
479 | struct snd_ctl_elem_value *ucontrol) | 479 | struct snd_ctl_elem_value *ucontrol) |
480 | { | 480 | { |
481 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 481 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
482 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 482 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
483 | 483 | ||
484 | ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg; | 484 | ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg; |
@@ -500,7 +500,7 @@ static int wm8958_mbc_get(struct snd_kcontrol *kcontrol, | |||
500 | struct snd_ctl_elem_value *ucontrol) | 500 | struct snd_ctl_elem_value *ucontrol) |
501 | { | 501 | { |
502 | int mbc = kcontrol->private_value; | 502 | int mbc = kcontrol->private_value; |
503 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 503 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
504 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 504 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
505 | 505 | ||
506 | ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc]; | 506 | ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc]; |
@@ -512,7 +512,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, | |||
512 | struct snd_ctl_elem_value *ucontrol) | 512 | struct snd_ctl_elem_value *ucontrol) |
513 | { | 513 | { |
514 | int mbc = kcontrol->private_value; | 514 | int mbc = kcontrol->private_value; |
515 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 515 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
516 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 516 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
517 | 517 | ||
518 | if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0]) | 518 | if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0]) |
@@ -546,7 +546,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, | |||
546 | static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, | 546 | static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, |
547 | struct snd_ctl_elem_value *ucontrol) | 547 | struct snd_ctl_elem_value *ucontrol) |
548 | { | 548 | { |
549 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 549 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
550 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 550 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
551 | struct wm8994 *control = wm8994->wm8994; | 551 | struct wm8994 *control = wm8994->wm8994; |
552 | int value = ucontrol->value.integer.value[0]; | 552 | int value = ucontrol->value.integer.value[0]; |
@@ -568,7 +568,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, | |||
568 | static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, | 568 | static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, |
569 | struct snd_ctl_elem_value *ucontrol) | 569 | struct snd_ctl_elem_value *ucontrol) |
570 | { | 570 | { |
571 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 571 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
572 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 572 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
573 | 573 | ||
574 | ucontrol->value.enumerated.item[0] = wm8994->vss_cfg; | 574 | ucontrol->value.enumerated.item[0] = wm8994->vss_cfg; |
@@ -579,7 +579,7 @@ static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, | |||
579 | static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, | 579 | static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, |
580 | struct snd_ctl_elem_value *ucontrol) | 580 | struct snd_ctl_elem_value *ucontrol) |
581 | { | 581 | { |
582 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 582 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
583 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 583 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
584 | struct wm8994 *control = wm8994->wm8994; | 584 | struct wm8994 *control = wm8994->wm8994; |
585 | int value = ucontrol->value.integer.value[0]; | 585 | int value = ucontrol->value.integer.value[0]; |
@@ -601,7 +601,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, | |||
601 | static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol, | 601 | static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol, |
602 | struct snd_ctl_elem_value *ucontrol) | 602 | struct snd_ctl_elem_value *ucontrol) |
603 | { | 603 | { |
604 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 604 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
605 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 605 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
606 | 606 | ||
607 | ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg; | 607 | ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg; |
@@ -623,7 +623,7 @@ static int wm8958_vss_get(struct snd_kcontrol *kcontrol, | |||
623 | struct snd_ctl_elem_value *ucontrol) | 623 | struct snd_ctl_elem_value *ucontrol) |
624 | { | 624 | { |
625 | int vss = kcontrol->private_value; | 625 | int vss = kcontrol->private_value; |
626 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 626 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
627 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 627 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
628 | 628 | ||
629 | ucontrol->value.integer.value[0] = wm8994->vss_ena[vss]; | 629 | ucontrol->value.integer.value[0] = wm8994->vss_ena[vss]; |
@@ -635,7 +635,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, | |||
635 | struct snd_ctl_elem_value *ucontrol) | 635 | struct snd_ctl_elem_value *ucontrol) |
636 | { | 636 | { |
637 | int vss = kcontrol->private_value; | 637 | int vss = kcontrol->private_value; |
638 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 638 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
639 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 639 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
640 | 640 | ||
641 | if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0]) | 641 | if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0]) |
@@ -684,7 +684,7 @@ static int wm8958_hpf_get(struct snd_kcontrol *kcontrol, | |||
684 | struct snd_ctl_elem_value *ucontrol) | 684 | struct snd_ctl_elem_value *ucontrol) |
685 | { | 685 | { |
686 | int hpf = kcontrol->private_value; | 686 | int hpf = kcontrol->private_value; |
687 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 687 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
688 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 688 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
689 | 689 | ||
690 | if (hpf < 3) | 690 | if (hpf < 3) |
@@ -699,7 +699,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, | |||
699 | struct snd_ctl_elem_value *ucontrol) | 699 | struct snd_ctl_elem_value *ucontrol) |
700 | { | 700 | { |
701 | int hpf = kcontrol->private_value; | 701 | int hpf = kcontrol->private_value; |
702 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 702 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
703 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 703 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
704 | 704 | ||
705 | if (hpf < 3) { | 705 | if (hpf < 3) { |
@@ -746,7 +746,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, | |||
746 | static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, | 746 | static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, |
747 | struct snd_ctl_elem_value *ucontrol) | 747 | struct snd_ctl_elem_value *ucontrol) |
748 | { | 748 | { |
749 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 749 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
750 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 750 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
751 | struct wm8994 *control = wm8994->wm8994; | 751 | struct wm8994 *control = wm8994->wm8994; |
752 | int value = ucontrol->value.integer.value[0]; | 752 | int value = ucontrol->value.integer.value[0]; |
@@ -768,7 +768,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, | |||
768 | static int wm8958_get_enh_eq_enum(struct snd_kcontrol *kcontrol, | 768 | static int wm8958_get_enh_eq_enum(struct snd_kcontrol *kcontrol, |
769 | struct snd_ctl_elem_value *ucontrol) | 769 | struct snd_ctl_elem_value *ucontrol) |
770 | { | 770 | { |
771 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 771 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
772 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 772 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
773 | 773 | ||
774 | ucontrol->value.enumerated.item[0] = wm8994->enh_eq_cfg; | 774 | ucontrol->value.enumerated.item[0] = wm8994->enh_eq_cfg; |
@@ -790,7 +790,7 @@ static int wm8958_enh_eq_get(struct snd_kcontrol *kcontrol, | |||
790 | struct snd_ctl_elem_value *ucontrol) | 790 | struct snd_ctl_elem_value *ucontrol) |
791 | { | 791 | { |
792 | int eq = kcontrol->private_value; | 792 | int eq = kcontrol->private_value; |
793 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 793 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
794 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 794 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
795 | 795 | ||
796 | ucontrol->value.integer.value[0] = wm8994->enh_eq_ena[eq]; | 796 | ucontrol->value.integer.value[0] = wm8994->enh_eq_ena[eq]; |
@@ -802,7 +802,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, | |||
802 | struct snd_ctl_elem_value *ucontrol) | 802 | struct snd_ctl_elem_value *ucontrol) |
803 | { | 803 | { |
804 | int eq = kcontrol->private_value; | 804 | int eq = kcontrol->private_value; |
805 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 805 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
806 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 806 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
807 | 807 | ||
808 | if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0]) | 808 | if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0]) |
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index d04e9cad445c..a145d0431b63 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c | |||
@@ -178,7 +178,7 @@ static int wm8960_set_deemph(struct snd_soc_codec *codec) | |||
178 | static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, | 178 | static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, |
179 | struct snd_ctl_elem_value *ucontrol) | 179 | struct snd_ctl_elem_value *ucontrol) |
180 | { | 180 | { |
181 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 181 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
182 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); | 182 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); |
183 | 183 | ||
184 | ucontrol->value.enumerated.item[0] = wm8960->deemph; | 184 | ucontrol->value.enumerated.item[0] = wm8960->deemph; |
@@ -188,7 +188,7 @@ static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, | |||
188 | static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, | 188 | static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, |
189 | struct snd_ctl_elem_value *ucontrol) | 189 | struct snd_ctl_elem_value *ucontrol) |
190 | { | 190 | { |
191 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 191 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
192 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); | 192 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); |
193 | int deemph = ucontrol->value.enumerated.item[0]; | 193 | int deemph = ucontrol->value.enumerated.item[0]; |
194 | 194 | ||
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index ecd26dd2e442..4823dffbdc95 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c | |||
@@ -1552,7 +1552,7 @@ static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol, | |||
1552 | struct snd_ctl_elem_value *ucontrol) | 1552 | struct snd_ctl_elem_value *ucontrol) |
1553 | { | 1553 | { |
1554 | int shift = kcontrol->private_value; | 1554 | int shift = kcontrol->private_value; |
1555 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1555 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1556 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); | 1556 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); |
1557 | 1557 | ||
1558 | ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift); | 1558 | ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift); |
@@ -1564,7 +1564,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, | |||
1564 | struct snd_ctl_elem_value *ucontrol) | 1564 | struct snd_ctl_elem_value *ucontrol) |
1565 | { | 1565 | { |
1566 | int shift = kcontrol->private_value; | 1566 | int shift = kcontrol->private_value; |
1567 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1567 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1568 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); | 1568 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); |
1569 | int old = wm8962->dsp2_ena; | 1569 | int old = wm8962->dsp2_ena; |
1570 | int ret = 0; | 1570 | int ret = 0; |
@@ -1602,7 +1602,7 @@ out: | |||
1602 | static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, | 1602 | static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, |
1603 | struct snd_ctl_elem_value *ucontrol) | 1603 | struct snd_ctl_elem_value *ucontrol) |
1604 | { | 1604 | { |
1605 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1605 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1606 | int ret; | 1606 | int ret; |
1607 | 1607 | ||
1608 | /* Apply the update (if any) */ | 1608 | /* Apply the update (if any) */ |
@@ -1632,7 +1632,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, | |||
1632 | static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, | 1632 | static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, |
1633 | struct snd_ctl_elem_value *ucontrol) | 1633 | struct snd_ctl_elem_value *ucontrol) |
1634 | { | 1634 | { |
1635 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1635 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1636 | int ret; | 1636 | int ret; |
1637 | 1637 | ||
1638 | /* Apply the update (if any) */ | 1638 | /* Apply the update (if any) */ |
diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c index 2b9bfa53efbf..19d5baa38f5c 100644 --- a/sound/soc/codecs/wm8983.c +++ b/sound/soc/codecs/wm8983.c | |||
@@ -552,7 +552,7 @@ static const struct snd_soc_dapm_route wm8983_audio_map[] = { | |||
552 | static int eqmode_get(struct snd_kcontrol *kcontrol, | 552 | static int eqmode_get(struct snd_kcontrol *kcontrol, |
553 | struct snd_ctl_elem_value *ucontrol) | 553 | struct snd_ctl_elem_value *ucontrol) |
554 | { | 554 | { |
555 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 555 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
556 | unsigned int reg; | 556 | unsigned int reg; |
557 | 557 | ||
558 | reg = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); | 558 | reg = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); |
@@ -567,7 +567,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, | |||
567 | static int eqmode_put(struct snd_kcontrol *kcontrol, | 567 | static int eqmode_put(struct snd_kcontrol *kcontrol, |
568 | struct snd_ctl_elem_value *ucontrol) | 568 | struct snd_ctl_elem_value *ucontrol) |
569 | { | 569 | { |
570 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 570 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
571 | unsigned int regpwr2, regpwr3; | 571 | unsigned int regpwr2, regpwr3; |
572 | unsigned int reg_eq; | 572 | unsigned int reg_eq; |
573 | 573 | ||
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c index 5473dc969585..ad23ffb8346c 100644 --- a/sound/soc/codecs/wm8985.c +++ b/sound/soc/codecs/wm8985.c | |||
@@ -526,7 +526,7 @@ static const struct snd_soc_dapm_route wm8985_dapm_routes[] = { | |||
526 | static int eqmode_get(struct snd_kcontrol *kcontrol, | 526 | static int eqmode_get(struct snd_kcontrol *kcontrol, |
527 | struct snd_ctl_elem_value *ucontrol) | 527 | struct snd_ctl_elem_value *ucontrol) |
528 | { | 528 | { |
529 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 529 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
530 | unsigned int reg; | 530 | unsigned int reg; |
531 | 531 | ||
532 | reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); | 532 | reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); |
@@ -541,7 +541,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, | |||
541 | static int eqmode_put(struct snd_kcontrol *kcontrol, | 541 | static int eqmode_put(struct snd_kcontrol *kcontrol, |
542 | struct snd_ctl_elem_value *ucontrol) | 542 | struct snd_ctl_elem_value *ucontrol) |
543 | { | 543 | { |
544 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 544 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
545 | unsigned int regpwr2, regpwr3; | 545 | unsigned int regpwr2, regpwr3; |
546 | unsigned int reg_eq; | 546 | unsigned int reg_eq; |
547 | 547 | ||
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index c413c1991453..b5c1f0f07058 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c | |||
@@ -132,7 +132,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); | |||
132 | static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, | 132 | static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, |
133 | struct snd_ctl_elem_value *ucontrol) | 133 | struct snd_ctl_elem_value *ucontrol) |
134 | { | 134 | { |
135 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 135 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
136 | struct soc_mixer_control *mc = | 136 | struct soc_mixer_control *mc = |
137 | (struct soc_mixer_control *)kcontrol->private_value; | 137 | (struct soc_mixer_control *)kcontrol->private_value; |
138 | int reg = mc->reg; | 138 | int reg = mc->reg; |
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index 844cc4a60d66..b8fd284fc0c0 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c | |||
@@ -154,7 +154,7 @@ static const unsigned int out_sidetone_tlv[] = { | |||
154 | static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, | 154 | static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, |
155 | struct snd_ctl_elem_value *ucontrol) | 155 | struct snd_ctl_elem_value *ucontrol) |
156 | { | 156 | { |
157 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 157 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
158 | int reg = kcontrol->private_value & 0xff; | 158 | int reg = kcontrol->private_value & 0xff; |
159 | int ret; | 159 | int ret; |
160 | u16 val; | 160 | u16 val; |
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 6303537f54c6..29f40a90fa79 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c | |||
@@ -298,7 +298,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, | |||
298 | { | 298 | { |
299 | struct soc_mixer_control *mc = | 299 | struct soc_mixer_control *mc = |
300 | (struct soc_mixer_control *)kcontrol->private_value; | 300 | (struct soc_mixer_control *)kcontrol->private_value; |
301 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 301 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
302 | int mask, ret; | 302 | int mask, ret; |
303 | 303 | ||
304 | /* Can't enable both ADC and DAC paths simultaneously */ | 304 | /* Can't enable both ADC and DAC paths simultaneously */ |
@@ -355,7 +355,7 @@ static int wm8994_get_drc(const char *name) | |||
355 | static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, | 355 | static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, |
356 | struct snd_ctl_elem_value *ucontrol) | 356 | struct snd_ctl_elem_value *ucontrol) |
357 | { | 357 | { |
358 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 358 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
359 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 359 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
360 | struct wm8994 *control = wm8994->wm8994; | 360 | struct wm8994 *control = wm8994->wm8994; |
361 | struct wm8994_pdata *pdata = &control->pdata; | 361 | struct wm8994_pdata *pdata = &control->pdata; |
@@ -378,7 +378,7 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, | |||
378 | static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol, | 378 | static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol, |
379 | struct snd_ctl_elem_value *ucontrol) | 379 | struct snd_ctl_elem_value *ucontrol) |
380 | { | 380 | { |
381 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 381 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
382 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 382 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
383 | int drc = wm8994_get_drc(kcontrol->id.name); | 383 | int drc = wm8994_get_drc(kcontrol->id.name); |
384 | 384 | ||
@@ -462,7 +462,7 @@ static int wm8994_get_retune_mobile_block(const char *name) | |||
462 | static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, | 462 | static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, |
463 | struct snd_ctl_elem_value *ucontrol) | 463 | struct snd_ctl_elem_value *ucontrol) |
464 | { | 464 | { |
465 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 465 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
466 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 466 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
467 | struct wm8994 *control = wm8994->wm8994; | 467 | struct wm8994 *control = wm8994->wm8994; |
468 | struct wm8994_pdata *pdata = &control->pdata; | 468 | struct wm8994_pdata *pdata = &control->pdata; |
@@ -485,7 +485,7 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, | |||
485 | static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, | 485 | static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, |
486 | struct snd_ctl_elem_value *ucontrol) | 486 | struct snd_ctl_elem_value *ucontrol) |
487 | { | 487 | { |
488 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 488 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
489 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 489 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
490 | int block = wm8994_get_retune_mobile_block(kcontrol->id.name); | 490 | int block = wm8994_get_retune_mobile_block(kcontrol->id.name); |
491 | 491 | ||
@@ -3999,8 +3999,6 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) | |||
3999 | 3999 | ||
4000 | wm8994->hubs.codec = codec; | 4000 | wm8994->hubs.codec = codec; |
4001 | 4001 | ||
4002 | snd_soc_codec_set_cache_io(codec, control->regmap); | ||
4003 | |||
4004 | mutex_init(&wm8994->accdet_lock); | 4002 | mutex_init(&wm8994->accdet_lock); |
4005 | INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, | 4003 | INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, |
4006 | wm1811_jackdet_bootstrap); | 4004 | wm1811_jackdet_bootstrap); |
@@ -4434,11 +4432,19 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) | |||
4434 | return 0; | 4432 | return 0; |
4435 | } | 4433 | } |
4436 | 4434 | ||
4435 | static struct regmap *wm8994_get_regmap(struct device *dev) | ||
4436 | { | ||
4437 | struct wm8994 *control = dev_get_drvdata(dev->parent); | ||
4438 | |||
4439 | return control->regmap; | ||
4440 | } | ||
4441 | |||
4437 | static struct snd_soc_codec_driver soc_codec_dev_wm8994 = { | 4442 | static struct snd_soc_codec_driver soc_codec_dev_wm8994 = { |
4438 | .probe = wm8994_codec_probe, | 4443 | .probe = wm8994_codec_probe, |
4439 | .remove = wm8994_codec_remove, | 4444 | .remove = wm8994_codec_remove, |
4440 | .suspend = wm8994_codec_suspend, | 4445 | .suspend = wm8994_codec_suspend, |
4441 | .resume = wm8994_codec_resume, | 4446 | .resume = wm8994_codec_resume, |
4447 | .get_regmap = wm8994_get_regmap, | ||
4442 | .set_bias_level = wm8994_set_bias_level, | 4448 | .set_bias_level = wm8994_set_bias_level, |
4443 | }; | 4449 | }; |
4444 | 4450 | ||
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index c6cbb3b8ace9..69266332760e 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c | |||
@@ -412,7 +412,7 @@ static int wm8996_get_retune_mobile_block(const char *name) | |||
412 | static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, | 412 | static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, |
413 | struct snd_ctl_elem_value *ucontrol) | 413 | struct snd_ctl_elem_value *ucontrol) |
414 | { | 414 | { |
415 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 415 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
416 | struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); | 416 | struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); |
417 | struct wm8996_pdata *pdata = &wm8996->pdata; | 417 | struct wm8996_pdata *pdata = &wm8996->pdata; |
418 | int block = wm8996_get_retune_mobile_block(kcontrol->id.name); | 418 | int block = wm8996_get_retune_mobile_block(kcontrol->id.name); |
@@ -434,7 +434,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, | |||
434 | static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, | 434 | static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, |
435 | struct snd_ctl_elem_value *ucontrol) | 435 | struct snd_ctl_elem_value *ucontrol) |
436 | { | 436 | { |
437 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 437 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
438 | struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); | 438 | struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); |
439 | int block = wm8996_get_retune_mobile_block(kcontrol->id.name); | 439 | int block = wm8996_get_retune_mobile_block(kcontrol->id.name); |
440 | 440 | ||
diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 004186b6bd48..09c4150840a3 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c | |||
@@ -1051,11 +1051,6 @@ static struct snd_soc_dai_driver wm8997_dai[] = { | |||
1051 | static int wm8997_codec_probe(struct snd_soc_codec *codec) | 1051 | static int wm8997_codec_probe(struct snd_soc_codec *codec) |
1052 | { | 1052 | { |
1053 | struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec); | 1053 | struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec); |
1054 | int ret; | ||
1055 | |||
1056 | ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); | ||
1057 | if (ret != 0) | ||
1058 | return ret; | ||
1059 | 1054 | ||
1060 | arizona_init_spk(codec); | 1055 | arizona_init_spk(codec); |
1061 | 1056 | ||
@@ -1086,9 +1081,17 @@ static unsigned int wm8997_digital_vu[] = { | |||
1086 | ARIZONA_DAC_DIGITAL_VOLUME_5R, | 1081 | ARIZONA_DAC_DIGITAL_VOLUME_5R, |
1087 | }; | 1082 | }; |
1088 | 1083 | ||
1084 | static struct regmap *wm8997_get_regmap(struct device *dev) | ||
1085 | { | ||
1086 | struct wm8997_priv *priv = dev_get_drvdata(dev); | ||
1087 | |||
1088 | return priv->core.arizona->regmap; | ||
1089 | } | ||
1090 | |||
1089 | static struct snd_soc_codec_driver soc_codec_dev_wm8997 = { | 1091 | static struct snd_soc_codec_driver soc_codec_dev_wm8997 = { |
1090 | .probe = wm8997_codec_probe, | 1092 | .probe = wm8997_codec_probe, |
1091 | .remove = wm8997_codec_remove, | 1093 | .remove = wm8997_codec_remove, |
1094 | .get_regmap = wm8997_get_regmap, | ||
1092 | 1095 | ||
1093 | .idle_bias_off = true, | 1096 | .idle_bias_off = true, |
1094 | 1097 | ||
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index d18eff31fbbc..185eb97769e7 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c | |||
@@ -340,7 +340,7 @@ static SOC_ENUM_SINGLE_DECL(speaker_mode, WM9081_ANALOGUE_SPEAKER_2, 6, | |||
340 | static int speaker_mode_get(struct snd_kcontrol *kcontrol, | 340 | static int speaker_mode_get(struct snd_kcontrol *kcontrol, |
341 | struct snd_ctl_elem_value *ucontrol) | 341 | struct snd_ctl_elem_value *ucontrol) |
342 | { | 342 | { |
343 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 343 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
344 | unsigned int reg; | 344 | unsigned int reg; |
345 | 345 | ||
346 | reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); | 346 | reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); |
@@ -361,7 +361,7 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol, | |||
361 | static int speaker_mode_put(struct snd_kcontrol *kcontrol, | 361 | static int speaker_mode_put(struct snd_kcontrol *kcontrol, |
362 | struct snd_ctl_elem_value *ucontrol) | 362 | struct snd_ctl_elem_value *ucontrol) |
363 | { | 363 | { |
364 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 364 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
365 | unsigned int reg_pwr = snd_soc_read(codec, WM9081_POWER_MANAGEMENT); | 365 | unsigned int reg_pwr = snd_soc_read(codec, WM9081_POWER_MANAGEMENT); |
366 | unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); | 366 | unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); |
367 | 367 | ||
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index bb5f7b4e3ebb..d9686dcd024c 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c | |||
@@ -242,7 +242,7 @@ struct wm_coeff_ctl { | |||
242 | static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, | 242 | static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, |
243 | struct snd_ctl_elem_value *ucontrol) | 243 | struct snd_ctl_elem_value *ucontrol) |
244 | { | 244 | { |
245 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 245 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
246 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 246 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
247 | struct wm_adsp *adsp = snd_soc_codec_get_drvdata(codec); | 247 | struct wm_adsp *adsp = snd_soc_codec_get_drvdata(codec); |
248 | 248 | ||
@@ -254,7 +254,7 @@ static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, | |||
254 | static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, | 254 | static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, |
255 | struct snd_ctl_elem_value *ucontrol) | 255 | struct snd_ctl_elem_value *ucontrol) |
256 | { | 256 | { |
257 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 257 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
258 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 258 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
259 | struct wm_adsp *adsp = snd_soc_codec_get_drvdata(codec); | 259 | struct wm_adsp *adsp = snd_soc_codec_get_drvdata(codec); |
260 | 260 | ||
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index b6209662ab13..916817fe6632 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c | |||
@@ -337,7 +337,7 @@ static void enable_dc_servo(struct snd_soc_codec *codec) | |||
337 | static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, | 337 | static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, |
338 | struct snd_ctl_elem_value *ucontrol) | 338 | struct snd_ctl_elem_value *ucontrol) |
339 | { | 339 | { |
340 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 340 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
341 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); | 341 | struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); |
342 | int ret; | 342 | int ret; |
343 | 343 | ||
diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index 9d5f64a583a3..ce27b507d5ef 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c | |||
@@ -139,7 +139,7 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value) | |||
139 | static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, | 139 | static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, |
140 | struct snd_ctl_elem_value *ucontrol) | 140 | struct snd_ctl_elem_value *ucontrol) |
141 | { | 141 | { |
142 | struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); | 142 | struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); |
143 | struct soc_mixer_control *mc = | 143 | struct soc_mixer_control *mc = |
144 | (struct soc_mixer_control *)kcontrol->private_value; | 144 | (struct soc_mixer_control *)kcontrol->private_value; |
145 | struct hsw_priv_data *pdata = | 145 | struct hsw_priv_data *pdata = |
@@ -177,7 +177,7 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, | |||
177 | static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, | 177 | static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, |
178 | struct snd_ctl_elem_value *ucontrol) | 178 | struct snd_ctl_elem_value *ucontrol) |
179 | { | 179 | { |
180 | struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); | 180 | struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); |
181 | struct soc_mixer_control *mc = | 181 | struct soc_mixer_control *mc = |
182 | (struct soc_mixer_control *)kcontrol->private_value; | 182 | (struct soc_mixer_control *)kcontrol->private_value; |
183 | struct hsw_priv_data *pdata = | 183 | struct hsw_priv_data *pdata = |
@@ -209,7 +209,7 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, | |||
209 | static int hsw_volume_put(struct snd_kcontrol *kcontrol, | 209 | static int hsw_volume_put(struct snd_kcontrol *kcontrol, |
210 | struct snd_ctl_elem_value *ucontrol) | 210 | struct snd_ctl_elem_value *ucontrol) |
211 | { | 211 | { |
212 | struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); | 212 | struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); |
213 | struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); | 213 | struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); |
214 | struct sst_hsw *hsw = pdata->hsw; | 214 | struct sst_hsw *hsw = pdata->hsw; |
215 | u32 volume; | 215 | u32 volume; |
@@ -234,7 +234,7 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol, | |||
234 | static int hsw_volume_get(struct snd_kcontrol *kcontrol, | 234 | static int hsw_volume_get(struct snd_kcontrol *kcontrol, |
235 | struct snd_ctl_elem_value *ucontrol) | 235 | struct snd_ctl_elem_value *ucontrol) |
236 | { | 236 | { |
237 | struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); | 237 | struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); |
238 | struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); | 238 | struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); |
239 | struct sst_hsw *hsw = pdata->hsw; | 239 | struct sst_hsw *hsw = pdata->hsw; |
240 | unsigned int volume = 0; | 240 | unsigned int volume = 0; |
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index bfed3e4c45ff..3fa77d5f9b75 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c | |||
@@ -162,8 +162,6 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) | |||
162 | i, codec_drv->reg_word_size) == val) | 162 | i, codec_drv->reg_word_size) == val) |
163 | continue; | 163 | continue; |
164 | 164 | ||
165 | WARN_ON(!snd_soc_codec_writable_register(codec, i)); | ||
166 | |||
167 | ret = snd_soc_write(codec, i, val); | 165 | ret = snd_soc_write(codec, i, val); |
168 | if (ret) | 166 | if (ret) |
169 | return ret; | 167 | return ret; |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 051c006281f5..4a381b307b08 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -154,22 +154,15 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf, | |||
154 | step = codec->driver->reg_cache_step; | 154 | step = codec->driver->reg_cache_step; |
155 | 155 | ||
156 | for (i = 0; i < codec->driver->reg_cache_size; i += step) { | 156 | for (i = 0; i < codec->driver->reg_cache_size; i += step) { |
157 | if (!snd_soc_codec_readable_register(codec, i)) | 157 | /* only support larger than PAGE_SIZE bytes debugfs |
158 | continue; | 158 | * entries for the default case */ |
159 | if (codec->driver->display_register) { | 159 | if (p >= pos) { |
160 | count += codec->driver->display_register(codec, buf + count, | 160 | if (total + len >= count - 1) |
161 | PAGE_SIZE - count, i); | 161 | break; |
162 | } else { | 162 | format_register_str(codec, i, buf + total, len); |
163 | /* only support larger than PAGE_SIZE bytes debugfs | 163 | total += len; |
164 | * entries for the default case */ | ||
165 | if (p >= pos) { | ||
166 | if (total + len >= count - 1) | ||
167 | break; | ||
168 | format_register_str(codec, i, buf + total, len); | ||
169 | total += len; | ||
170 | } | ||
171 | p += len; | ||
172 | } | 164 | } |
165 | p += len; | ||
173 | } | 166 | } |
174 | 167 | ||
175 | total = min(total, count - 1); | 168 | total = min(total, count - 1); |
@@ -663,8 +656,8 @@ int snd_soc_suspend(struct device *dev) | |||
663 | codec->driver->suspend(codec); | 656 | codec->driver->suspend(codec); |
664 | codec->suspended = 1; | 657 | codec->suspended = 1; |
665 | codec->cache_sync = 1; | 658 | codec->cache_sync = 1; |
666 | if (codec->using_regmap) | 659 | if (codec->component.regmap) |
667 | regcache_mark_dirty(codec->control_data); | 660 | regcache_mark_dirty(codec->component.regmap); |
668 | /* deactivate pins to sleep state */ | 661 | /* deactivate pins to sleep state */ |
669 | pinctrl_pm_select_sleep_state(codec->dev); | 662 | pinctrl_pm_select_sleep_state(codec->dev); |
670 | break; | 663 | break; |
@@ -854,14 +847,47 @@ EXPORT_SYMBOL_GPL(snd_soc_resume); | |||
854 | static const struct snd_soc_dai_ops null_dai_ops = { | 847 | static const struct snd_soc_dai_ops null_dai_ops = { |
855 | }; | 848 | }; |
856 | 849 | ||
850 | static struct snd_soc_codec *soc_find_codec(const struct device_node *codec_of_node, | ||
851 | const char *codec_name) | ||
852 | { | ||
853 | struct snd_soc_codec *codec; | ||
854 | |||
855 | list_for_each_entry(codec, &codec_list, list) { | ||
856 | if (codec_of_node) { | ||
857 | if (codec->dev->of_node != codec_of_node) | ||
858 | continue; | ||
859 | } else { | ||
860 | if (strcmp(codec->name, codec_name)) | ||
861 | continue; | ||
862 | } | ||
863 | |||
864 | return codec; | ||
865 | } | ||
866 | |||
867 | return NULL; | ||
868 | } | ||
869 | |||
870 | static struct snd_soc_dai *soc_find_codec_dai(struct snd_soc_codec *codec, | ||
871 | const char *codec_dai_name) | ||
872 | { | ||
873 | struct snd_soc_dai *codec_dai; | ||
874 | |||
875 | list_for_each_entry(codec_dai, &codec->component.dai_list, list) { | ||
876 | if (!strcmp(codec_dai->name, codec_dai_name)) { | ||
877 | return codec_dai; | ||
878 | } | ||
879 | } | ||
880 | |||
881 | return NULL; | ||
882 | } | ||
883 | |||
857 | static int soc_bind_dai_link(struct snd_soc_card *card, int num) | 884 | static int soc_bind_dai_link(struct snd_soc_card *card, int num) |
858 | { | 885 | { |
859 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; | 886 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; |
860 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | 887 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; |
861 | struct snd_soc_component *component; | 888 | struct snd_soc_component *component; |
862 | struct snd_soc_codec *codec; | ||
863 | struct snd_soc_platform *platform; | 889 | struct snd_soc_platform *platform; |
864 | struct snd_soc_dai *codec_dai, *cpu_dai; | 890 | struct snd_soc_dai *cpu_dai; |
865 | const char *platform_name; | 891 | const char *platform_name; |
866 | 892 | ||
867 | dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num); | 893 | dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num); |
@@ -889,42 +915,24 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) | |||
889 | return -EPROBE_DEFER; | 915 | return -EPROBE_DEFER; |
890 | } | 916 | } |
891 | 917 | ||
892 | /* Find CODEC from registered CODECs */ | 918 | /* Find CODEC from registered list */ |
893 | list_for_each_entry(codec, &codec_list, list) { | 919 | rtd->codec = soc_find_codec(dai_link->codec_of_node, |
894 | if (dai_link->codec_of_node) { | 920 | dai_link->codec_name); |
895 | if (codec->dev->of_node != dai_link->codec_of_node) | ||
896 | continue; | ||
897 | } else { | ||
898 | if (strcmp(codec->name, dai_link->codec_name)) | ||
899 | continue; | ||
900 | } | ||
901 | |||
902 | rtd->codec = codec; | ||
903 | |||
904 | /* | ||
905 | * CODEC found, so find CODEC DAI from registered DAIs from | ||
906 | * this CODEC | ||
907 | */ | ||
908 | list_for_each_entry(codec_dai, &codec->component.dai_list, list) { | ||
909 | if (!strcmp(codec_dai->name, dai_link->codec_dai_name)) { | ||
910 | rtd->codec_dai = codec_dai; | ||
911 | break; | ||
912 | } | ||
913 | } | ||
914 | |||
915 | if (!rtd->codec_dai) { | ||
916 | dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", | ||
917 | dai_link->codec_dai_name); | ||
918 | return -EPROBE_DEFER; | ||
919 | } | ||
920 | } | ||
921 | |||
922 | if (!rtd->codec) { | 921 | if (!rtd->codec) { |
923 | dev_err(card->dev, "ASoC: CODEC %s not registered\n", | 922 | dev_err(card->dev, "ASoC: CODEC %s not registered\n", |
924 | dai_link->codec_name); | 923 | dai_link->codec_name); |
925 | return -EPROBE_DEFER; | 924 | return -EPROBE_DEFER; |
926 | } | 925 | } |
927 | 926 | ||
927 | /* Find CODEC DAI from registered list */ | ||
928 | rtd->codec_dai = soc_find_codec_dai(rtd->codec, | ||
929 | dai_link->codec_dai_name); | ||
930 | if (!rtd->codec_dai) { | ||
931 | dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", | ||
932 | dai_link->codec_dai_name); | ||
933 | return -EPROBE_DEFER; | ||
934 | } | ||
935 | |||
928 | /* if there's no platform we match on the empty platform */ | 936 | /* if there's no platform we match on the empty platform */ |
929 | platform_name = dai_link->platform_name; | 937 | platform_name = dai_link->platform_name; |
930 | if (!platform_name && !dai_link->platform_of_node) | 938 | if (!platform_name && !dai_link->platform_of_node) |
@@ -995,21 +1003,10 @@ static void soc_remove_codec(struct snd_soc_codec *codec) | |||
995 | module_put(codec->dev->driver->owner); | 1003 | module_put(codec->dev->driver->owner); |
996 | } | 1004 | } |
997 | 1005 | ||
998 | static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) | 1006 | static void soc_remove_codec_dai(struct snd_soc_dai *codec_dai, int order) |
999 | { | 1007 | { |
1000 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | ||
1001 | struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai; | ||
1002 | int err; | 1008 | int err; |
1003 | 1009 | ||
1004 | /* unregister the rtd device */ | ||
1005 | if (rtd->dev_registered) { | ||
1006 | device_remove_file(rtd->dev, &dev_attr_pmdown_time); | ||
1007 | device_remove_file(rtd->dev, &dev_attr_codec_reg); | ||
1008 | device_unregister(rtd->dev); | ||
1009 | rtd->dev_registered = 0; | ||
1010 | } | ||
1011 | |||
1012 | /* remove the CODEC DAI */ | ||
1013 | if (codec_dai && codec_dai->probed && | 1010 | if (codec_dai && codec_dai->probed && |
1014 | codec_dai->driver->remove_order == order) { | 1011 | codec_dai->driver->remove_order == order) { |
1015 | if (codec_dai->driver->remove) { | 1012 | if (codec_dai->driver->remove) { |
@@ -1022,6 +1019,24 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) | |||
1022 | codec_dai->probed = 0; | 1019 | codec_dai->probed = 0; |
1023 | list_del(&codec_dai->card_list); | 1020 | list_del(&codec_dai->card_list); |
1024 | } | 1021 | } |
1022 | } | ||
1023 | |||
1024 | static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) | ||
1025 | { | ||
1026 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | ||
1027 | struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai; | ||
1028 | int err; | ||
1029 | |||
1030 | /* unregister the rtd device */ | ||
1031 | if (rtd->dev_registered) { | ||
1032 | device_remove_file(rtd->dev, &dev_attr_pmdown_time); | ||
1033 | device_remove_file(rtd->dev, &dev_attr_codec_reg); | ||
1034 | device_unregister(rtd->dev); | ||
1035 | rtd->dev_registered = 0; | ||
1036 | } | ||
1037 | |||
1038 | /* remove the CODEC DAI */ | ||
1039 | soc_remove_codec_dai(codec_dai, order); | ||
1025 | 1040 | ||
1026 | /* remove the cpu_dai */ | 1041 | /* remove the cpu_dai */ |
1027 | if (cpu_dai && cpu_dai->probed && | 1042 | if (cpu_dai && cpu_dai->probed && |
@@ -1127,26 +1142,31 @@ static int soc_probe_codec(struct snd_soc_card *card, | |||
1127 | 1142 | ||
1128 | soc_init_codec_debugfs(codec); | 1143 | soc_init_codec_debugfs(codec); |
1129 | 1144 | ||
1130 | if (driver->dapm_widgets) | 1145 | if (driver->dapm_widgets) { |
1131 | snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets, | 1146 | ret = snd_soc_dapm_new_controls(&codec->dapm, |
1132 | driver->num_dapm_widgets); | 1147 | driver->dapm_widgets, |
1148 | driver->num_dapm_widgets); | ||
1133 | 1149 | ||
1134 | /* Create DAPM widgets for each DAI stream */ | 1150 | if (ret != 0) { |
1135 | list_for_each_entry(dai, &codec->component.dai_list, list) | 1151 | dev_err(codec->dev, |
1136 | snd_soc_dapm_new_dai_widgets(&codec->dapm, dai); | 1152 | "Failed to create new controls %d\n", ret); |
1153 | goto err_probe; | ||
1154 | } | ||
1155 | } | ||
1137 | 1156 | ||
1138 | codec->dapm.idle_bias_off = driver->idle_bias_off; | 1157 | /* Create DAPM widgets for each DAI stream */ |
1158 | list_for_each_entry(dai, &codec->component.dai_list, list) { | ||
1159 | ret = snd_soc_dapm_new_dai_widgets(&codec->dapm, dai); | ||
1139 | 1160 | ||
1140 | if (!codec->write && dev_get_regmap(codec->dev, NULL)) { | 1161 | if (ret != 0) { |
1141 | /* Set the default I/O up try regmap */ | ||
1142 | ret = snd_soc_codec_set_cache_io(codec, NULL); | ||
1143 | if (ret < 0) { | ||
1144 | dev_err(codec->dev, | 1162 | dev_err(codec->dev, |
1145 | "Failed to set cache I/O: %d\n", ret); | 1163 | "Failed to create DAI widgets %d\n", ret); |
1146 | goto err_probe; | 1164 | goto err_probe; |
1147 | } | 1165 | } |
1148 | } | 1166 | } |
1149 | 1167 | ||
1168 | codec->dapm.idle_bias_off = driver->idle_bias_off; | ||
1169 | |||
1150 | if (driver->probe) { | 1170 | if (driver->probe) { |
1151 | ret = driver->probe(codec); | 1171 | ret = driver->probe(codec); |
1152 | if (ret < 0) { | 1172 | if (ret < 0) { |
@@ -1366,6 +1386,67 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, | |||
1366 | return 0; | 1386 | return 0; |
1367 | } | 1387 | } |
1368 | 1388 | ||
1389 | static int soc_probe_codec_dai(struct snd_soc_card *card, | ||
1390 | struct snd_soc_dai *codec_dai, | ||
1391 | int order) | ||
1392 | { | ||
1393 | int ret; | ||
1394 | |||
1395 | if (!codec_dai->probed && codec_dai->driver->probe_order == order) { | ||
1396 | if (codec_dai->driver->probe) { | ||
1397 | ret = codec_dai->driver->probe(codec_dai); | ||
1398 | if (ret < 0) { | ||
1399 | dev_err(codec_dai->dev, | ||
1400 | "ASoC: failed to probe CODEC DAI %s: %d\n", | ||
1401 | codec_dai->name, ret); | ||
1402 | return ret; | ||
1403 | } | ||
1404 | } | ||
1405 | |||
1406 | /* mark codec_dai as probed and add to card dai list */ | ||
1407 | codec_dai->probed = 1; | ||
1408 | list_add(&codec_dai->card_list, &card->dai_dev_list); | ||
1409 | } | ||
1410 | |||
1411 | return 0; | ||
1412 | } | ||
1413 | |||
1414 | static int soc_link_dai_widgets(struct snd_soc_card *card, | ||
1415 | struct snd_soc_dai_link *dai_link, | ||
1416 | struct snd_soc_dai *cpu_dai, | ||
1417 | struct snd_soc_dai *codec_dai) | ||
1418 | { | ||
1419 | struct snd_soc_dapm_widget *play_w, *capture_w; | ||
1420 | int ret; | ||
1421 | |||
1422 | /* link the DAI widgets */ | ||
1423 | play_w = codec_dai->playback_widget; | ||
1424 | capture_w = cpu_dai->capture_widget; | ||
1425 | if (play_w && capture_w) { | ||
1426 | ret = snd_soc_dapm_new_pcm(card, dai_link->params, | ||
1427 | capture_w, play_w); | ||
1428 | if (ret != 0) { | ||
1429 | dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", | ||
1430 | play_w->name, capture_w->name, ret); | ||
1431 | return ret; | ||
1432 | } | ||
1433 | } | ||
1434 | |||
1435 | play_w = cpu_dai->playback_widget; | ||
1436 | capture_w = codec_dai->capture_widget; | ||
1437 | if (play_w && capture_w) { | ||
1438 | ret = snd_soc_dapm_new_pcm(card, dai_link->params, | ||
1439 | capture_w, play_w); | ||
1440 | if (ret != 0) { | ||
1441 | dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", | ||
1442 | play_w->name, capture_w->name, ret); | ||
1443 | return ret; | ||
1444 | } | ||
1445 | } | ||
1446 | |||
1447 | return 0; | ||
1448 | } | ||
1449 | |||
1369 | static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | 1450 | static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) |
1370 | { | 1451 | { |
1371 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; | 1452 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; |
@@ -1374,7 +1455,6 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
1374 | struct snd_soc_platform *platform = rtd->platform; | 1455 | struct snd_soc_platform *platform = rtd->platform; |
1375 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 1456 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
1376 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1457 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
1377 | struct snd_soc_dapm_widget *play_w, *capture_w; | ||
1378 | int ret; | 1458 | int ret; |
1379 | 1459 | ||
1380 | dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", | 1460 | dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", |
@@ -1415,21 +1495,9 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
1415 | } | 1495 | } |
1416 | 1496 | ||
1417 | /* probe the CODEC DAI */ | 1497 | /* probe the CODEC DAI */ |
1418 | if (!codec_dai->probed && codec_dai->driver->probe_order == order) { | 1498 | ret = soc_probe_codec_dai(card, codec_dai, order); |
1419 | if (codec_dai->driver->probe) { | 1499 | if (ret) |
1420 | ret = codec_dai->driver->probe(codec_dai); | 1500 | return ret; |
1421 | if (ret < 0) { | ||
1422 | dev_err(codec_dai->dev, | ||
1423 | "ASoC: failed to probe CODEC DAI %s: %d\n", | ||
1424 | codec_dai->name, ret); | ||
1425 | return ret; | ||
1426 | } | ||
1427 | } | ||
1428 | |||
1429 | /* mark codec_dai as probed and add to card dai list */ | ||
1430 | codec_dai->probed = 1; | ||
1431 | list_add(&codec_dai->card_list, &card->dai_dev_list); | ||
1432 | } | ||
1433 | 1501 | ||
1434 | /* complete DAI probe during last probe */ | 1502 | /* complete DAI probe during last probe */ |
1435 | if (order != SND_SOC_COMP_ORDER_LAST) | 1503 | if (order != SND_SOC_COMP_ORDER_LAST) |
@@ -1467,29 +1535,10 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
1467 | codec2codec_close_delayed_work); | 1535 | codec2codec_close_delayed_work); |
1468 | 1536 | ||
1469 | /* link the DAI widgets */ | 1537 | /* link the DAI widgets */ |
1470 | play_w = codec_dai->playback_widget; | 1538 | ret = soc_link_dai_widgets(card, dai_link, |
1471 | capture_w = cpu_dai->capture_widget; | 1539 | cpu_dai, codec_dai); |
1472 | if (play_w && capture_w) { | 1540 | if (ret) |
1473 | ret = snd_soc_dapm_new_pcm(card, dai_link->params, | 1541 | return ret; |
1474 | capture_w, play_w); | ||
1475 | if (ret != 0) { | ||
1476 | dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", | ||
1477 | play_w->name, capture_w->name, ret); | ||
1478 | return ret; | ||
1479 | } | ||
1480 | } | ||
1481 | |||
1482 | play_w = cpu_dai->playback_widget; | ||
1483 | capture_w = codec_dai->capture_widget; | ||
1484 | if (play_w && capture_w) { | ||
1485 | ret = snd_soc_dapm_new_pcm(card, dai_link->params, | ||
1486 | capture_w, play_w); | ||
1487 | if (ret != 0) { | ||
1488 | dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", | ||
1489 | play_w->name, capture_w->name, ret); | ||
1490 | return ret; | ||
1491 | } | ||
1492 | } | ||
1493 | } | 1542 | } |
1494 | } | 1543 | } |
1495 | 1544 | ||
@@ -1501,14 +1550,15 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
1501 | } | 1550 | } |
1502 | 1551 | ||
1503 | #ifdef CONFIG_SND_SOC_AC97_BUS | 1552 | #ifdef CONFIG_SND_SOC_AC97_BUS |
1504 | static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | 1553 | static int soc_register_ac97_codec(struct snd_soc_codec *codec, |
1554 | struct snd_soc_dai *codec_dai) | ||
1505 | { | 1555 | { |
1506 | int ret; | 1556 | int ret; |
1507 | 1557 | ||
1508 | /* Only instantiate AC97 if not already done by the adaptor | 1558 | /* Only instantiate AC97 if not already done by the adaptor |
1509 | * for the generic AC97 subsystem. | 1559 | * for the generic AC97 subsystem. |
1510 | */ | 1560 | */ |
1511 | if (rtd->codec_dai->driver->ac97_control && !rtd->codec->ac97_registered) { | 1561 | if (codec_dai->driver->ac97_control && !codec->ac97_registered) { |
1512 | /* | 1562 | /* |
1513 | * It is possible that the AC97 device is already registered to | 1563 | * It is possible that the AC97 device is already registered to |
1514 | * the device subsystem. This happens when the device is created | 1564 | * the device subsystem. This happens when the device is created |
@@ -1517,28 +1567,38 @@ static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | |||
1517 | * | 1567 | * |
1518 | * In those cases we don't try to register the device again. | 1568 | * In those cases we don't try to register the device again. |
1519 | */ | 1569 | */ |
1520 | if (!rtd->codec->ac97_created) | 1570 | if (!codec->ac97_created) |
1521 | return 0; | 1571 | return 0; |
1522 | 1572 | ||
1523 | ret = soc_ac97_dev_register(rtd->codec); | 1573 | ret = soc_ac97_dev_register(codec); |
1524 | if (ret < 0) { | 1574 | if (ret < 0) { |
1525 | dev_err(rtd->codec->dev, | 1575 | dev_err(codec->dev, |
1526 | "ASoC: AC97 device register failed: %d\n", ret); | 1576 | "ASoC: AC97 device register failed: %d\n", ret); |
1527 | return ret; | 1577 | return ret; |
1528 | } | 1578 | } |
1529 | 1579 | ||
1530 | rtd->codec->ac97_registered = 1; | 1580 | codec->ac97_registered = 1; |
1531 | } | 1581 | } |
1532 | return 0; | 1582 | return 0; |
1533 | } | 1583 | } |
1534 | 1584 | ||
1535 | static void soc_unregister_ac97_dai_link(struct snd_soc_codec *codec) | 1585 | static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) |
1586 | { | ||
1587 | return soc_register_ac97_codec(rtd->codec, rtd->codec_dai); | ||
1588 | } | ||
1589 | |||
1590 | static void soc_unregister_ac97_codec(struct snd_soc_codec *codec) | ||
1536 | { | 1591 | { |
1537 | if (codec->ac97_registered) { | 1592 | if (codec->ac97_registered) { |
1538 | soc_ac97_dev_unregister(codec); | 1593 | soc_ac97_dev_unregister(codec); |
1539 | codec->ac97_registered = 0; | 1594 | codec->ac97_registered = 0; |
1540 | } | 1595 | } |
1541 | } | 1596 | } |
1597 | |||
1598 | static void soc_unregister_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | ||
1599 | { | ||
1600 | soc_unregister_ac97_codec(rtd->codec); | ||
1601 | } | ||
1542 | #endif | 1602 | #endif |
1543 | 1603 | ||
1544 | static int soc_check_aux_dev(struct snd_soc_card *card, int num) | 1604 | static int soc_check_aux_dev(struct snd_soc_card *card, int num) |
@@ -1837,7 +1897,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) | |||
1837 | dev_err(card->dev, | 1897 | dev_err(card->dev, |
1838 | "ASoC: failed to register AC97: %d\n", ret); | 1898 | "ASoC: failed to register AC97: %d\n", ret); |
1839 | while (--i >= 0) | 1899 | while (--i >= 0) |
1840 | soc_unregister_ac97_dai_link(card->rtd[i].codec); | 1900 | soc_unregister_ac97_dai_link(&card->rtd[i]); |
1841 | goto probe_aux_dev_err; | 1901 | goto probe_aux_dev_err; |
1842 | } | 1902 | } |
1843 | } | 1903 | } |
@@ -1980,92 +2040,6 @@ static struct platform_driver soc_driver = { | |||
1980 | }; | 2040 | }; |
1981 | 2041 | ||
1982 | /** | 2042 | /** |
1983 | * snd_soc_codec_volatile_register: Report if a register is volatile. | ||
1984 | * | ||
1985 | * @codec: CODEC to query. | ||
1986 | * @reg: Register to query. | ||
1987 | * | ||
1988 | * Boolean function indiciating if a CODEC register is volatile. | ||
1989 | */ | ||
1990 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, | ||
1991 | unsigned int reg) | ||
1992 | { | ||
1993 | if (codec->volatile_register) | ||
1994 | return codec->volatile_register(codec, reg); | ||
1995 | else | ||
1996 | return 0; | ||
1997 | } | ||
1998 | EXPORT_SYMBOL_GPL(snd_soc_codec_volatile_register); | ||
1999 | |||
2000 | /** | ||
2001 | * snd_soc_codec_readable_register: Report if a register is readable. | ||
2002 | * | ||
2003 | * @codec: CODEC to query. | ||
2004 | * @reg: Register to query. | ||
2005 | * | ||
2006 | * Boolean function indicating if a CODEC register is readable. | ||
2007 | */ | ||
2008 | int snd_soc_codec_readable_register(struct snd_soc_codec *codec, | ||
2009 | unsigned int reg) | ||
2010 | { | ||
2011 | if (codec->readable_register) | ||
2012 | return codec->readable_register(codec, reg); | ||
2013 | else | ||
2014 | return 1; | ||
2015 | } | ||
2016 | EXPORT_SYMBOL_GPL(snd_soc_codec_readable_register); | ||
2017 | |||
2018 | /** | ||
2019 | * snd_soc_codec_writable_register: Report if a register is writable. | ||
2020 | * | ||
2021 | * @codec: CODEC to query. | ||
2022 | * @reg: Register to query. | ||
2023 | * | ||
2024 | * Boolean function indicating if a CODEC register is writable. | ||
2025 | */ | ||
2026 | int snd_soc_codec_writable_register(struct snd_soc_codec *codec, | ||
2027 | unsigned int reg) | ||
2028 | { | ||
2029 | if (codec->writable_register) | ||
2030 | return codec->writable_register(codec, reg); | ||
2031 | else | ||
2032 | return 1; | ||
2033 | } | ||
2034 | EXPORT_SYMBOL_GPL(snd_soc_codec_writable_register); | ||
2035 | |||
2036 | int snd_soc_platform_read(struct snd_soc_platform *platform, | ||
2037 | unsigned int reg) | ||
2038 | { | ||
2039 | unsigned int ret; | ||
2040 | |||
2041 | if (!platform->driver->read) { | ||
2042 | dev_err(platform->dev, "ASoC: platform has no read back\n"); | ||
2043 | return -1; | ||
2044 | } | ||
2045 | |||
2046 | ret = platform->driver->read(platform, reg); | ||
2047 | dev_dbg(platform->dev, "read %x => %x\n", reg, ret); | ||
2048 | trace_snd_soc_preg_read(platform, reg, ret); | ||
2049 | |||
2050 | return ret; | ||
2051 | } | ||
2052 | EXPORT_SYMBOL_GPL(snd_soc_platform_read); | ||
2053 | |||
2054 | int snd_soc_platform_write(struct snd_soc_platform *platform, | ||
2055 | unsigned int reg, unsigned int val) | ||
2056 | { | ||
2057 | if (!platform->driver->write) { | ||
2058 | dev_err(platform->dev, "ASoC: platform has no write back\n"); | ||
2059 | return -1; | ||
2060 | } | ||
2061 | |||
2062 | dev_dbg(platform->dev, "write %x = %x\n", reg, val); | ||
2063 | trace_snd_soc_preg_write(platform, reg, val); | ||
2064 | return platform->driver->write(platform, reg, val); | ||
2065 | } | ||
2066 | EXPORT_SYMBOL_GPL(snd_soc_platform_write); | ||
2067 | |||
2068 | /** | ||
2069 | * snd_soc_new_ac97_codec - initailise AC97 device | 2043 | * snd_soc_new_ac97_codec - initailise AC97 device |
2070 | * @codec: audio codec | 2044 | * @codec: audio codec |
2071 | * @ops: AC97 bus operations | 2045 | * @ops: AC97 bus operations |
@@ -2153,28 +2127,28 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev, | |||
2153 | p = devm_pinctrl_get(dev); | 2127 | p = devm_pinctrl_get(dev); |
2154 | if (IS_ERR(p)) { | 2128 | if (IS_ERR(p)) { |
2155 | dev_err(dev, "Failed to get pinctrl\n"); | 2129 | dev_err(dev, "Failed to get pinctrl\n"); |
2156 | return PTR_RET(p); | 2130 | return PTR_ERR(p); |
2157 | } | 2131 | } |
2158 | cfg->pctl = p; | 2132 | cfg->pctl = p; |
2159 | 2133 | ||
2160 | state = pinctrl_lookup_state(p, "ac97-reset"); | 2134 | state = pinctrl_lookup_state(p, "ac97-reset"); |
2161 | if (IS_ERR(state)) { | 2135 | if (IS_ERR(state)) { |
2162 | dev_err(dev, "Can't find pinctrl state ac97-reset\n"); | 2136 | dev_err(dev, "Can't find pinctrl state ac97-reset\n"); |
2163 | return PTR_RET(state); | 2137 | return PTR_ERR(state); |
2164 | } | 2138 | } |
2165 | cfg->pstate_reset = state; | 2139 | cfg->pstate_reset = state; |
2166 | 2140 | ||
2167 | state = pinctrl_lookup_state(p, "ac97-warm-reset"); | 2141 | state = pinctrl_lookup_state(p, "ac97-warm-reset"); |
2168 | if (IS_ERR(state)) { | 2142 | if (IS_ERR(state)) { |
2169 | dev_err(dev, "Can't find pinctrl state ac97-warm-reset\n"); | 2143 | dev_err(dev, "Can't find pinctrl state ac97-warm-reset\n"); |
2170 | return PTR_RET(state); | 2144 | return PTR_ERR(state); |
2171 | } | 2145 | } |
2172 | cfg->pstate_warm_reset = state; | 2146 | cfg->pstate_warm_reset = state; |
2173 | 2147 | ||
2174 | state = pinctrl_lookup_state(p, "ac97-running"); | 2148 | state = pinctrl_lookup_state(p, "ac97-running"); |
2175 | if (IS_ERR(state)) { | 2149 | if (IS_ERR(state)) { |
2176 | dev_err(dev, "Can't find pinctrl state ac97-running\n"); | 2150 | dev_err(dev, "Can't find pinctrl state ac97-running\n"); |
2177 | return PTR_RET(state); | 2151 | return PTR_ERR(state); |
2178 | } | 2152 | } |
2179 | cfg->pstate_run = state; | 2153 | cfg->pstate_run = state; |
2180 | 2154 | ||
@@ -2273,7 +2247,7 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) | |||
2273 | { | 2247 | { |
2274 | mutex_lock(&codec->mutex); | 2248 | mutex_lock(&codec->mutex); |
2275 | #ifdef CONFIG_SND_SOC_AC97_BUS | 2249 | #ifdef CONFIG_SND_SOC_AC97_BUS |
2276 | soc_unregister_ac97_dai_link(codec); | 2250 | soc_unregister_ac97_codec(codec); |
2277 | #endif | 2251 | #endif |
2278 | kfree(codec->ac97->bus); | 2252 | kfree(codec->ac97->bus); |
2279 | kfree(codec->ac97); | 2253 | kfree(codec->ac97); |
@@ -2283,118 +2257,6 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) | |||
2283 | } | 2257 | } |
2284 | EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); | 2258 | EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); |
2285 | 2259 | ||
2286 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg) | ||
2287 | { | ||
2288 | unsigned int ret; | ||
2289 | |||
2290 | ret = codec->read(codec, reg); | ||
2291 | dev_dbg(codec->dev, "read %x => %x\n", reg, ret); | ||
2292 | trace_snd_soc_reg_read(codec, reg, ret); | ||
2293 | |||
2294 | return ret; | ||
2295 | } | ||
2296 | EXPORT_SYMBOL_GPL(snd_soc_read); | ||
2297 | |||
2298 | unsigned int snd_soc_write(struct snd_soc_codec *codec, | ||
2299 | unsigned int reg, unsigned int val) | ||
2300 | { | ||
2301 | dev_dbg(codec->dev, "write %x = %x\n", reg, val); | ||
2302 | trace_snd_soc_reg_write(codec, reg, val); | ||
2303 | return codec->write(codec, reg, val); | ||
2304 | } | ||
2305 | EXPORT_SYMBOL_GPL(snd_soc_write); | ||
2306 | |||
2307 | /** | ||
2308 | * snd_soc_update_bits - update codec register bits | ||
2309 | * @codec: audio codec | ||
2310 | * @reg: codec register | ||
2311 | * @mask: register mask | ||
2312 | * @value: new value | ||
2313 | * | ||
2314 | * Writes new register value. | ||
2315 | * | ||
2316 | * Returns 1 for change, 0 for no change, or negative error code. | ||
2317 | */ | ||
2318 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, | ||
2319 | unsigned int mask, unsigned int value) | ||
2320 | { | ||
2321 | bool change; | ||
2322 | unsigned int old, new; | ||
2323 | int ret; | ||
2324 | |||
2325 | if (codec->using_regmap) { | ||
2326 | ret = regmap_update_bits_check(codec->control_data, reg, | ||
2327 | mask, value, &change); | ||
2328 | } else { | ||
2329 | ret = snd_soc_read(codec, reg); | ||
2330 | if (ret < 0) | ||
2331 | return ret; | ||
2332 | |||
2333 | old = ret; | ||
2334 | new = (old & ~mask) | (value & mask); | ||
2335 | change = old != new; | ||
2336 | if (change) | ||
2337 | ret = snd_soc_write(codec, reg, new); | ||
2338 | } | ||
2339 | |||
2340 | if (ret < 0) | ||
2341 | return ret; | ||
2342 | |||
2343 | return change; | ||
2344 | } | ||
2345 | EXPORT_SYMBOL_GPL(snd_soc_update_bits); | ||
2346 | |||
2347 | /** | ||
2348 | * snd_soc_update_bits_locked - update codec register bits | ||
2349 | * @codec: audio codec | ||
2350 | * @reg: codec register | ||
2351 | * @mask: register mask | ||
2352 | * @value: new value | ||
2353 | * | ||
2354 | * Writes new register value, and takes the codec mutex. | ||
2355 | * | ||
2356 | * Returns 1 for change else 0. | ||
2357 | */ | ||
2358 | int snd_soc_update_bits_locked(struct snd_soc_codec *codec, | ||
2359 | unsigned short reg, unsigned int mask, | ||
2360 | unsigned int value) | ||
2361 | { | ||
2362 | int change; | ||
2363 | |||
2364 | mutex_lock(&codec->mutex); | ||
2365 | change = snd_soc_update_bits(codec, reg, mask, value); | ||
2366 | mutex_unlock(&codec->mutex); | ||
2367 | |||
2368 | return change; | ||
2369 | } | ||
2370 | EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked); | ||
2371 | |||
2372 | /** | ||
2373 | * snd_soc_test_bits - test register for change | ||
2374 | * @codec: audio codec | ||
2375 | * @reg: codec register | ||
2376 | * @mask: register mask | ||
2377 | * @value: new value | ||
2378 | * | ||
2379 | * Tests a register with a new value and checks if the new value is | ||
2380 | * different from the old value. | ||
2381 | * | ||
2382 | * Returns 1 for change else 0. | ||
2383 | */ | ||
2384 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, | ||
2385 | unsigned int mask, unsigned int value) | ||
2386 | { | ||
2387 | int change; | ||
2388 | unsigned int old, new; | ||
2389 | |||
2390 | old = snd_soc_read(codec, reg); | ||
2391 | new = (old & ~mask) | value; | ||
2392 | change = old != new; | ||
2393 | |||
2394 | return change; | ||
2395 | } | ||
2396 | EXPORT_SYMBOL_GPL(snd_soc_test_bits); | ||
2397 | |||
2398 | /** | 2260 | /** |
2399 | * snd_soc_cnew - create new control | 2261 | * snd_soc_cnew - create new control |
2400 | * @_template: control template | 2262 | * @_template: control template |
@@ -2491,7 +2353,7 @@ int snd_soc_add_codec_controls(struct snd_soc_codec *codec, | |||
2491 | struct snd_card *card = codec->card->snd_card; | 2353 | struct snd_card *card = codec->card->snd_card; |
2492 | 2354 | ||
2493 | return snd_soc_add_controls(card, codec->dev, controls, num_controls, | 2355 | return snd_soc_add_controls(card, codec->dev, controls, num_controls, |
2494 | codec->name_prefix, codec); | 2356 | codec->name_prefix, &codec->component); |
2495 | } | 2357 | } |
2496 | EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); | 2358 | EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); |
2497 | 2359 | ||
@@ -2511,7 +2373,7 @@ int snd_soc_add_platform_controls(struct snd_soc_platform *platform, | |||
2511 | struct snd_card *card = platform->card->snd_card; | 2373 | struct snd_card *card = platform->card->snd_card; |
2512 | 2374 | ||
2513 | return snd_soc_add_controls(card, platform->dev, controls, num_controls, | 2375 | return snd_soc_add_controls(card, platform->dev, controls, num_controls, |
2514 | NULL, platform); | 2376 | NULL, &platform->component); |
2515 | } | 2377 | } |
2516 | EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); | 2378 | EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); |
2517 | 2379 | ||
@@ -2595,12 +2457,15 @@ EXPORT_SYMBOL_GPL(snd_soc_info_enum_double); | |||
2595 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, | 2457 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, |
2596 | struct snd_ctl_elem_value *ucontrol) | 2458 | struct snd_ctl_elem_value *ucontrol) |
2597 | { | 2459 | { |
2598 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2460 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
2599 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 2461 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
2600 | unsigned int val, item; | 2462 | unsigned int val, item; |
2601 | unsigned int reg_val; | 2463 | unsigned int reg_val; |
2464 | int ret; | ||
2602 | 2465 | ||
2603 | reg_val = snd_soc_read(codec, e->reg); | 2466 | ret = snd_soc_component_read(component, e->reg, ®_val); |
2467 | if (ret) | ||
2468 | return ret; | ||
2604 | val = (reg_val >> e->shift_l) & e->mask; | 2469 | val = (reg_val >> e->shift_l) & e->mask; |
2605 | item = snd_soc_enum_val_to_item(e, val); | 2470 | item = snd_soc_enum_val_to_item(e, val); |
2606 | ucontrol->value.enumerated.item[0] = item; | 2471 | ucontrol->value.enumerated.item[0] = item; |
@@ -2626,7 +2491,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_enum_double); | |||
2626 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, | 2491 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, |
2627 | struct snd_ctl_elem_value *ucontrol) | 2492 | struct snd_ctl_elem_value *ucontrol) |
2628 | { | 2493 | { |
2629 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2494 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
2630 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 2495 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
2631 | unsigned int *item = ucontrol->value.enumerated.item; | 2496 | unsigned int *item = ucontrol->value.enumerated.item; |
2632 | unsigned int val; | 2497 | unsigned int val; |
@@ -2643,38 +2508,48 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, | |||
2643 | mask |= e->mask << e->shift_r; | 2508 | mask |= e->mask << e->shift_r; |
2644 | } | 2509 | } |
2645 | 2510 | ||
2646 | return snd_soc_update_bits_locked(codec, e->reg, mask, val); | 2511 | return snd_soc_component_update_bits(component, e->reg, mask, val); |
2647 | } | 2512 | } |
2648 | EXPORT_SYMBOL_GPL(snd_soc_put_enum_double); | 2513 | EXPORT_SYMBOL_GPL(snd_soc_put_enum_double); |
2649 | 2514 | ||
2650 | /** | 2515 | /** |
2651 | * snd_soc_read_signed - Read a codec register and interprete as signed value | 2516 | * snd_soc_read_signed - Read a codec register and interprete as signed value |
2652 | * @codec: codec | 2517 | * @component: component |
2653 | * @reg: Register to read | 2518 | * @reg: Register to read |
2654 | * @mask: Mask to use after shifting the register value | 2519 | * @mask: Mask to use after shifting the register value |
2655 | * @shift: Right shift of register value | 2520 | * @shift: Right shift of register value |
2656 | * @sign_bit: Bit that describes if a number is negative or not. | 2521 | * @sign_bit: Bit that describes if a number is negative or not. |
2522 | * @signed_val: Pointer to where the read value should be stored | ||
2657 | * | 2523 | * |
2658 | * This functions reads a codec register. The register value is shifted right | 2524 | * This functions reads a codec register. The register value is shifted right |
2659 | * by 'shift' bits and masked with the given 'mask'. Afterwards it translates | 2525 | * by 'shift' bits and masked with the given 'mask'. Afterwards it translates |
2660 | * the given registervalue into a signed integer if sign_bit is non-zero. | 2526 | * the given registervalue into a signed integer if sign_bit is non-zero. |
2661 | * | 2527 | * |
2662 | * Returns the register value as signed int. | 2528 | * Returns 0 on sucess, otherwise an error value |
2663 | */ | 2529 | */ |
2664 | static int snd_soc_read_signed(struct snd_soc_codec *codec, unsigned int reg, | 2530 | static int snd_soc_read_signed(struct snd_soc_component *component, |
2665 | unsigned int mask, unsigned int shift, unsigned int sign_bit) | 2531 | unsigned int reg, unsigned int mask, unsigned int shift, |
2532 | unsigned int sign_bit, int *signed_val) | ||
2666 | { | 2533 | { |
2667 | int ret; | 2534 | int ret; |
2668 | unsigned int val; | 2535 | unsigned int val; |
2669 | 2536 | ||
2670 | val = (snd_soc_read(codec, reg) >> shift) & mask; | 2537 | ret = snd_soc_component_read(component, reg, &val); |
2538 | if (ret < 0) | ||
2539 | return ret; | ||
2671 | 2540 | ||
2672 | if (!sign_bit) | 2541 | val = (val >> shift) & mask; |
2673 | return val; | 2542 | |
2543 | if (!sign_bit) { | ||
2544 | *signed_val = val; | ||
2545 | return 0; | ||
2546 | } | ||
2674 | 2547 | ||
2675 | /* non-negative number */ | 2548 | /* non-negative number */ |
2676 | if (!(val & BIT(sign_bit))) | 2549 | if (!(val & BIT(sign_bit))) { |
2677 | return val; | 2550 | *signed_val = val; |
2551 | return 0; | ||
2552 | } | ||
2678 | 2553 | ||
2679 | ret = val; | 2554 | ret = val; |
2680 | 2555 | ||
@@ -2686,7 +2561,9 @@ static int snd_soc_read_signed(struct snd_soc_codec *codec, unsigned int reg, | |||
2686 | */ | 2561 | */ |
2687 | ret |= ~((int)(BIT(sign_bit) - 1)); | 2562 | ret |= ~((int)(BIT(sign_bit) - 1)); |
2688 | 2563 | ||
2689 | return ret; | 2564 | *signed_val = ret; |
2565 | |||
2566 | return 0; | ||
2690 | } | 2567 | } |
2691 | 2568 | ||
2692 | /** | 2569 | /** |
@@ -2735,9 +2612,9 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw); | |||
2735 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, | 2612 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, |
2736 | struct snd_ctl_elem_value *ucontrol) | 2613 | struct snd_ctl_elem_value *ucontrol) |
2737 | { | 2614 | { |
2615 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
2738 | struct soc_mixer_control *mc = | 2616 | struct soc_mixer_control *mc = |
2739 | (struct soc_mixer_control *)kcontrol->private_value; | 2617 | (struct soc_mixer_control *)kcontrol->private_value; |
2740 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2741 | unsigned int reg = mc->reg; | 2618 | unsigned int reg = mc->reg; |
2742 | unsigned int reg2 = mc->rreg; | 2619 | unsigned int reg2 = mc->rreg; |
2743 | unsigned int shift = mc->shift; | 2620 | unsigned int shift = mc->shift; |
@@ -2747,25 +2624,32 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, | |||
2747 | int sign_bit = mc->sign_bit; | 2624 | int sign_bit = mc->sign_bit; |
2748 | unsigned int mask = (1 << fls(max)) - 1; | 2625 | unsigned int mask = (1 << fls(max)) - 1; |
2749 | unsigned int invert = mc->invert; | 2626 | unsigned int invert = mc->invert; |
2627 | int val; | ||
2628 | int ret; | ||
2750 | 2629 | ||
2751 | if (sign_bit) | 2630 | if (sign_bit) |
2752 | mask = BIT(sign_bit + 1) - 1; | 2631 | mask = BIT(sign_bit + 1) - 1; |
2753 | 2632 | ||
2754 | ucontrol->value.integer.value[0] = snd_soc_read_signed(codec, reg, mask, | 2633 | ret = snd_soc_read_signed(component, reg, mask, shift, sign_bit, &val); |
2755 | shift, sign_bit) - min; | 2634 | if (ret) |
2635 | return ret; | ||
2636 | |||
2637 | ucontrol->value.integer.value[0] = val - min; | ||
2756 | if (invert) | 2638 | if (invert) |
2757 | ucontrol->value.integer.value[0] = | 2639 | ucontrol->value.integer.value[0] = |
2758 | max - ucontrol->value.integer.value[0]; | 2640 | max - ucontrol->value.integer.value[0]; |
2759 | 2641 | ||
2760 | if (snd_soc_volsw_is_stereo(mc)) { | 2642 | if (snd_soc_volsw_is_stereo(mc)) { |
2761 | if (reg == reg2) | 2643 | if (reg == reg2) |
2762 | ucontrol->value.integer.value[1] = | 2644 | ret = snd_soc_read_signed(component, reg, mask, rshift, |
2763 | snd_soc_read_signed(codec, reg, mask, rshift, | 2645 | sign_bit, &val); |
2764 | sign_bit) - min; | ||
2765 | else | 2646 | else |
2766 | ucontrol->value.integer.value[1] = | 2647 | ret = snd_soc_read_signed(component, reg2, mask, shift, |
2767 | snd_soc_read_signed(codec, reg2, mask, shift, | 2648 | sign_bit, &val); |
2768 | sign_bit) - min; | 2649 | if (ret) |
2650 | return ret; | ||
2651 | |||
2652 | ucontrol->value.integer.value[1] = val - min; | ||
2769 | if (invert) | 2653 | if (invert) |
2770 | ucontrol->value.integer.value[1] = | 2654 | ucontrol->value.integer.value[1] = |
2771 | max - ucontrol->value.integer.value[1]; | 2655 | max - ucontrol->value.integer.value[1]; |
@@ -2788,9 +2672,9 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw); | |||
2788 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, | 2672 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, |
2789 | struct snd_ctl_elem_value *ucontrol) | 2673 | struct snd_ctl_elem_value *ucontrol) |
2790 | { | 2674 | { |
2675 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
2791 | struct soc_mixer_control *mc = | 2676 | struct soc_mixer_control *mc = |
2792 | (struct soc_mixer_control *)kcontrol->private_value; | 2677 | (struct soc_mixer_control *)kcontrol->private_value; |
2793 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2794 | unsigned int reg = mc->reg; | 2678 | unsigned int reg = mc->reg; |
2795 | unsigned int reg2 = mc->rreg; | 2679 | unsigned int reg2 = mc->rreg; |
2796 | unsigned int shift = mc->shift; | 2680 | unsigned int shift = mc->shift; |
@@ -2825,12 +2709,13 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, | |||
2825 | type_2r = true; | 2709 | type_2r = true; |
2826 | } | 2710 | } |
2827 | } | 2711 | } |
2828 | err = snd_soc_update_bits_locked(codec, reg, val_mask, val); | 2712 | err = snd_soc_component_update_bits(component, reg, val_mask, val); |
2829 | if (err < 0) | 2713 | if (err < 0) |
2830 | return err; | 2714 | return err; |
2831 | 2715 | ||
2832 | if (type_2r) | 2716 | if (type_2r) |
2833 | err = snd_soc_update_bits_locked(codec, reg2, val_mask, val2); | 2717 | err = snd_soc_component_update_bits(component, reg2, val_mask, |
2718 | val2); | ||
2834 | 2719 | ||
2835 | return err; | 2720 | return err; |
2836 | } | 2721 | } |
@@ -2849,10 +2734,9 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw); | |||
2849 | int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, | 2734 | int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, |
2850 | struct snd_ctl_elem_value *ucontrol) | 2735 | struct snd_ctl_elem_value *ucontrol) |
2851 | { | 2736 | { |
2852 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2737 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
2853 | struct soc_mixer_control *mc = | 2738 | struct soc_mixer_control *mc = |
2854 | (struct soc_mixer_control *)kcontrol->private_value; | 2739 | (struct soc_mixer_control *)kcontrol->private_value; |
2855 | |||
2856 | unsigned int reg = mc->reg; | 2740 | unsigned int reg = mc->reg; |
2857 | unsigned int reg2 = mc->rreg; | 2741 | unsigned int reg2 = mc->rreg; |
2858 | unsigned int shift = mc->shift; | 2742 | unsigned int shift = mc->shift; |
@@ -2860,13 +2744,23 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, | |||
2860 | int max = mc->max; | 2744 | int max = mc->max; |
2861 | int min = mc->min; | 2745 | int min = mc->min; |
2862 | int mask = (1 << (fls(min + max) - 1)) - 1; | 2746 | int mask = (1 << (fls(min + max) - 1)) - 1; |
2747 | unsigned int val; | ||
2748 | int ret; | ||
2863 | 2749 | ||
2864 | ucontrol->value.integer.value[0] = | 2750 | ret = snd_soc_component_read(component, reg, &val); |
2865 | ((snd_soc_read(codec, reg) >> shift) - min) & mask; | 2751 | if (ret < 0) |
2752 | return ret; | ||
2866 | 2753 | ||
2867 | if (snd_soc_volsw_is_stereo(mc)) | 2754 | ucontrol->value.integer.value[0] = ((val >> shift) - min) & mask; |
2868 | ucontrol->value.integer.value[1] = | 2755 | |
2869 | ((snd_soc_read(codec, reg2) >> rshift) - min) & mask; | 2756 | if (snd_soc_volsw_is_stereo(mc)) { |
2757 | ret = snd_soc_component_read(component, reg2, &val); | ||
2758 | if (ret < 0) | ||
2759 | return ret; | ||
2760 | |||
2761 | val = ((val >> rshift) - min) & mask; | ||
2762 | ucontrol->value.integer.value[1] = val; | ||
2763 | } | ||
2870 | 2764 | ||
2871 | return 0; | 2765 | return 0; |
2872 | } | 2766 | } |
@@ -2884,7 +2778,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_sx); | |||
2884 | int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, | 2778 | int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, |
2885 | struct snd_ctl_elem_value *ucontrol) | 2779 | struct snd_ctl_elem_value *ucontrol) |
2886 | { | 2780 | { |
2887 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2781 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
2888 | struct soc_mixer_control *mc = | 2782 | struct soc_mixer_control *mc = |
2889 | (struct soc_mixer_control *)kcontrol->private_value; | 2783 | (struct soc_mixer_control *)kcontrol->private_value; |
2890 | 2784 | ||
@@ -2896,13 +2790,13 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, | |||
2896 | int min = mc->min; | 2790 | int min = mc->min; |
2897 | int mask = (1 << (fls(min + max) - 1)) - 1; | 2791 | int mask = (1 << (fls(min + max) - 1)) - 1; |
2898 | int err = 0; | 2792 | int err = 0; |
2899 | unsigned short val, val_mask, val2 = 0; | 2793 | unsigned int val, val_mask, val2 = 0; |
2900 | 2794 | ||
2901 | val_mask = mask << shift; | 2795 | val_mask = mask << shift; |
2902 | val = (ucontrol->value.integer.value[0] + min) & mask; | 2796 | val = (ucontrol->value.integer.value[0] + min) & mask; |
2903 | val = val << shift; | 2797 | val = val << shift; |
2904 | 2798 | ||
2905 | err = snd_soc_update_bits_locked(codec, reg, val_mask, val); | 2799 | err = snd_soc_component_update_bits(component, reg, val_mask, val); |
2906 | if (err < 0) | 2800 | if (err < 0) |
2907 | return err; | 2801 | return err; |
2908 | 2802 | ||
@@ -2911,10 +2805,10 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, | |||
2911 | val2 = (ucontrol->value.integer.value[1] + min) & mask; | 2805 | val2 = (ucontrol->value.integer.value[1] + min) & mask; |
2912 | val2 = val2 << rshift; | 2806 | val2 = val2 << rshift; |
2913 | 2807 | ||
2914 | if (snd_soc_update_bits_locked(codec, reg2, val_mask, val2)) | 2808 | err = snd_soc_component_update_bits(component, reg2, val_mask, |
2915 | return err; | 2809 | val2); |
2916 | } | 2810 | } |
2917 | return 0; | 2811 | return err; |
2918 | } | 2812 | } |
2919 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx); | 2813 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx); |
2920 | 2814 | ||
@@ -2961,10 +2855,15 @@ int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, | |||
2961 | { | 2855 | { |
2962 | struct soc_mixer_control *mc = | 2856 | struct soc_mixer_control *mc = |
2963 | (struct soc_mixer_control *)kcontrol->private_value; | 2857 | (struct soc_mixer_control *)kcontrol->private_value; |
2964 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2858 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
2965 | unsigned int reg = mc->reg; | 2859 | unsigned int reg = mc->reg; |
2860 | unsigned int val; | ||
2966 | int min = mc->min; | 2861 | int min = mc->min; |
2967 | int val = snd_soc_read(codec, reg); | 2862 | int ret; |
2863 | |||
2864 | ret = snd_soc_component_read(component, reg, &val); | ||
2865 | if (ret) | ||
2866 | return ret; | ||
2968 | 2867 | ||
2969 | ucontrol->value.integer.value[0] = | 2868 | ucontrol->value.integer.value[0] = |
2970 | ((signed char)(val & 0xff))-min; | 2869 | ((signed char)(val & 0xff))-min; |
@@ -2988,7 +2887,7 @@ int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, | |||
2988 | { | 2887 | { |
2989 | struct soc_mixer_control *mc = | 2888 | struct soc_mixer_control *mc = |
2990 | (struct soc_mixer_control *)kcontrol->private_value; | 2889 | (struct soc_mixer_control *)kcontrol->private_value; |
2991 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2890 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
2992 | unsigned int reg = mc->reg; | 2891 | unsigned int reg = mc->reg; |
2993 | int min = mc->min; | 2892 | int min = mc->min; |
2994 | unsigned int val; | 2893 | unsigned int val; |
@@ -2996,7 +2895,7 @@ int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, | |||
2996 | val = (ucontrol->value.integer.value[0]+min) & 0xff; | 2895 | val = (ucontrol->value.integer.value[0]+min) & 0xff; |
2997 | val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8; | 2896 | val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8; |
2998 | 2897 | ||
2999 | return snd_soc_update_bits_locked(codec, reg, 0xffff, val); | 2898 | return snd_soc_component_update_bits(component, reg, 0xffff, val); |
3000 | } | 2899 | } |
3001 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8); | 2900 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8); |
3002 | 2901 | ||
@@ -3045,7 +2944,7 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, | |||
3045 | { | 2944 | { |
3046 | struct soc_mixer_control *mc = | 2945 | struct soc_mixer_control *mc = |
3047 | (struct soc_mixer_control *)kcontrol->private_value; | 2946 | (struct soc_mixer_control *)kcontrol->private_value; |
3048 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 2947 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
3049 | unsigned int reg = mc->reg; | 2948 | unsigned int reg = mc->reg; |
3050 | unsigned int rreg = mc->rreg; | 2949 | unsigned int rreg = mc->rreg; |
3051 | unsigned int shift = mc->shift; | 2950 | unsigned int shift = mc->shift; |
@@ -3062,7 +2961,7 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, | |||
3062 | val_mask = mask << shift; | 2961 | val_mask = mask << shift; |
3063 | val = val << shift; | 2962 | val = val << shift; |
3064 | 2963 | ||
3065 | ret = snd_soc_update_bits_locked(codec, reg, val_mask, val); | 2964 | ret = snd_soc_component_update_bits(component, reg, val_mask, val); |
3066 | if (ret < 0) | 2965 | if (ret < 0) |
3067 | return ret; | 2966 | return ret; |
3068 | 2967 | ||
@@ -3073,7 +2972,8 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, | |||
3073 | val_mask = mask << shift; | 2972 | val_mask = mask << shift; |
3074 | val = val << shift; | 2973 | val = val << shift; |
3075 | 2974 | ||
3076 | ret = snd_soc_update_bits_locked(codec, rreg, val_mask, val); | 2975 | ret = snd_soc_component_update_bits(component, rreg, val_mask, |
2976 | val); | ||
3077 | } | 2977 | } |
3078 | 2978 | ||
3079 | return ret; | 2979 | return ret; |
@@ -3092,9 +2992,9 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw_range); | |||
3092 | int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, | 2992 | int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, |
3093 | struct snd_ctl_elem_value *ucontrol) | 2993 | struct snd_ctl_elem_value *ucontrol) |
3094 | { | 2994 | { |
2995 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
3095 | struct soc_mixer_control *mc = | 2996 | struct soc_mixer_control *mc = |
3096 | (struct soc_mixer_control *)kcontrol->private_value; | 2997 | (struct soc_mixer_control *)kcontrol->private_value; |
3097 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3098 | unsigned int reg = mc->reg; | 2998 | unsigned int reg = mc->reg; |
3099 | unsigned int rreg = mc->rreg; | 2999 | unsigned int rreg = mc->rreg; |
3100 | unsigned int shift = mc->shift; | 3000 | unsigned int shift = mc->shift; |
@@ -3102,9 +3002,14 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, | |||
3102 | int max = mc->max; | 3002 | int max = mc->max; |
3103 | unsigned int mask = (1 << fls(max)) - 1; | 3003 | unsigned int mask = (1 << fls(max)) - 1; |
3104 | unsigned int invert = mc->invert; | 3004 | unsigned int invert = mc->invert; |
3005 | unsigned int val; | ||
3006 | int ret; | ||
3105 | 3007 | ||
3106 | ucontrol->value.integer.value[0] = | 3008 | ret = snd_soc_component_read(component, reg, &val); |
3107 | (snd_soc_read(codec, reg) >> shift) & mask; | 3009 | if (ret) |
3010 | return ret; | ||
3011 | |||
3012 | ucontrol->value.integer.value[0] = (val >> shift) & mask; | ||
3108 | if (invert) | 3013 | if (invert) |
3109 | ucontrol->value.integer.value[0] = | 3014 | ucontrol->value.integer.value[0] = |
3110 | max - ucontrol->value.integer.value[0]; | 3015 | max - ucontrol->value.integer.value[0]; |
@@ -3112,8 +3017,11 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, | |||
3112 | ucontrol->value.integer.value[0] - min; | 3017 | ucontrol->value.integer.value[0] - min; |
3113 | 3018 | ||
3114 | if (snd_soc_volsw_is_stereo(mc)) { | 3019 | if (snd_soc_volsw_is_stereo(mc)) { |
3115 | ucontrol->value.integer.value[1] = | 3020 | ret = snd_soc_component_read(component, rreg, &val); |
3116 | (snd_soc_read(codec, rreg) >> shift) & mask; | 3021 | if (ret) |
3022 | return ret; | ||
3023 | |||
3024 | ucontrol->value.integer.value[1] = (val >> shift) & mask; | ||
3117 | if (invert) | 3025 | if (invert) |
3118 | ucontrol->value.integer.value[1] = | 3026 | ucontrol->value.integer.value[1] = |
3119 | max - ucontrol->value.integer.value[1]; | 3027 | max - ucontrol->value.integer.value[1]; |
@@ -3167,11 +3075,11 @@ EXPORT_SYMBOL_GPL(snd_soc_limit_volume); | |||
3167 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, | 3075 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, |
3168 | struct snd_ctl_elem_info *uinfo) | 3076 | struct snd_ctl_elem_info *uinfo) |
3169 | { | 3077 | { |
3170 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 3078 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); |
3171 | struct soc_bytes *params = (void *)kcontrol->private_value; | 3079 | struct soc_bytes *params = (void *)kcontrol->private_value; |
3172 | 3080 | ||
3173 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; | 3081 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; |
3174 | uinfo->count = params->num_regs * codec->val_bytes; | 3082 | uinfo->count = params->num_regs * component->val_bytes; |
3175 | 3083 | ||
3176 | return 0; | 3084 | return 0; |
3177 | } | 3085 | } |
@@ -3180,20 +3088,20 @@ EXPORT_SYMBOL_GPL(snd_soc_bytes_info); | |||
3180 | int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, | 3088 | int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, |
3181 | struct snd_ctl_elem_value *ucontrol) | 3089 | struct snd_ctl_elem_value *ucontrol) |
3182 | { | 3090 | { |
3091 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
3183 | struct soc_bytes *params = (void *)kcontrol->private_value; | 3092 | struct soc_bytes *params = (void *)kcontrol->private_value; |
3184 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3185 | int ret; | 3093 | int ret; |
3186 | 3094 | ||
3187 | if (codec->using_regmap) | 3095 | if (component->regmap) |
3188 | ret = regmap_raw_read(codec->control_data, params->base, | 3096 | ret = regmap_raw_read(component->regmap, params->base, |
3189 | ucontrol->value.bytes.data, | 3097 | ucontrol->value.bytes.data, |
3190 | params->num_regs * codec->val_bytes); | 3098 | params->num_regs * component->val_bytes); |
3191 | else | 3099 | else |
3192 | ret = -EINVAL; | 3100 | ret = -EINVAL; |
3193 | 3101 | ||
3194 | /* Hide any masked bytes to ensure consistent data reporting */ | 3102 | /* Hide any masked bytes to ensure consistent data reporting */ |
3195 | if (ret == 0 && params->mask) { | 3103 | if (ret == 0 && params->mask) { |
3196 | switch (codec->val_bytes) { | 3104 | switch (component->val_bytes) { |
3197 | case 1: | 3105 | case 1: |
3198 | ucontrol->value.bytes.data[0] &= ~params->mask; | 3106 | ucontrol->value.bytes.data[0] &= ~params->mask; |
3199 | break; | 3107 | break; |
@@ -3217,16 +3125,16 @@ EXPORT_SYMBOL_GPL(snd_soc_bytes_get); | |||
3217 | int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | 3125 | int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, |
3218 | struct snd_ctl_elem_value *ucontrol) | 3126 | struct snd_ctl_elem_value *ucontrol) |
3219 | { | 3127 | { |
3128 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
3220 | struct soc_bytes *params = (void *)kcontrol->private_value; | 3129 | struct soc_bytes *params = (void *)kcontrol->private_value; |
3221 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3222 | int ret, len; | 3130 | int ret, len; |
3223 | unsigned int val, mask; | 3131 | unsigned int val, mask; |
3224 | void *data; | 3132 | void *data; |
3225 | 3133 | ||
3226 | if (!codec->using_regmap) | 3134 | if (!component->regmap) |
3227 | return -EINVAL; | 3135 | return -EINVAL; |
3228 | 3136 | ||
3229 | len = params->num_regs * codec->val_bytes; | 3137 | len = params->num_regs * component->val_bytes; |
3230 | 3138 | ||
3231 | data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA); | 3139 | data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA); |
3232 | if (!data) | 3140 | if (!data) |
@@ -3238,27 +3146,27 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | |||
3238 | * copy. | 3146 | * copy. |
3239 | */ | 3147 | */ |
3240 | if (params->mask) { | 3148 | if (params->mask) { |
3241 | ret = regmap_read(codec->control_data, params->base, &val); | 3149 | ret = regmap_read(component->regmap, params->base, &val); |
3242 | if (ret != 0) | 3150 | if (ret != 0) |
3243 | goto out; | 3151 | goto out; |
3244 | 3152 | ||
3245 | val &= params->mask; | 3153 | val &= params->mask; |
3246 | 3154 | ||
3247 | switch (codec->val_bytes) { | 3155 | switch (component->val_bytes) { |
3248 | case 1: | 3156 | case 1: |
3249 | ((u8 *)data)[0] &= ~params->mask; | 3157 | ((u8 *)data)[0] &= ~params->mask; |
3250 | ((u8 *)data)[0] |= val; | 3158 | ((u8 *)data)[0] |= val; |
3251 | break; | 3159 | break; |
3252 | case 2: | 3160 | case 2: |
3253 | mask = ~params->mask; | 3161 | mask = ~params->mask; |
3254 | ret = regmap_parse_val(codec->control_data, | 3162 | ret = regmap_parse_val(component->regmap, |
3255 | &mask, &mask); | 3163 | &mask, &mask); |
3256 | if (ret != 0) | 3164 | if (ret != 0) |
3257 | goto out; | 3165 | goto out; |
3258 | 3166 | ||
3259 | ((u16 *)data)[0] &= mask; | 3167 | ((u16 *)data)[0] &= mask; |
3260 | 3168 | ||
3261 | ret = regmap_parse_val(codec->control_data, | 3169 | ret = regmap_parse_val(component->regmap, |
3262 | &val, &val); | 3170 | &val, &val); |
3263 | if (ret != 0) | 3171 | if (ret != 0) |
3264 | goto out; | 3172 | goto out; |
@@ -3267,14 +3175,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | |||
3267 | break; | 3175 | break; |
3268 | case 4: | 3176 | case 4: |
3269 | mask = ~params->mask; | 3177 | mask = ~params->mask; |
3270 | ret = regmap_parse_val(codec->control_data, | 3178 | ret = regmap_parse_val(component->regmap, |
3271 | &mask, &mask); | 3179 | &mask, &mask); |
3272 | if (ret != 0) | 3180 | if (ret != 0) |
3273 | goto out; | 3181 | goto out; |
3274 | 3182 | ||
3275 | ((u32 *)data)[0] &= mask; | 3183 | ((u32 *)data)[0] &= mask; |
3276 | 3184 | ||
3277 | ret = regmap_parse_val(codec->control_data, | 3185 | ret = regmap_parse_val(component->regmap, |
3278 | &val, &val); | 3186 | &val, &val); |
3279 | if (ret != 0) | 3187 | if (ret != 0) |
3280 | goto out; | 3188 | goto out; |
@@ -3287,7 +3195,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | |||
3287 | } | 3195 | } |
3288 | } | 3196 | } |
3289 | 3197 | ||
3290 | ret = regmap_raw_write(codec->control_data, params->base, | 3198 | ret = regmap_raw_write(component->regmap, params->base, |
3291 | data, len); | 3199 | data, len); |
3292 | 3200 | ||
3293 | out: | 3201 | out: |
@@ -3338,24 +3246,27 @@ EXPORT_SYMBOL_GPL(snd_soc_info_xr_sx); | |||
3338 | int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, | 3246 | int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, |
3339 | struct snd_ctl_elem_value *ucontrol) | 3247 | struct snd_ctl_elem_value *ucontrol) |
3340 | { | 3248 | { |
3249 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
3341 | struct soc_mreg_control *mc = | 3250 | struct soc_mreg_control *mc = |
3342 | (struct soc_mreg_control *)kcontrol->private_value; | 3251 | (struct soc_mreg_control *)kcontrol->private_value; |
3343 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3344 | unsigned int regbase = mc->regbase; | 3252 | unsigned int regbase = mc->regbase; |
3345 | unsigned int regcount = mc->regcount; | 3253 | unsigned int regcount = mc->regcount; |
3346 | unsigned int regwshift = codec->driver->reg_word_size * BITS_PER_BYTE; | 3254 | unsigned int regwshift = component->val_bytes * BITS_PER_BYTE; |
3347 | unsigned int regwmask = (1<<regwshift)-1; | 3255 | unsigned int regwmask = (1<<regwshift)-1; |
3348 | unsigned int invert = mc->invert; | 3256 | unsigned int invert = mc->invert; |
3349 | unsigned long mask = (1UL<<mc->nbits)-1; | 3257 | unsigned long mask = (1UL<<mc->nbits)-1; |
3350 | long min = mc->min; | 3258 | long min = mc->min; |
3351 | long max = mc->max; | 3259 | long max = mc->max; |
3352 | long val = 0; | 3260 | long val = 0; |
3353 | unsigned long regval; | 3261 | unsigned int regval; |
3354 | unsigned int i; | 3262 | unsigned int i; |
3263 | int ret; | ||
3355 | 3264 | ||
3356 | for (i = 0; i < regcount; i++) { | 3265 | for (i = 0; i < regcount; i++) { |
3357 | regval = snd_soc_read(codec, regbase+i) & regwmask; | 3266 | ret = snd_soc_component_read(component, regbase+i, ®val); |
3358 | val |= regval << (regwshift*(regcount-i-1)); | 3267 | if (ret) |
3268 | return ret; | ||
3269 | val |= (regval & regwmask) << (regwshift*(regcount-i-1)); | ||
3359 | } | 3270 | } |
3360 | val &= mask; | 3271 | val &= mask; |
3361 | if (min < 0 && val > max) | 3272 | if (min < 0 && val > max) |
@@ -3384,12 +3295,12 @@ EXPORT_SYMBOL_GPL(snd_soc_get_xr_sx); | |||
3384 | int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol, | 3295 | int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol, |
3385 | struct snd_ctl_elem_value *ucontrol) | 3296 | struct snd_ctl_elem_value *ucontrol) |
3386 | { | 3297 | { |
3298 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
3387 | struct soc_mreg_control *mc = | 3299 | struct soc_mreg_control *mc = |
3388 | (struct soc_mreg_control *)kcontrol->private_value; | 3300 | (struct soc_mreg_control *)kcontrol->private_value; |
3389 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3390 | unsigned int regbase = mc->regbase; | 3301 | unsigned int regbase = mc->regbase; |
3391 | unsigned int regcount = mc->regcount; | 3302 | unsigned int regcount = mc->regcount; |
3392 | unsigned int regwshift = codec->driver->reg_word_size * BITS_PER_BYTE; | 3303 | unsigned int regwshift = component->val_bytes * BITS_PER_BYTE; |
3393 | unsigned int regwmask = (1<<regwshift)-1; | 3304 | unsigned int regwmask = (1<<regwshift)-1; |
3394 | unsigned int invert = mc->invert; | 3305 | unsigned int invert = mc->invert; |
3395 | unsigned long mask = (1UL<<mc->nbits)-1; | 3306 | unsigned long mask = (1UL<<mc->nbits)-1; |
@@ -3404,7 +3315,7 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol, | |||
3404 | for (i = 0; i < regcount; i++) { | 3315 | for (i = 0; i < regcount; i++) { |
3405 | regval = (val >> (regwshift*(regcount-i-1))) & regwmask; | 3316 | regval = (val >> (regwshift*(regcount-i-1))) & regwmask; |
3406 | regmask = (mask >> (regwshift*(regcount-i-1))) & regwmask; | 3317 | regmask = (mask >> (regwshift*(regcount-i-1))) & regwmask; |
3407 | err = snd_soc_update_bits_locked(codec, regbase+i, | 3318 | err = snd_soc_component_update_bits(component, regbase+i, |
3408 | regmask, regval); | 3319 | regmask, regval); |
3409 | if (err < 0) | 3320 | if (err < 0) |
3410 | return err; | 3321 | return err; |
@@ -3426,14 +3337,21 @@ EXPORT_SYMBOL_GPL(snd_soc_put_xr_sx); | |||
3426 | int snd_soc_get_strobe(struct snd_kcontrol *kcontrol, | 3337 | int snd_soc_get_strobe(struct snd_kcontrol *kcontrol, |
3427 | struct snd_ctl_elem_value *ucontrol) | 3338 | struct snd_ctl_elem_value *ucontrol) |
3428 | { | 3339 | { |
3340 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
3429 | struct soc_mixer_control *mc = | 3341 | struct soc_mixer_control *mc = |
3430 | (struct soc_mixer_control *)kcontrol->private_value; | 3342 | (struct soc_mixer_control *)kcontrol->private_value; |
3431 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3432 | unsigned int reg = mc->reg; | 3343 | unsigned int reg = mc->reg; |
3433 | unsigned int shift = mc->shift; | 3344 | unsigned int shift = mc->shift; |
3434 | unsigned int mask = 1 << shift; | 3345 | unsigned int mask = 1 << shift; |
3435 | unsigned int invert = mc->invert != 0; | 3346 | unsigned int invert = mc->invert != 0; |
3436 | unsigned int val = snd_soc_read(codec, reg) & mask; | 3347 | unsigned int val; |
3348 | int ret; | ||
3349 | |||
3350 | ret = snd_soc_component_read(component, reg, &val); | ||
3351 | if (ret) | ||
3352 | return ret; | ||
3353 | |||
3354 | val &= mask; | ||
3437 | 3355 | ||
3438 | if (shift != 0 && val != 0) | 3356 | if (shift != 0 && val != 0) |
3439 | val = val >> shift; | 3357 | val = val >> shift; |
@@ -3456,9 +3374,9 @@ EXPORT_SYMBOL_GPL(snd_soc_get_strobe); | |||
3456 | int snd_soc_put_strobe(struct snd_kcontrol *kcontrol, | 3374 | int snd_soc_put_strobe(struct snd_kcontrol *kcontrol, |
3457 | struct snd_ctl_elem_value *ucontrol) | 3375 | struct snd_ctl_elem_value *ucontrol) |
3458 | { | 3376 | { |
3377 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
3459 | struct soc_mixer_control *mc = | 3378 | struct soc_mixer_control *mc = |
3460 | (struct soc_mixer_control *)kcontrol->private_value; | 3379 | (struct soc_mixer_control *)kcontrol->private_value; |
3461 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
3462 | unsigned int reg = mc->reg; | 3380 | unsigned int reg = mc->reg; |
3463 | unsigned int shift = mc->shift; | 3381 | unsigned int shift = mc->shift; |
3464 | unsigned int mask = 1 << shift; | 3382 | unsigned int mask = 1 << shift; |
@@ -3468,12 +3386,11 @@ int snd_soc_put_strobe(struct snd_kcontrol *kcontrol, | |||
3468 | unsigned int val2 = (strobe ^ invert) ? 0 : mask; | 3386 | unsigned int val2 = (strobe ^ invert) ? 0 : mask; |
3469 | int err; | 3387 | int err; |
3470 | 3388 | ||
3471 | err = snd_soc_update_bits_locked(codec, reg, mask, val1); | 3389 | err = snd_soc_component_update_bits(component, reg, mask, val1); |
3472 | if (err < 0) | 3390 | if (err < 0) |
3473 | return err; | 3391 | return err; |
3474 | 3392 | ||
3475 | err = snd_soc_update_bits_locked(codec, reg, mask, val2); | 3393 | return snd_soc_component_update_bits(component, reg, mask, val2); |
3476 | return err; | ||
3477 | } | 3394 | } |
3478 | EXPORT_SYMBOL_GPL(snd_soc_put_strobe); | 3395 | EXPORT_SYMBOL_GPL(snd_soc_put_strobe); |
3479 | 3396 | ||
@@ -4037,6 +3954,8 @@ __snd_soc_register_component(struct device *dev, | |||
4037 | return -ENOMEM; | 3954 | return -ENOMEM; |
4038 | } | 3955 | } |
4039 | 3956 | ||
3957 | mutex_init(&cmpnt->io_mutex); | ||
3958 | |||
4040 | cmpnt->name = fmt_single_name(dev, &cmpnt->id); | 3959 | cmpnt->name = fmt_single_name(dev, &cmpnt->id); |
4041 | if (!cmpnt->name) { | 3960 | if (!cmpnt->name) { |
4042 | dev_err(dev, "ASoC: Failed to simplifying name\n"); | 3961 | dev_err(dev, "ASoC: Failed to simplifying name\n"); |
@@ -4084,12 +4003,25 @@ int snd_soc_register_component(struct device *dev, | |||
4084 | } | 4003 | } |
4085 | 4004 | ||
4086 | cmpnt->ignore_pmdown_time = true; | 4005 | cmpnt->ignore_pmdown_time = true; |
4006 | cmpnt->registered_as_component = true; | ||
4087 | 4007 | ||
4088 | return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL, | 4008 | return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL, |
4089 | dai_drv, num_dai, true); | 4009 | dai_drv, num_dai, true); |
4090 | } | 4010 | } |
4091 | EXPORT_SYMBOL_GPL(snd_soc_register_component); | 4011 | EXPORT_SYMBOL_GPL(snd_soc_register_component); |
4092 | 4012 | ||
4013 | static void __snd_soc_unregister_component(struct snd_soc_component *cmpnt) | ||
4014 | { | ||
4015 | snd_soc_unregister_dais(cmpnt); | ||
4016 | |||
4017 | mutex_lock(&client_mutex); | ||
4018 | list_del(&cmpnt->list); | ||
4019 | mutex_unlock(&client_mutex); | ||
4020 | |||
4021 | dev_dbg(cmpnt->dev, "ASoC: Unregistered component '%s'\n", cmpnt->name); | ||
4022 | kfree(cmpnt->name); | ||
4023 | } | ||
4024 | |||
4093 | /** | 4025 | /** |
4094 | * snd_soc_unregister_component - Unregister a component from the ASoC core | 4026 | * snd_soc_unregister_component - Unregister a component from the ASoC core |
4095 | * | 4027 | * |
@@ -4099,22 +4031,33 @@ void snd_soc_unregister_component(struct device *dev) | |||
4099 | struct snd_soc_component *cmpnt; | 4031 | struct snd_soc_component *cmpnt; |
4100 | 4032 | ||
4101 | list_for_each_entry(cmpnt, &component_list, list) { | 4033 | list_for_each_entry(cmpnt, &component_list, list) { |
4102 | if (dev == cmpnt->dev) | 4034 | if (dev == cmpnt->dev && cmpnt->registered_as_component) |
4103 | goto found; | 4035 | goto found; |
4104 | } | 4036 | } |
4105 | return; | 4037 | return; |
4106 | 4038 | ||
4107 | found: | 4039 | found: |
4108 | snd_soc_unregister_dais(cmpnt); | 4040 | __snd_soc_unregister_component(cmpnt); |
4041 | } | ||
4042 | EXPORT_SYMBOL_GPL(snd_soc_unregister_component); | ||
4109 | 4043 | ||
4110 | mutex_lock(&client_mutex); | 4044 | static int snd_soc_platform_drv_write(struct snd_soc_component *component, |
4111 | list_del(&cmpnt->list); | 4045 | unsigned int reg, unsigned int val) |
4112 | mutex_unlock(&client_mutex); | 4046 | { |
4047 | struct snd_soc_platform *platform = snd_soc_component_to_platform(component); | ||
4113 | 4048 | ||
4114 | dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name); | 4049 | return platform->driver->write(platform, reg, val); |
4115 | kfree(cmpnt->name); | 4050 | } |
4051 | |||
4052 | static int snd_soc_platform_drv_read(struct snd_soc_component *component, | ||
4053 | unsigned int reg, unsigned int *val) | ||
4054 | { | ||
4055 | struct snd_soc_platform *platform = snd_soc_component_to_platform(component); | ||
4056 | |||
4057 | *val = platform->driver->read(platform, reg); | ||
4058 | |||
4059 | return 0; | ||
4116 | } | 4060 | } |
4117 | EXPORT_SYMBOL_GPL(snd_soc_unregister_component); | ||
4118 | 4061 | ||
4119 | /** | 4062 | /** |
4120 | * snd_soc_add_platform - Add a platform to the ASoC core | 4063 | * snd_soc_add_platform - Add a platform to the ASoC core |
@@ -4125,6 +4068,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_component); | |||
4125 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, | 4068 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, |
4126 | const struct snd_soc_platform_driver *platform_drv) | 4069 | const struct snd_soc_platform_driver *platform_drv) |
4127 | { | 4070 | { |
4071 | int ret; | ||
4072 | |||
4128 | /* create platform component name */ | 4073 | /* create platform component name */ |
4129 | platform->name = fmt_single_name(dev, &platform->id); | 4074 | platform->name = fmt_single_name(dev, &platform->id); |
4130 | if (platform->name == NULL) | 4075 | if (platform->name == NULL) |
@@ -4134,8 +4079,22 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, | |||
4134 | platform->driver = platform_drv; | 4079 | platform->driver = platform_drv; |
4135 | platform->dapm.dev = dev; | 4080 | platform->dapm.dev = dev; |
4136 | platform->dapm.platform = platform; | 4081 | platform->dapm.platform = platform; |
4082 | platform->dapm.component = &platform->component; | ||
4137 | platform->dapm.stream_event = platform_drv->stream_event; | 4083 | platform->dapm.stream_event = platform_drv->stream_event; |
4138 | mutex_init(&platform->mutex); | 4084 | if (platform_drv->write) |
4085 | platform->component.write = snd_soc_platform_drv_write; | ||
4086 | if (platform_drv->read) | ||
4087 | platform->component.read = snd_soc_platform_drv_read; | ||
4088 | |||
4089 | /* register component */ | ||
4090 | ret = __snd_soc_register_component(dev, &platform->component, | ||
4091 | &platform_drv->component_driver, | ||
4092 | NULL, NULL, 0, false); | ||
4093 | if (ret < 0) { | ||
4094 | dev_err(platform->component.dev, | ||
4095 | "ASoC: Failed to register component: %d\n", ret); | ||
4096 | return ret; | ||
4097 | } | ||
4139 | 4098 | ||
4140 | mutex_lock(&client_mutex); | 4099 | mutex_lock(&client_mutex); |
4141 | list_add(&platform->list, &platform_list); | 4100 | list_add(&platform->list, &platform_list); |
@@ -4178,6 +4137,8 @@ EXPORT_SYMBOL_GPL(snd_soc_register_platform); | |||
4178 | */ | 4137 | */ |
4179 | void snd_soc_remove_platform(struct snd_soc_platform *platform) | 4138 | void snd_soc_remove_platform(struct snd_soc_platform *platform) |
4180 | { | 4139 | { |
4140 | __snd_soc_unregister_component(&platform->component); | ||
4141 | |||
4181 | mutex_lock(&client_mutex); | 4142 | mutex_lock(&client_mutex); |
4182 | list_del(&platform->list); | 4143 | list_del(&platform->list); |
4183 | mutex_unlock(&client_mutex); | 4144 | mutex_unlock(&client_mutex); |
@@ -4252,6 +4213,24 @@ static void fixup_codec_formats(struct snd_soc_pcm_stream *stream) | |||
4252 | stream->formats |= codec_format_map[i]; | 4213 | stream->formats |= codec_format_map[i]; |
4253 | } | 4214 | } |
4254 | 4215 | ||
4216 | static int snd_soc_codec_drv_write(struct snd_soc_component *component, | ||
4217 | unsigned int reg, unsigned int val) | ||
4218 | { | ||
4219 | struct snd_soc_codec *codec = snd_soc_component_to_codec(component); | ||
4220 | |||
4221 | return codec->driver->write(codec, reg, val); | ||
4222 | } | ||
4223 | |||
4224 | static int snd_soc_codec_drv_read(struct snd_soc_component *component, | ||
4225 | unsigned int reg, unsigned int *val) | ||
4226 | { | ||
4227 | struct snd_soc_codec *codec = snd_soc_component_to_codec(component); | ||
4228 | |||
4229 | *val = codec->driver->read(codec, reg); | ||
4230 | |||
4231 | return 0; | ||
4232 | } | ||
4233 | |||
4255 | /** | 4234 | /** |
4256 | * snd_soc_register_codec - Register a codec with the ASoC core | 4235 | * snd_soc_register_codec - Register a codec with the ASoC core |
4257 | * | 4236 | * |
@@ -4263,6 +4242,7 @@ int snd_soc_register_codec(struct device *dev, | |||
4263 | int num_dai) | 4242 | int num_dai) |
4264 | { | 4243 | { |
4265 | struct snd_soc_codec *codec; | 4244 | struct snd_soc_codec *codec; |
4245 | struct regmap *regmap; | ||
4266 | int ret, i; | 4246 | int ret, i; |
4267 | 4247 | ||
4268 | dev_dbg(dev, "codec register %s\n", dev_name(dev)); | 4248 | dev_dbg(dev, "codec register %s\n", dev_name(dev)); |
@@ -4278,22 +4258,41 @@ int snd_soc_register_codec(struct device *dev, | |||
4278 | goto fail_codec; | 4258 | goto fail_codec; |
4279 | } | 4259 | } |
4280 | 4260 | ||
4281 | codec->write = codec_drv->write; | 4261 | if (codec_drv->write) |
4282 | codec->read = codec_drv->read; | 4262 | codec->component.write = snd_soc_codec_drv_write; |
4283 | codec->volatile_register = codec_drv->volatile_register; | 4263 | if (codec_drv->read) |
4284 | codec->readable_register = codec_drv->readable_register; | 4264 | codec->component.read = snd_soc_codec_drv_read; |
4285 | codec->writable_register = codec_drv->writable_register; | ||
4286 | codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; | 4265 | codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; |
4287 | codec->dapm.bias_level = SND_SOC_BIAS_OFF; | 4266 | codec->dapm.bias_level = SND_SOC_BIAS_OFF; |
4288 | codec->dapm.dev = dev; | 4267 | codec->dapm.dev = dev; |
4289 | codec->dapm.codec = codec; | 4268 | codec->dapm.codec = codec; |
4269 | codec->dapm.component = &codec->component; | ||
4290 | codec->dapm.seq_notifier = codec_drv->seq_notifier; | 4270 | codec->dapm.seq_notifier = codec_drv->seq_notifier; |
4291 | codec->dapm.stream_event = codec_drv->stream_event; | 4271 | codec->dapm.stream_event = codec_drv->stream_event; |
4292 | codec->dev = dev; | 4272 | codec->dev = dev; |
4293 | codec->driver = codec_drv; | 4273 | codec->driver = codec_drv; |
4294 | codec->num_dai = num_dai; | 4274 | codec->num_dai = num_dai; |
4275 | codec->component.val_bytes = codec_drv->reg_word_size; | ||
4295 | mutex_init(&codec->mutex); | 4276 | mutex_init(&codec->mutex); |
4296 | 4277 | ||
4278 | if (!codec->component.write) { | ||
4279 | if (codec_drv->get_regmap) | ||
4280 | regmap = codec_drv->get_regmap(dev); | ||
4281 | else | ||
4282 | regmap = dev_get_regmap(dev, NULL); | ||
4283 | |||
4284 | if (regmap) { | ||
4285 | ret = snd_soc_component_init_io(&codec->component, | ||
4286 | regmap); | ||
4287 | if (ret) { | ||
4288 | dev_err(codec->dev, | ||
4289 | "Failed to set cache I/O:%d\n", | ||
4290 | ret); | ||
4291 | return ret; | ||
4292 | } | ||
4293 | } | ||
4294 | } | ||
4295 | |||
4297 | for (i = 0; i < num_dai; i++) { | 4296 | for (i = 0; i < num_dai; i++) { |
4298 | fixup_codec_formats(&dai_drv[i].playback); | 4297 | fixup_codec_formats(&dai_drv[i].playback); |
4299 | fixup_codec_formats(&dai_drv[i].capture); | 4298 | fixup_codec_formats(&dai_drv[i].capture); |
@@ -4343,7 +4342,7 @@ void snd_soc_unregister_codec(struct device *dev) | |||
4343 | return; | 4342 | return; |
4344 | 4343 | ||
4345 | found: | 4344 | found: |
4346 | snd_soc_unregister_component(dev); | 4345 | __snd_soc_unregister_component(&codec->component); |
4347 | 4346 | ||
4348 | mutex_lock(&client_mutex); | 4347 | mutex_lock(&client_mutex); |
4349 | list_del(&codec->list); | 4348 | list_del(&codec->list); |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 6d6ceee447d5..cd0a19fcbec9 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -378,86 +378,24 @@ static void dapm_reset(struct snd_soc_card *card) | |||
378 | static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg, | 378 | static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg, |
379 | unsigned int *value) | 379 | unsigned int *value) |
380 | { | 380 | { |
381 | if (w->codec) { | 381 | if (!w->dapm->component) |
382 | *value = snd_soc_read(w->codec, reg); | 382 | return -EIO; |
383 | return 0; | 383 | return snd_soc_component_read(w->dapm->component, reg, value); |
384 | } else if (w->platform) { | ||
385 | *value = snd_soc_platform_read(w->platform, reg); | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | dev_err(w->dapm->dev, "ASoC: no valid widget read method\n"); | ||
390 | return -1; | ||
391 | } | ||
392 | |||
393 | static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg, | ||
394 | unsigned int val) | ||
395 | { | ||
396 | if (w->codec) | ||
397 | return snd_soc_write(w->codec, reg, val); | ||
398 | else if (w->platform) | ||
399 | return snd_soc_platform_write(w->platform, reg, val); | ||
400 | |||
401 | dev_err(w->dapm->dev, "ASoC: no valid widget write method\n"); | ||
402 | return -1; | ||
403 | } | ||
404 | |||
405 | static inline void soc_widget_lock(struct snd_soc_dapm_widget *w) | ||
406 | { | ||
407 | if (w->codec && !w->codec->using_regmap) | ||
408 | mutex_lock(&w->codec->mutex); | ||
409 | else if (w->platform) | ||
410 | mutex_lock(&w->platform->mutex); | ||
411 | } | 384 | } |
412 | 385 | ||
413 | static inline void soc_widget_unlock(struct snd_soc_dapm_widget *w) | 386 | static int soc_widget_update_bits(struct snd_soc_dapm_widget *w, |
387 | int reg, unsigned int mask, unsigned int value) | ||
414 | { | 388 | { |
415 | if (w->codec && !w->codec->using_regmap) | 389 | if (!w->dapm->component) |
416 | mutex_unlock(&w->codec->mutex); | 390 | return -EIO; |
417 | else if (w->platform) | 391 | return snd_soc_component_update_bits_async(w->dapm->component, reg, |
418 | mutex_unlock(&w->platform->mutex); | 392 | mask, value); |
419 | } | 393 | } |
420 | 394 | ||
421 | static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) | 395 | static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) |
422 | { | 396 | { |
423 | if (dapm->codec && dapm->codec->using_regmap) | 397 | if (dapm->component) |
424 | regmap_async_complete(dapm->codec->control_data); | 398 | snd_soc_component_async_complete(dapm->component); |
425 | } | ||
426 | |||
427 | static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w, | ||
428 | unsigned short reg, unsigned int mask, unsigned int value) | ||
429 | { | ||
430 | bool change; | ||
431 | unsigned int old, new; | ||
432 | int ret; | ||
433 | |||
434 | if (w->codec && w->codec->using_regmap) { | ||
435 | ret = regmap_update_bits_check_async(w->codec->control_data, | ||
436 | reg, mask, value, | ||
437 | &change); | ||
438 | if (ret != 0) | ||
439 | return ret; | ||
440 | } else { | ||
441 | soc_widget_lock(w); | ||
442 | ret = soc_widget_read(w, reg, &old); | ||
443 | if (ret < 0) { | ||
444 | soc_widget_unlock(w); | ||
445 | return ret; | ||
446 | } | ||
447 | |||
448 | new = (old & ~mask) | (value & mask); | ||
449 | change = old != new; | ||
450 | if (change) { | ||
451 | ret = soc_widget_write(w, reg, new); | ||
452 | if (ret < 0) { | ||
453 | soc_widget_unlock(w); | ||
454 | return ret; | ||
455 | } | ||
456 | } | ||
457 | soc_widget_unlock(w); | ||
458 | } | ||
459 | |||
460 | return change; | ||
461 | } | 399 | } |
462 | 400 | ||
463 | /** | 401 | /** |
@@ -1132,7 +1070,7 @@ int dapm_reg_event(struct snd_soc_dapm_widget *w, | |||
1132 | else | 1070 | else |
1133 | val = w->off_val; | 1071 | val = w->off_val; |
1134 | 1072 | ||
1135 | soc_widget_update_bits_locked(w, -(w->reg + 1), | 1073 | soc_widget_update_bits(w, -(w->reg + 1), |
1136 | w->mask << w->shift, val << w->shift); | 1074 | w->mask << w->shift, val << w->shift); |
1137 | 1075 | ||
1138 | return 0; | 1076 | return 0; |
@@ -1428,7 +1366,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card, | |||
1428 | "pop test : Applying 0x%x/0x%x to %x in %dms\n", | 1366 | "pop test : Applying 0x%x/0x%x to %x in %dms\n", |
1429 | value, mask, reg, card->pop_time); | 1367 | value, mask, reg, card->pop_time); |
1430 | pop_wait(card->pop_time); | 1368 | pop_wait(card->pop_time); |
1431 | soc_widget_update_bits_locked(w, reg, mask, value); | 1369 | soc_widget_update_bits(w, reg, mask, value); |
1432 | } | 1370 | } |
1433 | 1371 | ||
1434 | list_for_each_entry(w, pending, power_list) { | 1372 | list_for_each_entry(w, pending, power_list) { |
@@ -1574,8 +1512,7 @@ static void dapm_widget_update(struct snd_soc_card *card) | |||
1574 | if (!w) | 1512 | if (!w) |
1575 | return; | 1513 | return; |
1576 | 1514 | ||
1577 | ret = soc_widget_update_bits_locked(w, update->reg, update->mask, | 1515 | ret = soc_widget_update_bits(w, update->reg, update->mask, update->val); |
1578 | update->val); | ||
1579 | if (ret < 0) | 1516 | if (ret < 0) |
1580 | dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", | 1517 | dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", |
1581 | w->name, ret); | 1518 | w->name, ret); |
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 260efc8466fc..7767fbd73eb7 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c | |||
@@ -17,77 +17,285 @@ | |||
17 | #include <linux/export.h> | 17 | #include <linux/export.h> |
18 | #include <sound/soc.h> | 18 | #include <sound/soc.h> |
19 | 19 | ||
20 | #include <trace/events/asoc.h> | 20 | /** |
21 | * snd_soc_component_read() - Read register value | ||
22 | * @component: Component to read from | ||
23 | * @reg: Register to read | ||
24 | * @val: Pointer to where the read value is stored | ||
25 | * | ||
26 | * Return: 0 on success, a negative error code otherwise. | ||
27 | */ | ||
28 | int snd_soc_component_read(struct snd_soc_component *component, | ||
29 | unsigned int reg, unsigned int *val) | ||
30 | { | ||
31 | int ret; | ||
32 | |||
33 | if (component->regmap) | ||
34 | ret = regmap_read(component->regmap, reg, val); | ||
35 | else if (component->read) | ||
36 | ret = component->read(component, reg, val); | ||
37 | else | ||
38 | ret = -EIO; | ||
39 | |||
40 | return ret; | ||
41 | } | ||
42 | EXPORT_SYMBOL_GPL(snd_soc_component_read); | ||
21 | 43 | ||
22 | #ifdef CONFIG_REGMAP | 44 | /** |
23 | static int hw_write(struct snd_soc_codec *codec, unsigned int reg, | 45 | * snd_soc_component_write() - Write register value |
24 | unsigned int value) | 46 | * @component: Component to write to |
47 | * @reg: Register to write | ||
48 | * @val: Value to write to the register | ||
49 | * | ||
50 | * Return: 0 on success, a negative error code otherwise. | ||
51 | */ | ||
52 | int snd_soc_component_write(struct snd_soc_component *component, | ||
53 | unsigned int reg, unsigned int val) | ||
25 | { | 54 | { |
26 | return regmap_write(codec->control_data, reg, value); | 55 | if (component->regmap) |
56 | return regmap_write(component->regmap, reg, val); | ||
57 | else if (component->write) | ||
58 | return component->write(component, reg, val); | ||
59 | else | ||
60 | return -EIO; | ||
27 | } | 61 | } |
62 | EXPORT_SYMBOL_GPL(snd_soc_component_write); | ||
28 | 63 | ||
29 | static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg) | 64 | static int snd_soc_component_update_bits_legacy( |
65 | struct snd_soc_component *component, unsigned int reg, | ||
66 | unsigned int mask, unsigned int val, bool *change) | ||
30 | { | 67 | { |
68 | unsigned int old, new; | ||
31 | int ret; | 69 | int ret; |
32 | unsigned int val; | ||
33 | 70 | ||
34 | ret = regmap_read(codec->control_data, reg, &val); | 71 | if (!component->read || !component->write) |
35 | if (ret == 0) | 72 | return -EIO; |
36 | return val; | 73 | |
74 | mutex_lock(&component->io_mutex); | ||
75 | |||
76 | ret = component->read(component, reg, &old); | ||
77 | if (ret < 0) | ||
78 | goto out_unlock; | ||
79 | |||
80 | new = (old & ~mask) | (val & mask); | ||
81 | *change = old != new; | ||
82 | if (*change) | ||
83 | ret = component->write(component, reg, new); | ||
84 | out_unlock: | ||
85 | mutex_unlock(&component->io_mutex); | ||
86 | |||
87 | return ret; | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * snd_soc_component_update_bits() - Perform read/modify/write cycle | ||
92 | * @component: Component to update | ||
93 | * @reg: Register to update | ||
94 | * @mask: Mask that specifies which bits to update | ||
95 | * @val: New value for the bits specified by mask | ||
96 | * | ||
97 | * Return: 1 if the operation was successful and the value of the register | ||
98 | * changed, 0 if the operation was successful, but the value did not change. | ||
99 | * Returns a negative error code otherwise. | ||
100 | */ | ||
101 | int snd_soc_component_update_bits(struct snd_soc_component *component, | ||
102 | unsigned int reg, unsigned int mask, unsigned int val) | ||
103 | { | ||
104 | bool change; | ||
105 | int ret; | ||
106 | |||
107 | if (component->regmap) | ||
108 | ret = regmap_update_bits_check(component->regmap, reg, mask, | ||
109 | val, &change); | ||
110 | else | ||
111 | ret = snd_soc_component_update_bits_legacy(component, reg, | ||
112 | mask, val, &change); | ||
113 | |||
114 | if (ret < 0) | ||
115 | return ret; | ||
116 | return change; | ||
117 | } | ||
118 | EXPORT_SYMBOL_GPL(snd_soc_component_update_bits); | ||
119 | |||
120 | /** | ||
121 | * snd_soc_component_update_bits_async() - Perform asynchronous | ||
122 | * read/modify/write cycle | ||
123 | * @component: Component to update | ||
124 | * @reg: Register to update | ||
125 | * @mask: Mask that specifies which bits to update | ||
126 | * @val: New value for the bits specified by mask | ||
127 | * | ||
128 | * This function is similar to snd_soc_component_update_bits(), but the update | ||
129 | * operation is scheduled asynchronously. This means it may not be completed | ||
130 | * when the function returns. To make sure that all scheduled updates have been | ||
131 | * completed snd_soc_component_async_complete() must be called. | ||
132 | * | ||
133 | * Return: 1 if the operation was successful and the value of the register | ||
134 | * changed, 0 if the operation was successful, but the value did not change. | ||
135 | * Returns a negative error code otherwise. | ||
136 | */ | ||
137 | int snd_soc_component_update_bits_async(struct snd_soc_component *component, | ||
138 | unsigned int reg, unsigned int mask, unsigned int val) | ||
139 | { | ||
140 | bool change; | ||
141 | int ret; | ||
142 | |||
143 | if (component->regmap) | ||
144 | ret = regmap_update_bits_check_async(component->regmap, reg, | ||
145 | mask, val, &change); | ||
37 | else | 146 | else |
147 | ret = snd_soc_component_update_bits_legacy(component, reg, | ||
148 | mask, val, &change); | ||
149 | |||
150 | if (ret < 0) | ||
151 | return ret; | ||
152 | return change; | ||
153 | } | ||
154 | EXPORT_SYMBOL_GPL(snd_soc_component_update_bits_async); | ||
155 | |||
156 | /** | ||
157 | * snd_soc_component_async_complete() - Ensure asynchronous I/O has completed | ||
158 | * @component: Component for which to wait | ||
159 | * | ||
160 | * This function blocks until all asynchronous I/O which has previously been | ||
161 | * scheduled using snd_soc_component_update_bits_async() has completed. | ||
162 | */ | ||
163 | void snd_soc_component_async_complete(struct snd_soc_component *component) | ||
164 | { | ||
165 | if (component->regmap) | ||
166 | regmap_async_complete(component->regmap); | ||
167 | } | ||
168 | EXPORT_SYMBOL_GPL(snd_soc_component_async_complete); | ||
169 | |||
170 | /** | ||
171 | * snd_soc_component_test_bits - Test register for change | ||
172 | * @component: component | ||
173 | * @reg: Register to test | ||
174 | * @mask: Mask that specifies which bits to test | ||
175 | * @value: Value to test against | ||
176 | * | ||
177 | * Tests a register with a new value and checks if the new value is | ||
178 | * different from the old value. | ||
179 | * | ||
180 | * Return: 1 for change, otherwise 0. | ||
181 | */ | ||
182 | int snd_soc_component_test_bits(struct snd_soc_component *component, | ||
183 | unsigned int reg, unsigned int mask, unsigned int value) | ||
184 | { | ||
185 | unsigned int old, new; | ||
186 | int ret; | ||
187 | |||
188 | ret = snd_soc_component_read(component, reg, &old); | ||
189 | if (ret < 0) | ||
190 | return ret; | ||
191 | new = (old & ~mask) | value; | ||
192 | return old != new; | ||
193 | } | ||
194 | EXPORT_SYMBOL_GPL(snd_soc_component_test_bits); | ||
195 | |||
196 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg) | ||
197 | { | ||
198 | unsigned int val; | ||
199 | int ret; | ||
200 | |||
201 | ret = snd_soc_component_read(&codec->component, reg, &val); | ||
202 | if (ret < 0) | ||
38 | return -1; | 203 | return -1; |
204 | |||
205 | return val; | ||
39 | } | 206 | } |
207 | EXPORT_SYMBOL_GPL(snd_soc_read); | ||
208 | |||
209 | int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, | ||
210 | unsigned int val) | ||
211 | { | ||
212 | return snd_soc_component_write(&codec->component, reg, val); | ||
213 | } | ||
214 | EXPORT_SYMBOL_GPL(snd_soc_write); | ||
40 | 215 | ||
41 | /** | 216 | /** |
42 | * snd_soc_codec_set_cache_io: Set up standard I/O functions. | 217 | * snd_soc_update_bits - update codec register bits |
218 | * @codec: audio codec | ||
219 | * @reg: codec register | ||
220 | * @mask: register mask | ||
221 | * @value: new value | ||
43 | * | 222 | * |
44 | * @codec: CODEC to configure. | 223 | * Writes new register value. |
45 | * @map: Register map to write to | ||
46 | * | 224 | * |
47 | * Register formats are frequently shared between many I2C and SPI | 225 | * Returns 1 for change, 0 for no change, or negative error code. |
48 | * devices. In order to promote code reuse the ASoC core provides | 226 | */ |
49 | * some standard implementations of CODEC read and write operations | 227 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg, |
50 | * which can be set up using this function. | 228 | unsigned int mask, unsigned int value) |
229 | { | ||
230 | return snd_soc_component_update_bits(&codec->component, reg, mask, | ||
231 | value); | ||
232 | } | ||
233 | EXPORT_SYMBOL_GPL(snd_soc_update_bits); | ||
234 | |||
235 | /** | ||
236 | * snd_soc_test_bits - test register for change | ||
237 | * @codec: audio codec | ||
238 | * @reg: codec register | ||
239 | * @mask: register mask | ||
240 | * @value: new value | ||
51 | * | 241 | * |
52 | * The caller is responsible for allocating and initialising the | 242 | * Tests a register with a new value and checks if the new value is |
53 | * actual cache. | 243 | * different from the old value. |
54 | * | 244 | * |
55 | * Note that at present this code cannot be used by CODECs with | 245 | * Returns 1 for change else 0. |
56 | * volatile registers. | ||
57 | */ | 246 | */ |
58 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | 247 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, |
59 | struct regmap *regmap) | 248 | unsigned int mask, unsigned int value) |
249 | { | ||
250 | return snd_soc_component_test_bits(&codec->component, reg, mask, value); | ||
251 | } | ||
252 | EXPORT_SYMBOL_GPL(snd_soc_test_bits); | ||
253 | |||
254 | int snd_soc_platform_read(struct snd_soc_platform *platform, | ||
255 | unsigned int reg) | ||
60 | { | 256 | { |
257 | unsigned int val; | ||
61 | int ret; | 258 | int ret; |
62 | 259 | ||
63 | /* Device has made its own regmap arrangements */ | 260 | ret = snd_soc_component_read(&platform->component, reg, &val); |
64 | if (!regmap) | 261 | if (ret < 0) |
65 | codec->control_data = dev_get_regmap(codec->dev, NULL); | 262 | return -1; |
66 | else | 263 | |
67 | codec->control_data = regmap; | 264 | return val; |
265 | } | ||
266 | EXPORT_SYMBOL_GPL(snd_soc_platform_read); | ||
267 | |||
268 | int snd_soc_platform_write(struct snd_soc_platform *platform, | ||
269 | unsigned int reg, unsigned int val) | ||
270 | { | ||
271 | return snd_soc_component_write(&platform->component, reg, val); | ||
272 | } | ||
273 | EXPORT_SYMBOL_GPL(snd_soc_platform_write); | ||
68 | 274 | ||
69 | if (IS_ERR(codec->control_data)) | 275 | /** |
70 | return PTR_ERR(codec->control_data); | 276 | * snd_soc_component_init_io() - Initialize regmap IO |
277 | * | ||
278 | * @component: component to initialize | ||
279 | * @regmap: regmap instance to use for IO operations | ||
280 | * | ||
281 | * Return: 0 on success, a negative error code otherwise | ||
282 | */ | ||
283 | int snd_soc_component_init_io(struct snd_soc_component *component, | ||
284 | struct regmap *regmap) | ||
285 | { | ||
286 | int ret; | ||
71 | 287 | ||
72 | codec->write = hw_write; | 288 | if (!regmap) |
73 | codec->read = hw_read; | 289 | return -EINVAL; |
74 | 290 | ||
75 | ret = regmap_get_val_bytes(codec->control_data); | 291 | ret = regmap_get_val_bytes(regmap); |
76 | /* Errors are legitimate for non-integer byte | 292 | /* Errors are legitimate for non-integer byte |
77 | * multiples */ | 293 | * multiples */ |
78 | if (ret > 0) | 294 | if (ret > 0) |
79 | codec->val_bytes = ret; | 295 | component->val_bytes = ret; |
80 | 296 | ||
81 | codec->using_regmap = true; | 297 | component->regmap = regmap; |
82 | 298 | ||
83 | return 0; | 299 | return 0; |
84 | } | 300 | } |
85 | EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io); | 301 | EXPORT_SYMBOL_GPL(snd_soc_component_init_io); |
86 | #else | ||
87 | int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | ||
88 | struct regmap *regmap) | ||
89 | { | ||
90 | return -ENOTSUPP; | ||
91 | } | ||
92 | EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io); | ||
93 | #endif | ||