diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2010-09-15 09:37:30 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2010-09-17 20:52:41 +0200 |
commit | 890e55e9f787a451ce77d6681bb7ff4bd07b9726 (patch) | |
tree | c3d8fdfb8979344f97e14e6bbc40ddb39807ee59 /src/target/firmware | |
parent | 4f53e169a22bac0c02a485c7116b5d7402be4a7c (diff) |
fw: Update dsl_load_tch_params to set the fn_sid, fn_report and fn_a5
Mix between Dieter's version in tch branch and how the TSM30 does it.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/target/firmware')
-rw-r--r-- | src/target/firmware/calypso/dsp.c | 43 | ||||
-rw-r--r-- | src/target/firmware/include/calypso/dsp.h | 7 | ||||
-rw-r--r-- | src/target/firmware/layer1/prim_tx_nb.c | 17 |
3 files changed, 47 insertions, 20 deletions
diff --git a/src/target/firmware/calypso/dsp.c b/src/target/firmware/calypso/dsp.c index 9cae1f6d..317abb59 100644 --- a/src/target/firmware/calypso/dsp.c +++ b/src/target/firmware/calypso/dsp.c @@ -34,6 +34,9 @@ #include <abb/twl3025.h> +#include <osmocore/gsm_utils.h> + + #define REG_API_CONTROL 0xfffe0000 #define APIC_R_SMODE_HOM (1 << 1) /* API is configured in HOM mode */ #define APIC_R_HINT (1 << 3) /* Host processor interrupt (DSP->MCU) */ @@ -316,11 +319,13 @@ void dsp_load_tx_task(uint16_t task, uint8_t burst_id, uint8_t tsc) dsp_api.db_w->d_ctrl_system |= tsc & 0x7; } -/* no AMR, no ciphering yet, fn does not work this way */ -void dsp_load_tch_param(uint16_t fn, uint8_t chan_mode, uint8_t chan_type, - uint8_t subchannel, uint8_t tch_loop, uint8_t sync_tch) +/* no AMR yet */ +void dsp_load_tch_param(struct gsm_time *next_time, + uint8_t chan_mode, uint8_t chan_type, uint8_t chan_sub, + uint8_t tch_loop, uint8_t sync_tch, uint8_t tn) { - uint16_t d_ctrl_tch; + uint16_t d_ctrl_tch; + uint16_t fn, a5fn0, a5fn1; /* d_ctrl_tch ---------- @@ -334,21 +339,35 @@ void dsp_load_tch_param(uint16_t fn, uint8_t chan_mode, uint8_t chan_type, bit [15] -> b_subchannel */ d_ctrl_tch = (chan_mode << B_CHAN_MODE) | (chan_type << B_CHAN_TYPE) | - (subchannel << B_SUBCHANNEL) | + (chan_sub << B_SUBCHANNEL) | (sync_tch << B_SYNC_TCH_UL) | (sync_tch << B_SYNC_TCH_DL) | (tch_loop << B_TCH_LOOP); - /* TODO (used for ciphering and TCH traffic) */ + /* used for ciphering and TCH traffic */ /* d_fn ---- - bit [0..7] -> b_fn_report - bit [8..15] -> b_fn_sid */ - dsp_api.db_w->d_fn = fn; /* write both Fn_sid, Fn_report. */ - dsp_api.db_w->a_a5fn[0] = 0; /* cyphering FN part 1 (TODO) */ - dsp_api.db_w->a_a5fn[1] = 0; /* cyphering FN part 2 (TODO) */ - dsp_api.db_w->d_ctrl_tch = d_ctrl_tch; /* Channel config. */ + bit [0..7] -> b_fn_report = (fn - (tn * 13) + 104) % 104) + bit [8..15] -> b_fn_sid = (fn % 104) */ + + fn = ((next_time->fn - (tn * 13) + 104) % 104) | + ((next_time->fn % 104) << 8); + + /* a_a5fn + ------ + byte[0] bit [0..4] -> T2 + byte[0] bit [5..10] -> T3 + byte[1] bit [0..10] -> T1 */ + + a5fn0 = ((uint16_t)next_time->t3 << 5) | + (uint16_t)next_time->t2; + a5fn1 = (uint16_t)next_time->t1; + + dsp_api.db_w->d_fn = fn; /* Fn_sid & Fn_report */ + dsp_api.db_w->a_a5fn[0] = a5fn0; /* cyphering FN part 1 */ + dsp_api.db_w->a_a5fn[1] = a5fn1; /* cyphering FN part 2 */ + dsp_api.db_w->d_ctrl_tch = d_ctrl_tch; /* Channel config. */ } #define SC_CHKSUM_VER (BASE_API_W_PAGE_0 + (2 * (0x08DB - 0x800))) diff --git a/src/target/firmware/include/calypso/dsp.h b/src/target/firmware/include/calypso/dsp.h index 4839f827..30dfad14 100644 --- a/src/target/firmware/include/calypso/dsp.h +++ b/src/target/firmware/include/calypso/dsp.h @@ -5,6 +5,8 @@ #define CAL_DSP_TGT_BB_LVL 80 +struct gsm_time; + struct dsp_api { T_NDB_MCU_DSP *ndb; T_DB_DSP_TO_MCU *db_r; @@ -25,8 +27,9 @@ void dsp_checksum_task(void); void dsp_api_memset(uint16_t *ptr, int octets); void dsp_load_afc_dac(uint16_t afc); void dsp_load_apc_dac(uint16_t apc); -void dsp_load_tch_param(uint16_t fn, uint8_t chan_mode, uint8_t chan_type, - uint8_t subchannel, uint8_t tch_loop, uint8_t sync_tch); +void dsp_load_tch_param(struct gsm_time *next_time, + uint8_t chan_mode, uint8_t chan_type, uint8_t chan_sub, + uint8_t tch_loop, uint8_t sync_tch, uint8_t tn); void dsp_end_scenario(void); void dsp_load_rx_task(uint16_t task, uint8_t burst_id, uint8_t tsc); diff --git a/src/target/firmware/layer1/prim_tx_nb.c b/src/target/firmware/layer1/prim_tx_nb.c index 6fd06546..aeb3bb1e 100644 --- a/src/target/firmware/layer1/prim_tx_nb.c +++ b/src/target/firmware/layer1/prim_tx_nb.c @@ -83,11 +83,6 @@ static int l1s_tx_cmd(uint8_t p1, uint8_t burst_id, uint16_t p3) l1s_tx_apc_helper(); - if (p1 == 0) /* DUL_DSP_TASK, one normal burst */ - dsp_load_tch_param(0, SIG_ONLY_MODE, INVALID_CHANNEL, 0, 0, 0); - else if (p1 == 2) /* DUL_DSP_TASK, four normal bursts */ - dsp_load_tch_param(0, SIG_ONLY_MODE, SDCCH_4, 0, 0, 0); - /* before sending first of the four bursts, copy data to API ram */ if (burst_id == 0) { uint16_t *info_ptr = dsp_api.ndb->a_cu; @@ -135,7 +130,17 @@ static int l1s_tx_cmd(uint8_t p1, uint8_t burst_id, uint16_t p3) msgb_free(msg); } - rfch_get_params(&l1s.next_time, &arfcn, &tsc, NULL); + rfch_get_params(&l1s.next_time, &arfcn, &tsc, &tn); + + if (p1 == 0) + /* DUL_DSP_TASK, one normal burst */ + dsp_load_tch_param(&l1s.next_time, + SIG_ONLY_MODE, INVALID_CHANNEL, 0, 0, 0, tn); + + else if (p1 == 2) + /* DUL_DSP_TASK, four normal bursts */ + dsp_load_tch_param(&l1s.next_time, + SIG_ONLY_MODE, SDCCH_4, 0, 0, 0, tn); dsp_load_tx_task(DUL_DSP_TASK, burst_id, tsc); |