@@ -135,7 +135,7 @@ int expo_test_render(struct expo *exp)
test->render_delta_us = get_timer_us(test->base_time_us);
/* Select 8x16 font for test display */
- ret = vidconsole_select_font(exp->cons, "8x16", 0);
+ ret = vidconsole_select_font(exp->cons, NULL, "8x16", 0);
if (ret && ret != -ENOSYS)
return log_msg_ret("font", ret);
@@ -647,10 +647,10 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev,
return -ENOTSUPP;
if (gen->font_name || gen->font_size) {
- ret = vidconsole_select_font(cons, gen->font_name,
+ ret = vidconsole_select_font(cons, NULL, gen->font_name,
gen->font_size);
} else {
- ret = vidconsole_select_font(cons, NULL, 0);
+ ret = vidconsole_select_font(cons, NULL, NULL, 0);
}
if (ret && ret != -ENOSYS)
return log_msg_ret("font", ret);
@@ -46,7 +46,7 @@ static int do_font_select(struct cmd_tbl *cmdtp, int flag, int argc,
name = argv[1];
if (argc == 3)
size = dectoul(argv[2], NULL);
- ret = vidconsole_select_font(dev, name, size);
+ ret = vidconsole_select_font(dev, NULL, name, size);
if (ret) {
printf("Failed (error %d)\n", ret);
return CMD_RET_FAILURE;
@@ -75,7 +75,7 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc,
} else {
size = dectoul(argv[1], NULL);
- ret = vidconsole_select_font(dev, font_name, size);
+ ret = vidconsole_select_font(dev, NULL, font_name, size);
if (ret) {
printf("Failed (error %d)\n", ret);
return CMD_RET_FAILURE;
@@ -369,7 +369,8 @@ int console_fixed_putc_xy(struct udevice *dev, void *vctx, uint x_frac, uint y,
return VID_TO_POS(fontdata->width);
}
-int console_simple_select_font(struct udevice *dev, const char *name, uint size)
+int console_simple_select_font(struct udevice *dev, void *ctx, const char *name,
+ uint size)
{
struct video_fontdata *font;
@@ -973,10 +973,10 @@ static int get_metrics(struct udevice *dev, const char *name, uint size,
return 0;
}
-static int truetype_select_font(struct udevice *dev, const char *name,
- uint size)
+static int truetype_select_font(struct udevice *dev, void *vctx,
+ const char *name, uint size)
{
- struct console_tt_ctx *ctx = vidconsole_ctx(dev);
+ struct console_tt_ctx *ctx = vctx;
struct console_tt_metrics *met;
struct video_fontdata *fontdata;
int ret;
@@ -647,14 +647,17 @@ int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep
return 0;
}
-int vidconsole_select_font(struct udevice *dev, const char *name, uint size)
+int vidconsole_select_font(struct udevice *dev, void *ctx, const char *name,
+ uint size)
{
struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+ if (!ctx)
+ ctx = vidconsole_ctx(dev);
if (!ops->select_font)
return -ENOSYS;
- return ops->select_font(dev, name, size);
+ return ops->select_font(dev, ctx, name, size);
}
int vidconsole_measure(struct udevice *dev, const char *name, uint size,
@@ -181,7 +181,8 @@ int console_simple_get_font(struct udevice *dev, int seq, struct vidfont_info *i
* Internal function to be used in as ops.
* See details in video_console.h select_font function
**/
-int console_simple_select_font(struct udevice *dev, const char *name, uint size);
+int console_simple_select_font(struct udevice *dev, void *ctx, const char *name,
+ uint size);
/**
* Normal console putc_xy function that can be called by other console drivers
@@ -334,11 +334,13 @@ struct vidconsole_ops {
* select_font() - Select a particular font by name / size
*
* @dev: Device to adjust
+ * @ctx: Context to use
* @name: Font name to use (NULL to use default)
* @size: Font size to use (0 to use default)
* Returns: 0 on success, -ENOENT if no such font
*/
- int (*select_font)(struct udevice *dev, const char *name, uint size);
+ int (*select_font)(struct udevice *dev, void *ctx, const char *name,
+ uint size);
/**
* measure() - Measure the bounding box of some text
@@ -487,10 +489,12 @@ int vidconsole_get_font(struct udevice *dev, int seq,
* vidconsole_select_font() - Select a particular font by name / size
*
* @dev: Device to adjust
+ * @ctx: Context to use (NULL to use default)
* @name: Font name to use (NULL to use default)
* @size: Font size to use (0 to use default)
*/
-int vidconsole_select_font(struct udevice *dev, const char *name, uint size);
+int vidconsole_select_font(struct udevice *dev, void *ctx, const char *name,
+ uint size);
/**
* vidconsole_measure() - Measure the bounding box of some text
@@ -259,7 +259,7 @@ static int dm_test_video_text(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
ut_asserteq(46, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
@@ -301,7 +301,7 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "12x22", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "12x22", 0));
ut_asserteq(46, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
@@ -342,7 +342,7 @@ static int dm_test_video_chars(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
vidconsole_put_string(con, NULL, test_string);
ut_asserteq(466, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
@@ -361,7 +361,7 @@ static int dm_test_video_ansi(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
/* reference clear: */
video_clear(con->parent);
@@ -414,7 +414,7 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot,
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
ut_asserteq(46, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
@@ -1165,11 +1165,11 @@ static int dm_test_video_font_switch(struct unit_test_state *uts)
vidconsole_put_string(con, NULL, truetype_text);
/* Switch to bitmap font */
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
vidconsole_put_string(con, NULL, bitmap_text);
/* Switch back to TrueType font */
- ut_assertok(vidconsole_select_font(con, NULL, 0));
+ ut_assertok(vidconsole_select_font(con, NULL, NULL, 0));
vidconsole_put_string(con, NULL, final_truetype_text);
ut_asserteq(14892, video_compress_fb(uts, dev, false));
@@ -1242,7 +1242,7 @@ static int dm_test_video_backspace_normal(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
ut_assertok(check_cursor_backspace(uts, dev, con, 16));
return 0;
@@ -1256,7 +1256,7 @@ static int dm_test_video_backspace_truetype(struct unit_test_state *uts)
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, NULL, 30));
+ ut_assertok(vidconsole_select_font(con, NULL, NULL, 30));
ut_assertok(check_cursor_backspace(uts, dev, con, 30));
return 0;
@@ -1271,7 +1271,7 @@ static int dm_test_video_cmd(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
ut_assertok(run_command("setcurs 10 5", 0));
@@ -1412,7 +1412,7 @@ static int dm_test_video_sync_damage(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
priv = dev_get_uclass_priv(dev);
/* Use manual sync to prevent interference with the test */
@@ -1561,7 +1561,7 @@ static int dm_test_video_entry_save(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, "8x16", 0));
+ ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0));
ut_assertok(check_entry_save(uts, con));
@@ -1576,7 +1576,7 @@ static int dm_test_video_entry_save_tt(struct unit_test_state *uts)
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- ut_assertok(vidconsole_select_font(con, NULL, 30));
+ ut_assertok(vidconsole_select_font(con, NULL, NULL, 30));
ut_assertok(check_entry_save(uts, con));