--- linux/drivers/char/lp.c Fri Oct 21 08:58:37 1994 +++ linux/drivers/char/lp.c Fri Oct 21 09:20:36 1994 @@ -5,6 +5,8 @@ * checking ought to be. * Copyright (C) 1993 by Nigel Gamble (added interrupt code) * Copyright (C) 1994 by Alan Cox (Modularised it) + * Copyright (C) 1994 by Yan Zhou, off-line printer support + * Copyright (C) 1994 by Karl Keyte, modified off-line printer code */ #include @@ -13,6 +15,9 @@ #include #include #include +#ifdef CONFIG_OFFLINE_LP +#include +#endif #include #include @@ -43,6 +48,13 @@ #undef LP_DEBUG +#ifdef CONFIG_OFFLINE_LP +#define LP_SERROR(x) (!((x) & LP_PERRORP)) /* Error */ +#define LP_SBUSY(x) (!((x) & LP_PBUSY)) /* Busy */ +#define LP_SOFFLINE(x) (!((x) & LP_PSELECD)) /* Off-line */ +#define LP_SREADY(x) (!LP_SERROR((x)) && !LP_SOFFLINE((x)) && !LP_SBUSY((x))) +#endif + static int lp_reset(int minor) { int testvalue; @@ -72,7 +84,12 @@ count ++; if(need_resched) schedule(); + +#ifdef CONFIG_OFFLINE_LP + } while(!LP_SREADY(status) && count < LP_CHAR(minor)); +#else } while(!(status & LP_PBUSY) && count < LP_CHAR(minor)); +#endif if (count == LP_CHAR(minor)) { return 0; @@ -102,11 +119,16 @@ int wait = 0; unsigned char status; - +#ifdef CONFIG_OFFLINE_LP + status = LP_S(minor); + if (!LP_SREADY(status)) status = LP_S(minor); + if (!LP_SREADY(status)) status = LP_S(minor); + if ( LP_SREADY(status)) { +#else if (!((status = LP_S(minor)) & LP_PACK) || (status & LP_PBUSY) || !((status = LP_S(minor)) & LP_PACK) || (status & LP_PBUSY) || !((status = LP_S(minor)) & LP_PACK) || (status & LP_PBUSY)) { - +#endif outb_p(lpchar, LP_B(minor)); /* must wait before taking strobe high, and after taking strobe low, according spec. Some printers need it, others don't. */ @@ -159,7 +181,12 @@ --copy_size; ++bytes_written; } else { +#ifdef CONFIG_OFFLINE_LP + status = LP_S(minor); + if (LP_SERROR(status)) { +#else if (!((status = LP_S(minor)) & LP_PERRORP)) { +#endif int rc = total_bytes_written + bytes_written; if ((status & LP_POUTPA)) { @@ -177,11 +204,19 @@ } if(LP_F(minor) & LP_ABORT) return rc; +#ifdef CONFIG_OFFLINE_LP + if (LP_SOFFLINE(status)) + return rc; +#endif } cli(); outb_p((LP_PSELECP|LP_PINITP|LP_PINTEN), (LP_C(minor))); status = LP_S(minor); +#ifdef CONFIG_OFFLINE_LP + if (LP_SREADY(status)) { +#else if (!(status & LP_PACK) || (status & LP_PBUSY)) { +#endif outb_p((LP_PSELECP|LP_PINITP), (LP_C(minor))); sti(); continue; @@ -308,6 +343,10 @@ return -ENODEV; if (LP_F(minor) & LP_BUSY) return -EBUSY; +#ifdef CONFIG_OFFLINE_LP + if (LP_SOFFLINE(LP_S(minor)) && !(file->f_flags & O_NDELAY)) + return -EIO; +#endif if ((irq = LP_IRQ(minor))) { lp_table[minor].lp_buffer = (char *) kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); @@ -466,9 +505,13 @@ lp_reset(offset); printk("lp_init: lp%d exists, ", offset); if (LP_IRQ(offset)) - printk("using IRQ%d\n", LP_IRQ(offset)); + printk("using IRQ%d", LP_IRQ(offset)); else - printk("using polling driver\n"); + printk("using polling driver"); +#ifdef CONFIG_OFFLINE_LP + printk(" (off-line support)"); +#endif + printk("\n"); count++; } } @@ -503,9 +546,13 @@ lp_reset(offset); printk("lp_init: lp%d exists, ", offset); if (LP_IRQ(offset)) - printk("using IRQ%d\n", LP_IRQ(offset)); + printk("using IRQ%d", LP_IRQ(offset)); else - printk("using polling driver\n"); + printk("using polling driver"); +#ifdef CONFIG_OFFLINE_LP + printk(" (off-line support)"); +#endif + printk("\n"); count++; } } --- linux/arch/i386/config.in Fri Oct 21 09:23:16 1994 +++ linux/arch/i386/config.in Fri Oct 21 09:22:52 1994 @@ -166,6 +166,9 @@ comment 'character devices' bool 'Parallel printer support' CONFIG_PRINTER n +if [ "$CONFIG_PRINTER" = "y" ]; then +bool ' Off-line printer support' CONFIG_OFFLINE_LP y +fi bool 'Logitech busmouse support' CONFIG_BUSMOUSE n bool 'PS/2 mouse (aka "auxiliary device") support' CONFIG_PSMOUSE n if [ "$CONFIG_PSMOUSE" = "y" ]; then