lin
2025-02-18 59b6413ea46963124667e54dd4348d204bcf94d5
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
/* g2d_driver_i.h
 *
 * Copyright (c)    2011 Allwinnertech Co., Ltd.
 *                    2011 Yupu Tang
 *
 * @ 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_DRIVER_I_H
#define __G2D_DRIVER_I_H
 
#include "g2d_bsp.h"
 
/* #include "g2d_bsp_v2.h" */
 
#define G2D_DEBUG    1
#ifdef    G2D_DEBUG
#define    DBG(format, args...) pr_debug("%s: " format, "G2D", ## args)
#else
#define    DBG(format, args...)
#endif
#define ERR(format, args...) pr_err("%s: " format, "G2D", ## args)
#define WARNING(format, args...) \
   pr_warn("%s: " format, "G2D", ## args)
#define INFO(format, args...) pr_info("%s: " format, "G2D", ## args)
 
#define MAX_G2D_MEM_INDEX    10
#define    INTC_IRQNO_DE_MIX    SUNXI_IRQ_MP
 
#define G2DALIGN(value, align) ((align == 0) ? \
               value : \
               (((value) + ((align) - 1)) & ~((align) - 1)))
 
#if ((defined CONFIG_ARCH_SUN8IW12P1) || (defined CONFIG_ARCH_SUN8IW15P1) || \
                   (defined CONFIG_ARCH_SUN8IW17P1) || \
                   (defined CONFIG_ARCH_SUN50IW9P1) || \
                   (defined CONFIG_ARCH_SUN8IW16P1) || \
                   (defined CONFIG_ARCH_SUN50IW10P1))
#define G2D_V2X_SUPPORT
#endif
 
struct info_mem {
   unsigned long phy_addr;
   void *virt_addr;
   __u32 b_used;
   __u32 mem_len;
};
 
typedef struct {
   struct device *dev;
   struct resource *mem;
   void __iomem *io;
   __u32 irq;
   struct mutex mutex;
   struct clk *clk;
   bool opened;
   __u32 user_cnt;
   struct clk *clk_parent;
} __g2d_info_t;
 
typedef struct {
   __u32 mid;
   __u32 used;
   __u32 status;
   struct semaphore *g2d_finished_sem;
   struct semaphore *event_sem;
   wait_queue_head_t queue;
   __u32 finish_flag;
} __g2d_drv_t;
 
struct g2d_alloc_struct {
   __u32 address;
   __u32 size;
   __u32 u_size;
   struct g2d_alloc_struct *next;
};
 
/* g2d_format_attr - g2d format attribute
 *
 * @format: pixel format
 * @bits: bits of each component
 * @hor_rsample_u: reciprocal of horizontal sample rate
 * @hor_rsample_v: reciprocal of horizontal sample rate
 * @ver_rsample_u: reciprocal of vertical sample rate
 * @hor_rsample_v: reciprocal of vertical sample rate
 * @uvc: 1: u & v component combined
 * @interleave: 0: progressive, 1: interleave
 * @factor & div: bytes of pixel = factor / div (bytes)
 * @addr[out]: address for each plane
 * @trd_addr[out]: address for each plane of right eye buffer
 */
struct g2d_format_attr {
   g2d_fmt_enh format;
   unsigned int bits;
   unsigned int hor_rsample_u;
   unsigned int hor_rsample_v;
   unsigned int ver_rsample_u;
   unsigned int ver_rsample_v;
   unsigned int uvc;
   unsigned int interleave;
   unsigned int factor;
   unsigned int div;
};
 
 
irqreturn_t g2d_handle_irq(int irq, void *dev_id);
int g2d_init(g2d_init_para *para);
int g2d_blit(g2d_blt *para);
int g2d_fill(g2d_fillrect *para);
int g2d_stretchblit(g2d_stretchblt *para);
/* int g2d_set_palette_table(g2d_palette *para); */
int g2d_wait_cmd_finish(void);
int g2d_cmdq(unsigned int para);
static int g2d_suspend(struct device *dev);
static int g2d_resume(struct device *dev);
 
#endif /* __G2D_DRIVER_I_H */