#define REGVAL_SPCR1_CLKSTP_NODELAY 0x1000
#define REGVAL_SPCR1_CLKSTP_NODELAY 0x1000
#define REGVAL_SPCR1_CLKSTP_WITHDELAY 0x1800
+#define REGVAL_SPCR1_RFULL 0x0004
+#define REGVAL_SPCR1_RRDY 0x0002
#define REGVAL_SPCR1_RRST_NOTRESET 0x0001
#define REGVAL_SPCR2_FRST_NOTRESET 0x0080
#define REGVAL_SPCR2_GRST_NOTRESET 0x0040
--- /dev/null
+################################################################
+###### 0CPM FIRMERWARE -- CODEC SUPPORT LIBRARY ######
+################################################################
+
+
+#
+# Objects always required for operation as a SIP phone:
+#
+objs-top-codec-${CONFIG_MAINFUNCTON_SIP_PHONE} += src/codec/wrap.o
+
+#
+# Codecs for literal audio sample transfer: L8, L16
+#
+objs-top-codec-${CONFIG_CODEC_L8_L16} += src/codec/l8l16.o
+
+#
+# Codecs from SpanDSP: G.711, G.722, G.726
+# Note: Either G.722 or G.726 implies G.711, the lowest common denominator codec
+#
+objs-top-codec-${CONFIG_CODEC_G711} += src/codec/spandsp/src/g711.o src/codec/spandsp/src/bitstream.o
+objs-top-codec-${CONFIG_CODEC_G722} += src/codec/spandsp/src/g722.o src/codec/spandsp/src/vector_int.o
+objs-top-codec-${CONFIG_CODEC_G726} += src/codec/spandsp/src/g726.o
+#
+# Additionally, SpanDSP supports T.38 fax
+#
+#TODO:T38# objs-top-$(CONFIG_CODEC_FACSIMILE) += src/codec/spandsp/src/t38_terminal.o src/codec/spandsp/src/t38_core.o src/codec/spandsp/src/t30_api.o src/codec/spandsp/src/t30.o src/codec/spandsp/src/t30_logging.o src/codec/spandsp/src/t35.o src/codec/spandsp/src/t4_rx.o src/codec/spandsp/src/t4_tx.o src/codec/spandsp/src/async.o src/codec/spandsp/src/timezone.o src/codec/spandsp/src/bit_operations.o src/codec/spandsp/src/logging.o
+
+#
+# Codec from Xiph: Speex
+#
+# Note: SPEEX_ULTRAWIDEBAND implies SPEEX_NARROWBAND and SPEEX_WIDEBAND
+# SPEEX_WIDEBAND implies SPEEX_NARROWBAND
+#
+#TODO# objs-top-codec-${CONFIG_CODEC_SPEEX_NARROWBAND} += src/codec/speex/TODO
+
+#
+# Experimental codec by Rowetel: Codec2
+#
+src/codec/codec2/src/codebook.c: src/codec/codec2/src/generate_codebook.c
+ make -C src/codec/codec2/src `basename $@`
+
+src/codec/codec2/src/codebookd.c: src/codec/codec2/src/generate_codebook.c
+ make -C src/codec/codec2/src `basename $@`
+
+src/codec/codec2/src/codebookdvq.c: src/codec/codec2/src/generate_codebook.c
+ make -C src/codec/codec2/src `basename $@`
+
+objs-top-codec-${CONFIG_CODEC_CODEC2} += src/codec/codec2/src/codec2.o src/codec/codec2/src/lpc.o src/codec/codec2/src/nlp.o src/codec/codec2/src/postfilter.o src/codec/codec2/src/sine.o src/codec/codec2/src/fft.o src/codec/codec2/src/kiss_fft.o src/codec/codec2/src/interp.o src/codec/codec2/src/lsp.o src/codec/codec2/src/phase.o src/codec/codec2/src/quantise.o src/codec/codec2/src/pack.o src/codec/codec2/src/codebook.o src/codec/codec2/src/codebookd.o src/codec/codec2/src/codebookdvq.o
+
+#
+# Codec by me: RTT
+#
+objs-top-codec-${CONFIG_CODEC_RTT} += src/codec/rtt/recvkeys.o src/codec/rtt/sendkeys.o
+
+#
+# Codec for encryption: ZRTP
+#
+#TODO# objs-top-codec-${CONFIG_CODEC_ZRTP} += TODO
+
void l8_decode (struct codec *hdl, int16_t *pcm, uint16_t *pcmlen, uint8_t *pkt, uint16_t *pktlen) {
while ((*pktlen >= 1) && (*pcmlen >= 1)) {
// Note: The 0x00ff masks away extra bits from 16-bit DSPs like tic55x
- *pcm++ = ((((uint16_t) *pkt++) & 0x00ff) ^ 0x0080) << 8;
+ *pcm++ = (((uint16_t) ((*pkt++) & 0x00ff)) ^ 0x0080) << 8;
(*pcmlen) --;
(*pktlen) --;
}
void l16_decode (struct codec *hdl, int16_t *pcm, uint16_t *pcmlen, uint8_t *pkt, uint16_t *pktlen) {
while ((*pktlen >= 2) && (*pcmlen >= 1)) {
// Note: The 0xff masks away extra bits from 16-bit DSPs like tic55x
- *pcm++ = (int16_t) ((((uint16_t) *pkt++) << 8) | ((*pkt++) & 0xff));
+ *pcm++ = (int16_t) ((((uint16_t) (*pkt++)) << 8) | ((*pkt++) & 0xff));
(*pcmlen) --;
(*pktlen) -= 2;
}
void tlv320aic2x_set_samplerate (uint8_t chan, uint32_t samplerate) {
uint16_t m, n, p;
SPCR2_1 |= REGVAL_SPCR2_GRST_NOTRESET | REGVAL_SPCR2_FRST_NOTRESET;
-{ uint32_t ctr = 100; while (ctr-- > 0) ; }
+//TRY-WITHOUT// { uint32_t ctr = 100000; while (ctr-- > 0) ; } // Helps to sync TLV --TODO-- wait4what?
SPCR1_1 |= REGVAL_SPCR1_RRST_NOTRESET;
SPCR2_1 |= REGVAL_SPCR2_XRST_NOTRESET;
-{ uint32_t ctr = 10000; while (ctr-- > 0) ; }
+//TRY-WITHOUT// { uint32_t ctr = 100000; while (ctr-- > 0) ; } // Helps to sync TLV --TODO-- wait4what?
+// Getting in tune with the TLV probably means waiting
+// until it has picked up changes. This means waiting
+// for a FS to occur. One way of doing that is to see
+// when a server overrun (RFULL) occurs.
+#if 1
+(void) DRR1_1; // Flag down RFULL
+while (! (SPCR1_1 & REGVAL_SPCR1_RFULL) ) {
+ ;
+}
+#endif
DXR1_1 = DXR1_1; // Flag down XEMPTY
tlv320aic2x_setreg (chan, 3, 0x31); // Channel offline
-{ uint32_t ctr = 1000; while (ctr-- > 0) ; }
+//TRY-WITHOUT// { uint32_t ctr = 10000; while (ctr-- > 0) ; }
(void) DRR1_1; // Flag down RFULL
(void) DRR1_1;
// Determine the dividors m, n and p
SPCR2_1 &= ~REGVAL_SPCR2_XRST_NOTRESET;
{ uint32_t ctr = 10000; while (ctr-- > 0) ; }
SPCR2_1 &= ~ ( REGVAL_SPCR2_GRST_NOTRESET | REGVAL_SPCR2_FRST_NOTRESET );
-{ uint32_t ctr = 10000; while (ctr-- > 0) ; }
+{ uint32_t ctr = 100000; while (ctr-- > 0) ; } // Helps to sync TLV --TODO-- wait4what?
// SPCR2_1 &= ~ ( REGVAL_SPCR2_FRST_NOTRESET );
{ uint32_t ctr = 10000; while (ctr-- > 0) ; }
// #endif
if (!bottom_soundchannel_acceptable_samplerate (PHONE_CHANNEL_TELEPHONY, 8000)) {
bottom_printf ("Failed to set sample rate");
bottom_show_fixed_msg (APP_LEVEL_ZERO, FIXMSG_CALL_ENDED);
- while (1) {
+ while (true) {
;
}
}
int16_t *outbuf;
while ((outbuf = bottom_play_claim (PHONE_CHANNEL_TELEPHONY))) {
uint16_t pcmlen, pktlen;
-#if 1
+#if 0
pcmlen = 64;
pktlen = 64;
// Note: No handle needed for stateless L8
#define abs(x) (((x)>0)?(x):(-(x)))
-/* 1 second at 8000 samples per second, plus 25% extra */
-uint8_t samples [10000];
+/* 1 second at 8000 samples per second, 2 bytes each, plus 25% extra */
+int8_t samples [20000];
void top_main_delay_1sec (void) {
uint16_t prepblocks = 0;
- uint16_t playptr = 2000, recptr = 0;
-memset (samples, 0x33, sizeof (samples));
+ uint16_t playptr = 4000, recptr = 0;
bottom_critical_region_end ();
+ memset (samples, 0x33, sizeof (samples));
if (!bottom_soundchannel_acceptable_samplerate (PHONE_CHANNEL_TELEPHONY, 8000)) {
bottom_printf ("Failed to set sample rate");
bottom_show_fixed_msg (APP_LEVEL_ZERO, FIXMSG_CALL_ENDED);
- exit (1);
+ while (true) {
+ ;
+ }
}
bottom_soundchannel_set_samplerate (PHONE_CHANNEL_TELEPHONY, 8000, 100, 1, 1);
bottom_soundchannel_setvolume (PHONE_CHANNEL_TELEPHONY, 127);
buf = bottom_play_claim (PHONE_CHANNEL_TELEPHONY);
} while (buf == NULL);
pcmlen = 100;
- pktlen = 100;
- // Note: No handle needed for stateless L8
- l8_encode (NULL, buf, &pcmlen, samples + playptr, &pktlen);
+ pktlen = 200;
+ // Note: No handle needed for stateless L16
+bottom_printf ("Playing %d, %d, %d...\n", 0xffff & (intptr_t) buf [0], 0xffff & (intptr_t) buf [1], 0xffff & (intptr_t) buf [2]);
+ l16_encode (NULL, buf, &pcmlen, samples + playptr, &pktlen);
bottom_play_release (PHONE_CHANNEL_TELEPHONY);
- playptr += 100;
- if (playptr >= 10000) {
- playptr -= 10000;
+ playptr += 200;
+ if (playptr >= 20000) {
+ playptr -= 20000;
}
do {
buf = bottom_record_claim (PHONE_CHANNEL_TELEPHONY);
} while (buf == NULL);
pcmlen = 100;
- pktlen = 100;
- // Note: No handle needed for stateless L8
- l8_decode (NULL, buf, &pcmlen, samples + recptr, &pktlen);
+ pktlen = 200;
+ // Note: No handle needed for stateless L16
+ l16_decode (NULL, buf, &pcmlen, samples + recptr, &pktlen);
+bottom_printf ("Recorded %d, %d, %d...\n", 0xffff & (intptr_t) buf [0], 0xffff & (intptr_t) buf [1], 0xffff & (intptr_t) buf [2]);
bottom_record_release (PHONE_CHANNEL_TELEPHONY);
- recptr += 100;
- if (recptr >= 10000) {
- recptr -= 10000;
+ recptr += 200;
+ if (recptr >= 20000) {
+ recptr -= 20000;
}
#ifdef CONFIG_FUNCTION_NETCONSOLE