• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * g2d_rcq/g2d_rcq.h
3  *
4  * Copyright (c) 2007-2019 Allwinnertech Co., Ltd.
5  * Author: zhengxiaobin <zhengxiaobin@allwinnertech.com>
6  *
7  * This software is licensed under the terms of the GNU General Public
8  * License version 2, as published by the Free Software Foundation, and
9  * may be copied, distributed, and modified under those terms.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  */
17 #ifndef _G2D_RCQ_H
18 #define _G2D_RCQ_H
19 
20 #include "g2d_bsp.h"
21 
22 /*32 byte align required by rcq*/
23 #define G2D_RCQ_BYTE_ALIGN(x) (((x + (32 - 1)) >> 5) << 5)
24 /* 2 align */
25 #define G2D_RCQ_HEADER_ALIGN(x) (((x + 1) >> 1) << 1)
26 
27 
28 #define G2D_MIXER_RCQ_USED 1
29 
30 union rcq_hd_dw0 {
31 	__u32 dwval;
32 	struct {
33 		__u32 len:24;
34 		__u32 high_addr:8;
35 	} bits;
36 };
37 
38 union rcq_hd_dirty {
39 	__u32 dwval;
40 	struct {
41 		__u32 dirty:1;
42 		__u32 res0:15;
43 		__u32 n_header_len : 16; /*next frame header length*/
44 	} bits;
45 };
46 
47 struct g2d_rcq_head {
48 	__u32 low_addr; /* 32 bytes align */
49 	union rcq_hd_dw0 dw0;
50 	union rcq_hd_dirty dirty;
51 	__u32 reg_offset; /* offset_addr based on g2d_reg_base */
52 };
53 
54 /*
55 * @phy_addr: must be 32 bytes align, can not be accessed by cpu.
56 * @vir_addr: for cpu access.
57 * @size: unit: byte. must be 2 bytes align.
58 * @reg_addr: reg base addr of this block.
59 * @dirty: this block need be updated to hw reg if @dirty is true.
60 * @rcq_hd: pointer to rcq head of this dma_reg block at rcq mode.
61 * @block_id: unique id for current block
62 */
63 struct g2d_reg_block {
64 	u8 __iomem *phy_addr;
65 	u8 *vir_addr;
66 	__u32 size;
67 	u8 __iomem *reg_addr;
68 	__u32 dirty;
69 	struct g2d_rcq_head *rcq_hd;
70 	__u32 block_id;
71 };
72 
73 struct g2d_reg_mem_info {
74 	u8 __iomem *phy_addr; /* it is non-null at rcq mode */
75 	u8 *vir_addr;
76 	__u32 size;
77 };
78 
79 struct g2d_rcq_mem_info {
80 	u8 __iomem *phy_addr;
81 	struct g2d_rcq_head *vir_addr;
82 	struct g2d_reg_block **reg_blk;
83 	__u32 alloc_num;
84 	__u32 cur_num;
85 	__u32 block_num_per_frame;
86 	__u32 alloc_num_per_frame;
87 	__u32 rcq_header_len;
88 	__u32 rcq_byte_used;
89 	__u32 rcq_reg_mem_size;
90 };
91 __s32 g2d_top_mem_pool_alloc(struct g2d_rcq_mem_info *p_rcq_info);
92 void *g2d_top_reg_memory_alloc(__u32 size, void *phy_addr,
93 			       struct g2d_rcq_mem_info *p_rcq_info);
94 void g2d_top_mem_pool_free(struct g2d_rcq_mem_info *p_rcq_info);
95 
96 #endif /*End of file*/
97