summaryrefslogtreecommitdiff
path: root/kernel/xpp/xbus-pcm.h
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-02-04 23:00:48 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-02-04 23:00:48 +0000
commit7e068801fbf82413ac0a5e63e586c268bd457434 (patch)
tree9b61e9a4e07167e0b7d347e4336245724befa29c /kernel/xpp/xbus-pcm.h
parent29daeebad888269fa0ee2ca7e54e238c8498ca2d (diff)
Move kernel stuff to under kernel/
(merged branch /zaptel/team/tzafrir/move ) Closes issue #7117. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@3793 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/xbus-pcm.h')
-rw-r--r--kernel/xpp/xbus-pcm.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/kernel/xpp/xbus-pcm.h b/kernel/xpp/xbus-pcm.h
new file mode 100644
index 0000000..79d0078
--- /dev/null
+++ b/kernel/xpp/xbus-pcm.h
@@ -0,0 +1,106 @@
+/*
+ * Written by Oron Peled <oron@actcom.co.il>
+ * Copyright (C) 2004-2007, Xorcom
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/*
+ * This source module contains all the PCM and SYNC handling code.
+ */
+#ifndef XBUS_PCM_H
+#define XBUS_PCM_H
+
+#include "xdefs.h"
+#include <linux/proc_fs.h>
+#include <zaptel.h>
+
+#ifdef __KERNEL__
+
+enum sync_mode {
+ SYNC_MODE_NONE = 0x00,
+ SYNC_MODE_AB = 0x01, /* Astribank sync */
+ SYNC_MODE_PLL = 0x03, /* Adjust XPD's PLL according to HOST */
+ SYNC_MODE_QUERY = 0x80,
+};
+
+/*
+ * A generic timing source. Encapsulates all sampling
+ * logic, average and standard deviation computation,
+ * tick_rate computation.
+ *
+ * Each xbus has embedded instance.
+ * Also there is a global instance for external reference
+ * syncing (e.g: from zaptel)
+ */
+struct xpp_timing {
+ const char *name;
+ struct timeval timing_val;
+ unsigned long timing_count;
+ long accumulated_usec;
+ long accumulated_usec_sqr;
+ int tick_avg;
+ int tick_stddev;
+ spinlock_t lock;
+ unsigned int tick_rate;
+};
+
+void xpp_timing_init(struct xpp_timing *timing, const char *name);
+
+static inline long usec_diff(const struct timeval *tv1, const struct timeval *tv2)
+{
+ long diff_sec;
+ long diff_usec;
+
+ diff_sec = tv1->tv_sec - tv2->tv_sec;
+ diff_usec = tv1->tv_usec - tv2->tv_usec;
+ return diff_sec * 1000000 + diff_usec;
+}
+
+
+int xbus_pcm_init(struct proc_dir_entry *top);
+void xbus_pcm_shutdown(void);
+int send_pcm_frame(xbus_t *xbus, xframe_t *xframe);
+void pcm_recompute(xpd_t *xpd, xpp_line_t tmp_pcm_mask);
+void __pcm_recompute(xpd_t *xpd, xpp_line_t tmp_pcm_mask); /* non locking */
+void xframe_receive_pcm(xbus_t *xbus, xframe_t *xframe);
+void generic_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpp_line_t lines, xpacket_t *pack);
+void generic_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
+void fill_beep(u_char *buf, int num, int duration);
+const char *sync_mode_name(enum sync_mode mode);
+void xbus_set_command_timer(xbus_t *xbus, bool on);
+void xbus_request_sync(xbus_t *xbus, enum sync_mode mode);
+void got_new_syncer(xbus_t *xbus, enum sync_mode mode, int drift);
+int xbus_command_queue_tick(xbus_t *xbus);
+void xbus_reset_counters(xbus_t *xbus);
+void elect_syncer(const char *msg);
+int xpp_echocan(struct zt_chan *chan, int len);
+#ifdef ZAPTEL_SYNC_TICK
+int zaptel_sync_tick(struct zt_span *span, int is_master);
+#endif
+
+#ifdef XPP_EC_CHUNK
+extern int xpp_ec;
+#else
+#define xpp_ec 0
+#endif
+
+#endif /* __KERNEL__ */
+
+#endif /* XBUS_PCM_H */
+