blob: 49bbb62d70aba4cffa59f34c7d4b10f2a1cd7b06 [file] [log] [blame]
Andreas Eversberga23c7ee2012-12-18 10:47:28 +01001#ifndef _SYSMO_L1_IF_H
2#define _SYSMO_L1_IF_H
3
4#include <osmocom/core/select.h>
5#include <osmocom/core/write_queue.h>
6#include <osmocom/core/gsmtap_util.h>
7#include <osmocom/gsm/gsm_utils.h>
8#include "femtobts.h"
9
10enum {
11 MQ_SYS_READ,
12 MQ_L1_READ,
13#ifndef HW_SYSMOBTS_V1
14 MQ_TCH_READ,
15 MQ_PDTCH_READ,
16#endif
17 _NUM_MQ_READ
18};
19
20enum {
21 MQ_SYS_WRITE,
22 MQ_L1_WRITE,
23#ifndef HW_SYSMOBTS_V1
24 MQ_TCH_WRITE,
25 MQ_PDTCH_WRITE,
26#endif
27 _NUM_MQ_WRITE
28};
29
30struct femtol1_hdl {
31 struct gsm_time gsm_time;
32 uint32_t hLayer1; /* handle to the L1 instance in the DSP */
33 uint32_t dsp_trace_f;
34 int clk_cal;
35 uint8_t clk_src;
36 struct llist_head wlc_list;
37
38 struct gsmtap_inst *gsmtap;
39 uint32_t gsmtap_sapi_mask;
40
41 void *priv; /* user reference */
42
43 struct osmo_timer_list alive_timer;
44 unsigned int alive_prim_cnt;
45
46 struct osmo_fd read_ofd[_NUM_MQ_READ]; /* osmo file descriptors */
47 struct osmo_wqueue write_q[_NUM_MQ_WRITE];
48
49 struct {
50 uint8_t dsp_version[3];
51 uint8_t fpga_version[3];
52 uint32_t band_support; /* bitmask of GSM_BAND_* */
53 } hw_info;
54};
55
56#define msgb_l1prim(msg) ((GsmL1_Prim_t *)(msg)->l1h)
57#define msgb_sysprim(msg) ((SuperFemto_Prim_t *)(msg)->l1h)
58
59typedef int l1if_compl_cb(struct msgb *l1_msg, void *data);
60
61/* send a request primitive to the L1 and schedule completion call-back */
62int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg,
63 int is_system_prim, l1if_compl_cb *cb, void *data);
64
65int l1if_reset(struct femtol1_hdl *hdl);
66int l1if_activate_rf(struct femtol1_hdl *hdl, int on);
67int l1if_set_trace_flags(struct femtol1_hdl *hdl, uint32_t flags);
68int l1if_set_txpower(struct femtol1_hdl *fl1h, float tx_power);
69
70struct msgb *l1p_msgb_alloc(void);
71struct msgb *sysp_msgb_alloc(void);
72
73uint32_t l1if_lchan_to_hLayer2(struct gsm_lchan *lchan);
74struct gsm_lchan *l1if_hLayer2_to_lchan(struct gsm_bts_trx *trx, uint32_t hLayer2);
75
76/* tch.c */
77int l1if_tch_rx(struct gsm_lchan *lchan, struct msgb *l1p_msg);
78int l1if_tch_fill(struct gsm_lchan *lchan, uint8_t *l1_buffer);
79struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan);
80
81#endif /* _SYSMO_L1_IF_H */