blob: 9555932e9d2b7dd3d7aecd9fdaab1214a42ca7db [file] [log] [blame]
Harald Welte065dab82022-11-29 23:13:06 +01001#pragma once
2
3#include <osmocom/core/bits.h>
4
5/* See Section 5.1.2.1 of ITU-T V.110 */
6#define MAX_D_BITS 48
7#define MAX_E_BITS 7
8#define MAX_S_BITS 9
9#define MAX_X_BITS 2
10
11/*! a 'decoded' representation of a single V.110 frame. contains unpacket D, E, S and X bits */
12struct osmo_v110_decoded_frame {
13 ubit_t d_bits[MAX_D_BITS];
14 ubit_t e_bits[MAX_E_BITS];
15 ubit_t s_bits[MAX_S_BITS];
16 ubit_t x_bits[MAX_X_BITS];
17};
18
19int osmo_v110_decode_frame(struct osmo_v110_decoded_frame *fr, const ubit_t *ra_bits, size_t n_bits);
20int osmo_v110_encode_frame(ubit_t *ra_bits, size_t n_bits, const struct osmo_v110_decoded_frame *fr);
21
22void osmo_v110_ubit_dump(FILE *outf, const ubit_t *fr, size_t in_len);
23
24
25/*! enum for each supported V.110 synchronous RA1 function (one for each user bitrate) */
26enum osmo_v100_sync_ra1_rate {
27 OSMO_V110_SYNC_RA1_600,
28 OSMO_V110_SYNC_RA1_1200,
29 OSMO_V110_SYNC_RA1_2400,
30 OSMO_V110_SYNC_RA1_4800,
31 OSMO_V110_SYNC_RA1_7200,
32 OSMO_V110_SYNC_RA1_9600,
33 OSMO_V110_SYNC_RA1_12000,
34 OSMO_V110_SYNC_RA1_14400,
35 OSMO_V110_SYNC_RA1_19200,
36 OSMO_V110_SYNC_RA1_24000,
37 OSMO_V110_SYNC_RA1_28800,
38 OSMO_V110_SYNC_RA1_38400,
39 _NUM_OSMO_V110_SYNC_RA1
40};
41
Vadim Yanitskiy06922fa2024-01-16 19:56:02 +070042extern const ubit_t osmo_v110_e1e2e3[_NUM_OSMO_V110_SYNC_RA1][3];
43
44#define osmo_v110_e1e2e3_set(e_bits, rate) \
45 memcpy(e_bits, osmo_v110_e1e2e3[rate], 3)
46#define osmo_v110_e1e2e3_cmp(e_bits, rate) \
47 memcmp(e_bits, osmo_v110_e1e2e3[rate], 3)
48
Harald Welte065dab82022-11-29 23:13:06 +010049int osmo_v110_sync_ra1_get_user_data_chunk_bitlen(enum osmo_v100_sync_ra1_rate rate);
50int osmo_v110_sync_ra1_get_user_data_rate(enum osmo_v100_sync_ra1_rate rate);
51int osmo_v110_sync_ra1_get_intermediate_rate(enum osmo_v100_sync_ra1_rate rate);
52
53int osmo_v110_sync_ra1_user_to_ir(enum osmo_v100_sync_ra1_rate rate, struct osmo_v110_decoded_frame *fr,
54 const ubit_t *d_in, size_t in_len);
55
56int osmo_v110_sync_ra1_ir_to_user(enum osmo_v100_sync_ra1_rate rate, ubit_t *d_out, size_t out_len,
57 const struct osmo_v110_decoded_frame *fr);