lin
2025-01-10 2e0fe69425adee0529756dc3381ac1838197f3ac
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
128
129
130
131
132
133
134
135
/*
 * drivers/video/sunxi/disp2/disp/de/disp_device.c
 *
 * Copyright (c) 2007-2019 Allwinnertech Co., Ltd.
 * Author: zhengxiaobin <zhengxiaobin@allwinnertech.com>
 *
 * 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 "disp_device.h"
 
static LIST_HEAD(device_list);
 
s32 disp_device_set_manager(struct disp_device* dispdev, struct disp_manager *mgr)
{
   if ((NULL == dispdev) || (NULL == mgr)) {
       DE_WRN("NULL hdl!\n");
       return DIS_FAIL;
   }
   DE_INF("device %d, mgr %d\n", dispdev->disp, mgr->disp);
 
   dispdev->manager = mgr;
   mgr->device = dispdev;
 
   return DIS_SUCCESS;
}
 
s32 disp_device_unset_manager(struct disp_device* dispdev)
{
   if ((NULL == dispdev)) {
       DE_WRN("NULL hdl!\n");
       return DIS_FAIL;
   }
 
   if (dispdev->manager)
       dispdev->manager->device = NULL;
   dispdev->manager = NULL;
 
   return DIS_SUCCESS;
}
 
s32 disp_device_get_resolution(struct disp_device* dispdev, u32 *xres, u32 *yres)
{
   if ((NULL == dispdev)) {
       DE_WRN("NULL hdl!\n");
       return DIS_FAIL;
   }
 
   *xres = dispdev->timings.x_res;
   *yres = dispdev->timings.y_res;
 
   return 0;
}
 
s32 disp_device_get_timings(struct disp_device* dispdev, struct disp_video_timings *timings)
{
   if ((NULL == dispdev)) {
       DE_WRN("NULL hdl!\n");
       return DIS_FAIL;
   }
 
   if (timings)
       memcpy(timings, &dispdev->timings, sizeof(struct disp_video_timings));
 
   return 0;
}
 
s32 disp_device_is_interlace(struct disp_device *dispdev)
{
   if ((NULL == dispdev)) {
       DE_WRN("NULL hdl!\n");
       return DIS_FAIL;
   }
 
   return dispdev->timings.b_interlace;
}
 
/* get free device */
struct disp_device* disp_device_get(int disp, enum disp_output_type output_type)
{
   struct disp_device* dispdev = NULL;
 
   list_for_each_entry(dispdev, &device_list, list) {
       if ((dispdev->type == output_type) && (dispdev->disp == disp)
           && (NULL == dispdev->manager)) {
           return dispdev;
       }
   }
 
   return NULL;
}
 
struct disp_device* disp_device_find(int disp, enum disp_output_type output_type)
{
   struct disp_device* dispdev = NULL;
 
   list_for_each_entry(dispdev, &device_list, list) {
       if ((dispdev->type == output_type) && (dispdev->disp == disp)) {
           return dispdev;
       }
   }
 
   return NULL;
}
 
struct list_head* disp_device_get_list_head(void)
{
   return (&device_list);
}
 
 
s32 disp_device_register(struct disp_device *dispdev)
{
   list_add_tail(&dispdev->list, &device_list);
   return 0;
}
 
s32 disp_device_unregister(struct disp_device *dispdev)
{
   list_del(&dispdev->list);
   return 0;
}
 
void disp_device_show_builtin_patten(struct disp_device *dispdev, u32 patten)
{
   if (dispdev)
       disp_al_show_builtin_patten(dispdev->hwdev_index, patten);
}