1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*
* disp_board_config.c
*
* Copyright (c) 2007-2020 Allwinnertech Co., Ltd.
* Author: zhengxiaobin <[email protected]>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <hal_clk.h>
#include <hal_gpio.h>
#include "../disp/disp_sys_intf.h"
#include "disp_board_config.h"
// extern struct property_t g_lcd0_config[];
extern struct property_t *g_lcd0_config;
extern struct property_t g_lcd1_config[];
extern struct property_t g_disp_config[];
extern u32 g_disp_config_len;
extern u32 g_lcd0_config_len;
extern u32 g_lcd1_config_len;
#define MAX_PIN_NUM 32
static struct property_t *disp_get_board_config(const char *main_name, u32 *len)
{
u32 i = 0, j = 0;
struct property_t *cur = NULL;
if (!main_name || !len) {
goto OUT;
}
if (!strcmp(main_name, "lcd0")) {
cur = g_lcd0_config;
*len = g_lcd0_config_len;
} else if (!strcmp(main_name, "lcd1")) {
cur = g_lcd1_config;
*len = g_lcd1_config_len;
} else if (!strcmp(main_name, "disp")) {
cur = g_disp_config;
*len = g_disp_config_len;
}
OUT:
return cur;
}
u32 disp_get_property_value(const char *main_name, const char *sub_name, void *value)
{
u32 i = 0, len = 0;
struct property_t *cur = NULL;
if (!main_name || !sub_name || !value)
return 0;
cur = disp_get_board_config(main_name, &len);
if (!cur || !len)
goto OUT;
for (i = 0; i < len; ++i) {
if(!strcmp(sub_name, cur[i].name)) {
if (cur[i].type == PROPERTY_INTGER) {
*(u32 *)value = cur[i].v.value;
} else if (cur[i].type == PROPERTY_STRING) {
memcpy(value, cur[i].v.str, strlen(cur[i].v.str) + 1);
} else if (cur[i].type == PROPERTY_GPIO) {
struct disp_gpio_set_t *gpio_info =
(struct disp_gpio_set_t *)value;
gpio_info->gpio = cur[i].v.gpio_list.gpio;
gpio_info->mul_sel = cur[i].v.gpio_list.mul_sel;
gpio_info->pull = cur[i].v.gpio_list.pull;
gpio_info->drv_level = cur[i].v.gpio_list.drv_level;
gpio_info->data = cur[i].v.gpio_list.data;
memcpy(gpio_info->gpio_name, sub_name, strlen(sub_name) + 1);
} else if (cur[i].type == PROPERTY_POWER) {
struct disp_power_t *power =
(struct disp_power_t *)value;
memcpy(power, &cur[i].v.power, sizeof(struct disp_power_t));
}
return cur[i].type;
}
}
OUT:
return PROPERTY_UNDEFINED;
}
struct disp_gpio_set_t *disp_get_all_pin_property(const char *main_name,
u32 *list_len)
{
static struct disp_gpio_set_t gpio_list[MAX_PIN_NUM];
u32 i = 0, len = 0, j = 0;
struct property_t *cur = NULL;
memset(gpio_list, 0, 30 * sizeof(struct disp_gpio_set_t));
if (!main_name)
return NULL;
cur = disp_get_board_config(main_name, &len);
if (!cur || !len)
return NULL;
for (i = 0, j = 0; i < len; ++i) {
if (cur[i].type == PROPERTY_PIN) {
if (j == MAX_PIN_NUM)
return NULL;
memcpy(&gpio_list[j], &cur[i].v.gpio_list,
sizeof(struct disp_gpio_set_t));
++j;
}
}
*list_len = j;
return gpio_list;
}
|