@@ -160,32 +160,6 @@ static void catpt_stream_read_position(struct catpt_dev *cdev,
160160 memcpy_fromio (pos , cdev -> lpe_ba + stream -> info .read_pos_regaddr , sizeof (* pos ));
161161}
162162
163- static u32 catpt_stream_volume (struct catpt_dev * cdev ,
164- struct catpt_stream_runtime * stream , u32 channel )
165- {
166- u32 volume , offset ;
167-
168- if (channel >= CATPT_CHANNELS_MAX )
169- channel = 0 ;
170-
171- offset = stream -> info .volume_regaddr [channel ];
172- memcpy_fromio (& volume , cdev -> lpe_ba + offset , sizeof (volume ));
173- return volume ;
174- }
175-
176- static u32 catpt_mixer_volume (struct catpt_dev * cdev ,
177- struct catpt_mixer_stream_info * info , u32 channel )
178- {
179- u32 volume , offset ;
180-
181- if (channel >= CATPT_CHANNELS_MAX )
182- channel = 0 ;
183-
184- offset = info -> volume_regaddr [channel ];
185- memcpy_fromio (& volume , cdev -> lpe_ba + offset , sizeof (volume ));
186- return volume ;
187- }
188-
189163static void catpt_arrange_page_table (struct snd_pcm_substream * substream ,
190164 struct snd_dma_buffer * pgtbl )
191165{
@@ -911,7 +885,6 @@ static int catpt_volume_info(struct snd_kcontrol *kcontrol,
911885 return 0 ;
912886}
913887
914- __maybe_unused
915888static int catpt_volume_get (struct snd_kcontrol * kctl , struct snd_ctl_elem_value * uctl )
916889{
917890 struct snd_soc_component * component = snd_kcontrol_chip (kctl );
@@ -938,7 +911,6 @@ static int catpt_volume_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value
938911 return 0 ;
939912}
940913
941- __maybe_unused
942914static int catpt_volume_put (struct snd_kcontrol * kctl , struct snd_ctl_elem_value * uctl )
943915{
944916 struct snd_soc_component * component = snd_kcontrol_chip (kctl );
@@ -967,14 +939,12 @@ static int catpt_volume_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value
967939 return 1 ;
968940}
969941
970- __maybe_unused
971942static int catpt_loopback_mute_get (struct snd_kcontrol * kctl , struct snd_ctl_elem_value * uctl )
972943{
973944 uctl -> value .integer .value [0 ] = * (bool * )kctl -> private_value ;
974945 return 0 ;
975946}
976947
977- __maybe_unused
978948static int catpt_loopback_mute_put (struct snd_kcontrol * kctl , struct snd_ctl_elem_value * uctl )
979949{
980950 struct snd_soc_component * component = snd_kcontrol_chip (kctl );
@@ -1002,195 +972,6 @@ static int catpt_loopback_mute_put(struct snd_kcontrol *kctl, struct snd_ctl_ele
1002972 return 1 ;
1003973}
1004974
1005- static int catpt_mixer_volume_get (struct snd_kcontrol * kcontrol ,
1006- struct snd_ctl_elem_value * ucontrol )
1007- {
1008- struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
1009- struct catpt_dev * cdev = dev_get_drvdata (component -> dev );
1010- u32 dspvol ;
1011- int ret ;
1012- int i ;
1013-
1014- ret = pm_runtime_resume_and_get (cdev -> dev );
1015- if (ret )
1016- return ret ;
1017-
1018- for (i = 0 ; i < CATPT_CHANNELS_MAX ; i ++ ) {
1019- dspvol = catpt_mixer_volume (cdev , & cdev -> mixer , i );
1020- ucontrol -> value .integer .value [i ] = dspvol_to_ctlvol (dspvol );
1021- }
1022-
1023- pm_runtime_put_autosuspend (cdev -> dev );
1024-
1025- return 0 ;
1026- }
1027-
1028- static int catpt_mixer_volume_put (struct snd_kcontrol * kcontrol ,
1029- struct snd_ctl_elem_value * ucontrol )
1030- {
1031- struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
1032- struct catpt_dev * cdev = dev_get_drvdata (component -> dev );
1033- int ret ;
1034-
1035- ret = pm_runtime_resume_and_get (cdev -> dev );
1036- if (ret )
1037- return ret ;
1038-
1039- ret = catpt_set_dspvol (cdev , cdev -> mixer .mixer_hw_id ,
1040- ucontrol -> value .integer .value );
1041-
1042- pm_runtime_put_autosuspend (cdev -> dev );
1043-
1044- return ret ;
1045- }
1046-
1047- static int catpt_stream_volume_get (struct snd_kcontrol * kcontrol ,
1048- struct snd_ctl_elem_value * ucontrol ,
1049- enum catpt_pin_id pin_id )
1050- {
1051- struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
1052- struct catpt_stream_runtime * stream ;
1053- struct catpt_dev * cdev = dev_get_drvdata (component -> dev );
1054- long * ctlvol = (long * )kcontrol -> private_value ;
1055- u32 dspvol ;
1056- int ret ;
1057- int i ;
1058-
1059- guard (mutex )(& cdev -> stream_mutex );
1060-
1061- stream = catpt_stream_find (cdev , pin_id );
1062- if (!stream ) {
1063- for (i = 0 ; i < CATPT_CHANNELS_MAX ; i ++ )
1064- ucontrol -> value .integer .value [i ] = ctlvol [i ];
1065- return 0 ;
1066- }
1067-
1068- ret = pm_runtime_resume_and_get (cdev -> dev );
1069- if (ret )
1070- return ret ;
1071-
1072- for (i = 0 ; i < CATPT_CHANNELS_MAX ; i ++ ) {
1073- dspvol = catpt_stream_volume (cdev , stream , i );
1074- ucontrol -> value .integer .value [i ] = dspvol_to_ctlvol (dspvol );
1075- }
1076-
1077- pm_runtime_put_autosuspend (cdev -> dev );
1078-
1079- return 0 ;
1080- }
1081-
1082- static int catpt_stream_volume_put (struct snd_kcontrol * kcontrol ,
1083- struct snd_ctl_elem_value * ucontrol ,
1084- enum catpt_pin_id pin_id )
1085- {
1086- struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
1087- struct catpt_stream_runtime * stream ;
1088- struct catpt_dev * cdev = dev_get_drvdata (component -> dev );
1089- long * ctlvol = (long * )kcontrol -> private_value ;
1090- int ret , i ;
1091-
1092- guard (mutex )(& cdev -> stream_mutex );
1093-
1094- stream = catpt_stream_find (cdev , pin_id );
1095- if (!stream ) {
1096- for (i = 0 ; i < CATPT_CHANNELS_MAX ; i ++ )
1097- ctlvol [i ] = ucontrol -> value .integer .value [i ];
1098- return 0 ;
1099- }
1100-
1101- ret = pm_runtime_resume_and_get (cdev -> dev );
1102- if (ret )
1103- return ret ;
1104-
1105- ret = catpt_set_dspvol (cdev , stream -> info .stream_hw_id ,
1106- ucontrol -> value .integer .value );
1107-
1108- pm_runtime_put_autosuspend (cdev -> dev );
1109-
1110- if (ret )
1111- return ret ;
1112-
1113- for (i = 0 ; i < CATPT_CHANNELS_MAX ; i ++ )
1114- ctlvol [i ] = ucontrol -> value .integer .value [i ];
1115- return 0 ;
1116- }
1117-
1118- static int catpt_offload1_volume_get (struct snd_kcontrol * kctl ,
1119- struct snd_ctl_elem_value * uctl )
1120- {
1121- return catpt_stream_volume_get (kctl , uctl , CATPT_PIN_ID_OFFLOAD1 );
1122- }
1123-
1124- static int catpt_offload1_volume_put (struct snd_kcontrol * kctl ,
1125- struct snd_ctl_elem_value * uctl )
1126- {
1127- return catpt_stream_volume_put (kctl , uctl , CATPT_PIN_ID_OFFLOAD1 );
1128- }
1129-
1130- static int catpt_offload2_volume_get (struct snd_kcontrol * kctl ,
1131- struct snd_ctl_elem_value * uctl )
1132- {
1133- return catpt_stream_volume_get (kctl , uctl , CATPT_PIN_ID_OFFLOAD2 );
1134- }
1135-
1136- static int catpt_offload2_volume_put (struct snd_kcontrol * kctl ,
1137- struct snd_ctl_elem_value * uctl )
1138- {
1139- return catpt_stream_volume_put (kctl , uctl , CATPT_PIN_ID_OFFLOAD2 );
1140- }
1141-
1142- static int catpt_capture_volume_get (struct snd_kcontrol * kctl ,
1143- struct snd_ctl_elem_value * uctl )
1144- {
1145- return catpt_stream_volume_get (kctl , uctl , CATPT_PIN_ID_CAPTURE1 );
1146- }
1147-
1148- static int catpt_capture_volume_put (struct snd_kcontrol * kctl ,
1149- struct snd_ctl_elem_value * uctl )
1150- {
1151- return catpt_stream_volume_put (kctl , uctl , CATPT_PIN_ID_CAPTURE1 );
1152- }
1153-
1154- static int catpt_loopback_switch_get (struct snd_kcontrol * kcontrol ,
1155- struct snd_ctl_elem_value * ucontrol )
1156- {
1157- ucontrol -> value .integer .value [0 ] = * (bool * )kcontrol -> private_value ;
1158- return 0 ;
1159- }
1160-
1161- static int catpt_loopback_switch_put (struct snd_kcontrol * kcontrol ,
1162- struct snd_ctl_elem_value * ucontrol )
1163- {
1164- struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
1165- struct catpt_stream_runtime * stream ;
1166- struct catpt_dev * cdev = dev_get_drvdata (component -> dev );
1167- bool mute ;
1168- int ret ;
1169-
1170- guard (mutex )(& cdev -> stream_mutex );
1171-
1172- mute = (bool )ucontrol -> value .integer .value [0 ];
1173- stream = catpt_stream_find (cdev , CATPT_PIN_ID_REFERENCE );
1174- if (!stream ) {
1175- * (bool * )kcontrol -> private_value = mute ;
1176- return 0 ;
1177- }
1178-
1179- ret = pm_runtime_resume_and_get (cdev -> dev );
1180- if (ret )
1181- return ret ;
1182-
1183- ret = catpt_ipc_mute_loopback (cdev , stream -> info .stream_hw_id , mute );
1184-
1185- pm_runtime_put_autosuspend (cdev -> dev );
1186-
1187- if (ret )
1188- return CATPT_IPC_RET (ret );
1189-
1190- * (bool * )kcontrol -> private_value = mute ;
1191- return 0 ;
1192- }
1193-
1194975static int catpt_waves_switch_get (struct snd_kcontrol * kcontrol ,
1195976 struct snd_ctl_elem_value * ucontrol )
1196977{
@@ -1219,7 +1000,7 @@ static int catpt_waves_param_put(struct snd_kcontrol *kcontrol,
12191000
12201001static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE (catpt_volume_tlv , -9000 , 300 , 1 ) ;
12211002
1222- #define CATPT_VOLUME_CTL2 (kname , pname ) { \
1003+ #define CATPT_VOLUME_CTL (kname , pname ) { \
12231004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
12241005 .name = kname, \
12251006 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
@@ -1232,27 +1013,15 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(catpt_volume_tlv, -9000, 300, 1);
12321013 &(struct catpt_control_data) { CATPT_PIN_ID_##pname } \
12331014}
12341015
1235- #define CATPT_VOLUME_CTL (kname , sname ) \
1236- { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1237- .name = (kname), \
1238- .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1239- SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1240- .info = catpt_volume_info, \
1241- .get = catpt_##sname##_volume_get, \
1242- .put = catpt_##sname##_volume_put, \
1243- .tlv.p = catpt_volume_tlv, \
1244- .private_value = (unsigned long) \
1245- &(long[CATPT_CHANNELS_MAX]) {0} }
1246-
12471016static const struct snd_kcontrol_new component_kcontrols [] = {
12481017/* Master volume (mixer stream) */
1249- CATPT_VOLUME_CTL ("Master Playback Volume" , mixer ),
1018+ CATPT_VOLUME_CTL ("Master Playback Volume" , MIXER ),
12501019/* Individual volume controls for offload and capture */
1251- CATPT_VOLUME_CTL ("Media0 Playback Volume" , offload1 ),
1252- CATPT_VOLUME_CTL ("Media1 Playback Volume" , offload2 ),
1253- CATPT_VOLUME_CTL ("Mic Capture Volume" , capture ),
1020+ CATPT_VOLUME_CTL ("Media0 Playback Volume" , OFFLOAD1 ),
1021+ CATPT_VOLUME_CTL ("Media1 Playback Volume" , OFFLOAD2 ),
1022+ CATPT_VOLUME_CTL ("Mic Capture Volume" , CAPTURE1 ),
12541023SOC_SINGLE_BOOL_EXT ("Loopback Mute" , (unsigned long )& (bool [1 ]) {0 },
1255- catpt_loopback_switch_get , catpt_loopback_switch_put ),
1024+ catpt_loopback_mute_get , catpt_loopback_mute_put ),
12561025/* Enable or disable WAVES module */
12571026SOC_SINGLE_BOOL_EXT ("Waves Switch" , 0 ,
12581027 catpt_waves_switch_get , catpt_waves_switch_put ),
0 commit comments