annotate ater/tx_func.c @ 52:626180a15857 default tip

ater play-d144: emit E-data frames manually, osmo_trau_frame_encode() is currently broken for this frame type
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 25 Sep 2024 06:40:43 +0000
parents db39e8855f3d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Here we are going to implement Tx on Ater toward the TRAU.
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdint.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdbool.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <unistd.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
51
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
12 #include <osmocom/core/bits.h>
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
13 #include <osmocom/core/msgb.h>
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <osmocom/core/select.h>
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <osmocom/isdn/i460_mux.h>
26
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
16 #include <osmocom/trau/trau_frame.h>
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #include "globals.h"
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #include "submux.h"
26
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
20 #include "out_frame.h"
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
49
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
22 /*
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
23 * The following hard-coded frame is based on TS 48.060 section 5.3.1.
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
24 * 0-based octet numbers in the comments are as in the spec.
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
25 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
26 static const ubit_t d144_sync_frame[320] = {
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
27 0, 0, 0, 0, 0, 0, 0, 0, /* octet 0 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
28 0, 0, 0, 0, 0, 0, 0, 0, /* octet 1 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
29 1, 1, 0, 1, 0, 0, 1, 1, /* octet 2 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
30 1, 1, 1, 1, 1, 1, 1, 1, /* octet 3 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
31 1, 1, 1, 1, 1, 1, 1, 1, /* octet 4 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
32 1, 1, 1, 1, 1, 1, 1, 1, /* octet 5 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
33 1, 1, 1, 1, 1, 1, 1, 1, /* octet 6 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
34 1, 1, 1, 1, 1, 1, 1, 1, /* octet 7 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
35 1, 1, 1, 1, 1, 1, 1, 1, /* octet 8 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
36 1, 1, 1, 1, 1, 1, 1, 1, /* octet 9 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
37 1, 1, 1, 1, 1, 1, 1, 1, /* octet 10 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
38 1, 1, 1, 1, 1, 1, 1, 1, /* octet 11 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
39 1, 1, 1, 1, 1, 1, 1, 1, /* octet 12 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
40 1, 1, 1, 1, 1, 1, 1, 1, /* octet 13 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
41 1, 1, 1, 1, 1, 1, 1, 1, /* octet 14 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
42 1, 1, 1, 1, 1, 1, 1, 1, /* octet 15 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
43 1, 1, 1, 1, 1, 1, 1, 1, /* octet 16 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
44 1, 1, 1, 1, 1, 1, 1, 1, /* octet 17 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
45 1, 1, 1, 1, 1, 1, 1, 1, /* octet 18 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
46 1, 1, 1, 1, 1, 1, 1, 1, /* octet 19 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
47 1, 1, 1, 1, 1, 1, 1, 1, /* octet 20 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
48 1, 1, 1, 1, 1, 1, 1, 1, /* octet 21 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
49 1, 1, 1, 1, 1, 1, 1, 1, /* octet 22 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
50 1, 1, 1, 1, 1, 1, 1, 1, /* octet 23 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
51 1, 1, 1, 1, 1, 1, 1, 1, /* octet 24 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
52 1, 1, 1, 1, 1, 1, 1, 1, /* octet 25 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
53 1, 1, 1, 1, 1, 1, 1, 1, /* octet 26 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
54 1, 1, 1, 1, 1, 1, 1, 1, /* octet 27 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
55 1, 1, 1, 1, 1, 1, 1, 1, /* octet 28 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
56 1, 1, 1, 1, 1, 1, 1, 1, /* octet 29 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
57 1, 1, 1, 1, 1, 1, 1, 1, /* octet 30 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
58 1, 1, 1, 1, 1, 1, 1, 1, /* octet 31 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
59 1, 1, 1, 1, 1, 1, 1, 1, /* octet 32 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
60 1, 1, 1, 1, 1, 1, 1, 1, /* octet 33 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
61 1, 1, 1, 1, 1, 1, 1, 1, /* octet 34 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
62 1, 1, 1, 1, 1, 1, 1, 1, /* octet 35 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
63 1, 1, 1, 1, 1, 1, 1, 1, /* octet 36 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
64 1, 1, 1, 1, 1, 1, 1, 1, /* octet 37 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
65 1, 1, 1, 1, 1, 1, 1, 1, /* octet 38 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
66 1, 1, 1, 1, 1, 1, 1, 1, /* octet 39 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
67 };
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
68
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
69 /*
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
70 * The following hard-coded frame is based on TS 48.060 section 5.3.2.
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
71 * 0-based octet numbers in the comments are as in the spec.
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
72 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
73 static const ubit_t d144_idle_edata[320] = {
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
74 0, 0, 0, 0, 0, 0, 0, 0, /* octet 0 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
75 0, 0, 0, 0, 0, 0, 0, 0, /* octet 1 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
76 1, 1, 1, 1, 1, 1, 1, 1, /* octet 2 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
77 1, 1, 1, 1, 1, 1, 1, 1, /* octet 3 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
78 1, 1, 1, 1, 1, 1, 1, 1, /* octet 4 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
79 1, 1, 1, 1, 1, 1, 1, 1, /* octet 5 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
80 1, 1, 1, 1, 1, 1, 1, 1, /* octet 6 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
81 1, 1, 1, 1, 1, 1, 1, 1, /* octet 7 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
82 1, 1, 1, 1, 1, 1, 1, 1, /* octet 8 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
83 1, 1, 1, 1, 1, 1, 1, 1, /* octet 9 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
84 1, 1, 1, 1, 1, 1, 1, 1, /* octet 10 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
85 1, 1, 1, 1, 1, 1, 1, 1, /* octet 11 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
86 1, 1, 1, 1, 1, 1, 1, 1, /* octet 12 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
87 1, 1, 1, 1, 1, 1, 1, 1, /* octet 13 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
88 1, 1, 1, 1, 1, 1, 1, 1, /* octet 14 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
89 1, 1, 1, 1, 1, 1, 1, 1, /* octet 15 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
90 1, 1, 1, 1, 1, 1, 1, 1, /* octet 16 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
91 1, 1, 1, 1, 1, 1, 1, 1, /* octet 17 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
92 1, 1, 1, 1, 1, 1, 1, 1, /* octet 18 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
93 1, 1, 1, 1, 1, 1, 1, 1, /* octet 19 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
94 1, 1, 1, 1, 1, 1, 1, 1, /* octet 20 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
95 1, 1, 1, 1, 1, 1, 1, 1, /* octet 21 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
96 1, 1, 1, 1, 1, 1, 1, 1, /* octet 22 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
97 1, 1, 1, 1, 1, 1, 1, 1, /* octet 23 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
98 1, 1, 1, 1, 1, 1, 1, 1, /* octet 24 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
99 1, 1, 1, 1, 1, 1, 1, 1, /* octet 25 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
100 1, 1, 1, 1, 1, 1, 1, 1, /* octet 26 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
101 1, 1, 1, 1, 1, 1, 1, 1, /* octet 27 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
102 1, 1, 1, 1, 1, 1, 1, 1, /* octet 28 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
103 1, 1, 1, 1, 1, 1, 1, 1, /* octet 29 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
104 1, 1, 1, 1, 1, 1, 1, 1, /* octet 30 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
105 1, 1, 1, 1, 1, 1, 1, 1, /* octet 31 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
106 1, 1, 1, 1, 1, 1, 1, 1, /* octet 32 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
107 1, 1, 1, 1, 1, 1, 1, 1, /* octet 33 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
108 1, 1, 1, 1, 1, 1, 1, 1, /* octet 34 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
109 1, 1, 1, 1, 1, 1, 1, 1, /* octet 35 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
110 1, 1, 1, 1, 1, 1, 1, 1, /* octet 36 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
111 1, 1, 1, 1, 1, 1, 1, 1, /* octet 37 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
112 1, 1, 1, 1, 1, 1, 1, 1, /* octet 38 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
113 1, 1, 1, 1, 1, 1, 1, 1, /* octet 39 */
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
114 };
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
115
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
116 void init_trau_ul_frame(int nr)
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
117 {
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
118 struct ater_subslot *at = &subslots[nr];
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
119 struct osmo_trau_frame *fr = &at->ul_frame;
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
120
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
121 fr->type = at->is_efr ? OSMO_TRAU16_FT_EFR : OSMO_TRAU16_FT_FR;
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
122 fr->dir = OSMO_TRAU_DIR_UL;
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
123 memset(fr->c_bits + 5, 0, 6);
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
124 memset(fr->c_bits + 15, 1, 6);
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
125 memset(fr->t_bits, 1, 4);
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
126 }
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
127
44
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
128 void init_trau_ul_frame_csd(int nr, bool ir_16k)
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
129 {
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
130 struct ater_subslot *at = &subslots[nr];
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
131 struct osmo_trau_frame *fr = &at->ul_frame;
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
132
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
133 fr->type = OSMO_TRAU16_FT_DATA;
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
134 fr->dir = OSMO_TRAU_DIR_UL;
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
135 fr->c_bits[5] = ir_16k;
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
136 memset(fr->c_bits + 6, 1, 9);
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
137 memset(fr->d_bits, 1, 63 * 4);
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
138 }
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
139
52
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
140 static void d144_play_frame(ubit_t *out, const uint8_t *filerec)
51
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
141 {
52
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
142 memset(out, 0, 16);
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
143 memset(out + 16, 1, 6);
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
144 out[22] = 0;
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
145 memset(out + 23, 1, 7);
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
146 out[30] = (filerec[1] & 2) >> 1;
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
147 out[31] = filerec[1] & 1;
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
148 osmo_pbit2ubit(out + 32, filerec + 2, 288);
51
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
149 }
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
150
52
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
151 static void d144_fill_frame(struct ater_subslot *at, ubit_t *out)
49
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
152 {
51
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
153 if (at->play_buffer) {
52
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
154 d144_play_frame(out, at->play_buffer + at->play_buf_ptr * 38);
51
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
155 at->play_buf_ptr++;
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
156 if (at->play_buf_ptr < at->play_buf_total)
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
157 return;
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
158 free(at->play_buffer);
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
159 at->play_buffer = NULL;
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
160 printf("file play finished\n");
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
161 return;
db39e8855f3d ater: implement play-d144
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
162 }
52
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
163 memcpy(out, at->d144_edata ? d144_idle_edata : d144_sync_frame, 320);
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
164 }
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
165
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
166 static void handle_d144(int nr)
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
167 {
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
168 struct ater_subslot *at = &subslots[nr];
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
169 struct msgb *msg;
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
170
49
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
171 msg = msgb_alloc_c(g_ctx, 320, "TRAU-UL-frame");
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
172 if (!msg)
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
173 return;
52
626180a15857 ater play-d144: emit E-data frames manually,
Mychaela Falconia <falcon@freecalypso.org>
parents: 51
diff changeset
174 d144_fill_frame(at, msg->tail);
49
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
175 msgb_put(msg, 320);
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
176 osmo_i460_mux_enqueue(at->schan, msg);
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
177 }
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
178
26
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
179 static void handle_play(struct ater_subslot *at)
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
180 {
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
181 if (at->play_wait_align) {
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
182 if (at->mfrm_count)
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
183 return;
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
184 at->play_wait_align = false;
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
185 }
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
186 trau_frame_from_record(at->play_buffer + at->play_buf_ptr * 34,
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
187 at->is_efr, &at->ul_frame);
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
188 at->play_buf_ptr++;
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
189 if (at->play_buf_ptr < at->play_buf_total)
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
190 return;
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
191 free(at->play_buffer);
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
192 at->play_buffer = NULL;
27
2742dbea95f1 ater: implement play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 26
diff changeset
193 printf("file play finished\n");
26
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
194 }
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
195
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
196 static void tx_service_subslot(int nr)
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
197 {
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
198 struct ater_subslot *at = &subslots[nr];
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
199 struct osmo_trau_frame *fr = &at->ul_frame;
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
200 struct msgb *msg;
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
201 int len;
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
202
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
203 if (!at->is_active)
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
204 return;
49
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
205 if (at->is_data_144) {
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
206 handle_d144(nr);
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
207 return;
40f781efdbe1 ater: beginning of D144 mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 47
diff changeset
208 }
26
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
209 if (at->play_buffer)
237687e2be6c ater: implement play internals
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
210 handle_play(at);
44
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
211 if (!at->is_data) {
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
212 at->mfrm_count++;
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
213 if (at->mfrm_count >= 24) {
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
214 at->mfrm_count = 0;
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
215 fr->c_bits[14] = 1;
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
216 } else {
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
217 fr->c_bits[14] = 0;
16715bd149e0 ater: add support for data mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 27
diff changeset
218 }
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
219 }
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
220 msg = msgb_alloc_c(g_ctx, 640, "TRAU-UL-frame");
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
221 if (!msg)
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
222 return;
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
223 len = osmo_trau_frame_encode(msg->tail, msgb_tailroom(msg), fr);
23
0d70444b5070 ater: more robust msgb handling in TRAU-UL output
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
224 if (len <= 0) {
0d70444b5070 ater: more robust msgb handling in TRAU-UL output
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
225 msgb_free(msg);
0d70444b5070 ater: more robust msgb handling in TRAU-UL output
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
226 return;
0d70444b5070 ater: more robust msgb handling in TRAU-UL output
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
227 }
47
13fffc41f989 ater: add support for HR-data-16k TRAU-UL frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
228 /*
13fffc41f989 ater: add support for HR-data-16k TRAU-UL frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
229 * A very ugly/hacky way of setting C5 for HR data,
13fffc41f989 ater: add support for HR-data-16k TRAU-UL frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
230 * working around libosmotrau API that is not designed
13fffc41f989 ater: add support for HR-data-16k TRAU-UL frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
231 * for such hacking.
13fffc41f989 ater: add support for HR-data-16k TRAU-UL frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
232 */
13fffc41f989 ater: add support for HR-data-16k TRAU-UL frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
233 if (at->is_data && at->is_hr_data)
13fffc41f989 ater: add support for HR-data-16k TRAU-UL frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
234 msg->tail[21] = 1;
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
235 msgb_put(msg, len);
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
236 osmo_i460_mux_enqueue(at->schan, msg);
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
237 }
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
238
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 void transmit_e1_ts(void)
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 {
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 uint8_t buf[160];
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
242 int nr;
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243
19
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
244 for (nr = 0; nr < ATER_SUBSLOTS; nr++)
1e375472d5a5 ater: implement TRAU frame output
Mychaela Falconia <falcon@freecalypso.org>
parents: 18
diff changeset
245 tx_service_subslot(nr);
18
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 osmo_i460_mux_out(&i460_ts, buf, 160);
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 write(ts_fd, buf, 160);
61862af2247f ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 }