/* * The flow of privacy event: * 1) User presses key. HW does stuff with this key (timeout is started) * 2) WMI event is emitted from BIOS * 3) WMI event is received by dell-privacy * 4) KEY_MICMUTE emitted from dell-privacy * 5) Userland picks up key and modifies kcontrol for SW mute * 6) Codec kernel driver catches and calls ledtrig_audio_set which will call * led_set_brightness() on the LED registered by dell_privacy_leds_setup() * 7) dell-privacy notifies EC, the timeout is cancelled and the HW mute activates. * If the EC is not notified then the HW mic mute will activate when the timeout * triggers, just a bit later than with the active ack.
*/ bool dell_privacy_process_event(int type, int code, int status)
{ struct privacy_wmi_data *priv; conststruct key_entry *key; bool ret = false;
/* * Describes the Device State class exposed by BIOS which can be consumed by * various applications interested in knowing the Privacy feature capabilities. * class DeviceState * { * [key, read] string InstanceName; * [read] boolean ReadOnly; * * [WmiDataId(1), read] uint32 DevicesSupported; * 0 - None; 0x1 - Microphone; 0x2 - Camera; 0x4 - ePrivacy Screen * * [WmiDataId(2), read] uint32 CurrentState; * 0 - Off; 1 - On; Bit0 - Microphone; Bit1 - Camera; Bit2 - ePrivacyScreen * };
*/ staticint get_current_status(struct wmi_device *wdev)
{ struct privacy_wmi_data *priv = dev_get_drvdata(&wdev->dev); union acpi_object *obj_present;
u32 *buffer; int ret = 0;
if (!priv) {
dev_err(&wdev->dev, "dell privacy priv is NULL\n"); return -EINVAL;
} /* check privacy support features and device states */
obj_present = wmidev_block_query(wdev, 0); if (!obj_present) {
dev_err(&wdev->dev, "failed to read Binary MOF\n"); return -EIO;
}
if (obj_present->type != ACPI_TYPE_BUFFER) {
dev_err(&wdev->dev, "Binary MOF is not a buffer!\n");
ret = -EIO; goto obj_free;
} /* Although it's not technically a failure, this would lead to * unexpected behavior
*/ if (obj_present->buffer.length != 8) {
dev_err(&wdev->dev, "Dell privacy buffer has unexpected length (%d)!\n",
obj_present->buffer.length);
ret = -EINVAL; goto obj_free;
}
buffer = (u32 *)obj_present->buffer.pointer;
priv->features_present = buffer[0];
priv->last_status = buffer[1];
/* * Pressing the mute key activates a time delayed circuit to physically cut * off the mute. The LED is in the same circuit, so it reflects the true * state of the HW mute. The reason for the EC "ack" is so that software * can first invoke a SW mute before the HW circuit is cut off. Without SW * cutting this off first does not affect the time delayed muting or status * of the LED but there is a possibility of a "popping" noise. * * If the EC receives the SW ack, the circuit will be activated before the * delay completed. * * Exposing as an LED device allows the codec drivers notification path to * EC ACK to work
*/ staticint dell_privacy_leds_setup(struct device *dev)
{ struct privacy_wmi_data *priv = dev_get_drvdata(dev);
/* remap the wmi keymap event to new keymap */
keymap = kcalloc(ARRAY_SIZE(dell_wmi_keymap_type_0012), sizeof(struct key_entry), GFP_KERNEL); if (!keymap) return -ENOMEM;
/* remap the keymap code with Dell privacy key type 0x12 as prefix * KEY_MICMUTE scancode will be reported as 0x120001
*/ for (i = 0, j = 0; i < ARRAY_SIZE(dell_wmi_keymap_type_0012); i++) { /* * Unlike keys where only presses matter, userspace may act * on switches in both of their positions. Only register * SW_CAMERA_LENS_COVER if it is actually there.
*/ if (dell_wmi_keymap_type_0012[i].type == KE_VSW &&
dell_wmi_keymap_type_0012[i].sw.code == SW_CAMERA_LENS_COVER &&
!(priv->features_present & BIT(DELL_PRIVACY_TYPE_CAMERA))) continue;
keymap[j] = dell_wmi_keymap_type_0012[i];
keymap[j].code |= (0x0012 << 16);
j++;
}
ret = sparse_keymap_setup(priv->input_dev, keymap, NULL);
kfree(keymap); if (ret) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.