/*
 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sub license,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#ifndef _SAVAGE_UTIL_H
#define _SAVAGE_UTIL_H

/* define the Primary ID */
#include "savage_driver.h"

#define	UT_XV_FUNC_BIOS         0x11

/* define the Secondary ID */
#define	UT_XV_FUNC_BIOS_GetChipID				1
#define UT_XV_FUNC_BIOS_GetVersion				2
#define	UT_XV_FUNC_BIOS_GetDate					3
#define	UT_XV_FUNC_BIOS_GetVideoMemSizeMB		4

typedef struct UTBIOSVERSION {
    ulong dwVersion;  /* The version. */
    ulong dwRevision; /* The revision. */
} UTBIOSVERSION;

typedef struct UTBIOSDATE {
    ulong dwYear;  /* Year, like 2001. */
    ulong dwMonth; /* Month, like 5, 12. */
    ulong dwDay;   /* Day, like 7, 30. */
} UTBIOSDATE;


/* define the Primary ID */
#define	UT_XV_FUNC_DRIVER       0x12

/* defne the Secondary ID */
#define UT_XV_FUNC_DRIVER_GetFileName           1
#define UT_XV_FUNC_DRIVER_GetFileVersion        2

#define DISPLAY_DRIVER              1
#define	VIDEO_CAPTURE_DRIVER        2
#define	HWOVERLAY_DRIVER            3
#define	HWMPEG2_DECODER             4

typedef struct	UTDriverVersion {
	ulong	dwMajorNum ;
	ulong	dwMinorNum ;
	ulong	dwReversionNum;
} UTDRIVERFILEVERSION;


/* define the Primary ID */
#define	UT_XV_FUNC_DEVICE		0x13

/* define the Secondary ID */
#define	UT_XV_FUNC_DEVICE_GetSupportState		1
#define	UT_XV_FUNC_DEVICE_GetConnectState		2
#define	UT_XV_FUNC_DEVICE_GetActiveState		3
#define	UT_XV_FUNC_DEVICE_SetActiveState		4
#define	UT_XV_FUNC_DEVICE_GetSAMMState  		5
#define	UT_XV_FUNC_DEVICE_GetRotateState	   	6
#define	UT_XV_FUNC_DEVICE_SetRotateState	   	7

/* define the device type */
#define UT_DEVICE_NONE      0x0000 /* No device. */
#define	UT_DEVICE_CRT1		0x0001 /* CRT1 */
#define	UT_DEVICE_LCD		0x0002 /* LCD */
#define	UT_DEVICE_TV		0x0004 /* TV */
#define	UT_DEVICE_DFP		0x0008 /* DFP */
#define	UT_DEVICE_CRT2		0x0016 /* CRT2 */

/* define the SAMM state */
#define	UT_STATE_SAMM_OFF  0  /* Not in SAMM mode. */
#define	UT_STATE_SAMM_ON   1  /* In SAMM mode. */

/* defined the rotate state */
#define	UT_ROTATE_NONE     0  /* Normal. */
#define	UT_ROTATE_90_DEG   1  /* Rotate 90 deg. clockwise. */
#define	UT_ROTATE_180_DEG  2  /* Rotate 180 deg. clockwise. */
#define	UT_ROTATE_270_DEG  3  /* Rotate 270 deg. clockwise. */

/* define the structure for device rotate state */
typedef struct _UTROTATESTATE {
    ulong dwDevice; /* Get which device's state? Value defined in Device Type, Bitwise. */
    ulong dwRotateState;  /* The rotate state. Value defined in Rotate State. */
} UTROTATESTATE;


/* define the Primary ID */
#define	UT_XV_FUNC_PANEL		0x14

/* defne the Secondary ID */
#define	UT_XV_FUNC_DEVICE_SetTargetPanel		1
#define	UT_XV_FUNC_DEVICE_GetPanelInfo		    2
#define	UT_XV_FUNC_DEVICE_GetExpandState		3
#define	UT_XV_FUNC_DEVICE_SetExpandState		4

/* define panel type */
#define UT_PANEL_TYPE_STN   0 /* STN. */
#define UT_PANEL_TYPE_TFT   1 /* TFT. */

/* define the expand state */
#define UT_STATE_EXPAND_OFF     0 /* Not expanded; centered. */
#define UT_STATE_EXPAND_ON      1 /* Expanded. */

/* define panel info structure */
typedef struct _UTPANELINFO {
    ulong	dwType;  /* Panel type */
    ulong	dwResX;  /* X Resolution of the panel. */
    ulong	dwResY;  /* Y Resolution of the panel. */
} UTPANELINFO;

/* define the Primary ID */
#define	UT_XV_FUNC_TV			0x15

/* defne the Secondary ID */
#define	UT_XV_FUNC_TV_GetSupportStandardState		1
#define	UT_XV_FUNC_TV_GetStandard					2
#define	UT_XV_FUNC_TV_SetStandard					3
#define	UT_XV_FUNC_TV_GetSupportSignalTypeState		4
#define	UT_XV_FUNC_TV_GetSignalType				    5
#define	UT_XV_FUNC_TV_SetSignalType				    6
#define	UT_XV_FUNC_TV_GetMaxViewSizeValue		    7
#define	UT_XV_FUNC_TV_GetViewSizeValue			    8
#define	UT_XV_FUNC_TV_SetViewSizeValue			    9
#define	UT_XV_FUNC_TV_GetMaxViewPositionValue		10
#define	UT_XV_FUNC_TV_GetViewPositionValue			11
#define	UT_XV_FUNC_TV_SetViewPositionValue			12
#define	UT_XV_FUNC_TV_GetSupportTuningState		    13
#define	UT_XV_FUNC_TV_GetTuningItemMaxValue		    14
#define	UT_XV_FUNC_TV_GetTuningItemValue			15
#define	UT_XV_FUNC_TV_SetTuningItemValue			16
#define	UT_XV_FUNC_TV_GetSupportSettingState		17
#define	UT_XV_FUNC_TV_GetSettingItemState			18
#define	UT_XV_FUNC_TV_SetSettingItemState			19

/* defined TV Standard as: */
#define	UT_TV_STD_NTSC 		0x0001  /* NTSC. */
#define	UT_TV_STD_PAL		0x0002  /* PAL. */
#define	UT_TV_STD_PAL_M 	0x0004  /* PAL M. */
#define	UT_TV_STD_PAL_N 	0x0008  /* PAL N. */
#define	UT_TV_STD_PAL_NC	0x0010  /* PAL N combination. */

/* defined TV Signal Type as:*/
#define	UT_TV_SGNL_COMPOSITE		0x0001  /* Composite. */
#define	UT_TV_SGNL_S_VIDEO			0x0002  /* S-Video. */
#define	UT_TV_SGNL_SCART			0x0004  /* SCART. */
#define	UT_TV_SGNL_COMP_OUTPUT	    0x0008  /* Component Output. */

/* We defined TV Tuning Item as : */
#define	UT_TV_TUNING_NONE   			0x0000  /* Flicker Filter. */
#define	UT_TV_TUNING_FFILTER			0x0001  /* Flicker Filter. */
#define	UT_TV_TUNING_ADAPTIVE_FFILTER	0x0002  /* Adaptive Flicker Filter. */
#define	UT_TV_TUNING_BRIGHTNESS	        0x0004  /* Brightness. */
#define	UT_TV_TUNING_CONTRAST		    0x0008  /* Contrast. */
#define	UT_TV_TUNING_SATURATION 	    0x0010  /* Saturation. */
#define	UT_TV_TUNING_TINT       		0x0020  /* Tint. */

/*
 * defined TV Setting State as: 
 * Note: UT_TV_SETTING_FFILTER and UT_TV_SETTING_ADAPTIVE_FFILTER are exclusive.
 */
#define	UT_TV_SETTING_NONE         			0x0000  /* Flicker Filter. */
#define	UT_TV_SETTING_FFILTER				0x0001 
#define	UT_TV_SETTING_ADAPTIVE_FFILTER		0x0002
#define	UT_TV_SETTING_DOT_CRAWL			    0x0004
#define	UT_TV_SETTING_LOCK_ASPECT_RATIO	    0x0008

/* defined TV Setting State as: */
#define	UT_STATE_OFF		0  
#define	UT_STATE_ON 		1 

/* define two macro that use in specifing now is TV standard or TV signal output: */
#define TV_STANDARD_INPUT_TYPE      0
#define TV_SIGNAL_OUTPUT_TYPE       1

/* define the structure that save the size or position x and y value: */
typedef struct _UTXYVALUE {
    ulong	dwX;
    ulong	dwY;
} UTXYVALUE;

/* define the structure of setting TV tuning information: */
typedef struct _UTSETTVTUNINGINFO {
    /*
     * The item ID, value defined in TV Tuning Item, Bitwise. 
     * E.g., if we want to set the value of tuning Tint, we should set the ID as 
     * UT_TV_TUNING_TINT.
    */
    ulong	dwItemID;
    /* The value we want to set. 0xFFFF means set the default value. */
    ulong	dwValue;
} UTSETTVTUNINGINFO;

/* define the sturcture of settinf TV item state */
typedef struct _UTSETTVITEMSTATE {
    /*
     * The item ID, value defined in TV Setting Item, Bitwise. 
     * E.g., if we want to set the state of Flicker Filter, we should set the ID as  
     * UT_TV_SETTING_FFILTER. 
     * Note: UT_TV_SETTING_FFILTER and UT_TV_SETTING_ADAPTIVE_FFILTER are exclusive.
     */
	ulong dwItemID;    
	ulong dwState;  /* Value defined in TV Setting state. */
} UTSETTVITEMSTATE;


/* define the Primary ID */
#define	UT_XV_FUNC_GAMMA		0x16

/* define the Secondary ID */
#define	UT_ESC_FUNC_GAMMA_GetDeviceSupportState		1
#define	UT_ESC_FUNC_GAMMA_GetLookUpTable		    2
#define	UT_ESC_FUNC_GAMMA_SetLookUpTable		    3

typedef struct _UTDEVICEINFO {
    ulong  dwDeviceType; /* Device type, value defined in Device Type, Bitwise. */
    ulong  dwResX;       /* X Resolution. 0 means "Current resolution". */
    ulong  dwResY;       /* Y Resolution. 0 means "Current resolution". */
    ulong  dwColorDepth; /* Bit number of color depth. 0 means "Current depth". */
} UTDEVICEINFO, *LPUTDEVICEINFO;

typedef struct _UTGAMMAINFO
{
    /* E.g., if we want the table of CRT1, we should set the dwDeviceType as UT_DEVICE_CRT1. */    
    UTDEVICEINFO	DeviceInfo;
    ulong	LookUpTable[256];
} UTGAMMAINFO, *LPUTGAMMAINFO;


#endif

