398
495
#define MADI_DS_CHANNELS 32
399
496
#define MADI_QS_CHANNELS 16
498
#define RAYDAT_SS_CHANNELS 36
499
#define RAYDAT_DS_CHANNELS 20
500
#define RAYDAT_QS_CHANNELS 12
502
#define AIO_IN_SS_CHANNELS 14
503
#define AIO_IN_DS_CHANNELS 10
504
#define AIO_IN_QS_CHANNELS 8
505
#define AIO_OUT_SS_CHANNELS 16
506
#define AIO_OUT_DS_CHANNELS 12
507
#define AIO_OUT_QS_CHANNELS 10
509
#define AES32_CHANNELS 16
401
511
/* the size of a substream (1 mono data stream) */
402
512
#define HDSPM_CHANNEL_BUFFER_SAMPLES (16*1024)
403
513
#define HDSPM_CHANNEL_BUFFER_BYTES (4*HDSPM_CHANNEL_BUFFER_SAMPLES)
405
515
/* the size of the area we need to allocate for DMA transfers. the
406
516
size is the same regardless of the number of channels, and
407
also the latency to use.
517
also the latency to use.
408
518
for one direction !!!
410
520
#define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES)
411
521
#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024)
413
523
/* revisions >= 230 indicate AES32 card */
414
#define HDSPM_AESREVISION 230
524
#define HDSPM_MADI_OLD_REV 207
525
#define HDSPM_MADI_REV 210
526
#define HDSPM_RAYDAT_REV 211
527
#define HDSPM_AIO_REV 212
528
#define HDSPM_MADIFACE_REV 213
529
#define HDSPM_AES_REV 240
530
#define HDSPM_AES32_REV 234
531
#define HDSPM_AES32_OLD_REV 233
416
533
/* speed factor modes */
417
534
#define HDSPM_SPEED_SINGLE 0
418
535
#define HDSPM_SPEED_DOUBLE 1
419
536
#define HDSPM_SPEED_QUAD 2
420
538
/* names for speed modes */
421
539
static char *hdspm_speed_names[] = { "single", "double", "quad" };
541
static char *texts_autosync_aes_tco[] = { "Word Clock",
542
"AES1", "AES2", "AES3", "AES4",
543
"AES5", "AES6", "AES7", "AES8",
545
static char *texts_autosync_aes[] = { "Word Clock",
546
"AES1", "AES2", "AES3", "AES4",
547
"AES5", "AES6", "AES7", "AES8" };
548
static char *texts_autosync_madi_tco[] = { "Word Clock",
549
"MADI", "TCO", "Sync In" };
550
static char *texts_autosync_madi[] = { "Word Clock",
553
static char *texts_autosync_raydat_tco[] = {
555
"ADAT 1", "ADAT 2", "ADAT 3", "ADAT 4",
556
"AES", "SPDIF", "TCO", "Sync In"
558
static char *texts_autosync_raydat[] = {
560
"ADAT 1", "ADAT 2", "ADAT 3", "ADAT 4",
561
"AES", "SPDIF", "Sync In"
563
static char *texts_autosync_aio_tco[] = {
565
"ADAT", "AES", "SPDIF", "TCO", "Sync In"
567
static char *texts_autosync_aio[] = { "Word Clock",
568
"ADAT", "AES", "SPDIF", "Sync In" };
570
static char *texts_freq[] = {
583
static char *texts_ports_madi[] = {
584
"MADI.1", "MADI.2", "MADI.3", "MADI.4", "MADI.5", "MADI.6",
585
"MADI.7", "MADI.8", "MADI.9", "MADI.10", "MADI.11", "MADI.12",
586
"MADI.13", "MADI.14", "MADI.15", "MADI.16", "MADI.17", "MADI.18",
587
"MADI.19", "MADI.20", "MADI.21", "MADI.22", "MADI.23", "MADI.24",
588
"MADI.25", "MADI.26", "MADI.27", "MADI.28", "MADI.29", "MADI.30",
589
"MADI.31", "MADI.32", "MADI.33", "MADI.34", "MADI.35", "MADI.36",
590
"MADI.37", "MADI.38", "MADI.39", "MADI.40", "MADI.41", "MADI.42",
591
"MADI.43", "MADI.44", "MADI.45", "MADI.46", "MADI.47", "MADI.48",
592
"MADI.49", "MADI.50", "MADI.51", "MADI.52", "MADI.53", "MADI.54",
593
"MADI.55", "MADI.56", "MADI.57", "MADI.58", "MADI.59", "MADI.60",
594
"MADI.61", "MADI.62", "MADI.63", "MADI.64",
598
static char *texts_ports_raydat_ss[] = {
599
"ADAT1.1", "ADAT1.2", "ADAT1.3", "ADAT1.4", "ADAT1.5", "ADAT1.6",
600
"ADAT1.7", "ADAT1.8", "ADAT2.1", "ADAT2.2", "ADAT2.3", "ADAT2.4",
601
"ADAT2.5", "ADAT2.6", "ADAT2.7", "ADAT2.8", "ADAT3.1", "ADAT3.2",
602
"ADAT3.3", "ADAT3.4", "ADAT3.5", "ADAT3.6", "ADAT3.7", "ADAT3.8",
603
"ADAT4.1", "ADAT4.2", "ADAT4.3", "ADAT4.4", "ADAT4.5", "ADAT4.6",
604
"ADAT4.7", "ADAT4.8",
609
static char *texts_ports_raydat_ds[] = {
610
"ADAT1.1", "ADAT1.2", "ADAT1.3", "ADAT1.4",
611
"ADAT2.1", "ADAT2.2", "ADAT2.3", "ADAT2.4",
612
"ADAT3.1", "ADAT3.2", "ADAT3.3", "ADAT3.4",
613
"ADAT4.1", "ADAT4.2", "ADAT4.3", "ADAT4.4",
618
static char *texts_ports_raydat_qs[] = {
619
"ADAT1.1", "ADAT1.2",
620
"ADAT2.1", "ADAT2.2",
621
"ADAT3.1", "ADAT3.2",
622
"ADAT4.1", "ADAT4.2",
628
static char *texts_ports_aio_in_ss[] = {
629
"Analogue.L", "Analogue.R",
631
"SPDIF.L", "SPDIF.R",
632
"ADAT.1", "ADAT.2", "ADAT.3", "ADAT.4", "ADAT.5", "ADAT.6",
636
static char *texts_ports_aio_out_ss[] = {
637
"Analogue.L", "Analogue.R",
639
"SPDIF.L", "SPDIF.R",
640
"ADAT.1", "ADAT.2", "ADAT.3", "ADAT.4", "ADAT.5", "ADAT.6",
645
static char *texts_ports_aio_in_ds[] = {
646
"Analogue.L", "Analogue.R",
648
"SPDIF.L", "SPDIF.R",
649
"ADAT.1", "ADAT.2", "ADAT.3", "ADAT.4"
652
static char *texts_ports_aio_out_ds[] = {
653
"Analogue.L", "Analogue.R",
655
"SPDIF.L", "SPDIF.R",
656
"ADAT.1", "ADAT.2", "ADAT.3", "ADAT.4",
660
static char *texts_ports_aio_in_qs[] = {
661
"Analogue.L", "Analogue.R",
663
"SPDIF.L", "SPDIF.R",
664
"ADAT.1", "ADAT.2", "ADAT.3", "ADAT.4"
667
static char *texts_ports_aio_out_qs[] = {
668
"Analogue.L", "Analogue.R",
670
"SPDIF.L", "SPDIF.R",
671
"ADAT.1", "ADAT.2", "ADAT.3", "ADAT.4",
675
static char *texts_ports_aes32[] = {
676
"AES.1", "AES.2", "AES.3", "AES.4", "AES.5", "AES.6", "AES.7",
677
"AES.8", "AES.9.", "AES.10", "AES.11", "AES.12", "AES.13", "AES.14",
681
/* These tables map the ALSA channels 1..N to the channels that we
682
need to use in order to find the relevant channel buffer. RME
683
refers to this kind of mapping as between "the ADAT channel and
684
the DMA channel." We index it using the logical audio channel,
685
and the value is the DMA channel (i.e. channel buffer number)
686
where the data for that channel can be read/written from/to.
689
static char channel_map_unity_ss[HDSPM_MAX_CHANNELS] = {
690
0, 1, 2, 3, 4, 5, 6, 7,
691
8, 9, 10, 11, 12, 13, 14, 15,
692
16, 17, 18, 19, 20, 21, 22, 23,
693
24, 25, 26, 27, 28, 29, 30, 31,
694
32, 33, 34, 35, 36, 37, 38, 39,
695
40, 41, 42, 43, 44, 45, 46, 47,
696
48, 49, 50, 51, 52, 53, 54, 55,
697
56, 57, 58, 59, 60, 61, 62, 63
700
static char channel_map_raydat_ss[HDSPM_MAX_CHANNELS] = {
701
4, 5, 6, 7, 8, 9, 10, 11, /* ADAT 1 */
702
12, 13, 14, 15, 16, 17, 18, 19, /* ADAT 2 */
703
20, 21, 22, 23, 24, 25, 26, 27, /* ADAT 3 */
704
28, 29, 30, 31, 32, 33, 34, 35, /* ADAT 4 */
708
-1, -1, -1, -1, -1, -1, -1, -1,
709
-1, -1, -1, -1, -1, -1, -1, -1,
710
-1, -1, -1, -1, -1, -1, -1, -1,
713
static char channel_map_raydat_ds[HDSPM_MAX_CHANNELS] = {
714
4, 5, 6, 7, /* ADAT 1 */
715
8, 9, 10, 11, /* ADAT 2 */
716
12, 13, 14, 15, /* ADAT 3 */
717
16, 17, 18, 19, /* ADAT 4 */
721
-1, -1, -1, -1, -1, -1, -1, -1,
722
-1, -1, -1, -1, -1, -1, -1, -1,
723
-1, -1, -1, -1, -1, -1, -1, -1,
724
-1, -1, -1, -1, -1, -1, -1, -1,
725
-1, -1, -1, -1, -1, -1, -1, -1,
728
static char channel_map_raydat_qs[HDSPM_MAX_CHANNELS] = {
736
-1, -1, -1, -1, -1, -1, -1, -1,
737
-1, -1, -1, -1, -1, -1, -1, -1,
738
-1, -1, -1, -1, -1, -1, -1, -1,
739
-1, -1, -1, -1, -1, -1, -1, -1,
740
-1, -1, -1, -1, -1, -1, -1, -1,
741
-1, -1, -1, -1, -1, -1, -1, -1,
744
static char channel_map_aio_in_ss[HDSPM_MAX_CHANNELS] = {
747
10, 11, /* spdif in */
748
12, 13, 14, 15, 16, 17, 18, 19, /* ADAT in */
750
-1, -1, -1, -1, -1, -1, -1, -1,
751
-1, -1, -1, -1, -1, -1, -1, -1,
752
-1, -1, -1, -1, -1, -1, -1, -1,
753
-1, -1, -1, -1, -1, -1, -1, -1,
754
-1, -1, -1, -1, -1, -1, -1, -1,
755
-1, -1, -1, -1, -1, -1, -1, -1,
758
static char channel_map_aio_out_ss[HDSPM_MAX_CHANNELS] = {
761
10, 11, /* spdif out */
762
12, 13, 14, 15, 16, 17, 18, 19, /* ADAT out */
763
6, 7, /* phone out */
764
-1, -1, -1, -1, -1, -1, -1, -1,
765
-1, -1, -1, -1, -1, -1, -1, -1,
766
-1, -1, -1, -1, -1, -1, -1, -1,
767
-1, -1, -1, -1, -1, -1, -1, -1,
768
-1, -1, -1, -1, -1, -1, -1, -1,
769
-1, -1, -1, -1, -1, -1, -1, -1,
772
static char channel_map_aio_in_ds[HDSPM_MAX_CHANNELS] = {
775
10, 11, /* spdif in */
776
12, 14, 16, 18, /* adat in */
777
-1, -1, -1, -1, -1, -1,
778
-1, -1, -1, -1, -1, -1, -1, -1,
779
-1, -1, -1, -1, -1, -1, -1, -1,
780
-1, -1, -1, -1, -1, -1, -1, -1,
781
-1, -1, -1, -1, -1, -1, -1, -1,
782
-1, -1, -1, -1, -1, -1, -1, -1,
783
-1, -1, -1, -1, -1, -1, -1, -1
786
static char channel_map_aio_out_ds[HDSPM_MAX_CHANNELS] = {
789
10, 11, /* spdif out */
790
12, 14, 16, 18, /* adat out */
791
6, 7, /* phone out */
793
-1, -1, -1, -1, -1, -1, -1, -1,
794
-1, -1, -1, -1, -1, -1, -1, -1,
795
-1, -1, -1, -1, -1, -1, -1, -1,
796
-1, -1, -1, -1, -1, -1, -1, -1,
797
-1, -1, -1, -1, -1, -1, -1, -1,
798
-1, -1, -1, -1, -1, -1, -1, -1
801
static char channel_map_aio_in_qs[HDSPM_MAX_CHANNELS] = {
804
10, 11, /* spdif in */
805
12, 16, /* adat in */
806
-1, -1, -1, -1, -1, -1, -1, -1,
807
-1, -1, -1, -1, -1, -1, -1, -1,
808
-1, -1, -1, -1, -1, -1, -1, -1,
809
-1, -1, -1, -1, -1, -1, -1, -1,
810
-1, -1, -1, -1, -1, -1, -1, -1,
811
-1, -1, -1, -1, -1, -1, -1, -1,
812
-1, -1, -1, -1, -1, -1, -1, -1
815
static char channel_map_aio_out_qs[HDSPM_MAX_CHANNELS] = {
818
10, 11, /* spdif out */
819
12, 16, /* adat out */
820
6, 7, /* phone out */
821
-1, -1, -1, -1, -1, -1,
822
-1, -1, -1, -1, -1, -1, -1, -1,
823
-1, -1, -1, -1, -1, -1, -1, -1,
824
-1, -1, -1, -1, -1, -1, -1, -1,
825
-1, -1, -1, -1, -1, -1, -1, -1,
826
-1, -1, -1, -1, -1, -1, -1, -1,
827
-1, -1, -1, -1, -1, -1, -1, -1
830
static char channel_map_aes32[HDSPM_MAX_CHANNELS] = {
831
0, 1, 2, 3, 4, 5, 6, 7,
832
8, 9, 10, 11, 12, 13, 14, 15,
833
-1, -1, -1, -1, -1, -1, -1, -1,
834
-1, -1, -1, -1, -1, -1, -1, -1,
835
-1, -1, -1, -1, -1, -1, -1, -1,
836
-1, -1, -1, -1, -1, -1, -1, -1,
837
-1, -1, -1, -1, -1, -1, -1, -1,
838
-1, -1, -1, -1, -1, -1, -1, -1
423
841
struct hdspm_midi {
424
842
struct hdspm *hdspm;
1341
1953
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1342
1954
uinfo->count = 1;
1955
uinfo->value.integer.min = 27000;
1956
uinfo->value.integer.max = 207000;
1957
uinfo->value.integer.step = 1;
1346
1962
static int snd_hdspm_get_system_sample_rate(struct snd_kcontrol *kcontrol,
1347
1963
struct snd_ctl_elem_value *
1350
1966
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
1352
ucontrol->value.enumerated.item[0] = hdspm->system_sample_rate;
1968
ucontrol->value.integer.value[0] = hdspm_get_system_sample_rate(hdspm);
1974
* Returns the WordClock sample rate class for the given card.
1976
static int hdspm_get_wc_sample_rate(struct hdspm *hdspm)
1980
switch (hdspm->io_type) {
1983
status = hdspm_read(hdspm, HDSPM_RD_STATUS_1);
1984
return (status >> 16) & 0xF;
1996
* Returns the TCO sample rate class for the given card.
1998
static int hdspm_get_tco_sample_rate(struct hdspm *hdspm)
2003
switch (hdspm->io_type) {
2006
status = hdspm_read(hdspm, HDSPM_RD_STATUS_1);
2007
return (status >> 20) & 0xF;
2019
* Returns the SYNC_IN sample rate class for the given card.
2021
static int hdspm_get_sync_in_sample_rate(struct hdspm *hdspm)
2026
switch (hdspm->io_type) {
2029
status = hdspm_read(hdspm, HDSPM_RD_STATUS_2);
2030
return (status >> 12) & 0xF;
2042
* Returns the sample rate class for input source <idx> for
2043
* 'new style' cards like the AIO and RayDAT.
2045
static int hdspm_get_s1_sample_rate(struct hdspm *hdspm, unsigned int idx)
2047
int status = hdspm_read(hdspm, HDSPM_RD_STATUS_2);
2049
return (status >> (idx*4)) & 0xF;
1356
2054
#define HDSPM_AUTOSYNC_SAMPLE_RATE(xname, xindex) \
1357
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1360
.access = SNDRV_CTL_ELEM_ACCESS_READ, \
1361
.info = snd_hdspm_info_autosync_sample_rate, \
1362
.get = snd_hdspm_get_autosync_sample_rate \
2055
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2057
.private_value = xindex, \
2058
.access = SNDRV_CTL_ELEM_ACCESS_READ, \
2059
.info = snd_hdspm_info_autosync_sample_rate, \
2060
.get = snd_hdspm_get_autosync_sample_rate \
1365
2064
static int snd_hdspm_info_autosync_sample_rate(struct snd_kcontrol *kcontrol,
1366
2065
struct snd_ctl_elem_info *uinfo)
1368
static char *texts[] = { "32000", "44100", "48000",
1369
"64000", "88200", "96000",
1370
"128000", "176400", "192000",
1373
2067
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1374
2068
uinfo->count = 1;
1375
2069
uinfo->value.enumerated.items = 10;
1376
2071
if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1377
uinfo->value.enumerated.item =
1378
uinfo->value.enumerated.items - 1;
2072
uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
1379
2073
strcpy(uinfo->value.enumerated.name,
1380
texts[uinfo->value.enumerated.item]);
2074
texts_freq[uinfo->value.enumerated.item]);
1384
2079
static int snd_hdspm_get_autosync_sample_rate(struct snd_kcontrol *kcontrol,
1385
2080
struct snd_ctl_elem_value *
1388
2083
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
1390
switch (hdspm_external_sample_rate(hdspm)) {
1392
ucontrol->value.enumerated.item[0] = 0;
1395
ucontrol->value.enumerated.item[0] = 1;
1398
ucontrol->value.enumerated.item[0] = 2;
1401
ucontrol->value.enumerated.item[0] = 3;
1404
ucontrol->value.enumerated.item[0] = 4;
1407
ucontrol->value.enumerated.item[0] = 5;
1410
ucontrol->value.enumerated.item[0] = 6;
1413
ucontrol->value.enumerated.item[0] = 7;
1416
ucontrol->value.enumerated.item[0] = 8;
2085
switch (hdspm->io_type) {
2087
switch (kcontrol->private_value) {
2089
ucontrol->value.enumerated.item[0] =
2090
hdspm_get_wc_sample_rate(hdspm);
2093
ucontrol->value.enumerated.item[0] =
2094
hdspm_get_tco_sample_rate(hdspm);
2097
ucontrol->value.enumerated.item[0] =
2098
hdspm_get_sync_in_sample_rate(hdspm);
2101
ucontrol->value.enumerated.item[0] =
2102
hdspm_get_s1_sample_rate(hdspm,
2103
kcontrol->private_value-1);
2107
switch (kcontrol->private_value) {
2109
ucontrol->value.enumerated.item[0] =
2110
hdspm_get_wc_sample_rate(hdspm);
2113
ucontrol->value.enumerated.item[0] =
2114
hdspm_get_tco_sample_rate(hdspm);
2116
case 5: /* SYNC_IN */
2117
ucontrol->value.enumerated.item[0] =
2118
hdspm_get_sync_in_sample_rate(hdspm);
2121
ucontrol->value.enumerated.item[0] =
2122
hdspm_get_s1_sample_rate(hdspm,
2123
ucontrol->id.index-1);
2128
switch (kcontrol->private_value) {
2130
ucontrol->value.enumerated.item[0] =
2131
hdspm_get_wc_sample_rate(hdspm);
2134
ucontrol->value.enumerated.item[0] =
2135
hdspm_get_tco_sample_rate(hdspm);
2137
case 10: /* SYNC_IN */
2138
ucontrol->value.enumerated.item[0] =
2139
hdspm_get_sync_in_sample_rate(hdspm);
2141
default: /* AES1 to AES8 */
2142
ucontrol->value.enumerated.item[0] =
2143
hdspm_get_s1_sample_rate(hdspm,
2144
kcontrol->private_value-1);
1420
ucontrol->value.enumerated.item[0] = 9;
1425
2156
#define HDSPM_SYSTEM_CLOCK_MODE(xname, xindex) \
1426
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1429
.access = SNDRV_CTL_ELEM_ACCESS_READ, \
1430
.info = snd_hdspm_info_system_clock_mode, \
1431
.get = snd_hdspm_get_system_clock_mode, \
2157
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2160
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
2161
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2162
.info = snd_hdspm_info_system_clock_mode, \
2163
.get = snd_hdspm_get_system_clock_mode, \
2164
.put = snd_hdspm_put_system_clock_mode, \
1436
static int hdspm_system_clock_mode(struct hdspm * hdspm)
2169
* Returns the system clock mode for the given card.
2170
* @returns 0 - master, 1 - slave
2172
static int hdspm_system_clock_mode(struct hdspm *hdspm)
1438
/* Always reflect the hardware info, rme is never wrong !!!! */
1440
if (hdspm->control_register & HDSPM_ClockModeMaster)
2174
switch (hdspm->io_type) {
2177
if (hdspm->settings_register & HDSPM_c0Master)
2182
if (hdspm->control_register & HDSPM_ClockModeMaster)
2191
* Sets the system clock mode.
2192
* @param mode 0 - master, 1 - slave
2194
static void hdspm_set_system_clock_mode(struct hdspm *hdspm, int mode)
2196
switch (hdspm->io_type) {
2200
hdspm->settings_register |= HDSPM_c0Master;
2202
hdspm->settings_register &= ~HDSPM_c0Master;
2204
hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register);
2209
hdspm->control_register |= HDSPM_ClockModeMaster;
2211
hdspm->control_register &= ~HDSPM_ClockModeMaster;
2213
hdspm_write(hdspm, HDSPM_controlRegister,
2214
hdspm->control_register);
1445
2219
static int snd_hdspm_info_system_clock_mode(struct snd_kcontrol *kcontrol,
1446
2220
struct snd_ctl_elem_info *uinfo)
1448
static char *texts[] = { "Master", "Slave" };
2222
static char *texts[] = { "Master", "AutoSync" };
1450
2224
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1451
2225
uinfo->count = 1;
1618
2371
#define HDSPM_PREF_SYNC_REF(xname, xindex) \
1619
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1622
.info = snd_hdspm_info_pref_sync_ref, \
1623
.get = snd_hdspm_get_pref_sync_ref, \
1624
.put = snd_hdspm_put_pref_sync_ref \
2372
{.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2375
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
2376
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2377
.info = snd_hdspm_info_pref_sync_ref, \
2378
.get = snd_hdspm_get_pref_sync_ref, \
2379
.put = snd_hdspm_put_pref_sync_ref \
2384
* Returns the current preferred sync reference setting.
2385
* The semantics of the return value are depending on the
2386
* card, please see the comments for clarification.
1627
2388
static int hdspm_pref_sync_ref(struct hdspm * hdspm)
1629
/* Notice that this looks at the requested sync source,
1630
not the one actually in use.
1632
if (hdspm->is_aes32) {
1633
switch (hdspm->control_register & HDSPM_SyncRefMask) {
1634
/* number gives AES index, except for 0 which
1635
corresponds to WordClock */
1637
case HDSPM_SyncRef0: return 1;
1638
case HDSPM_SyncRef1: return 2;
1639
case HDSPM_SyncRef1+HDSPM_SyncRef0: return 3;
1640
case HDSPM_SyncRef2: return 4;
1641
case HDSPM_SyncRef2+HDSPM_SyncRef0: return 5;
1642
case HDSPM_SyncRef2+HDSPM_SyncRef1: return 6;
1643
case HDSPM_SyncRef2+HDSPM_SyncRef1+HDSPM_SyncRef0: return 7;
1644
case HDSPM_SyncRef3: return 8;
1647
switch (hdspm->control_register & HDSPM_SyncRefMask) {
1648
case HDSPM_SyncRef_Word:
1649
return HDSPM_SYNC_FROM_WORD;
1650
case HDSPM_SyncRef_MADI:
1651
return HDSPM_SYNC_FROM_MADI;
2390
switch (hdspm->io_type) {
2392
switch (hdspm->control_register & HDSPM_SyncRefMask) {
2393
case 0: return 0; /* WC */
2394
case HDSPM_SyncRef0: return 1; /* AES 1 */
2395
case HDSPM_SyncRef1: return 2; /* AES 2 */
2396
case HDSPM_SyncRef1+HDSPM_SyncRef0: return 3; /* AES 3 */
2397
case HDSPM_SyncRef2: return 4; /* AES 4 */
2398
case HDSPM_SyncRef2+HDSPM_SyncRef0: return 5; /* AES 5 */
2399
case HDSPM_SyncRef2+HDSPM_SyncRef1: return 6; /* AES 6 */
2400
case HDSPM_SyncRef2+HDSPM_SyncRef1+HDSPM_SyncRef0:
2401
return 7; /* AES 7 */
2402
case HDSPM_SyncRef3: return 8; /* AES 8 */
2403
case HDSPM_SyncRef3+HDSPM_SyncRef0: return 9; /* TCO */
2410
switch (hdspm->control_register & HDSPM_SyncRefMask) {
2411
case 0: return 0; /* WC */
2412
case HDSPM_SyncRef0: return 1; /* MADI */
2413
case HDSPM_SyncRef1: return 2; /* TCO */
2414
case HDSPM_SyncRef1+HDSPM_SyncRef0:
2415
return 3; /* SYNC_IN */
2418
switch (hdspm->control_register & HDSPM_SyncRefMask) {
2419
case 0: return 0; /* WC */
2420
case HDSPM_SyncRef0: return 1; /* MADI */
2421
case HDSPM_SyncRef1+HDSPM_SyncRef0:
2422
return 2; /* SYNC_IN */
2429
switch ((hdspm->settings_register &
2430
HDSPM_c0_SyncRefMask) / HDSPM_c0_SyncRef0) {
2431
case 0: return 0; /* WC */
2432
case 3: return 1; /* ADAT 1 */
2433
case 4: return 2; /* ADAT 2 */
2434
case 5: return 3; /* ADAT 3 */
2435
case 6: return 4; /* ADAT 4 */
2436
case 1: return 5; /* AES */
2437
case 2: return 6; /* SPDIF */
2438
case 9: return 7; /* TCO */
2439
case 10: return 8; /* SYNC_IN */
2442
switch ((hdspm->settings_register &
2443
HDSPM_c0_SyncRefMask) / HDSPM_c0_SyncRef0) {
2444
case 0: return 0; /* WC */
2445
case 3: return 1; /* ADAT 1 */
2446
case 4: return 2; /* ADAT 2 */
2447
case 5: return 3; /* ADAT 3 */
2448
case 6: return 4; /* ADAT 4 */
2449
case 1: return 5; /* AES */
2450
case 2: return 6; /* SPDIF */
2451
case 10: return 7; /* SYNC_IN */
2459
switch ((hdspm->settings_register &
2460
HDSPM_c0_SyncRefMask) / HDSPM_c0_SyncRef0) {
2461
case 0: return 0; /* WC */
2462
case 3: return 1; /* ADAT */
2463
case 1: return 2; /* AES */
2464
case 2: return 3; /* SPDIF */
2465
case 9: return 4; /* TCO */
2466
case 10: return 5; /* SYNC_IN */
2469
switch ((hdspm->settings_register &
2470
HDSPM_c0_SyncRefMask) / HDSPM_c0_SyncRef0) {
2471
case 0: return 0; /* WC */
2472
case 3: return 1; /* ADAT */
2473
case 1: return 2; /* AES */
2474
case 2: return 3; /* SPDIF */
2475
case 10: return 4; /* SYNC_IN */
1655
return HDSPM_SYNC_FROM_WORD;
2487
* Set the preferred sync reference to <pref>. The semantics
2488
* of <pref> are depending on the card type, see the comments
2489
* for clarification.
1658
2491
static int hdspm_set_pref_sync_ref(struct hdspm * hdspm, int pref)
1660
hdspm->control_register &= ~HDSPM_SyncRefMask;
1662
if (hdspm->is_aes32) {
1665
hdspm->control_register |= 0;
1668
hdspm->control_register |= HDSPM_SyncRef0;
1671
hdspm->control_register |= HDSPM_SyncRef1;
1674
hdspm->control_register |= HDSPM_SyncRef1+HDSPM_SyncRef0;
1677
hdspm->control_register |= HDSPM_SyncRef2;
1680
hdspm->control_register |= HDSPM_SyncRef2+HDSPM_SyncRef0;
1683
hdspm->control_register |= HDSPM_SyncRef2+HDSPM_SyncRef1;
1686
hdspm->control_register |=
1687
HDSPM_SyncRef2+HDSPM_SyncRef1+HDSPM_SyncRef0;
1690
hdspm->control_register |= HDSPM_SyncRef3;
1697
case HDSPM_SYNC_FROM_MADI:
1698
hdspm->control_register |= HDSPM_SyncRef_MADI;
1700
case HDSPM_SYNC_FROM_WORD:
1701
hdspm->control_register |= HDSPM_SyncRef_Word;
2495
switch (hdspm->io_type) {
2497
hdspm->control_register &= ~HDSPM_SyncRefMask;
2502
hdspm->control_register |= HDSPM_SyncRef0;
2505
hdspm->control_register |= HDSPM_SyncRef1;
2508
hdspm->control_register |=
2509
HDSPM_SyncRef1+HDSPM_SyncRef0;
2512
hdspm->control_register |= HDSPM_SyncRef2;
2515
hdspm->control_register |=
2516
HDSPM_SyncRef2+HDSPM_SyncRef0;
2519
hdspm->control_register |=
2520
HDSPM_SyncRef2+HDSPM_SyncRef1;
2523
hdspm->control_register |=
2524
HDSPM_SyncRef2+HDSPM_SyncRef1+HDSPM_SyncRef0;
2527
hdspm->control_register |= HDSPM_SyncRef3;
2530
hdspm->control_register |=
2531
HDSPM_SyncRef3+HDSPM_SyncRef0;
1707
hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
2541
hdspm->control_register &= ~HDSPM_SyncRefMask;
2547
hdspm->control_register |= HDSPM_SyncRef0;
2550
hdspm->control_register |= HDSPM_SyncRef1;
2552
case 3: /* SYNC_IN */
2553
hdspm->control_register |=
2554
HDSPM_SyncRef0+HDSPM_SyncRef1;
2564
hdspm->control_register |= HDSPM_SyncRef0;
2566
case 2: /* SYNC_IN */
2567
hdspm->control_register |=
2568
HDSPM_SyncRef0+HDSPM_SyncRef1;
2580
case 0: p = 0; break; /* WC */
2581
case 1: p = 3; break; /* ADAT 1 */
2582
case 2: p = 4; break; /* ADAT 2 */
2583
case 3: p = 5; break; /* ADAT 3 */
2584
case 4: p = 6; break; /* ADAT 4 */
2585
case 5: p = 1; break; /* AES */
2586
case 6: p = 2; break; /* SPDIF */
2587
case 7: p = 9; break; /* TCO */
2588
case 8: p = 10; break; /* SYNC_IN */
2593
case 0: p = 0; break; /* WC */
2594
case 1: p = 3; break; /* ADAT 1 */
2595
case 2: p = 4; break; /* ADAT 2 */
2596
case 3: p = 5; break; /* ADAT 3 */
2597
case 4: p = 6; break; /* ADAT 4 */
2598
case 5: p = 1; break; /* AES */
2599
case 6: p = 2; break; /* SPDIF */
2600
case 7: p = 10; break; /* SYNC_IN */
2609
case 0: p = 0; break; /* WC */
2610
case 1: p = 3; break; /* ADAT */
2611
case 2: p = 1; break; /* AES */
2612
case 3: p = 2; break; /* SPDIF */
2613
case 4: p = 9; break; /* TCO */
2614
case 5: p = 10; break; /* SYNC_IN */
2619
case 0: p = 0; break; /* WC */
2620
case 1: p = 3; break; /* ADAT */
2621
case 2: p = 1; break; /* AES */
2622
case 3: p = 2; break; /* SPDIF */
2623
case 4: p = 10; break; /* SYNC_IN */
2630
switch (hdspm->io_type) {
2633
hdspm->settings_register &= ~HDSPM_c0_SyncRefMask;
2634
hdspm->settings_register |= HDSPM_c0_SyncRef0 * p;
2635
hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register);
2641
hdspm_write(hdspm, HDSPM_controlRegister,
2642
hdspm->control_register);
1711
2649
static int snd_hdspm_info_pref_sync_ref(struct snd_kcontrol *kcontrol,
1712
2650
struct snd_ctl_elem_info *uinfo)
1714
2652
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
1716
if (hdspm->is_aes32) {
1717
static char *texts[] = { "Word", "AES1", "AES2", "AES3",
1718
"AES4", "AES5", "AES6", "AES7", "AES8" };
1720
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1723
uinfo->value.enumerated.items = 9;
1725
if (uinfo->value.enumerated.item >=
1726
uinfo->value.enumerated.items)
1727
uinfo->value.enumerated.item =
1728
uinfo->value.enumerated.items - 1;
1729
strcpy(uinfo->value.enumerated.name,
1730
texts[uinfo->value.enumerated.item]);
1732
static char *texts[] = { "Word", "MADI" };
1734
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1737
uinfo->value.enumerated.items = 2;
1739
if (uinfo->value.enumerated.item >=
1740
uinfo->value.enumerated.items)
1741
uinfo->value.enumerated.item =
1742
uinfo->value.enumerated.items - 1;
1743
strcpy(uinfo->value.enumerated.name,
1744
texts[uinfo->value.enumerated.item]);
2654
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2656
uinfo->value.enumerated.items = hdspm->texts_autosync_items;
2658
if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2659
uinfo->value.enumerated.item =
2660
uinfo->value.enumerated.items - 1;
2662
strcpy(uinfo->value.enumerated.name,
2663
hdspm->texts_autosync[uinfo->value.enumerated.item]);
2753
static int snd_hdspm_get_madisync_sync_check(struct snd_kcontrol *kcontrol,
2754
struct snd_ctl_elem_value *
2757
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
2759
ucontrol->value.enumerated.item[0] =
2760
hdspm_madisync_sync_check(hdspm);
2765
#define HDSPM_AES_SYNC_CHECK(xname, xindex) \
2766
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2769
.access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2770
.info = snd_hdspm_info_sync_check, \
2771
.get = snd_hdspm_get_aes_sync_check \
2774
static int hdspm_aes_sync_check(struct hdspm * hdspm, int idx)
2776
int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
2777
if (status2 & (HDSPM_LockAES >> idx)) {
2778
/* I don't know how to differenciate sync from lock.
2779
Doing as if sync for now */
2785
static int snd_hdspm_get_aes_sync_check(struct snd_kcontrol *kcontrol,
2786
struct snd_ctl_elem_value *ucontrol)
2789
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
2791
offset = ucontrol->id.index - 1;
2792
if (offset < 0 || offset >= 8)
2795
ucontrol->value.enumerated.item[0] =
2796
hdspm_aes_sync_check(hdspm, offset);
3678
static int hdspm_s1_sync_check(struct hdspm *hdspm, int idx)
3680
int status, lock, sync;
3682
status = hdspm_read(hdspm, HDSPM_RD_STATUS_1);
3684
lock = (status & (0x1<<idx)) ? 1 : 0;
3685
sync = (status & (0x100<<idx)) ? 1 : 0;
3695
static int hdspm_sync_in_sync_check(struct hdspm *hdspm)
3697
int status, lock = 0, sync = 0;
3699
switch (hdspm->io_type) {
3702
status = hdspm_read(hdspm, HDSPM_RD_STATUS_3);
3703
lock = (status & 0x400) ? 1 : 0;
3704
sync = (status & 0x800) ? 1 : 0;
3709
status = hdspm_read(hdspm, HDSPM_statusRegister2);
3710
lock = (status & HDSPM_syncInLock) ? 1 : 0;
3711
sync = (status & HDSPM_syncInSync) ? 1 : 0;
3726
static int hdspm_aes_sync_check(struct hdspm *hdspm, int idx)
3728
int status2, lock, sync;
3729
status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
3731
lock = (status2 & (0x0080 >> idx)) ? 1 : 0;
3732
sync = (status2 & (0x8000 >> idx)) ? 1 : 0;
3742
static int hdspm_tco_sync_check(struct hdspm *hdspm)
3747
switch (hdspm->io_type) {
3750
status = hdspm_read(hdspm, HDSPM_statusRegister);
3751
if (status & HDSPM_tcoLock) {
3752
if (status & HDSPM_tcoSync)
3763
status = hdspm_read(hdspm, HDSPM_RD_STATUS_1);
3765
if (status & 0x8000000)
3766
return 2; /* Sync */
3767
if (status & 0x4000000)
3768
return 1; /* Lock */
3769
return 0; /* No signal */
3781
static int snd_hdspm_get_sync_check(struct snd_kcontrol *kcontrol,
3782
struct snd_ctl_elem_value *ucontrol)
3784
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
3787
switch (hdspm->io_type) {
3789
switch (kcontrol->private_value) {
3791
val = hdspm_wc_sync_check(hdspm); break;
3793
val = hdspm_tco_sync_check(hdspm); break;
3794
case 8: /* SYNC IN */
3795
val = hdspm_sync_in_sync_check(hdspm); break;
3797
val = hdspm_s1_sync_check(hdspm, ucontrol->id.index-1);
3801
switch (kcontrol->private_value) {
3803
val = hdspm_wc_sync_check(hdspm); break;
3805
val = hdspm_tco_sync_check(hdspm); break;
3806
case 5: /* SYNC IN */
3807
val = hdspm_sync_in_sync_check(hdspm); break;
3809
val = hdspm_s1_sync_check(hdspm, ucontrol->id.index-1);
3813
switch (kcontrol->private_value) {
3815
val = hdspm_wc_sync_check(hdspm); break;
3817
val = hdspm_madi_sync_check(hdspm); break;
3819
val = hdspm_tco_sync_check(hdspm); break;
3820
case 3: /* SYNC_IN */
3821
val = hdspm_sync_in_sync_check(hdspm); break;
3825
val = hdspm_madi_sync_check(hdspm); /* MADI */
3829
switch (kcontrol->private_value) {
3831
val = hdspm_wc_sync_check(hdspm); break;
3833
val = hdspm_tco_sync_check(hdspm); break;
3834
case 10 /* SYNC IN */:
3835
val = hdspm_sync_in_sync_check(hdspm); break;
3836
default: /* AES1 to AES8 */
3837
val = hdspm_aes_sync_check(hdspm,
3838
kcontrol->private_value-1);
3846
ucontrol->value.enumerated.item[0] = val;
3855
static void hdspm_tco_write(struct hdspm *hdspm)
3857
unsigned int tc[4] = { 0, 0, 0, 0};
3859
switch (hdspm->tco->input) {
3861
tc[2] |= HDSPM_TCO2_set_input_MSB;
3864
tc[2] |= HDSPM_TCO2_set_input_LSB;
3870
switch (hdspm->tco->framerate) {
3872
tc[1] |= HDSPM_TCO1_LTC_Format_LSB;
3875
tc[1] |= HDSPM_TCO1_LTC_Format_MSB;
3878
tc[1] |= HDSPM_TCO1_LTC_Format_MSB +
3879
HDSPM_TCO1_set_drop_frame_flag;
3882
tc[1] |= HDSPM_TCO1_LTC_Format_LSB +
3883
HDSPM_TCO1_LTC_Format_MSB;
3886
tc[1] |= HDSPM_TCO1_LTC_Format_LSB +
3887
HDSPM_TCO1_LTC_Format_MSB +
3888
HDSPM_TCO1_set_drop_frame_flag;
3894
switch (hdspm->tco->wordclock) {
3896
tc[2] |= HDSPM_TCO2_WCK_IO_ratio_LSB;
3899
tc[2] |= HDSPM_TCO2_WCK_IO_ratio_MSB;
3905
switch (hdspm->tco->samplerate) {
3907
tc[2] |= HDSPM_TCO2_set_freq;
3910
tc[2] |= HDSPM_TCO2_set_freq_from_app;
3916
switch (hdspm->tco->pull) {
3918
tc[2] |= HDSPM_TCO2_set_pull_up;
3921
tc[2] |= HDSPM_TCO2_set_pull_down;
3924
tc[2] |= HDSPM_TCO2_set_pull_up + HDSPM_TCO2_set_01_4;
3927
tc[2] |= HDSPM_TCO2_set_pull_down + HDSPM_TCO2_set_01_4;
3933
if (1 == hdspm->tco->term) {
3934
tc[2] |= HDSPM_TCO2_set_term_75R;
3937
hdspm_write(hdspm, HDSPM_WR_TCO, tc[0]);
3938
hdspm_write(hdspm, HDSPM_WR_TCO+4, tc[1]);
3939
hdspm_write(hdspm, HDSPM_WR_TCO+8, tc[2]);
3940
hdspm_write(hdspm, HDSPM_WR_TCO+12, tc[3]);
3944
#define HDSPM_TCO_SAMPLE_RATE(xname, xindex) \
3945
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3948
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
3949
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
3950
.info = snd_hdspm_info_tco_sample_rate, \
3951
.get = snd_hdspm_get_tco_sample_rate, \
3952
.put = snd_hdspm_put_tco_sample_rate \
3955
static int snd_hdspm_info_tco_sample_rate(struct snd_kcontrol *kcontrol,
3956
struct snd_ctl_elem_info *uinfo)
3958
static char *texts[] = { "44.1 kHz", "48 kHz" };
3959
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3961
uinfo->value.enumerated.items = 2;
3963
if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
3964
uinfo->value.enumerated.item =
3965
uinfo->value.enumerated.items - 1;
3967
strcpy(uinfo->value.enumerated.name,
3968
texts[uinfo->value.enumerated.item]);
3973
static int snd_hdspm_get_tco_sample_rate(struct snd_kcontrol *kcontrol,
3974
struct snd_ctl_elem_value *ucontrol)
3976
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
3978
ucontrol->value.enumerated.item[0] = hdspm->tco->samplerate;
3983
static int snd_hdspm_put_tco_sample_rate(struct snd_kcontrol *kcontrol,
3984
struct snd_ctl_elem_value *ucontrol)
3986
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
3988
if (hdspm->tco->samplerate != ucontrol->value.enumerated.item[0]) {
3989
hdspm->tco->samplerate = ucontrol->value.enumerated.item[0];
3991
hdspm_tco_write(hdspm);
4000
#define HDSPM_TCO_PULL(xname, xindex) \
4001
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4004
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
4005
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
4006
.info = snd_hdspm_info_tco_pull, \
4007
.get = snd_hdspm_get_tco_pull, \
4008
.put = snd_hdspm_put_tco_pull \
4011
static int snd_hdspm_info_tco_pull(struct snd_kcontrol *kcontrol,
4012
struct snd_ctl_elem_info *uinfo)
4014
static char *texts[] = { "0", "+ 0.1 %", "- 0.1 %", "+ 4 %", "- 4 %" };
4015
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4017
uinfo->value.enumerated.items = 5;
4019
if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
4020
uinfo->value.enumerated.item =
4021
uinfo->value.enumerated.items - 1;
4023
strcpy(uinfo->value.enumerated.name,
4024
texts[uinfo->value.enumerated.item]);
4029
static int snd_hdspm_get_tco_pull(struct snd_kcontrol *kcontrol,
4030
struct snd_ctl_elem_value *ucontrol)
4032
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4034
ucontrol->value.enumerated.item[0] = hdspm->tco->pull;
4039
static int snd_hdspm_put_tco_pull(struct snd_kcontrol *kcontrol,
4040
struct snd_ctl_elem_value *ucontrol)
4042
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4044
if (hdspm->tco->pull != ucontrol->value.enumerated.item[0]) {
4045
hdspm->tco->pull = ucontrol->value.enumerated.item[0];
4047
hdspm_tco_write(hdspm);
4055
#define HDSPM_TCO_WCK_CONVERSION(xname, xindex) \
4056
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4059
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
4060
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
4061
.info = snd_hdspm_info_tco_wck_conversion, \
4062
.get = snd_hdspm_get_tco_wck_conversion, \
4063
.put = snd_hdspm_put_tco_wck_conversion \
4066
static int snd_hdspm_info_tco_wck_conversion(struct snd_kcontrol *kcontrol,
4067
struct snd_ctl_elem_info *uinfo)
4069
static char *texts[] = { "1:1", "44.1 -> 48", "48 -> 44.1" };
4070
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4072
uinfo->value.enumerated.items = 3;
4074
if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
4075
uinfo->value.enumerated.item =
4076
uinfo->value.enumerated.items - 1;
4078
strcpy(uinfo->value.enumerated.name,
4079
texts[uinfo->value.enumerated.item]);
4084
static int snd_hdspm_get_tco_wck_conversion(struct snd_kcontrol *kcontrol,
4085
struct snd_ctl_elem_value *ucontrol)
4087
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4089
ucontrol->value.enumerated.item[0] = hdspm->tco->wordclock;
4094
static int snd_hdspm_put_tco_wck_conversion(struct snd_kcontrol *kcontrol,
4095
struct snd_ctl_elem_value *ucontrol)
4097
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4099
if (hdspm->tco->wordclock != ucontrol->value.enumerated.item[0]) {
4100
hdspm->tco->wordclock = ucontrol->value.enumerated.item[0];
4102
hdspm_tco_write(hdspm);
4111
#define HDSPM_TCO_FRAME_RATE(xname, xindex) \
4112
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4115
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
4116
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
4117
.info = snd_hdspm_info_tco_frame_rate, \
4118
.get = snd_hdspm_get_tco_frame_rate, \
4119
.put = snd_hdspm_put_tco_frame_rate \
4122
static int snd_hdspm_info_tco_frame_rate(struct snd_kcontrol *kcontrol,
4123
struct snd_ctl_elem_info *uinfo)
4125
static char *texts[] = { "24 fps", "25 fps", "29.97fps",
4126
"29.97 dfps", "30 fps", "30 dfps" };
4127
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4129
uinfo->value.enumerated.items = 6;
4131
if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
4132
uinfo->value.enumerated.item =
4133
uinfo->value.enumerated.items - 1;
4135
strcpy(uinfo->value.enumerated.name,
4136
texts[uinfo->value.enumerated.item]);
4141
static int snd_hdspm_get_tco_frame_rate(struct snd_kcontrol *kcontrol,
4142
struct snd_ctl_elem_value *ucontrol)
4144
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4146
ucontrol->value.enumerated.item[0] = hdspm->tco->framerate;
4151
static int snd_hdspm_put_tco_frame_rate(struct snd_kcontrol *kcontrol,
4152
struct snd_ctl_elem_value *ucontrol)
4154
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4156
if (hdspm->tco->framerate != ucontrol->value.enumerated.item[0]) {
4157
hdspm->tco->framerate = ucontrol->value.enumerated.item[0];
4159
hdspm_tco_write(hdspm);
4168
#define HDSPM_TCO_SYNC_SOURCE(xname, xindex) \
4169
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4172
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
4173
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
4174
.info = snd_hdspm_info_tco_sync_source, \
4175
.get = snd_hdspm_get_tco_sync_source, \
4176
.put = snd_hdspm_put_tco_sync_source \
4179
static int snd_hdspm_info_tco_sync_source(struct snd_kcontrol *kcontrol,
4180
struct snd_ctl_elem_info *uinfo)
4182
static char *texts[] = { "LTC", "Video", "WCK" };
4183
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4185
uinfo->value.enumerated.items = 3;
4187
if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
4188
uinfo->value.enumerated.item =
4189
uinfo->value.enumerated.items - 1;
4191
strcpy(uinfo->value.enumerated.name,
4192
texts[uinfo->value.enumerated.item]);
4197
static int snd_hdspm_get_tco_sync_source(struct snd_kcontrol *kcontrol,
4198
struct snd_ctl_elem_value *ucontrol)
4200
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4202
ucontrol->value.enumerated.item[0] = hdspm->tco->input;
4207
static int snd_hdspm_put_tco_sync_source(struct snd_kcontrol *kcontrol,
4208
struct snd_ctl_elem_value *ucontrol)
4210
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4212
if (hdspm->tco->input != ucontrol->value.enumerated.item[0]) {
4213
hdspm->tco->input = ucontrol->value.enumerated.item[0];
4215
hdspm_tco_write(hdspm);
4224
#define HDSPM_TCO_WORD_TERM(xname, xindex) \
4225
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4228
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
4229
SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
4230
.info = snd_hdspm_info_tco_word_term, \
4231
.get = snd_hdspm_get_tco_word_term, \
4232
.put = snd_hdspm_put_tco_word_term \
4235
static int snd_hdspm_info_tco_word_term(struct snd_kcontrol *kcontrol,
4236
struct snd_ctl_elem_info *uinfo)
4238
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
4240
uinfo->value.integer.min = 0;
4241
uinfo->value.integer.max = 1;
4247
static int snd_hdspm_get_tco_word_term(struct snd_kcontrol *kcontrol,
4248
struct snd_ctl_elem_value *ucontrol)
4250
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4252
ucontrol->value.enumerated.item[0] = hdspm->tco->term;
4258
static int snd_hdspm_put_tco_word_term(struct snd_kcontrol *kcontrol,
4259
struct snd_ctl_elem_value *ucontrol)
4261
struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
4263
if (hdspm->tco->term != ucontrol->value.enumerated.item[0]) {
4264
hdspm->tco->term = ucontrol->value.enumerated.item[0];
4266
hdspm_tco_write(hdspm);
2801
4277
static struct snd_kcontrol_new snd_hdspm_controls_madi[] = {
2803
4278
HDSPM_MIXER("Mixer", 0),
2804
/* 'Sample Clock Source' complies with the alsa control naming scheme */
2805
HDSPM_CLOCK_SOURCE("Sample Clock Source", 0),
4279
HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
2807
4280
HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
2808
4281
HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0),
2809
4282
HDSPM_AUTOSYNC_REF("AutoSync Reference", 0),
2810
4283
HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0),
2811
/* 'External Rate' complies with the alsa control naming scheme */
2812
HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0),
2813
HDSPM_WC_SYNC_CHECK("Word Clock Lock Status", 0),
2814
HDSPM_MADI_SYNC_CHECK("MADI Sync Lock Status", 0),
4284
HDSPM_SYNC_CHECK("WC SyncCheck", 0),
4285
HDSPM_SYNC_CHECK("MADI SyncCheck", 1),
4286
HDSPM_SYNC_CHECK("TCO SyncCHeck", 2),
4287
HDSPM_SYNC_CHECK("SYNC IN SyncCheck", 3),
2815
4288
HDSPM_LINE_OUT("Line Out", 0),
2816
4289
HDSPM_TX_64("TX 64 channels mode", 0),
2817
4290
HDSPM_C_TMS("Clear Track Marker", 0),
2818
4291
HDSPM_SAFE_MODE("Safe Mode", 0),
2819
HDSPM_INPUT_SELECT("Input Select", 0),
4292
HDSPM_INPUT_SELECT("Input Select", 0)
4296
static struct snd_kcontrol_new snd_hdspm_controls_madiface[] = {
4297
HDSPM_MIXER("Mixer", 0),
4298
HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
4299
HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
4300
HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0),
4301
HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0),
4302
HDSPM_SYNC_CHECK("MADI SyncCheck", 0),
4303
HDSPM_TX_64("TX 64 channels mode", 0),
4304
HDSPM_C_TMS("Clear Track Marker", 0),
4305
HDSPM_SAFE_MODE("Safe Mode", 0)
4308
static struct snd_kcontrol_new snd_hdspm_controls_aio[] = {
4309
HDSPM_MIXER("Mixer", 0),
4310
HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
4311
HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
4312
HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0),
4313
HDSPM_AUTOSYNC_REF("AutoSync Reference", 0),
4314
HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0),
4315
HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0),
4316
HDSPM_SYNC_CHECK("WC SyncCheck", 0),
4317
HDSPM_SYNC_CHECK("AES SyncCheck", 1),
4318
HDSPM_SYNC_CHECK("SPDIF SyncCheck", 2),
4319
HDSPM_SYNC_CHECK("ADAT SyncCheck", 3),
4320
HDSPM_SYNC_CHECK("TCO SyncCheck", 4),
4321
HDSPM_SYNC_CHECK("SYNC IN SyncCheck", 5),
4322
HDSPM_AUTOSYNC_SAMPLE_RATE("WC Frequency", 0),
4323
HDSPM_AUTOSYNC_SAMPLE_RATE("AES Frequency", 1),
4324
HDSPM_AUTOSYNC_SAMPLE_RATE("SPDIF Frequency", 2),
4325
HDSPM_AUTOSYNC_SAMPLE_RATE("ADAT Frequency", 3),
4326
HDSPM_AUTOSYNC_SAMPLE_RATE("TCO Frequency", 4),
4327
HDSPM_AUTOSYNC_SAMPLE_RATE("SYNC IN Frequency", 5)
4330
HDSPM_INPUT_SELECT("Input Select", 0),
4331
HDSPM_SPDIF_OPTICAL("SPDIF Out Optical", 0),
4332
HDSPM_PROFESSIONAL("SPDIF Out Professional", 0);
4333
HDSPM_SPDIF_IN("SPDIF In", 0);
4334
HDSPM_BREAKOUT_CABLE("Breakout Cable", 0);
4335
HDSPM_INPUT_LEVEL("Input Level", 0);
4336
HDSPM_OUTPUT_LEVEL("Output Level", 0);
4337
HDSPM_PHONES("Phones", 0);
4341
static struct snd_kcontrol_new snd_hdspm_controls_raydat[] = {
4342
HDSPM_MIXER("Mixer", 0),
4343
HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
4344
HDSPM_SYSTEM_CLOCK_MODE("Clock Mode", 0),
4345
HDSPM_PREF_SYNC_REF("Pref Sync Ref", 0),
4346
HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0),
4347
HDSPM_SYNC_CHECK("WC SyncCheck", 0),
4348
HDSPM_SYNC_CHECK("AES SyncCheck", 1),
4349
HDSPM_SYNC_CHECK("SPDIF SyncCheck", 2),
4350
HDSPM_SYNC_CHECK("ADAT1 SyncCheck", 3),
4351
HDSPM_SYNC_CHECK("ADAT2 SyncCheck", 4),
4352
HDSPM_SYNC_CHECK("ADAT3 SyncCheck", 5),
4353
HDSPM_SYNC_CHECK("ADAT4 SyncCheck", 6),
4354
HDSPM_SYNC_CHECK("TCO SyncCheck", 7),
4355
HDSPM_SYNC_CHECK("SYNC IN SyncCheck", 8),
4356
HDSPM_AUTOSYNC_SAMPLE_RATE("WC Frequency", 0),
4357
HDSPM_AUTOSYNC_SAMPLE_RATE("AES Frequency", 1),
4358
HDSPM_AUTOSYNC_SAMPLE_RATE("SPDIF Frequency", 2),
4359
HDSPM_AUTOSYNC_SAMPLE_RATE("ADAT1 Frequency", 3),
4360
HDSPM_AUTOSYNC_SAMPLE_RATE("ADAT2 Frequency", 4),
4361
HDSPM_AUTOSYNC_SAMPLE_RATE("ADAT3 Frequency", 5),
4362
HDSPM_AUTOSYNC_SAMPLE_RATE("ADAT4 Frequency", 6),
4363
HDSPM_AUTOSYNC_SAMPLE_RATE("TCO Frequency", 7),
4364
HDSPM_AUTOSYNC_SAMPLE_RATE("SYNC IN Frequency", 8)
2822
4367
static struct snd_kcontrol_new snd_hdspm_controls_aes32[] = {
2824
4368
HDSPM_MIXER("Mixer", 0),
2825
/* 'Sample Clock Source' complies with the alsa control naming scheme */
2826
HDSPM_CLOCK_SOURCE("Sample Clock Source", 0),
4369
HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
2828
4370
HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
2829
4371
HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0),
2830
4372
HDSPM_AUTOSYNC_REF("AutoSync Reference", 0),
2831
4373
HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0),
2832
/* 'External Rate' complies with the alsa control naming scheme */
2833
4374
HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0),
2834
HDSPM_WC_SYNC_CHECK("Word Clock Lock Status", 0),
2835
/* HDSPM_AES_SYNC_CHECK("AES Lock Status", 0),*/ /* created in snd_hdspm_create_controls() */
4375
HDSPM_SYNC_CHECK("WC Sync Check", 0),
4376
HDSPM_SYNC_CHECK("AES1 Sync Check", 1),
4377
HDSPM_SYNC_CHECK("AES2 Sync Check", 2),
4378
HDSPM_SYNC_CHECK("AES3 Sync Check", 3),
4379
HDSPM_SYNC_CHECK("AES4 Sync Check", 4),
4380
HDSPM_SYNC_CHECK("AES5 Sync Check", 5),
4381
HDSPM_SYNC_CHECK("AES6 Sync Check", 6),
4382
HDSPM_SYNC_CHECK("AES7 Sync Check", 7),
4383
HDSPM_SYNC_CHECK("AES8 Sync Check", 8),
4384
HDSPM_SYNC_CHECK("TCO Sync Check", 9),
4385
HDSPM_SYNC_CHECK("SYNC IN Sync Check", 10),
4386
HDSPM_AUTOSYNC_SAMPLE_RATE("WC Frequency", 0),
4387
HDSPM_AUTOSYNC_SAMPLE_RATE("AES1 Frequency", 1),
4388
HDSPM_AUTOSYNC_SAMPLE_RATE("AES2 Frequency", 2),
4389
HDSPM_AUTOSYNC_SAMPLE_RATE("AES3 Frequency", 3),
4390
HDSPM_AUTOSYNC_SAMPLE_RATE("AES4 Frequency", 4),
4391
HDSPM_AUTOSYNC_SAMPLE_RATE("AES5 Frequency", 5),
4392
HDSPM_AUTOSYNC_SAMPLE_RATE("AES6 Frequency", 6),
4393
HDSPM_AUTOSYNC_SAMPLE_RATE("AES7 Frequency", 7),
4394
HDSPM_AUTOSYNC_SAMPLE_RATE("AES8 Frequency", 8),
4395
HDSPM_AUTOSYNC_SAMPLE_RATE("TCO Frequency", 9),
4396
HDSPM_AUTOSYNC_SAMPLE_RATE("SYNC IN Frequency", 10),
2836
4397
HDSPM_LINE_OUT("Line Out", 0),
2837
4398
HDSPM_EMPHASIS("Emphasis", 0),
2838
4399
HDSPM_DOLBY("Non Audio", 0),
2942
4527
struct snd_info_buffer *buffer)
2944
4529
struct hdspm *hdspm = entry->private_data;
2945
unsigned int status;
2946
unsigned int status2;
4530
unsigned int status, status2, control, freq;
2947
4532
char *pref_sync_ref;
2948
4533
char *autosync_ref;
2949
4534
char *system_clock_mode;
4539
int a, ltc, frames, seconds, minutes, hours;
4540
unsigned int period;
2955
4544
status = hdspm_read(hdspm, HDSPM_statusRegister);
2956
4545
status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
4546
control = hdspm->control_register;
4547
freq = hdspm_read(hdspm, HDSPM_timecodeRegister);
2958
4549
snd_iprintf(buffer, "%s (Card #%d) Rev.%x Status2first3bits: %x\n",
2959
hdspm->card_name, hdspm->card->number + 1,
2960
hdspm->firmware_rev,
2961
(status2 & HDSPM_version0) |
2962
(status2 & HDSPM_version1) | (status2 &
4550
hdspm->card_name, hdspm->card->number + 1,
4551
hdspm->firmware_rev,
4552
(status2 & HDSPM_version0) |
4553
(status2 & HDSPM_version1) | (status2 &
4556
snd_iprintf(buffer, "HW Serial: 0x%06x%06x\n",
4557
(hdspm_read(hdspm, HDSPM_midiStatusIn1)>>8) & 0xFFFFFF,
4558
(hdspm_read(hdspm, HDSPM_midiStatusIn0)>>8) & 0xFFFFFF);
2965
4560
snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
2966
hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase);
4561
hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase);
2968
4563
snd_iprintf(buffer, "--- System ---\n");
2970
4565
snd_iprintf(buffer,
2971
"IRQ Pending: Audio=%d, MIDI0=%d, MIDI1=%d, IRQcount=%d\n",
2972
status & HDSPM_audioIRQPending,
2973
(status & HDSPM_midi0IRQPending) ? 1 : 0,
2974
(status & HDSPM_midi1IRQPending) ? 1 : 0,
2977
"HW pointer: id = %d, rawptr = %d (%d->%d) "
2978
"estimated= %ld (bytes)\n",
2979
((status & HDSPM_BufferID) ? 1 : 0),
2980
(status & HDSPM_BufferPositionMask),
2981
(status & HDSPM_BufferPositionMask) %
2982
(2 * (int)hdspm->period_bytes),
2983
((status & HDSPM_BufferPositionMask) - 64) %
2984
(2 * (int)hdspm->period_bytes),
2985
(long) hdspm_hw_pointer(hdspm) * 4);
2988
"MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n",
2989
hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF,
2990
hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF,
2991
hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF,
2992
hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF);
2994
"Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, "
2996
hdspm->control_register, hdspm->control2_register,
4566
"IRQ Pending: Audio=%d, MIDI0=%d, MIDI1=%d, IRQcount=%d\n",
4567
status & HDSPM_audioIRQPending,
4568
(status & HDSPM_midi0IRQPending) ? 1 : 0,
4569
(status & HDSPM_midi1IRQPending) ? 1 : 0,
4572
"HW pointer: id = %d, rawptr = %d (%d->%d) "
4573
"estimated= %ld (bytes)\n",
4574
((status & HDSPM_BufferID) ? 1 : 0),
4575
(status & HDSPM_BufferPositionMask),
4576
(status & HDSPM_BufferPositionMask) %
4577
(2 * (int)hdspm->period_bytes),
4578
((status & HDSPM_BufferPositionMask) - 64) %
4579
(2 * (int)hdspm->period_bytes),
4580
(long) hdspm_hw_pointer(hdspm) * 4);
4583
"MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n",
4584
hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF,
4585
hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF,
4586
hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF,
4587
hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF);
4589
"MIDIoverMADI FIFO: In=0x%x, Out=0x%x \n",
4590
hdspm_read(hdspm, HDSPM_midiStatusIn2) & 0xFF,
4591
hdspm_read(hdspm, HDSPM_midiStatusOut2) & 0xFF);
4593
"Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, "
4595
hdspm->control_register, hdspm->control2_register,
4597
if (status & HDSPM_tco_detect) {
4598
snd_iprintf(buffer, "TCO module detected.\n");
4599
a = hdspm_read(hdspm, HDSPM_RD_TCO+4);
4600
if (a & HDSPM_TCO1_LTC_Input_valid) {
4601
snd_iprintf(buffer, " LTC valid, ");
4602
switch (a & (HDSPM_TCO1_LTC_Format_LSB |
4603
HDSPM_TCO1_LTC_Format_MSB)) {
4605
snd_iprintf(buffer, "24 fps, ");
4607
case HDSPM_TCO1_LTC_Format_LSB:
4608
snd_iprintf(buffer, "25 fps, ");
4610
case HDSPM_TCO1_LTC_Format_MSB:
4611
snd_iprintf(buffer, "29.97 fps, ");
4614
snd_iprintf(buffer, "30 fps, ");
4617
if (a & HDSPM_TCO1_set_drop_frame_flag) {
4618
snd_iprintf(buffer, "drop frame\n");
4620
snd_iprintf(buffer, "full frame\n");
4623
snd_iprintf(buffer, " no LTC\n");
4625
if (a & HDSPM_TCO1_Video_Input_Format_NTSC) {
4626
snd_iprintf(buffer, " Video: NTSC\n");
4627
} else if (a & HDSPM_TCO1_Video_Input_Format_PAL) {
4628
snd_iprintf(buffer, " Video: PAL\n");
4630
snd_iprintf(buffer, " No video\n");
4632
if (a & HDSPM_TCO1_TCO_lock) {
4633
snd_iprintf(buffer, " Sync: lock\n");
4635
snd_iprintf(buffer, " Sync: no lock\n");
4638
switch (hdspm->io_type) {
4641
freq_const = 110069313433624ULL;
4645
freq_const = 104857600000000ULL;
4648
break; /* no TCO possible */
4651
period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ);
4652
snd_iprintf(buffer, " period: %u\n", period);
4655
/* rate = freq_const/period; */
4656
rate = div_u64(freq_const, period);
4658
if (control & HDSPM_QuadSpeed) {
4660
} else if (control & HDSPM_DoubleSpeed) {
4664
snd_iprintf(buffer, " Frequency: %u Hz\n",
4665
(unsigned int) rate);
4667
ltc = hdspm_read(hdspm, HDSPM_RD_TCO);
4670
frames += (ltc & 0x3) * 10;
4672
seconds = ltc & 0xF;
4674
seconds += (ltc & 0x7) * 10;
4676
minutes = ltc & 0xF;
4678
minutes += (ltc & 0x7) * 10;
4682
hours += (ltc & 0x3) * 10;
4684
" LTC In: %02d:%02d:%02d:%02d\n",
4685
hours, minutes, seconds, frames);
4688
snd_iprintf(buffer, "No TCO module detected.\n");
2999
4691
snd_iprintf(buffer, "--- Settings ---\n");
3001
4693
x = 1 << (6 + hdspm_decode_latency(hdspm->control_register &
3002
HDSPM_LatencyMask));
4694
HDSPM_LatencyMask));
3004
4696
snd_iprintf(buffer,
3005
"Size (Latency): %d samples (2 periods of %lu bytes)\n",
3006
x, (unsigned long) hdspm->period_bytes);
4697
"Size (Latency): %d samples (2 periods of %lu bytes)\n",
4698
x, (unsigned long) hdspm->period_bytes);
3008
snd_iprintf(buffer, "Line out: %s, Precise Pointer: %s\n",
3009
(hdspm->control_register & HDSPM_LineOut) ? "on " : "off",
3010
(hdspm->precise_ptr) ? "on" : "off");
4700
snd_iprintf(buffer, "Line out: %s\n",
4701
(hdspm->control_register & HDSPM_LineOut) ? "on " : "off");
3012
4703
switch (hdspm->control_register & HDSPM_InputMask) {
3013
4704
case HDSPM_InputOptical:
3274
4897
snd_iprintf(buffer, "--- Status:\n");
3276
4899
snd_iprintf(buffer, "Word: %s Frequency: %d\n",
3277
(status & HDSPM_AES32_wcLock)? "Sync " : "No Lock",
4900
(status & HDSPM_AES32_wcLock) ? "Sync " : "No Lock",
3278
4901
HDSPM_bit2freq((status >> HDSPM_AES32_wcFreq_bit) & 0xF));
3280
4903
for (x = 0; x < 8; x++) {
3281
4904
snd_iprintf(buffer, "AES%d: %s Frequency: %d\n",
3283
4906
(status2 & (HDSPM_LockAES >> x)) ?
4907
"Sync " : "No Lock",
3285
4908
HDSPM_bit2freq((timecode >> (4*x)) & 0xF));
3288
4911
switch (hdspm_autosync_ref(hdspm)) {
3289
case HDSPM_AES32_AUTOSYNC_FROM_NONE: autosync_ref="None"; break;
3290
case HDSPM_AES32_AUTOSYNC_FROM_WORD: autosync_ref="Word Clock"; break;
3291
case HDSPM_AES32_AUTOSYNC_FROM_AES1: autosync_ref="AES1"; break;
3292
case HDSPM_AES32_AUTOSYNC_FROM_AES2: autosync_ref="AES2"; break;
3293
case HDSPM_AES32_AUTOSYNC_FROM_AES3: autosync_ref="AES3"; break;
3294
case HDSPM_AES32_AUTOSYNC_FROM_AES4: autosync_ref="AES4"; break;
3295
case HDSPM_AES32_AUTOSYNC_FROM_AES5: autosync_ref="AES5"; break;
3296
case HDSPM_AES32_AUTOSYNC_FROM_AES6: autosync_ref="AES6"; break;
3297
case HDSPM_AES32_AUTOSYNC_FROM_AES7: autosync_ref="AES7"; break;
3298
case HDSPM_AES32_AUTOSYNC_FROM_AES8: autosync_ref="AES8"; break;
3299
default: autosync_ref = "---"; break;
4912
case HDSPM_AES32_AUTOSYNC_FROM_NONE:
4913
autosync_ref = "None"; break;
4914
case HDSPM_AES32_AUTOSYNC_FROM_WORD:
4915
autosync_ref = "Word Clock"; break;
4916
case HDSPM_AES32_AUTOSYNC_FROM_AES1:
4917
autosync_ref = "AES1"; break;
4918
case HDSPM_AES32_AUTOSYNC_FROM_AES2:
4919
autosync_ref = "AES2"; break;
4920
case HDSPM_AES32_AUTOSYNC_FROM_AES3:
4921
autosync_ref = "AES3"; break;
4922
case HDSPM_AES32_AUTOSYNC_FROM_AES4:
4923
autosync_ref = "AES4"; break;
4924
case HDSPM_AES32_AUTOSYNC_FROM_AES5:
4925
autosync_ref = "AES5"; break;
4926
case HDSPM_AES32_AUTOSYNC_FROM_AES6:
4927
autosync_ref = "AES6"; break;
4928
case HDSPM_AES32_AUTOSYNC_FROM_AES7:
4929
autosync_ref = "AES7"; break;
4930
case HDSPM_AES32_AUTOSYNC_FROM_AES8:
4931
autosync_ref = "AES8"; break;
4933
autosync_ref = "---"; break;
3301
4935
snd_iprintf(buffer, "AutoSync ref = %s\n", autosync_ref);
3303
4937
snd_iprintf(buffer, "\n");
4941
snd_hdspm_proc_read_raydat(struct snd_info_entry *entry,
4942
struct snd_info_buffer *buffer)
4944
struct hdspm *hdspm = entry->private_data;
4945
unsigned int status1, status2, status3, control, i;
4946
unsigned int lock, sync;
4948
status1 = hdspm_read(hdspm, HDSPM_RD_STATUS_1); /* s1 */
4949
status2 = hdspm_read(hdspm, HDSPM_RD_STATUS_2); /* freq */
4950
status3 = hdspm_read(hdspm, HDSPM_RD_STATUS_3); /* s2 */
4952
control = hdspm->control_register;
4954
snd_iprintf(buffer, "STATUS1: 0x%08x\n", status1);
4955
snd_iprintf(buffer, "STATUS2: 0x%08x\n", status2);
4956
snd_iprintf(buffer, "STATUS3: 0x%08x\n", status3);
4959
snd_iprintf(buffer, "\n*** CLOCK MODE\n\n");
4961
snd_iprintf(buffer, "Clock mode : %s\n",
4962
(hdspm_system_clock_mode(hdspm) == 0) ? "master" : "slave");
4963
snd_iprintf(buffer, "System frequency: %d Hz\n",
4964
hdspm_get_system_sample_rate(hdspm));
4966
snd_iprintf(buffer, "\n*** INPUT STATUS\n\n");
4971
for (i = 0; i < 8; i++) {
4972
snd_iprintf(buffer, "s1_input %d: Lock %d, Sync %d, Freq %s\n",
4974
(status1 & lock) ? 1 : 0,
4975
(status1 & sync) ? 1 : 0,
4976
texts_freq[(status2 >> (i * 4)) & 0xF]);
4982
snd_iprintf(buffer, "WC input: Lock %d, Sync %d, Freq %s\n",
4983
(status1 & 0x1000000) ? 1 : 0,
4984
(status1 & 0x2000000) ? 1 : 0,
4985
texts_freq[(status1 >> 16) & 0xF]);
4987
snd_iprintf(buffer, "TCO input: Lock %d, Sync %d, Freq %s\n",
4988
(status1 & 0x4000000) ? 1 : 0,
4989
(status1 & 0x8000000) ? 1 : 0,
4990
texts_freq[(status1 >> 20) & 0xF]);
4992
snd_iprintf(buffer, "SYNC IN: Lock %d, Sync %d, Freq %s\n",
4993
(status3 & 0x400) ? 1 : 0,
4994
(status3 & 0x800) ? 1 : 0,
4995
texts_freq[(status2 >> 12) & 0xF]);
3306
4999
#ifdef CONFIG_SND_DEBUG
3308
snd_hdspm_proc_read_debug(struct snd_info_entry * entry,
5001
snd_hdspm_proc_read_debug(struct snd_info_entry *entry,
3309
5002
struct snd_info_buffer *buffer)
3311
5004
struct hdspm *hdspm = entry->private_data;
3891
5618
.buffer_bytes_max =
3892
5619
HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS,
3893
5620
.period_bytes_min = (64 * 4),
3894
.period_bytes_max = (8192 * 4) * HDSPM_MAX_CHANNELS,
5621
.period_bytes_max = (4096 * 4) * HDSPM_MAX_CHANNELS,
3895
5622
.periods_min = 2,
3900
static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes = {
3901
.count = ARRAY_SIZE(period_sizes),
3902
.list = period_sizes,
3907
static int snd_hdspm_hw_rule_channels_rate(struct snd_pcm_hw_params *params,
3908
struct snd_pcm_hw_rule * rule)
3910
struct hdspm *hdspm = rule->private;
3911
struct snd_interval *c =
3912
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
3913
struct snd_interval *r =
3914
hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3916
if (r->min > 48000 && r->max <= 96000) {
3917
struct snd_interval t = {
3918
.min = hdspm->ds_channels,
3919
.max = hdspm->ds_channels,
3922
return snd_interval_refine(c, &t);
3923
} else if (r->max < 64000) {
3924
struct snd_interval t = {
3925
.min = hdspm->ss_channels,
3926
.max = hdspm->ss_channels,
3929
return snd_interval_refine(c, &t);
3934
static int snd_hdspm_hw_rule_rate_channels(struct snd_pcm_hw_params *params,
3935
struct snd_pcm_hw_rule * rule)
3937
struct hdspm *hdspm = rule->private;
3938
struct snd_interval *c =
3939
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
3940
struct snd_interval *r =
3941
hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3943
if (c->min >= hdspm->ss_channels) {
3944
struct snd_interval t = {
3949
return snd_interval_refine(r, &t);
3950
} else if (c->max <= hdspm->ds_channels) {
3951
struct snd_interval t = {
3957
return snd_interval_refine(r, &t);
3962
static int snd_hdspm_hw_rule_channels(struct snd_pcm_hw_params *params,
3963
struct snd_pcm_hw_rule *rule)
3965
unsigned int list[3];
3966
struct hdspm *hdspm = rule->private;
3967
struct snd_interval *c = hw_param_interval(params,
3968
SNDRV_PCM_HW_PARAM_CHANNELS);
3969
if (hdspm->is_aes32) {
3970
list[0] = hdspm->qs_channels;
3971
list[1] = hdspm->ds_channels;
3972
list[2] = hdspm->ss_channels;
3973
return snd_interval_list(c, 3, list, 0);
5627
static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes_old = {
5628
.count = ARRAY_SIZE(period_sizes_old),
5629
.list = period_sizes_old,
5633
static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes_new = {
5634
.count = ARRAY_SIZE(period_sizes_new),
5635
.list = period_sizes_new,
5639
static struct snd_pcm_hw_constraint_list hw_constraints_raydat_io_buffer = {
5640
.count = ARRAY_SIZE(raydat_aio_buffer_sizes),
5641
.list = raydat_aio_buffer_sizes,
5645
static int snd_hdspm_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params,
5646
struct snd_pcm_hw_rule *rule)
5648
struct hdspm *hdspm = rule->private;
5649
struct snd_interval *c =
5650
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
5651
struct snd_interval *r =
5652
hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
5654
if (r->min > 96000 && r->max <= 192000) {
5655
struct snd_interval t = {
5656
.min = hdspm->qs_in_channels,
5657
.max = hdspm->qs_in_channels,
5660
return snd_interval_refine(c, &t);
5661
} else if (r->min > 48000 && r->max <= 96000) {
5662
struct snd_interval t = {
5663
.min = hdspm->ds_in_channels,
5664
.max = hdspm->ds_in_channels,
5667
return snd_interval_refine(c, &t);
5668
} else if (r->max < 64000) {
5669
struct snd_interval t = {
5670
.min = hdspm->ss_in_channels,
5671
.max = hdspm->ss_in_channels,
5674
return snd_interval_refine(c, &t);
5680
static int snd_hdspm_hw_rule_out_channels_rate(struct snd_pcm_hw_params *params,
5681
struct snd_pcm_hw_rule * rule)
5683
struct hdspm *hdspm = rule->private;
5684
struct snd_interval *c =
5685
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
5686
struct snd_interval *r =
5687
hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
5689
if (r->min > 96000 && r->max <= 192000) {
5690
struct snd_interval t = {
5691
.min = hdspm->qs_out_channels,
5692
.max = hdspm->qs_out_channels,
5695
return snd_interval_refine(c, &t);
5696
} else if (r->min > 48000 && r->max <= 96000) {
5697
struct snd_interval t = {
5698
.min = hdspm->ds_out_channels,
5699
.max = hdspm->ds_out_channels,
5702
return snd_interval_refine(c, &t);
5703
} else if (r->max < 64000) {
5704
struct snd_interval t = {
5705
.min = hdspm->ss_out_channels,
5706
.max = hdspm->ss_out_channels,
5709
return snd_interval_refine(c, &t);
3975
list[0] = hdspm->ds_channels;
3976
list[1] = hdspm->ss_channels;
3977
return snd_interval_list(c, 2, list, 0);
5715
static int snd_hdspm_hw_rule_rate_in_channels(struct snd_pcm_hw_params *params,
5716
struct snd_pcm_hw_rule * rule)
5718
struct hdspm *hdspm = rule->private;
5719
struct snd_interval *c =
5720
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
5721
struct snd_interval *r =
5722
hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
5724
if (c->min >= hdspm->ss_in_channels) {
5725
struct snd_interval t = {
5730
return snd_interval_refine(r, &t);
5731
} else if (c->max <= hdspm->qs_in_channels) {
5732
struct snd_interval t = {
5737
return snd_interval_refine(r, &t);
5738
} else if (c->max <= hdspm->ds_in_channels) {
5739
struct snd_interval t = {
5744
return snd_interval_refine(r, &t);
5749
static int snd_hdspm_hw_rule_rate_out_channels(struct snd_pcm_hw_params *params,
5750
struct snd_pcm_hw_rule *rule)
5752
struct hdspm *hdspm = rule->private;
5753
struct snd_interval *c =
5754
hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
5755
struct snd_interval *r =
5756
hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
5758
if (c->min >= hdspm->ss_out_channels) {
5759
struct snd_interval t = {
5764
return snd_interval_refine(r, &t);
5765
} else if (c->max <= hdspm->qs_out_channels) {
5766
struct snd_interval t = {
5771
return snd_interval_refine(r, &t);
5772
} else if (c->max <= hdspm->ds_out_channels) {
5773
struct snd_interval t = {
5778
return snd_interval_refine(r, &t);
5784
static int snd_hdspm_hw_rule_in_channels(struct snd_pcm_hw_params *params,
5785
struct snd_pcm_hw_rule *rule)
5787
unsigned int list[3];
5788
struct hdspm *hdspm = rule->private;
5789
struct snd_interval *c = hw_param_interval(params,
5790
SNDRV_PCM_HW_PARAM_CHANNELS);
5792
list[0] = hdspm->qs_in_channels;
5793
list[1] = hdspm->ds_in_channels;
5794
list[2] = hdspm->ss_in_channels;
5795
return snd_interval_list(c, 3, list, 0);
5798
static int snd_hdspm_hw_rule_out_channels(struct snd_pcm_hw_params *params,
5799
struct snd_pcm_hw_rule *rule)
5801
unsigned int list[3];
5802
struct hdspm *hdspm = rule->private;
5803
struct snd_interval *c = hw_param_interval(params,
5804
SNDRV_PCM_HW_PARAM_CHANNELS);
5806
list[0] = hdspm->qs_out_channels;
5807
list[1] = hdspm->ds_out_channels;
5808
list[2] = hdspm->ss_out_channels;
5809
return snd_interval_list(c, 3, list, 0);
4416
6449
snd_printdd("use IRQ %d\n", pci->irq);
4418
6451
hdspm->irq = pci->irq;
4419
hdspm->precise_ptr = precise_ptr;
4421
hdspm->monitor_outs = enable_monitor;
4423
6453
snd_printdd("kmalloc Mixer memory of %zd Bytes\n",
4424
sizeof(struct hdspm_mixer));
6454
sizeof(struct hdspm_mixer));
4425
6455
hdspm->mixer = kzalloc(sizeof(struct hdspm_mixer), GFP_KERNEL);
4426
6456
if (!hdspm->mixer) {
4427
6457
snd_printk(KERN_ERR "HDSPM: "
4428
"unable to kmalloc Mixer memory of %d Bytes\n",
4429
(int)sizeof(struct hdspm_mixer));
6458
"unable to kmalloc Mixer memory of %d Bytes\n",
6459
(int)sizeof(struct hdspm_mixer));
4433
hdspm->ss_channels = MADI_SS_CHANNELS;
4434
hdspm->ds_channels = MADI_DS_CHANNELS;
4435
hdspm->qs_channels = MADI_QS_CHANNELS;
6463
hdspm->port_names_in = NULL;
6464
hdspm->port_names_out = NULL;
6466
switch (hdspm->io_type) {
6468
hdspm->ss_in_channels = hdspm->ss_out_channels = AES32_CHANNELS;
6469
hdspm->ds_in_channels = hdspm->ds_out_channels = AES32_CHANNELS;
6470
hdspm->qs_in_channels = hdspm->qs_out_channels = AES32_CHANNELS;
6472
hdspm->channel_map_in_ss = hdspm->channel_map_out_ss =
6474
hdspm->channel_map_in_ds = hdspm->channel_map_out_ds =
6476
hdspm->channel_map_in_qs = hdspm->channel_map_out_qs =
6478
hdspm->port_names_in_ss = hdspm->port_names_out_ss =
6480
hdspm->port_names_in_ds = hdspm->port_names_out_ds =
6482
hdspm->port_names_in_qs = hdspm->port_names_out_qs =
6485
hdspm->max_channels_out = hdspm->max_channels_in =
6487
hdspm->port_names_in = hdspm->port_names_out =
6489
hdspm->channel_map_in = hdspm->channel_map_out =
6496
hdspm->ss_in_channels = hdspm->ss_out_channels =
6498
hdspm->ds_in_channels = hdspm->ds_out_channels =
6500
hdspm->qs_in_channels = hdspm->qs_out_channels =
6503
hdspm->channel_map_in_ss = hdspm->channel_map_out_ss =
6504
channel_map_unity_ss;
6505
hdspm->channel_map_in_ds = hdspm->channel_map_out_ds =
6506
channel_map_unity_ss;
6507
hdspm->channel_map_in_qs = hdspm->channel_map_out_qs =
6508
channel_map_unity_ss;
6510
hdspm->port_names_in_ss = hdspm->port_names_out_ss =
6512
hdspm->port_names_in_ds = hdspm->port_names_out_ds =
6514
hdspm->port_names_in_qs = hdspm->port_names_out_qs =
6519
if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBI_D)) {
6520
snd_printk(KERN_INFO "HDSPM: AEB input board found, but not supported\n");
6523
hdspm->ss_in_channels = AIO_IN_SS_CHANNELS;
6524
hdspm->ds_in_channels = AIO_IN_DS_CHANNELS;
6525
hdspm->qs_in_channels = AIO_IN_QS_CHANNELS;
6526
hdspm->ss_out_channels = AIO_OUT_SS_CHANNELS;
6527
hdspm->ds_out_channels = AIO_OUT_DS_CHANNELS;
6528
hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS;
6530
hdspm->channel_map_out_ss = channel_map_aio_out_ss;
6531
hdspm->channel_map_out_ds = channel_map_aio_out_ds;
6532
hdspm->channel_map_out_qs = channel_map_aio_out_qs;
6534
hdspm->channel_map_in_ss = channel_map_aio_in_ss;
6535
hdspm->channel_map_in_ds = channel_map_aio_in_ds;
6536
hdspm->channel_map_in_qs = channel_map_aio_in_qs;
6538
hdspm->port_names_in_ss = texts_ports_aio_in_ss;
6539
hdspm->port_names_out_ss = texts_ports_aio_out_ss;
6540
hdspm->port_names_in_ds = texts_ports_aio_in_ds;
6541
hdspm->port_names_out_ds = texts_ports_aio_out_ds;
6542
hdspm->port_names_in_qs = texts_ports_aio_in_qs;
6543
hdspm->port_names_out_qs = texts_ports_aio_out_qs;
6548
hdspm->ss_in_channels = hdspm->ss_out_channels =
6550
hdspm->ds_in_channels = hdspm->ds_out_channels =
6552
hdspm->qs_in_channels = hdspm->qs_out_channels =
6555
hdspm->max_channels_in = RAYDAT_SS_CHANNELS;
6556
hdspm->max_channels_out = RAYDAT_SS_CHANNELS;
6558
hdspm->channel_map_in_ss = hdspm->channel_map_out_ss =
6559
channel_map_raydat_ss;
6560
hdspm->channel_map_in_ds = hdspm->channel_map_out_ds =
6561
channel_map_raydat_ds;
6562
hdspm->channel_map_in_qs = hdspm->channel_map_out_qs =
6563
channel_map_raydat_qs;
6564
hdspm->channel_map_in = hdspm->channel_map_out =
6565
channel_map_raydat_ss;
6567
hdspm->port_names_in_ss = hdspm->port_names_out_ss =
6568
texts_ports_raydat_ss;
6569
hdspm->port_names_in_ds = hdspm->port_names_out_ds =
6570
texts_ports_raydat_ds;
6571
hdspm->port_names_in_qs = hdspm->port_names_out_qs =
6572
texts_ports_raydat_qs;
6580
switch (hdspm->io_type) {
6583
if (hdspm_read(hdspm, HDSPM_statusRegister2) &
6584
HDSPM_s2_tco_detect) {
6586
hdspm->tco = kzalloc(sizeof(struct hdspm_tco),
6588
if (NULL != hdspm->tco) {
6589
hdspm_tco_write(hdspm);
6591
snd_printk(KERN_INFO "HDSPM: AIO/RayDAT TCO module found\n");
6598
if (hdspm_read(hdspm, HDSPM_statusRegister) & HDSPM_tco_detect) {
6600
hdspm->tco = kzalloc(sizeof(struct hdspm_tco),
6602
if (NULL != hdspm->tco) {
6603
hdspm_tco_write(hdspm);
6605
snd_printk(KERN_INFO "HDSPM: MADI TCO module found\n");
6616
switch (hdspm->io_type) {
6619
hdspm->texts_autosync = texts_autosync_aes_tco;
6620
hdspm->texts_autosync_items = 10;
6622
hdspm->texts_autosync = texts_autosync_aes;
6623
hdspm->texts_autosync_items = 9;
6629
hdspm->texts_autosync = texts_autosync_madi_tco;
6630
hdspm->texts_autosync_items = 4;
6632
hdspm->texts_autosync = texts_autosync_madi;
6633
hdspm->texts_autosync_items = 3;
6643
hdspm->texts_autosync = texts_autosync_raydat_tco;
6644
hdspm->texts_autosync_items = 9;
6646
hdspm->texts_autosync = texts_autosync_raydat;
6647
hdspm->texts_autosync_items = 8;
6653
hdspm->texts_autosync = texts_autosync_aio_tco;
6654
hdspm->texts_autosync_items = 6;
6656
hdspm->texts_autosync = texts_autosync_aio;
6657
hdspm->texts_autosync_items = 5;
6663
tasklet_init(&hdspm->midi_tasklet,
6664
hdspm_midi_tasklet, (unsigned long) hdspm);
4437
6666
snd_printdd("create alsa devices.\n");
4438
6667
err = snd_hdspm_create_alsa_devices(card, hdspm);