summaryrefslogtreecommitdiff
path: root/xpp/utils
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-09-04 23:53:30 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-09-04 23:53:30 +0000
commitd1dca1a4fed07a51f4a2b013902eca069ae1734c (patch)
treedaeb458935244fae1a2293068a46140e694fafc0 /xpp/utils
parentee5282ac097e112e9baf1c760211e6ee0f2a4fe8 (diff)
* Re-add calibrate_slics to the FXS initialization process
* xpp/utils: Build and install init_fxo_modes . Data is based on data from wctdm.c . TODO: a separate daa.h? * Fail the script if automatic calibration has failed. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1394 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils')
-rw-r--r--xpp/utils/Makefile16
-rw-r--r--xpp/utils/print_modes.c44
2 files changed, 57 insertions, 3 deletions
diff --git a/xpp/utils/Makefile b/xpp/utils/Makefile
index d840333..7dc4fa2 100644
--- a/xpp/utils/Makefile
+++ b/xpp/utils/Makefile
@@ -10,11 +10,13 @@ DATADIR = /usr/share/zaptel
MANDIR = /usr/share/man/man8
HOTPLUG_USB_DIR = /etc/hotplug/usb
-DATA_FILES = $(wildcard ../init_data_*.cmd *.hex)
+DATA_FILES = $(wildcard ../init_data_*.cmd *.hex) init_fxo_modes
+
+WCTDM=../../wctdm.c
CFLAGS = -g -Wall $(EXTRA_CFLAGS)
-TARGETS = libhexfile.a fpga_load test_parse
+TARGETS = libhexfile.a fpga_load test_parse init_fxo_modes
all: $(TARGETS)
@@ -23,7 +25,7 @@ install: all
$(INSTALL) genzaptelconf fpga_load $(DESTDIR)$(BINDIR)/
$(INSTALL) -d $(DESTDIR)$(DATADIR)
$(INSTALL_DATA) $(DATA_FILES) $(DESTDIR)$(DATADIR)/
- $(INSTALL) ../initialize_registers $(DESTDIR)$(DATADIR)/
+ $(INSTALL) ../initialize_registers ../calibrate_slics $(DESTDIR)$(DATADIR)/
$(INSTALL) -d $(DESTDIR)$(MANDIR)
$(INSTALL_DATA) fpga_load.8 genzaptelconf.8 $(DESTDIR)$(MANDIR)/
$(INSTALL) -d $(DESTDIR)$(HOTPLUG_USB_DIR)
@@ -46,5 +48,13 @@ test_parse.o: test_parse.c hexfile.h
test_parse: test_parse.o libhexfile.a
$(CC) -L. -o $@ $@.o $(EXTRA_LIBS) -lhexfile -lusb
+print_modes.o: wctdm_fxomodes.h
+
+wctdm_fxomodes.h: $(WCTDM)
+ perl -n -e 'print if (/^static struct fxo_mode {$$/ .. /};$$/)' $(WCTDM) >$@
+
+init_fxo_modes: print_modes
+ ./$^ >$@
+
clean:
$(RM) *.o $(TARGETS)
diff --git a/xpp/utils/print_modes.c b/xpp/utils/print_modes.c
new file mode 100644
index 0000000..473bafb
--- /dev/null
+++ b/xpp/utils/print_modes.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+
+#include "wctdm_fxomodes.h"
+
+int main() {
+ size_t i;
+
+ printf("case \"$mode\" in\n");
+ for (i=0; i<(sizeof(fxo_modes)/sizeof(struct fxo_mode)); i++) {
+ if (fxo_modes[i].name == NULL) break;
+ int reg16=0, reg26=0, reg30=0, reg31=0x3a;
+ char ring_osc[BUFSIZ]="", ring_x[BUFSIZ] = "";
+
+ reg16 |= (fxo_modes[i].ohs << 6);
+ reg16 |= (fxo_modes[i].rz << 1);
+ reg16 |= (fxo_modes[i].rt);
+
+ reg26 |= (fxo_modes[i].dcv << 6);
+ reg26 |= (fxo_modes[i].mini << 4);
+ reg26 |= (fxo_modes[i].ilim << 1);
+
+ reg30 = (fxo_modes[i].acim);
+
+ reg31 |= (fxo_modes[i].ohs2 << 3);
+
+ if (fxo_modes[i].ring_osc !=0 ) {
+ snprintf(ring_osc, BUFSIZ, "; ring_osc=\"%02X %02X\"",
+ (fxo_modes[i].ring_osc)>>8,
+ (fxo_modes[i].ring_osc)&&0xFF
+ );
+ }
+ if (fxo_modes[i].ring_x !=0 ) {
+ snprintf(ring_x, BUFSIZ, "; ring_x=\"%02X %02X\"",
+ (fxo_modes[i].ring_x)>>8,
+ (fxo_modes[i].ring_x)&&0xFF
+ );
+ }
+
+ printf("%s)\treg16=%02X; reg26=%02X; reg30=%02X; reg31=%02X%s%s;;\n",
+ fxo_modes[i].name, reg16, reg26, reg30, reg31, ring_osc, ring_x);
+ }
+ printf("esac\n");
+ return 0;
+}