1#include "display_adapter.h" 2 3 4typedef struct acpi_ns_device_info { 5 device_node *node; 6 acpi_handle acpi_device; 7} display_device_info; 8 9 10extern "C" { 11 12 13/* 14 15TODO: 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 24Brightness notifications 25 26*/ 27 28 29static status_t 30display_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 38static status_t 39display_read(void *_cookie, off_t position, void *buf, size_t* num_bytes) 40{ 41 return B_ERROR; 42} 43 44 45static status_t 46display_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 54static status_t 55display_control(void* cookie, uint32 op, void* arg, size_t len) 56{ 57 return B_ERROR; 58} 59 60 61static status_t 62display_close(void* cookie) 63{ 64 return B_OK; 65} 66 67 68static status_t 69display_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 79static status_t 80display_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 106static void 107display_uninit(void *_cookie) 108{ 109 display_device_info *device = (display_device_info *)_cookie; 110 free(device); 111} 112 113} //extern c 114 115device_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