/*
 * $Header: /smsa/bsd:include/dev/laser.h:bsd  1.4  $
 * $Source: /smsa/bsd:include/dev/laser.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 */
/*
 * Header:		laser.h
 *
 * Purpose in life:	Fixed definitions for laser beam printer module
 *
 * Copyright:		Acorn Computers Ltd., (c) March 1988
 */

#ifndef __dev_laser_h
#define __dev_laser_h

/* The offset added to the podule ID address to give IOC base address */
#define		POD_TO_IOC_OFFSET	(-0x3c0000)

/* Control port bits */
#define		LB_C_MASK	((1<<7)+(1<<6))
#define		LB_C_SC		(1<<5)
#define		LB_C_CCLK	(1<<4)
#define		LB_C_CBSY	(1<<3)
#define		LB_C_PRNT	(1<<2)
#define		LB_C_VSYNC	(1<<1)
#define		LB_C_NOT_CPRDY	(1<<0)


/*
 * Now the list of interrupts which may be anticipated.  Values are the bits
 * in the various ports.
 */

/* IRQa - triggered:
	VSREQ		when /VSREQ goes low (VSREQ asserted)
	ENDRAST		rising edge of FLYBK (asserted)
	TIMER		reload detected
 */
#define		LB_I_A_VSREQ		(1<<0)
#define		LB_I_A_ENDRAST		(1<<3)
#define		LB_I_A_TIMER		(1<<5)
#define		LB_I_A_MASK		((1<<0) | (1<<3) | (1<<5))

/* IRQb - triggered when lines come low:
	PPRDY			/PPRDY low (printer powered up)
	NOT_RDY			RDY low (deasserted)
	NOT_SBSY		SBSY low (deasserted)
	STATUS_0		SC low (data 0)
	NOT_PPRDY		PPRDY low (printer loses power)
 * Bit 1 (PPRDY) is now complemented by the new bit 5 connection (NOT_PPRDY).
 * DFlynn's document is misleading about bit 5, which was always tied high
 * until now.
 */
#define		LB_I_B_PPRDY		(1<<1)
#define		LB_I_B_NOT_RDY		(1<<2)
#define		LB_I_B_NOT_SBSY		(1<<3)
#define		LB_I_B_STATUS_0		(1<<4)
#define		LB_I_B_NOT_PPRDY	(1<<5)
#define		LB_I_B_MASK		(0x1f << 1)

/* FIQ - triggered:
	VSREQ			VSREQ high (asserted)
	ENDRAST			FLYBK high (asserted)
	FIFORQ			/VRQL low (asserted)
 */
#define		LB_I_F_VSREQ		(1<<0)
#define		LB_I_F_ENDRAST		(1<<1)
#define		LB_I_F_FIFORQ		(1<<2)
#define		LB_I_F_MASK		(0x7)


/*
 * These apply to the Canon SX 300 dpi laser drive.
 *
 * VDO clock:		1.8638 MHz
 * Dot period:		0.53653 uS
 *
 * BD period minimum 	= 1797 uS - 2%
 *			= 1761 uS
 *			= 3282 dots  (0xcd2)
 *	truncate to	=~3280 dots  (0xcd0)
 *
 * BD -> video depends on paper (for 8mm border)
 *	Letter			 89   uS	160 = 0xa0
 *	Legal			 89   uS	160 = 0xa0
 *	A4			107.8 uS	200 = 0xc8
 *	Executive		189.5 uS	352 = 0x160
 *	B5			196.4 uS	360 = 0x168
 * 
 * VDO width depends upon paper also (i.e. the number of displayed dots)
 *	Letter/legal/A4		210mm		2432 = 0x980
 *	  This goes over the edge, so I'm using 2304 = 0x900
 *	B5/executive		173mm		2048 = 0x800
 *	  I'm reducing this proportionately to	1920 = 0x780
 *
 * Lines
 *	Letter/legal/A4		291mm		3440 = 0xd70
 *	  Again, this overflows, so I'll use	3392 = 0xd40
 *	B5/executive		250mm		2960 = 0xb90
 *	  This is bodged (guessed) to		2460 = 0xa00
 *	
 * Top margin
 *	212 mS = 117 lines for feed + 5mm
 */

#define		MaxRasterWidth		3280

#define		Letter_left_margin	160
#define		Legal_left_margin	160
#define		A4_left_margin		168
/* The above is for test */
#define		Executive_left_margin	352
#define		B5_left_margin		360

#define		Letter_top_margin	117
#define		Legal_top_margin	117
#define		A4_top_margin		117
#define		Executive_top_margin	117
#define		B5_top_margin		117

#define		Letter_dots_per_raster	2304
#define		Legal_dots_per_raster	2304
#define		A4_dots_per_raster	2304
#define		Executive_dots_per_raster 1920
#define		B5_dots_per_raster	1920

#define		Letter_rasters_per_page	3392
#define		Legal_rasters_per_page	3392
#define		A4_rasters_per_page	3392
#define		Executive_rasters_per_page 2460
#define		B5_rasters_per_page	2460

#define		Max_dots_per_page	(8 * 1024 * 1024)
#define		Ticks_per_centisecond	((10000 * 2 * 22366)/24000)


/* Status requests */
#define		LB_ST_STATUS		0x01
#define		LB_ST_PROB_1		0x02
#define		LB_ST_PROB_2		0x04
#define		LB_ST_NUM_RETX		0x08
#define		LB_ST_PAPER_SIZE	0x0b
#define		LB_ST_TONER		0x1f
#define		LB_ST_CCLK		0x40
#define		LB_ST_NO_RETX		0x5d

#endif/*__dev_laser_h*/

/* EOF laser.h */
