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 18 #include <stdlib.h> 19 #include <string.h> 20 #ifndef _G2D_RCQ_H 21 #define _G2D_RCQ_H 22 23 #include "g2d_bsp.h" 24 25 /*32 byte align required by rcq*/ 26 #define G2D_RCQ_BYTE_ALIGN(x) (((x + (32 - 1)) >> 5) << 5) 27 /* 2 align */ 28 #define G2D_RCQ_HEADER_ALIGN(x) (((x + 1) >> 1) << 1) 29 30 31 #define G2D_MIXER_RCQ_USED 1 32 33 union rcq_hd_dw0 { 34 __u32 dwval; 35 struct { 36 __u32 len:24; 37 __u32 high_addr:8; 38 } bits; 39 }; 40 41 union rcq_hd_dirty { 42 __u32 dwval; 43 struct { 44 __u32 dirty:1; 45 __u32 res0:15; 46 __u32 n_header_len : 16; /*next frame header length*/ 47 } bits; 48 }; 49 50 struct g2d_rcq_head { 51 __u32 low_addr; /* 32 bytes align */ 52 union rcq_hd_dw0 dw0; 53 union rcq_hd_dirty dirty; 54 __u32 reg_offset; /* offset_addr based on g2d_reg_base */ 55 }; 56 57 /* 58 * @phy_addr: must be 32 bytes align, can not be accessed by cpu. 59 * @vir_addr: for cpu access. 60 * @size: unit: byte. must be 2 bytes align. 61 * @reg_addr: reg base addr of this block. 62 * @dirty: this block need be updated to hw reg if @dirty is true. 63 * @rcq_hd: pointer to rcq head of this dma_reg block at rcq mode. 64 * @block_id: unique id for current block 65 */ 66 struct g2d_reg_block { 67 u8 *phy_addr; 68 u8 *vir_addr; 69 __u32 size; 70 u8 *reg_addr; 71 __u32 dirty; 72 struct g2d_rcq_head *rcq_hd; 73 __u32 block_id; 74 }; 75 76 struct g2d_reg_mem_info { 77 u8 *phy_addr; /* it is non-null at rcq mode */ 78 u8 *vir_addr; 79 __u32 size; 80 }; 81 82 struct g2d_rcq_mem_info { 83 u8 *phy_addr; 84 struct g2d_rcq_head *vir_addr; 85 struct g2d_reg_block **reg_blk; 86 __u32 alloc_num; 87 __u32 cur_num; 88 __u32 block_num_per_frame; 89 __u32 alloc_num_per_frame; 90 __u32 rcq_header_len; 91 __u32 rcq_byte_used; 92 __u32 rcq_reg_mem_size; 93 }; 94 __s32 g2d_top_mem_pool_alloc(struct g2d_rcq_mem_info *p_rcq_info); 95 void *g2d_top_reg_memory_alloc(__u32 size, void *phy_addr, 96 struct g2d_rcq_mem_info *p_rcq_info); 97 void g2d_top_mem_pool_free(struct g2d_rcq_mem_info *p_rcq_info); 98 99 #endif /*End of file*/ 100