/* 2009-08-18: File added by Sony Corporation */
/*
 *  Global header file for the NAVU Frame Buffer Extension
 *
 *  Copyright 2008 Sony Corporation.
 *
 *  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 the
 *  Free Software Foundation;  version 2 of the  License.
 *
 *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
 *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
 *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
 *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *  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.,
 *  675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#ifndef __NAVUFB_H__
#define __NAVUFB_H__

#ifdef __KERNEL__
#include <linux/types.h>
#include <asm/ioctl.h>
#else
#include <stdint.h>
#include <sys/ioctl.h>
#endif

#define IOC_MP200_NAVU_FB_MAGIC             ('T')

#define SONY_NAVU_FBIO_DISP                 _IO(IOC_MP200_NAVU_FB_MAGIC,   1)
#define SONY_NAVU_FBIO_TPLED                _IO(IOC_MP200_NAVU_FB_MAGIC,   2)

#define SONY_NAVU_FBIO_LAYER2               _IO(IOC_MP200_NAVU_FB_MAGIC,  10)
#define SONY_NAVU_FBIO_SETDISP2             _IO(IOC_MP200_NAVU_FB_MAGIC,  11)
#define SONY_NAVU_FBIO_GETDISP2             _IO(IOC_MP200_NAVU_FB_MAGIC,  12)
#define SONY_NAVU_FBIO_GETBASE2             _IO(IOC_MP200_NAVU_FB_MAGIC,  13)
#define SONY_NAVU_FBIO_SELBUF2              _IO(IOC_MP200_NAVU_FB_MAGIC,  14)
#define SONY_NAVU_FBIO_SETSCROLL_FLIP2      _IO(IOC_MP200_NAVU_FB_MAGIC,  15)
#define SONY_NAVU_FBIO_SETSCROLL2           _IO(IOC_MP200_NAVU_FB_MAGIC,  16)
#define SONY_NAVU_FBIO_GETSCROLL2           _IO(IOC_MP200_NAVU_FB_MAGIC,  17)
#define SONY_NAVU_FBIO_SETFORMAT2           _IO(IOC_MP200_NAVU_FB_MAGIC, 110)
#define SONY_NAVU_FBIO_GETFORMAT2           _IO(IOC_MP200_NAVU_FB_MAGIC, 111)
#define SONY_NAVU_FBIO_GETADDROFFSET2       _IO(IOC_MP200_NAVU_FB_MAGIC, 112)

#define SONY_NAVU_FBIO_LAYER1               _IO(IOC_MP200_NAVU_FB_MAGIC,  20)
#define SONY_NAVU_FBIO_SETPAL1              _IO(IOC_MP200_NAVU_FB_MAGIC,  21)
#define SONY_NAVU_FBIO_SELBUF1              _IO(IOC_MP200_NAVU_FB_MAGIC,  22)
#define SONY_NAVU_FBIO_SETTRANS1            _IO(IOC_MP200_NAVU_FB_MAGIC,  23)
#define SONY_NAVU_FBIO_SETDISP1             _IO(IOC_MP200_NAVU_FB_MAGIC,  24)
#define SONY_NAVU_FBIO_GETDISP1             _IO(IOC_MP200_NAVU_FB_MAGIC,  25)
#define SONY_NAVU_FBIO_GETBASE1             _IO(IOC_MP200_NAVU_FB_MAGIC,  26)

#define SONY_NAVU_FBIO_LAYER0               _IO(IOC_MP200_NAVU_FB_MAGIC, 131)
#define SONY_NAVU_FBIO_SETPAL0              _IO(IOC_MP200_NAVU_FB_MAGIC,  30)
#define SONY_NAVU_FBIO_GETPAL0              _IO(IOC_MP200_NAVU_FB_MAGIC,  39)
#define SONY_NAVU_FBIO_SETSCROLL0           _IO(IOC_MP200_NAVU_FB_MAGIC,  31)
#define SONY_NAVU_FBIO_GETSCROLL0           _IO(IOC_MP200_NAVU_FB_MAGIC,  32)
#define SONY_NAVU_FBIO_SELBUF0              _IO(IOC_MP200_NAVU_FB_MAGIC,  37)
#define SONY_NAVU_FBIO_SETFRAME0            _IO(IOC_MP200_NAVU_FB_MAGIC,  34)
#define SONY_NAVU_FBIO_GETFRAME0            _IO(IOC_MP200_NAVU_FB_MAGIC,  35)
#define SONY_NAVU_FBIO_GETBASE0             _IO(IOC_MP200_NAVU_FB_MAGIC,  36)
#define SONY_NAVU_FBIO_SETSCROLL_FLIP0      _IO(IOC_MP200_NAVU_FB_MAGIC, 130)

#define SONY_NAVU_FBIO_WAITVSYNC            _IO(IOC_MP200_NAVU_FB_MAGIC,  50)
#define SONY_NAVU_FBIO_WAITSTARTFRAME       _IO(IOC_MP200_NAVU_FB_MAGIC,  51)

#define SONY_NAVU_FBIO_STARTCAPTURE         _IO(IOC_MP200_NAVU_FB_MAGIC,  60)
#define SONY_NAVU_FBIO_STOPCAPTURE          _IO(IOC_MP200_NAVU_FB_MAGIC,  61)
#define SONY_NAVU_FBIO_GETFRAMEVIDEO        _IO(IOC_MP200_NAVU_FB_MAGIC,  66)
#define SONY_NAVU_FBIO_GETDISPVIDEO         _IO(IOC_MP200_NAVU_FB_MAGIC,  62)
#define SONY_NAVU_FBIO_GETBASEVIDEO_Y       _IO(IOC_MP200_NAVU_FB_MAGIC,  63)
#define SONY_NAVU_FBIO_GETBASEVIDEO_B       _IO(IOC_MP200_NAVU_FB_MAGIC,  64)
#define SONY_NAVU_FBIO_GETBASEVIDEO_R       _IO(IOC_MP200_NAVU_FB_MAGIC,  65)

/* @todo experimental */
#define SONY_NAVU_FBIO_LAYER3               _IO(IOC_MP200_NAVU_FB_MAGIC,  70)
#define SONY_NAVU_FBIO_SETTRANS3            _IO(IOC_MP200_NAVU_FB_MAGIC,  71)
#define SONY_NAVU_FBIO_GETBASE3             _IO(IOC_MP200_NAVU_FB_MAGIC,  72)
#define SONY_NAVU_FBIO_GETDISP3             _IO(IOC_MP200_NAVU_FB_MAGIC,  73)
#define SONY_NAVU_FBIO_SETDISP3             _IO(IOC_MP200_NAVU_FB_MAGIC,  74)

enum SONY_NAVU_TPLED_MODE {
	SONY_NAVU_TPLED_OFF,
	SONY_NAVU_TPLED_AUTO,
	SONY_NAVU_TPLED_ON,
	SONY_NAVU_TPLED_END,
};

typedef struct {
	uint32_t type;
	uint32_t bytelane;
} SONY_NAVU_COLOR_FORMAT;

typedef struct {
	uint32_t yrgbaddr;
	uint32_t uvaddr;
	uint32_t vaddr;
} SONY_NAVU_ADDR_OFFSET;

enum SONY_NAVU_COLOR_FORMAT_TYPE {
	SONY_NAVU_COLOR_FORMAT_RGB666,
	SONY_NAVU_COLOR_FORMAT_RGB565,
	SONY_NAVU_COLOR_FORMAT_YUV422Px,
	SONY_NAVU_COLOR_FORMAT_YUV422Pl2,
	SONY_NAVU_COLOR_FORMAT_YUV422Pl,
	SONY_NAVU_COLOR_FORMAT_YUV420Pl2,
	SONY_NAVU_COLOR_FORMAT_YUV420Pl,
	SONY_NAVU_COLOR_FORMAT_END,
};

typedef struct {
    unsigned int  FrameX;
    unsigned int  FrameY;
    unsigned int  Flag;
} SONY_NAVU_GETSCROLL;
typedef SONY_NAVU_GETSCROLL SONY_NAVU_GETSCROLL0;
typedef SONY_NAVU_GETSCROLL SONY_NAVU_GETSCROLL2;

#define SONY_NAVU_SCROLL_INIT   0x00000000  /* initial value */
#define SONY_NAVU_SCROLL_AUTO   0x80000000  /* auto-executing or waiting flip */
#define SONY_NAVU_SCROLL_ACTIVE 0x40000000  /* executing request */
#define SONY_NAVU_SCROLL_GOAL   0x00000002  /* reached to the goal */
#define SONY_NAVU_SCROLL_OB     0x00000001  /* out of bound */

#define SONY_NAVU_SCROLL_WORK_MASK   (SONY_NAVU_SCROLL_AUTO | SONY_NAVU_SCROLL_ACTIVE)
#define SONY_NAVU_SCROLL_RESULT_MASK (SONY_NAVU_SCROLL_GOAL | SONY_NAVU_SCROLL_OB)

typedef struct {
    unsigned int    FrameX;
    unsigned int    FrameY;
    int             SpeedFrameX;
    int             SpeedFrameY;
} SONY_NAVU_SETSCROLL;
typedef SONY_NAVU_SETSCROLL SONY_NAVU_SETSCROLL0;
typedef SONY_NAVU_SETSCROLL SONY_NAVU_SETSCROLL2;

#define SONY_NAVU_FAR_LIMIT     0x80000000
#define SONY_NAVU_SPEED_WARP    0x80000000

typedef struct {
    unsigned int    FrameX;
    unsigned int    FrameY;
    int             SpeedFrameX;
    int             SpeedFrameY;
    unsigned int    StartX;
    unsigned int    StartY;
    unsigned int    Flip;
} SONY_NAVU_SETSCROLL_FLIP;
#define SONY_NAVU_NO_FLIP 0xffffffff

typedef SONY_NAVU_SETSCROLL_FLIP SONY_NAVU_SETSCROLL_FLIP0;
typedef SONY_NAVU_SETSCROLL_FLIP SONY_NAVU_SETSCROLL_FLIP2;

typedef struct {
    unsigned int  FrameWidth;
    unsigned int  FrameHeight;
} SONY_NAVU_FRAMESETTING;
typedef SONY_NAVU_FRAMESETTING SONY_NAVU_DISPSETTING0;

typedef struct {
    unsigned int  DispX;
    unsigned int  DispY;
    unsigned int  DispWidth;
    unsigned int  DispHeight;
    unsigned int  FrameX;
    unsigned int  FrameY;
} SONY_NAVU_DISPSETTING1;

typedef struct {
    unsigned int  DispX;
    unsigned int  DispY;
    unsigned int  DispWidth;
    unsigned int  DispHeight;
    unsigned int  FrameX;
    unsigned int  FrameY;
    unsigned int  FrameWidth;
    unsigned int  FrameHeight;
} SONY_NAVU_DISPSETTING;
typedef SONY_NAVU_DISPSETTING SONY_NAVU_DISPSETTING2;
typedef SONY_NAVU_DISPSETTING SONY_NAVU_DISPSETTING3;

typedef struct {
    unsigned int  FrameWidth;
    unsigned int  FrameHeight;
} SONY_NAVU_FRAMESETTINGVIDEO;

typedef struct {
    unsigned int  DispX;
    unsigned int  DispY;
    unsigned int  DispWidth;
    unsigned int  DispHeight;
} SONY_NAVU_DISPSETTINGVIDEO;


/* for backward compatibility... */
/* @todo remove */
#define FBIO_PXA270_DISP                SONY_NAVU_FBIO_DISP

#define FBIO_PXA270_LAYER2              SONY_NAVU_FBIO_LAYER2
#define FBIO_PXA270_SETDISP2            SONY_NAVU_FBIO_SETDISP2
#define FBIO_PXA270_GETDISP2            SONY_NAVU_FBIO_GETDISP2
#define FBIO_PXA270_GETBASE2            SONY_NAVU_FBIO_GETBASE2
#define FBIO_PXA270_SELBUF2             SONY_NAVU_FBIO_SELBUF2

#define FBIO_PXA270_LAYER1              SONY_NAVU_FBIO_LAYER1
#define FBIO_PXA270_SETPAL1             SONY_NAVU_FBIO_SETPAL1
#define FBIO_PXA270_SELBUF1             SONY_NAVU_FBIO_SELBUF1
#define FBIO_PXA270_SETTRANS1           SONY_NAVU_FBIO_SETTRANS1
#define FBIO_PXA270_SETDISP1            SONY_NAVU_FBIO_SETDISP1
#define FBIO_PXA270_GETDISP1            SONY_NAVU_FBIO_GETDISP1
#define FBIO_PXA270_GETBASE1            SONY_NAVU_FBIO_GETBASE1

#define FBIO_PXA270_SETPAL0             SONY_NAVU_FBIO_SETPAL0
#define FBIO_PXA270_GETPAL0             SONY_NAVU_FBIO_GETPAL0
#define FBIO_PXA270_SETSCROLL0          SONY_NAVU_FBIO_SETSCROLL0
#define FBIO_PXA270_GETSCROLL0          SONY_NAVU_FBIO_GETSCROLL0
#define FBIO_PXA270_SELBUF0             SONY_NAVU_FBIO_SELBUF0
#define FBIO_PXA270_SETFRAME0           SONY_NAVU_FBIO_SETFRAME0
#define FBIO_PXA270_GETFRAME0           SONY_NAVU_FBIO_GETFRAME0
#define FBIO_PXA270_GETBASE0            SONY_NAVU_FBIO_GETBASE0
#define FBIO_PXA270_SETSCROLL_FLIP0     SONY_NAVU_FBIO_SETSCROLL_FLIP0

#define FBIO_PXA270_WAITVSYNC           SONY_NAVU_FBIO_WAITVSYNC
#define FBIO_PXA270_WAITSTARTFRAME      SONY_NAVU_FBIO_WAITSTARTFRAME

#define FBIO_PXA270_STARTCAPTURE        SONY_NAVU_FBIO_STARTCAPTURE
#define FBIO_PXA270_STOPCAPTURE         SONY_NAVU_FBIO_STOPCAPTURE
#define FBIO_PXA270_GETFRAMEVIDEO       SONY_NAVU_FBIO_GETFRAMEVIDEO
#define FBIO_PXA270_GETDISPVIDEO        SONY_NAVU_FBIO_GETDISPVIDEO
#define FBIO_PXA270_GETBASEVIDEO_Y      SONY_NAVU_FBIO_GETBASEVIDEO_Y
#define FBIO_PXA270_GETBASEVIDEO_B      SONY_NAVU_FBIO_GETBASEVIDEO_B
#define FBIO_PXA270_GETBASEVIDEO_R      SONY_NAVU_FBIO_GETBASEVIDEO_R

typedef SONY_NAVU_GETSCROLL0         MXCFB_GETSCROLL0;
typedef SONY_NAVU_SETSCROLL0         MXCFB_SETSCROLL0;
typedef SONY_NAVU_SETSCROLL_FLIP0    MXCFB_SETSCROLL_FLIP0;
typedef SONY_NAVU_DISPSETTING0       MXCFB_DISPSETTING0;
typedef SONY_NAVU_DISPSETTING1       MXCFB_DISPSETTING1;
typedef SONY_NAVU_DISPSETTING2       MXCFB_DISPSETTING2;
typedef SONY_NAVU_FRAMESETTINGVIDEO  MXCFB_FRAMESETTINGVIDEO;
typedef SONY_NAVU_DISPSETTINGVIDEO   MXCFB_DISPSETTINGVIDEO;

typedef MXCFB_GETSCROLL0         PXA270_GETSCROLL0;
typedef MXCFB_SETSCROLL0         PXA270_SETSCROLL0;
typedef MXCFB_SETSCROLL_FLIP0    PXA270_SETSCROLL_FLIP0;
typedef MXCFB_DISPSETTING0       PXA270_DISPSETTING0;
typedef MXCFB_DISPSETTING1       PXA270_DISPSETTING1;
typedef MXCFB_DISPSETTING2       PXA270_DISPSETTING2;
typedef MXCFB_FRAMESETTINGVIDEO  PXA270_FRAMESETTINGVIDEO;
typedef MXCFB_DISPSETTINGVIDEO   PXA270_DISPSETTINGVIDEO;

#endif /* __NAVUFB_H__ */
