Lines Matching refs:ckdev
137 static bool cros_ec_keyb_has_ghosting(struct cros_ec_keyb *ckdev, uint8_t *buf) in cros_ec_keyb_has_ghosting() argument
140 struct device *dev = ckdev->dev; in cros_ec_keyb_has_ghosting()
141 uint8_t *valid_keys = ckdev->valid_keys; in cros_ec_keyb_has_ghosting()
156 for (col1 = 0; col1 < ckdev->cols; col1++) { in cros_ec_keyb_has_ghosting()
158 for (col2 = col1 + 1; col2 < ckdev->cols; col2++) { in cros_ec_keyb_has_ghosting()
177 static void cros_ec_keyb_process(struct cros_ec_keyb *ckdev, in cros_ec_keyb_process() argument
180 struct input_dev *idev = ckdev->idev; in cros_ec_keyb_process()
185 if (ckdev->ghost_filter && cros_ec_keyb_has_ghosting(ckdev, kb_state)) { in cros_ec_keyb_process()
191 dev_dbg(ckdev->dev, "ghosting found\n"); in cros_ec_keyb_process()
195 for (col = 0; col < ckdev->cols; col++) { in cros_ec_keyb_process()
196 for (row = 0; row < ckdev->rows; row++) { in cros_ec_keyb_process()
197 int pos = MATRIX_SCAN_CODE(row, col, ckdev->row_shift); in cros_ec_keyb_process()
201 old_state = ckdev->old_kb_state[col] & (1 << row); in cros_ec_keyb_process()
203 dev_dbg(ckdev->dev, in cros_ec_keyb_process()
212 ckdev->old_kb_state[col] = kb_state[col]; in cros_ec_keyb_process()
214 input_sync(ckdev->idev); in cros_ec_keyb_process()
227 static void cros_ec_keyb_report_bs(struct cros_ec_keyb *ckdev, in cros_ec_keyb_report_bs() argument
231 struct input_dev *idev = ckdev->bs_idev; in cros_ec_keyb_report_bs()
249 struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb, in cros_ec_keyb_work() local
259 if (queued_during_suspend && !device_may_wakeup(ckdev->dev)) in cros_ec_keyb_work()
262 switch (ckdev->ec->event_data.event_type) { in cros_ec_keyb_work()
264 pm_wakeup_event(ckdev->dev, 0); in cros_ec_keyb_work()
266 if (ckdev->ec->event_size != ckdev->cols) { in cros_ec_keyb_work()
267 dev_err(ckdev->dev, in cros_ec_keyb_work()
272 cros_ec_keyb_process(ckdev, in cros_ec_keyb_work()
273 ckdev->ec->event_data.data.key_matrix, in cros_ec_keyb_work()
274 ckdev->ec->event_size); in cros_ec_keyb_work()
278 pm_wakeup_event(ckdev->dev, 0); in cros_ec_keyb_work()
280 val = get_unaligned_le32(&ckdev->ec->event_data.data.sysrq); in cros_ec_keyb_work()
281 dev_dbg(ckdev->dev, "sysrq code from EC: %#x\n", val); in cros_ec_keyb_work()
287 pm_wakeup_event(ckdev->dev, 0); in cros_ec_keyb_work()
289 if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) { in cros_ec_keyb_work()
291 &ckdev->ec->event_data.data.buttons); in cros_ec_keyb_work()
295 &ckdev->ec->event_data.data.switches); in cros_ec_keyb_work()
298 cros_ec_keyb_report_bs(ckdev, ev_type, val); in cros_ec_keyb_work()
312 static void cros_ec_keyb_compute_valid_keys(struct cros_ec_keyb *ckdev) in cros_ec_keyb_compute_valid_keys() argument
315 int row_shift = ckdev->row_shift; in cros_ec_keyb_compute_valid_keys()
316 unsigned short *keymap = ckdev->idev->keycode; in cros_ec_keyb_compute_valid_keys()
319 BUG_ON(ckdev->idev->keycodesize != sizeof(*keymap)); in cros_ec_keyb_compute_valid_keys()
321 for (col = 0; col < ckdev->cols; col++) { in cros_ec_keyb_compute_valid_keys()
322 for (row = 0; row < ckdev->rows; row++) { in cros_ec_keyb_compute_valid_keys()
325 ckdev->valid_keys[col] |= 1 << row; in cros_ec_keyb_compute_valid_keys()
327 dev_dbg(ckdev->dev, "valid_keys[%02d] = 0x%02x\n", in cros_ec_keyb_compute_valid_keys()
328 col, ckdev->valid_keys[col]); in cros_ec_keyb_compute_valid_keys()
406 static int cros_ec_keyb_query_switches(struct cros_ec_keyb *ckdev) in cros_ec_keyb_query_switches() argument
408 struct cros_ec_device *ec_dev = ckdev->ec; in cros_ec_keyb_query_switches()
418 cros_ec_keyb_report_bs(ckdev, EV_SW, in cros_ec_keyb_query_switches()
435 struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); in cros_ec_keyb_resume() local
437 if (ckdev->bs_idev) in cros_ec_keyb_resume()
438 return cros_ec_keyb_query_switches(ckdev); in cros_ec_keyb_resume()
459 static int cros_ec_keyb_register_bs(struct cros_ec_keyb *ckdev, in cros_ec_keyb_register_bs() argument
462 struct cros_ec_device *ec_dev = ckdev->ec; in cros_ec_keyb_register_bs()
463 struct device *dev = ckdev->dev; in cros_ec_keyb_register_bs()
511 input_set_drvdata(idev, ckdev); in cros_ec_keyb_register_bs()
512 ckdev->bs_idev = idev; in cros_ec_keyb_register_bs()
522 ret = cros_ec_keyb_query_switches(ckdev); in cros_ec_keyb_register_bs()
528 ret = input_register_device(ckdev->bs_idev); in cros_ec_keyb_register_bs()
537 static void cros_ec_keyb_parse_vivaldi_physmap(struct cros_ec_keyb *ckdev) in cros_ec_keyb_parse_vivaldi_physmap() argument
539 u32 *physmap = ckdev->vdata.function_row_physmap; in cros_ec_keyb_parse_vivaldi_physmap()
545 n_physmap = device_property_count_u32(ckdev->dev, in cros_ec_keyb_parse_vivaldi_physmap()
551 dev_warn(ckdev->dev, in cros_ec_keyb_parse_vivaldi_physmap()
557 error = device_property_read_u32_array(ckdev->dev, in cros_ec_keyb_parse_vivaldi_physmap()
561 dev_warn(ckdev->dev, in cros_ec_keyb_parse_vivaldi_physmap()
574 scancode = MATRIX_SCAN_CODE(row, col, ckdev->row_shift); in cros_ec_keyb_parse_vivaldi_physmap()
578 ckdev->vdata.num_function_row_keys = n_physmap; in cros_ec_keyb_parse_vivaldi_physmap()
590 static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev) in cros_ec_keyb_register_matrix() argument
592 struct cros_ec_device *ec_dev = ckdev->ec; in cros_ec_keyb_register_matrix()
593 struct device *dev = ckdev->dev; in cros_ec_keyb_register_matrix()
598 err = matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols); in cros_ec_keyb_register_matrix()
602 ckdev->valid_keys = devm_kzalloc(dev, ckdev->cols, GFP_KERNEL); in cros_ec_keyb_register_matrix()
603 if (!ckdev->valid_keys) in cros_ec_keyb_register_matrix()
606 ckdev->old_kb_state = devm_kzalloc(dev, ckdev->cols, GFP_KERNEL); in cros_ec_keyb_register_matrix()
607 if (!ckdev->old_kb_state) in cros_ec_keyb_register_matrix()
631 ckdev->ghost_filter = device_property_read_bool(dev, in cros_ec_keyb_register_matrix()
634 err = matrix_keypad_build_keymap(NULL, NULL, ckdev->rows, ckdev->cols, in cros_ec_keyb_register_matrix()
641 ckdev->row_shift = get_count_order(ckdev->cols); in cros_ec_keyb_register_matrix()
644 input_set_drvdata(idev, ckdev); in cros_ec_keyb_register_matrix()
645 ckdev->idev = idev; in cros_ec_keyb_register_matrix()
646 cros_ec_keyb_compute_valid_keys(ckdev); in cros_ec_keyb_register_matrix()
647 cros_ec_keyb_parse_vivaldi_physmap(ckdev); in cros_ec_keyb_register_matrix()
649 err = input_register_device(ckdev->idev); in cros_ec_keyb_register_matrix()
662 const struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); in function_row_physmap_show() local
663 const struct vivaldi_data *data = &ckdev->vdata; in function_row_physmap_show()
680 struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); in cros_ec_keyb_attr_is_visible() local
683 !ckdev->vdata.num_function_row_keys) in cros_ec_keyb_attr_is_visible()
698 struct cros_ec_keyb *ckdev; in cros_ec_keyb_probe() local
710 ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL); in cros_ec_keyb_probe()
711 if (!ckdev) in cros_ec_keyb_probe()
714 ckdev->ec = ec; in cros_ec_keyb_probe()
715 ckdev->dev = dev; in cros_ec_keyb_probe()
716 dev_set_drvdata(dev, ckdev); in cros_ec_keyb_probe()
719 err = cros_ec_keyb_register_matrix(ckdev); in cros_ec_keyb_probe()
727 err = cros_ec_keyb_register_bs(ckdev, buttons_switches_only); in cros_ec_keyb_probe()
739 ckdev->notifier.notifier_call = cros_ec_keyb_work; in cros_ec_keyb_probe()
740 err = blocking_notifier_chain_register(&ckdev->ec->event_notifier, in cros_ec_keyb_probe()
741 &ckdev->notifier); in cros_ec_keyb_probe()
747 device_init_wakeup(ckdev->dev, true); in cros_ec_keyb_probe()
753 struct cros_ec_keyb *ckdev = dev_get_drvdata(&pdev->dev); in cros_ec_keyb_remove() local
755 blocking_notifier_chain_unregister(&ckdev->ec->event_notifier, in cros_ec_keyb_remove()
756 &ckdev->notifier); in cros_ec_keyb_remove()