FreeCalypso > hg > freecalypso-tools
view ffstools/tiaud/decomp.c @ 1014:961efadd530a default tip
fc-shell TCH DL handler: add support for CSD modes
TCH DL capture mechanism in FC Tourmaline firmware has been extended
to support CSD modes in addition to speech - add the necessary support
on the host tools side.
It needs to be noted that this mechanism in its present state does NOT
provide the debug utility value that was sought: as we learned only
after the code was implemented, TI's DSP has a misfeature in that the
buffer we are reading (a_dd_0[]) is zeroed out when the IDS block
is enabled, i.e., we are reading all zeros and not the real DL bits
we were after. But since the code has already been written, we are
keeping it - perhaps we can do some tests with IDS disabled.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 26 Nov 2024 06:27:43 +0000 |
parents | 516066ac5bc1 |
children |
line wrap: on
line source
/* * This utility decompiles a binary /aud/*.cfg file read out of FFS * into our ASCII text representation. */ #include <sys/types.h> #include <sys/file.h> #include <sys/stat.h> #include <stdio.h> #include <stdint.h> #include <endian.h> #include <stdlib.h> #include <unistd.h> #include "binstruct.h" struct audio_cfg_bin bin; int is_new_aec; FILE *outf; read_bin_file(filename) char *filename; { int fd; struct stat st; fd = open(filename, O_RDONLY); if (fd < 0) { perror(filename); exit(1); } fstat(fd, &st); if (!S_ISREG(st.st_mode)) { fprintf(stderr, "%s is not a regular file\n", filename); exit(1); } if (st.st_size == MODE_FILE_SIZE_OLDAEC) is_new_aec = 0; else if (st.st_size == MODE_FILE_SIZE_NEWAEC) is_new_aec = 1; else { fprintf(stderr, "%s has the wrong length\n", filename); exit(1); } read(fd, &bin, st.st_size); close(fd); } emit_fir(table) uint16_t *table; { int i; for (i = 0; i < 31; i++) { if ((i % 8) == 0) fprintf(outf, "\tfir %2d", i); fprintf(outf, " 0x%04X", le16toh(table[i])); if (i == 7 || i == 15 || i == 23 || i == 30) putc('\n', outf); } } emit_ascii() { int i, num_aec; fprintf(outf, "voice-path %u\n", bin.voice_path); switch (bin.mic_mode) { case AUDIO_MICROPHONE_HANDHELD: fprintf(outf, "mic default {\n"); break; case AUDIO_MICROPHONE_HANDFREE: fprintf(outf, "mic aux {\n"); break; case AUDIO_MICROPHONE_HEADSET: fprintf(outf, "mic headset {\n"); break; default: fprintf(stderr, "error: unknown microphone mode 0x%02X\n", bin.mic_mode); exit(1); } fprintf(outf, "\tgain %d\n", bin.mic_bytes[0]); if (bin.mic_mode == AUDIO_MICROPHONE_HANDFREE) { fprintf(outf, "\textra-gain %d\n", bin.mic_bytes[1]); fprintf(outf, "\toutput-bias %d\n", bin.mic_bytes[2]); } else fprintf(outf, "\toutput-bias %d\n", bin.mic_bytes[1]); emit_fir(bin.mic_fir); fputs("}\n", outf); switch (bin.speaker_mode) { case AUDIO_SPEAKER_HANDHELD: fprintf(outf, "speaker ear {\n"); break; case AUDIO_SPEAKER_HANDFREE: fprintf(outf, "speaker aux {\n"); break; case AUDIO_SPEAKER_HEADSET: fprintf(outf, "speaker headset {\n"); break; case AUDIO_SPEAKER_BUZZER: fprintf(outf, "speaker buzzer {\n"); break; case AUDIO_SPEAKER_HANDHELD_HANDFREE: fprintf(outf, "speaker ear+aux {\n"); break; default: fprintf(stderr, "error: unknown speaker mode 0x%02X\n", bin.speaker_mode); exit(1); } if (bin.speaker_mode != AUDIO_SPEAKER_BUZZER) { fprintf(outf, "\tgain %d\n", bin.speaker_bytes[0]); fprintf(outf, "\taudio-filter %d\n", bin.speaker_bytes[1]); emit_fir(bin.speaker_fir); } else fprintf(outf, "\tactivate %d\n", bin.speaker_bytes[0]); fputs("}\n", outf); fprintf(outf, "sidetone %d\n", bin.sidetone_gain); if (is_new_aec) { fputs("aec-new", outf); num_aec = 12; } else { fputs("aec", outf); num_aec = 5; } for (i = 0; i < num_aec; i++) { putc(' ', outf); if (bin.aec_words[i]) fprintf(outf, "0x%X", le16toh(bin.aec_words[i])); else putc('0', outf); } putc('\n', outf); } main(argc, argv) char **argv; { if (argc < 2 || argc > 3) { fprintf(stderr, "usage: %s infile [outfile]\n", argv[0]); exit(1); } read_bin_file(argv[1]); if (argc > 2) { outf = fopen(argv[2], "w"); if (!outf) { perror(argv[2]); exit(1); } } else outf = stdout; emit_ascii(); exit(0); }