Add initial opvxa24xx sources from Raptor OpenVox tree

From GIT hash 1129c666
parent 1dda3f4d
......@@ -11,6 +11,7 @@ obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_ICE1USB) += icE1usb/
endif
ifdef CONFIG_PCI
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OPVXA24XX) += opvxa24xx/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OCT612X) += oct612x/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT4XXP) += wct4xxp/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTC4XXP) += wctc4xxp/
......
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_OPVXA24XX) += opvxa24xx.o
FIRM_DIR := ../firmware
EXTRA_CFLAGS += -I$(src)/.. -I$(src)/../oct612x/ $(shell $(src)/../oct612x/octasic-helper cflags $(src)/../oct612x) -Wno-undef
DAHDI_KERNEL_H_NAME:=kernel.h
DAHDI_KERNEL_H_PATH:=$(DAHDI_INCLUDE)/dahdi/$(DAHDI_KERNEL_H_NAME)
ifneq ($(DAHDI_KERNEL_H_PATH),)
DAHDI_SPAN_MODULE:=$(shell if grep -C 5 "struct dahdi_span {" $(DAHDI_KERNEL_H_PATH) | grep -q "struct module \*owner"; then echo "yes"; else echo "no"; fi)
DAHDI_SPAN_OPS:=$(shell if grep -q "struct dahdi_span_ops {" $(DAHDI_KERNEL_H_PATH); then echo "yes"; else echo "no"; fi)
ifeq ($(DAHDI_SPAN_MODULE),yes)
EXTRA_CFLAGS+=-DDAHDI_SPAN_MODULE
else
ifeq ($(DAHDI_SPAN_OPS),yes)
EXTRA_CFLAGS+=-DDAHDI_SPAN_OPS
endif
endif
endif
ifeq ($(HOTPLUG_FIRMWARE),yes)
EXTRA_CFLAGS+=-DHOTPLUG_FIRMWARE
endif
opvxa24xx-objs := private.o a24xx.o si321x.o si3050.o ec3000.o callerid.o busydetect.o base.o $(shell $(src)/../oct612x/octasic-helper objects ../oct612x)
ifneq ($(HOTPLUG_FIRMWARE),yes)
opvxa24xx-objs += $(FIRM_DIR)/dahdi-fw-oct6114-032.o $(FIRM_DIR)/dahdi-fw-oct6114-064.o $(FIRM_DIR)/dahdi-fw-oct6114-128.o
endif
$(obj)/$(FIRM_DIR)/dahdi-fw-oct6114-032.o: $(obj)/base.o
$(MAKE) -C $(obj)/$(FIRM_DIR) dahdi-fw-oct6114-032.o
$(obj)/$(FIRM_DIR)/dahdi-fw-oct6114-064.o: $(obj)/base.o
$(MAKE) -C $(obj)/$(FIRM_DIR) dahdi-fw-oct6114-064.o
$(obj)/$(FIRM_DIR)/dahdi-fw-oct6114-128.o: $(obj)/base.o
$(MAKE) -C $(obj)/$(FIRM_DIR) dahdi-fw-oct6114-128.o
ifdef KBUILD_EXTMOD
# We only get here on kernels 2.6.0-2.6.9 .
# For newer kernels, Kbuild will be included directly by the kernel
# build system.
include $(src)/Kbuild
else
endif
/*
* OpenVox A24xx FXS/FXO Interface Driver for Zapata Telephony interface
*
* Written by MiaoLin<miaolin@openvox.cn>
* $Id: a24xx.c 185 2010-12-14 07:58:51Z yangshugang $
* Copyright (C) 2005-2010 OpenVox Communication Co. Ltd,
*
* 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.
*
*/
#include <linux/spinlock.h>
#include <linux/jiffies.h>
#include <dahdi/kernel.h>
#include "base.h"
#include "proslic.h"
#define BIT_EC_PRESENT (1<<0)
#define VPM_DEFAULT_DTMFTHRESHOLD 1000
/* indirect_resg */
static alpha indirect_regs[] =
{
{0,255,"DTMF_ROW_0_PEAK",0x55C2},
{1,255,"DTMF_ROW_1_PEAK",0x51E6},
{2,255,"DTMF_ROW2_PEAK",0x4B85},
{3,255,"DTMF_ROW3_PEAK",0x4937},
{4,255,"DTMF_COL1_PEAK",0x3333},
{5,255,"DTMF_FWD_TWIST",0x0202},
{6,255,"DTMF_RVS_TWIST",0x0202},
{7,255,"DTMF_ROW_RATIO_TRES",0x0198},
{8,255,"DTMF_COL_RATIO_TRES",0x0198},
{9,255,"DTMF_ROW_2ND_ARM",0x0611},
{10,255,"DTMF_COL_2ND_ARM",0x0202},
{11,255,"DTMF_PWR_MIN_TRES",0x00E5},
{12,255,"DTMF_OT_LIM_TRES",0x0A1C},
{13,0,"OSC1_COEF",0x7B30},
{14,1,"OSC1X",0x0063},
{15,2,"OSC1Y",0x0000},
{16,3,"OSC2_COEF",0x7870},
{17,4,"OSC2X",0x007D},
{18,5,"OSC2Y",0x0000},
{19,6,"RING_V_OFF",0x0000},
{20,7,"RING_OSC",0x7EF0},
{21,8,"RING_X",0x0160},
{22,9,"RING_Y",0x0000},
{23,255,"PULSE_ENVEL",0x2000},
{24,255,"PULSE_X",0x2000},
{25,255,"PULSE_Y",0x0000},
//{26,13,"RECV_DIGITAL_GAIN",0x4000}, // playback volume set lower
{26,13,"RECV_DIGITAL_GAIN",0x2000}, // playback volume set lower
{27,14,"XMIT_DIGITAL_GAIN",0x4000},
//{27,14,"XMIT_DIGITAL_GAIN",0x2000},
{28,15,"LOOP_CLOSE_TRES",0x1000},
{29,16,"RING_TRIP_TRES",0x3600},
{30,17,"COMMON_MIN_TRES",0x1000},
{31,18,"COMMON_MAX_TRES",0x0200},
{32,19,"PWR_ALARM_Q1Q2",0x0ff4},
{33,20,"PWR_ALARM_Q3Q4",0x6e7e},
{34,21,"PWR_ALARM_Q5Q6",0x0ff4},
{35,22,"LOOP_CLOSURE_FILTER",0x8000},
{36,23,"RING_TRIP_FILTER",0x0320},
{37,24,"TERM_LP_POLE_Q1Q2",0x0012},
{38,25,"TERM_LP_POLE_Q3Q4",0x0012},
{39,26,"TERM_LP_POLE_Q5Q6",0x0012},
{40,27,"CM_BIAS_RINGING",0x0C00},
{41,64,"DCDC_MIN_V",0x0C00},
{42,255,"DCDC_XTRA",0x1000},
{43,66,"LOOP_CLOSE_TRES_LOW",0x1000},
};
void __a24xx_wait_just_a_bit(int foo)
{
long newjiffies;
newjiffies = jiffies + foo;
while(jiffies < newjiffies);
}
void __a24xx_setcard(void *wc_dev, int card)
{
struct a24xx_dev *dev = (struct a24xx_dev *)(wc_dev);
if (dev->curcard != card) {
__opvx_a24xx_setcard(dev->mem32, card);
dev->curcard = card;
}
}
inline void __a24xx_spi_setreg(struct a24xx_dev *wc_dev, int card, unsigned char reg, unsigned char value)
{
__opvx_a24xx_spi_setreg((void *)wc_dev, wc_dev->mem32, card, wc_dev->modtype[card], reg, value, __a24xx_setcard);
}
inline unsigned char __a24xx_spi_getreg(struct a24xx_dev *wc_dev, int card, unsigned char reg)
{
return __opvx_a24xx_spi_getreg((void *)wc_dev, wc_dev->mem32, card, wc_dev->modtype[card], reg, __a24xx_setcard);
}
int __a24xx_malloc_chunk(struct a24xx_dev *wc_dev,unsigned int frq)
{
__opvx_a24xx_set_chunk(&(wc_dev->readchunk), &(wc_dev->writechunk),frq);
wc_dev->readdma = wc_dev->writedma + frq * DAHDI_MAX_CHUNKSIZE * (MAX_NUM_CARDS) * 2;
return 0;
}
static unsigned char __translate_3215(unsigned char address)
{
int x;
for (x=0;x<sizeof(indirect_regs)/sizeof(indirect_regs[0]);x++) {
if (indirect_regs[x].address == address) {
address = indirect_regs[x].altaddr;
break;
}
}
return address;
}
int __a24xx_wait_access(struct a24xx_dev *wc_dev, int card)
{
unsigned char data = 0;
long origjiffies;
int count = 0;
#define MAX 6000 /* attempts */
origjiffies = jiffies;
/* Wait for indirect access */
while (count++ < MAX) {
data = __a24xx_spi_getreg(wc_dev, card, I_STATUS);
if (!data) {
return 0;
}
}
if(count > (MAX-1)) {
printk(" ##### Loop error (%02x) #####\n", data);
}
return 0;
}
int __a24xx_proslic_setreg_indirect(struct a24xx_dev *wc_dev, int card, unsigned char address, unsigned short data)
{
int res = -1;
/* Translate 3215 addresses */
if (wc_dev->flags[card] & FLAG_3215) {
address = __translate_3215(address);
if (address == 255) {
return 0;
}
}
if(!__a24xx_wait_access(wc_dev, card)) {
__a24xx_spi_setreg(wc_dev, card, IDA_LO,(unsigned char)(data & 0xFF));
__a24xx_spi_setreg(wc_dev, card, IDA_HI,(unsigned char)((data & 0xFF00)>>8));
__a24xx_spi_setreg(wc_dev, card, IAA,address);
res = 0;
}
return res;
}
int __a24xx_proslic_getreg_indirect(struct a24xx_dev *wc_dev, int card, unsigned char address)
{
int res = -1;
char *p=NULL;
/* Translate 3215 addresses */
if (wc_dev->flags[card] & FLAG_3215) {
address = __translate_3215(address);
if (address == 255) {
return 0;
}
}
if (!__a24xx_wait_access(wc_dev, card)) {
__a24xx_spi_setreg(wc_dev, card, IAA, address);
if (!__a24xx_wait_access(wc_dev, card)) {
unsigned char data1, data2;
data1 = __a24xx_spi_getreg(wc_dev, card, IDA_LO);
data2 = __a24xx_spi_getreg(wc_dev, card, IDA_HI);
res = data1 | (data2 << 8);
} else {
p = "Failed to wait inside\n";
}
} else {
p = "failed to wait\n";
}
if (p) {
printk("%s\n", p);
}
return res;
}
void __a24xx_vpm_setpresent(struct a24xx_dev *wc_dev)
{
wc_dev->vpm = BIT_EC_PRESENT;
if ( (wc_dev->fwversion&0xffff) > 0x3)
__opvx_a24xx_vpm_setpresent_v2(wc_dev->mem32);
else
__opvx_a24xx_vpm_setpresent(wc_dev->mem32);
printk("OpenVox VPM: Present and operational servicing %d span(s)\n", 1/*wc_dev->numspans*/);
}
void a24xx_spi_setreg(struct a24xx_dev *wc_dev, int card, unsigned char reg, unsigned char value)
{
unsigned long flags;
spin_lock_irqsave(&wc_dev->lock, flags);
__a24xx_spi_setreg(wc_dev, card, reg, value);
spin_unlock_irqrestore(&wc_dev->lock, flags);
}
unsigned char a24xx_spi_getreg(struct a24xx_dev *wc_dev, int card, unsigned char reg)
{
unsigned long flags;
unsigned char ret;
spin_lock_irqsave(&wc_dev->lock, flags);
ret = __a24xx_spi_getreg(wc_dev, card, reg);
spin_unlock_irqrestore(&wc_dev->lock, flags);
return ret;
}
static inline unsigned int a24xx_oct_in(struct a24xx_dev *wc_dev, const unsigned int addr)
{
unsigned long flags;
unsigned int ret;
spin_lock_irqsave(&wc_dev->lock, flags);
if ( (wc_dev->fwversion&0xffff) > 0x3)
ret = __opvx_a24xx_oct_in_v2(wc_dev->mem32, addr);
else
ret = __opvx_a24xx_oct_in(wc_dev->mem32, addr);
spin_unlock_irqrestore(&wc_dev->lock, flags);
return ret;
}
static inline void a24xx_oct_out(struct a24xx_dev *wc_dev, const unsigned int addr, const unsigned int value)
{
unsigned long flags;
spin_lock_irqsave(&wc_dev->lock, flags);
if ( (wc_dev->fwversion&0xffff) > 0x3)
__opvx_a24xx_oct_out_v2(wc_dev->mem32, addr, value);
else
__opvx_a24xx_oct_out(wc_dev->mem32, addr, value);
spin_unlock_irqrestore(&wc_dev->lock, flags);
}
void oct_set_reg(void *data, unsigned int reg, unsigned int val)
{
struct a24xx_dev *wc_dev = data;
a24xx_oct_out(wc_dev, reg, val);
}
unsigned int oct_get_reg(void *data, unsigned int reg)
{
struct a24xx_dev *wc_dev = data;
unsigned int ret;
ret = a24xx_oct_in(wc_dev, reg);
return ret;
}
void a24xx_reset_spi(struct a24xx_dev *wc_dev, int card)
{
unsigned long flags;
spin_lock_irqsave(&wc_dev->lock, flags);
__opvx_a24xx_reset_spi(wc_dev, card, __a24xx_setcard);
spin_unlock_irqrestore(&wc_dev->lock, flags);
}
This diff is collapsed.
This diff is collapsed.
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-1d45
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-2060
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-206a
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-207c
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-21c5
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-21cf
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-21e1
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-21ff
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-2209
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-221b
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-2ab2
/home/wanghao/dahdi-linux-complete-3.0.0+3.0.0/linux/drivers/dahdi/opvxa24xx/base.o-.text-39d7
This diff is collapsed.
/*
* OpenVox FXO Detect Busy Voice Driver for DAHDI Telephony interface
*
* Written by kevin.chen
* Copyright (C) 2012-2013 OpenVox Communication Co. Ltd,
*
* 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.
*
*/
#ifndef _BUSYDETECT_H
#define _BUSYDETECT_H
#include "base.h"
#define FRAME_SHORT_SIZE (DAHDI_CHUNKSIZE * 20)
#define SAMPLE_PER_SEC 8000
#define TOTAL_CARDS 120
#define SIN_DIVISION 128
static const short sin_table[] =
{
201,
603,
1005,
1407,
1809,
2210,
2611,
3012,
3412,
3812,
4211,
4609,
5007,
5404,
5800,
6195,
6590,
6983,
7376,
7767,
8157,
8546,
8933,
9319,
9704,
10088,
10469,
10850,
11228,
11605,
11980,
12354,
12725,
13095,
13463,
13828,
14192,
14553,
14912,
15269,
15624,
15976,
16326,
16673,
17018,
17361,
17700,
18037,
18372,
18703,
19032,
19358,
19681,
20001,
20318,
20632,
20943,
21251,
21555,
21856,
22154,
22449,
22740,
23028,
23312,
23593,
23870,
24144,
24414,
24680,
24943,
25202,
25457,
25708,
25956,
26199,
26439,
26674,
26906,
27133,
27357,
27576,
27791,
28002,
28209,
28411,
28610,
28803,
28993,
29178,
29359,
29535,
29707,
29875,
30038,
30196,
30350,
30499,
30644,
30784,
30920,
31050,
31177,
31298,
31415,
31527,
31634,
31737,
31834,
31927,
32015,
32099,
32177,
32251,
32319,
32383,
32442,
32496,
32546,
32590,
32629,
32664,
32693,
32718,
32738,
32753,
32762,
32767,
32767
};
/* Level index range -30 ~ 0, step 1 */
#define MIN_INDEX_LEVEL -30
#define MAX_INDEX_LEVEL 0
#define STEP_LEVEL 1
static const short gain_table[] = {
722,
810,
909,
1020,
1144,
1284,
1440,
1616,
1813,
2034,
2283,
2561,
2874,
3224,
3618,
4059,
4554,
5110,
5734,
6433,
7218,
8099,
9087,
10196,
11440,
12836,
14402,
16160,
18132,
20344,
22826,
};
/* Frequency index range 300 ~ 700, step 5 */
#define MIN_INDEX_FREQ 300
#define MAX_INDEX_FREQ 700
#define STEP_FREQ 5
static const short fac_table[] = {
31861,
31830,
31800,
31768,
31737,
31704,
31672,
31638,
31605,
31570,
31536,
31501,
31465,
31429,
31392,
31355,
31318,
31279,
31241,
31202,
31162,
31122,
31082,
31041,
30999,
30958,
30915,
30872,
30829,
30785,
30741,
30696,
30651,
30605,
30559,
30512,
30465,
30417,
30369,
30321,
30272,
30222,
30172,
30122,
30071,
30020,
29968,
29916,
29863,
29810,
29756,
29702,
29648,
29593,
29537,
29481,
29425,
29368,
29311,
29253,
29195,
29136,
29077,
29017,
28957,
28897,
28836,
28775,
28713,
28651,
28588,
28525,
28462,
28398,
28333,
28268,
28203,
28137,
28071,
28005,
27938,
};
/* busydetect.c */
void parser_busy_silent_process(struct a24xx *wc, int is_write);
int init_busydetect(struct a24xx *wc, const char *opermode);
void destroy_busydetect(struct a24xx *wc);
/* callerid.c */
void parser_callerid_process(struct a24xx *wc, int cidbuflen, int cidtimeout);
void set_cidstart_desc_from_chan_num(int spanno, int channo, int cid_state);
void set_signal_unknown_from_chan_num(int spanno, int channo);
int is_callerid_disable(int spanno, int channo);
char is_ring_delay_operation(int spanno, int channo);
void reset_parser_variable_from_chan_num(int spanno, int channo);
int init_callerid(struct a24xx *wc);
void destroy_callerid(struct a24xx *wc);
#endif /* _BUSYDETECT_H */
This diff is collapsed.
This diff is collapsed.
/*
* OpenVox A24xx FXS/FXO Interface Driver for Zapata Telephony interface
*
* Written by MiaoLin<miaolin@openvox.cn>
* Written by mark.liu<mark.liu@openvox.cn>
* $Id: ec3000.h 165 2010-12-09 05:38:49Z liuyuan $
*
* Copyright (C) 2005-2010 OpenVox Communication Co. Ltd,
*
* 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.
*
*/
#ifndef _EC3000_H_
#define _EC3000_H_
#include <linux/firmware.h>
struct ec;
/* From driver */
unsigned int oct_get_reg(void *data, unsigned int reg);
void oct_set_reg(void *data, unsigned int reg, unsigned int val);
/* From vpm450m */