static long dtlk_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { char __user *argp = (char __user *)arg; struct dtlk_settings *sp; char portval; TRACE_TEXT(" dtlk_ioctl"); switch (cmd) { case DTLK_INTERROGATE: mutex_lock(&dtlk_mutex); sp = dtlk_interrogate(); mutex_unlock(&dtlk_mutex); if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) return -EINVAL; return 0; case DTLK_STATUS: portval = inb_p(dtlk_port_tts); return put_user(portval, argp); default: return -EINVAL; } }
static int dtlk_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct dtlk_settings *sp; char portval; TRACE_TEXT(" dtlk_ioctl"); switch (cmd) { case DTLK_INTERROGATE: sp = dtlk_interrogate(); if (copy_to_user((char *) arg, (char *) sp, sizeof(struct dtlk_settings))) return -EINVAL; return 0; case DTLK_STATUS: portval = inb_p(dtlk_port_tts); return put_user(portval, (char *) arg); default: return -EINVAL; } }
static int __init dtlk_dev_probe(void) { unsigned int testval = 0; int i = 0; struct dtlk_settings *sp; if (dtlk_port_lpc | dtlk_port_tts) return -EBUSY; for (i = 0; dtlk_portlist[i]; i++) { #if 0 printk("DoubleTalk PC - Port %03x = %04x\n", dtlk_portlist[i], (testval = inw_p(dtlk_portlist[i]))); #endif if (!request_region(dtlk_portlist[i], DTLK_IO_EXTENT, "dtlk")) continue; testval = inw_p(dtlk_portlist[i]); if ((testval &= 0xfbff) == 0x107f) { dtlk_port_lpc = dtlk_portlist[i]; dtlk_port_tts = dtlk_port_lpc + 1; sp = dtlk_interrogate(); printk("DoubleTalk PC at %03x-%03x, " "ROM version %s, serial number %u", dtlk_portlist[i], dtlk_portlist[i] + DTLK_IO_EXTENT - 1, sp->rom_version, sp->serial_number); /* put LPC port into known state, so dtlk_readable() gives valid result */ outb_p(0xff, dtlk_port_lpc); /* INIT string and index marker */ dtlk_write_bytes("\036\1@\0\0012I\r", 8); /* posting an index takes 18 msec. Here, we wait up to 100 msec to see whether it appears. */ msleep_interruptible(100); dtlk_has_indexing = dtlk_readable(); #ifdef TRACING printk(", indexing %d\n", dtlk_has_indexing); #endif #ifdef INSCOPE { /* This macro records ten samples read from the LPC port, for later display */ #define LOOK \ for (i = 0; i < 10; i++) \ { \ buffer[b++] = inb_p(dtlk_port_lpc); \ __delay(loops_per_jiffy/(1000000/HZ)); \ } char buffer[1000]; int b = 0, i, j; LOOK outb_p(0xff, dtlk_port_lpc); buffer[b++] = 0; LOOK dtlk_write_bytes("\0012I\r", 4); buffer[b++] = 0; __delay(50 * loops_per_jiffy / (1000/HZ)); outb_p(0xff, dtlk_port_lpc); buffer[b++] = 0; LOOK printk("\n"); for (j = 0; j < b; j++) printk(" %02x", buffer[j]); printk("\n"); } #endif /* INSCOPE */ #ifdef OUTSCOPE { /* This macro records ten samples read from the TTS port, for later display */ #define LOOK \ for (i = 0; i < 10; i++) \ { \ buffer[b++] = inb_p(dtlk_port_tts); \ __delay(loops_per_jiffy/(1000000/HZ)); /* 1 us */ \ } char buffer[1000]; int b = 0, i, j; mdelay(10); /* 10 ms */ LOOK outb_p(0x03, dtlk_port_tts); buffer[b++] = 0; LOOK LOOK printk("\n"); for (j = 0; j < b; j++) printk(" %02x", buffer[j]); printk("\n"); } #endif /* OUTSCOPE */ dtlk_write_bytes("Double Talk found", 18); return 0; } release_region(dtlk_portlist[i], DTLK_IO_EXTENT); } printk(KERN_INFO "DoubleTalk PC - not found\n"); return -ENODEV; }