/* Macros to determine the row/column from a bit that is set in SSR0/1. */ #define BIT_TO_ROW_SSRN(bit_nr, reg_n) (((bit_nr) >> 3) + 4 * (reg_n)) #define BIT_TO_COL(bit_nr) ((bit_nr) % 8)
/* * Returns the keycode from the input device keymap given the row and * column.
*/ staticint bcm_kp_get_keycode(struct bcm_kp *kp, int row, int col)
{ unsignedint row_shift = get_count_order(kp->n_cols); unsignedshort *keymap = kp->input_dev->keycode;
staticvoid bcm_kp_report_keys(struct bcm_kp *kp, int reg_num, int pull_mode)
{ unsignedlong state, change; int bit_nr; int key_press; int row, col; unsignedint keycode;
/* Set column bits in rows 4 to 7 in IMR1 */
kp->imr1_val = 0; if (num_rows) {
kp->imr1_val = col_mask; while (--num_rows)
kp->imr1_val |= kp->imr1_val << MAX_COLS;
}
/* Initialize the KPEMR Keypress Edge Mode Registers */ /* Trigger on both edges */
kp->kpemr = 0; for (i = 0; i <= 30; i += 2)
kp->kpemr |= (KPEMR_EDGETYPE_BOTH << i);
/* * Obtain the Status filter debounce value and verify against the * possible values specified in the DT binding.
*/
of_property_read_u32(np, "status-debounce-filter-period", &dt_val);
if (dt_val > KPCR_STATUSFILTERTYPE_MAX) {
dev_err(dev, "Invalid Status filter debounce value %d\n",
dt_val); return -EINVAL;
}
/* * Obtain the Column filter debounce value and verify against the * possible values specified in the DT binding.
*/
of_property_read_u32(np, "col-debounce-filter-period", &dt_val);
if (dt_val > KPCR_COLFILTERTYPE_MAX) {
dev_err(dev, "Invalid Column filter debounce value %d\n",
dt_val); return -EINVAL;
}
kp->kpcr |= dt_val << KPCR_COLFILTERTYPE_SHIFT;
/* * Determine between the row and column, * which should be configured as output.
*/ if (of_property_read_bool(np, "row-output-enabled")) { /* * Set RowOContrl or ColumnOContrl in KPIOR * to the number of pins to drive as outputs
*/
kp->kpior = ((1 << kp->n_rows) - 1) <<
KPIOR_ROWOCONTRL_SHIFT;
} else {
kp->kpior = ((1 << kp->n_cols) - 1) <<
KPIOR_COLUMNOCONTRL_SHIFT;
}
/* * Determine if the scan pull up needs to be enabled
*/ if (of_property_read_bool(np, "pull-up-enabled"))
kp->kpcr |= KPCR_MODE;
kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL); if (!kp) return -ENOMEM;
input_dev = devm_input_allocate_device(&pdev->dev); if (!input_dev) {
dev_err(&pdev->dev, "failed to allocate the input device\n"); return -ENOMEM;
}
__set_bit(EV_KEY, input_dev->evbit);
/* Enable auto repeat feature of Linux input subsystem */ if (of_property_read_bool(pdev->dev.of_node, "autorepeat"))
__set_bit(EV_REP, input_dev->evbit);
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.