1 /*****************************************************************************/
4 * sm.c -- soundcard radio modem driver.
6 * Copyright (C) 1996-2000 Thomas Sailer (sailer@ife.ee.ethz.ch)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * Please note that the GPL allows you to use the driver, NOT the radio.
23 * In order to use the radio, you need a license from the communications
24 * authority of your country.
27 * Command line options (insmod command line)
29 * mode mode string; eg. "wss:afsk1200"
30 * iobase base address of the soundcard; common values are 0x220 for sbc,
32 * irq interrupt number; common values are 7 or 5 for sbc, 11 for wss
33 * dma dma number; common values are 0 or 1
37 * 0.1 21.09.1996 Started
38 * 18.10.1996 Changed to new user space access routines (copy_{to,from}_user)
39 * 0.4 21.01.1997 Separately compileable soundcard/modem modules
40 * 0.5 03.03.1997 fixed LPT probing (check_lpt result was interpreted the wrong way round)
41 * 0.6 16.04.1997 init code/data tagged
42 * 0.7 30.07.1997 fixed halfduplex interrupt handlers/hotfix for CS423X
43 * 0.8 14.04.1998 cleanups
44 * 0.9 03.08.1999 adapt to Linus' new __setup/__initcall
45 * use parport lowlevel drivers instead of directly writing to a parallel port
46 * removed some pre-2.2 kernel compatibility cruft
47 * 0.10 10.08.1999 Check if parport can do SPP and is safe to access during interrupt contexts
48 * 0.11 12.02.2000 adapted to softnet driver interface
51 /*****************************************************************************/
53 #include <linux/config.h>
54 #include <linux/version.h>
55 #include <linux/module.h>
56 #include <linux/ioport.h>
57 #include <linux/string.h>
58 #include <linux/init.h>
59 #include <linux/parport.h>
60 #include <asm/uaccess.h>
64 /* --------------------------------------------------------------------- */
66 /*static*/ const char sm_drvname
[] = "soundmodem";
67 static const char sm_drvinfo
[] = KERN_INFO
"soundmodem: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n"
68 KERN_INFO
"soundmodem: version 0.11 compiled " __TIME__
" " __DATE__
"\n";
70 /* --------------------------------------------------------------------- */
72 /*static*/ const struct modem_tx_info
*sm_modem_tx_table
[] = {
73 #ifdef CONFIG_SOUNDMODEM_AFSK1200
75 #endif /* CONFIG_SOUNDMODEM_AFSK1200 */
76 #ifdef CONFIG_SOUNDMODEM_AFSK2400_7
78 #endif /* CONFIG_SOUNDMODEM_AFSK2400_7 */
79 #ifdef CONFIG_SOUNDMODEM_AFSK2400_8
81 #endif /* CONFIG_SOUNDMODEM_AFSK2400_8 */
82 #ifdef CONFIG_SOUNDMODEM_AFSK2666
84 #endif /* CONFIG_SOUNDMODEM_AFSK2666 */
85 #ifdef CONFIG_SOUNDMODEM_PSK4800
87 #endif /* CONFIG_SOUNDMODEM_PSK4800 */
88 #ifdef CONFIG_SOUNDMODEM_HAPN4800
93 #endif /* CONFIG_SOUNDMODEM_HAPN4800 */
94 #ifdef CONFIG_SOUNDMODEM_FSK9600
97 #endif /* CONFIG_SOUNDMODEM_FSK9600 */
101 /*static*/ const struct modem_rx_info
*sm_modem_rx_table
[] = {
102 #ifdef CONFIG_SOUNDMODEM_AFSK1200
104 #endif /* CONFIG_SOUNDMODEM_AFSK1200 */
105 #ifdef CONFIG_SOUNDMODEM_AFSK2400_7
107 #endif /* CONFIG_SOUNDMODEM_AFSK2400_7 */
108 #ifdef CONFIG_SOUNDMODEM_AFSK2400_8
110 #endif /* CONFIG_SOUNDMODEM_AFSK2400_8 */
111 #ifdef CONFIG_SOUNDMODEM_AFSK2666
113 #endif /* CONFIG_SOUNDMODEM_AFSK2666 */
114 #ifdef CONFIG_SOUNDMODEM_PSK4800
116 #endif /* CONFIG_SOUNDMODEM_PSK4800 */
117 #ifdef CONFIG_SOUNDMODEM_HAPN4800
121 &sm_hapn4800_pm10_rx
,
122 #endif /* CONFIG_SOUNDMODEM_HAPN4800 */
123 #ifdef CONFIG_SOUNDMODEM_FSK9600
126 #endif /* CONFIG_SOUNDMODEM_FSK9600 */
130 static const struct hardware_info
*sm_hardware_table
[] = {
131 #ifdef CONFIG_SOUNDMODEM_SBC
134 #endif /* CONFIG_SOUNDMODEM_SBC */
135 #ifdef CONFIG_SOUNDMODEM_WSS
138 #endif /* CONFIG_SOUNDMODEM_WSS */
142 /* --------------------------------------------------------------------- */
146 static struct net_device sm_device
[NR_PORTS
];
148 /* --------------------------------------------------------------------- */
150 #define UART_RBR(iobase) (iobase+0)
151 #define UART_THR(iobase) (iobase+0)
152 #define UART_IER(iobase) (iobase+1)
153 #define UART_IIR(iobase) (iobase+2)
154 #define UART_FCR(iobase) (iobase+2)
155 #define UART_LCR(iobase) (iobase+3)
156 #define UART_MCR(iobase) (iobase+4)
157 #define UART_LSR(iobase) (iobase+5)
158 #define UART_MSR(iobase) (iobase+6)
159 #define UART_SCR(iobase) (iobase+7)
160 #define UART_DLL(iobase) (iobase+0)
161 #define UART_DLM(iobase) (iobase+1)
165 #define MIDI_DATA(iobase) (iobase)
166 #define MIDI_STATUS(iobase) (iobase+1)
167 #define MIDI_READ_FULL 0x80 /* attention: negative logic!! */
168 #define MIDI_WRITE_EMPTY 0x40 /* attention: negative logic!! */
170 #define MIDI_EXTENT 2
172 /* ---------------------------------------------------------------------- */
174 #define PARAM_TXDELAY 1
175 #define PARAM_PERSIST 2
176 #define PARAM_SLOTTIME 3
177 #define PARAM_TXTAIL 4
178 #define PARAM_FULLDUP 5
179 #define PARAM_HARDWARE 6
180 #define PARAM_RETURN 255
187 * ===================== port checking routines ========================
190 enum uart
{ c_uart_unknown
, c_uart_8250
,
191 c_uart_16450
, c_uart_16550
, c_uart_16550A
};
192 static const char *uart_str
[] =
193 { "unknown", "8250", "16450", "16550", "16550A" };
195 static enum uart
check_uart(unsigned int iobase
)
197 unsigned char b1
,b2
,b3
;
199 enum uart uart_tab
[] =
200 { c_uart_16450
, c_uart_unknown
, c_uart_16550
, c_uart_16550A
};
202 if (iobase
<= 0 || iobase
> 0x1000-SER_EXTENT
)
203 return c_uart_unknown
;
204 if (check_region(iobase
, SER_EXTENT
))
205 return c_uart_unknown
;
206 b1
= inb(UART_MCR(iobase
));
207 outb(b1
| 0x10, UART_MCR(iobase
)); /* loopback mode */
208 b2
= inb(UART_MSR(iobase
));
209 outb(0x1a, UART_MCR(iobase
));
210 b3
= inb(UART_MSR(iobase
)) & 0xf0;
211 outb(b1
, UART_MCR(iobase
)); /* restore old values */
212 outb(b2
, UART_MSR(iobase
));
214 return c_uart_unknown
;
215 inb(UART_RBR(iobase
));
216 inb(UART_RBR(iobase
));
217 outb(0x01, UART_FCR(iobase
)); /* enable FIFOs */
218 u
= uart_tab
[(inb(UART_IIR(iobase
)) >> 6) & 3];
219 if (u
== c_uart_16450
) {
220 outb(0x5a, UART_SCR(iobase
));
221 b1
= inb(UART_SCR(iobase
));
222 outb(0xa5, UART_SCR(iobase
));
223 b2
= inb(UART_SCR(iobase
));
224 if ((b1
!= 0x5a) || (b2
!= 0xa5))
230 /* --------------------------------------------------------------------- */
232 static int check_midi(unsigned int iobase
)
234 unsigned long timeout
;
238 if (iobase
<= 0 || iobase
> 0x1000-MIDI_EXTENT
)
240 if (check_region(iobase
, MIDI_EXTENT
))
242 timeout
= jiffies
+ (HZ
/ 100);
243 while (inb(MIDI_STATUS(iobase
)) & MIDI_WRITE_EMPTY
)
244 if ((signed)(jiffies
- timeout
) > 0)
248 outb(0xff, MIDI_DATA(iobase
));
249 b
= inb(MIDI_STATUS(iobase
));
250 restore_flags(flags
);
251 if (!(b
& MIDI_WRITE_EMPTY
))
253 while (inb(MIDI_STATUS(iobase
)) & MIDI_WRITE_EMPTY
)
254 if ((signed)(jiffies
- timeout
) > 0)
259 /* --------------------------------------------------------------------- */
261 void sm_output_status(struct sm_state
*sm
)
266 int ptt
= /*hdlcdrv_ptt(&sm->hdrv)*/(sm
->dma
.ptt_cnt
> 0) ^ invert_ptt
;
267 int dcd
= (!!sm
->hdrv
.hdlcrx
.dcd
) ^ invert_dcd
;
269 if (sm
->hdrv
.ptt_out
.flags
& SP_SER
) {
270 outb(dcd
| (ptt
<< 1), UART_MCR(sm
->hdrv
.ptt_out
.seriobase
));
271 outb(0x40 & (-ptt
), UART_LCR(sm
->hdrv
.ptt_out
.seriobase
));
273 if (sm
->hdrv
.ptt_out
.flags
& SP_PAR
&& sm
->pardev
&& sm
->pardev
->port
)
274 parport_write_data(sm
->pardev
->port
, ptt
| (dcd
<< 1));
275 if (sm
->hdrv
.ptt_out
.flags
& SP_MIDI
&& hdlcdrv_ptt(&sm
->hdrv
))
276 outb(0, MIDI_DATA(sm
->hdrv
.ptt_out
.midiiobase
));
279 /* --------------------------------------------------------------------- */
281 static void sm_output_open(struct sm_state
*sm
)
283 enum uart u
= c_uart_unknown
;
284 struct parport
*pp
= NULL
;
286 sm
->hdrv
.ptt_out
.flags
= 0;
287 if (sm
->hdrv
.ptt_out
.seriobase
> 0 &&
288 sm
->hdrv
.ptt_out
.seriobase
<= 0x1000-SER_EXTENT
&&
289 ((u
= check_uart(sm
->hdrv
.ptt_out
.seriobase
))) != c_uart_unknown
) {
290 sm
->hdrv
.ptt_out
.flags
|= SP_SER
;
291 request_region(sm
->hdrv
.ptt_out
.seriobase
, SER_EXTENT
, "sm ser ptt");
292 outb(0, UART_IER(sm
->hdrv
.ptt_out
.seriobase
));
293 /* 5 bits, 1 stop, no parity, no break, Div latch access */
294 outb(0x80, UART_LCR(sm
->hdrv
.ptt_out
.seriobase
));
295 outb(0, UART_DLM(sm
->hdrv
.ptt_out
.seriobase
));
296 outb(1, UART_DLL(sm
->hdrv
.ptt_out
.seriobase
)); /* as fast as possible */
297 /* LCR and MCR set by output_status */
300 if (sm
->hdrv
.ptt_out
.pariobase
> 0) {
301 pp
= parport_enumerate();
302 while (pp
&& pp
->base
!= sm
->hdrv
.ptt_out
.pariobase
)
305 printk(KERN_WARNING
"%s: parport at address 0x%x not found\n", sm_drvname
, sm
->hdrv
.ptt_out
.pariobase
);
306 else if ((~pp
->modes
) & (PARPORT_MODE_PCSPP
| PARPORT_MODE_SAFEININT
))
307 printk(KERN_WARNING
"%s: parport at address 0x%x cannot be used\n", sm_drvname
, sm
->hdrv
.ptt_out
.pariobase
);
309 sm
->pardev
= parport_register_device(pp
, sm
->hdrv
.ifname
, NULL
, NULL
, NULL
, PARPORT_DEV_EXCL
, NULL
);
312 printk(KERN_WARNING
"%s: cannot register parport device (address 0x%x)\n", sm_drvname
, sm
->hdrv
.ptt_out
.pariobase
);
314 if (parport_claim(sm
->pardev
)) {
315 parport_unregister_device(sm
->pardev
);
317 printk(KERN_WARNING
"%s: cannot claim parport at address 0x%x\n", sm_drvname
, sm
->hdrv
.ptt_out
.pariobase
);
319 sm
->hdrv
.ptt_out
.flags
|= SP_PAR
;
323 if (sm
->hdrv
.ptt_out
.midiiobase
> 0 &&
324 sm
->hdrv
.ptt_out
.midiiobase
<= 0x1000-MIDI_EXTENT
&&
325 check_midi(sm
->hdrv
.ptt_out
.midiiobase
)) {
326 sm
->hdrv
.ptt_out
.flags
|= SP_MIDI
;
327 request_region(sm
->hdrv
.ptt_out
.midiiobase
, MIDI_EXTENT
,
330 sm_output_status(sm
);
332 printk(KERN_INFO
"%s: ptt output:", sm_drvname
);
333 if (sm
->hdrv
.ptt_out
.flags
& SP_SER
)
334 printk(" serial interface at 0x%x, uart %s", sm
->hdrv
.ptt_out
.seriobase
,
336 if (sm
->hdrv
.ptt_out
.flags
& SP_PAR
)
337 printk(" parallel interface at 0x%x", sm
->hdrv
.ptt_out
.pariobase
);
338 if (sm
->hdrv
.ptt_out
.flags
& SP_MIDI
)
339 printk(" mpu401 (midi) interface at 0x%x", sm
->hdrv
.ptt_out
.midiiobase
);
340 if (!sm
->hdrv
.ptt_out
.flags
)
345 /* --------------------------------------------------------------------- */
347 static void sm_output_close(struct sm_state
*sm
)
349 /* release regions used for PTT output */
350 sm
->hdrv
.hdlctx
.ptt
= sm
->hdrv
.hdlctx
.calibrate
= 0;
351 sm_output_status(sm
);
352 if (sm
->hdrv
.ptt_out
.flags
& SP_SER
)
353 release_region(sm
->hdrv
.ptt_out
.seriobase
, SER_EXTENT
);
354 if (sm
->hdrv
.ptt_out
.flags
& SP_PAR
&& sm
->pardev
) {
355 parport_release(sm
->pardev
);
356 parport_unregister_device(sm
->pardev
);
358 if (sm
->hdrv
.ptt_out
.flags
& SP_MIDI
)
359 release_region(sm
->hdrv
.ptt_out
.midiiobase
, MIDI_EXTENT
);
360 sm
->hdrv
.ptt_out
.flags
= 0;
363 /* --------------------------------------------------------------------- */
365 static int sm_open(struct net_device
*dev
);
366 static int sm_close(struct net_device
*dev
);
367 static int sm_ioctl(struct net_device
*dev
, struct ifreq
*ifr
,
368 struct hdlcdrv_ioctl
*hi
, int cmd
);
370 /* --------------------------------------------------------------------- */
372 static const struct hdlcdrv_ops sm_ops
= {
373 sm_drvname
, sm_drvinfo
, sm_open
, sm_close
, sm_ioctl
376 /* --------------------------------------------------------------------- */
378 static int sm_open(struct net_device
*dev
)
383 if (!dev
|| !dev
->priv
||
384 ((struct sm_state
*)dev
->priv
)->hdrv
.magic
!= HDLCDRV_MAGIC
) {
385 printk(KERN_ERR
"sm_open: invalid device struct\n");
388 sm
= (struct sm_state
*)dev
->priv
;
390 if (!sm
->mode_tx
|| !sm
->mode_rx
|| !sm
->hwdrv
|| !sm
->hwdrv
->open
)
392 sm
->hdrv
.par
.bitrate
= sm
->mode_rx
->bitrate
;
393 err
= sm
->hwdrv
->open(dev
, sm
);
398 printk(KERN_INFO
"%s: %s mode %s.%s at iobase 0x%lx irq %u dma %u dma2 %u\n",
399 sm_drvname
, sm
->hwdrv
->hw_name
, sm
->mode_tx
->name
,
400 sm
->mode_rx
->name
, dev
->base_addr
, dev
->irq
, dev
->dma
, sm
->hdrv
.ptt_out
.dma2
);
404 /* --------------------------------------------------------------------- */
406 static int sm_close(struct net_device
*dev
)
411 if (!dev
|| !dev
->priv
||
412 ((struct sm_state
*)dev
->priv
)->hdrv
.magic
!= HDLCDRV_MAGIC
) {
413 printk(KERN_ERR
"sm_close: invalid device struct\n");
416 sm
= (struct sm_state
*)dev
->priv
;
419 if (sm
->hwdrv
&& sm
->hwdrv
->close
)
420 err
= sm
->hwdrv
&& sm
->hwdrv
->close(dev
, sm
);
423 printk(KERN_INFO
"%s: close %s at iobase 0x%lx irq %u dma %u\n",
424 sm_drvname
, sm
->hwdrv
->hw_name
, dev
->base_addr
, dev
->irq
, dev
->dma
);
428 /* --------------------------------------------------------------------- */
430 static int sethw(struct net_device
*dev
, struct sm_state
*sm
, char *mode
)
432 char *cp
= strchr(mode
, ':');
433 const struct hardware_info
**hwp
= sm_hardware_table
;
439 while (hwp
&& (*hwp
) && (*hwp
)->hw_name
&& strcmp((*hwp
)->hw_name
, mode
))
441 if (!hwp
|| !*hwp
|| !(*hwp
)->hw_name
)
443 if ((*hwp
)->loc_storage
> sizeof(sm
->hw
)) {
444 printk(KERN_ERR
"%s: insufficient storage for hw driver %s (%d)\n",
445 sm_drvname
, (*hwp
)->hw_name
, (*hwp
)->loc_storage
);
452 if (sm
->hwdrv
&& sm
->hwdrv
->sethw
)
453 return sm
->hwdrv
->sethw(dev
, sm
, cp
);
457 /* --------------------------------------------------------------------- */
459 static int sm_ioctl(struct net_device
*dev
, struct ifreq
*ifr
,
460 struct hdlcdrv_ioctl
*hi
, int cmd
)
465 unsigned int newdiagmode
;
466 unsigned int newdiagflags
;
468 const struct modem_tx_info
**mtp
= sm_modem_tx_table
;
469 const struct modem_rx_info
**mrp
= sm_modem_rx_table
;
470 const struct hardware_info
**hwp
= sm_hardware_table
;
472 if (!dev
|| !dev
->priv
||
473 ((struct sm_state
*)dev
->priv
)->hdrv
.magic
!= HDLCDRV_MAGIC
) {
474 printk(KERN_ERR
"sm_ioctl: invalid device struct\n");
477 sm
= (struct sm_state
*)dev
->priv
;
479 if (cmd
!= SIOCDEVPRIVATE
) {
480 if (!sm
->hwdrv
|| !sm
->hwdrv
->ioctl
)
481 return sm
->hwdrv
->ioctl(dev
, sm
, ifr
, hi
, cmd
);
486 if (sm
->hwdrv
&& sm
->hwdrv
->ioctl
)
487 return sm
->hwdrv
->ioctl(dev
, sm
, ifr
, hi
, cmd
);
490 case HDLCDRVCTL_GETMODE
:
491 cp
= hi
->data
.modename
;
492 if (sm
->hwdrv
&& sm
->hwdrv
->hw_name
)
493 cp
+= sprintf(cp
, "%s:", sm
->hwdrv
->hw_name
);
495 cp
+= sprintf(cp
, "<unspec>:");
496 if (sm
->mode_tx
&& sm
->mode_tx
->name
)
497 cp
+= sprintf(cp
, "%s", sm
->mode_tx
->name
);
499 cp
+= sprintf(cp
, "<unspec>");
500 if (!sm
->mode_rx
|| !sm
->mode_rx
||
501 strcmp(sm
->mode_rx
->name
, sm
->mode_tx
->name
)) {
502 if (sm
->mode_rx
&& sm
->mode_rx
->name
)
503 cp
+= sprintf(cp
, ",%s", sm
->mode_rx
->name
);
505 cp
+= sprintf(cp
, ",<unspec>");
507 if (copy_to_user(ifr
->ifr_data
, hi
, sizeof(*hi
)))
511 case HDLCDRVCTL_SETMODE
:
512 if (netif_running(dev
) || !capable(CAP_NET_ADMIN
))
514 hi
->data
.modename
[sizeof(hi
->data
.modename
)-1] = '\0';
515 return sethw(dev
, sm
, hi
->data
.modename
);
517 case HDLCDRVCTL_MODELIST
:
518 cp
= hi
->data
.modename
;
521 cp
+= sprintf(cp
, "%s:,", (*hwp
)->hw_name
);
526 cp
+= sprintf(cp
, ">%s,", (*mtp
)->name
);
531 cp
+= sprintf(cp
, "<%s,", (*mrp
)->name
);
535 if (copy_to_user(ifr
->ifr_data
, hi
, sizeof(*hi
)))
541 if (copy_from_user(&bi
, ifr
->ifr_data
, sizeof(bi
)))
543 bi
.data
.dbg
.int_rate
= sm
->debug_vals
.last_intcnt
;
544 bi
.data
.dbg
.mod_cycles
= sm
->debug_vals
.mod_cyc
;
545 bi
.data
.dbg
.demod_cycles
= sm
->debug_vals
.demod_cyc
;
546 bi
.data
.dbg
.dma_residue
= sm
->debug_vals
.dma_residue
;
547 sm
->debug_vals
.mod_cyc
= sm
->debug_vals
.demod_cyc
=
548 sm
->debug_vals
.dma_residue
= 0;
549 if (copy_to_user(ifr
->ifr_data
, &bi
, sizeof(bi
)))
552 #endif /* SM_DEBUG */
555 if (copy_from_user(&bi
, ifr
->ifr_data
, sizeof(bi
)))
557 newdiagmode
= bi
.data
.diag
.mode
;
558 newdiagflags
= bi
.data
.diag
.flags
;
559 if (newdiagmode
> SM_DIAGMODE_CONSTELLATION
)
561 bi
.data
.diag
.mode
= sm
->diag
.mode
;
562 bi
.data
.diag
.flags
= sm
->diag
.flags
;
563 bi
.data
.diag
.samplesperbit
= sm
->mode_rx
->sperbit
;
564 if (sm
->diag
.mode
!= newdiagmode
) {
568 sm
->diag
.flags
= newdiagflags
& ~SM_DIAGFLAG_VALID
;
569 sm
->diag
.mode
= newdiagmode
;
570 restore_flags(flags
);
571 if (copy_to_user(ifr
->ifr_data
, &bi
, sizeof(bi
)))
575 if (sm
->diag
.ptr
< 0 || sm
->diag
.mode
== SM_DIAGMODE_OFF
) {
576 if (copy_to_user(ifr
->ifr_data
, &bi
, sizeof(bi
)))
580 if (bi
.data
.diag
.datalen
> DIAGDATALEN
)
581 bi
.data
.diag
.datalen
= DIAGDATALEN
;
582 if (sm
->diag
.ptr
< bi
.data
.diag
.datalen
) {
583 if (copy_to_user(ifr
->ifr_data
, &bi
, sizeof(bi
)))
587 if (copy_to_user(bi
.data
.diag
.data
, sm
->diag
.data
,
588 bi
.data
.diag
.datalen
* sizeof(short)))
590 bi
.data
.diag
.flags
|= SM_DIAGFLAG_VALID
;
594 sm
->diag
.flags
= newdiagflags
& ~SM_DIAGFLAG_VALID
;
595 sm
->diag
.mode
= newdiagmode
;
596 restore_flags(flags
);
597 if (copy_to_user(ifr
->ifr_data
, &bi
, sizeof(bi
)))
603 /* --------------------------------------------------------------------- */
606 * command line settable parameters
608 static char *mode
[NR_PORTS
] = { [0 ... NR_PORTS
-1] = NULL
};
609 static int iobase
[NR_PORTS
] = { [0 ... NR_PORTS
-1] = -1 };
610 static int irq
[NR_PORTS
] = { [0 ... NR_PORTS
-1] = -1 };
611 static int dma
[NR_PORTS
] = { [0 ... NR_PORTS
-1] = -1 };
612 static int dma2
[NR_PORTS
] = { [0 ... NR_PORTS
-1] = -1 };
613 static int serio
[NR_PORTS
] = { [0 ... NR_PORTS
-1] = 0 };
614 static int pario
[NR_PORTS
] = { [0 ... NR_PORTS
-1] = 0 };
615 static int midiio
[NR_PORTS
] = { [0 ... NR_PORTS
-1] = 0 };
617 MODULE_PARM(mode
, "1-" __MODULE_STRING(NR_PORTS
) "s");
618 MODULE_PARM_DESC(mode
, "soundmodem operating mode; eg. sbc:afsk1200 or wss:fsk9600");
619 MODULE_PARM(iobase
, "1-" __MODULE_STRING(NR_PORTS
) "i");
620 MODULE_PARM_DESC(iobase
, "soundmodem base address");
621 MODULE_PARM(irq
, "1-" __MODULE_STRING(NR_PORTS
) "i");
622 MODULE_PARM_DESC(irq
, "soundmodem interrupt");
623 MODULE_PARM(dma
, "1-" __MODULE_STRING(NR_PORTS
) "i");
624 MODULE_PARM_DESC(dma
, "soundmodem dma channel");
625 MODULE_PARM(dma2
, "1-" __MODULE_STRING(NR_PORTS
) "i");
626 MODULE_PARM_DESC(dma2
, "soundmodem 2nd dma channel; full duplex only");
627 MODULE_PARM(serio
, "1-" __MODULE_STRING(NR_PORTS
) "i");
628 MODULE_PARM_DESC(serio
, "soundmodem PTT output on serial port");
629 MODULE_PARM(pario
, "1-" __MODULE_STRING(NR_PORTS
) "i");
630 MODULE_PARM_DESC(pario
, "soundmodem PTT output on parallel port");
631 MODULE_PARM(midiio
, "1-" __MODULE_STRING(NR_PORTS
) "i");
632 MODULE_PARM_DESC(midiio
, "soundmodem PTT output on midi port");
634 MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
635 MODULE_DESCRIPTION("Soundcard amateur radio modem driver");
637 /* --------------------------------------------------------------------- */
639 static int __init
init_soundmodem(void)
644 char ifname
[HDLCDRV_IFNAMELEN
];
648 * register net devices
650 for (i
= 0; i
< NR_PORTS
; i
++) {
651 struct net_device
*dev
= sm_device
+i
;
652 sprintf(ifname
, "sm%d", i
);
657 if (!strncmp(mode
[i
], "sbc", 3)) {
674 iobase
[i
] = irq
[i
] = 0;
675 j
= hdlcdrv_register_hdlcdrv(dev
, &sm_ops
, sizeof(struct sm_state
), ifname
, iobase
[i
], irq
[i
], dma
[i
]);
677 sm
= (struct sm_state
*)dev
->priv
;
678 sm
->hdrv
.ptt_out
.dma2
= dma2
[i
];
679 sm
->hdrv
.ptt_out
.seriobase
= serio
[i
];
680 sm
->hdrv
.ptt_out
.pariobase
= pario
[i
];
681 sm
->hdrv
.ptt_out
.midiiobase
= midiio
[i
];
682 if (set_hw
&& sethw(dev
, sm
, mode
[i
]))
686 printk(KERN_WARNING
"%s: cannot register net device\n", sm_drvname
);
694 static void __exit
cleanup_soundmodem(void)
698 printk(KERN_INFO
"sm: cleanup_module called\n");
700 for(i
= 0; i
< NR_PORTS
; i
++) {
701 struct net_device
*dev
= sm_device
+i
;
702 struct sm_state
*sm
= (struct sm_state
*)dev
->priv
;
705 if (sm
->hdrv
.magic
!= HDLCDRV_MAGIC
)
706 printk(KERN_ERR
"sm: invalid magic in "
709 hdlcdrv_unregister_hdlcdrv(dev
);
714 module_init(init_soundmodem
);
715 module_exit(cleanup_soundmodem
);
717 /* --------------------------------------------------------------------- */
722 * format: soundmodem=io,irq,dma[,dma2[,serio[,pario]]],mode
724 * hw: sbc, wss, wssfdx
725 * modem: afsk1200, fsk9600
728 static int __init
sm_setup(char *str
)
730 static unsigned nr_dev
= 0;
733 if (nr_dev
>= NR_PORTS
)
735 str
= get_options(str
, 8, ints
);
738 iobase
[nr_dev
] = ints
[1];
740 irq
[nr_dev
] = ints
[2];
742 dma
[nr_dev
] = ints
[3];
744 dma2
[nr_dev
] = ints
[4];
746 serio
[nr_dev
] = ints
[5];
748 pario
[nr_dev
] = ints
[6];
750 midiio
[nr_dev
] = ints
[7];
755 __setup("soundmodem=", sm_setup
);
758 /* --------------------------------------------------------------------- */