• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "lcd_abs_if.h"
17 #include "hdf_log.h"
18 
19 #define TRANSFORM_KILO 1000
20 #define TRANSFORM_MILL 1000000
21 
22 static struct PanelManager g_panelManager = {0};
23 
24 #define LCD_HDF_SUCCESS (0)            /* < The operation is successful. */
25 #define LCD_HDF_FAILURE (-1)           /* < Failed to invoke the OS underlying function. */
26 #define LCD_HDF_ERR_INVALID_PARAM (-3) /* < Invalid parameter. */
27 
RegisterPanel(struct PanelData * data)28 int32_t RegisterPanel(struct PanelData *data)
29 {
30     HDF_LOGI("enter in %s\n", __FUNCTION__);
31 
32     int32_t panelNum;
33     if (data == NULL) {
34         HDF_LOGE("%s: panel data is null", __func__);
35         return LCD_HDF_ERR_INVALID_PARAM;
36     }
37     panelNum = g_panelManager.panelNum;
38     if (panelNum >= PANEL_MAX) {
39         HDF_LOGE("%s registered panel up PANEL_MAX", __func__);
40         return LCD_HDF_FAILURE;
41     }
42     g_panelManager.panel[panelNum] = data;
43     g_panelManager.panelNum++;
44 
45     return LCD_HDF_SUCCESS;
46 }
47 
GetPanelManager(void)48 struct PanelManager *GetPanelManager(void)
49 {
50     if (g_panelManager.panelNum == 0) {
51         return NULL;
52     } else {
53         return &g_panelManager;
54     }
55 }
56 
GetPanel(int32_t index)57 struct PanelData *GetPanel(int32_t index)
58 {
59     struct PanelManager *panelManager = NULL;
60 
61     panelManager = GetPanelManager();
62     if (panelManager == NULL) {
63         HDF_LOGE("%s panelManager is null", __func__);
64         return NULL;
65     }
66     if (index >= g_panelManager.panelNum) {
67         HDF_LOGE("%s index is greater than g_panelManager.panelNum", __func__);
68         return NULL;
69     }
70 
71     return panelManager->panel[index];
72 }