- pressed_in_col[col] += 1;
- if (pressed_in_col[col] > max_in_col)
- max_in_col = pressed_in_col[col];
- }
- }
- if (pressed_in_row[row] > max_in_row)
- max_in_row = pressed_in_row[row];
- }
-
- if (max_in_col < 2 || max_in_row < 2)
- return false;
-
- /* Find possible ghosting locations. These are the corners of the L's.
- * We know there is at least one L (i.e. one point whose row has at
- * least two keys ON and whose column has at least two keys ON).
- */
- for (row = 0; row < MKBP_NUM_ROWS; row++) {
- mask = 1 << row;
- if (pressed_in_row[row] < 2)
- continue;
- for (col = 0; col < MKBP_NUM_COLS; col++) {
- if (pressed_in_col[col] < 2)
- continue;
- if (buf[col] & mask & valid_keys[col]) {
- corners[n_corners].row = row;
- corners[n_corners].col = col;
- n_corners++;
- if (n_corners == sizeof(corners) /
- sizeof(corners[0])) {
- /* give up */
- dev_dbg(dev, "too many corners!");
- return true;
- }
- }
- }
- }
- /* Examine all corners for possible ghosting. */
- for (n_corners--; n_corners >= 0; n_corners--) {
- row_corner = corners[n_corners].row;
- col_corner = corners[n_corners].col;
- mask_corner = 1 << row_corner;
- /* Find the other bits in this column. */
- for (row = 0; row < MKBP_NUM_ROWS; row++) {
- if (row == row_corner)
- /* Skip the corner. */
- continue;
- mask = 1 << row;
- if (!(buf[col_corner] & mask & valid_keys[col_corner]))
- /* Key is OFF */
- continue;
- /* [row, col_corner] is ON. Find the other bits in
- * row_corner.
- */
- for (col = 0; col < MKBP_NUM_COLS; col++) {
- if (col == col_corner)
- /* Skip the corner. */
- continue;
- if (!(buf[col] & mask_corner))
- /* Key is OFF. */
- continue;
- /* If we get here, [row_corner, col] is ON,
- * therefore [row, col] is the possible
- * ghosting location (diagonally opposite). If
- * that key is wired, we have ghosting.
- */
- if (valid_keys[col] & mask) {