*** sys.orig/i386/isa/wdpi.c	Tue Oct 29 04:23:28 1996
--- sys/i386/isa/wdpi.c	Fri May 15 23:28:27 1998
***************
*** 178,183 ****
--- 178,195 ----
  #endif
  
  /*
+  Special drive list:
+ */
+ static struct _wdpi_special_list_ {
+ 	char *wdpi_sl_model;
+ 	int wdpi_sl_nslot;
+ } wdpi_special_list[]={
+ 	{"TEAC    PD",2},
+ 	{"MATSHITAPD",2},
+         {NULL,0}
+ };
+ 
+ /*
   * Configuration
   * ----------------------------------------------------------------------
   *
***************
*** 405,410 ****
--- 417,442 ----
  	if (i == 50)
  		wdprf(aprint_normal, sc, "Unit did not become ready\n");
  
+         /* search the special list of drives.  
+ 	   if this drive is ATAPI PD/CD drive, we must treate LUN as like
+ 	   SCSI command packet.
+ 	 this modification was added by kimoto@ohnolab.org (05/02/1998)
+ 	 */
+          sc->wdpi_sclun = 0;
+          {
+ 		 struct _wdpi_special_list_ *wp;
+ 
+ 		 for (wp = wdpi_special_list;wp->wdpi_sl_model != NULL;wp++) {
+ 			if (strncmp(wp->wdpi_sl_model,
+ 				    u.p.wdp_model,
+ 				    strlen(wp->wdpi_sl_model)) == 0) {
+ 					    sc->wdpi_nslot = wp->wdpi_sl_nslot;
+ 					    sc->wdpi_sclun = 1;
+ 					    break;
+ 			}
+ 		 }
+ 	 }
+ 
  	/* See if this is a changer */
  	if ((sc->wdpi_flags & WDPI_NOCHG) == 0)
  		wchg_attach(sc);
***************
*** 679,684 ****
--- 711,724 ----
  
  		/* Send command */
  		DELAY(1);			/* XXX NEC drives */
+ 
+ 		/* store SCSI LUN,
+ 		 but I should modify this implimantation immediately.*/
+ 		if (sc->wdpi_sclun == 1) {
+ 			scp->scp_cdb.cdb_bytes[1] &= 0x1f;
+ 			scp->scp_cdb.cdb_bytes[1] |= ((scp->scp_lun & 7) << 5);
+ 		}
+ 
  		pi_outsw(sc, base + wd_data, (u_short *)&scp->scp_cdb, 6);
  
  		if (sc->wdpi_polldrq == POLL_IGNORE) {
*** sys.orig/i386/isa/wdpi_changer.c	Fri Oct  4 14:12:18 1996
--- sys/i386/isa/wdpi_changer.c	Fri May 15 23:25:41 1998
***************
*** 134,139 ****
--- 134,149 ----
  	    cd->bufsize_hi << 8 | cd->bufsize_lo,
  	    cd->nvol_hi << 8 | cd->nvol_lo);
  
+ 	/* if SCSI LUN is enabled, number of slots is already set in upper
+ 	   function.
+ 	 */
+ 	if (sc->wdpi_sclun == 1) {
+ 		/* sc->wdpi_nslot is already set */
+ 		sc->wdpi_curslot = 0;
+ 		sc->wdpi_hba.hba_driver = &wdpi_chg_hbadriver;
+ 		goto freeout;
+ 	}
+ 
  	if (cd->mech_type != MTYPE_ICHANGE && cd->mech_type != MTYPE_CCHANGE)
  		goto freeout;
  
***************
*** 206,213 ****
  	int rc;
  
  	/* Just pass through if already on the right slot */
! 	if (scp->scp_lun == sc->wdpi_curslot)
  		return (wdpi_start_s(scp));
  
  	/*
  	 * This lets us recognize units even if there isn't a disc in the
--- 216,228 ----
  	int rc;
  
  	/* Just pass through if already on the right slot */
! 	if (scp->scp_lun == sc->wdpi_curslot)	
  		return (wdpi_start_s(scp));
+ 	/* if SCSI LUN is enable, just set LUN and pass the operation */
+ 	if (sc->wdpi_sclun == 1) {
+ 		sc->wdpi_curslot = scp->scp_lun;
+ 		return (wdpi_start_s(scp));
+ 	}
  
  	/*
  	 * This lets us recognize units even if there isn't a disc in the
***************
*** 256,261 ****
--- 271,281 ----
  	/* Just pass through if already on the right slot */
  	if (scp->scp_lun == sc->wdpi_curslot)
  		return(wdpi_start(scp));
+ 	/* if SCSI LUN is enable, just set LUN and pass the operation */
+ 	if (sc->wdpi_sclun == 1) {
+ 		sc->wdpi_curslot = scp->scp_lun;
+ 		return (wdpi_start_s(scp));
+ 	}
  	sc->wdpi_chg_errcnt = 0;
  	sc->wdpi_pscp = scp;
  	return(wdpi_chg_issueload(sc));
*** sys.orig/i386/isa/wdpivar.h	Fri Oct  4 14:12:19 1996
--- sys/i386/isa/wdpivar.h	Sat May  2 10:30:24 1998
***************
*** 30,35 ****
--- 30,41 ----
  	int	wdpi_chg_errcnt;	/* Changer retry counter */
  	int	wdpi_immed;		/* Changer ops: immediate or async */
  	int	wdpi_sss;		/* Software slot select flag */
+ 	int	wdpi_sclun;		/* How to treate SCSI LUN.
+ 					 0: normal operation
+ 					 1: enable LUN like SCSI device
+ 					 This flag was added by
+ 					  kimoto@ohnolab.org (05/02/1998).
+ 					 */
  	scp_t	*wdpi_wscp;		/* Work SCP (used for changer cmds) */
  	scp_t	*wdpi_pscp;		/* Pending SCP (while changing) */
  	struct scsi_sense wdpi_sd;	/* Sense data */
