[svn-commits] branch 1.2 r1233 - in /branches/1.2: Makefile vpm450m.c vpm450m.h wct4xxp_base.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sat Jul 15 13:26:54 MST 2006


Author: file
Date: Sat Jul 15 15:26:53 2006
New Revision: 1233

URL: http://svn.digium.com/view/zaptel?rev=1233&view=rev
Log:
Add support for loading the VPM450M firmware using hotplug from userspace. 

Modified:
    branches/1.2/Makefile
    branches/1.2/vpm450m.c
    branches/1.2/vpm450m.h
    branches/1.2/wct4xxp_base.c

Modified: branches/1.2/Makefile
URL: http://svn.digium.com/view/zaptel/branches/1.2/Makefile?rev=1233&r1=1232&r2=1233&view=diff
==============================================================================
--- branches/1.2/Makefile (original)
+++ branches/1.2/Makefile Sat Jul 15 15:26:53 2006
@@ -70,6 +70,7 @@
     DYNFS=yes
     UDEVRULES=yes
   endif
+  HOTPLUG_FIRMWARE:=yes
 endif
 
 CHKCONFIG:=$(shell sh -c 'type -p chkconfig' 2> /dev/null)
@@ -79,6 +80,16 @@
 
 ifneq ($(wildcard .version),)
   ZAPTELVERSION:=$(shell cat .version)
+endif
+
+# Set this to override hotplug firmware loading and revert to classic header based
+#HOTPLUG_FIRMWARE=no
+
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+  CFLAGS+=-DHOTPLUG_FIRMWARE
+  VPM450M_FIRMWARE_HEADER=
+else
+  VPM450M_FIRMWARE_HEADER=vpm450m_fw.h
 endif
 
 # CVS mirrors of SVN have .svnrevision files showing
@@ -133,7 +144,7 @@
 
 linux24: prereq vpm450m_fw.h $(MODULESO) $(BINS)
 
-linux26: prereq vpm450m_fw.h $(BINS)
+linux26: prereq $(VPM450M_FIRMWARE_HEADER) $(BINS)
 	@echo $(KSRC)
 	@if [ -z "$(KSRC)" -o ! -d "$(KSRC)" ]; then echo "You do not appear to have the sources for the $(KVERS) kernel installed."; exit 1 ; fi
 	$(KMAKE) modules
@@ -314,7 +325,7 @@
   endif
 endif
 
-install: all devices
+install: all devices firmware
 	install -D -m 755 ztcfg $(INSTALL_PREFIX)/sbin/ztcfg
 	if [ -f sethdlc-new ]; then \
 		install -D -m 755 sethdlc-new $(INSTALL_PREFIX)/sbin/sethdlc; \
@@ -358,6 +369,18 @@
 
 install-udev: devices
 
+firmware:
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+	if [ -d /usr/lib/hotplug/firmware ]; then \
+		install -D -m 644 *.ima /usr/lib/hotplug/firmware ; \
+	elif [ -d /lib/firmware ]; then \
+		install -D -m 644 *.ima /lib/firmware ; \
+	fi
+	@echo "Installed firmware"
+else
+	@echo "Not installing firmware because we are not using hotplug firmware"
+endif
+
 config:
 	if [ -d $(INSTALL_PREFIX)/etc/rc.d/init.d ]; then \
 		install -D -m 755 zaptel.init $(INSTALL_PREFIX)/etc/rc.d/init.d/zaptel; \

Modified: branches/1.2/vpm450m.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/vpm450m.c?rev=1233&r1=1232&r2=1233&view=diff
==============================================================================
--- branches/1.2/vpm450m.c (original)
+++ branches/1.2/vpm450m.c Sat Jul 15 15:26:53 2006
@@ -65,6 +65,9 @@
 
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
+#ifdef HOTPLUG_FIRMWARE
+#include <linux/firmware.h>
+#endif
 
 /****************************  PRIVATE FUNCTIONS  ****************************/
 
@@ -29253,7 +29256,9 @@
 	return cOCT6100_ERR_OK;
 }
 
+#ifndef HOTPLUG_FIRMWARE
 #include "vpm450m_fw.h"
+#endif
 
 #define SOUT_G168_1100GB_ON 0x40000004
 #define SOUT_DTMF_1 0x40000011
@@ -29515,7 +29520,11 @@
 	return 0;
 }
 
+#ifdef HOTPLUG_FIRMWARE
+struct vpm450m *init_vpm450m(void *wc, int *isalaw, const struct firmware *firmware)
+#else
 struct vpm450m *init_vpm450m(void *wc, int *isalaw)
+#endif
 {
 	tOCT6100_CHIP_OPEN ChipOpen;
 	tOCT6100_GET_INSTANCE_SIZE InstanceSize;
@@ -29536,10 +29545,15 @@
 	/* Setup Chip Open Parameters */
 	ChipOpen.ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ;
 	Oct6100GetInstanceSizeDef(&InstanceSize);
-	
+
+	ChipOpen.pProcessContext = wc;
+#ifdef HOTPLUG_FIRMWARE
+	ChipOpen.pbyImageFile = firmware->data;
+	ChipOpen.ulImageSize = firmware->size;
+#else
 	ChipOpen.pbyImageFile = vpm450m_fw;
-	ChipOpen.pProcessContext = wc;
-	ChipOpen.ulImageSize = sizeof(vpm450m_fw); 
+	ChipOpen.ulImageSize = sizeof(vpm450m_fw);
+#endif	
 	ChipOpen.fEnableMemClkOut = TRUE;
 	ChipOpen.ulMemClkFreq = cOCT6100_MCLK_FREQ_133_MHZ;
 	ChipOpen.ulMaxChannels = 128;

Modified: branches/1.2/vpm450m.h
URL: http://svn.digium.com/view/zaptel/branches/1.2/vpm450m.h?rev=1233&r1=1232&r2=1233&view=diff
==============================================================================
--- branches/1.2/vpm450m.h (original)
+++ branches/1.2/vpm450m.h Sat Jul 15 15:26:53 2006
@@ -11,14 +11,20 @@
 
 
 struct vpm450m;
-
+#ifdef HOTPLUG_FIRMWARE
+struct firmware;
+#endif
 
 /* From driver */
 extern unsigned int oct_get_reg(void *data, unsigned int reg);
 extern void oct_set_reg(void *data, unsigned int reg, unsigned int val);
 
 /* From vpm450m2 */
+#ifdef HOTPLUG_FIRMWARE
+extern struct vpm450m *init_vpm450m(void *wc, int *isalaw, const struct firmware *firmware);
+#else
 extern struct vpm450m *init_vpm450m(void *wc, int *isalaw);
+#endif
 extern void vpm450m_setec(struct vpm450m *instance, int channel, int eclen);
 extern void vpm450m_setdtmf(struct vpm450m *instance, int channel, int dtmfdetect, int dtmfmute);
 extern int vpm450m_checkirq(struct vpm450m *vpm450m);

Modified: branches/1.2/wct4xxp_base.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/wct4xxp_base.c?rev=1233&r1=1232&r2=1233&view=diff
==============================================================================
--- branches/1.2/wct4xxp_base.c (original)
+++ branches/1.2/wct4xxp_base.c Sat Jul 15 15:26:53 2006
@@ -40,6 +40,9 @@
 #endif
 #ifdef LINUX26
 #include <linux/moduleparam.h>
+#ifdef HOTPLUG_FIRMWARE
+#include <linux/firmware.h>
+#endif
 #endif
 #include "wct4xxp.h"
 #include "vpm450m.h"
@@ -2671,6 +2674,10 @@
 	unsigned int check1, check2;
 	int laws[4] = { 0, };
 	int x;
+#ifdef HOTPLUG_FIRMWARE
+	const struct firmware *firmware;
+#endif
+
 	if (!vpmsupport) {
 		printk("VPM450M: Support Disabled\n");
 		return;
@@ -2687,15 +2694,31 @@
 		printk("VPM450: Not Present\n");
 		return;
 	}
+#ifdef HOTPLUG_FIRMWARE
+	if (request_firmware(&firmware, "OCT6114-128D.ima", &wc->dev->dev) != 0 || !firmware) {
+		printk("VPM450M: Firmware not found to be loaded\n");
+		return;
+	}
+	printk("VPM450: Firmware of size %d found\n", firmware->size);
+#else
+	printk("VPM450: Using classic method of loading firmware\n");
+#endif
 	/* Setup alaw vs ulaw rules */
 	for (x=0;x<wc->numspans;x++) {
 		if (wc->tspans[x]->span.channels > 24)
 			laws[x] = 1;
 	}
+#ifdef HOTPLUG_FIRMWARE
+	if (!(wc->vpm450m = init_vpm450m(wc, laws, firmware))) {
+#else
 	if (!(wc->vpm450m = init_vpm450m(wc, laws))) {
+#endif
 		printk("VPM450: Failed to initialize\n");
 		return;
 	}
+#ifdef HOTPLUG_FIRMWARE
+	release_firmware(firmware);
+#endif
 	wc->vpm = T4_VPM_PRESENT;
 	printk("VPM450: Present and operational servicing %d span(s)\n", vpmspans);
 }



More information about the svn-commits mailing list