patch-2.4.5 linux/drivers/parport/ieee1284.c

Next file: linux/drivers/parport/ieee1284_ops.c
Previous file: linux/drivers/parport/ChangeLog
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.4/linux/drivers/parport/ieee1284.c linux/drivers/parport/ieee1284.c
@@ -12,6 +12,8 @@
  * Any part of this program may be used in documents licensed under
  * the GNU Free Documentation License, Version 1.1 or any later version
  * published by the Free Software Foundation.
+ *
+ * Various hacks, Fred Barnes <frmb2@ukc.ac.uk>, 04/2000
  */
 
 #include <linux/config.h>
@@ -523,9 +525,10 @@
 		r = parport_wait_peripheral (port,
 					     PARPORT_STATUS_PAPEROUT,
 					     PARPORT_STATUS_PAPEROUT);
-		if (r)
+		if (r) {
 			DPRINTK (KERN_INFO "%s: Timeout at event 31\n",
-				 port->name);
+				port->name);
+		}
 
 		port->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
 		DPRINTK (KERN_DEBUG "%s: ECP direction: forward\n",
@@ -614,6 +617,7 @@
 	/* Use the mode we're in. */
 	switch (mode) {
 	case IEEE1284_MODE_NIBBLE:
+	case IEEE1284_MODE_BYTE:
 		parport_negotiate (port, IEEE1284_MODE_COMPAT);
 	case IEEE1284_MODE_COMPAT:
 		DPRINTK (KERN_DEBUG "%s: Using compatibility mode\n",
@@ -623,19 +627,29 @@
 
 	case IEEE1284_MODE_EPP:
 		DPRINTK (KERN_DEBUG "%s: Using EPP mode\n", port->name);
-		if (addr)
+		if (addr) {
 			fn = port->ops->epp_write_addr;
-		else
+		} else {
 			fn = port->ops->epp_write_data;
+		}
+		break;
+	case IEEE1284_MODE_EPPSWE:
+		DPRINTK (KERN_DEBUG "%s: Using software-emulated EPP mode\n",
+			port->name);
+		if (addr) {
+			fn = parport_ieee1284_epp_write_addr;
+		} else {
+			fn = parport_ieee1284_epp_write_data;
+		}
 		break;
-
 	case IEEE1284_MODE_ECP:
 	case IEEE1284_MODE_ECPRLE:
 		DPRINTK (KERN_DEBUG "%s: Using ECP mode\n", port->name);
-		if (addr)
+		if (addr) {
 			fn = port->ops->ecp_write_addr;
-		else
+		} else {
 			fn = port->ops->ecp_write_data;
+		}
 		break;
 
 	case IEEE1284_MODE_ECPSWE:
@@ -643,10 +657,11 @@
 			 port->name);
 		/* The caller has specified that it must be emulated,
 		 * even if we have ECP hardware! */
-		if (addr)
+		if (addr) {
 			fn = parport_ieee1284_ecp_write_addr;
-		else
+		} else {
 			fn = parport_ieee1284_ecp_write_data;
+		}
 		break;
 
 	default:
@@ -656,8 +671,7 @@
 	}
 
 	retval = (*fn) (port, buffer, len, 0);
-	DPRINTK (KERN_DEBUG "%s: wrote %d/%d bytes\n", port->name, retval,
-		 len);
+	DPRINTK (KERN_DEBUG "%s: wrote %d/%d bytes\n", port->name, retval, len);
 	return retval;
 #endif /* IEEE1284 support */
 }
@@ -696,8 +710,22 @@
 	/* Use the mode we're in. */
 	switch (mode) {
 	case IEEE1284_MODE_COMPAT:
-		if (parport_negotiate (port, IEEE1284_MODE_NIBBLE))
+		/* if we can tri-state use BYTE mode instead of NIBBLE mode,
+		 * if that fails, revert to NIBBLE mode -- ought to store somewhere
+		 * the device's ability to do BYTE mode reverse transfers, so we don't
+		 * end up needlessly calling negotiate(BYTE) repeately..  (fb)
+		 */
+		if ((port->physport->modes & PARPORT_MODE_TRISTATE) &&
+		    !parport_negotiate (port, IEEE1284_MODE_BYTE)) {
+			/* got into BYTE mode OK */
+			DPRINTK (KERN_DEBUG "%s: Using byte mode\n", port->name);
+			fn = port->ops->byte_read_data;
+			break;
+		}
+		if (parport_negotiate (port, IEEE1284_MODE_NIBBLE)) {
 			return -EIO;
+		}
+		/* fall through to NIBBLE */
 	case IEEE1284_MODE_NIBBLE:
 		DPRINTK (KERN_DEBUG "%s: Using nibble mode\n", port->name);
 		fn = port->ops->nibble_read_data;
@@ -710,12 +738,21 @@
 
 	case IEEE1284_MODE_EPP:
 		DPRINTK (KERN_DEBUG "%s: Using EPP mode\n", port->name);
-		if (addr)
+		if (addr) {
 			fn = port->ops->epp_read_addr;
-		else
+		} else {
 			fn = port->ops->epp_read_data;
+		}
+		break;
+	case IEEE1284_MODE_EPPSWE:
+		DPRINTK (KERN_DEBUG "%s: Using software-emulated EPP mode\n",
+			port->name);
+		if (addr) {
+			fn = parport_ieee1284_epp_read_addr;
+		} else {
+			fn = parport_ieee1284_epp_read_data;
+		}
 		break;
-
 	case IEEE1284_MODE_ECP:
 	case IEEE1284_MODE_ECPRLE:
 		DPRINTK (KERN_DEBUG "%s: Using ECP mode\n", port->name);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)