|
|
|
@ -34,8 +34,8 @@ struct _E_ACPI_Device_Multiplexed |
|
|
|
|
/* local function prototypes */ |
|
|
|
|
static Eina_Bool _e_acpi_cb_server_del(void *data __UNUSED__, int type __UNUSED__, void *event); |
|
|
|
|
static Eina_Bool _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event); |
|
|
|
|
static void _e_acpi_cb_event_free(void *data __UNUSED__, void *event); |
|
|
|
|
static int _e_acpi_lid_status_get(const char *device, const char *bus); |
|
|
|
|
static void _e_acpi_cb_event_free(void *data __UNUSED__, void *event); |
|
|
|
|
static int _e_acpi_lid_status_get(const char *device, const char *bus); |
|
|
|
|
static Eina_Bool _e_acpi_cb_event(void *data __UNUSED__, int type __UNUSED__, void *event); |
|
|
|
|
|
|
|
|
|
/* local variables */ |
|
|
|
@ -47,48 +47,48 @@ static Eina_Strbuf *acpibuf = NULL; |
|
|
|
|
static E_ACPI_Device_Simple _devices_simple[] = |
|
|
|
|
{ |
|
|
|
|
/* NB: DO NOT TRANSLATE THESE. */ |
|
|
|
|
{"ac_adapter", E_ACPI_TYPE_AC_ADAPTER}, |
|
|
|
|
{"battery", E_ACPI_TYPE_BATTERY}, |
|
|
|
|
{"button/lid", E_ACPI_TYPE_LID}, |
|
|
|
|
{"ac_adapter", E_ACPI_TYPE_AC_ADAPTER}, |
|
|
|
|
{"battery", E_ACPI_TYPE_BATTERY}, |
|
|
|
|
{"button/lid", E_ACPI_TYPE_LID}, |
|
|
|
|
{"button/power", E_ACPI_TYPE_POWER}, |
|
|
|
|
{"button/sleep", E_ACPI_TYPE_SLEEP}, |
|
|
|
|
{"fan", E_ACPI_TYPE_FAN}, |
|
|
|
|
{"processor", E_ACPI_TYPE_PROCESSOR}, |
|
|
|
|
{"fan", E_ACPI_TYPE_FAN}, |
|
|
|
|
{"processor", E_ACPI_TYPE_PROCESSOR}, |
|
|
|
|
{"thermal_zone", E_ACPI_TYPE_THERMAL}, |
|
|
|
|
{"video", E_ACPI_TYPE_VIDEO}, |
|
|
|
|
{"video", E_ACPI_TYPE_VIDEO}, |
|
|
|
|
|
|
|
|
|
{NULL, E_ACPI_TYPE_UNKNOWN} |
|
|
|
|
{NULL, E_ACPI_TYPE_UNKNOWN} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static E_ACPI_Device_Multiplexed _devices_multiplexed[] = |
|
|
|
|
{ |
|
|
|
|
/* NB: DO NOT TRANSLATE THESE. */ |
|
|
|
|
/* Sony VAIO - VPCF115FM / PCG-81114L - nvidia gfx */ |
|
|
|
|
{"sony/hotkey", NULL, 0x10, E_ACPI_TYPE_BRIGHTNESS_DOWN}, |
|
|
|
|
{"sony/hotkey", NULL, 0x11, E_ACPI_TYPE_BRIGHTNESS_UP}, |
|
|
|
|
{"sony/hotkey", NULL, 0x12, E_ACPI_TYPE_VIDEO}, |
|
|
|
|
{"sony/hotkey", NULL, 0x14, E_ACPI_TYPE_ZOOM_OUT}, |
|
|
|
|
{"sony/hotkey", NULL, 0x15, E_ACPI_TYPE_ZOOM_IN}, |
|
|
|
|
{"sony/hotkey", NULL, 0x17, E_ACPI_TYPE_HIBERNATE}, |
|
|
|
|
{"sony/hotkey", NULL, 0xa6, E_ACPI_TYPE_ASSIST}, |
|
|
|
|
{"sony/hotkey", NULL, 0x20, E_ACPI_TYPE_S1}, |
|
|
|
|
{"sony/hotkey", NULL, 0xa5, E_ACPI_TYPE_VAIO}, |
|
|
|
|
{"sony/hotkey", NULL, 0x10, E_ACPI_TYPE_BRIGHTNESS_DOWN}, |
|
|
|
|
{"sony/hotkey", NULL, 0x11, E_ACPI_TYPE_BRIGHTNESS_UP}, |
|
|
|
|
{"sony/hotkey", NULL, 0x12, E_ACPI_TYPE_VIDEO}, |
|
|
|
|
{"sony/hotkey", NULL, 0x14, E_ACPI_TYPE_ZOOM_OUT}, |
|
|
|
|
{"sony/hotkey", NULL, 0x15, E_ACPI_TYPE_ZOOM_IN}, |
|
|
|
|
{"sony/hotkey", NULL, 0x17, E_ACPI_TYPE_HIBERNATE}, |
|
|
|
|
{"sony/hotkey", NULL, 0xa6, E_ACPI_TYPE_ASSIST}, |
|
|
|
|
{"sony/hotkey", NULL, 0x20, E_ACPI_TYPE_S1}, |
|
|
|
|
{"sony/hotkey", NULL, 0xa5, E_ACPI_TYPE_VAIO}, |
|
|
|
|
|
|
|
|
|
/* Sony VAIO - X505 - intel gfx */ |
|
|
|
|
{"sony/hotkey", NULL, 0x0e, E_ACPI_TYPE_MUTE}, |
|
|
|
|
{"sony/hotkey", NULL, 0x0f, E_ACPI_TYPE_VOLUME}, |
|
|
|
|
{"sony/hotkey", NULL, 0x10, E_ACPI_TYPE_BRIGHTNESS}, |
|
|
|
|
{"sony/hotkey", NULL, 0x12, E_ACPI_TYPE_VIDEO}, |
|
|
|
|
{"sony/hotkey", NULL, 0x0e, E_ACPI_TYPE_MUTE}, |
|
|
|
|
{"sony/hotkey", NULL, 0x0f, E_ACPI_TYPE_VOLUME}, |
|
|
|
|
{"sony/hotkey", NULL, 0x10, E_ACPI_TYPE_BRIGHTNESS}, |
|
|
|
|
{"sony/hotkey", NULL, 0x12, E_ACPI_TYPE_VIDEO}, |
|
|
|
|
|
|
|
|
|
/* HP Compaq Presario - CQ61 - intel gfx */ |
|
|
|
|
/** interesting these get auto-mapped to keys in x11. here for documentation
|
|
|
|
|
** but not enabled as we can use regular keybinds for these |
|
|
|
|
** but not enabled as we can use regular keybinds for these |
|
|
|
|
{"video", "DD03", 0x87, E_ACPI_TYPE_BRIGHTNESS_DOWN}, |
|
|
|
|
{"video", "DD03", 0x86, E_ACPI_TYPE_BRIGHTNESS_UP}, |
|
|
|
|
{"video", "OVGA", 0x80, E_ACPI_TYPE_VIDEO}, |
|
|
|
|
*/ |
|
|
|
|
*/ |
|
|
|
|
/* END */ |
|
|
|
|
{NULL, NULL, 0x00, E_ACPI_TYPE_UNKNOWN} |
|
|
|
|
{NULL, NULL, 0x00, E_ACPI_TYPE_UNKNOWN} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/* public variables */ |
|
|
|
@ -105,24 +105,24 @@ e_acpi_init(void) |
|
|
|
|
|
|
|
|
|
/* try to connect to acpid socket */ |
|
|
|
|
_e_acpid = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM, |
|
|
|
|
"/var/run/acpid.socket", -1, NULL); |
|
|
|
|
"/var/run/acpid.socket", -1, NULL); |
|
|
|
|
if (!_e_acpid) return 1; |
|
|
|
|
|
|
|
|
|
/* setup handlers */ |
|
|
|
|
_e_acpid_hdls = |
|
|
|
|
eina_list_append(_e_acpid_hdls, |
|
|
|
|
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, |
|
|
|
|
_e_acpi_cb_server_del, NULL)); |
|
|
|
|
eina_list_append(_e_acpid_hdls, |
|
|
|
|
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, |
|
|
|
|
_e_acpi_cb_server_del, NULL)); |
|
|
|
|
_e_acpid_hdls = |
|
|
|
|
eina_list_append(_e_acpid_hdls, |
|
|
|
|
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, |
|
|
|
|
_e_acpi_cb_server_data, NULL)); |
|
|
|
|
eina_list_append(_e_acpid_hdls, |
|
|
|
|
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, |
|
|
|
|
_e_acpi_cb_server_data, NULL)); |
|
|
|
|
|
|
|
|
|
/* Add handlers for standard acpi events */ |
|
|
|
|
_e_acpid_hdls = |
|
|
|
|
eina_list_append(_e_acpid_hdls, |
|
|
|
|
ecore_event_handler_add(E_EVENT_ACPI, |
|
|
|
|
_e_acpi_cb_event, NULL)); |
|
|
|
|
eina_list_append(_e_acpid_hdls, |
|
|
|
|
ecore_event_handler_add(E_EVENT_ACPI, |
|
|
|
|
_e_acpi_cb_event, NULL)); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -132,7 +132,8 @@ e_acpi_shutdown(void) |
|
|
|
|
Ecore_Event_Handler *hdl; |
|
|
|
|
|
|
|
|
|
/* cleanup event handlers */ |
|
|
|
|
EINA_LIST_FREE(_e_acpid_hdls, hdl) ecore_event_handler_del(hdl); |
|
|
|
|
EINA_LIST_FREE(_e_acpid_hdls, hdl) |
|
|
|
|
ecore_event_handler_del(hdl); |
|
|
|
|
|
|
|
|
|
/* kill the server if existing */ |
|
|
|
|
if (_e_acpid) |
|
|
|
@ -167,7 +168,8 @@ _e_acpi_cb_server_del(void *data __UNUSED__, int type __UNUSED__, void *event) |
|
|
|
|
if (ev->server != _e_acpid) return ECORE_CALLBACK_PASS_ON; |
|
|
|
|
|
|
|
|
|
/* cleanup event handlers */ |
|
|
|
|
EINA_LIST_FREE(_e_acpid_hdls, hdl) ecore_event_handler_del(hdl); |
|
|
|
|
EINA_LIST_FREE(_e_acpid_hdls, hdl) |
|
|
|
|
ecore_event_handler_del(hdl); |
|
|
|
|
|
|
|
|
|
/* kill the server if existing */ |
|
|
|
|
if (_e_acpid) |
|
|
|
@ -192,7 +194,7 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event) |
|
|
|
|
if ((!ev->data) || (ev->size < 1)) return ECORE_CALLBACK_PASS_ON; |
|
|
|
|
|
|
|
|
|
/* write out actual acpi received data to stdout for debugging
|
|
|
|
|
res = fwrite(ev->data, ev->size, 1, stdout); |
|
|
|
|
res = fwrite(ev->data, ev->size, 1, stdout); |
|
|
|
|
*/ |
|
|
|
|
/* data from a server isnt a string - its not 0 byte terminated. it's just
|
|
|
|
|
* a blob of data. copy to string and 0 byte terminate it so it can be |
|
|
|
@ -232,8 +234,8 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event) |
|
|
|
|
if ((!strcmp(device, _devices_multiplexed[i].name)) && |
|
|
|
|
// AND busname not set OR device name matches
|
|
|
|
|
(!_devices_multiplexed[i].bus || |
|
|
|
|
(_devices_multiplexed[i].bus && |
|
|
|
|
(!strcmp(bus, _devices_multiplexed[i].bus)))) && |
|
|
|
|
(_devices_multiplexed[i].bus && |
|
|
|
|
(!strcmp(bus, _devices_multiplexed[i].bus)))) && |
|
|
|
|
// AND status matches
|
|
|
|
|
(_devices_multiplexed[i].status == status)) |
|
|
|
|
{ |
|
|
|
@ -269,6 +271,7 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event) |
|
|
|
|
acpi_event->status = |
|
|
|
|
_e_acpi_lid_status_get(device, bus); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -350,15 +353,19 @@ _e_acpi_lid_status_get(const char *device, const char *bus) |
|
|
|
|
|
|
|
|
|
/* parse out state file */ |
|
|
|
|
i = 0; |
|
|
|
|
while (buff[i] != ':') i++; |
|
|
|
|
while (!isalnum(buff[i])) i++; |
|
|
|
|
while (buff[i] != ':') |
|
|
|
|
i++; |
|
|
|
|
while (!isalnum(buff[i])) |
|
|
|
|
i++; |
|
|
|
|
ret = &(buff[i]); |
|
|
|
|
while (isalnum(buff[i])) i++; |
|
|
|
|
while (isalnum(buff[i])) |
|
|
|
|
i++; |
|
|
|
|
buff[i] = 0; |
|
|
|
|
|
|
|
|
|
/* compare value from state file and return something sane */ |
|
|
|
|
if (!strcmp(ret, "open")) return E_ACPI_LID_OPEN; |
|
|
|
|
else if (!strcmp(ret, "closed")) return E_ACPI_LID_CLOSED; |
|
|
|
|
else if (!strcmp(ret, "closed")) |
|
|
|
|
return E_ACPI_LID_CLOSED; |
|
|
|
|
else return E_ACPI_LID_UNKNOWN; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -372,3 +379,4 @@ _e_acpi_cb_event(void *data __UNUSED__, int type __UNUSED__, void *event) |
|
|
|
|
e_bindings_acpi_event_handle(E_BINDING_CONTEXT_NONE, NULL, ev); |
|
|
|
|
return ECORE_CALLBACK_PASS_ON; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|