/*
 * File Name       : /drivers/video/Xcommon.h
 * Function        : Common parameters for Xserver
 * Release Version : Ver 1.00
 * Release Date    : 2005/05/25
 *
 * Copyright (C) NEC Electronics Corporation 2005
 *
 *
 * This program is free software;you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by Free Softwere
 * Foundation; either version 2 of License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warrnty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; If not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */

#ifndef _XCOMMON_H_
#define _XCOMMON_H_

#if 1 // CONFIG_MP201
#include <asm/arch/mp201_mem.h>
#endif

/*****************************************************************************
 * definitions
 *****************************************************************************/

#ifndef bool
typedef unsigned int bool;
#endif

/*****************************************************************************
 * structures
 *****************************************************************************/

/* GLXWindowTable for 3D */

#define max_GLXWindowTable	8	/* 512x512x16bpp in 4MB */
#define GLXWindowTable_SIZE	32	/* bytes of GLXWindowTable */
#define GLX_WINDOW_TABLE_LENGTH	(GLXWindowTable_SIZE * max_GLXWindowTable)
typedef struct _GLXWindowTable {
	void *		WindowID;	/* Xserver WindowID */
	int		pitch;		/* how many bytes per line */
	int		x,y;		/* top-left coodinate of valid image */
	int		bpp;		/* for now,16(bpp) fixed */
        unsigned	updated:2;	/* 0-1:3D window not ready,3:3D
                                           updated,2:transfered */
	unsigned	writtenframe:30;/* GLX latest written frame address */
        unsigned	swapinhibit:1;	/* if true,inhibit to overwrite on
                                           readingframe */
	unsigned	:1;
        unsigned	readingframe:30;/* fb current reading(update
                                           inhibit)frame */
        unsigned	validentry:1;	/* if false,this entry should be
                                           ignored */
	unsigned	:31;
} GLXWindowTable;

#define GLXWIN_UPDATED		3
#define GLXWIN_TRANSFERED	2

/* BLD_SCRN_LIST */

#define max_BLD_SCRN_LIST	10
#define BLD_SCRN_LIST_SIZE	30	/* bytes of _BLD_SCRN_LIST */
#define BLD_SCRN_LIST_LENGTH	(BLD_SCRN_LIST_SIZE * max_BLD_SCRN_LIST)
typedef struct _BLD_SCRN_LIST {
	unsigned	transfer:1;	/* b15
					     1:effective transfer rect
					     0:endmark			*/
	unsigned	:9;
	unsigned	exclude:1;	/* b5:(exclude start)
					     1:exclude before transfer
					     0:nothing before transfer	*/
	unsigned	unexclude:1;	/* b4:(exclude end)
					     1:unexclude after transfer
					     0:nothing after transfer	*/
	unsigned	:1;
	unsigned	image:3;	/* b2:0(image kind)
					     111:reserved for cursor
					     011:ROT overlay
					     010:reserved for Xv overlay
					     001:3D(refer GLXWindowTable)
					     000:2D			*/
	int		src_x;		/* transfer rect */
	int		src_y;
	int		width;
	int		height;
        int		dest_x;		/* left-top coodination of destination
                                         */
	int		dest_y;
	int		index_GLXWindowTable;	/* index of GLXWindowTable (only available with 3D rect) */
} BLD_SCRN_LIST;

#define BLD_SCRN_TYPE_TRANSFER		1
#define BLD_SCRN_TYPE_ENDMARK		0
#define BLD_SCRN_TYPE_EXCLUDE		1
#define BLD_SCRN_TYPE_UNEXCLUDE		1
#define BLD_SCRN_TYPE_IMAGE_CURSOR	7	/* 111 */
#define BLD_SCRN_TYPE_IMAGE_ROT_OVL	3	/* 011 */
#define BLD_SCRN_TYPE_IMAGE_XV_OVL	2	/* 010 */
#define BLD_SCRN_TYPE_IMAGE_3D		1	/* 001 */
#define BLD_SCRN_TYPE_IMAGE_2D		0	/* 000 */

/* interface between DSP driver and fb driver */

typedef struct {
        int		framecount;		/* count of buffers - 0 origin
                                                 */
	int		writtenframe;		/* the latest buffer number which is output from ROT       */
						/*   -1            : no buffer is ready to be transferred. */
						/*   0 - framecount: the buffer is ready to be transfered. */
	int		readingframe;		/* buffer number which IMG is reading now                  */
						/*   -1            : no buffer is start to be transfered.  */
						/*   0 - framecount: the buffer is being transfered now.   */
	unsigned long	interFb_buf0;		/* physical address of InterFb_BufInfo for buffer 0        */
	int		interFb_buf1_Offset;	/* offset from InterFb_BufInfo for buffer 0 to InterFb_BufInfo for buffer 1 */
	int		interFb_buf2_Offset;	/* offset from InterFb_BufInfo for buffer 0 to InterFb_BufInfo for buffer 2 */
} interFb_bufaddr;

typedef struct {
	unsigned long	bufAddr_Y;		/* Y buffer physical address   */
	unsigned long	bufAddr_CbCr;		/* CbCr buffer physical address*/
	int		FrameNum;		/* frame sequence number       */
	int		Height;			/* height of image             */
	int		Width;			/* width of image              */
	int		f_Rotator;		/* rotate angle                */
						/*   0: 0 degree               */
						/*   1: 90 degree              */
						/*   2: 180 degree             */
						/*   3: 270 degree             */
	int		f_PanScan;		/* PanScan mode flag           */
						/*   0: 4:3                    */
						/*   1: 16:9                   */
						/*   3: 4:3 letter box         */
						/*   4: 16:9 side panel        */
} InterFb_BufInfo;

#endif /* _XCOMMON_H_ */
