[zaptel-commits] trunk r1234 - in /trunk: ./ Makefile vpm450m.c vpm450m.h wct4xxp_base.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Sat Jul 15 13:29:12 MST 2006


Author: file
Date: Sat Jul 15 15:29:11 2006
New Revision: 1234

URL: http://svn.digium.com/view/zaptel?rev=1234&view=rev
Log:
Merged revisions 1233 via svnmerge from 
https://origsvn.digium.com/svn/zaptel/branches/1.2

........
r1233 | file | 2006-07-15 15:26:53 -0500 (Sat, 15 Jul 2006) | 2 lines

Add support for loading the VPM450M firmware using hotplug from userspace. 

........

Modified:
    trunk/   (props changed)
    trunk/Makefile
    trunk/vpm450m.c
    trunk/vpm450m.h
    trunk/wct4xxp_base.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-1.2-merged (original)
+++ branch-1.2-merged Sat Jul 15 15:29:11 2006
@@ -1,1 +1,1 @@
-/branches/1.2:1-916,918-936,938-949,958,962,970,990,1004,1011,1017,1031,1033,1060,1062,1064-1066,1069,1071,1076,1079,1081,1097,1101,1151,1185,1187,1205
+/branches/1.2:1-916,918-936,938-949,958,962,970,990,1004,1011,1017,1031,1033,1060,1062,1064-1066,1069,1071,1076,1079,1081,1097,1101,1151,1185,1187,1205,1233

Modified: trunk/Makefile
URL: http://svn.digium.com/view/zaptel/trunk/Makefile?rev=1234&r1=1233&r2=1234&view=diff
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Sat Jul 15 15:29:11 2006
@@ -7,7 +7,7 @@
 
 .EXPORT_ALL_VARIABLES:
 
-.PHONY: menuselect distclean dist-clean clean version.h all _all install b410p devices programs modules linux24 linux26 xpp tests devel data stackcheck install-udev config update install-programs install-modules install-linux24 install-linux26
+.PHONY: menuselect distclean dist-clean clean version.h all _all install b410p devices programs modules linux24 linux26 xpp tests devel data stackcheck install-udev config update install-programs install-modules install-linux24 install-linux26 firmware
 
 HOSTCC=gcc
 CC=gcc
@@ -137,6 +137,7 @@
 MODULESKO:=$(MODULES:%=%.ko)
 ifeq ($(BUILDVER),linux26)
 MODULES_BUILD:=$(MODULESKO)
+HOTPLUG_FIRMWARE:=yes
 else
 MODULES_BUILD:=$(MODULESO)
 endif
@@ -152,6 +153,15 @@
 obj-m:=$(MODULESO)
 wct4xxp-objs:=wct4xxp_base.o vpm450m.o
 
+# Set this to override hotplug firmware loading and revert to classic header
+#HOTPLUG_FIRMWARE=no
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+CFLAGS+=-DHOTPLUG_FIRMWARE
+VPM450M_FIRMWARE_HEADER=
+else
+VPM450M_FIRMWARE_HEADER=vpm450m_fw.h
+endif	
+
 # Also build xpp in the subdirectory xpp/ . But only for >=2.6.10 and only 
 # for i386 or x86_64. On other archs the module will probably build but panic.
 # These lines are only meaningful when this Makefile is used as kconfig for 
@@ -181,7 +191,7 @@
 
 linux24: prereq vpm450m_fw.h $(MODULESO) $(BINS)
 
-linux26: prereq vpm450m_fw.h $(BINS)
+linux26: prereq $(VPM450M_FIRMWARE_HEADER) $(BINS)
 	@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
 
@@ -356,7 +366,7 @@
   endif
 endif
 
-install: all devices
+install: all devices firmware
 	if [ -f ztcfg ]; then \
 		$(INSTALL) -D -m 755 ztcfg $(INSTALL_PREFIX)/sbin/ztcfg; \
 	fi
@@ -413,6 +423,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: trunk/vpm450m.c
URL: http://svn.digium.com/view/zaptel/trunk/vpm450m.c?rev=1234&r1=1233&r2=1234&view=diff
==============================================================================
--- trunk/vpm450m.c (original)
+++ trunk/vpm450m.c Sat Jul 15 15:29:11 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: trunk/vpm450m.h
URL: http://svn.digium.com/view/zaptel/trunk/vpm450m.h?rev=1234&r1=1233&r2=1234&view=diff
==============================================================================
--- trunk/vpm450m.h (original)
+++ trunk/vpm450m.h Sat Jul 15 15:29:11 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: trunk/wct4xxp_base.c
URL: http://svn.digium.com/view/zaptel/trunk/wct4xxp_base.c?rev=1234&r1=1233&r2=1234&view=diff
==============================================================================
--- trunk/wct4xxp_base.c (original)
+++ trunk/wct4xxp_base.c Sat Jul 15 15:29:11 2006
@@ -42,6 +42,9 @@
 #endif
 #ifdef LINUX26
 #include <linux/moduleparam.h>
+#ifdef HOTPLUG_FIRMWARE
+#include <linux/firmware.h>
+#endif
 #endif
 #include "wct4xxp.h"
 #include "vpm450m.h"
@@ -3094,6 +3097,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;
@@ -3110,15 +3117,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 zaptel-commits mailing list