1 /* 2 * Allwinner SoCs display driver. 3 * 4 * Copyright (C) 2016 Allwinner. 5 * 6 * This file is licensed under the terms of the GNU General Public 7 * License version 2. This program is licensed "as is" without any 8 * warranty of any kind, whether express or implied. 9 */ 10 11 /** 12 * All Winner Tech, All Right Reserved. 2014-2015 Copyright (c) 13 * 14 * File name : de_scaler.h 15 * 16 * Description : display engine 2.0 gsu/vsu basic function 17 * declaration 18 * 19 * History : 2014/03/20 vito cheng v0.1 Initial version 20 * 21 */ 22 23 #ifndef __DE_SCALER_H__ 24 #define __DE_SCALER_H__ 25 26 #include "de_rtmx.h" 27 28 /* GSU configuration */ 29 #define GSU_PHASE_NUM 16 30 /* bit19 to bit2 is fraction part */ 31 #define GSU_PHASE_FRAC_BITWIDTH 18 32 /* bit19 to bit2 is fraction part, and bit1 to bit0 is void */ 33 #define GSU_PHASE_FRAC_REG_SHIFT 2 34 /* frame buffer information fraction part bit width */ 35 #define GSU_FB_FRAC_BITWIDTH 32 36 37 /* VSU configuration */ 38 #define VSU_PHASE_NUM 32 39 /* bit19 to bit1 is fraction part */ 40 #define VSU_PHASE_FRAC_BITWIDTH 19 41 /* bit19 to bit1 is fraction part, and bit0 is void */ 42 #define VSU_PHASE_FRAC_REG_SHIFT 1 43 /* frame buffer information fraction part bit width */ 44 #define VSU_FB_FRAC_BITWIDTH 32 45 46 /* GSU/VSU size limitation */ 47 /* VSU0 offset based on RTMX */ 48 #define VSU_OFST 0x20000 49 #define SC_MIN_WIDTH 32 50 #define SC_MIN_HEIGHT 8 51 52 enum vsu_pixel_format { 53 VSU_FORMAT_YUV422 = 0x00, 54 VSU_FORMAT_YUV420 = 0x01, 55 VSU_FORMAT_YUV411 = 0x02, 56 VSU_FORMAT_RGB = 0x03 57 }; 58 59 /* VSU FUNCTION */ 60 int de_vsu_init(unsigned int sel, uintptr_t reg_base); 61 int de_vsu_exit(unsigned int sel); 62 int de_vsu_update_regs(unsigned int sel); 63 int de_vsu_set_reg_base(unsigned int sel, unsigned int chno, void *base); 64 int de_vsu_enable(unsigned int sel, unsigned int chno, unsigned int en); 65 int de_vsu_set_para(unsigned int sel, unsigned int chno, unsigned int enable, 66 unsigned char fmt, unsigned int in_w, unsigned int in_h, 67 unsigned int out_w, unsigned int out_h, 68 struct scaler_para *ypara, struct scaler_para *cpara); 69 int de_vsu_calc_scaler_para(unsigned char fmt, struct de_rect64 crop, 70 struct de_rect frame, struct de_rect *crop_fix, 71 struct scaler_para *ypara, struct scaler_para *cpara); 72 int de_vsu_sel_ovl_scaler_para(unsigned char *en, 73 struct scaler_para *layer_luma_scale_para, 74 struct scaler_para *layer_chroma_scale_para, 75 struct scaler_para *ovl_luma_scale_para, 76 struct scaler_para *ovl_chroma_scale_para); 77 int de_vsu_recalc_scale_para(int coarse_status, unsigned int vsu_outw, 78 unsigned int vsu_outh, unsigned int vsu_inw, 79 unsigned int vsu_inh, unsigned int vsu_inw_c, 80 unsigned int vsu_inh_c, struct scaler_para *fix_y_para, 81 struct scaler_para *fix_c_para); 82 int de_recalc_ovl_bld_for_scale(unsigned int scaler_en, unsigned char *lay_en, 83 int laynum, struct scaler_para *step, struct de_rect *layer, 84 struct de_rect *bld_rect, unsigned int *ovlw, 85 unsigned int *ovlh, unsigned int gsu_sel, 86 unsigned int scn_w, unsigned scn_h); 87 88 /* GSU FUNCTION */ 89 int de_gsu_init(unsigned int sel, uintptr_t reg_base); 90 int de_gsu_exit(unsigned int sel); 91 int de_gsu_update_regs(unsigned int sel); 92 int de_gsu_set_reg_base(unsigned int sel, unsigned int chno, void *base); 93 int de_gsu_enable(unsigned int sel, unsigned int chno, unsigned int en); 94 int de_gsu_set_para(unsigned int sel, unsigned int chno, unsigned int enable, 95 unsigned int in_w, unsigned int in_h, unsigned int out_w, 96 unsigned int out_h, struct scaler_para *para); 97 int de_gsu_calc_scaler_para(struct de_rect64 crop, struct de_rect frame, 98 struct de_rect *crop_fix, struct scaler_para *para); 99 int de_calc_ovl_coord(unsigned int frame_coord, unsigned int scale_step, 100 int gsu_sel); 101 int de_gsu_sel_ovl_scaler_para(unsigned char *en, 102 struct scaler_para *layer_scale_para, 103 struct scaler_para *ovl_scale_para); 104 105 #endif 106