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
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
|
/* $OpenBSD: aria.c,v 1.2 1996/08/01 15:29:53 deraadt Exp $ */
/*
* Copyright (c) 1995, 1996 Roland C. Dowdeswell. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Roland C. Dowdeswell.
* 4. The name of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* TODO:
* o Test the driver on cards other than a single
* Prometheus Aria 16.
* o Look into where aria_prometheus_kludge() belongs.
* o Add some dma code. It accomplishes its goal by
* direct IO at the moment.
* o Look into return values on aria_set_sr(), if there is
* no matching rate. (I think that this behaves in the
* same way as sbdsp.c)
* o Different programs should be able to open the device
* with O_RDONLY and O_WRONLY at the same time. But I
* do not see support for this in /sys/dev/audio.c, so
* I cannot effectively code it.
* o Separate the debugging code, with a #define.
* Write more into aria_printsc().
* o Rework the mixer interface.
* o Deal with the lvls better. We need to do better mapping
* between logarithmic scales and the one byte that
* we are passed.
* o Deal better with cards that have no mixer.
*
* roland@imrryr.org
* update from http://www.imrryr.org/NetBSD/hacks/aria/
*/
#include "aria.h"
#if NARIA > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <vm/vm.h>
#include <machine/cpu.h>
#include <machine/pio.h>
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/mulaw.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
#include <i386/isa/icu.h>
#include <dev/isa/ariareg.h>
#define FREAD 1
#define FWRITE 2
#ifdef AUDIO_DEBUG
extern void Dprintf __P((const char *, ...));
#define DPRINTF(x) if (ariadebug) Dprintf x
int ariadebug = 0;
#else
#define DPRINTF(x)
#endif
struct aria_mixdev_info {
u_char num_channels;
u_char level[2];
u_char mute;
};
struct aria_mixmaster {
u_char num_channels;
u_char level[2];
u_char treble[2];
u_char bass[2];
};
struct aria_softc {
struct device sc_dev; /* base device */
struct isadev sc_id; /* ISA device */
void *sc_ih; /* interrupt vectoring */
u_short sc_iobase; /* I/O port base address */
u_short sc_irq; /* interrupt */
u_short sc_drq; /* dma chan */
u_short sc_open; /* reference count of open calls */
u_short sc_play; /* non-paused play chans 2**chan */
u_short sc_record; /* non-paused record chans 2**chan */
u_short sc_change; /* to keep track of changes of a type */
u_short gain[2]; /* left/right gain (play) */
u_int spkr_state; /* non-null is on */
u_long sc_rate; /* Sample rate for input and output */
u_int encoding; /* audio encoding -- ulaw/linear */
int sc_chans; /* # of channels */
int sc_precision; /* # bits per sample */
u_long sc_interrupts; /* number of interrupts taken */
void (*sc_rintr)(void*); /* record transfer completion intr handler */
void (*sc_pintr)(void*); /* play transfer completion intr handler */
void *sc_rarg; /* arg for sc_rintr() */
void *sc_parg; /* arg for sc_pintr() */
int sc_blocksize; /* literal dio block size */
void *sc_rdiobuffer; /* record: where the next samples should be */
void *sc_pdiobuffer; /* play: where the next samples are */
u_short sc_hardware; /* bit field of hardware present */
#define ARIA_TELEPHONE 0x0001 /* has telephone input */
#define ARIA_MIXER 0x0002 /* has SC18075 digital mixer */
#define ARIA_MODEL 0x0004 /* is SC18025 (=0) or SC18026 (=1) */
struct aria_mixdev_info aria_mix[6];
struct aria_mixmaster ariamix_master;
u_char aria_mix_source;
};
struct {
int sendcmd;
int wmidi;
} ariaerr;
int ariaprobe();
void ariaattach __P((struct device *, struct device *, void *));
void ariaclose __P((void *));
int ariaopen __P((dev_t, int));
int aria_getdev __P((void *, struct audio_device *));
void aria_do_kludge __P((u_short, u_short, u_short, u_short, u_short));
void aria_prometheus_kludge __P((struct isa_attach_args *));
int aria_set_sr __P((void *, u_long));
u_long aria_get_sr __P((void *));
int aria_query_encoding __P((void *, struct audio_encoding *));
int aria_set_encoding __P((void *, u_int));
int aria_get_encoding __P((void *));
int aria_set_precision __P((void *, u_int));
int aria_get_precision __P((void *));
int aria_set_channels __P((void *, int));
int aria_get_channels __P((void *));
int aria_round_blocksize __P((void *, int));
int aria_set_out_port __P((void *, int));
int aria_get_out_port __P((void *));
int aria_set_in_port __P((void *, int));
int aria_get_in_port __P((void *));
int aria_speaker_ctl __P((void *, int));
int aria_commit_settings __P((void *));
int aria_start_output __P((void *, void *, int, void (*)(), void*));
int aria_start_input __P((void *, void *, int, void (*)(), void*));
int aria_halt_input __P((void *));
int aria_halt_output __P((void *));
int aria_cont __P((void *));
u_int aria_get_silence __P((int));
int aria_sendcmd __P((u_short, u_short, int, int, int));
u_short aria_getdspmem __P((u_short, u_short));
u_short aria_putdspmem __P((u_short, u_short, u_short));
int aria_intr __P((void *));
short ariaversion __P((struct aria_softc *));
int aria_setfd __P((void *, int));
void aria_mix_write __P((struct aria_softc *, int, int));
int aria_mix_read __P((struct aria_softc *, int));
int aria_mixer_set_port __P((void *, mixer_ctrl_t *));
int aria_mixer_get_port __P((void *, mixer_ctrl_t *));
int aria_mixer_query_devinfo __P((void *, mixer_devinfo_t *));
/*
* Mixer defines...
*/
struct cfattach aria_ca = {
sizeof(struct aria_softc), ariaprobe, ariaattach
};
struct cfdriver aria_cd = {
NULL, "aria", DV_DULL
};
struct audio_device aria_device = {
"Aria 16(se)",
"x",
"aria"
};
/*
* Define our interface to the higher level audio driver.
*/
struct audio_hw_if aria_hw_if = {
ariaopen,
ariaclose,
NULL,
aria_set_sr,
aria_get_sr,
aria_set_sr,
aria_get_sr,
aria_query_encoding,
aria_set_encoding,
aria_get_encoding,
aria_set_precision,
aria_get_precision,
aria_set_channels,
aria_get_channels,
aria_round_blocksize,
aria_set_out_port,
aria_get_out_port,
aria_set_in_port,
aria_get_in_port,
aria_commit_settings,
aria_get_silence,
mulaw_expand,
mulaw_compress,
aria_start_output,
aria_start_input,
aria_halt_input,
aria_halt_output,
aria_cont,
aria_cont,
aria_speaker_ctl,
aria_getdev,
aria_setfd,
aria_mixer_set_port,
aria_mixer_get_port,
aria_mixer_query_devinfo,
1, /* full-duplex */
0
};
/*
* Probe / attach routines.
*/
/*
* Probe for the aria hardware.
*/
int
ariaprobe(parent, self, aux)
struct device *parent, *self;
void *aux;
{
register struct aria_softc *sc = (void *)self;
register struct isa_attach_args *ia = aux;
struct cfdata *cf = sc->sc_dev.dv_cfdata;
register u_short iobase = ia->ia_iobase;
static u_char irq_conf[11] = {
-1, -1, 0x01, -1, -1, 0x02, -1, 0x04, -1, 0x01, 0x08
};
int i,j;
int flags = cf->cf_flags;
if (!ARIA_BASE_VALID(ia->ia_iobase)) {
printf("aria: configured iobase %d invalid\n", ia->ia_iobase);
return 0;
}
sc->sc_iobase = iobase;
if (!ARIA_IRQ_VALID(ia->ia_irq)) {
printf("aria: configured irq %d invalid\n", ia->ia_irq);
return 0;
}
sc->sc_irq = ia->ia_irq;
if (flags & ARIAR_PROMETHEUS_KLUDGE)
aria_prometheus_kludge(ia);
if (aria_reset(sc) != 0) {
DPRINTF(("aria: aria probe failed\n"));
return 0;
}
ia->ia_iosize = ARIADSP_NPORT;
return 1;
}
/*
* I didn't call this a kludge for
* nothing. This is cribbed from
* ariainit, the author of that
* disassembled some code to discover
* how to set up the initial values of
* the card. Without this, the card
* is dead. (It will not respond to _any_
* input at all.)
*
* ariainit can be found (ftp) at:
* ftp://ftp.wi.leidenuniv.nl/pub/audio/aria/programming/contrib/ariainit.zip
* currently.
*/
void
aria_prometheus_kludge(ia)
register struct isa_attach_args *ia;
{
int i, j;
u_short end;
u_short rba = ia->ia_iobase;
DPRINTF(("aria_prometheus_kludge\n"));
/* Begin Config Sequence */
outb(0x204, 0x4c);
outb(0x205, 0x42);
outb(0x206, 0x00);
outw(0x200, 0x0f);
outb(0x201, 0x00);
outw(0x200, 0x02);
outb(0x201, rba>>2);
/* These next three lines set up the iobase, and the irq; and disable the drq. */
aria_do_kludge(0x111, ((ia->ia_iobase-0x280)>>2)+0xA0, 0xbf, 0xa0, rba);
aria_do_kludge(0x011, ia->ia_irq-6, 0xf8, 0x00, rba);
aria_do_kludge(0x011, 0x00, 0xef, 0x00, rba);
/* The rest of these lines just disable everything else */
aria_do_kludge(0x113, 0x00, 0x88, 0x00, rba);
aria_do_kludge(0x013, 0x00, 0xf8, 0x00, rba);
aria_do_kludge(0x013, 0x00, 0xef, 0x00, rba);
aria_do_kludge(0x117, 0x00, 0x88, 0x00, rba);
aria_do_kludge(0x017, 0x00, 0xff, 0x00, rba);
/* End Sequence */
outb(0x200, 0x0f);
end = inb(rba);
outw(0x200, 0x0f);
outb(0x201, end|0x80);
inb(0x200);
/*
* This delay is necessary for some reason,
* at least it would crash, and sometimes not
* probe properly if it did not exist.
*/
delay(1000000);
}
void
aria_do_kludge(func, bits, and, or, rba)
u_short func;
u_short bits;
u_short and;
u_short or;
u_short rba;
{
u_int i;
if (func & 0x100) {
func &= ~0x100;
if (bits) {
outw(0x200, func-1);
outb(0x201, bits);
}
} else
or |= bits;
outb(0x200, func);
i = inb(rba);
outw(0x200, func);
outb(0x201, (i&and) | or);
}
#ifdef NEWCONFIG
void
ariaforceintr(aux)
void *aux;
{
struct isa_attach_args *ia = aux;
u_short iobase = ia->ia_iobase;
(void)aria_sendcmd(iobase, ARIADSPC_FORCEINTR, -1, -1, -1);
}
#endif
/*
* Attach hardware to driver, attach hardware driver to audio
* pseudo-device driver.
*/
void
ariaattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
register struct aria_softc *sc = (struct aria_softc *)self;
struct isa_attach_args *ia = (struct isa_attach_args *)aux;
register u_short iobase = ia->ia_iobase;
register u_short i;
int err;
sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
IPL_AUDIO, aria_intr, sc, sc->sc_dev.dv_xname);
i = aria_getdspmem(iobase, ARIAA_HARDWARE_A);
sc->sc_hardware = 0;
sc->sc_hardware |= ((i>>13)&0x01==1)?ARIA_TELEPHONE:0;
sc->sc_hardware |= (((i>>5)&0x07)==0x04)?ARIA_MIXER:0;
sc->sc_hardware |= (aria_getdspmem(iobase, ARIAA_MODEL_A)==1)?ARIA_MODEL:0;
sc->sc_open = 0;
sc->sc_play = 0;
sc->sc_record = 0;
sc->sc_rate = 7875;
sc->sc_chans = 1;
sc->sc_change = 1;
sc->sc_blocksize = 1024;
sc->sc_precision = 8;
sc->sc_rintr = 0;
sc->sc_rarg = 0;
sc->sc_pintr = 0;
sc->sc_parg = 0;
sc->gain[0] = 127;
sc->gain[1] = 127;
for (i=0; i<6; i++) {
if (i == ARIAMIX_TEL_LVL)
sc->aria_mix[i].num_channels = 1;
else
sc->aria_mix[i].num_channels = 2;
sc->aria_mix[i].level[0] = 127;
sc->aria_mix[i].level[1] = 127;
}
sc->ariamix_master.num_channels = 2;
sc->ariamix_master.level[0] = 222;
sc->ariamix_master.level[1] = 222;
sc->ariamix_master.bass[0] = 127;
sc->ariamix_master.bass[1] = 127;
sc->ariamix_master.treble[0] = 127;
sc->ariamix_master.treble[1] = 127;
sc->aria_mix_source = 0;
sc->sc_change = 1;
aria_commit_settings(sc); /* so that my cdplayer is at the 'right' vol */
printf(": dsp %s", (ARIA_MODEL&sc->sc_hardware)?"SC18026":"SC18025");
if (ARIA_TELEPHONE&sc->sc_hardware)
printf(", tel");
if (ARIA_MIXER&sc->sc_hardware)
printf(", SC18075 mixer");
printf("\n");
sprintf(aria_device.version, "%s", (ARIA_MODEL&sc->sc_hardware?"SC18026":"SC18025"));
if ((err = audio_hardware_attach(&aria_hw_if, sc)) != 0)
printf("aria: could not attach to audio pseudo-device driver (%d)\n", err);
}
/*
* Various routines to interface to higher level audio driver
*/
int
ariaopen(dev, flags)
dev_t dev;
int flags;
{
struct aria_softc *sc;
register u_short iobase = sc->sc_iobase;
int unit = AUDIOUNIT(dev);
short err;
DPRINTF(("ariaopen() called\n"));
if (unit >= aria_cd.cd_ndevs)
return ENODEV;
sc = aria_cd.cd_devs[unit];
if (!sc || sc->sc_open != 0)
return ENXIO;
sc->sc_open = 0;
if (flags&FREAD)
sc->sc_open |= ARIAR_OPEN_RECORD;
if (flags&FWRITE)
sc->sc_open |= ARIAR_OPEN_PLAY;
sc->sc_play = 0;
sc->sc_record= 0;
sc->sc_rintr = 0;
sc->sc_rarg = 0;
sc->sc_pintr = 0;
sc->sc_parg = 0;
sc->sc_change= 1;
return 0;
}
int
aria_getdev(addr, retp)
void *addr;
struct audio_device *retp;
{
*retp = aria_device;
return 0;
}
#ifdef AUDIO_DEBUG
void
aria_printsc(struct aria_softc *sc)
{
printf("open %x dmachan %d irq %d iobase %x nintr %d\n", sc->sc_open, sc->sc_drq,
sc->sc_irq, sc->sc_iobase, sc->sc_interrupts);
printf("irate %d encoding %x chans %d\n", sc->sc_rate, sc->encoding,
sc->sc_chans);
printf("\n");
}
#endif
/*
* Various routines to interface to higher level audio driver
*/
int
aria_set_sr(addr, sr)
void *addr;
u_long sr;
{
struct aria_softc *sc = addr;
if (sr<=9000)
sr = 7875;
else if (sr<=15000)
sr = 11025;
else if (sr<=20000)
sr = 15750;
else if (sr<=25000)
sr = 22050;
else if (sr<=40000)
sr = 31500;
else
sr = 44100;
sc->sc_rate = sr;
return 0;
}
u_long
aria_get_sr(addr)
void *addr;
{
struct aria_softc *sc = addr;
return sc->sc_rate;
}
int
aria_query_encoding(addr, fp)
void *addr;
struct audio_encoding *fp;
{
register struct aria_softc *sc = addr;
switch (fp->index) {
case 0:
strcpy(fp->name, AudioEmulaw);
fp->format_id = AUDIO_ENCODING_ULAW;
break;
case 1:
strcpy(fp->name, AudioEpcm16);
fp->format_id = AUDIO_ENCODING_PCM16;
break;
default:
return(EINVAL);
/*NOTREACHED*/
}
return (0);
}
int
aria_set_encoding(addr, enc)
void *addr;
u_int enc;
{
register struct aria_softc *sc = addr;
DPRINTF(("aria_set_encoding\n"));
switch(enc){
case AUDIO_ENCODING_ULAW:
sc->encoding = AUDIO_ENCODING_ULAW;
break;
case AUDIO_ENCODING_LINEAR:
sc->encoding = AUDIO_ENCODING_LINEAR;
break;
default:
return (EINVAL);
}
return (0);
}
int
aria_get_encoding(addr)
void *addr;
{
register struct aria_softc *sc = addr;
DPRINTF(("aria_get_encoding\n"));
return(sc->encoding);
}
int
aria_set_precision(addr, prec)
void *addr;
u_int prec;
{
struct aria_softc *sc = addr;
DPRINTF(("aria_set_precision\n"));
if (prec!=8 && prec!=16)
return EINVAL;
if (sc->encoding!=AUDIO_ENCODING_PCM16 && prec==16)
return EINVAL;
sc->sc_precision = prec;
return(0);
}
int
aria_get_precision(addr)
void *addr;
{
struct aria_softc *sc = addr;
DPRINTF(("aria_get_precision\n"));
return sc->sc_precision;
}
int
aria_set_channels(addr, chans)
void *addr;
int chans;
{
struct aria_softc *sc = addr;
DPRINTF(("aria_set_channels\n"));
if (chans != 1 && chans != 2)
return EINVAL;
sc->sc_chans = chans;
return(0);
}
int
aria_get_channels(addr)
void *addr;
{
struct aria_softc *sc = addr;
DPRINTF(("aria_get_channels\n"));
return sc->sc_chans;
}
/*
* There is only one way to output on
* this card.
*/
int
aria_set_out_port(addr, port)
void *addr;
int port;
{
DPRINTF(("aria_set_out_port\n"));
return(0);
}
int
aria_get_out_port(addr)
void *addr;
{
DPRINTF(("aria_get_out_port\n"));
return(ARIAMIX_OUT_LVL);
}
int
aria_set_in_port(addr, port)
void *addr;
int port;
{
register struct aria_softc *sc = addr;
DPRINTF(("aria_set_in_port\n"));
if (port<0 || port>6)
return ENXIO;
sc->aria_mix_source = port;
return(0);
}
int
aria_get_in_port(addr)
void *addr;
{
register struct aria_softc *sc = addr;
DPRINTF(("aria_get_in_port\n"));
return(sc->aria_mix_source);
}
/*
* XXX -- to be done
* I should probably just add a mixer thing, and
* access it through here.
*/
int
aria_speaker_ctl(addr, newstate)
void *addr;
int newstate;
{
return(0);
}
/*
* Store blocksize in words (what the chipset
* understands), but report and take values
* in bytes.
*/
int
aria_round_blocksize(addr, blk)
void *addr;
int blk;
{
int i;
struct aria_softc *sc = addr;
for (i=64; i<1024; i*=2)
if (blk <= i)
break;
sc->sc_blocksize = i;
sc->sc_change = 1;
return(i);
}
/*
* This is where all of the twiddling goes on.
*/
int
aria_commit_settings(addr)
void *addr;
{
struct aria_softc *sc = addr;
register u_short iobase = sc->sc_iobase;
u_char tones[16] = { 7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11, 12, 13, 14, 15 };
u_short format;
u_short left, right;
u_short samp;
u_char i;
DPRINTF(("aria_commit_settings\n"));
switch (sc->sc_rate) {
case 7875: format = 0x00; samp = 0x60; break;
case 11025: format = 0x00; samp = 0x40; break;
case 15750: format = 0x10; samp = 0x60; break;
case 22050: format = 0x10; samp = 0x40; break;
case 31500: format = 0x10; samp = 0x20; break;
case 44100: format = 0x20; samp = 0x00; break;
default: format = 0x00; samp = 0x40; break;
}
format |= (sc->sc_chans==2)?1:0;
format |= (sc->sc_precision==16)?2:0;
aria_sendcmd(iobase, ARIADSPC_FORMAT, format, -1, -1);
outw(iobase+ARIADSP_CONTROL, (inw(iobase+ARIADSP_STATUS)&~0x60)|samp); /* Addition parm for sample rate */
if (sc->sc_hardware&ARIA_MIXER) {
for (i=0; i<6; i++) {
u_char source;
switch(i) {
case ARIAMIX_MIC_LVL: source = 0x0001; break;
case ARIAMIX_CD_LVL: source = 0x0002; break;
case ARIAMIX_LINE_IN_LVL: source = 0x0008; break;
case ARIAMIX_TEL_LVL: source = 0x0020; break;
case ARIAMIX_AUX_LVL: source = 0x0010; break;
case ARIAMIX_DAC_LVL: source = 0x0004; break;
default: source = 0x0000; break;
}
if (source != 0x0000 && source != 0x0004) {
if (sc->aria_mix[i].mute == 1)
aria_sendcmd(iobase, ARIADSPC_INPMONMODE, source, 3, -1);
else
aria_sendcmd(iobase, ARIADSPC_INPMONMODE, source, (sc->aria_mix[i].num_channels==2)?0:1, -1);
aria_sendcmd(iobase, ARIADSPC_INPMONMODE, 0x8000|source, (sc->aria_mix[i].num_channels==2)?0:1, -1);
aria_sendcmd(iobase, ARIADSPC_MIXERVOL, source, sc->aria_mix[i].level[0] << 7, sc->aria_mix[i].level[1] << 7);
}
if (sc->aria_mix_source == i) {
aria_sendcmd(iobase, ARIADSPC_ADCSOURCE, source, -1, -1);
if (sc->sc_open & ARIAR_OPEN_RECORD)
aria_sendcmd(iobase, ARIADSPC_ADCCONTROL, 1, -1, -1);
else
aria_sendcmd(iobase, ARIADSPC_ADCCONTROL, 0, -1, -1);
}
}
if (sc->sc_chans==2) {
aria_sendcmd(iobase, ARIADSPC_CHAN_VOL, (sc->gain[0]+sc->gain[1])/2, -1, -1);
aria_sendcmd(iobase, ARIADSPC_CHAN_PAN, (sc->gain[0]-sc->gain[1])/4+0x40, -1, -1);
} else {
aria_sendcmd(iobase, ARIADSPC_CHAN_VOL, sc->gain[0], -1, -1);
aria_sendcmd(iobase, ARIADSPC_CHAN_PAN, 0x40, -1, -1);
}
/* aria_sendcmd(iobase, ARIADSPC_MASMONMODE, (sc->ariamix_master.num_channels==2)?0:1 | (1<<8), -1, -1); */
aria_sendcmd(iobase, ARIADSPC_MASMONMODE, (sc->ariamix_master.num_channels==2)?0:1, -1, -1);
aria_sendcmd(iobase, ARIADSPC_MIXERVOL, 0x0004, sc->ariamix_master.level[0] << 7, sc->ariamix_master.level[1] << 7);
/* Convert treb/bass from byte to soundcard style */
left = tones[(sc->ariamix_master.bass[0]>>4)&0x0f]<<8 | tones[(sc->ariamix_master.treble[0]>>4)&0x0f];
right = tones[(sc->ariamix_master.bass[1]>>4)&0x0f]<<8 | tones[(sc->ariamix_master.treble[1]>>4)&0x0f];
aria_sendcmd(iobase, ARIADSPC_TONE, left, right, -1);
}
if (sc->sc_change != 0)
aria_sendcmd(iobase, ARIADSPC_BLOCKSIZE, sc->sc_blocksize/2, -1, -1);
/*
* If we think that the card is recording or playing, start it up again here.
* Some of the previous commands turn the channels off.
*/
if (sc->sc_record&(1<<ARIAR_RECORD_CHAN)) {
aria_sendcmd(iobase, ARIADSPC_START_REC, ARIAR_PLAY_CHAN, -1, -1);
sc->sc_play |= (1<<ARIAR_RECORD_CHAN);
}
if (sc->sc_play&(1<<ARIAR_PLAY_CHAN)) {
aria_sendcmd(iobase, ARIADSPC_START_PLAY, ARIAR_PLAY_CHAN, -1, -1);
sc->sc_play |= (1<<ARIAR_PLAY_CHAN);
}
sc->sc_change = 0;
return(0);
}
void
ariaclose(addr)
void *addr;
{
struct aria_softc *sc = addr;
register u_int iobase = sc->sc_iobase;
DPRINTF(("aria_close sc=0x%x\n", sc));
sc->spkr_state = SPKR_OFF;
sc->sc_rintr = 0;
sc->sc_pintr = 0;
sc->sc_rdiobuffer = 0;
sc->sc_pdiobuffer = 0;
if (sc->sc_play&(1<<ARIAR_PLAY_CHAN) && sc->sc_open & ARIAR_OPEN_PLAY) {
aria_sendcmd(iobase, ARIADSPC_STOP_PLAY, ARIAR_PLAY_CHAN, -1, -1);
sc->sc_play &= ~(1<<ARIAR_PLAY_CHAN);
}
if (sc->sc_record&(1<<ARIAR_RECORD_CHAN) && sc->sc_open & ARIAR_OPEN_RECORD) {
aria_sendcmd(iobase, ARIADSPC_STOP_REC, ARIAR_RECORD_CHAN, -1, -1);
sc->sc_record &= ~(1<<ARIAR_RECORD_CHAN);
}
sc->sc_open = 0;
if (aria_reset(sc) != 0) {
delay(500);
aria_reset(sc);
}
}
/*
* Reset the hardware.
*/
int
aria_reset(sc)
register struct aria_softc *sc;
{
register u_short iobase = sc->sc_iobase;
int fail=0;
outw(iobase + ARIADSP_CONTROL, ARIAR_ARIA_SYNTH|ARIAR_SR22K|ARIAR_DSPINTWR);
aria_putdspmem(iobase, 0x6102, 0);
fail |= aria_sendcmd(iobase, ARIADSPC_SYSINIT, 0x0000, 0x0000, 0x0000);
while (aria_getdspmem(iobase, ARIAA_TASK_A) != 1)
;
outw(iobase+ARIADSP_CONTROL, ARIAR_ARIA_SYNTH|ARIAR_SR22K|ARIAR_DSPINTWR|ARIAR_PCINTWR);
fail |= aria_sendcmd(iobase, ARIADSPC_MODE, ARIAV_MODE_NO_SYNTH,-1,-1);
return (fail);
}
/*
* Lower-level routines
*/
u_short
aria_putdspmem(iobase, loc, val)
register u_short iobase;
register u_short loc;
register u_short val;
{
outw(iobase + ARIADSP_DMAADDRESS, loc);
outw(iobase + ARIADSP_DMADATA, val);
}
u_short
aria_getdspmem(iobase, loc)
register u_short iobase;
register u_short loc;
{
outw(iobase+ARIADSP_DMAADDRESS, loc);
return inw(iobase+ARIADSP_DMADATA);
}
/*
* aria_sendcmd()
* each full DSP command is unified into this
* function.
*/
int
aria_sendcmd(iobase, command, arg1, arg2, arg3)
u_short iobase;
u_short command;
int arg1;
int arg2;
int arg3;
{
int i, fail = 0;
for (i = ARIAR_NPOLL; (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY) != 0 && i>0; i-- )
;
fail |= (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY)==0?0:1;
outw(iobase + ARIADSP_WRITE, (u_short) command);
if (arg1 != -1) {
for (i = ARIAR_NPOLL; (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY) != 0 && i>0; i-- )
;
fail |= (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY)==0?0:2;
outw(iobase + ARIADSP_WRITE, (u_short) arg1);
}
if (arg2 != -1) {
for (i = ARIAR_NPOLL; (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY) != 0 && i>0; i-- )
;
fail |= (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY)==0?0:4;
outw(iobase + ARIADSP_WRITE, (u_short) arg2);
}
if (arg3 != -1) {
for (i = ARIAR_NPOLL; (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY) != 0 && i>0; i-- )
;
fail |= (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY)==0?0:8;
outw(iobase + ARIADSP_WRITE, (u_short) arg3);
}
for (i = ARIAR_NPOLL; (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY) != 0 && i>0; i-- )
;
fail |= (inw(iobase + ARIADSP_STATUS) & ARIAR_BUSY)==0?0:16;
outw(iobase + ARIADSP_WRITE, (u_short) ARIADSPC_TERM);
#ifdef AUDIO_DEBUG
if (fail) {
++ariaerr.sendcmd;
DPRINTF(("aria_sendcmd: failure=(%d) cmd=(0x%x) fail=(0x%x)\n", ariaerr.sendcmd, command, fail));
return -1;
}
#else
if (fail != 0) {
++ariaerr.sendcmd;
return -1;
}
#endif
return 0;
}
int
aria_halt_input(addr)
void *addr;
{
register struct aria_softc *sc = addr;
DPRINTF(("aria_halt_input\n"));
if (sc->sc_record&(1<<0)) {
aria_sendcmd(sc->sc_iobase, ARIADSPC_STOP_REC, 0, -1, -1);
sc->sc_record &= ~(1<<0);
}
return(0);
}
int
aria_halt_output(addr)
void *addr;
{
register struct aria_softc *sc = addr;
DPRINTF(("aria_halt_output\n"));
if (sc->sc_play & (1<<1)) {
aria_sendcmd(sc->sc_iobase, ARIADSPC_STOP_PLAY, 1, -1, -1);
sc->sc_play &= ~(1<<1);
}
return(0);
}
/*
* This is not called in dev/audio.c?
*/
int
aria_cont(addr)
void *addr;
{
register struct aria_softc *sc = addr;
DPRINTF(("aria_cont\n"));
if (!sc->sc_record&(1<<0) && (sc->sc_open&ARIAR_OPEN_RECORD)) {
aria_sendcmd(sc->sc_iobase, ARIADSPC_START_REC, ARIAR_RECORD_CHAN, -1, -1);
sc->sc_record |= ~(1<<ARIAR_RECORD_CHAN);
}
if (!sc->sc_play&(1<<ARIAR_PLAY_CHAN) && (sc->sc_open&ARIAR_OPEN_PLAY)) {
aria_sendcmd(sc->sc_iobase, ARIADSPC_START_PLAY, 1, -1, -1);
sc->sc_play |= ~(1<<ARIAR_PLAY_CHAN);
}
return(0);
}
/*
* Here we just set up the buffers. If we receive
* an interrupt without these set, it is ignored.
*/
int
aria_start_input(addr, p, cc, intr, arg)
void *addr;
void *p;
int cc;
void (*intr)();
void *arg;
{
register struct aria_softc *sc = addr;
register int i;
DPRINTF(("aria_start_input %d @ %x\n", cc, p));
if (cc != sc->sc_blocksize) {
DPRINTF(("aria_start_input reqsize %d not sc_blocksize %d\n",
cc, sc->sc_blocksize));
return EINVAL;
}
sc->sc_rarg = arg;
sc->sc_rintr = intr;
sc->sc_rdiobuffer = p;
if (!(sc->sc_record&(1<<0))) {
aria_sendcmd(sc->sc_iobase, ARIADSPC_START_REC, 0, -1, -1);
sc->sc_record |= (1<<0);
}
return 0;
}
int
aria_start_output(addr, p, cc, intr, arg)
void *addr;
void *p;
int cc;
void (*intr)();
void *arg;
{
register struct aria_softc *sc = addr;
register int i;
DPRINTF(("aria_start_output %d @ %x\n", cc, p));
if (cc != sc->sc_blocksize) {
DPRINTF(("aria_start_output reqsize %d not sc_blocksize %d\n",
cc, sc->sc_blocksize));
return EINVAL;
}
sc->sc_parg = arg;
sc->sc_pintr = intr;
sc->sc_pdiobuffer = p;
if (!(sc->sc_play&(1<<1))) {
aria_sendcmd(sc->sc_iobase, ARIADSPC_START_PLAY, 1, -1, -1);
sc->sc_play |= (1<<1);
}
return 0;
}
/*
* Process an interrupt. This should be a
* request (from the card) to write or read
* samples.
*/
int
aria_intr(arg)
void *arg;
{
register struct aria_softc *sc = arg;
register u_short iobase = sc->sc_iobase;
register u_short *pdata = sc->sc_pdiobuffer;
register u_short *rdata = sc->sc_rdiobuffer;
u_short address;
int i;
if (inw(iobase) & 1 != 0x1)
return 0; /* not for us */
sc->sc_interrupts++;
DPRINTF(("aria_intr\n"));
if ((sc->sc_open & ARIAR_OPEN_PLAY) && (pdata!=NULL)) {
DPRINTF(("aria_intr play=(%x)\n", pdata));
address = 0x8000 - 2*(sc->sc_blocksize);
address+= aria_getdspmem(iobase, ARIAA_PLAY_FIFO_A);
outw(iobase+ARIADSP_DMAADDRESS, address);
outsw(iobase + ARIADSP_DMADATA, pdata, sc->sc_blocksize/2);
if (sc->sc_pintr != NULL)
(*sc->sc_pintr)(sc->sc_parg);
}
if ((sc->sc_open & ARIAR_OPEN_RECORD) && (rdata!=NULL)) {
DPRINTF(("aria_intr record=(%x)\n", rdata));
address = 0x8000 - (sc->sc_blocksize);
address+= aria_getdspmem(iobase, ARIAA_REC_FIFO_A);
outw(iobase+ARIADSP_DMAADDRESS, address);
insw(iobase + ARIADSP_DMADATA, rdata, sc->sc_blocksize/2);
if (sc->sc_rintr != NULL)
(*sc->sc_rintr)(sc->sc_rarg);
}
aria_sendcmd(iobase, ARIADSPC_TRANSCOMPLETE, -1, -1, -1);
return 1;
}
u_int
aria_get_silence(enc)
int enc;
{
#define ULAW_SILENCE 0x7f
#define ALAW_SILENCE 0x55
#define LINEAR_SILENCE 0x00
u_int auzero;
switch (enc) {
case AUDIO_ENCODING_ULAW:
auzero = ULAW_SILENCE;
break;
case AUDIO_ENCODING_ALAW:
auzero = ALAW_SILENCE;
break;
case AUDIO_ENCODING_PCM8:
case AUDIO_ENCODING_PCM16:
default:
auzero = LINEAR_SILENCE;
break;
}
return(auzero);
}
int
aria_setfd(addr, flag)
void *addr;
int flag;
{
/*
* okay return yes. I'll assume that it will only
* ask when the file open read/write... Or before...
*/
return(0);
}
int
aria_mixer_set_port(addr, cp)
void *addr;
mixer_ctrl_t *cp;
{
register struct aria_softc *sc = addr;
int error = EINVAL;
DPRINTF(("aria_mixer_set_port\n"));
if (!(ARIA_MIXER&sc->sc_hardware)) /* This could be done better, no mixer still has some controls. */
return ENXIO;
if (cp->type == AUDIO_MIXER_VALUE) {
register mixer_level_t *mv = &cp->un.value;
switch (cp->dev) {
case ARIAMIX_MIC_LVL:
if (mv->num_channels == 1 || mv->num_channels == 2) {
sc->aria_mix[ARIAMIX_MIC_LVL].num_channels = mv->num_channels;
sc->aria_mix[ARIAMIX_MIC_LVL].level[0] = mv->level[0];
sc->aria_mix[ARIAMIX_MIC_LVL].level[1] = mv->level[1];
error = 0;
}
break;
case ARIAMIX_LINE_IN_LVL:
if (mv->num_channels == 1 || mv->num_channels == 2) {
sc->aria_mix[ARIAMIX_LINE_IN_LVL].num_channels = mv->num_channels;
sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[0] = mv->level[0];
sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[1] = mv->level[1];
error = 0;
}
break;
case ARIAMIX_CD_LVL:
if (mv->num_channels == 1 || mv->num_channels == 2) {
sc->aria_mix[ARIAMIX_CD_LVL].num_channels = mv->num_channels;
sc->aria_mix[ARIAMIX_CD_LVL].level[0] = mv->level[0];
sc->aria_mix[ARIAMIX_CD_LVL].level[1] = mv->level[1];
error = 0;
}
break;
case ARIAMIX_TEL_LVL:
if (mv->num_channels == 1) {
sc->aria_mix[ARIAMIX_TEL_LVL].num_channels = mv->num_channels;
sc->aria_mix[ARIAMIX_TEL_LVL].level[0] = mv->level[0];
error = 0;
}
break;
case ARIAMIX_DAC_LVL:
if (mv->num_channels == 1 || mv->num_channels == 2) {
sc->aria_mix[ARIAMIX_DAC_LVL].num_channels = mv->num_channels;
sc->aria_mix[ARIAMIX_DAC_LVL].level[0] = mv->level[0];
sc->aria_mix[ARIAMIX_DAC_LVL].level[1] = mv->level[1];
error = 0;
}
break;
case ARIAMIX_AUX_LVL:
if (mv->num_channels == 1 || mv->num_channels == 2) {
sc->aria_mix[ARIAMIX_AUX_LVL].num_channels = mv->num_channels;
sc->aria_mix[ARIAMIX_AUX_LVL].level[0] = mv->level[0];
sc->aria_mix[ARIAMIX_AUX_LVL].level[1] = mv->level[1];
error = 0;
}
break;
case ARIAMIX_MASTER_LVL:
if (mv->num_channels == 1 || mv->num_channels == 2) {
sc->ariamix_master.num_channels = mv->num_channels;
sc->ariamix_master.level[0] = mv->level[0];
sc->ariamix_master.level[1] = mv->level[1];
error = 0;
}
break;
case ARIAMIX_MASTER_TREBLE:
if (mv->num_channels == 2) {
sc->ariamix_master.treble[0] = (mv->level[0]==0)?1:mv->level[0];
sc->ariamix_master.treble[1] = (mv->level[1]==0)?1:mv->level[1];
error = 0;
}
break;
case ARIAMIX_MASTER_BASS:
if (mv->num_channels == 2) {
sc->ariamix_master.bass[0] = (mv->level[0]==0)?1:mv->level[0];
sc->ariamix_master.bass[1] = (mv->level[1]==0)?1:mv->level[1];
error = 0;
}
break;
case ARIAMIX_OUT_LVL:
if (mv->num_channels == 1 || mv->num_channels == 2) {
sc->gain[0] = mv->level[0];
sc->gain[1] = mv->level[1];
error = 0;
}
break;
default:
}
}
if (cp->type == AUDIO_MIXER_ENUM)
switch(cp->dev) {
case ARIAMIX_RECORD_SOURCE:
if (cp->un.ord>=0 && cp->un.ord<=6) {
sc->aria_mix_source = cp->un.ord;
error = 0;
}
break;
case ARIAMIX_MIC_MUTE:
if (cp->un.ord == 0 || cp->un.ord == 1) {
sc->aria_mix[ARIAMIX_MIC_LVL].mute = cp->un.ord;
error = 0;
}
break;
case ARIAMIX_LINE_IN_MUTE:
if (cp->un.ord == 0 || cp->un.ord == 1) {
sc->aria_mix[ARIAMIX_LINE_IN_LVL].mute = cp->un.ord;
error = 0;
}
break;
case ARIAMIX_CD_MUTE:
if (cp->un.ord == 0 || cp->un.ord == 1) {
sc->aria_mix[ARIAMIX_CD_LVL].mute = cp->un.ord;
error = 0;
}
break;
case ARIAMIX_DAC_MUTE:
if (cp->un.ord == 0 || cp->un.ord == 1) {
sc->aria_mix[ARIAMIX_DAC_LVL].mute = cp->un.ord;
error = 0;
}
break;
case ARIAMIX_AUX_MUTE:
if (cp->un.ord == 0 || cp->un.ord == 1) {
sc->aria_mix[ARIAMIX_AUX_LVL].mute = cp->un.ord;
error = 0;
}
break;
case ARIAMIX_TEL_MUTE:
if (cp->un.ord == 0 || cp->un.ord == 1) {
sc->aria_mix[ARIAMIX_TEL_LVL].mute = cp->un.ord;
error = 0;
}
break;
default:
return ENXIO;
/* NOTREACHED */
}
return(error);
}
int
aria_mixer_get_port(addr, cp)
void *addr;
mixer_ctrl_t *cp;
{
register struct aria_softc *sc = addr;
int error = EINVAL;
DPRINTF(("aria_mixer_get_port\n"));
if (!(ARIA_MIXER&sc->sc_hardware)) /* This could be done better, no mixer still has some controls. */
return ENXIO;
switch (cp->dev) {
case ARIAMIX_MIC_LVL:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = sc->aria_mix[ARIAMIX_MIC_LVL].num_channels;
cp->un.value.level[0] = sc->aria_mix[ARIAMIX_MIC_LVL].level[0];
cp->un.value.level[1] = sc->aria_mix[ARIAMIX_MIC_LVL].level[1];
error = 0;
}
break;
case ARIAMIX_LINE_IN_LVL:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = sc->aria_mix[ARIAMIX_LINE_IN_LVL].num_channels;
cp->un.value.level[0] = sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[0];
cp->un.value.level[1] = sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[1];
error = 0;
}
break;
case ARIAMIX_CD_LVL:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = sc->aria_mix[ARIAMIX_CD_LVL].num_channels;
cp->un.value.level[0] = sc->aria_mix[ARIAMIX_CD_LVL].level[0];
cp->un.value.level[1] = sc->aria_mix[ARIAMIX_CD_LVL].level[1];
error = 0;
}
break;
case ARIAMIX_TEL_LVL:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = sc->aria_mix[ARIAMIX_TEL_LVL].num_channels;
cp->un.value.level[0] = sc->aria_mix[ARIAMIX_TEL_LVL].level[0];
error = 0;
}
break;
case ARIAMIX_DAC_LVL:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = sc->aria_mix[ARIAMIX_DAC_LVL].num_channels;
cp->un.value.level[0] = sc->aria_mix[ARIAMIX_DAC_LVL].level[0];
cp->un.value.level[1] = sc->aria_mix[ARIAMIX_DAC_LVL].level[1];
error = 0;
}
break;
case ARIAMIX_AUX_LVL:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = sc->aria_mix[ARIAMIX_AUX_LVL].num_channels;
cp->un.value.level[0] = sc->aria_mix[ARIAMIX_AUX_LVL].level[0];
cp->un.value.level[1] = sc->aria_mix[ARIAMIX_AUX_LVL].level[1];
error = 0;
}
break;
case ARIAMIX_MIC_MUTE:
if (cp->type == AUDIO_MIXER_ENUM) {
cp->un.ord = sc->aria_mix[ARIAMIX_MIC_LVL].mute;
error = 0;
}
break;
case ARIAMIX_LINE_IN_MUTE:
if (cp->type == AUDIO_MIXER_ENUM) {
cp->un.ord = sc->aria_mix[ARIAMIX_LINE_IN_LVL].mute;
error = 0;
}
break;
case ARIAMIX_CD_MUTE:
if (cp->type == AUDIO_MIXER_ENUM) {
cp->un.ord = sc->aria_mix[ARIAMIX_CD_LVL].mute;
error = 0;
}
break;
case ARIAMIX_DAC_MUTE:
if (cp->type == AUDIO_MIXER_ENUM) {
cp->un.ord = sc->aria_mix[ARIAMIX_DAC_LVL].mute;
error = 0;
}
break;
case ARIAMIX_AUX_MUTE:
if (cp->type == AUDIO_MIXER_ENUM) {
cp->un.ord = sc->aria_mix[ARIAMIX_AUX_LVL].mute;
error = 0;
}
break;
case ARIAMIX_TEL_MUTE:
if (cp->type == AUDIO_MIXER_ENUM) {
cp->un.ord = sc->aria_mix[ARIAMIX_TEL_LVL].mute;
error = 0;
}
break;
case ARIAMIX_MASTER_LVL:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = sc->ariamix_master.num_channels;
cp->un.value.level[0] = sc->ariamix_master.level[0];
cp->un.value.level[1] = sc->ariamix_master.level[1];
error = 0;
}
break;
case ARIAMIX_MASTER_TREBLE:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = 2;
cp->un.value.level[0] = sc->ariamix_master.treble[0];
cp->un.value.level[1] = sc->ariamix_master.treble[1];
error = 0;
}
break;
case ARIAMIX_MASTER_BASS:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = 2;
cp->un.value.level[0] = sc->ariamix_master.bass[0];
cp->un.value.level[1] = sc->ariamix_master.bass[1];
error = 0;
}
break;
case ARIAMIX_OUT_LVL:
if (cp->type == AUDIO_MIXER_VALUE) {
cp->un.value.num_channels = sc->sc_chans;
cp->un.value.level[0] = sc->gain[0];
cp->un.value.level[1] = sc->gain[1];
error = 0;
}
break;
case ARIAMIX_RECORD_SOURCE:
if (cp->type == AUDIO_MIXER_ENUM) {
cp->un.ord = sc->aria_mix_source;
error = 0;
}
break;
default:
return ENXIO;
/* NOT REACHED */
}
return(error);
}
int
aria_mixer_query_devinfo(addr, dip)
void *addr;
register mixer_devinfo_t *dip;
{
register struct aria_softc *sc = addr;
DPRINTF(("aria_mixer_query_devinfo\n"));
if (!(ARIA_MIXER&sc->sc_hardware)) /* This could be done better, no mixer still has some controls. */
return ENXIO;
dip->prev = dip->next = AUDIO_MIXER_LAST;
switch(dip->index) {
case ARIAMIX_MIC_LVL:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_INPUT_CLASS;
dip->next = ARIAMIX_MIC_MUTE;
strcpy(dip->label.name, AudioNmicrophone);
dip->un.v.num_channels = 2;
strcpy(dip->un.v.units.name, AudioNvolume);
break;
case ARIAMIX_LINE_IN_LVL:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_INPUT_CLASS;
dip->next = ARIAMIX_LINE_IN_MUTE;
strcpy(dip->label.name, AudioNline);
dip->un.v.num_channels = 2;
strcpy(dip->un.v.units.name, AudioNvolume);
break;
case ARIAMIX_CD_LVL:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_INPUT_CLASS;
dip->next = ARIAMIX_CD_MUTE;
strcpy(dip->label.name, AudioNcd);
dip->un.v.num_channels = 2;
strcpy(dip->un.v.units.name, AudioNvolume);
break;
case ARIAMIX_TEL_LVL:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_INPUT_CLASS;
dip->next = ARIAMIX_TEL_MUTE;
strcpy(dip->label.name, "telephone");
dip->un.v.num_channels = 1;
strcpy(dip->un.v.units.name, AudioNvolume);
break;
case ARIAMIX_DAC_LVL:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_INPUT_CLASS;
dip->next = ARIAMIX_DAC_MUTE;
strcpy(dip->label.name, AudioNdac);
dip->un.v.num_channels = 1;
strcpy(dip->un.v.units.name, AudioNvolume);
break;
case ARIAMIX_AUX_LVL:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_INPUT_CLASS;
dip->next = ARIAMIX_AUX_MUTE;
strcpy(dip->label.name, AudioNoutput);
dip->un.v.num_channels = 1;
strcpy(dip->un.v.units.name, AudioNvolume);
break;
case ARIAMIX_MIC_MUTE:
dip->prev = ARIAMIX_MIC_LVL;
goto mode;
case ARIAMIX_LINE_IN_MUTE:
dip->prev = ARIAMIX_LINE_IN_LVL;
goto mode;
case ARIAMIX_CD_MUTE:
dip->prev = ARIAMIX_CD_LVL;
goto mode;
case ARIAMIX_DAC_MUTE:
dip->prev = ARIAMIX_DAC_LVL;
goto mode;
case ARIAMIX_AUX_MUTE:
dip->prev = ARIAMIX_AUX_LVL;
goto mode;
case ARIAMIX_TEL_MUTE:
dip->prev = ARIAMIX_TEL_LVL;
goto mode;
mode:
dip->mixer_class = ARIAMIX_INPUT_CLASS;
dip->type = AUDIO_MIXER_ENUM;
strcpy(dip->label.name, AudioNmute);
dip->un.e.num_mem = 2;
strcpy(dip->un.e.member[0].label.name, AudioNoff);
dip->un.e.member[0].ord = 0;
strcpy(dip->un.e.member[1].label.name, AudioNon);
dip->un.e.member[1].ord = 1;
break;
case ARIAMIX_MASTER_LVL:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
dip->next = ARIAMIX_MASTER_TREBLE;
strcpy(dip->label.name, AudioNvolume);
dip->un.v.num_channels = 2;
strcpy(dip->un.v.units.name, AudioNvolume);
break;
case ARIAMIX_MASTER_TREBLE:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
dip->prev = ARIAMIX_MASTER_LVL;
dip->next = ARIAMIX_MASTER_BASS;
strcpy(dip->label.name, AudioNmaster);
dip->un.v.num_channels = 2;
strcpy(dip->un.v.units.name, AudioNtreble);
break;
case ARIAMIX_MASTER_BASS:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
dip->prev = ARIAMIX_MASTER_TREBLE;
strcpy(dip->label.name, AudioNmaster);
dip->un.v.num_channels = 2;
strcpy(dip->un.v.units.name, AudioNbass);
break;
case ARIAMIX_OUT_LVL:
dip->type = AUDIO_MIXER_VALUE;
dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
strcpy(dip->label.name, AudioNoutput);
dip->un.v.num_channels = 2;
strcpy(dip->un.v.units.name, AudioNvolume);
break;
case ARIAMIX_RECORD_SOURCE:
dip->mixer_class = ARIAMIX_RECORD_CLASS;
dip->type = AUDIO_MIXER_ENUM;
strcpy(dip->label.name, AudioNsource);
dip->un.e.num_mem = 6;
strcpy(dip->un.e.member[0].label.name, AudioNoutput);
dip->un.e.member[0].ord = ARIAMIX_AUX_LVL;
strcpy(dip->un.e.member[1].label.name, AudioNmicrophone);
dip->un.e.member[1].ord = ARIAMIX_MIC_LVL;
strcpy(dip->un.e.member[2].label.name, AudioNdac);
dip->un.e.member[2].ord = ARIAMIX_DAC_LVL;
strcpy(dip->un.e.member[3].label.name, AudioNline);
dip->un.e.member[3].ord = ARIAMIX_LINE_IN_LVL;
strcpy(dip->un.e.member[3].label.name, AudioNcd);
dip->un.e.member[4].ord = ARIAMIX_CD_LVL;
strcpy(dip->un.e.member[3].label.name, "telephone");
dip->un.e.member[5].ord = ARIAMIX_TEL_LVL;
break;
case ARIAMIX_INPUT_CLASS:
dip->type = AUDIO_MIXER_CLASS;
dip->mixer_class = ARIAMIX_INPUT_CLASS;
strcpy(dip->label.name, AudioCInputs);
break;
case ARIAMIX_OUTPUT_CLASS:
dip->type = AUDIO_MIXER_CLASS;
dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
strcpy(dip->label.name, AudioCOutputs);
break;
case ARIAMIX_RECORD_CLASS:
dip->type = AUDIO_MIXER_CLASS;
dip->mixer_class = ARIAMIX_RECORD_CLASS;
strcpy(dip->label.name, AudioCRecord);
break;
case ARIAMIX_EQ_CLASS:
dip->type = AUDIO_MIXER_CLASS;
dip->mixer_class = ARIAMIX_EQ_CLASS;
strcpy(dip->label.name, AudioCEqualization);
break;
default:
return ENXIO;
/*NOTREACHED*/
}
return 0;
}
#endif /* NARIA */
|