forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
riptide.c
2232 lines (2026 loc) · 64.3 KB
/
riptide.c
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
/*
* Driver for the Conexant Riptide Soundchip
*
* Copyright (c) 2004 Peter Gruber <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
History:
- 02/15/2004 first release
This Driver is based on the OSS Driver version from Linuxant (riptide-0.6lnxtbeta03111100)
credits from the original files:
MODULE NAME: cnxt_rt.h
AUTHOR: K. Lazarev (Transcribed by KNL)
HISTORY: Major Revision Date By
----------------------------- -------- -----
Created 02/1/2000 KNL
MODULE NAME: int_mdl.c
AUTHOR: Konstantin Lazarev (Transcribed by KNL)
HISTORY: Major Revision Date By
----------------------------- -------- -----
Created 10/01/99 KNL
MODULE NAME: riptide.h
AUTHOR: O. Druzhinin (Transcribed by OLD)
HISTORY: Major Revision Date By
----------------------------- -------- -----
Created 10/16/97 OLD
MODULE NAME: Rp_Cmdif.cpp
AUTHOR: O. Druzhinin (Transcribed by OLD)
K. Lazarev (Transcribed by KNL)
HISTORY: Major Revision Date By
----------------------------- -------- -----
Adopted from NT4 driver 6/22/99 OLD
Ported to Linux 9/01/99 KNL
MODULE NAME: rt_hw.c
AUTHOR: O. Druzhinin (Transcribed by OLD)
C. Lazarev (Transcribed by CNL)
HISTORY: Major Revision Date By
----------------------------- -------- -----
Created 11/18/97 OLD
Hardware functions for RipTide 11/24/97 CNL
(ES1) are coded
Hardware functions for RipTide 12/24/97 CNL
(A0) are coded
Hardware functions for RipTide 03/20/98 CNL
(A1) are coded
Boot loader is included 05/07/98 CNL
Redesigned for WDM 07/27/98 CNL
Redesigned for Linux 09/01/99 CNL
MODULE NAME: rt_hw.h
AUTHOR: C. Lazarev (Transcribed by CNL)
HISTORY: Major Revision Date By
----------------------------- -------- -----
Created 11/18/97 CNL
MODULE NAME: rt_mdl.c
AUTHOR: Konstantin Lazarev (Transcribed by KNL)
HISTORY: Major Revision Date By
----------------------------- -------- -----
Created 10/01/99 KNL
MODULE NAME: mixer.h
AUTHOR: K. Kenney
HISTORY: Major Revision Date By
----------------------------- -------- -----
Created from MS W95 Sample 11/28/95 KRS
RipTide 10/15/97 KRS
Adopted for Windows NT driver 01/20/98 CNL
*/
#include <sound/driver.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/gameport.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include <asm/io.h>
#include <sound/core.h>
#include <sound/info.h>
#include <sound/control.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/ac97_codec.h>
#include <sound/mpu401.h>
#include <sound/opl3.h>
#include <sound/initval.h>
#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
#define SUPPORT_JOYSTICK 1
#endif
MODULE_AUTHOR("Peter Gruber <[email protected]>");
MODULE_DESCRIPTION("riptide");
MODULE_LICENSE("GPL");
MODULE_SUPPORTED_DEVICE("{{Conexant,Riptide}}");
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
#ifdef SUPPORT_JOYSTICK
static int joystick_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x200 };
#endif
static int mpu_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x330 };
static int opl3_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x388 };
module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for Riptide soundcard.");
module_param_array(id, charp, NULL, 0444);
MODULE_PARM_DESC(id, "ID string for Riptide soundcard.");
module_param_array(enable, bool, NULL, 0444);
MODULE_PARM_DESC(enable, "Enable Riptide soundcard.");
#ifdef SUPPORT_JOYSTICK
module_param_array(joystick_port, int, NULL, 0444);
MODULE_PARM_DESC(joystick_port, "Joystick port # for Riptide soundcard.");
#endif
module_param_array(mpu_port, int, NULL, 0444);
MODULE_PARM_DESC(mpu_port, "MPU401 port # for Riptide driver.");
module_param_array(opl3_port, int, NULL, 0444);
MODULE_PARM_DESC(opl3_port, "OPL3 port # for Riptide driver.");
/*
*/
#define MPU401_HW_RIPTIDE MPU401_HW_MPU401
#define OPL3_HW_RIPTIDE OPL3_HW_OPL3
#define PCI_EXT_CapId 0x40
#define PCI_EXT_NextCapPrt 0x41
#define PCI_EXT_PWMC 0x42
#define PCI_EXT_PWSCR 0x44
#define PCI_EXT_Data00 0x46
#define PCI_EXT_PMSCR_BSE 0x47
#define PCI_EXT_SB_Base 0x48
#define PCI_EXT_FM_Base 0x4a
#define PCI_EXT_MPU_Base 0x4C
#define PCI_EXT_Game_Base 0x4E
#define PCI_EXT_Legacy_Mask 0x50
#define PCI_EXT_AsicRev 0x52
#define PCI_EXT_Reserved3 0x53
#define LEGACY_ENABLE_ALL 0x8000 /* legacy device options */
#define LEGACY_ENABLE_SB 0x4000
#define LEGACY_ENABLE_FM 0x2000
#define LEGACY_ENABLE_MPU_INT 0x1000
#define LEGACY_ENABLE_MPU 0x0800
#define LEGACY_ENABLE_GAMEPORT 0x0400
#define MAX_WRITE_RETRY 10 /* cmd interface limits */
#define MAX_ERROR_COUNT 10
#define CMDIF_TIMEOUT 500000
#define RESET_TRIES 5
#define READ_PORT_ULONG(p) inl((unsigned long)&(p))
#define WRITE_PORT_ULONG(p,x) outl(x,(unsigned long)&(p))
#define READ_AUDIO_CONTROL(p) READ_PORT_ULONG(p->audio_control)
#define WRITE_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,x)
#define UMASK_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,READ_PORT_ULONG(p->audio_control)|x)
#define MASK_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,READ_PORT_ULONG(p->audio_control)&x)
#define READ_AUDIO_STATUS(p) READ_PORT_ULONG(p->audio_status)
#define SET_GRESET(p) UMASK_AUDIO_CONTROL(p,0x0001) /* global reset switch */
#define UNSET_GRESET(p) MASK_AUDIO_CONTROL(p,~0x0001)
#define SET_AIE(p) UMASK_AUDIO_CONTROL(p,0x0004) /* interrupt enable */
#define UNSET_AIE(p) MASK_AUDIO_CONTROL(p,~0x0004)
#define SET_AIACK(p) UMASK_AUDIO_CONTROL(p,0x0008) /* interrupt acknowledge */
#define UNSET_AIACKT(p) MASKAUDIO_CONTROL(p,~0x0008)
#define SET_ECMDAE(p) UMASK_AUDIO_CONTROL(p,0x0010)
#define UNSET_ECMDAE(p) MASK_AUDIO_CONTROL(p,~0x0010)
#define SET_ECMDBE(p) UMASK_AUDIO_CONTROL(p,0x0020)
#define UNSET_ECMDBE(p) MASK_AUDIO_CONTROL(p,~0x0020)
#define SET_EDATAF(p) UMASK_AUDIO_CONTROL(p,0x0040)
#define UNSET_EDATAF(p) MASK_AUDIO_CONTROL(p,~0x0040)
#define SET_EDATBF(p) UMASK_AUDIO_CONTROL(p,0x0080)
#define UNSET_EDATBF(p) MASK_AUDIO_CONTROL(p,~0x0080)
#define SET_ESBIRQON(p) UMASK_AUDIO_CONTROL(p,0x0100)
#define UNSET_ESBIRQON(p) MASK_AUDIO_CONTROL(p,~0x0100)
#define SET_EMPUIRQ(p) UMASK_AUDIO_CONTROL(p,0x0200)
#define UNSET_EMPUIRQ(p) MASK_AUDIO_CONTROL(p,~0x0200)
#define IS_CMDE(a) (READ_PORT_ULONG(a->stat)&0x1) /* cmd empty */
#define IS_DATF(a) (READ_PORT_ULONG(a->stat)&0x2) /* data filled */
#define IS_READY(p) (READ_AUDIO_STATUS(p)&0x0001)
#define IS_DLREADY(p) (READ_AUDIO_STATUS(p)&0x0002)
#define IS_DLERR(p) (READ_AUDIO_STATUS(p)&0x0004)
#define IS_GERR(p) (READ_AUDIO_STATUS(p)&0x0008) /* error ! */
#define IS_CMDAEIRQ(p) (READ_AUDIO_STATUS(p)&0x0010)
#define IS_CMDBEIRQ(p) (READ_AUDIO_STATUS(p)&0x0020)
#define IS_DATAFIRQ(p) (READ_AUDIO_STATUS(p)&0x0040)
#define IS_DATBFIRQ(p) (READ_AUDIO_STATUS(p)&0x0080)
#define IS_EOBIRQ(p) (READ_AUDIO_STATUS(p)&0x0100) /* interrupt status */
#define IS_EOSIRQ(p) (READ_AUDIO_STATUS(p)&0x0200)
#define IS_EOCIRQ(p) (READ_AUDIO_STATUS(p)&0x0400)
#define IS_UNSLIRQ(p) (READ_AUDIO_STATUS(p)&0x0800)
#define IS_SBIRQ(p) (READ_AUDIO_STATUS(p)&0x1000)
#define IS_MPUIRQ(p) (READ_AUDIO_STATUS(p)&0x2000)
#define RESP 0x00000001 /* command flags */
#define PARM 0x00000002
#define CMDA 0x00000004
#define CMDB 0x00000008
#define NILL 0x00000000
#define LONG0(a) ((u32)a) /* shifts and masks */
#define BYTE0(a) (LONG0(a)&0xff)
#define BYTE1(a) (BYTE0(a)<<8)
#define BYTE2(a) (BYTE0(a)<<16)
#define BYTE3(a) (BYTE0(a)<<24)
#define WORD0(a) (LONG0(a)&0xffff)
#define WORD1(a) (WORD0(a)<<8)
#define WORD2(a) (WORD0(a)<<16)
#define TRINIB0(a) (LONG0(a)&0xffffff)
#define TRINIB1(a) (TRINIB0(a)<<8)
#define RET(a) ((union cmdret *)(a))
#define SEND_GETV(p,b) sendcmd(p,RESP,GETV,0,RET(b)) /* get version */
#define SEND_GETC(p,b,c) sendcmd(p,PARM|RESP,GETC,c,RET(b))
#define SEND_GUNS(p,b) sendcmd(p,RESP,GUNS,0,RET(b))
#define SEND_SCID(p,b) sendcmd(p,RESP,SCID,0,RET(b))
#define SEND_RMEM(p,b,c,d) sendcmd(p,PARM|RESP,RMEM|BYTE1(b),LONG0(c),RET(d)) /* memory access for firmware write */
#define SEND_SMEM(p,b,c) sendcmd(p,PARM,SMEM|BYTE1(b),LONG0(c),RET(0)) /* memory access for firmware write */
#define SEND_WMEM(p,b,c) sendcmd(p,PARM,WMEM|BYTE1(b),LONG0(c),RET(0)) /* memory access for firmware write */
#define SEND_SDTM(p,b,c) sendcmd(p,PARM|RESP,SDTM|TRINIB1(b),0,RET(c)) /* memory access for firmware write */
#define SEND_GOTO(p,b) sendcmd(p,PARM,GOTO,LONG0(b),RET(0)) /* memory access for firmware write */
#define SEND_SETDPLL(p) sendcmd(p,0,ARM_SETDPLL,0,RET(0))
#define SEND_SSTR(p,b,c) sendcmd(p,PARM,SSTR|BYTE3(b),LONG0(c),RET(0)) /* start stream */
#define SEND_PSTR(p,b) sendcmd(p,PARM,PSTR,BYTE3(b),RET(0)) /* pause stream */
#define SEND_KSTR(p,b) sendcmd(p,PARM,KSTR,BYTE3(b),RET(0)) /* stop stream */
#define SEND_KDMA(p) sendcmd(p,0,KDMA,0,RET(0)) /* stop all dma */
#define SEND_GPOS(p,b,c,d) sendcmd(p,PARM|RESP,GPOS,BYTE3(c)|BYTE2(b),RET(d)) /* get position in dma */
#define SEND_SETF(p,b,c,d,e,f,g) sendcmd(p,PARM,SETF|WORD1(b)|BYTE3(c),d|BYTE1(e)|BYTE2(f)|BYTE3(g),RET(0)) /* set sample format at mixer */
#define SEND_GSTS(p,b,c,d) sendcmd(p,PARM|RESP,GSTS,BYTE3(c)|BYTE2(b),RET(d))
#define SEND_NGPOS(p,b,c,d) sendcmd(p,PARM|RESP,NGPOS,BYTE3(c)|BYTE2(b),RET(d))
#define SEND_PSEL(p,b,c) sendcmd(p,PARM,PSEL,BYTE2(b)|BYTE3(c),RET(0)) /* activate lbus path */
#define SEND_PCLR(p,b,c) sendcmd(p,PARM,PCLR,BYTE2(b)|BYTE3(c),RET(0)) /* deactivate lbus path */
#define SEND_PLST(p,b) sendcmd(p,PARM,PLST,BYTE3(b),RET(0))
#define SEND_RSSV(p,b,c,d) sendcmd(p,PARM|RESP,RSSV,BYTE2(b)|BYTE3(c),RET(d))
#define SEND_LSEL(p,b,c,d,e,f,g,h) sendcmd(p,PARM,LSEL|BYTE1(b)|BYTE2(c)|BYTE3(d),BYTE0(e)|BYTE1(f)|BYTE2(g)|BYTE3(h),RET(0)) /* select paths for internal connections */
#define SEND_SSRC(p,b,c,d,e) sendcmd(p,PARM,SSRC|BYTE1(b)|WORD2(c),WORD0(d)|WORD2(e),RET(0)) /* configure source */
#define SEND_SLST(p,b) sendcmd(p,PARM,SLST,BYTE3(b),RET(0))
#define SEND_RSRC(p,b,c) sendcmd(p,RESP,RSRC|BYTE1(b),0,RET(c)) /* read source config */
#define SEND_SSRB(p,b,c) sendcmd(p,PARM,SSRB|BYTE1(b),WORD2(c),RET(0))
#define SEND_SDGV(p,b,c,d,e) sendcmd(p,PARM,SDGV|BYTE2(b)|BYTE3(c),WORD0(d)|WORD2(e),RET(0)) /* set digital mixer */
#define SEND_RDGV(p,b,c,d) sendcmd(p,PARM|RESP,RDGV|BYTE2(b)|BYTE3(c),0,RET(d)) /* read digital mixer */
#define SEND_DLST(p,b) sendcmd(p,PARM,DLST,BYTE3(b),RET(0))
#define SEND_SACR(p,b,c) sendcmd(p,PARM,SACR,WORD0(b)|WORD2(c),RET(0)) /* set AC97 register */
#define SEND_RACR(p,b,c) sendcmd(p,PARM|RESP,RACR,WORD2(b),RET(c)) /* get AC97 register */
#define SEND_ALST(p,b) sendcmd(p,PARM,ALST,BYTE3(b),RET(0))
#define SEND_TXAC(p,b,c,d,e,f) sendcmd(p,PARM,TXAC|BYTE1(b)|WORD2(c),WORD0(d)|BYTE2(e)|BYTE3(f),RET(0))
#define SEND_RXAC(p,b,c,d) sendcmd(p,PARM|RESP,RXAC,BYTE2(b)|BYTE3(c),RET(d))
#define SEND_SI2S(p,b) sendcmd(p,PARM,SI2S,WORD2(b),RET(0))
#define EOB_STATUS 0x80000000 /* status flags : block boundary */
#define EOS_STATUS 0x40000000 /* : stoppped */
#define EOC_STATUS 0x20000000 /* : stream end */
#define ERR_STATUS 0x10000000
#define EMPTY_STATUS 0x08000000
#define IEOB_ENABLE 0x1 /* enable interrupts for status notification above */
#define IEOS_ENABLE 0x2
#define IEOC_ENABLE 0x4
#define RDONCE 0x8
#define DESC_MAX_MASK 0xff
#define ST_PLAY 0x1 /* stream states */
#define ST_STOP 0x2
#define ST_PAUSE 0x4
#define I2S_INTDEC 3 /* config for I2S link */
#define I2S_MERGER 0
#define I2S_SPLITTER 0
#define I2S_MIXER 7
#define I2S_RATE 44100
#define MODEM_INTDEC 4 /* config for modem link */
#define MODEM_MERGER 3
#define MODEM_SPLITTER 0
#define MODEM_MIXER 11
#define FM_INTDEC 3 /* config for FM/OPL3 link */
#define FM_MERGER 0
#define FM_SPLITTER 0
#define FM_MIXER 9
#define SPLIT_PATH 0x80 /* path splitting flag */
enum FIRMWARE {
DATA_REC = 0, EXT_END_OF_FILE, EXT_SEG_ADDR_REC, EXT_GOTO_CMD_REC,
EXT_LIN_ADDR_REC,
};
enum CMDS {
GETV = 0x00, GETC, GUNS, SCID, RMEM =
0x10, SMEM, WMEM, SDTM, GOTO, SSTR =
0x20, PSTR, KSTR, KDMA, GPOS, SETF, GSTS, NGPOS, PSEL =
0x30, PCLR, PLST, RSSV, LSEL, SSRC = 0x40, SLST, RSRC, SSRB, SDGV =
0x50, RDGV, DLST, SACR = 0x60, RACR, ALST, TXAC, RXAC, SI2S =
0x70, ARM_SETDPLL = 0x72,
};
enum E1SOURCE {
ARM2LBUS_FIFO0 = 0, ARM2LBUS_FIFO1, ARM2LBUS_FIFO2, ARM2LBUS_FIFO3,
ARM2LBUS_FIFO4, ARM2LBUS_FIFO5, ARM2LBUS_FIFO6, ARM2LBUS_FIFO7,
ARM2LBUS_FIFO8, ARM2LBUS_FIFO9, ARM2LBUS_FIFO10, ARM2LBUS_FIFO11,
ARM2LBUS_FIFO12, ARM2LBUS_FIFO13, ARM2LBUS_FIFO14, ARM2LBUS_FIFO15,
INTER0_OUT, INTER1_OUT, INTER2_OUT, INTER3_OUT, INTER4_OUT,
INTERM0_OUT, INTERM1_OUT, INTERM2_OUT, INTERM3_OUT, INTERM4_OUT,
INTERM5_OUT, INTERM6_OUT, DECIMM0_OUT, DECIMM1_OUT, DECIMM2_OUT,
DECIMM3_OUT, DECIM0_OUT, SR3_4_OUT, OPL3_SAMPLE, ASRC0, ASRC1,
ACLNK2PADC, ACLNK2MODEM0RX, ACLNK2MIC, ACLNK2MODEM1RX, ACLNK2HNDMIC,
DIGITAL_MIXER_OUT0, GAINFUNC0_OUT, GAINFUNC1_OUT, GAINFUNC2_OUT,
GAINFUNC3_OUT, GAINFUNC4_OUT, SOFTMODEMTX, SPLITTER0_OUTL,
SPLITTER0_OUTR, SPLITTER1_OUTL, SPLITTER1_OUTR, SPLITTER2_OUTL,
SPLITTER2_OUTR, SPLITTER3_OUTL, SPLITTER3_OUTR, MERGER0_OUT,
MERGER1_OUT, MERGER2_OUT, MERGER3_OUT, ARM2LBUS_FIFO_DIRECT, NO_OUT
};
enum E2SINK {
LBUS2ARM_FIFO0 = 0, LBUS2ARM_FIFO1, LBUS2ARM_FIFO2, LBUS2ARM_FIFO3,
LBUS2ARM_FIFO4, LBUS2ARM_FIFO5, LBUS2ARM_FIFO6, LBUS2ARM_FIFO7,
INTER0_IN, INTER1_IN, INTER2_IN, INTER3_IN, INTER4_IN, INTERM0_IN,
INTERM1_IN, INTERM2_IN, INTERM3_IN, INTERM4_IN, INTERM5_IN, INTERM6_IN,
DECIMM0_IN, DECIMM1_IN, DECIMM2_IN, DECIMM3_IN, DECIM0_IN, SR3_4_IN,
PDAC2ACLNK, MODEM0TX2ACLNK, MODEM1TX2ACLNK, HNDSPK2ACLNK,
DIGITAL_MIXER_IN0, DIGITAL_MIXER_IN1, DIGITAL_MIXER_IN2,
DIGITAL_MIXER_IN3, DIGITAL_MIXER_IN4, DIGITAL_MIXER_IN5,
DIGITAL_MIXER_IN6, DIGITAL_MIXER_IN7, DIGITAL_MIXER_IN8,
DIGITAL_MIXER_IN9, DIGITAL_MIXER_IN10, DIGITAL_MIXER_IN11,
GAINFUNC0_IN, GAINFUNC1_IN, GAINFUNC2_IN, GAINFUNC3_IN, GAINFUNC4_IN,
SOFTMODEMRX, SPLITTER0_IN, SPLITTER1_IN, SPLITTER2_IN, SPLITTER3_IN,
MERGER0_INL, MERGER0_INR, MERGER1_INL, MERGER1_INR, MERGER2_INL,
MERGER2_INR, MERGER3_INL, MERGER3_INR, E2SINK_MAX
};
enum LBUS_SINK {
LS_SRC_INTERPOLATOR = 0, LS_SRC_INTERPOLATORM, LS_SRC_DECIMATOR,
LS_SRC_DECIMATORM, LS_MIXER_IN, LS_MIXER_GAIN_FUNCTION,
LS_SRC_SPLITTER, LS_SRC_MERGER, LS_NONE1, LS_NONE2,
};
enum RT_CHANNEL_IDS {
M0TX = 0, M1TX, TAMTX, HSSPKR, PDAC, DSNDTX0, DSNDTX1, DSNDTX2,
DSNDTX3, DSNDTX4, DSNDTX5, DSNDTX6, DSNDTX7, WVSTRTX, COP3DTX, SPARE,
M0RX, HSMIC, M1RX, CLEANRX, MICADC, PADC, COPRX1, COPRX2,
CHANNEL_ID_COUNTER
};
enum { SB_CMD = 0, MODEM_CMD, I2S_CMD0, I2S_CMD1, FM_CMD, MAX_CMD };
struct lbuspath {
unsigned char *noconv;
unsigned char *stereo;
unsigned char *mono;
};
struct cmdport {
u32 data1; /* cmd,param */
u32 data2; /* param */
u32 stat; /* status */
u32 pad[5];
};
struct riptideport {
u32 audio_control; /* status registers */
u32 audio_status;
u32 pad[2];
struct cmdport port[2]; /* command ports */
};
struct cmdif {
struct riptideport *hwport;
spinlock_t lock;
unsigned int cmdcnt; /* cmd statistics */
unsigned int cmdtime;
unsigned int cmdtimemax;
unsigned int cmdtimemin;
unsigned int errcnt;
int is_reset;
};
struct riptide_firmware {
u16 ASIC;
u16 CODEC;
u16 AUXDSP;
u16 PROG;
};
union cmdret {
u8 retbytes[8];
u16 retwords[4];
u32 retlongs[2];
};
union firmware_version {
union cmdret ret;
struct riptide_firmware firmware;
};
#define get_pcmhwdev(substream) (struct pcmhw *)(substream->runtime->private_data)
#define PLAYBACK_SUBSTREAMS 3
struct snd_riptide {
struct snd_card *card;
struct pci_dev *pci;
const struct firmware *fw_entry;
struct cmdif *cif;
struct snd_pcm *pcm;
struct snd_pcm *pcm_i2s;
struct snd_rawmidi *rmidi;
struct snd_opl3 *opl3;
struct snd_ac97 *ac97;
struct snd_ac97_bus *ac97_bus;
struct snd_pcm_substream *playback_substream[PLAYBACK_SUBSTREAMS];
struct snd_pcm_substream *capture_substream;
int openstreams;
int irq;
unsigned long port;
unsigned short mpuaddr;
unsigned short opladdr;
#ifdef SUPPORT_JOYSTICK
unsigned short gameaddr;
#endif
struct resource *res_port;
unsigned short device_id;
union firmware_version firmware;
spinlock_t lock;
struct tasklet_struct riptide_tq;
struct snd_info_entry *proc_entry;
unsigned long received_irqs;
unsigned long handled_irqs;
#ifdef CONFIG_PM
int in_suspend;
#endif
};
struct sgd { /* scatter gather desriptor */
u32 dwNextLink;
u32 dwSegPtrPhys;
u32 dwSegLen;
u32 dwStat_Ctl;
};
struct pcmhw { /* pcm descriptor */
struct lbuspath paths;
unsigned char *lbuspath;
unsigned char source;
unsigned char intdec[2];
unsigned char mixer;
unsigned char id;
unsigned char state;
unsigned int rate;
unsigned int channels;
snd_pcm_format_t format;
struct snd_dma_buffer sgdlist;
struct sgd *sgdbuf;
unsigned int size;
unsigned int pages;
unsigned int oldpos;
unsigned int pointer;
};
#define CMDRET_ZERO (union cmdret){{(u32)0, (u32) 0}}
static int sendcmd(struct cmdif *cif, u32 flags, u32 cmd, u32 parm,
union cmdret *ret);
static int getsourcesink(struct cmdif *cif, unsigned char source,
unsigned char sink, unsigned char *a,
unsigned char *b);
static int snd_riptide_initialize(struct snd_riptide *chip);
static int riptide_reset(struct cmdif *cif, struct snd_riptide *chip);
/*
*/
static struct pci_device_id snd_riptide_ids[] = {
{
.vendor = 0x127a,.device = 0x4310,
.subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID,
},
{
.vendor = 0x127a,.device = 0x4320,
.subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID,
},
{
.vendor = 0x127a,.device = 0x4330,
.subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID,
},
{
.vendor = 0x127a,.device = 0x4340,
.subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID,
},
{0,},
};
#ifdef SUPPORT_JOYSTICK
static struct pci_device_id snd_riptide_joystick_ids[] __devinitdata = {
{
.vendor = 0x127a,.device = 0x4312,
.subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID,
},
{
.vendor = 0x127a,.device = 0x4322,
.subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID,
},
{.vendor = 0x127a,.device = 0x4332,
.subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID,
},
{.vendor = 0x127a,.device = 0x4342,
.subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID,
},
{0,},
};
#endif
MODULE_DEVICE_TABLE(pci, snd_riptide_ids);
/*
*/
static unsigned char lbusin2out[E2SINK_MAX + 1][2] = {
{NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT,
LS_NONE2},
{NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT,
LS_NONE2},
{INTER0_OUT, LS_SRC_INTERPOLATOR}, {INTER1_OUT, LS_SRC_INTERPOLATOR},
{INTER2_OUT, LS_SRC_INTERPOLATOR}, {INTER3_OUT, LS_SRC_INTERPOLATOR},
{INTER4_OUT, LS_SRC_INTERPOLATOR}, {INTERM0_OUT, LS_SRC_INTERPOLATORM},
{INTERM1_OUT, LS_SRC_INTERPOLATORM}, {INTERM2_OUT,
LS_SRC_INTERPOLATORM},
{INTERM3_OUT, LS_SRC_INTERPOLATORM}, {INTERM4_OUT,
LS_SRC_INTERPOLATORM},
{INTERM5_OUT, LS_SRC_INTERPOLATORM}, {INTERM6_OUT,
LS_SRC_INTERPOLATORM},
{DECIMM0_OUT, LS_SRC_DECIMATORM}, {DECIMM1_OUT, LS_SRC_DECIMATORM},
{DECIMM2_OUT, LS_SRC_DECIMATORM}, {DECIMM3_OUT, LS_SRC_DECIMATORM},
{DECIM0_OUT, LS_SRC_DECIMATOR}, {SR3_4_OUT, LS_NONE1}, {NO_OUT,
LS_NONE2},
{NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1},
{DIGITAL_MIXER_OUT0, LS_MIXER_IN}, {DIGITAL_MIXER_OUT0, LS_MIXER_IN},
{DIGITAL_MIXER_OUT0, LS_MIXER_IN}, {DIGITAL_MIXER_OUT0, LS_MIXER_IN},
{DIGITAL_MIXER_OUT0, LS_MIXER_IN}, {DIGITAL_MIXER_OUT0, LS_MIXER_IN},
{DIGITAL_MIXER_OUT0, LS_MIXER_IN}, {DIGITAL_MIXER_OUT0, LS_MIXER_IN},
{DIGITAL_MIXER_OUT0, LS_MIXER_IN}, {DIGITAL_MIXER_OUT0, LS_MIXER_IN},
{DIGITAL_MIXER_OUT0, LS_MIXER_IN}, {DIGITAL_MIXER_OUT0, LS_MIXER_IN},
{GAINFUNC0_OUT, LS_MIXER_GAIN_FUNCTION}, {GAINFUNC1_OUT,
LS_MIXER_GAIN_FUNCTION},
{GAINFUNC2_OUT, LS_MIXER_GAIN_FUNCTION}, {GAINFUNC3_OUT,
LS_MIXER_GAIN_FUNCTION},
{GAINFUNC4_OUT, LS_MIXER_GAIN_FUNCTION}, {SOFTMODEMTX, LS_NONE1},
{SPLITTER0_OUTL, LS_SRC_SPLITTER}, {SPLITTER1_OUTL, LS_SRC_SPLITTER},
{SPLITTER2_OUTL, LS_SRC_SPLITTER}, {SPLITTER3_OUTL, LS_SRC_SPLITTER},
{MERGER0_OUT, LS_SRC_MERGER}, {MERGER0_OUT, LS_SRC_MERGER},
{MERGER1_OUT, LS_SRC_MERGER},
{MERGER1_OUT, LS_SRC_MERGER}, {MERGER2_OUT, LS_SRC_MERGER},
{MERGER2_OUT, LS_SRC_MERGER},
{MERGER3_OUT, LS_SRC_MERGER}, {MERGER3_OUT, LS_SRC_MERGER}, {NO_OUT,
LS_NONE2},
};
static unsigned char lbus_play_opl3[] = {
DIGITAL_MIXER_IN0 + FM_MIXER, 0xff
};
static unsigned char lbus_play_modem[] = {
DIGITAL_MIXER_IN0 + MODEM_MIXER, 0xff
};
static unsigned char lbus_play_i2s[] = {
INTER0_IN + I2S_INTDEC, DIGITAL_MIXER_IN0 + I2S_MIXER, 0xff
};
static unsigned char lbus_play_out[] = {
PDAC2ACLNK, 0xff
};
static unsigned char lbus_play_outhp[] = {
HNDSPK2ACLNK, 0xff
};
static unsigned char lbus_play_noconv1[] = {
DIGITAL_MIXER_IN0, 0xff
};
static unsigned char lbus_play_stereo1[] = {
INTER0_IN, DIGITAL_MIXER_IN0, 0xff
};
static unsigned char lbus_play_mono1[] = {
INTERM0_IN, DIGITAL_MIXER_IN0, 0xff
};
static unsigned char lbus_play_noconv2[] = {
DIGITAL_MIXER_IN1, 0xff
};
static unsigned char lbus_play_stereo2[] = {
INTER1_IN, DIGITAL_MIXER_IN1, 0xff
};
static unsigned char lbus_play_mono2[] = {
INTERM1_IN, DIGITAL_MIXER_IN1, 0xff
};
static unsigned char lbus_play_noconv3[] = {
DIGITAL_MIXER_IN2, 0xff
};
static unsigned char lbus_play_stereo3[] = {
INTER2_IN, DIGITAL_MIXER_IN2, 0xff
};
static unsigned char lbus_play_mono3[] = {
INTERM2_IN, DIGITAL_MIXER_IN2, 0xff
};
static unsigned char lbus_rec_noconv1[] = {
LBUS2ARM_FIFO5, 0xff
};
static unsigned char lbus_rec_stereo1[] = {
DECIM0_IN, LBUS2ARM_FIFO5, 0xff
};
static unsigned char lbus_rec_mono1[] = {
DECIMM3_IN, LBUS2ARM_FIFO5, 0xff
};
static unsigned char play_ids[] = { 4, 1, 2, };
static unsigned char play_sources[] = {
ARM2LBUS_FIFO4, ARM2LBUS_FIFO1, ARM2LBUS_FIFO2,
};
static struct lbuspath lbus_play_paths[] = {
{
.noconv = lbus_play_noconv1,
.stereo = lbus_play_stereo1,
.mono = lbus_play_mono1,
},
{
.noconv = lbus_play_noconv2,
.stereo = lbus_play_stereo2,
.mono = lbus_play_mono2,
},
{
.noconv = lbus_play_noconv3,
.stereo = lbus_play_stereo3,
.mono = lbus_play_mono3,
},
};
static struct lbuspath lbus_rec_path = {
.noconv = lbus_rec_noconv1,
.stereo = lbus_rec_stereo1,
.mono = lbus_rec_mono1,
};
#define FIRMWARE_VERSIONS 1
static union firmware_version firmware_versions[] = {
{
.firmware = {
.ASIC = 3,
.CODEC = 2,
.AUXDSP = 3,
.PROG = 773,
},
},
};
static u32 atoh(unsigned char *in, unsigned int len)
{
u32 sum = 0;
unsigned int mult = 1;
unsigned char c;
while (len) {
c = in[len - 1];
if ((c >= '0') && (c <= '9'))
sum += mult * (c - '0');
else if ((c >= 'A') && (c <= 'F'))
sum += mult * (c - ('A' - 10));
else if ((c >= 'a') && (c <= 'f'))
sum += mult * (c - ('a' - 10));
mult *= 16;
--len;
}
return sum;
}
static int senddata(struct cmdif *cif, unsigned char *in, u32 offset)
{
u32 addr;
u32 data;
u32 i;
unsigned char *p;
i = atoh(&in[1], 2);
addr = offset + atoh(&in[3], 4);
if (SEND_SMEM(cif, 0, addr) != 0)
return -EACCES;
p = in + 9;
while (i) {
data = atoh(p, 8);
if (SEND_WMEM(cif, 2,
((data & 0x0f0f0f0f) << 4) | ((data & 0xf0f0f0f0)
>> 4)))
return -EACCES;
i -= 4;
p += 8;
}
return 0;
}
static int loadfirmware(struct cmdif *cif, unsigned char *img,
unsigned int size)
{
unsigned char *in;
u32 laddr, saddr, t, val;
int err = 0;
laddr = saddr = 0;
while (size > 0 && err == 0) {
in = img;
if (in[0] == ':') {
t = atoh(&in[7], 2);
switch (t) {
case DATA_REC:
err = senddata(cif, in, laddr + saddr);
break;
case EXT_SEG_ADDR_REC:
saddr = atoh(&in[9], 4) << 4;
break;
case EXT_LIN_ADDR_REC:
laddr = atoh(&in[9], 4) << 16;
break;
case EXT_GOTO_CMD_REC:
val = atoh(&in[9], 8);
if (SEND_GOTO(cif, val) != 0)
err = -EACCES;
break;
case EXT_END_OF_FILE:
size = 0;
break;
default:
break;
}
while (size > 0) {
size--;
if (*img++ == '\n')
break;
}
}
}
snd_printdd("load firmware return %d\n", err);
return err;
}
static void
alloclbuspath(struct cmdif *cif, unsigned char source,
unsigned char *path, unsigned char *mixer, unsigned char *s)
{
while (*path != 0xff) {
unsigned char sink, type;
sink = *path & (~SPLIT_PATH);
if (sink != E2SINK_MAX) {
snd_printdd("alloc path 0x%x->0x%x\n", source, sink);
SEND_PSEL(cif, source, sink);
source = lbusin2out[sink][0];
type = lbusin2out[sink][1];
if (type == LS_MIXER_IN) {
if (mixer)
*mixer = sink - DIGITAL_MIXER_IN0;
}
if (type == LS_SRC_DECIMATORM ||
type == LS_SRC_DECIMATOR ||
type == LS_SRC_INTERPOLATORM ||
type == LS_SRC_INTERPOLATOR) {
if (s) {
if (s[0] != 0xff)
s[1] = sink;
else
s[0] = sink;
}
}
}
if (*path++ & SPLIT_PATH) {
unsigned char *npath = path;
while (*npath != 0xff)
npath++;
alloclbuspath(cif, source + 1, ++npath, mixer, s);
}
}
}
static void
freelbuspath(struct cmdif *cif, unsigned char source, unsigned char *path)
{
while (*path != 0xff) {
unsigned char sink;
sink = *path & (~SPLIT_PATH);
if (sink != E2SINK_MAX) {
snd_printdd("free path 0x%x->0x%x\n", source, sink);
SEND_PCLR(cif, source, sink);
source = lbusin2out[sink][0];
}
if (*path++ & SPLIT_PATH) {
unsigned char *npath = path;
while (*npath != 0xff)
npath++;
freelbuspath(cif, source + 1, ++npath);
}
}
}
static int writearm(struct cmdif *cif, u32 addr, u32 data, u32 mask)
{
union cmdret rptr = CMDRET_ZERO;
unsigned int i = MAX_WRITE_RETRY;
int flag = 1;
SEND_RMEM(cif, 0x02, addr, &rptr);
rptr.retlongs[0] &= (~mask);
while (--i) {
SEND_SMEM(cif, 0x01, addr);
SEND_WMEM(cif, 0x02, (rptr.retlongs[0] | data));
SEND_RMEM(cif, 0x02, addr, &rptr);
if ((rptr.retlongs[0] & data) == data) {
flag = 0;
break;
} else
rptr.retlongs[0] &= ~mask;
}
snd_printdd("send arm 0x%x 0x%x 0x%x return %d\n", addr, data, mask,
flag);
return flag;
}
static int sendcmd(struct cmdif *cif, u32 flags, u32 cmd, u32 parm,
union cmdret *ret)
{
int i, j;
int err;
unsigned int time = 0;
unsigned long irqflags;
struct riptideport *hwport;
struct cmdport *cmdport = NULL;
snd_assert(cif, return -EINVAL);
hwport = cif->hwport;
if (cif->errcnt > MAX_ERROR_COUNT) {
if (cif->is_reset) {
snd_printk(KERN_ERR
"Riptide: Too many failed cmds, reinitializing\n");
if (riptide_reset(cif, NULL) == 0) {
cif->errcnt = 0;
return -EIO;
}
}
snd_printk(KERN_ERR "Riptide: Initialization failed.\n");
return -EINVAL;
}
if (ret) {
ret->retlongs[0] = 0;
ret->retlongs[1] = 0;
}
i = 0;
spin_lock_irqsave(&cif->lock, irqflags);
while (i++ < CMDIF_TIMEOUT && !IS_READY(cif->hwport))
udelay(10);
if (i >= CMDIF_TIMEOUT) {
err = -EBUSY;
goto errout;
}
err = 0;
for (j = 0, time = 0; time < CMDIF_TIMEOUT; j++, time += 2) {
cmdport = &(hwport->port[j % 2]);
if (IS_DATF(cmdport)) { /* free pending data */
READ_PORT_ULONG(cmdport->data1);
READ_PORT_ULONG(cmdport->data2);
}
if (IS_CMDE(cmdport)) {
if (flags & PARM) /* put data */
WRITE_PORT_ULONG(cmdport->data2, parm);
WRITE_PORT_ULONG(cmdport->data1, cmd); /* write cmd */
if ((flags & RESP) && ret) {
while (!IS_DATF(cmdport) &&
time++ < CMDIF_TIMEOUT)
udelay(10);
if (time < CMDIF_TIMEOUT) { /* read response */
ret->retlongs[0] =
READ_PORT_ULONG(cmdport->data1);
ret->retlongs[1] =
READ_PORT_ULONG(cmdport->data2);
} else {
err = -ENOSYS;
goto errout;
}
}
break;
}
udelay(20);
}
if (time == CMDIF_TIMEOUT) {
err = -ENODATA;
goto errout;
}
spin_unlock_irqrestore(&cif->lock, irqflags);
cif->cmdcnt++; /* update command statistics */
cif->cmdtime += time;
if (time > cif->cmdtimemax)
cif->cmdtimemax = time;
if (time < cif->cmdtimemin)
cif->cmdtimemin = time;
if ((cif->cmdcnt) % 1000 == 0)
snd_printdd
("send cmd %d time: %d mintime: %d maxtime %d err: %d\n",
cif->cmdcnt, cif->cmdtime, cif->cmdtimemin,
cif->cmdtimemax, cif->errcnt);
return 0;
errout:
cif->errcnt++;
spin_unlock_irqrestore(&cif->lock, irqflags);
snd_printdd
("send cmd %d hw: 0x%x flag: 0x%x cmd: 0x%x parm: 0x%x ret: 0x%x 0x%x CMDE: %d DATF: %d failed %d\n",
cif->cmdcnt, (int)((void *)&(cmdport->stat) - (void *)hwport),
flags, cmd, parm, ret ? ret->retlongs[0] : 0,
ret ? ret->retlongs[1] : 0, IS_CMDE(cmdport), IS_DATF(cmdport),
err);
return err;
}
static int
setmixer(struct cmdif *cif, short num, unsigned short rval, unsigned short lval)
{
union cmdret rptr = CMDRET_ZERO;
int i = 0;
snd_printdd("sent mixer %d: 0x%d 0x%d\n", num, rval, lval);
do {
SEND_SDGV(cif, num, num, rval, lval);
SEND_RDGV(cif, num, num, &rptr);
if (rptr.retwords[0] == lval && rptr.retwords[1] == rval)
return 0;
} while (i++ < MAX_WRITE_RETRY);
snd_printdd("sent mixer failed\n");
return -EIO;
}
static int getpaths(struct cmdif *cif, unsigned char *o)
{
unsigned char src[E2SINK_MAX];
unsigned char sink[E2SINK_MAX];
int i, j = 0;
for (i = 0; i < E2SINK_MAX; i++) {
getsourcesink(cif, i, i, &src[i], &sink[i]);
if (sink[i] < E2SINK_MAX) {
o[j++] = sink[i];
o[j++] = i;
}
}
return j;
}
static int
getsourcesink(struct cmdif *cif, unsigned char source, unsigned char sink,
unsigned char *a, unsigned char *b)
{
union cmdret rptr = CMDRET_ZERO;
if (SEND_RSSV(cif, source, sink, &rptr) &&
SEND_RSSV(cif, source, sink, &rptr))
return -EIO;
*a = rptr.retbytes[0];
*b = rptr.retbytes[1];
snd_printdd("getsourcesink 0x%x 0x%x\n", *a, *b);