Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kbscan: Switch from GPIO mode to KBS (Normal) mode #362

Merged
merged 2 commits into from
Jul 29, 2023
Merged

Conversation

crawfxrd
Copy link
Member

@crawfxrd crawfxrd commented Jun 3, 2023

Use the default mode for reading the keyboard scan matrix when being used as a keyboard. There should be no perceived change in behavior, but should make the code easier to understand.

Note: KSO[17:16] are configured by GPRCRC on boards that use them. They are now set to alternate function to use in KBS mode rather than GPIO mode, with the pull-up enabled to prevent them from floating when configured as open-drain.

As part of this change, we now only read the hardware matrix state once upfront, instead of on every iteration through the loop applying the logic.

Tested by cherry-picking to darp9 and verifying that typing still worked.

Need to test:

  • Wake from sleep on keyboard input
  • bonw14 (n-key rollover), but I don't think that has successfully booted on newer firmware in a while
  • the 14" keyboards
  • External debugging still works
  • typing really fast

TODO:

  • Don't re-read hardware state after initial scan (kbscan_row_has_ghost())
  • Check if kbscan_get_real_keys() is even needed
    • I don't notice any difference

@crawfxrd crawfxrd requested review from jackpot51 and a team June 3, 2023 08:37
@crawfxrd crawfxrd force-pushed the kbs-mode branch 2 times, most recently from ba1aba5 to 48400e0 Compare June 4, 2023 15:33
@crawfxrd crawfxrd force-pushed the kbs-mode branch 3 times, most recently from d691750 to 2709450 Compare June 12, 2023 13:11
@crawfxrd crawfxrd force-pushed the kbs-mode branch 2 times, most recently from c05d9d2 to dedd488 Compare June 12, 2023 19:27
@crawfxrd crawfxrd force-pushed the kbs-mode branch 2 times, most recently from 7d7ffca to 7847c67 Compare July 17, 2023 19:55
@crawfxrd
Copy link
Member Author

Increases XRAM use by 18 bytes.
Decreases ROM use by 186 bytes.

--- build/system76/oryp8/0/ec.mem	2023-07-17 13:57:23.967001078 -0600
+++ build/system76/oryp8/1/ec.mem	2023-07-17 13:57:34.875145986 -0600
@@ -25,5 +25,5 @@
    Name             Start    End      Size     Max
    ---------------- -------- -------- -------- --------
    PAGED EXT. RAM                         0      256
-   EXTERNAL RAM     0x0001   0x051e    1310     2048
-   ROM/EPROM/FLASH  0x0000   0x8f8e   36218    65536
+   EXTERNAL RAM     0x0001   0x0530    1328     2048
+   ROM/EPROM/FLASH  0x0000   0x8ed4   36032    65536

Use the default mode for reading the keyboard scan matrix when being
used as a keyboard. There should be no perceived change in behavior, but
should make the code easier to understand.

Note: `KSO[17:16]` are configured by `GPCRC` on boards that use them.
They are now set to alternate function to use in KBS mode rather than
GPIO mode, with the pull-up enabled to prevent them from floating when
configured as open-drain.

As part of this change, we now only read the hardware matrix state once
upfront, instead of on every iteration through the loop applying the
logic.

Tested by verifying that typing still works on darp9.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
Remove checking against the real keys declared in the keymap. It appears
to have no effect on behavior.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
Copy link
Member

@leviport leviport left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on bonw14's NKRO keyboard, and it can keep up with as fast as I can type. I think this is working great.

@crawfxrd
Copy link
Member Author

crawfxrd commented Jul 26, 2023

May be better to use push-pull (ITE default) rather than open-drain?
Faster slopes and lower power due to not using the pull-ups?

I can't tell what the ENE chip does.


I tried and it was buggy. Open-drain is working so I'll just leave it for now.

@jackpot51 jackpot51 merged commit d4ecd8a into master Jul 29, 2023
41 checks passed
@jackpot51 jackpot51 deleted the kbs-mode branch July 29, 2023 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants