FreeCalypso > hg > freecalypso-tools
annotate rvinterf/etmsync/tmsaur.c @ 914:bf302e52c8ea
Source-dirs: add tchtools
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 29 Dec 2022 22:21:04 +0000 |
parents | 9da5fb3f42dd |
children |
rev | line source |
---|---|
841
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This fc-tmsync module implements aur commands and operations. |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "etm.h" |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "audio.h" |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "limits.h" |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "localtypes.h" |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "exitcodes.h" |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern u_char rvi_msg[]; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern int rvi_msg_len; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 do_aur(param, data, size) |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 u_char *data; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 u_char cmdpkt[5]; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 cmdpkt[1] = ETM_AUDIO; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 cmdpkt[2] = 'R'; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 cmdpkt[3] = param; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 etm_pkt_exch(cmdpkt, 3); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 if (rvi_msg[3]) { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 fprintf(stderr, "target error %u in response to aur\n", |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 rvi_msg[3]); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 return(ERROR_TARGET); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 if (rvi_msg_len < size + 7) { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 fprintf(stderr, "target error: aur response too short\n"); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 return(ERROR_TARGET); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (rvi_msg[4] != 'R') { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 fprintf(stderr, "target error: aur response wrong type\n"); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 return(ERROR_TARGET); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 if (rvi_msg[5] != param) { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 fprintf(stderr, "target error: aur response wrong index\n"); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 return(ERROR_TARGET); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 bcopy(rvi_msg + 6, data, size); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(0); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
842
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
49 static int |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
50 convert_signed_byte(b) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
51 { |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
52 if (b >= 128) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
53 b -= 256; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
54 return(b); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
55 } |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
56 |
841
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 cmd_aur(argc, argv) |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 char **argv; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 unsigned param, word; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 u_char data[62]; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 int size, rc, i; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 param = strtoul(argv[1], 0, 0); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 switch (param) { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 case AUDIO_PATH_USED: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 case AUDIO_MICROPHONE_MODE: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 case AUDIO_MICROPHONE_GAIN: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 case AUDIO_MICROPHONE_EXTRA_GAIN: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 case AUDIO_MICROPHONE_OUTPUT_BIAS: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 case AUDIO_SPEAKER_MODE: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 case AUDIO_SPEAKER_GAIN: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 case AUDIO_SPEAKER_FILTER: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 case AUDIO_SPEAKER_BUZZER_STATE: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 case AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 case AUDIO_SPEAKER_VOLUME_LEVEL: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 size = 1; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 break; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 case AUDIO_MICROPHONE_FIR: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 case AUDIO_SPEAKER_FIR: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 size = 62; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 break; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 case AUDIO_MICROPHONE_SPEAKER_LOOP_AEC: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 size = 24; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 break; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 default: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 fprintf(stderr, "error: unknown aur parameter\n"); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 return(ERROR_USAGE); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 rc = do_aur(param, data, size); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 if (rc) |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 return(rc); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 switch (param) { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 case AUDIO_PATH_USED: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 case AUDIO_SPEAKER_VOLUME_LEVEL: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 printf("%u\n", data[0]); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 break; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 case AUDIO_MICROPHONE_MODE: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 case AUDIO_MICROPHONE_GAIN: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 case AUDIO_MICROPHONE_EXTRA_GAIN: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 case AUDIO_MICROPHONE_OUTPUT_BIAS: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 case AUDIO_SPEAKER_MODE: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 case AUDIO_SPEAKER_GAIN: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 case AUDIO_SPEAKER_FILTER: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 case AUDIO_SPEAKER_BUZZER_STATE: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 case AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE: |
842
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
107 printf("%d\n", convert_signed_byte(data[0])); |
841
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 break; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 case AUDIO_MICROPHONE_FIR: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 case AUDIO_SPEAKER_FIR: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 fputs("fir-coeff-table\n\n", stdout); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 for (i = 0; i < 31; i++) { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 printf("0x%04X", (data[i*2+1] << 8) | data[i*2]); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 if (i == 7 || i == 15 || i == 23 || i == 30) |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 putchar('\n'); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 else |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 putchar(' '); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 break; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 case AUDIO_MICROPHONE_SPEAKER_LOOP_AEC: |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 fputs("aec-new", stdout); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 for (i = 0; i < 12; i++) { |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 putchar(' '); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 word = (data[i*2+1] << 8) | data[i*2]; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 if (word) |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 printf("0x%X", word); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 else |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 putchar('0'); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 putchar('\n'); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 break; |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 } |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 return(0); |
379574e5cf5e
fc-tmsync aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 } |
842
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
135 |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
136 cmd_aur_all(argc, argv) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
137 char **argv; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
138 { |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
139 u_char data[62]; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
140 unsigned mic_mode, speaker_mode, word; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
141 int rc, i; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
142 |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
143 rc = do_aur(AUDIO_PATH_USED, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
144 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
145 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
146 printf("voice-path %u\n", data[0]); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
147 |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
148 rc = do_aur(AUDIO_MICROPHONE_MODE, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
149 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
150 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
151 mic_mode = data[0]; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
152 switch (mic_mode) { |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
153 case AUDIO_MICROPHONE_HANDHELD: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
154 printf("mic default {\n"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
155 break; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
156 case AUDIO_MICROPHONE_HANDFREE: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
157 printf("mic aux {\n"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
158 break; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
159 case AUDIO_MICROPHONE_HEADSET: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
160 printf("mic headset {\n"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
161 break; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
162 default: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
163 fprintf(stderr, "error: unknown microphone mode 0x%02X\n", |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
164 mic_mode); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
165 return(ERROR_TARGET); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
166 } |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
167 rc = do_aur(AUDIO_MICROPHONE_GAIN, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
168 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
169 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
170 printf("\tgain %d\n", convert_signed_byte(data[0])); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
171 if (mic_mode == AUDIO_MICROPHONE_HANDFREE) { |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
172 rc = do_aur(AUDIO_MICROPHONE_EXTRA_GAIN, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
173 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
174 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
175 printf("\textra-gain %d\n", convert_signed_byte(data[0])); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
176 } |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
177 rc = do_aur(AUDIO_MICROPHONE_OUTPUT_BIAS, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
178 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
179 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
180 printf("\toutput-bias %d\n", convert_signed_byte(data[0])); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
181 rc = do_aur(AUDIO_MICROPHONE_FIR, data, 62); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
182 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
183 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
184 for (i = 0; i < 31; i++) { |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
185 if ((i % 8) == 0) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
186 printf("\tfir %2d", i); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
187 printf(" 0x%04X", (data[i*2+1] << 8) | data[i*2]); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
188 if (i == 7 || i == 15 || i == 23 || i == 30) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
189 putchar('\n'); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
190 } |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
191 puts("}"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
192 |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
193 rc = do_aur(AUDIO_SPEAKER_MODE, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
194 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
195 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
196 speaker_mode = data[0]; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
197 switch (speaker_mode) { |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
198 case AUDIO_SPEAKER_HANDHELD: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
199 printf("speaker ear {\n"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
200 break; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
201 case AUDIO_SPEAKER_HANDFREE: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
202 printf("speaker aux {\n"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
203 break; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
204 case AUDIO_SPEAKER_HEADSET: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
205 printf("speaker headset {\n"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
206 break; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
207 case AUDIO_SPEAKER_HANDHELD_HANDFREE: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
208 printf("speaker ear+aux {\n"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
209 break; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
210 default: |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
211 fprintf(stderr, "error: unknown speaker mode 0x%02X\n", |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
212 speaker_mode); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
213 return(ERROR_TARGET); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
214 } |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
215 rc = do_aur(AUDIO_SPEAKER_GAIN, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
216 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
217 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
218 printf("\tgain %d\n", convert_signed_byte(data[0])); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
219 rc = do_aur(AUDIO_SPEAKER_FILTER, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
220 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
221 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
222 printf("\taudio-filter %d\n", convert_signed_byte(data[0])); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
223 rc = do_aur(AUDIO_SPEAKER_FIR, data, 62); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
224 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
225 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
226 for (i = 0; i < 31; i++) { |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
227 if ((i % 8) == 0) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
228 printf("\tfir %2d", i); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
229 printf(" 0x%04X", (data[i*2+1] << 8) | data[i*2]); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
230 if (i == 7 || i == 15 || i == 23 || i == 30) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
231 putchar('\n'); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
232 } |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
233 puts("}"); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
234 |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
235 rc = do_aur(AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE, data, 1); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
236 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
237 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
238 printf("sidetone %d\n", convert_signed_byte(data[0])); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
239 rc = do_aur(AUDIO_MICROPHONE_SPEAKER_LOOP_AEC, data, 24); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
240 if (rc) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
241 return(rc); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
242 fputs("aec-new", stdout); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
243 for (i = 0; i < 12; i++) { |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
244 putchar(' '); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
245 word = (data[i*2+1] << 8) | data[i*2]; |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
246 if (word) |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
247 printf("0x%X", word); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
248 else |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
249 putchar('0'); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
250 } |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
251 putchar('\n'); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
252 return(0); |
9da5fb3f42dd
fc-tmsync aur-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
841
diff
changeset
|
253 } |