[Concept,00/18] Refactor vidconsole context for dynamic allocation

Message ID 20260117005702.1684841-1-sjg@u-boot.org
Headers
Series Refactor vidconsole context for dynamic allocation |

Message

Simon Glass Jan. 17, 2026, 12:56 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

This series refactors the vidconsole subsystem to support dynamic context
allocation. This is groundwork for allowing multiple independent contexts
per vidconsole device, which will enable each expo textline to have its
own context without needing save/restore logic.

The main changes are:

1. Move fields from vidconsole_priv into vidconsole_ctx (patches 2-5)
   - curs, xstart_frac, tab_width_frac, xsize_frac
   - This consolidates per-context state into a single structure

2. Add infrastructure for dynamic context allocation (patches 8-10)
   - Add vidconsole_uc_plat with ctx_size for per-driver context sizes
   - Implement vidconsole_ctx_new/dispose for context lifecycle
   - Allocate vidconsole_ctx dynamically using ctx_size

3. Clean up truetype driver (patches 1, 11-12)
   - Rename vc_ctx to com for consistency
   - Remove embedded ctx from console_tt_priv
   - Use consistent ctx/com pattern throughout

4. Move truetype-specific fields to console_tt_ctx (patches 13-14)
   - cur_met, cur_fontdata now in console_tt_ctx
   - These are per-context rather than per-device

5. Simplify save/restore (patches 15-17)
   - Remove redundant store.cur field
   - Remove console_tt_store and console_store structs
   - Save/restore entire context directly

6. Add tests (patch 18)
   - Add dm_test_video_entry_save() for bitmap fonts
   - Add dm_test_video_entry_save_tt() for truetype fonts

The next step (not in this series) is to add a ctx parameter to driver
methods like putc_xy(), allowing callers to specify which context to
use. This will enable expo textlines to each maintain their own cursor
position and state.


Simon Glass (18):
  video: truetype: Rename vc_ctx to com
  video: Move curs into vidconsole_ctx
  video: Move xstart_frac into vidconsole_ctx
  video: Move tab_width_frac into vidconsole_ctx
  video: Move xsize_frac into vidconsole_ctx
  video: Use vidconsole_ctx_from_priv() in expo_test
  video: Update cli_index_adjust() to use vidconsole_ctx
  video: Add vidconsole_uc_plat for per-device platform data
  video: Set ctx_size in console_truetype driver
  video: Allocate vidconsole_ctx dynamically using ctx_size
  video: truetype: Remove ctx from console_tt_priv
  video: truetype: Use consistent ctx/com pattern
  video: Move cur_met to console_tt_ctx
  video: Move cur_fontdata to console_tt_ctx
  video: truetype: Remove redundant store.cur field
  video: truetype: Remove console_tt_store struct
  video: normal: Remove console_store struct
  video: Add test for entry save/restore

 board/atmel/common/video_display.c |   4 +-
 boot/expo_test.c                   |  12 +-
 drivers/video/console_core.c       |   8 +-
 drivers/video/console_normal.c     |  29 +---
 drivers/video/console_rotate.c     |   6 +-
 drivers/video/console_truetype.c   | 221 ++++++++++++-----------------
 drivers/video/vidconsole-uclass.c  |  73 ++++++----
 include/video_console.h            |  50 ++++---
 test/dm/video.c                    |  70 ++++++++-
 9 files changed, 260 insertions(+), 213 deletions(-)