1 #include "display_adapter.h"
2
3
4 typedef struct acpi_ns_device_info {
5 device_node *node;
6 acpi_handle acpi_device;
7 } display_device_info;
8
9
10 extern "C" {
11
12
13 /*
14
15 TODO: ACPI Spec 5 Appendix B: Implement:
16 _BCL Brightness control levels
17 _BCM Brightness control method
18 _BQC Brightness Query Current Level
19 _DCS Get current hardware status
20 _DDC Return the EDID for this device
21 _DGS Query desired hardware active \ inactive state
22 _DSS Set hardware active \ inactive state
23
24 Brightness notifications
25
26 */
27
28
29 static status_t
display_open(void * _cookie,const char * path,int flags,void ** cookie)30 display_open(void *_cookie, const char* path, int flags, void** cookie)
31 {
32 display_device_info *device = (display_device_info *)_cookie;
33 *cookie = device;
34 return B_OK;
35 }
36
37
38 static status_t
display_read(void * _cookie,off_t position,void * buf,size_t * num_bytes)39 display_read(void *_cookie, off_t position, void *buf, size_t* num_bytes)
40 {
41 return B_ERROR;
42 }
43
44
45 static status_t
display_write(void * cookie,off_t position,const void * buffer,size_t * num_bytes)46 display_write(void* cookie, off_t position, const void* buffer,
47 size_t* num_bytes)
48 {
49 *num_bytes = 0;
50 return B_ERROR;
51 }
52
53
54 static status_t
display_control(void * cookie,uint32 op,void * arg,size_t len)55 display_control(void* cookie, uint32 op, void* arg, size_t len)
56 {
57 return B_ERROR;
58 }
59
60
61 static status_t
display_close(void * cookie)62 display_close(void* cookie)
63 {
64 return B_OK;
65 }
66
67
68 static status_t
display_free(void * cookie)69 display_free(void* cookie)
70 {
71 display_device_info *device = (display_device_info *)cookie;
72 return B_OK;
73 }
74
75
76 // #pragma mark - device module API
77
78
79 static status_t
display_init(void * _cookie,void ** cookie)80 display_init(void *_cookie, void **cookie)
81 {
82 device_node *node = (device_node *)_cookie;
83
84 display_device_info *device =
85 (display_device_info *)calloc(1, sizeof(*device));
86
87 if (device == NULL)
88 return B_NO_MEMORY;
89
90 device->node = node;
91
92 const char *path;
93 if (gDeviceManager->get_attr_string(node, ACPI_DEVICE_PATH_ITEM, &path,
94 false) != B_OK
95 || gAcpi->get_handle(NULL, path, &device->acpi_device) != B_OK) {
96 dprintf("%s: failed to get acpi node.\n", __func__);
97 free(device);
98 return B_ERROR;
99 }
100
101 *cookie = device;
102 return B_OK;
103 }
104
105
106 static void
display_uninit(void * _cookie)107 display_uninit(void *_cookie)
108 {
109 display_device_info *device = (display_device_info *)_cookie;
110 free(device);
111 }
112
113 } //extern c
114
115 device_module_info display_device_module = {
116 {
117 DISPLAY_DEVICE_MODULE_NAME,
118 0,
119 NULL
120 },
121
122 display_init,
123 display_uninit,
124 NULL,
125
126 display_open,
127 display_close,
128 display_free,
129 display_read,
130 display_write,
131 NULL,
132 display_control,
133
134 NULL,
135 NULL
136 };
137
138
139
140
141