• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your 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, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #include "vou_proc.h"
20 #include "vou.h"
21 #include "vou_graphics.h"
22 #include "securec.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif /* end of #ifdef __cplusplus */
29 
vo_proc_get_intf_mux_name(hi_u32 intf_type_index)30 static hi_char *vo_proc_get_intf_mux_name(hi_u32 intf_type_index)
31 {
32     hi_char *intf_type_name[VO_MAX_INTF_TYPE_NUM] = {
33         "     CVBS", "    YPbPr", "      VGA", "    BT656", "   BT1120", "     HDMI", "      LCD", "   BT656H",
34         "   BT656L", " LCD_6BIT", " LCD_8BIT", "LCD_16BIT", "LCD_18BIT", "LCD_24BIT", "     MIPI", "   MIPI_S"
35     };
36 
37     if (intf_type_index >= VO_MAX_INTF_TYPE_NUM) {
38         return "         ";
39     }
40 
41     return intf_type_name[intf_type_index];
42 }
43 
vo_proc_get_intf_mux(hi_u32 intf_type_index,hi_char * mux_name,hi_u32 mux_name_len)44 static hi_s32 vo_proc_get_intf_mux(hi_u32 intf_type_index, hi_char *mux_name, hi_u32 mux_name_len)
45 {
46     hi_s32 ret;
47 
48     ret = strncpy_s(mux_name, mux_name_len, vo_proc_get_intf_mux_name(intf_type_index), VO_MAX_INTFNAME_LEN - 1);
49     if (ret != EOK) {
50         vo_err_trace("get intf type index %u mux name fail\n", intf_type_index);
51         return HI_FAILURE;
52     }
53 
54     return HI_SUCCESS;
55 }
56 
vou_print_mux(hi_vo_intf_type intf_type,hi_char (* asz)[VO_MAX_INTFNAME_LEN])57 static hi_void vou_print_mux(hi_vo_intf_type intf_type, hi_char (*asz)[VO_MAX_INTFNAME_LEN])
58 {
59     hi_s32 i = 0;
60     hi_u32 j;
61     hi_s32 ret;
62 
63     for (j = 0; j < VO_MAX_MUX_NUM; j++) {
64         ret = strncpy_s(asz[j], VO_MAX_INTFNAME_LEN, "         ", VO_MAX_INTFNAME_LEN - 1);
65         if (ret != EOK) {
66             vo_err_trace("init mux name fail\n");
67             return;
68         }
69     }
70 
71     for (j = 0; j < VO_MAX_INTF_TYPE_NUM; j++) {
72         if ((intf_type >> j) & 0x01L) {
73             if (i >= VO_MAX_MUX_NUM) {
74                 break;
75             }
76             ret = vo_proc_get_intf_mux(j, asz[i], VO_MAX_INTFNAME_LEN);
77             if (ret != HI_SUCCESS) {
78                 return;
79             }
80             i++;
81         }
82     }
83 
84     for (j = 0; j < VO_MAX_MUX_NUM; j++) {
85         asz[j][VO_MAX_INTFNAME_LEN - 1] = '\0';
86     }
87 }
88 
vou_print_out_mode(hi_vo_intf_sync intf_sync)89 static hi_char *vou_print_out_mode(hi_vo_intf_sync intf_sync)
90 {
91     vo_sync_basic_info *sync_basic_info = vo_get_sync_basic_info();
92     if (intf_sync >= VO_OUTPUT_PAL && intf_sync <= VO_OUTPUT_USER) {
93         if (sync_basic_info[intf_sync].index == intf_sync) {
94             return sync_basic_info[intf_sync].name;
95         } else {
96             return "-";
97         }
98     } else {
99         return "-";
100     }
101 }
102 
vou_print_clk_source(hi_vo_clk_source clk_source)103 static hi_char *vou_print_clk_source(hi_vo_clk_source clk_source)
104 {
105     switch (clk_source) {
106         case VO_CLK_SOURCE_PLL:
107             return "PLL";
108         case VO_CLK_SOURCE_LCDMCLK:
109             return "LCDMCLK";
110         default:
111             return "-";
112     }
113 }
114 
vou_print_bool(hi_bool value)115 static hi_char *vou_print_bool(hi_bool value)
116 {
117     return (value) ? "Y" : "N";
118 }
119 
vou_proc_dev_cfg(osal_proc_entry_t * s)120 static hi_void vou_proc_dev_cfg(osal_proc_entry_t *s)
121 {
122     vo_dev_info *dev_ctx = HI_NULL;
123     hi_u32 i;
124     hi_char asz[VO_MAX_MUX_NUM][VO_MAX_INTFNAME_LEN] = {0};
125     hi_u32 vtth = 0;
126     hi_u32 vtth2 = 0;
127 
128     osal_seq_printf(s, "-----DEVICE CONFIG------------------------------------------------------------------------\n");
129     osal_seq_printf(s, "%8s%8s%11s%11s%11s%14s%13s%8s%8s%8s\n",
130                     "DevId", "DevEn", "Mux1", "Mux2", "Mux3", "IntfSync", "BgClr", "DevFrt", "Vtth", "Vtth2");
131 
132     for (i = 0; i < VO_MAX_DEV_NUM; i++) {
133         dev_ctx = vo_get_dev_ctx(i);
134         if (dev_ctx->vo_enable == HI_TRUE) {
135             vou_print_mux(dev_ctx->vou_attr.intf_type, asz);
136             vou_drv_get_dev_vtth2(i, &vtth2);
137             vou_drv_get_dev_vtth(i, &vtth);
138             osal_seq_printf(s, "%8u%8s%11s%11s%11s%14s%#13x%8u%8u%8u\n",
139                             i, vou_print_bool(dev_ctx->vo_enable), asz[0], asz[1], asz[2],
140                             vou_print_out_mode(dev_ctx->vou_attr.intf_sync),
141                             dev_ctx->vou_attr.bg_color, dev_ctx->full_frame_rate,
142                             vtth, vtth2);
143         }
144     }
145     osal_seq_printf(s, "\r\n");
146 }
147 
vou_proc_dev_clk_info(osal_proc_entry_t * s)148 static hi_void vou_proc_dev_clk_info(osal_proc_entry_t *s)
149 {
150     vo_dev_info *dev_ctx = HI_NULL;
151     hi_u32 i;
152     hi_vo_user_intfsync_attr *user_intf_sync_attr = HI_NULL;
153     hi_vo_user_intfsync_pll *user_sync_pll = HI_NULL;
154 
155     osal_seq_printf(s, "-----DEVICE CLOCK INFO-------------------------------------------------------------------\n");
156     osal_seq_printf(s, "%8s%8s%11s%8s%8s%11s%11s%10s%10s%10s%10s%11s\n",
157                     "DevId", "DevEn", "ClkSource", "FbDiv", "Frac", "RefDiv", "PostDiv1", "PostDiv2", "LCDMCLK",
158                     "VoDevDiv", "VoPreDiv", "ClkReverse");
159 
160     for (i = 0; i < VO_MAX_DEV_NUM; i++) {
161         dev_ctx = vo_get_dev_ctx(i);
162 
163         user_intf_sync_attr = &dev_ctx->vo_user_sync_info.user_intf_sync_attr;
164         user_sync_pll = &dev_ctx->vo_user_sync_info.user_intf_sync_attr.user_sync_pll;
165 
166         if ((dev_ctx->vo_enable == HI_TRUE) && (dev_ctx->vou_attr.intf_sync == VO_OUTPUT_USER)) {
167             osal_seq_printf(s, "%8u%8s%11s",
168                             i, vou_print_bool(dev_ctx->vo_enable),
169                             vou_print_clk_source(user_intf_sync_attr->clk_source));
170 
171             if (user_intf_sync_attr->clk_source == VO_CLK_SOURCE_PLL) {
172                 osal_seq_printf(s, "%8u%8u%11u%11u%10u",
173                                 user_sync_pll->fbdiv, user_sync_pll->frac, user_sync_pll->refdiv,
174                                 user_sync_pll->postdiv1, user_sync_pll->postdiv2);
175 
176                 osal_seq_printf(s, "%20u", dev_ctx->vo_user_sync_info.dev_div);
177                 osal_seq_printf(s, "%10u", dev_ctx->vo_user_sync_info.pre_div);
178             } else {
179                 osal_seq_printf(s, "%58u", user_intf_sync_attr->lcd_m_clk_div);
180                 osal_seq_printf(s, "%10u", dev_ctx->vo_user_sync_info.dev_div);
181                 osal_seq_printf(s, "%10u", dev_ctx->vo_user_sync_info.pre_div);
182             }
183 
184             osal_seq_printf(s, "%11s\n", vou_print_bool(dev_ctx->vo_user_sync_info.clk_reverse));
185         }
186     }
187     osal_seq_printf(s, "\r\n");
188 }
189 
vou_proc_dev_show(osal_proc_entry_t * s)190 static hi_void vou_proc_dev_show(osal_proc_entry_t *s)
191 {
192     vou_proc_dev_cfg(s);
193     vou_proc_dev_clk_info(s);
194 }
195 
vou_proc_module_param_show(osal_proc_entry_t * s)196 static hi_void vou_proc_module_param_show(osal_proc_entry_t *s)
197 {
198     hi_u32 i;
199     hi_s32 ret;
200     hi_u32 len = 2;
201     hi_vo_mod_param *vo_mod_param = HI_NULL;
202     hi_char c_string[VO_MAX_PHY_DEV_NUM + VO_MAX_PHY_DEV_NUM + 1] = { 0 };
203 
204     vo_mod_param = vo_get_vo_mod_param();
205 
206     osal_seq_printf(s, "-----MODULE PARAM-----------------------------\n");
207     osal_seq_printf(s, "%20s%11s%14s%12s%13s\n",
208                     "transparentTransmit", "ExitDev", "WbcBgBlackEn", "DevClkExtEn", "SaveBufMode");
209 
210     for (i = 0; i < VO_MAX_PHY_DEV_NUM; i++) {
211         ret = snprintf_s(&c_string[i * len], (sizeof(c_string) - i * len),
212                          len, "%2s", vou_print_bool(vo_mod_param->save_buf_mode[i]));
213         if (ret < 0) {
214             return;
215         }
216     }
217 
218     osal_seq_printf(s, "%20s%11s%14s%12s%13s\n",
219                     vou_print_bool(vo_mod_param->transparent_transmit), vou_print_bool(vo_mod_param->exit_dev),
220                     vou_print_bool(vo_mod_param->wbc_bg_black_en), vou_print_bool(vo_mod_param->dev_clk_ext_en),
221                     c_string);
222 
223     osal_seq_printf(s, "\r\n");
224 }
225 
vou_proc_dev_int_show(osal_proc_entry_t * s)226 static hi_void vou_proc_dev_int_show(osal_proc_entry_t *s)
227 {
228     vo_dev_info *dev_ctx = HI_NULL;
229     hi_u32 i;
230 
231     osal_seq_printf(s, "-----DEV Int Status------------------------------------------------------------\n");
232     osal_seq_printf(s, "%8s%8s%8s%8s%8s%9s%9s\n", "DevId", "IntRate", "IntTime", "MaxIntT", "TimePrM", "IntGapT",
233                     "MaxGapT");
234 
235     for (i = 0; i < VO_MAX_DEV_NUM; i++) {
236         dev_ctx = vo_get_dev_ctx(i);
237         if (dev_ctx->vo_enable == HI_TRUE) {
238             osal_seq_printf(s, "%8u%8u%8u%8u%8u%9u%9u\n", i, dev_ctx->debug_info.int_rate,
239                             dev_ctx->debug_info.int_time, dev_ctx->debug_info.max_int_time,
240                             dev_ctx->debug_info.int_time_per_min, dev_ctx->debug_info.int_gap_time,
241                             dev_ctx->debug_info.max_int_gap_time);
242         }
243     }
244     osal_seq_printf(s, "\r\n");
245 }
246 
vou_proc_show(osal_proc_entry_t * s)247 static hi_s32 vou_proc_show(osal_proc_entry_t *s)
248 {
249     osal_seq_printf(s, "\n[VO] Version: [" MPP_VERSION "], Build Time["__DATE__", "__TIME__"]\n");
250     osal_seq_printf(s, "\n");
251 
252     vou_proc_dev_show(s);
253     vou_proc_module_param_show(s);
254 
255 #ifdef CONFIG_HI_VO_GRAPH
256     vou_graphics_show_proc(s);
257 #endif
258 
259     vou_proc_dev_int_show(s);
260 
261 #ifdef HI_DEBUG
262     vou_drv_lbw_show_proc(s);
263 #endif
264 
265     return HI_SUCCESS;
266 }
267 
vo_mod_init_proc(hi_void)268 hi_s32 vo_mod_init_proc(hi_void)
269 {
270     osal_proc_entry_t *proc = HI_NULL;
271 
272     proc = osal_create_proc_entry(PROC_ENTRY_VO_DEV, HI_NULL);
273     if (proc == HI_NULL) {
274         vo_alert_trace("VO create proc fail!\n");
275         return HI_FAILURE;
276     }
277     proc->read = vou_proc_show;
278 
279     return HI_SUCCESS;
280 }
281 
282 #ifdef __cplusplus
283 #if __cplusplus
284 }
285 #endif
286 #endif /* end of #ifdef __cplusplus */
287 
288