FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/L1/cfile/tch_feature.c @ 1016:a6ca9ee289f7
gsm-fw feature tch-reroute: uplink substitution implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 21 Mar 2016 02:27:51 +0000 |
parents | 3bfeee466b0a |
children | 6312f684cef1 |
comparison
equal
deleted
inserted
replaced
1015:9ced8e13cf91 | 1016:a6ca9ee289f7 |
---|---|
5 | 5 |
6 #include "config.h" | 6 #include "config.h" |
7 #include "l1_confg.h" | 7 #include "l1_confg.h" |
8 #include "l1_types.h" | 8 #include "l1_types.h" |
9 #include "sys_types.h" | 9 #include "sys_types.h" |
10 #include <string.h> | |
11 #include "l1_const.h" | |
12 #include "l1_defty.h" | |
13 #include "l1_varex.h" | |
10 #include "l1_trace.h" | 14 #include "l1_trace.h" |
11 #include "tch_feature.h" | 15 #include "tch_feature.h" |
12 | 16 |
13 T_RVT_USER_ID tch_reroute_rvt_id; | 17 T_RVT_USER_ID tch_reroute_rvt_id; |
14 BOOL tch_reroute_downlink; | 18 BOOL tch_reroute_downlink; |
16 void tch_send_downlink_bits(API *dsp_buffer) | 20 void tch_send_downlink_bits(API *dsp_buffer) |
17 { | 21 { |
18 T_RVT_BUFFER buf; | 22 T_RVT_BUFFER buf; |
19 T_RVT_RET rc; | 23 T_RVT_RET rc; |
20 UINT8 *dp; | 24 UINT8 *dp; |
21 API apiword; | 25 UWORD16 apiword; |
22 int i; | 26 int i; |
23 | 27 |
24 rc = rvt_mem_alloc(tch_reroute_rvt_id, 41, &buf); | 28 rc = rvt_mem_alloc(tch_reroute_rvt_id, 41, &buf); |
25 if (rc != RVT_OK) | 29 if (rc != RVT_OK) |
26 return; | 30 return; |
32 *dp++ = apiword >> 8; | 36 *dp++ = apiword >> 8; |
33 } | 37 } |
34 rvt_send_trace_no_cpy(buf, tch_reroute_rvt_id, 41, RVT_BINARY_FORMAT); | 38 rvt_send_trace_no_cpy(buf, tch_reroute_rvt_id, 41, RVT_BINARY_FORMAT); |
35 } | 39 } |
36 | 40 |
37 static void handle_tch_config_reg(T_RVT_BUFFER pkt) | 41 static void send_tch_ulbits_conf() |
42 { | |
43 T_RVT_BUFFER buf; | |
44 T_RVT_RET rc; | |
45 | |
46 rc = rvt_mem_alloc(tch_reroute_rvt_id, 1, &buf); | |
47 if (rc == RVT_OK) { | |
48 buf[0] = TCH_ULBITS_CONF; | |
49 rvt_send_trace_no_cpy(buf, tch_reroute_rvt_id, 1, | |
50 RVT_BINARY_FORMAT); | |
51 } | |
52 } | |
53 | |
54 #define UPLINK_QUEUE_SIZE 5 | |
55 #define WORDS_PER_ENTRY 17 | |
56 | |
57 static UWORD16 uplink_data[UPLINK_QUEUE_SIZE][WORDS_PER_ENTRY]; | |
58 static volatile int ul_read_ptr, ul_write_ptr; | |
59 | |
60 void tch_substitute_uplink(API *dsp_buffer) | |
61 { | |
62 int read_ptr; | |
63 int i; | |
64 | |
65 read_ptr = ul_read_ptr; | |
66 if (read_ptr == ul_write_ptr) { | |
67 /* no uplink substitution */ | |
68 l1s_dsp_com.dsp_ndb_ptr->d_tch_mode &= ~(1 << B_PLAY_UL); | |
69 return; | |
70 } | |
71 for (i = 0; i < WORDS_PER_ENTRY; i++) | |
72 dsp_buffer[i+3] = uplink_data[read_ptr][i]; | |
73 // Fill data block Header... | |
74 dsp_buffer[0] = (1 << B_BLUD); // 1st word: Set B_BLU bit. | |
75 dsp_buffer[1] = 0; // 2nd word: cleared. | |
76 dsp_buffer[2] = 0; // 3rd word: cleared. | |
77 l1s_dsp_com.dsp_ndb_ptr->d_tch_mode |= (1 << B_PLAY_UL); | |
78 /* advance the read pointer and send TCH_ULBITS_CONF */ | |
79 read_ptr++; | |
80 if (read_ptr >= UPLINK_QUEUE_SIZE) | |
81 read_ptr = 0; | |
82 ul_read_ptr = read_ptr; | |
83 send_tch_ulbits_conf(); | |
84 } | |
85 | |
86 static void handle_tch_ulbits_req(T_RVT_BUFFER pkt) | |
87 { | |
88 int write_ptr, write_next; | |
89 | |
90 write_ptr = ul_write_ptr; | |
91 write_next = write_ptr + 1; | |
92 if (write_next >= UPLINK_QUEUE_SIZE) | |
93 write_next = 0; | |
94 if (write_next == ul_read_ptr) /* queue full */ | |
95 return; | |
96 memcpy(uplink_data[write_ptr], pkt + 1, 34); | |
97 ul_write_ptr = write_next; | |
98 } | |
99 | |
100 static void handle_tch_config_req(T_RVT_BUFFER pkt) | |
38 { | 101 { |
39 UWORD8 config; | 102 UWORD8 config; |
40 T_RVT_BUFFER buf; | 103 T_RVT_BUFFER buf; |
41 T_RVT_RET rc; | 104 T_RVT_RET rc; |
42 | 105 |
63 return; | 126 return; |
64 switch (pkt[0]) { | 127 switch (pkt[0]) { |
65 case TCH_CONFIG_REQ: | 128 case TCH_CONFIG_REQ: |
66 if (pktlen != 2) | 129 if (pktlen != 2) |
67 return; | 130 return; |
68 handle_tch_config_reg(pkt); | 131 handle_tch_config_req(pkt); |
69 break; | 132 break; |
70 case TCH_ULBITS_REQ: | 133 case TCH_ULBITS_REQ: |
71 /* to be filled */ | 134 if (pktlen < 34) |
135 return; | |
136 handle_tch_ulbits_req(pkt); | |
72 break; | 137 break; |
73 } | 138 } |
74 } | 139 } |
75 | 140 |
76 void feature_tch_reroute_init() | 141 void feature_tch_reroute_init() |
77 { | 142 { |
78 rvt_register_id("TCH", &tch_reroute_rvt_id, tch_rvt_input_callback); | 143 rvt_register_id("TCH", &tch_reroute_rvt_id, tch_rvt_input_callback); |
79 tch_reroute_downlink = FALSE; | 144 tch_reroute_downlink = FALSE; |
145 ul_read_ptr = 0; | |
146 ul_write_ptr = 0; | |
80 } | 147 } |