ret = device_property_count_u32(&pdev->dev, "linux,keycodes"); if (ret > IQS62X_NUM_KEYS) {
dev_err(&pdev->dev, "Too many keycodes present\n"); return -EINVAL;
} elseif (ret < 0) {
dev_err(&pdev->dev, "Failed to count keycodes: %d\n", ret); return ret;
}
iqs62x_keys->keycodemax = ret;
ret = device_property_read_u32_array(&pdev->dev, "linux,keycodes",
iqs62x_keys->keycode,
iqs62x_keys->keycodemax); if (ret) {
dev_err(&pdev->dev, "Failed to read keycodes: %d\n", ret); return ret;
}
for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) { struct fwnode_handle *child __free(fwnode_handle) =
device_get_named_child_node(&pdev->dev,
iqs62x_switch_names[i]); if (!child) continue;
ret = fwnode_property_read_u32(child, "linux,code", &val); if (ret) {
dev_err(&pdev->dev, "Failed to read switch code: %d\n",
ret); return ret;
}
iqs62x_keys->switches[i].code = val;
iqs62x_keys->switches[i].enabled = true;
if (fwnode_property_present(child, "azoteq,use-prox"))
iqs62x_keys->switches[i].flag = (i == IQS62X_SW_HALL_N ?
IQS62X_EVENT_HALL_N_P :
IQS62X_EVENT_HALL_S_P); else
iqs62x_keys->switches[i].flag = (i == IQS62X_SW_HALL_N ?
IQS62X_EVENT_HALL_N_T :
IQS62X_EVENT_HALL_S_T);
}
switch (iqs62x->dev_desc->prod_num) { case IQS620_PROD_NUM: case IQS621_PROD_NUM: case IQS622_PROD_NUM:
event_reg = IQS620_GLBL_EVENT_MASK;
/* * Discreet button, hysteresis and SAR UI flags represent keys * and are unmasked if mapped to a valid keycode.
*/ for (i = 0; i < iqs62x_keys->keycodemax; i++) { if (iqs62x_keys->keycode[i] == KEY_RESERVED) continue;
ret = regmap_read(iqs62x->regmap, iqs62x->dev_desc->hall_flags,
&val); if (ret) return ret;
/* * Hall UI flags represent switches and are unmasked if their * corresponding child nodes are present.
*/ for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) { if (!(iqs62x_keys->switches[i].enabled)) continue;
flag = iqs62x_keys->switches[i].flag;
if (iqs62x_events[flag].reg != IQS62X_EVENT_HALL) continue;
/* * Interval change events represent keys and are unmasked if * either wheel movement flag is mapped to a valid keycode.
*/ if (iqs62x_keys->keycode[IQS62X_EVENT_WHEEL_UP] != KEY_RESERVED)
event_mask |= IQS624_HALL_UI_INT_EVENT;
if (iqs62x_keys->keycode[IQS62X_EVENT_WHEEL_DN] != KEY_RESERVED)
event_mask |= IQS624_HALL_UI_INT_EVENT;
ret = regmap_read(iqs62x->regmap, iqs62x->dev_desc->interval,
&val); if (ret) return ret;
if (event_flags & BIT(IQS62X_EVENT_SYS_RESET)) {
ret = iqs62x_keys_init(iqs62x_keys); if (ret) {
dev_err(iqs62x_keys->input->dev.parent, "Failed to re-initialize device: %d\n", ret); return NOTIFY_BAD;
}
return NOTIFY_OK;
}
for (i = 0; i < iqs62x_keys->keycodemax; i++) { if (iqs62x_events[i].reg == IQS62X_EVENT_WHEEL &&
event_data->interval == iqs62x_keys->interval) continue;
for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) if (iqs62x_keys->switches[i].enabled)
input_report_switch(iqs62x_keys->input,
iqs62x_keys->switches[i].code,
event_flags &
BIT(iqs62x_keys->switches[i].flag));
input_sync(iqs62x_keys->input);
if (event_data->interval == iqs62x_keys->interval) return NOTIFY_OK;
/* * Each frame contains at most one wheel event (up or down), in which * case a complementary release cycle is emulated.
*/ if (event_flags & BIT(IQS62X_EVENT_WHEEL_UP)) {
input_report_key(iqs62x_keys->input,
iqs62x_keys->keycode[IQS62X_EVENT_WHEEL_UP],
0);
input_sync(iqs62x_keys->input);
} elseif (event_flags & BIT(IQS62X_EVENT_WHEEL_DN)) {
input_report_key(iqs62x_keys->input,
iqs62x_keys->keycode[IQS62X_EVENT_WHEEL_DN],
0);
input_sync(iqs62x_keys->input);
}
for (i = 0; i < iqs62x_keys->keycodemax; i++) if (iqs62x_keys->keycode[i] != KEY_RESERVED)
input_set_capability(input, EV_KEY,
iqs62x_keys->keycode[i]);
for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) if (iqs62x_keys->switches[i].enabled)
input_set_capability(input, EV_SW,
iqs62x_keys->switches[i].code);
ret = blocking_notifier_chain_unregister(&iqs62x_keys->iqs62x->nh,
&iqs62x_keys->notifier); if (ret)
dev_err(&pdev->dev, "Failed to unregister notifier: %d\n", 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.