1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License as published by the 6 * Free Software Foundation; either version 2 of the License, or (at your 7 * option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * 17 */ 18 19 #include "mkp_vo_init.h" 20 #include "mkp_vo_dev.h" 21 #include "mkp_vo_gfx.h" 22 #include "mkp_vo_video.h" 23 #include "vo.h" 24 #include "hi_common_vo.h" 25 #include "hi_common_video.h" 26 27 #include "mkp_vo.h" 28 #include "sys_ext.h" 29 30 #include "hi_board.h" 31 #include "drv_vo.h" 32 33 #if VO_DESC("clk init") vo_init_set_sys_clk(hi_void)34static hi_void vo_init_set_sys_clk(hi_void) 35 { 36 vo_lpw_bus_reset(HI_FALSE); 37 } 38 vo_init_crg_clk(hi_void)39static hi_void vo_init_crg_clk(hi_void) 40 { 41 vo_drv_set_all_crg_clk(HI_TRUE); 42 } 43 vo_init_board(hi_void)44static hi_void vo_init_board(hi_void) 45 { 46 vo_drv_board_init(); 47 } 48 #endif 49 50 #if VO_DESC("init context") 51 vo_init_context(hi_void)52static hi_void vo_init_context(hi_void) 53 { 54 vo_init_dev_info(); 55 56 vo_init_layer_resource(); 57 } 58 #endif 59 60 #if VO_DESC("vo init flag") 61 62 static hi_bool g_is_initialized = HI_FALSE; vo_get_vo_init_flag(hi_void)63hi_bool vo_get_vo_init_flag(hi_void) 64 { 65 return g_is_initialized; 66 } 67 vo_set_vo_init_flag(hi_bool flag)68static hi_void vo_set_vo_init_flag(hi_bool flag) 69 { 70 g_is_initialized = flag; 71 } 72 #endif 73 74 #if VO_DESC("init operation") 75 vo_init(hi_void)76hi_s32 vo_init(hi_void) 77 { 78 hi_vo_dev dev; 79 hi_vo_layer layer; 80 if (vo_get_vo_init_flag() == HI_FALSE) { 81 /* unreset */ 82 vo_init_set_sys_clk(); 83 84 /* clk enable */ 85 vo_init_crg_clk(); 86 87 /* step1: init drv context */ 88 vo_init_context(); 89 90 /* step2: init mkp context */ 91 for (dev = 0; dev < HI_VO_MAX_PHYS_DEV_NUM; dev++) { 92 vo_init_dev_ctx(dev); 93 } 94 for (layer = 0; layer < HI_VO_MAX_PHYS_VIDEO_LAYER_NUM; layer++) { 95 vo_init_layer_ctx(layer); 96 } 97 98 /* step3: init mkp gfx context */ 99 vo_init_gfx(); 100 101 /* hardware init */ 102 vo_init_board(); 103 104 vo_set_vo_init_flag(HI_TRUE); 105 } 106 107 return HI_SUCCESS; 108 } 109 #endif 110