]> www.infradead.org Git - users/jedix/linux-maple.git/commit
drm/ast: astdp: Look up mode index from table
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 31 Jan 2025 09:21:14 +0000 (10:21 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 3 Feb 2025 13:01:15 +0000 (14:01 +0100)
commit6af7e16c4d818c0d019c0cdb4eb12da6dc720b57
tree19628f749f5e3972b01b90e5e3a7d4ae98bc35c0
parentd86f6beed067309eeea8bf7c91d967f310db98df
drm/ast: astdp: Look up mode index from table

Replace the large switch statement with a look-up table when selecting
the mode index. Makes the code easier to read. The table is sorted by
resolutions; if run-time overhead from traversal becomes significant,
binary search would be a possible optimization.

The mode index requires a refresh-rate index to be added or subtracted,
which still requires a minimal switch. In the original code, some of
the indices did not contain this computation. Those cases would have been
equivalent to adding 0, so they are now all subsumed in the switch's
default branch.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Suggested-by: Jocelyn Falempe <jfalempe@redhat.com>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
v3:
- explain the semantics of the new switch statement (Jocelyn)
Link: https://patchwork.freedesktop.org/patch/msgid/20250131092257.115596-15-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_dp.c