************************************************************************************
CFXGA Linux Driver Specifications	Ver1.01E

Copyright (C) 2002 I-O DATA DEVICE,INC.
************************************************************************************

[Module Name]
  memory_cs.o

[Driver Direction Folder]
  /lib/modules/xxx.xx.xx/pcmcia/
		These 7 words are Kernel Versions.

[API List]
 1. CFXGA_GET_STATUS	Get a status of CFXGA. Check the physical card and a driver version.
 2. CFXGA_GET_RESONUM	Return supported resolution numbers.
 3. CFXGA_GET_RESOINFO	List up suppoted resolutions info.
 4. CFXGA_SET_RESO		Set up a resolution
 5. CFXGA_COPY_FB		Copy data from memory to frame buffer
 6. CFXGA_COPY_FB2		Copy data from assigned physical address to frame buffer
 7. CFXGA_CLEAR_SCREEN@	Display clear
 8. CFXGA_SCREEN_OFF	Display off

[How to call API]
 Open "/dev/cfxga0a", and then call ioctrl().

 * For Example
 #include "CFXGA.h"
 int fd;

 fd = open("/dev/cfxga0a",O_RDONLY );
 ioctl(fd , fuction "name", parameter address);


------------------------------------------------------------------------------------
CFXGA driver ioctl API
------------------------------------------------------------------------------------

=====================================================================================
ioctl commmand No.  [Command Macro]
=====================================================================================
#include <linux/ioctl.h>
#define	CFXGA_MAGIC_NO		'c'
#define	CFXGA_GET_STATUS	_IOR(CFXGA_MAGIC_NO, 1, struct status_t)
#define	CFXGA_GET_RESONUM	_IOR(CFXGA_MAGIC_NO, 2, unsigned int)
#define	CFXGA_GET_RESOINFO	_IOR(CFXGA_MAGIC_NO, 3, struct reso_info_t)
#define	CFXGA_SET_RESO		_IOW(CFXGA_MAGIC_NO, 4, unsigned int)
#define	CFXGA_COPY_FB		_IOW(CFXGA_MAGIC_NO, 5, struct copy_info_t)
#define	CFXGA_COPY_FB2		_IOW(CFXGA_MAGIC_NO, 6, struct copy2_info_t)
#define	CFXGA_CLEAR_SCREEN	 _IO(CFXGA_MAGIC_NO, 7)
#define	CFXGA_SCREEN_OFF	 _IO(CFXGA_MAGIC_NO, 8)

=====================================================================================
1.CFXGA_GET_STATUS
=====================================================================================
	Put CFXGA's status & version info on structure "status_t"
	Status info will be to member flags

[Parameter]
	typedef struct status_t {
		int		version;  //[OUT]	driver version (100 = 1.00)
		int		flags;	@//[OUT]	status flags
	} status_t;
	"Structure Pointer"

	//flags details
	#define	CFXGA_INSTALLED	0x00000001	//CFXGA is avaiable
	#define	CFXGA_BUSY	0x00000002	//** N/A **
	#define	CFXGA_SCREEN_ON	0x00000004	//CFXGA output is ON

[For Example]
	status_t cfxga_status;
	ioctl(fd, CFXGA_GET_STATUS, &cfxga_status);

=====================================================================================
2.CFXGA_GET_RESONUM
=====================================================================================
	Return the numbers of supported resolutions

[Parameter]
	"int" Pointer

[For Example]
	int resonum;
	ioctl(fd, CFXGA_GET_RESONUM, &resonum);

=====================================================================================     
3.CFXGA_GET_RESOINFO
=====================================================================================
	List up suppoted resolutions info.
	Put the numbers of resolution to member "mode_no", and call it
	Get info to repeat as many as times of resolutions that are got by CFXGA_GET_RESONUM
@
[Parameter]
	typedef struct reso_info_t {
		u_int	mode_no;	//[IN]	mode no. 
		reso_t	reso;		//[OUT]	resolution infomation
	} reso_info_t;
	"Structure Pointer"

	typedef struct reso_t {
	    int		cx;	//resolution x
	    int		cy;	//resolution y
	    u_int	ref;	//refresh rate (Hz)
	    u_int	bpp;	//color depth (bits/pixel)
	    u_int	dclk;	//dot clock (kHz)
	    u_int	flags;	//resolution flags
	} reso_t;

	//reso_t.flags̏ڍ
	#define MODE_VGA	0x00000001	//Analog RGB
	#define MODE_NTSC	0x00000002	//NTSC
	#define MODE_PAL	0x00000004	//PAL
	#define OUT_VGA		0x00000010	//Out put is Analog RGB@@
	#define OUT_COMPOSITE	0x00000020	//Out put is Composite
	#define OUT_SVIDEO	0x00000040	//Out put is S-VIDEO

[For Example]
	int 		i, resonum;
	reso_info_t	resoinfo;
	reso_info_t	*resotbl;

	ioctl(fd, CFXGA_GET_RESONUM, &resonum);
	resotbl = malloc(resonum * sizeof(resoinfo));
	for(i=0; i<resonum; i++)
	{
		resoinfo.mode_no = i;
		ioctl(fd, CFXGA_GET_RESOINFO, &resoinfo);
		memcpy(&resotbl[i], &resoinfo, sizeof(reso_info_t);
	}

=====================================================================================
4.CFXGA_SET_RESO
=====================================================================================
	Set up a resolution

[Parameter]
	"int   mode" Pointer

	The current supported resolutions are here.
	  0 : 640x480 16bpp AnalogRGB 72Hz 
	  1 : 640x480 16bpp AnalogRGB 85Hz
	  2 : 848x480 16bpp AnalogRGB 60Hz
	  3 : 800x600 16bpp AnalogRGB 60Hz
	  4 : 640x480 16bpp NTSC Compsite
	  5 : 696x436 16bpp NTSC Compsite
	  6 : 640x480 16bpp NTSC S-Video 
	  7 : 696x436 16bpp NTSC S-Video
	  8 : 640x480 16bpp PAL Composite
	  9 : 800x572 16bpp PAL Composite
	 10 : 640x480 16bpp PAL S-Video
	 11 : 800x572 16bpp PAL S-Video

[For Example]
	int	mode;
	mode = 3;	//800x600 60Hz 16bpp AnalogRGB
	ioctl(fd, CFXGA_SET_RESO, &mode);


=====================================================================================
5.CFXGA_COPY_FB
=====================================================================================
	Copy data from memory to frame buffer
 
[Parameter]
	typedef struct copy_info_t {
		int		x;		//[IN]	destnation x org
		int		y;		//[IN]	destnation y org
		int		w;		//[IN]	width
		int		h;		//[IN]	height
		int		bpp;		//[IN]	src bpp(bit per pixel  8 or 16)
		int		stride;		//[IN]	src screen stride (Byte count)
		void		*adr;		//[IN]	src data start address (virtual Address) 
	} copy_info_t;
	"Structure Pointer"

	[NOTE] Now bpp is suppoted 16bit(RGB565) only

[For Example]
	copy_info_t	cp;
	uchar		*fb0;
	
	//640x480(16bpp) picture data in fb0
	cp.x      = 0;
	cp.y      = 0;
	cp.w      = 640;
	cp.h      = 480;
	cp.bpp    = 16;
	cp.stride = cp.w * cp.bpp / 8;
	cp.adr	  = fb0;
	ioctl(fd, CFXGA_COPY_FB, &cp);

=====================================================================================
6.CFXGA_COPY_FB2
=====================================================================================
	Copy data from assigned physical address to frame buffer

[Parameter]
	typedef struct copy2_info_t {
		int		x;		//[IN]	destnation x org
		int		y;		//[IN]	destnation y org
		int		w;		//[IN]	width
		int		h;		//[IN]	height
		int		bpp;		//[IN]	src bpp
		int		stride;		//[IN]	src screen stride
		u_long		phys_adr;	//[IN]	src screen physical address
		u_long		size;		//[IN]	src screen physical address size (bytes)
		u_long		offset;		//[IN]	src date offset (bytes)
		u_int		swivel;		//[IN]	swivel level	
	} copy2_info_t;
	"Structure Pointer"

	//.swivel details
	#define	SWIVEL_0	0	//No rotate
	#define	SWIVEL_90	1	//Spin it 90 degrees left
	#define	SWIVEL_180	2	//Do half-turn
	#define	SWIVEL_270	3	//Spin it 270 degrees left

	[NOTE] Now bpp is suppoted 16bit(RGB565) only

[For Example]
	copy2_info_t	cp2;

	//adrs   = Physical address on the top of picture area
	//offset = Offset address from the top physical address
	//Spin 480x640(16bpp) picture 90 degrees left from (adrs+offset) area, and then copy it.
	cp2.x        = 0;
	cp2.y        = 0;
	cp2.w        = 480;
	cp2.h        = 640;
	cp2.bpp      = 16;
	cp2.stride   = cp.w * cp.bpp / 8;
	cp2.phys_adr = adrs;
	cp2.offset   = offset;
	cp2.swivel   = SWIVEL_90;
	ioctl(fd, CFXGA_COPY_FB2, &cp2);


=====================================================================================
7.CFXGA_CLEAR_SCREEN
=====================================================================================
	Display clear

[Parameter]
	Not required

[For Example]
	ioctl(fd, CFXGA_CLEAR_SCREEN, NULL);



=====================================================================================
8.CFXGA_SCREEN_OFF
=====================================================================================
	Display off
	If it turn on again, use CFXGA_SET_RESO

[Parameter]
	Not required

[For Example]
	ioctl(fd, CFXGA_SCREEN_OFF, NULL);

---------------------------------------------------------------------------------------
