@@ -66,11 +66,13 @@ process_channel_to_freq(dsd_opts* opts, dsd_state* state, int channel) {
6666 int type = state -> p25_chan_type [iden ] & 0xF ;
6767 // OP25-derived slots-per-carrier by channel type
6868 static const int slots_per_carrier [16 ] = {1 , 1 , 1 , 2 , 4 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 };
69- // Derive division only when TDMA iden is known. This matches OP25, which
70- // only divides the channel by tdma when an IDEN_UP_TDMA has populated the
71- // table. Without that knowledge, treat channel as FDMA (denom=1) .
69+ // Derive division only when TDMA iden is known. Explicit IDEN hints take
70+ // precedence over the system-level TDMA fallback so mixed P1/P2 systems do
71+ // not halve explicitly FDMA channel numbers .
7272 int denom = 1 ;
73- if ((state -> p25_chan_tdma [iden ] & 0x1 ) != 0 ) {
73+ int explicit_hint = state -> p25_chan_tdma_explicit [iden ];
74+ int use_tdma_denom = (explicit_hint == 2 || (explicit_hint == 0 && (state -> p25_chan_tdma [iden ] & 0x1 ) != 0 ));
75+ if (use_tdma_denom ) {
7476 if (type < 0 || type > 15 ) {
7577 fprintf (stderr , "\n P25 FREQ: unknown iden type %d (iden %d)" , type , iden );
7678 return 0 ;
@@ -80,7 +82,7 @@ process_channel_to_freq(dsd_opts* opts, dsd_state* state, int channel) {
8082 fprintf (stderr , "\n P25 FREQ: invalid slots/carrier for type %d" , type );
8183 return 0 ;
8284 }
83- } else {
85+ } else if ( explicit_hint != 1 ) {
8486 // Fallback: if the system is known to carry Phase 2 (TDMA) voice but
8587 // we have not yet seen an IDEN_UP_TDMA for this iden, assume 2
8688 // slots/carrier. This avoids early mis-tunes where a TDMA grant
@@ -150,11 +152,13 @@ p25_format_chan_suffix(const dsd_state* state, uint16_t chan, int slot_hint, cha
150152 int type = state -> p25_chan_type [iden ] & 0xF ;
151153 static const int slots_per_carrier [16 ] = {1 , 1 , 1 , 2 , 4 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 };
152154 int denom = 1 ;
153- if ((state -> p25_chan_tdma [iden ] & 0x1 ) != 0 ) {
155+ int explicit_hint = state -> p25_chan_tdma_explicit [iden ];
156+ int use_tdma_denom = (explicit_hint == 2 || (explicit_hint == 0 && (state -> p25_chan_tdma [iden ] & 0x1 ) != 0 ));
157+ if (use_tdma_denom ) {
154158 if (type >= 0 && type <= 15 ) {
155159 denom = slots_per_carrier [type ];
156160 }
157- } else if (state -> p25_sys_is_tdma == 1 ) {
161+ } else if (explicit_hint != 1 && state -> p25_sys_is_tdma == 1 ) {
158162 // Conservative fallback when TDMA IDEN not yet learned
159163 denom = 2 ;
160164 }
0 commit comments