[PARPORT] Once again with diff -u: some patches concerning IEEE1284 negotiation


schreite@helena.physik.uni-stuttgart.de
Sat, 13 Jun 98 23:00:28 +0200


Hi,

well, diff -u makes a much more human readable output than just diff:

--- parport_probe.c.orig Tue Jun 9 22:56:31 1998
+++ parport_probe.c Wed Jun 10 01:00:05 1998
@@ -3,6 +3,8 @@
  *
  * Authors: Carsten Gross, carsten@sol.wohnheim.uni-ulm.de
  * Philip Blundell <Philip.Blundell@pobox.com>
+ * "well known command sets" added by:
+ * Roger Schreiter <Roger.Schreiter@t-online.de>
  */
 
 #include <linux/tasks.h>
@@ -102,14 +104,24 @@
 
         parport_claim_or_block(dev);
 
+#ifdef HPOJ
+ switch (parport_ieee1284_negotiate(port, 4)) {
+ case 2:
+#else
         switch (parport_ieee1284_nibble_mode_ok(port, 4)) {
         case 1:
+#endif
                 current->state=TASK_INTERRUPTIBLE;
                 current->timeout=jiffies+1;
                 schedule(); /* HACK: wait 10ms because printer seems to
                                  * ack wrong */
                 result = read_polled(port, buffer, len);
                 break;
+#ifdef HPOJ
+ case 1:
+ result = 0;
+ break;
+#endif
         case 0:
                 result = -EIO;
                 break;
@@ -189,9 +201,18 @@
                                 printk(KERN_WARNING "%s probe: warning,
class '%s' not understood.\n", port->name, sep);
                                 port->probe_info.class = PARPORT_CLASS_OTHER;
                         } else if (!strcmp(p, "CMD") || !strcmp(p, "COMMAND SET")) {
+ if (strstr(sep, "PJL"))
port->probe_info.well_known_cmdsets|=PARPORT_PJL;
+ if (strstr(sep, "PCL"))
port->probe_info.well_known_cmdsets|=PARPORT_PCL;
+ if (strstr(sep, "PS"))
port->probe_info.well_known_cmdsets|=PARPORT_PS;
+ if (strstr(sep, "POSTSCRIPT"))
port->probe_info.well_known_cmdsets|=PARPORT_PS;
+ if (strstr(sep, "SCL"))
port->probe_info.well_known_cmdsets|=PARPORT_SCL;
+ if (strstr(sep, "MLC"))
port->probe_info.well_known_cmdsets|=PARPORT_MLC;
+ if (strstr(sep, "PML"))
port->probe_info.well_known_cmdsets|=PARPORT_PML;
                                 /* if it speaks printer language, it's
                                    probably a printer */
- if (strstr(sep, "PJL") || strstr(sep, "PCL"))
+ if
(port->probe_info.well_known_cmdsets&(PARPORT_PJL|
+
 PARPORT_PCL|
+
 PARPORT_PS))
                                         guessed_class = PARPORT_CLASS_PRINTER;
                         } else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) {
                                 port->probe_info.description = strdup(sep);
@@ -230,6 +251,7 @@
         port->probe_info.mfr = "Unknown vendor";
         port->probe_info.description = NULL;
         port->probe_info.class = PARPORT_CLASS_UNSPEC;
+ port->probe_info.well_known_cmdsets=0;
 
         if (!buffer) {
                 printk(KERN_ERR "%s probe: Memory squeeze.\n", port->name);

===========================================================================

--- parport_init.c.orig Tue Jun 9 23:52:20 1998
+++ parport_init.c Tue Jun 9 23:53:35 1998
@@ -138,6 +138,7 @@
 EXPORT_SYMBOL(parport_unregister_device);
 EXPORT_SYMBOL(parport_enumerate);
 EXPORT_SYMBOL(parport_ieee1284_nibble_mode_ok);
+EXPORT_SYMBOL(parport_ieee1284_negotiate);
 EXPORT_SYMBOL(parport_wait_peripheral);
 EXPORT_SYMBOL(parport_proc_register);
 EXPORT_SYMBOL(parport_proc_unregister);

===========================================================================

--- parport_ieee1284.c.orig Tue Jun 9 22:41:12 1998
+++ parport_ieee1284.c Wed Jun 10 00:53:35 1998
@@ -4,6 +4,9 @@
  * Authors: Phil Blundell <Philip.Blundell@pobox.com>
  * Carsten Gross <carsten@sol.wohnheim.uni-ulm.de>
  * Jose Renau <renau@acm.org>
+ * parport_ieee1284_nibble_mode_ok modified to
+ * parport_ieee1284_negotiate for test purpose by:
+ * Roger Schreiter <Roger.Schreiter@t-online.de>
  */
 
 #include <linux/tasks.h>
@@ -66,4 +69,37 @@
         /* nAutoFd low */
         parport_write_control(port, parport_read_control(port) & ~2);
         return (parport_wait_peripheral(port, 0x20, 0))?2:1;
+}
+
+/* Negotiate an IEEE 1284 mode.
+ * Follows the IEEE1284 docs provided by Warp Engeneer -
+ * and works fine with the HP OfficeJets.
+ * return values are:
+ * 0 - handshake failed; peripheral is not compliant (or none present)
+ * 1 - handshake OK; IEEE1284 peripheral present but mode not available
+ * 2 - handshake OK; IEEE1284 peripheral and mode available
+ */
+int parport_ieee1284_negotiate(struct parport *port, unsigned char mode)
+{
+ parport_write_data(port, mode);
+ udelay(500);
+ /* nSelectIn high, nAutoFd low (nInit permanently high) */
+ parport_write_control(port, 6);
+ if (parport_wait_peripheral(port, 0x78, 0x38)) {
+ parport_write_control(port, 0x0c);
+ return 0;
+ }
+ /* nStrobe low */
+ parport_write_control(port, 7);
+ udelay(5); /* Strobe wait */
+ /* nStrobe high */
+ parport_write_control(port, 6);
+ udelay(5);
+ /* nAutoFd low */
+ parport_write_control(port, 4);
+ if (parport_wait_peripheral(port, 0x60, 0x40)) {
+ parport_write_control(port, 0x0c);
+ return 1;
+ }
+ return 2;
 }
--- parport.h.orig Tue Jun 9 23:08:47 1998
+++ parport.h Wed Jun 10 00:27:59 1998
@@ -124,11 +124,19 @@
         void (*dec_use_count)(void);
 };
 
+/* well known command sets: */
+#define PARPORT_PJL 1
+#define PARPORT_PCL 2
+#define PARPORT_PS 4
+#define PARPORT_SCL 8
+#define PARPORT_MLC 16
+#define PARPORT_PML 32
 struct parport_device_info {
         parport_device_class class;
         char *mfr;
         char *model;
         char *cmdset;
+ int well_known_cmdsets;
         char *description;
 };
 
@@ -295,6 +303,7 @@
 
 extern void parport_parse_irqs(int, const char *[], int irqval[]);
 extern int parport_ieee1284_nibble_mode_ok(struct parport *, unsigned char);
+extern int parport_ieee1284_negotiate(struct parport *, unsigned char);
 extern int parport_wait_peripheral(struct parport *, unsigned char, unsigned
                                    char);
 

-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --



This archive was generated by hypermail 2.0b3 on Wed 30 Dec 1998 - 10:17:49 EST