Ejemplo n.º 1
0
static int PowerProc(Device_Vendor Dev_vendor, usb_ss801u *dev, Register_Func Reg_fn, bool bON)
{
    int iRet;
    CBW_Form PwrCBW;
    unsigned char Data[512];
    unsigned int DataLen=512;

    Init_stdCBWHdr(&PwrCBW);

    //____Step1. Read register
	Vendor_Fill_ReadReg_Cmd(Dev_vendor, &PwrCBW, Reg_fn, DataLen);
    iRet = Egis_SndSCSICmd(	dev, 					// device infomation
		    	   			&PwrCBW, 				// CBW
		    	   			Data, DataLen, dir_in, 	// data infomation
		    	   			NULL,					// CSW
							5000					// timeout
		    	  			);


    //____Step2. Write register
    Vendor_Fill_WriteReg_Cmd(Dev_vendor, &PwrCBW, Reg_fn, bON, Data, 512);
    if(0 == iRet)
		iRet = Egis_SndSCSICmd(	dev, 					// device infomation
					   			&PwrCBW, 				// CBW
					   			Data, DataLen, dir_out,	// data infomation
					   			NULL,					// CSW
								5000					// timeout
					  			);

    return iRet;
}
Ejemplo n.º 2
0
static int Read_Write_Register(
			usb_ss801u * dev,
			__u8 RWDir , __u8 MemType,
			__u8 HAddr, __u8 LAddr,
			__u8 xHLen, __u8 xLLen,
			unsigned char *Buffer , unsigned int BufLen)
{
	int iRet;
	trans_dir xDir;
	CBW_Form CBW;
	memcpy(&CBW, &dev->normalCBW, CBW_SIZE);

	CBW.Length = BufLen;
	CBW.CommandLength = 10;
	if (0xD2 == RWDir) { /* 0xD2 : Read*/
		xDir = dir_in;
		CBW.Direction = SCSI_IN;
	} else if (0xDA == RWDir) { /* 0xDA : Write*/
		xDir = dir_out;
		CBW.Direction = SCSI_OUT;
	} else {
		return -1;
	}

	Fill_SCSIVendor_Cmd(&CBW, RWDir, MemType, HAddr, LAddr, xHLen, xLLen);
	iRet = Egis_SndSCSICmd(dev,				/* device infomation */
							&CBW,				/* CBW */
							Buffer, BufLen, xDir,	/* data infomation */
							NULL,				/* CSW */
							5000				/* timeout */
							);
	return iRet;
}
Ejemplo n.º 3
0
int Egis_SndNormalModeCmd(Device_Vendor Dev_vendor, usb_ss801u *dev, unsigned char* CSW)
{
    return  Egis_SndSCSICmd(dev, 				// device infomation
		     	     		&dev->normalCBW,	// CBW
			  			    0, 0, dir_out,		// data infomation
			     			CSW,			  	// CSW
							5000				// timeout
				    	   );
}
Ejemplo n.º 4
0
int Egis_SndContactModeCmd(Device_Vendor Dev_vendor, usb_ss801u *dev, unsigned char* CSW)
{
    int retval=0;
	int bytes_write = 0;
	int bytes_read = 0;
	unsigned char inBuffer[6];

#ifndef BEFORE_ES603
		
	if(Dev_vendor == EGIS_603) 
	{
		return 0;
	}

#endif
	//____step1. pre-set contact mode
	switch(Dev_vendor)
	{
		case USBEST_801u:
		retval = PowerSwitch(Dev_vendor, dev, true);
			break;

		case EGIS_603: //No need to do PowerSwitch in 603
			
			break;
		case DEVICE_NOTSUPPORT:
		default:
			err("Vendor device is not supported!! \r\n");
			break;
	}

    
	//____step2. set contact mode command
	switch(Dev_vendor)
	{
		case USBEST_801u:
    	if(0==retval)
    		retval = Egis_SndSCSICmd(dev, 			  	// device infomation
		    	 	       	 		 &dev->contactCBW,  // CBW
			  				     	 0, 0, dir_out,		// data infomation
							     	 CSW,				// CSW
									 5000				// timeout		
					    			);
			break;
		case EGIS_603:
			//send command to host
			retval = Egis_BulkXfer(
				dev,
	  			dir_out,
       			(void*)&dev->contactCBW,
       			31,
       			&bytes_write, 
				5000
			 );
			//read data
			if(0 == retval)
				{
					retval = Egis_BulkXfer(
					dev,
	  				dir_in,
       				(void*)inBuffer,
       				6,
       				&bytes_read, 
					5000
			 		);
				}
			else
				{
					err("USB bulk transfer fail! \r\n");
				}
			break;
		case DEVICE_NOTSUPPORT:
		default:
			err("Vendor device is not supported!! \r\n");
			break;
	}
	//____step3. post-set contact mode command
    switch(Dev_vendor){
		case USBEST_801u:
		    AlphaTec_SwitchIOPwrOff(dev);
			break;
		case MOAI_802u:
		     
			break;
		case EGIS_603:
			break;

		case DEVICE_NOTSUPPORT:
		default:
			err("Vendor device is not supported!! \r\n");
			break;
    }

    return retval;
}