From 4db3ee4f7f9377f7c6543c5cb21fc277f0355c6e Mon Sep 17 00:00:00 2001 From: qwell Date: Tue, 24 Apr 2007 18:33:29 +0000 Subject: Backport pre-echocan debugging for ztmonitor git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2434 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- jpah.h | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 jpah.h (limited to 'jpah.h') diff --git a/jpah.h b/jpah.h new file mode 100644 index 0000000..f72c5fa --- /dev/null +++ b/jpah.h @@ -0,0 +1,104 @@ +/* + * ECHO_CAN_JP1 + * + * by Jason Parker + * + * Based upon mg2ec.h - sort of. + * This "echo can" will completely hose your audio. + * Don't use it unless you're absolutely sure you know what you're doing. + * + * Copyright (C) 2007, Digium, Inc. + * + * This program is free software and may be used and + * distributed according to the terms of the GNU + * General Public License, incorporated herein by + * reference. + * + */ + +#ifndef _JP_ECHO_H +#define _JP_ECHO_H + +#ifdef __KERNEL__ +#include +#include +#define MALLOC(a) kmalloc((a), GFP_KERNEL) +#define FREE(a) kfree(a) +#else +#include +#include +#include +#include +#define MALLOC(a) malloc(a) +#define FREE(a) free(a) +#endif + +/* Echo canceller definition */ +struct echo_can_state { + /* an arbitrary ID for this echo can - this really should be settable from the calling channel... */ + int id; + + /* absolute time - aka. sample number index - essentially the number of samples since this can was init'ed */ + int i_d; +}; + +static void echo_can_init(void) +{ + printk("Zaptel Audio Hoser: JP1\n"); +} + +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "JP1", len); +} + +static void echo_can_shutdown(void) +{ +} + +static inline void init_cc(struct echo_can_state *ec) +{ + void *ptr = ec; + unsigned long tmp; + /* Double-word align past end of state */ + ptr += sizeof(struct echo_can_state); + tmp = (unsigned long)ptr; + tmp += 3; + tmp &= ~3L; + ptr = (void *)tmp; +} + +static inline void echo_can_free(struct echo_can_state *ec) +{ + FREE(ec); +} + +static inline short echo_can_update(struct echo_can_state *ec, short iref, short isig) +{ + static int blah = 0; + + if (blah < 2) { + blah++; + return 0; + } else { + blah = (blah + 1) % 3; + return isig; + } +} + +static inline struct echo_can_state *echo_can_create(int len, int adaption_mode) +{ + struct echo_can_state *ec; + ec = (struct echo_can_state *)MALLOC(sizeof(struct echo_can_state) + 4); /* align */ + if (ec) { + memset(ec, 0, sizeof(struct echo_can_state) + 4); /* align */ + init_cc(ec); + } + return ec; +} + +static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val) +{ + return 0; +} +#endif -- cgit v1.2.3