/* rts_g2d_driver.h
 *
 * Copyright(c) 2019 Realtek Semiconductor Corp.
 *
 * @author shawn_chen@realsil.com.cn
 *
 * 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; either version 2 of the 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 warranty 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, MA02111-1307USA
 */

#ifndef __G2D_DRIVER_H
#define __G2D_DRIVER_H

#define G2D_DEVNAME "rtsg2d"

/* mixer data format */
enum g2d_data_fmt {
	G2D_FMT_8BPP_PALETTE = 0,

	G2D_FMT_RGB565,

	G2D_FMT_ARGB1555,
	G2D_FMT_RGBA5551,

	G2D_FMT_ARGB4444,
	G2D_FMT_RGBA4444,

	G2D_FMT_ARGB8888,
	G2D_FMT_RGBA8888,

	G2D_FMT_RGB888,

	G2D_FMT_YUV420_NV12,
	G2D_FMT_YUV420_NV16,

	G2D_FMT_YUV422_YUY2,
	G2D_FMT_YUV422_UYUV,
};

/* pixel sequence in double word */
enum g2d_pixel_seq {
	G2D_SEQ_NORMAL = 0x0,
};

enum g2d_fillrect_flags {
	G2D_FIL_NONE = 0,
	G2D_FIL_PIXEL_ALPHA,
	G2D_FIL_PLANE_ALPHA,
	G2D_FIL_MULTI_ALPHA,
};

enum g2d_blt_flags {
	G2D_BLT_NONE = 0,
	G2D_BLT_PIXEL_ALPHA,
	G2D_BLT_PLANE_ALPHA,
	G2D_BLT_MULTI_ALPHA,
	G2D_BLT_SRC_COLORKEY,
	G2D_BLT_DST_COLORKEY,
};

enum g2d_rotate_flags {
	G2D_ROTATE90 = 0,
	G2D_ROTATE180,
	G2D_ROTATE270,
};

enum g2d_mirror_flags {
	G2D_MIRROR_X = 1,
	G2D_MIRROR_Y,
	G2D_MIRROR_XY
};

/* rectangle struct */
struct g2d_rect {
	__u32 x;			/* left top point coordinate x */
	__u32 y;			/* left top point coordinate y */
	__u32 w;			/* rectangle width */
	__u32 h;			/* rectangle height */
};

/* image struct */
struct g2d_image {
	__u32 addr[3]; /* base addr of image frame buffer in byte */
	__u32 w; /* width of image frame buffer in pixel */
	__u32 h; /* height of image frame buffer in pixel */
	enum g2d_data_fmt format; /* pixel format of image frame buffer */
	enum g2d_pixel_seq pixel_seq; /* pixel sequence of image frame buffer */
};

struct g2d_blt {
	enum g2d_blt_flags flag;
	struct g2d_image src_image;
	struct g2d_rect	src_rect;
	struct g2d_image dst_image;
	__u32 dst_x;		/* left top point coordinate x of dst rect */
	__u32 dst_y;		/* left top point coordinate y of dst rect */
	__u32 colorkey;		/* colorkey color in RGB */
	__u8 src_alpha;		/* plane alpha value */
	__u8 dst_alpha;		/* plane alpha value */
};

struct g2d_rotate {
	enum g2d_rotate_flags flag;
	struct g2d_image src_image;
	struct g2d_rect src_rect;
	struct g2d_image dst_image;
	__s32 dst_x;		/* left top point coordinate x of dst rect */
	__s32 dst_y;		/* left top point coordinate y of dst rect */
};

struct g2d_mirror {
	enum g2d_mirror_flags flag;
	struct g2d_image src_image;
	struct g2d_rect src_rect;
	struct g2d_image dst_image;
	__s32 dst_x;		/* left top point coordinate x of dst rect */
	__s32 dst_y;		/* left top point coordinate y of dst rect */
};

struct g2d_fillrect {
	__u32 color;		/* color */
	struct g2d_rect dst_rect;
	struct g2d_image dst_image;
};

struct g2d_stretch {
	enum g2d_blt_flags flag;
	struct g2d_image src_image;
	struct g2d_rect src_rect;
	struct g2d_image dst_image;
	struct g2d_rect dst_rect;
	__u32 color;		/* colorkey color */
	__u32 alpha;		/* plane alpha value */
};

struct g2d_formatconv {
	struct g2d_image src_image;
	struct g2d_rect src_rect;
	struct g2d_image dst_image;
	__s32 dst_x;		/* left top point coordinate x of dst rect */
	__s32 dst_y;		/* left top point coordinate y of dst rect */
};

struct g2d_palette {
	__u32 *pbuffer;
	__u32 size;
};

enum g2d_cmd {
	G2D_CMD_BITBLT = 0x50,
	G2D_CMD_STRETCH,
	G2D_CMD_FILLRECT,
	G2D_CMD_DRAWRECT,
	G2D_CMD_PALETTE_TBL,
	G2D_CMD_ROTATE,
	G2D_CMD_MIRROR,
	G2D_CMD_FORMAT_CONV,
	G2D_CMD_NOP,
	G2D_CMD_PATCH16BPP,

	G2D_CMD_MEM_REQUEST	= 0x60,
	G2D_CMD_MEM_RELEASE,
	G2D_CMD_MEM_GETADR,
	G2D_CMD_MEM_SELIDX,
};

#endif	/* __G2D_DRIVER_H */
