1 /* 2 * Copyright 2015 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef __VEPU541_COMMON_H__ 17 #define __VEPU541_COMMON_H__ 18 19 #include "rk_venc_cmd.h" 20 #include "mpp_device.h" 21 #include "vepu5xx_common.h" 22 23 #define VEPU541_REG_BASE_HW_STATUS 0x0000001C 24 #define VEPU541_REG_BASE_STATISTICS 0x00000210 25 #define VEPU541_REG_BASE_OSD_PLT 0x00000400 26 #define VEPU541_REG_BASE_L2 0x00010004 27 28 #define VEPU541_MAX_ROI_NUM 8 29 30 /* 31 * Vepu541RoiCfg 32 * 33 * Each Vepu541RoiCfg in roi buffer indicates a 16x16 cu encoding config at 34 * corresponding position. 35 * 36 * NOTE: roi buffer should be aligned to 64x64 each is 4 16x16 in horizontal 37 * and 4 16x16 in vertical. So the buffer need to be enlarged to avoid hardware 38 * access error. 39 */ 40 typedef struct Vepu541RoiCfg_t { 41 /* 42 * Force_intra 43 * 1 - The corresponding 16x16cu is forced to be intra 44 * 0 - Not force to intra 45 */ 46 RK_U16 force_intra : 1; 47 RK_U16 reserved : 3; 48 /* 49 * Qp area index 50 * The choosed qp area index. 51 */ 52 RK_U16 qp_area_idx : 3; 53 /* 54 * Area qp limit function enable flag 55 * Force to be true in vepu541 56 */ 57 RK_U16 qp_area_en : 1; 58 /* 59 * Qp_adj 60 * Qp_adj 61 * in absolute qp mode qp_adj is the final qp used by encoder 62 * in relative qp mode qp_adj is a adjustment to final qp 63 */ 64 RK_S16 qp_adj : 7; 65 /* 66 * Qp_adj_mode 67 * Qp adjustment mode 68 * 1 - absolute qp mode: 69 * the 16x16 MB qp is set to the qp_adj value 70 * 0 - relative qp mode 71 * the 16x16 MB qp is adjusted by qp_adj value 72 */ 73 RK_U16 qp_adj_mode : 1; 74 } Vepu541RoiCfg; 75 76 typedef struct Vepu541OsdPos_t { 77 /* X coordinate/16 of OSD region's left-top point. */ 78 RK_U32 osd_lt_x : 8; 79 /* Y coordinate/16 of OSD region's left-top point. */ 80 RK_U32 osd_lt_y : 8; 81 /* X coordinate/16 of OSD region's right-bottom point. */ 82 RK_U32 osd_rb_x : 8; 83 /* Y coordinate/16 of OSD region's right-bottom point. */ 84 RK_U32 osd_rb_y : 8; 85 } Vepu541OsdPos; 86 87 typedef struct Vepu541B8NumQp_t { 88 RK_U32 b8num_qp : 18; 89 RK_U32 reserved : 14; 90 } Vepu541B8NumQp; 91 92 #ifdef __cplusplus 93 extern "C" { 94 #endif 95 96 /* 97 * roi function 98 * 99 * vepu541_get_roi_buf_size 100 * Calculate roi buffer size for image with size w * h 101 * 102 * vepu541_set_roi 103 * Setup roi config buffeer for image with mb count mb_w * mb_h 104 */ 105 RK_S32 vepu541_get_roi_buf_size(RK_S32 w, RK_S32 h); 106 MPP_RET vepu541_set_roi(void *buf, MppEncROICfg *roi, RK_S32 w, RK_S32 h); 107 MPP_RET vepu541_set_one_roi(void *buf, MppEncROIRegion *region, RK_S32 w, RK_S32 h); 108 109 MPP_RET vepu541_set_osd(Vepu5xxOsdCfg *cfg); 110 MPP_RET vepu540_set_osd(Vepu5xxOsdCfg *cfg); 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* __VEPU541_COMMON_H__ */ 117