| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef XBUS_PCM_H |
| 27 |
#define XBUS_PCM_H |
| 28 |
|
| 29 |
#include "xdefs.h" |
| 30 |
#include <linux/proc_fs.h> |
| 31 |
#include <dahdi/kernel.h> |
| 32 |
|
| 33 |
#ifdef __KERNEL__ |
| 34 |
|
| 35 |
enum sync_mode { |
| 36 |
SYNC_MODE_NONE = 0x00, |
| 37 |
SYNC_MODE_AB = 0x01, |
| 38 |
SYNC_MODE_PLL = 0x03, |
| 39 |
SYNC_MODE_QUERY = 0x80, |
| 40 |
}; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
struct xpp_ticker { |
| 51 |
int count; |
| 52 |
int cycle; |
| 53 |
ktime_t first_sample; |
| 54 |
ktime_t last_sample; |
| 55 |
int tick_period; |
| 56 |
spinlock_t lock; |
| 57 |
}; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
struct xpp_drift { |
| 64 |
int delta_tick; |
| 65 |
int lost_ticks; |
| 66 |
int lost_tick_count; |
| 67 |
int sync_inaccuracy; |
| 68 |
ktime_t last_lost_tick; |
| 69 |
long delta_sum; |
| 70 |
int offset_prev; |
| 71 |
int offset_range; |
| 72 |
int offset_min; |
| 73 |
int offset_max; |
| 74 |
int min_speed; |
| 75 |
int max_speed; |
| 76 |
spinlock_t lock; |
| 77 |
}; |
| 78 |
|
| 79 |
void xpp_drift_init(xbus_t *xbus); |
| 80 |
|
| 81 |
static inline long usec_diff(const ktime_t *tv1, |
| 82 |
const ktime_t *tv2) |
| 83 |
{ |
| 84 |
return ktime_us_delta(*tv1, *tv2); |
| 85 |
} |
| 86 |
|
| 87 |
int xbus_pcm_init(void *top); |
| 88 |
void xbus_pcm_shutdown(void); |
| 89 |
int send_pcm_frame(xbus_t *xbus, xframe_t *xframe); |
| 90 |
void pcm_recompute(xpd_t *xpd, xpp_line_t tmp_pcm_mask); |
| 91 |
void xframe_receive_pcm(xbus_t *xbus, xframe_t *xframe); |
| 92 |
void update_wanted_pcm_mask(xpd_t *xpd, xpp_line_t new_mask, uint new_pcm_len); |
| 93 |
void generic_card_pcm_recompute(xpd_t *xpd, xpp_line_t pcm_mask); |
| 94 |
void generic_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack); |
| 95 |
void generic_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack); |
| 96 |
int generic_timing_priority(xpd_t *xpd); |
| 97 |
int generic_echocancel_timeslot(xpd_t *xpd, int pos); |
| 98 |
int generic_echocancel_setmask(xpd_t *xpd, xpp_line_t ec_mask); |
| 99 |
void fill_beep(u_char *buf, int num, int duration); |
| 100 |
const char *sync_mode_name(enum sync_mode mode); |
| 101 |
void xbus_set_command_timer(xbus_t *xbus, bool on); |
| 102 |
void xbus_request_sync(xbus_t *xbus, enum sync_mode mode); |
| 103 |
void got_new_syncer(xbus_t *xbus, enum sync_mode mode, int drift); |
| 104 |
int xbus_command_queue_tick(xbus_t *xbus); |
| 105 |
void xbus_reset_counters(xbus_t *xbus); |
| 106 |
void elect_syncer(const char *msg); |
| 107 |
int exec_sync_command(const char *buf, size_t count); |
| 108 |
int fill_sync_string(char *buf, size_t count); |
| 109 |
#ifdef DAHDI_SYNC_TICK |
| 110 |
void dahdi_sync_tick(struct dahdi_span *span, int is_master); |
| 111 |
#endif |
| 112 |
|
| 113 |
#ifdef DEBUG_PCMTX |
| 114 |
extern int pcmtx; |
| 115 |
extern int pcmtx_chan; |
| 116 |
#endif |
| 117 |
|
| 118 |
#endif |
| 119 |
|
| 120 |
#endif |