1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
|
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2020, The Linux Foundation. All rights reserved.
*/
#include <linux/init.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/time.h>
#include <linux/wait.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/pcm.h>
#include <ipc/apr_tal.h>
#include <dsp/apr_audio-v2.h>
#include <dsp/q6audio-v2.h>
#include <dsp/audio_cal_utils.h>
#include <dsp/q6voice.h>
#include <dsp/q6asm-v2.h>
#include <dsp/q6common.h>
#include <asoc/sec_audio_adaptation.h>
#include "msm-pcm-routing-v2.h"
struct afe_ctl {
void *apr;
atomic_t state;
atomic_t status;
wait_queue_head_t wait;
};
struct afe_port {
unsigned int device_tx_port;
unsigned int spk_rx_port;
unsigned int usb_rx_port;
unsigned int bt_rx_port;
unsigned int headset_rx_port;
unsigned int volume_monitor_port;
};
static struct afe_ctl this_afe;
static struct audio_session *session;
static struct afe_port afe_port;
static struct mutex asm_lock;
static uint32_t upscaler_val;
int q6asm_set_sound_alive(struct audio_client *ac, long *param)
{
struct asm_stream_cmd_set_pp_params_sa cmd;
struct param_hdr_v3 param_info;
int rc = 0;
int i = 0;
if (ac == NULL) {
pr_err("%s: Audio client is NULL\n", __func__);
return -EINVAL;
}
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_info, 0, sizeof(param_info));
memset(&cmd, 0, sizeof(cmd));
param_info.module_id = MODULE_ID_PP_SA;
param_info.instance_id = INSTANCE_ID_0;
param_info.param_id = PARAM_ID_PP_SA_PARAMS;
param_info.param_size = sizeof(cmd);
/* SA paramerters */
cmd.OutDevice = param[0];
cmd.Preset = param[1];
for (i = 0; i < 9; i++)
cmd.EqLev[i] = param[i+2];
cmd.m3Dlevel = param[11];
cmd.BElevel = param[12];
cmd.CHlevel = param[13];
cmd.CHRoomSize = param[14];
cmd.Clalevel = param[15];
cmd.volume = param[16];
cmd.Sqrow = param[17];
cmd.Sqcol = param[18];
cmd.TabInfo = param[19];
cmd.NewUI = param[20];
cmd.m3DPositionOn = param[21];
cmd.m3DPositionAngle[0] = param[22];
cmd.m3DPositionAngle[1] = param[23];
cmd.m3DPositionGain[0] = param[24];
cmd.m3DPositionGain[1] = param[25];
cmd.AHDRonoff = param[26];
pr_info("%s: %d %d %d%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
__func__,
cmd.OutDevice, cmd.Preset, cmd.EqLev[0],
cmd.EqLev[1], cmd.EqLev[2], cmd.EqLev[3],
cmd.EqLev[4], cmd.EqLev[5], cmd.EqLev[6],
cmd.EqLev[7], cmd.EqLev[8],
cmd.m3Dlevel, cmd.BElevel, cmd.CHlevel,
cmd.CHRoomSize, cmd.Clalevel, cmd.volume,
cmd.Sqrow, cmd.Sqcol, cmd.TabInfo,
cmd.NewUI, cmd.m3DPositionOn,
cmd.m3DPositionAngle[0], cmd.m3DPositionAngle[1],
cmd.m3DPositionGain[0], cmd.m3DPositionGain[1],
cmd.AHDRonoff);
rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
(u8 *) &cmd);
if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
__func__, param_info.param_id, rc);
return rc;
}
int q6asm_set_sa_listenback(struct audio_client *ac, long *param)
{
struct asm_stream_cmd_set_pp_params_sa cmd = {0, };
struct param_hdr_v3 param_info;
int rc = 0;
if (ac == NULL) {
pr_err("%s: Audio client is NULL\n", __func__);
return -EINVAL;
}
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_info, 0, sizeof(param_info));
memset(&cmd, 0, sizeof(cmd));
param_info.module_id = MODULE_ID_PP_SA;
param_info.instance_id = INSTANCE_ID_0;
param_info.param_id = PARAM_ID_PP_SA_PARAMS;
param_info.param_size = sizeof(cmd);
/* SA paramerters */
cmd.OutDevice = 1; /* EAR */
cmd.Preset = param[0];
cmd.BElevel = param[1];
cmd.Clalevel = param[2];
cmd.TabInfo = 1;
cmd.NewUI = 1;
pr_info("%s: %d %d %d\n", __func__, cmd.Preset, cmd.BElevel, cmd.Clalevel);
rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
(u8 *) &cmd);
if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
__func__, param_info.param_id, rc);
return rc;
}
int q6asm_set_play_speed(struct audio_client *ac, long *param)
{
struct asm_stream_cmd_set_pp_params_vsp cmd;
struct param_hdr_v3 param_info;
int rc = 0;
if (ac == NULL) {
pr_err("%s: Audio client is NULL\n", __func__);
return -EINVAL;
}
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_info, 0, sizeof(param_info));
memset(&cmd, 0, sizeof(cmd));
param_info.module_id = MODULE_ID_PP_SA_VSP;
param_info.instance_id = INSTANCE_ID_0;
param_info.param_id = PARAM_ID_PP_SA_VSP_PARAMS;
param_info.param_size = sizeof(cmd);
/* play speed paramerters */
cmd.speed_int = param[0];
pr_info("%s: %d\n", __func__, cmd.speed_int);
rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
(u8 *) &cmd);
if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
__func__, param_info.param_id, rc);
return rc;
}
int q6asm_set_adaptation_sound(struct audio_client *ac, long *param)
{
struct asm_stream_cmd_set_pp_params_adaptation_sound cmd;
struct param_hdr_v3 param_info;
int rc = 0;
int i = 0;
if (ac == NULL) {
pr_err("%s: Audio client is NULL\n", __func__);
return -EINVAL;
}
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_info, 0, sizeof(param_info));
memset(&cmd, 0, sizeof(cmd));
param_info.module_id = MODULE_ID_PP_ADAPTATION_SOUND;
param_info.instance_id = INSTANCE_ID_0;
param_info.param_id = PARAM_ID_PP_ADAPTATION_SOUND_PARAMS;
param_info.param_size = sizeof(cmd);
/* adapt sound paramerters */
cmd.enable = param[0];
for (i = 0; i < 12; i++)
cmd.gain[i/6][i%6] = param[i+1];
cmd.device = param[13];
pr_info("%s: %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
__func__,
cmd.enable, cmd.gain[0][0], cmd.gain[0][1], cmd.gain[0][2],
cmd.gain[0][3], cmd.gain[0][4], cmd.gain[0][5], cmd.gain[1][0],
cmd.gain[1][1], cmd.gain[1][2], cmd.gain[1][3], cmd.gain[1][4],
cmd.gain[1][5], cmd.device);
rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
(u8 *) &cmd);
if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
__func__, param_info.param_id, rc);
return rc;
}
int q6asm_set_sound_balance(struct audio_client *ac, long *param)
{
struct asm_stream_cmd_set_pp_params_lrsm cmd;
struct param_hdr_v3 param_info;
int rc = 0;
if (ac == NULL) {
pr_err("%s: Audio client is NULL\n", __func__);
return -EINVAL;
}
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_info, 0, sizeof(param_info));
memset(&cmd, 0, sizeof(cmd));
param_info.module_id = MODULE_ID_PP_LRSM;
param_info.instance_id = INSTANCE_ID_0;
param_info.param_id = PARAM_ID_PP_LRSM_PARAMS;
param_info.param_size = sizeof(cmd);
/* sound balance paramerters */
cmd.sm = param[0];
cmd.lr = param[1];
pr_info("%s: %d %d\n", __func__, cmd.sm, cmd.lr);
rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
(u8 *) &cmd);
if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
__func__, param_info.param_id, rc);
return rc;
}
int q6asm_set_myspace(struct audio_client *ac, long *param)
{
struct asm_stream_cmd_set_pp_params_msp cmd;
struct param_hdr_v3 param_info;
int rc = 0;
if (ac == NULL) {
pr_err("%s: Audio client is NULL\n", __func__);
return -EINVAL;
}
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_info, 0, sizeof(param_info));
memset(&cmd, 0, sizeof(cmd));
param_info.module_id = MODULE_ID_PP_SA_MSP;
param_info.instance_id = INSTANCE_ID_0;
param_info.param_id = MODULE_ID_PP_SA_MSP_PARAM;
param_info.param_size = sizeof(cmd);
/* myspace paramerters */
cmd.msp_int = param[0];
pr_info("%s: %d\n", __func__, cmd.msp_int);
rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
(u8 *) &cmd);
if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
__func__, param_info.param_id, rc);
return rc;
}
int q6asm_set_upscaler(struct audio_client *ac, long *param)
{
struct asm_stream_cmd_set_pp_params_upscaler cmd;
struct param_hdr_v3 param_info;
int rc = 0;
if (ac == NULL) {
pr_err("%s: Audio client is NULL\n", __func__);
return -EINVAL;
}
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_info, 0, sizeof(param_info));
memset(&cmd, 0, sizeof(cmd));
param_info.module_id = MODULE_ID_PP_SA_UPSCALER_COLOR;
param_info.instance_id = INSTANCE_ID_0;
param_info.param_id = PARAM_ID_PP_SA_UPSCALER_COLOR_PARAMS;
param_info.param_size = sizeof(cmd);
/* upscaler paramerters */
cmd.upscaler_enable = param[0];
pr_info("%s: %d\n", __func__, cmd.upscaler_enable);
rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
(u8 *) &cmd);
if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
__func__, param_info.param_id, rc);
upscaler_val = cmd.upscaler_enable;
return rc;
}
int q6asm_set_dolby_atmos(struct audio_client *ac, long *param)
{
struct asm_stream_cmd_set_pp_params_dolby_atmos cmd;
struct param_hdr_v3 param_info;
int rc = 0;
if (ac == NULL) {
pr_err("%s: Audio client is NULL\n", __func__);
return -EINVAL;
}
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_info, 0, sizeof(param_info));
memset(&cmd, 0, sizeof(cmd));
param_info.module_id = MODULE_ID_PP_DOLBY_DAP;
param_info.instance_id = INSTANCE_ID_0;
param_info.param_id = PARAM_ID_PP_DOLBY_DAP_PARAMS;
param_info.param_size = sizeof(cmd);
/* rotation paramerters */
cmd.enable = (uint32_t)param[0];
cmd.device = (uint16_t)param[1];
cmd.dolby_profile = (uint16_t)param[2];
pr_info("%s: %d %d %d\n", __func__,
cmd.enable, cmd.device, cmd.dolby_profile);
rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
(u8 *) &cmd);
if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
__func__, param_info.param_id, rc);
return rc;
}
int adm_set_sound_booster(int port_id, int copp_idx,
long *param)
{
struct adm_param_soundbooster_t sb_param;
struct param_hdr_v3 param_hdr;
int ret = 0;
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
pr_debug("%s: Enter\n", __func__);
memset(¶m_hdr, 0, sizeof(param_hdr));
param_hdr.module_id = MODULE_ID_PP_SB;
param_hdr.instance_id = INSTANCE_ID_0;
param_hdr.param_id = PARAM_ID_PP_SB_PARAM;
param_hdr.param_size = sizeof(sb_param);
/* soundbooster paramerters */
sb_param.sb_enable = (uint32_t)param[0];
pr_info("%s: Enter, port_id(0x%x), copp_idx(%d), enable(%d)\n",
__func__, port_id, copp_idx, sb_param.sb_enable);
ret = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
(uint8_t *) &sb_param);
if (ret)
pr_err("%s: Failed to set sound booster params, err %d\n",
__func__, ret);
pr_debug("%s: Exit, ret=%d\n", __func__, ret);
return ret;
}
int adm_set_sb_rotation(int port_id, int copp_idx,
uint32_t rotation)
{
struct adm_param_sb_rotation cmd;
struct param_hdr_v3 param_hdr;
int ret = 0;
memset(¶m_hdr, 0, sizeof(param_hdr));
param_hdr.module_id = MODULE_ID_PP_SB;
param_hdr.instance_id = INSTANCE_ID_0;
param_hdr.param_id = PARAM_ID_PP_SB_ROTATION_PARAM;
param_hdr.param_size = sizeof(cmd);
/* rotation paramerters */
cmd.sb_rotation = rotation;
pr_info("%s: Enter, port_id(0x%x), copp_idx(%d), enable(%d)\n",
__func__, port_id, copp_idx, cmd.sb_rotation);
ret = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
(uint8_t *) &cmd);
if (ret)
pr_err("%s: Failed to set sb rotation params, err %d\n",
__func__, ret);
pr_debug("%s: Exit, ret=%d\n", __func__, ret);
return ret;
}
int adm_set_sb_flatmotion(int port_id, int copp_idx,
long *param)
{
struct adm_param_sb_flatmotion cmd;
struct param_hdr_v3 param_hdr;
int ret = 0;
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
memset(¶m_hdr, 0, sizeof(param_hdr));
param_hdr.module_id = MODULE_ID_PP_SB;
param_hdr.instance_id = INSTANCE_ID_0;
param_hdr.param_id = PARAM_ID_PP_SB_FLATMOTION_PARAM;
param_hdr.param_size = sizeof(cmd);
/* flatmotion paramerters */
cmd.sb_flatmotion = (unsigned int)param[0];
pr_info("%s: Enter, port_id(0x%x), copp_idx(%d), enable(%d)\n",
__func__, port_id, copp_idx, cmd.sb_flatmotion);
ret = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
(uint8_t *) &cmd);
if (ret)
pr_err("%s: Failed to set sb flatmotion params, err %d\n",
__func__, ret);
pr_debug("%s: Exit, ret=%d\n", __func__, ret);
return ret;
}
int adm_set_sb_volume(int port_id, int copp_idx,
long *param)
{
struct adm_param_sb_volume cmd;
struct param_hdr_v3 param_hdr;
int ret = 0;
if (param == NULL) {
pr_err("%s: param is NULL\n", __func__);
return -EINVAL;
}
pr_debug("%s: Enter\n", __func__);
memset(¶m_hdr, 0, sizeof(param_hdr));
param_hdr.module_id = MODULE_ID_PP_SB;
param_hdr.instance_id = INSTANCE_ID_0;
param_hdr.param_id = PARAM_ID_PP_SB_PARAMS_VOLUME;
param_hdr.param_size = sizeof(cmd);
/* soundbooster paramerters */
cmd.sb_volume = (uint32_t)param[0];
pr_info("%s: Enter, port_id(0x%x), copp_idx(%d), volume(%d)\n",
__func__, port_id, copp_idx, cmd.sb_volume);
ret = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
(uint8_t *) &cmd);
if (ret)
pr_err("%s: Failed to set sound booster volume, err %d\n",
__func__, ret);
pr_debug("%s: Exit, ret=%d\n", __func__, ret);
return ret;
}
static int sec_audio_sound_alive_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sa_listenback_rx_vol_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sb_rx_vol_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sb_fm_rx_vol_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sa_listenback_rx_data_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_play_speed_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_adaptation_sound_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sound_balance_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_voice_tracking_info_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int rc = 0;
int be_idx = 0;
char *param_value;
int *update_param_value;
uint32_t param_size = (RMS_PAYLOAD_LEN + 1) * sizeof(uint32_t);
struct msm_pcm_routing_bdai_data msm_bedai;
struct param_hdr_v3 param_hdr;
param_value = kzalloc(param_size, GFP_KERNEL);
if (!param_value)
return -ENOMEM;
for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
if (msm_bedai.port_id == afe_port.device_tx_port)
break;
}
if ((be_idx < MSM_BACKEND_DAI_MAX) && msm_bedai.active) {
memset(¶m_hdr, 0, sizeof(param_hdr));
param_hdr.module_id = MODULE_ID_PP_SS_REC;
param_hdr.instance_id = 0x8000;
param_hdr.param_id = PARAM_ID_PP_SS_REC_GETPARAMS;
param_hdr.param_size = param_size;
rc = adm_get_pp_params(afe_port.device_tx_port, 0,
ADM_CLIENT_ID_DEFAULT, NULL, ¶m_hdr, param_value);
if (rc) {
pr_err("%s: get parameters failed:%d\n", __func__, rc);
kfree(param_value);
return -EINVAL;
}
if (param_value == NULL) {
pr_err("%s: param_value is NULL\n", __func__);
return -EINVAL;
}
update_param_value = (int *)param_value;
ucontrol->value.integer.value[0] = update_param_value[0];
pr_debug("%s: FROM DSP value[0] 0x%x\n",
__func__, update_param_value[0]);
}
kfree(param_value);
return 0;
}
static int sec_audio_myspace_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sound_boost_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_upscaler_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
ucontrol->value.integer.value[0] = upscaler_val;
return 0;
}
static int sec_audio_sb_rotation_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sb_flatmotion_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_dolby_atmos_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
int32_t volume_monitor_value[VOLUME_MONITOR_GET_PAYLOAD_SIZE] = {0};
static int sec_audio_volume_monitor_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
int be_idx = 0;
int i;
struct msm_pcm_routing_bdai_data msm_bedai;
for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
if (msm_bedai.active) {
if (msm_bedai.port_id == afe_port.headset_rx_port)
break;
if (msm_bedai.port_id == afe_port.bt_rx_port)
break;
if (msm_bedai.port_id == afe_port.usb_rx_port)
break;
}
}
if (be_idx == MSM_BACKEND_DAI_MAX) {
pr_info("%s: no active backend port\n", __func__);
goto done;
}
afe_port.volume_monitor_port = msm_bedai.port_id;
ret = afe_get_volume_monitor(afe_port.volume_monitor_port, volume_monitor_value);
if (ret) {
pr_err("%s: fail afe_get_volume_monitor error = %d\n", __func__, ret);
ret = -EINVAL;
goto done;
}
if (volume_monitor_value == NULL) {
pr_err("%s: volume_monitor_value is NULL\n", __func__);
return -EINVAL;
}
for (i = 0; i < VOLUME_MONITOR_GET_PAYLOAD_SIZE; i++)
ucontrol->value.integer.value[i] = volume_monitor_value[i];
done:
return ret;
}
static int sec_audio_volume_monitor_data_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sa_listenback_enable_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_sound_alive_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
struct msm_pcm_routing_fdai_data fe_dai_map;
struct audio_client *ac;
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA4,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED))
goto done;
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_sound_alive(ac,
(long *)ucontrol->value.integer.value);
if (ret < 0)
pr_err("%s: sound alive cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_sa_listenback_rx_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
uint32_t gain_list[8];
int ret = 0;
struct audio_client *ac;
struct msm_pcm_routing_fdai_data fe_dai_map;
gain_list[0] = (uint32_t)ucontrol->value.integer.value[0];
gain_list[1] = (uint32_t)ucontrol->value.integer.value[0];
gain_list[2] = (uint32_t)ucontrol->value.integer.value[0];
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA6,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED)) {
pr_info("%s: audio session is not active : %d\n",
__func__, fe_dai_map.strm_id);
ret = -EINVAL;
goto done;
}
pr_info("%s: stream id %d, vol = %d\n",
__func__, fe_dai_map.strm_id, gain_list[0]);
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_multich_gain(ac, 3/*num_channels*/, gain_list, NULL, true);
if (ret < 0)
pr_err("%s: listenback rx vol cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_sb_rx_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
int port_id, copp_idx;
port_id = afe_port.spk_rx_port;
ret = q6audio_get_copp_idx_from_port_id(port_id, SB_VOLUME, &copp_idx);
if (ret) {
pr_err("%s: Could not get copp idx for port_id=%d\n",
__func__, port_id);
ret = -EINVAL;
goto done;
}
ret = adm_set_sb_volume(port_id, copp_idx,
(long *)ucontrol->value.integer.value);
if (ret) {
pr_err("%s: Error setting sound booster volume, err=%d\n",
__func__, ret);
ret = -EINVAL;
goto done;
}
done:
return ret;
}
static int sec_audio_sb_fm_rx_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
uint32_t gain_list[8];
int ret = 0;
struct audio_client *ac;
struct msm_pcm_routing_fdai_data fe_dai_map;
gain_list[0] = (uint32_t)ucontrol->value.integer.value[0];
gain_list[1] = (uint32_t)ucontrol->value.integer.value[0];
gain_list[2] = (uint32_t)ucontrol->value.integer.value[0];
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA6,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED)) {
pr_info("%s: audio session is not active : %d\n",
__func__, fe_dai_map.strm_id);
ret = -EINVAL;
goto done;
}
pr_info("%s: stream id %d, vol = %d\n",
__func__, fe_dai_map.strm_id, gain_list[0]);
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_multich_gain(ac, 3/*num_channels*/, gain_list, NULL, true);
if (ret < 0)
pr_err("%s: fm rx vol cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_sa_listenback_rx_data_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
struct msm_pcm_routing_fdai_data fe_dai_map;
struct audio_client *ac;
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA6,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED))
goto done;
pr_info("%s: stream id %d\n", __func__, fe_dai_map.strm_id);
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_sa_listenback(ac, (long *)ucontrol->value.integer.value);
if (ret < 0)
pr_err("%s: listenback rx data cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_play_speed_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
struct msm_pcm_routing_fdai_data fe_dai_map;
struct audio_client *ac;
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA4,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED))
goto done;
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_play_speed(ac,
(long *)ucontrol->value.integer.value);
if (ret < 0)
pr_err("%s: play speed cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_adaptation_sound_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
struct msm_pcm_routing_fdai_data fe_dai_map;
struct audio_client *ac;
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA4,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED))
goto done;
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_adaptation_sound(ac,
(long *)ucontrol->value.integer.value);
if (ret < 0)
pr_err("%s: adaptation sound cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_sound_balance_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
struct msm_pcm_routing_fdai_data fe_dai_map;
struct audio_client *ac;
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA4,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED))
goto done;
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_sound_balance(ac,
(long *)ucontrol->value.integer.value);
if (ret < 0)
pr_err("%s: sound balance cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_voice_tracking_info_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
return ret;
}
static int sec_audio_myspace_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
struct msm_pcm_routing_fdai_data fe_dai_map;
struct audio_client *ac;
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA4,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED))
goto done;
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_myspace(ac, (long *)ucontrol->value.integer.value);
if (ret < 0)
pr_err("%s: sound myspace cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_sound_boost_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
int port_id, copp_idx;
enum sb_type func_type = (uint32_t)ucontrol->value.integer.value[0];
port_id = afe_port.spk_rx_port;
ret = q6audio_get_copp_idx_from_port_id(port_id, func_type, &copp_idx);
if (ret) {
pr_err("%s: Could not get copp idx for port_id=%d\n",
__func__, port_id);
ret = -EINVAL;
goto done;
}
ret = adm_set_sound_booster(port_id, copp_idx,
(long *)ucontrol->value.integer.value);
if (ret) {
pr_err("%s: Error setting Sound Focus Params, err=%d\n",
__func__, ret);
ret = -EINVAL;
goto done;
}
done:
return ret;
}
static int sec_audio_upscaler_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
struct msm_pcm_routing_fdai_data fe_dai_map;
struct audio_client *ac;
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA4,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED))
goto done;
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_upscaler(ac, (long *)ucontrol->value.integer.value);
if (ret < 0)
pr_err("%s: upscaler cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
/*
* Stream Information
* 0 : Deep/Offload
* 1 : Low Latency
*
* Rotation Information
* 0 : Top up
* 1 : Left up
* 2 : Bottom up
* 3 : Right up
*/
static int sec_audio_sb_rotation_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
int port_id, copp_idx;
uint32_t stream = 0;
uint32_t rotation = 0;
enum sb_type func_type = SB_MAX;
stream = (uint32_t)ucontrol->value.integer.value[0];
rotation = (uint32_t)ucontrol->value.integer.value[1];
switch (stream) {
case DEEP_OFFLOAD_MODE:
func_type = SB_ROTATION;
break;
case LOW_LATENCY_MODE:
func_type = SB_ROTATION_LL;
break;
case RINGTONE_MODE:
func_type = SB_ROTATION_RINGTONE;
break;
default:
pr_info("%s: unknown stream type\n", __func__);
break;
}
port_id = afe_port.spk_rx_port;
ret = q6audio_get_copp_idx_from_port_id(port_id, func_type, &copp_idx);
if (ret) {
pr_err("%s: Could not get copp idx for port_id=%d\n",
__func__, port_id);
ret = -EINVAL;
goto done;
}
ret = adm_set_sb_rotation(port_id, copp_idx, rotation);
if (ret) {
pr_err("%s: Error setting Sound boost rotation, err=%d\n",
__func__, ret);
ret = -EINVAL;
goto done;
}
done:
return ret;
}
static int sec_audio_sb_flatmotion_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
int port_id, copp_idx;
port_id = afe_port.spk_rx_port;
ret = q6audio_get_copp_idx_from_port_id(port_id, SB_FLATMOTION, &copp_idx);
if (ret) {
pr_err("%s: Could not get copp idx for port_id=%d\n",
__func__, port_id);
ret = -EINVAL;
goto done;
}
ret = adm_set_sb_flatmotion(port_id, copp_idx,
(long *)ucontrol->value.integer.value);
if (ret) {
pr_err("%s: Error setting Sound boost flatmotion, err=%d\n",
__func__, ret);
ret = -EINVAL;
goto done;
}
done:
return ret;
}
static int sec_audio_dolby_atmos_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
struct msm_pcm_routing_fdai_data fe_dai_map;
struct audio_client *ac;
mutex_lock(&asm_lock);
msm_pcm_routing_get_fedai_info(MSM_FRONTEND_DAI_MULTIMEDIA4,
SESSION_TYPE_RX, &fe_dai_map);
if ((fe_dai_map.strm_id <= 0) ||
(fe_dai_map.strm_id > ASM_ACTIVE_STREAMS_ALLOWED))
goto done;
ac = q6asm_get_audio_client(fe_dai_map.strm_id);
ret = q6asm_set_dolby_atmos(ac, (long *)ucontrol->value.integer.value);
if (ret < 0)
pr_err("%s: dolby atmos cmd failed ret=%d\n", __func__, ret);
done:
mutex_unlock(&asm_lock);
return ret;
}
static int sec_audio_volume_monitor_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_audio_volume_monitor_data_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
int port_id;
int be_idx = 0;
int enable = ucontrol->value.integer.value[0];
int volume_level = ucontrol->value.integer.value[1];
int avc_support = ucontrol->value.integer.value[2];
int db_atten = ucontrol->value.integer.value[3];
struct msm_pcm_routing_bdai_data msm_bedai;
for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
if (msm_bedai.active) {
if (msm_bedai.port_id == afe_port.headset_rx_port)
break;
if (msm_bedai.port_id == afe_port.bt_rx_port)
break;
if (msm_bedai.port_id == afe_port.usb_rx_port)
break;
}
}
if (be_idx == MSM_BACKEND_DAI_MAX) {
pr_info("%s: no active backend port\n", __func__);
goto done;
}
port_id = msm_bedai.port_id;
pr_info("%s: port_id : %x , enable : %d volume_level : %d avc_support : %d db_atten : %d\n",
__func__, port_id, enable, volume_level, avc_support, db_atten);
ret = afe_set_volume_monitor(port_id, enable, volume_level, avc_support, db_atten);
if (ret) {
pr_err("%s: Error setting volume monitor, err=%d\n",
__func__, ret);
ret = -EINVAL;
goto done;
}
done:
return ret;
}
static int sec_audio_sa_listenback_enable_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
int port_id;
int be_idx = 0;
int enable = ucontrol->value.integer.value[0];
struct msm_pcm_routing_bdai_data msm_bedai;
for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
if (msm_bedai.active) {
if (msm_bedai.port_id == afe_port.usb_rx_port)
break;
if (msm_bedai.port_id == afe_port.headset_rx_port)
break;
}
}
if (be_idx == MSM_BACKEND_DAI_MAX) {
pr_info("%s: no active backend port\n", __func__);
goto done;
}
port_id = msm_bedai.port_id;
pr_info("%s: port_id : %x , enable : %d\n",
__func__, port_id, enable);
ret = afe_set_sa_listenback(port_id, enable);
if (ret) {
pr_err("%s: Error setting set listenback, err=%d\n",
__func__, ret);
ret = -EINVAL;
goto done;
}
done:
return ret;
}
static int sec_afe_remote_mic_vol(int index)
{
int ret = 0;
int port_id;
int be_idx = 0;
struct msm_pcm_routing_bdai_data msm_bedai;
for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
if (msm_bedai.active) {
if (msm_bedai.port_id == afe_port.device_tx_port)
break;
}
}
if (be_idx == MSM_BACKEND_DAI_MAX) {
pr_info("%s: no active backend port\n", __func__);
goto done;
}
port_id = msm_bedai.port_id;
pr_info("%s: port_id : %x , index : %d\n",
__func__, port_id, index);
ret = afe_set_remote_mic_vol(port_id, index);
if (ret) {
pr_err("%s: Error setting set listenback, err=%d\n",
__func__, ret);
ret = -EINVAL;
goto done;
}
done:
return ret;
}
static int sec_remote_mic_vol_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return 0;
}
static int sec_remote_mic_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int volumeindex = ucontrol->value.integer.value[0];
if ((volumeindex < 0) || (volumeindex > 15)) {
pr_err("%s: volumeindex=%d is wrong value\n", __func__, volumeindex);
return -EINVAL;
}
pr_debug("%s: volumeindex=%d\n", __func__, volumeindex);
return sec_afe_remote_mic_vol(volumeindex);
}
static const struct snd_kcontrol_new samsung_solution_mixer_controls[] = {
SOC_SINGLE_MULTI_EXT("SA data", SND_SOC_NOPM, 0, 65535, 0, 27,
sec_audio_sound_alive_get,
sec_audio_sound_alive_put),
SOC_SINGLE_EXT("SA LISTENBACK RX volume", SND_SOC_NOPM, 0, 65535, 0,
sec_audio_sa_listenback_rx_vol_get,
sec_audio_sa_listenback_rx_vol_put),
SOC_SINGLE_MULTI_EXT("SA LISTENBACK RX data", SND_SOC_NOPM, 0, 65535, 0, 27,
sec_audio_sa_listenback_rx_data_get,
sec_audio_sa_listenback_rx_data_put),
SOC_SINGLE_MULTI_EXT("VSP data", SND_SOC_NOPM, 0, 65535, 0, 1,
sec_audio_play_speed_get,
sec_audio_play_speed_put),
SOC_SINGLE_MULTI_EXT("Audio DHA data", SND_SOC_NOPM, 0, 65535, 0, 14,
sec_audio_adaptation_sound_get,
sec_audio_adaptation_sound_put),
SOC_SINGLE_MULTI_EXT("LRSM data", SND_SOC_NOPM, 0, 65535, 0, 2,
sec_audio_sound_balance_get,
sec_audio_sound_balance_put),
SOC_SINGLE_EXT("VoiceTrackInfo", SND_SOC_NOPM, 0, 2147483647, 0,
sec_audio_voice_tracking_info_get,
sec_audio_voice_tracking_info_put),
SOC_SINGLE_MULTI_EXT("MSP data", SND_SOC_NOPM, 0, 65535, 0, 1,
sec_audio_myspace_get, sec_audio_myspace_put),
SOC_SINGLE_MULTI_EXT("SB enable", SND_SOC_NOPM, 0, 65535, 0, 1,
sec_audio_sound_boost_get,
sec_audio_sound_boost_put),
SOC_SINGLE_MULTI_EXT("UPSCALER", SND_SOC_NOPM, 0, 65535, 0, 1,
sec_audio_upscaler_get, sec_audio_upscaler_put),
SOC_SINGLE_MULTI_EXT("SB rotation", SND_SOC_NOPM, 0, 65535, 0, 2,
sec_audio_sb_rotation_get, sec_audio_sb_rotation_put),
SOC_SINGLE_MULTI_EXT("SB flatmotion", SND_SOC_NOPM, 0, 65535, 0, 1,
sec_audio_sb_flatmotion_get, sec_audio_sb_flatmotion_put),
SOC_SINGLE_MULTI_EXT("DA data", SND_SOC_NOPM, 0, 65535, 0, 3,
sec_audio_dolby_atmos_get, sec_audio_dolby_atmos_put),
SOC_SINGLE_EXT("SB RX Volume", SND_SOC_NOPM, 0, 65535, 0,
sec_audio_sb_rx_vol_get,
sec_audio_sb_rx_vol_put),
SOC_SINGLE_EXT("SB FM RX Volume", SND_SOC_NOPM, 0, 65535, 0,
sec_audio_sb_fm_rx_vol_get,
sec_audio_sb_fm_rx_vol_put),
SOC_SINGLE_EXT("Remote Mic Vol Index", SND_SOC_NOPM, 0, 65535, 0,
sec_remote_mic_vol_get,
sec_remote_mic_vol_put),
SOC_SINGLE_MULTI_EXT("VM Energy", SND_SOC_NOPM, 0, 65535, 0, 61,
sec_audio_volume_monitor_get, sec_audio_volume_monitor_put),
SOC_SINGLE_MULTI_EXT("VM data", SND_SOC_NOPM, 0, 65535, 0, 4,
sec_audio_volume_monitor_data_get, sec_audio_volume_monitor_data_put),
SOC_SINGLE_EXT("Listenback Enable", SND_SOC_NOPM, 0, 65535, 0,
sec_audio_sa_listenback_enable_get,
sec_audio_sa_listenback_enable_put),
};
static int q6audio_adaptation_platform_probe(struct snd_soc_component *component)
{
pr_info("%s: platform\n", __func__);
session = q6asm_get_audio_session();
snd_soc_add_component_controls(component,
samsung_solution_mixer_controls,
ARRAY_SIZE(samsung_solution_mixer_controls));
return 0;
}
static const struct snd_soc_component_driver q6audio_adaptation = {
.probe = q6audio_adaptation_platform_probe,
};
static int samsung_q6audio_adaptation_probe(struct platform_device *pdev)
{
int ret;
pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
atomic_set(&this_afe.state, 0);
atomic_set(&this_afe.status, 0);
this_afe.apr = NULL;
init_waitqueue_head(&this_afe.wait);
mutex_init(&asm_lock);
ret = of_property_read_u32(pdev->dev.of_node,
"adaptation,device-tx-port-id",
&afe_port.device_tx_port);
if (ret)
pr_err("%s : Unable to read Tx BE\n", __func__);
ret = of_property_read_u32(pdev->dev.of_node,
"adaptation,spk-rx-port-id",
&afe_port.spk_rx_port);
if (ret)
pr_debug("%s : Unable to find amp-rx-port\n", __func__);
ret = of_property_read_u32(pdev->dev.of_node,
"adaptation,usb-rx-port-id",
&afe_port.usb_rx_port);
if (ret)
pr_debug("%s : Unable to find usb-rx-port\n", __func__);
ret = of_property_read_u32(pdev->dev.of_node,
"adaptation,bt-rx-port-id",
&afe_port.bt_rx_port);
if (ret)
pr_debug("%s : Unable to find bt-rx-port\n", __func__);
ret = of_property_read_u32(pdev->dev.of_node,
"adaptation,headset-rx-port-id",
&afe_port.headset_rx_port);
if (ret)
pr_debug("%s : Unable to find headset-rx-port\n", __func__);
return snd_soc_register_component(&pdev->dev,
&q6audio_adaptation, NULL, 0);
}
static int samsung_q6audio_adaptation_remove(struct platform_device *pdev)
{
pr_debug("%s\n", __func__);
snd_soc_unregister_component(&pdev->dev);
return 0;
}
static const struct of_device_id samsung_q6audio_adaptation_dt_match[] = {
{.compatible = "samsung,q6audio-adaptation"},
{}
};
MODULE_DEVICE_TABLE(of, samsung_q6audio_adaptation_dt_match);
static struct platform_driver samsung_q6audio_adaptation_driver = {
.driver = {
.name = "samsung-q6audio-adaptation",
.owner = THIS_MODULE,
.of_match_table = samsung_q6audio_adaptation_dt_match,
},
.probe = samsung_q6audio_adaptation_probe,
.remove = samsung_q6audio_adaptation_remove,
};
int __init sec_soc_audio_platform_init(void)
{
pr_debug("%s\n", __func__);
return platform_driver_register(&samsung_q6audio_adaptation_driver);
}
void sec_soc_audio_platform_exit(void)
{
pr_debug("%s\n", __func__);
platform_driver_unregister(&samsung_q6audio_adaptation_driver);
}
MODULE_DESCRIPTION("Samsung Audio Adaptation platform driver");
MODULE_LICENSE("GPL v2");
|