/****************************************************************************
*
*	Name:			usbsndcm.h
*
*	Description:	Firmware command routines header file.
*
*	Copyright:		(c) 1999 Conexant Systems Inc.
*
*	Revision:	Date:		Author:				Description:
*
*	Linux-1.0	May 29 2002	Shen Wei Wang			Created.
*					shenwei.wang@conexant.com
*
*****************************************************************************
*	$Author:   Shen Wei Wang  $
*	$Revision:   1.0  $
*	$Modtime:   May 29 2002 11:09:58  $
****************************************************************************/

#ifndef _USBSNDCM_H
#define _USBSNDCM_H

#define CM_STRICT_PACKET_SIZE		(64)
#define CM_STRICT_PACKET_DUMMY_SIZE	(CM_STRICT_PACKET_SIZE - 4)

#define CM_PACKET_DATA_ARRAY_SIZE	CM_STRICT_PACKET_DUMMY_SIZE
#define CM_DOWNLOAD_DATA_MAX (CM_STRICT_PACKET_SIZE - 12)

typedef enum
{
/*	CM_REQUEST_UNDEFINED					= 0x80, 

	CM_REQUEST_TEST, 

	CM_REQUEST_CHIP_GET_MAC_ADDRESS, 

	CM_REQUEST_CHIP_GET_DP_VERSIONS, 

	CM_REQUEST_CHIP_ADSL_LINE_START, 
	CM_REQUEST_CHIP_ADSL_LINE_STOP, 

	CM_REQUEST_CHIP_ADSL_LINE_GET_STATUS, 
	CM_REQUEST_CHIP_ADSL_LINE_GET_SPEED, 

	CM_REQUEST_CARD_INFO_GET, 
						    
	CM_REQUEST_CARD_DATA_GET, 
						    
	CM_REQUEST_CARD_DATA_SET, 
						    
	CM_REQUEST_COMMAND_HW_IO, 

	CM_REQUEST_INTERFACE_HW_IO, 

	CM_REQUEST_CARD_SERIAL_DATA_PATH_GET, 
	CM_REQUEST_CARD_SERIAL_DATA_PATH_SET, 

	CM_REQUEST_MAX
*/
	CM_REQUEST_UNDEFINED					= 0x80, 

	CM_REQUEST_TEST = 0x81, 

	CM_REQUEST_CHIP_GET_MAC_ADDRESS = 0x82, 

	CM_REQUEST_CHIP_GET_DP_VERSIONS = 0x83, 

	CM_REQUEST_CHIP_ADSL_LINE_START = 0x84, 
	CM_REQUEST_CHIP_ADSL_LINE_STOP = 0x85, 

	CM_REQUEST_CHIP_ADSL_LINE_GET_STATUS = 0x86, 
	CM_REQUEST_CHIP_ADSL_LINE_GET_SPEED = 0x87, 

	CM_REQUEST_CARD_INFO_GET = 0x88, 
						    
	CM_REQUEST_CARD_DATA_GET = 0x89, 
						    
	CM_REQUEST_CARD_DATA_SET = 0x8A, 
						    
	CM_REQUEST_COMMAND_HW_IO = 0x8B, 

	CM_REQUEST_INTERFACE_HW_IO = 0x8C, 

	CM_REQUEST_CARD_SERIAL_DATA_PATH_GET = 0x8D, 
	CM_REQUEST_CARD_SERIAL_DATA_PATH_SET = 0x8E, 

	CM_REQUEST_CARD_CONTROLLER_VERSION_GET = 0x8F,
    
	CM_REQUEST_CARD_GET_STATUS = 0x90, 

	CM_REQUEST_CARD_GET_MAC_ADDRESS = 0x91, 

	CM_REQUEST_CARD_GET_DATA_LINK_STATUS = 0x92, 

    CM_REQUEST_BIT_ALLOC = 0x93,
						    
    CM_REQUEST_SNR = 0x94,
    CM_REQUEST_ERROR_DOWNLOAD_COMPLETE = 0x95,
    CM_REQUEST_GET_LOCATION = 0x96,
    CM_REQUEST_UPLOAD_BLOCK_COMPLETE = 0x97,
    CM_REQUEST_READ_MEMORY_BLOCK = 0x98,
    CM_REQUEST_PACKING_MODE = 0x99,
    CM_REQUEST_USB_SUSPEND = 0x9A,
    CM_REQUEST_BEGIN_DOWNLOAD = 0x9B,

	CM_REQUEST_MAX
} CM_REQUEST_CODE;


typedef struct cardParamStruct
{
	DWORD dwIndex;
	DWORD dwValue;
} CARDPARAM, *PCARDPARAM;

#define CARD_PARAM_MAX					(7)

typedef struct cardDataStruct
{
	DWORD     dwCount;
	CARDPARAM Param[CARD_PARAM_MAX];
} CARDDATA, *PCARDDATA;

/*
typedef struct
{
	BYTE	uRequest;			// Request code 
	BYTE	uStatus;			// Status code	 
	BYTE	uId;				// Request ID	 
	BYTE	uReserved;			// Reserved	

	union
	{
		CARDDATA	CardData;

		BYTE		Array[CM_PACKET_DATA_ARRAY_SIZE];

		BYTE		Dummy[CM_STRICT_PACKET_DUMMY_SIZE];
	} Data;
} CM_PACKET, * PCM_PACKET;
*/

typedef struct 
{
    DWORD		dwByteCount;
    DWORD		dwAddress;
    BYTE		DownloadData[CM_DOWNLOAD_DATA_MAX];
}CM_DOWNLOAD_PACKET;

typedef struct
{
	BYTE	uRequest;			/* Request code	*/ 
	BYTE	uStatus;			/* Status code	*/ 
	BYTE	uId;				/* Request ID	*/ 
	BYTE	uReserved;			/* Reserved		*/ 

	union
	{
		CARDDATA	CardData;
        	DWORD       dwData;
		BYTE		Array[CM_PACKET_DATA_ARRAY_SIZE];

		BYTE		Dummy[CM_STRICT_PACKET_DUMMY_SIZE];
        	CM_DOWNLOAD_PACKET CmDownload;
	} Data;
} CM_PACKET, * PCM_PACKET;

#define CM_PACKAGE_FRAME_SIZE		(64)
#define DBG_ENABLED_STATUS_SIMULATION					(0)
#define DBG_ENABLED_DBG_CM_REQUEST_CODE					(1)
#define DBG_ENUM_IS_OUT_OF_RANGE	"DBG_ENUM_IS_OUT_OF_RANGE"



BOOLEAN 
CmCommandRcv
(
	IN PDEVICE_OBJECT	DeviceObject,
	IN	CM_REQUEST_CODE	eCommand
);

BOOLEAN 
CmPacketSend
(
	IN PDEVICE_OBJECT	DeviceObject,
	IN  CM_PACKET	*	CmRequest
);

BOOLEAN 
CmCommandSend
(
	IN PDEVICE_OBJECT	DeviceObject,
	IN	CM_REQUEST_CODE	eCommand, 
	IN	DWORD		dwParam
);


BOOLEAN 
CmConfigParamSend
(
	IN PDEVICE_OBJECT	DeviceObject,
	IN	CM_REQUEST_CODE	eCommand, 
//	IN	DWORD			dwParam,
    IN MINIPORTCOMPLETIONROUTINE  CallBack,
    IN PVOID MPContext,
    IN ULONG pipeNumber,
    IN BOOLEAN   IOFlag
);

BOOLEAN CmReadMacAddress
(
	IN PDEVICE_OBJECT	DeviceObject,
	IN MINIPORTCOMPLETIONROUTINE  CallBack,
	IN PVOID MPContext
);
#endif

