/* * Dummy Zaptel Driver for Zapata Telephony interface * * Required: usb-uhci module and kernel > 2.4.4 OR kernel > 2.6.0 * * Written by Robert Pleh * 2.6 version by Tony Hoyle * Unified by Mark Spencer * * Copyright (C) 2002, Hermes Softlab * Copyright (C) 2004, Digium, Inc. * * 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. * */ /* * This source works on only Kurouto-Shikou Kurobox. * Big Modification from original ztdymmy. DO NOT use for another platform. * For More information, http://voip.gapj.net * */ #include #ifndef VERSION_CODE # define VERSION_CODE(vers,rel,seq) ( ((vers)<<16) | ((rel)<<8) | (seq) ) #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,4,5) # error "This kernel is too old: not supported by this file" #endif #include #include #include #include #include #include "zaptel.h" #include #include #include #ifndef LINUX_VERSION_CODE # include #endif #ifndef VERSION_CODE # define VERSION_CODE(vers,rel,seq) ( ((vers)<<16) | ((rel)<<8) | (seq) ) #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,4,5) # error "This kernel is too old: not supported by this file" #endif struct ztdummy { struct zt_span span; struct zt_chan chan; }; static int cnt1; static struct ztdummy *ztd; static int debug = 0; static struct timer_list timer; static void ztdummy_timer(unsigned long param) { for(cnt1=0;cnt1<10;cnt1++){ zt_receive(&ztd->span); zt_transmit(&ztd->span); } timer.expires = jiffies + 1; add_timer(&timer); } static int ztdummy_initialize(struct ztdummy *ztd) { /* Zapata stuff */ sprintf(ztd->span.name, "ZTDUMMY/1"); sprintf(ztd->span.desc, "%s %d", ztd->span.name, 1); sprintf(ztd->chan.name, "ZTDUMMY/%d/%d", 1, 0); ztd->chan.chanpos = 1; ztd->span.chans = &ztd->chan; ztd->span.channels = 0; /* no channels on our span */ ztd->span.deflaw = ZT_LAW_MULAW; init_waitqueue_head(&ztd->span.maintq); ztd->span.pvt = ztd; ztd->chan.pvt = ztd; if (zt_register(&ztd->span, 0)) { return -1; } return 0; } int init_module(void) { ztd = kmalloc(sizeof(struct ztdummy), GFP_KERNEL); if (ztd == NULL) { printk("ztdummy_kb: Unable to allocate memory\n"); return -ENOMEM; } memset(ztd, 0x0, sizeof(struct ztdummy)); if (ztdummy_initialize(ztd)) { printk("ztdummy_kb: Unable to intialize zaptel driver\n"); kfree(ztd); return -ENODEV; } init_timer(&timer); timer.function = ztdummy_timer; timer.expires = jiffies + 1; add_timer(&timer); if (debug) printk("ztdummy_kb: init() finished\n"); return 0; } void cleanup_module(void) { del_timer(&timer); zt_unregister(&ztd->span); kfree(ztd); if (debug) printk("ztdummy_kb: cleanup() finished\n"); } MODULE_PARM(debug, "i"); /*MODULE_PARM(monitor, "i");*/ MODULE_DESCRIPTION("Dummy Zaptel Driver for kurobox"); MODULE_AUTHOR("Robert Pleh and mod by TT"); #ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); #endif