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