• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* g2d_bsp.h
2  *
3  * Copyright (c)	2016 Allwinnertech Co., Ltd.
4  *					2016 gqs
5  *
6  * G2D driver
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
16  * GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef __G2D_BSP_H
21 #define __G2D_BSP_H
22 
23 #include "linux/kernel.h"
24 #include "linux/mm.h"
25 #include <asm/uaccess.h>
26 #include <asm/memory.h>
27 #include <asm/unistd.h>
28 #include "linux/semaphore.h"
29 #include <linux/vmalloc.h>
30 #include <linux/fs.h>
31 #include <linux/dma-mapping.h>
32 #include <linux/fb.h>
33 #include <linux/sched.h>
34 #include <linux/kthread.h>
35 #include <linux/err.h>
36 #include <linux/delay.h>
37 #include <linux/platform_device.h>
38 #include "asm-generic/int-ll64.h"
39 #include <linux/module.h>
40 #include <linux/errno.h>
41 #include <linux/slab.h>
42 #include <linux/delay.h>
43 #include <linux/init.h>
44 #include <linux/dma-mapping.h>
45 #include <linux/interrupt.h>
46 #include <linux/platform_device.h>
47 #include <linux/clk.h>
48 #include <linux/cdev.h>
49 #include <linux/types.h>
50 #include <linux/of_irq.h>
51 #include <linux/of_address.h>
52 #include <linux/of_iommu.h>
53 #include <linux/of_device.h>
54 #include <linux/of_platform.h>
55 #include <linux/string.h>
56 #include <sunxi-g2d.h>
57 #include <linux/dma-buf.h>
58 #include <linux/reset.h>
59 
60 #define G2D_FINISH_IRQ		(1<<8)
61 #define G2D_ERROR_IRQ			(1<<9)
62 
63 extern u32 dbg_info;
64 
65 #define G2D_INFO_MSG(fmt, args...) \
66 	do {\
67 		if (dbg_info)\
68 		pr_info("[G2D-%s] line:%d: " fmt, __func__, __LINE__, ##args);\
69 	} while (0)
70 
71 typedef struct {
72 	unsigned long g2d_base;
73 } g2d_init_para;
74 
75 typedef struct {
76 	g2d_init_para init_para;
77 } g2d_dev_t;
78 
79 typedef enum {
80 	G2D_RGB2YUV_709,
81 	G2D_YUV2RGB_709,
82 	G2D_RGB2YUV_601,
83 	G2D_YUV2RGB_601,
84 	G2D_RGB2YUV_2020,
85 	G2D_YUV2RGB_2020,
86 } g2d_csc_sel;
87 
88 typedef enum {
89 	VSU_FORMAT_YUV422 = 0x00,
90 	VSU_FORMAT_YUV420 = 0x01,
91 	VSU_FORMAT_YUV411 = 0x02,
92 	VSU_FORMAT_RGB = 0x03,
93 	VSU_FORMAT_BUTT = 0x04,
94 } vsu_pixel_format;
95 
96 #define VSU_ZOOM0_SIZE	1
97 #define VSU_ZOOM1_SIZE	8
98 #define VSU_ZOOM2_SIZE	4
99 #define VSU_ZOOM3_SIZE	1
100 #define VSU_ZOOM4_SIZE	1
101 #define VSU_ZOOM5_SIZE	1
102 
103 #define VSU_PHASE_NUM            32
104 #define VSU_PHASE_FRAC_BITWIDTH  19
105 #define VSU_PHASE_FRAC_REG_SHIFT 1
106 #define VSU_FB_FRAC_BITWIDTH     32
107 
108 #define VI_LAYER_NUMBER 1
109 #define UI_LAYER_NUMBER 3
110 
111 __s32 g2d_bsp_open(void);
112 __s32 g2d_bsp_close(void);
113 __s32 g2d_bsp_reset(void);
114 __s32 mixer_irq_query(void);
115 __s32 rot_irq_query(void);
116 __s32 g2d_mixer_reset(void);
117 __s32 g2d_rot_reset(void);
118 __s32 g2d_bsp_bld(g2d_image_enh *, g2d_image_enh *, __u32, g2d_ck *);
119 __s32 g2d_fillrectangle(g2d_image_enh *dst, __u32 color_value);
120 __s32 g2d_bsp_maskblt(g2d_image_enh *src, g2d_image_enh *ptn,
121 		      g2d_image_enh *mask, g2d_image_enh *dst,
122 		      __u32 back_flag, __u32 fore_flag);
123 __s32 g2d_bsp_bitblt(g2d_image_enh *src, g2d_image_enh *dst, __u32 flag);
124 __s32 g2d_byte_cal(__u32 format, __u32 *ycnt, __u32 *ucnt, __u32 *vcnt);
125 
126 extern int g2d_wait_cmd_finish(void);
127 
128 __u32	mixer_reg_init(void);
129 __s32	mixer_blt(g2d_blt *para, enum g2d_scan_order scan_order);
130 __s32	mixer_fillrectangle(g2d_fillrect *para);
131 __s32	mixer_stretchblt(g2d_stretchblt *para, enum g2d_scan_order scan_order);
132 __s32	mixer_maskblt(g2d_maskblt *para);
133 __u32	mixer_set_palette(g2d_palette *para);
134 __u64	mixer_get_addr(__u32 buffer_addr, __u32 format,
135 			__u32 stride, __u32 x, __u32 y);
136 __u32	mixer_set_reg_base(unsigned long addr);
137 __u32	mixer_get_irq(void);
138 __u32	mixer_get_irq0(void);
139 __u32	mixer_clear_init(void);
140 __u32	mixer_clear_init0(void);
141 __s32	mixer_cmdq(__u32 addr);
142 __u32	mixer_premultiply_set(__u32 flag);
143 __u32	mixer_micro_block_set(g2d_blt *para);
144 
145 #endif	/* __G2D_BSP_H */
146 
147