@@ -79,13 +79,12 @@ static int console_move_rows(struct udevice *dev, uint rowdst,
return 0;
}
-int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp)
+int console_normal_putc_xy(struct udevice *dev, void *vctx, uint x_frac,
+ uint y, int cp)
{
- struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
struct console_simple_priv *priv = dev_get_priv(dev);
- return console_fixed_putc_xy(dev, vidconsole_ctx_from_priv(vc_priv),
- x_frac, y, cp, priv->fontdata);
+ return console_fixed_putc_xy(dev, vctx, x_frac, y, cp, priv->fontdata);
}
static __maybe_unused int console_get_cursor_info(struct udevice *dev)
@@ -172,9 +171,10 @@ static __maybe_unused int normal_entry_restore(struct udevice *dev,
return 0;
}
-static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp)
+static int console_putc_xy(struct udevice *dev, void *vctx, uint x_frac,
+ uint y, int cp)
{
- return console_normal_putc_xy(dev, x_frac, y, cp);
+ return console_normal_putc_xy(dev, vctx, x_frac, y, cp);
}
static int console_simple_ctx_new(struct udevice *dev, void **ctxp)
@@ -72,10 +72,10 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
return 0;
}
-static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp)
+static int console_putc_xy_1(struct udevice *dev, void *vctx, uint x_frac,
+ uint y, int cp)
{
- struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
- struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv);
+ struct vidconsole_ctx *ctx = vctx;
struct udevice *vid = dev->parent;
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
struct console_simple_priv *priv = dev_get_priv(dev);
@@ -161,10 +161,10 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,
return 0;
}
-static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp)
+static int console_putc_xy_2(struct udevice *dev, void *vctx, uint x_frac,
+ uint y, int cp)
{
- struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
- struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv);
+ struct vidconsole_ctx *ctx = vctx;
struct udevice *vid = dev->parent;
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
struct console_simple_priv *priv = dev_get_priv(dev);
@@ -252,10 +252,10 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,
return 0;
}
-static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp)
+static int console_putc_xy_3(struct udevice *dev, void *vctx, uint x_frac,
+ uint y, int cp)
{
- struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
- struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv);
+ struct vidconsole_ctx *ctx = vctx;
struct udevice *vid = dev->parent;
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
struct console_simple_priv *priv = dev_get_priv(dev);
@@ -395,11 +395,11 @@ static void clear_from(struct udevice *dev, int index)
}
}
-static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
- int cp)
+static int console_truetype_putc_xy(struct udevice *dev, void *vctx, uint x,
+ uint y, int cp)
{
struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
- struct console_tt_ctx *ctx = vidconsole_ctx(dev);
+ struct console_tt_ctx *ctx = vctx;
struct vidconsole_ctx *com = &ctx->com;
struct console_tt_priv *priv = dev_get_priv(dev);
struct console_tt_metrics *met = ctx->cur_met;
@@ -22,13 +22,15 @@
#include <video_font.h> /* Bitmap font for code page 437 */
#include <linux/ctype.h>
-int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int ch)
+int vidconsole_putc_xy(struct udevice *dev, void *vctx, uint x, uint y, int ch)
{
+ struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
struct vidconsole_ops *ops = vidconsole_get_ops(dev);
if (!ops->putc_xy)
return -ENOSYS;
- return ops->putc_xy(dev, x, y, ch);
+ return ops->putc_xy(dev, vctx ?: vidconsole_ctx_from_priv(priv), x, y,
+ ch);
}
int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc,
@@ -468,10 +470,10 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch)
* colour depth. Check this and return an error to help with
* diagnosis.
*/
- ret = vidconsole_putc_xy(dev, ctx->xcur_frac, ctx->ycur, ch);
+ ret = vidconsole_putc_xy(dev, ctx, ctx->xcur_frac, ctx->ycur, ch);
if (ret == -EAGAIN) {
vidconsole_newline(dev, ctx);
- ret = vidconsole_putc_xy(dev, ctx->xcur_frac, ctx->ycur, ch);
+ ret = vidconsole_putc_xy(dev, ctx, ctx->xcur_frac, ctx->ycur, ch);
}
if (ret < 0)
return ret;
@@ -187,12 +187,14 @@ int console_simple_select_font(struct udevice *dev, const char *name, uint size)
* Normal console putc_xy function that can be called by other console drivers
*
* @param dev console device
+ * @param ctx vidconsole context to use, or NULL for default
* @param x_frac fractional X position
* @param y Y position in pixels
* @param cp Unicode code point
* @returns width in fractional pixels, or -ve on error
*/
-int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp);
+int console_normal_putc_xy(struct udevice *dev, void *ctx, uint x_frac,
+ uint y, int cp);
/**
* Fixed font putc_xy function that can be called with explicit font data
@@ -240,6 +240,7 @@ struct vidconsole_ops {
* putc_xy() - write a single character to a position
*
* @dev: Device to write to
+ * @ctx: Vidconsole context to use (cannot be NULL)
* @x_frac: Fractional pixel X position (0=left-most pixel) which
* is the X position multipled by VID_FRAC_DIV.
* @y: Pixel Y position (0=top-most pixel)
@@ -248,7 +249,8 @@ struct vidconsole_ops {
* if all is OK, -EAGAIN if we ran out of space on this line, other -ve
* on error
*/
- int (*putc_xy)(struct udevice *dev, uint x_frac, uint y, int cp);
+ int (*putc_xy)(struct udevice *dev, void *ctx, uint x_frac, uint y,
+ int cp);
/**
* move_rows() - Move text rows from one place to another
@@ -687,6 +689,7 @@ void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old);
* vidconsole_putc_xy() - write a single character to a position
*
* @dev: Device to write to
+ * @ctx: Vidconsole context to use, or NULL to use default
* @x_frac: Fractional pixel X position (0=left-most pixel) which
* is the X position multipled by VID_FRAC_DIV.
* @y: Pixel Y position (0=top-most pixel)
@@ -695,7 +698,7 @@ void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old);
* if all is OK, -EAGAIN if we ran out of space on this line, other -ve
* on error
*/
-int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int cp);
+int vidconsole_putc_xy(struct udevice *dev, void *ctx, uint x, uint y, int cp);
/**
* vidconsole_move_rows() - Move text rows from one place to another
@@ -264,16 +264,16 @@ static int dm_test_video_text(struct unit_test_state *uts)
ut_assertok(video_check_copy_fb(uts, dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_putc_xy(con, 0, 0, 'a');
+ vidconsole_putc_xy(con, NULL, 0, 0, 'a');
ut_asserteq(79, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
- vidconsole_putc_xy(con, 0, 0, ' ');
+ vidconsole_putc_xy(con, NULL, 0, 0, ' ');
ut_asserteq(46, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
+ vidconsole_putc_xy(con, NULL, VID_TO_POS(i * 8), 0, ' ' + i);
ut_asserteq(273, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
@@ -282,7 +282,7 @@ static int dm_test_video_text(struct unit_test_state *uts)
ut_assertok(video_check_copy_fb(uts, dev));
for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
+ vidconsole_putc_xy(con, NULL, VID_TO_POS(i * 8), 0, ' ' + i);
ut_asserteq(273, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
@@ -306,16 +306,16 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts)
ut_assertok(video_check_copy_fb(uts, dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
- vidconsole_putc_xy(con, 0, 0, 'a');
+ vidconsole_putc_xy(con, NULL, 0, 0, 'a');
ut_asserteq(89, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
- vidconsole_putc_xy(con, 0, 0, ' ');
+ vidconsole_putc_xy(con, NULL, 0, 0, ' ');
ut_asserteq(46, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
+ vidconsole_putc_xy(con, NULL, VID_TO_POS(i * 8), 0, ' ' + i);
ut_asserteq(363, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
@@ -324,7 +324,7 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts)
ut_assertok(video_check_copy_fb(uts, dev));
for (i = 0; i < 20; i++)
- vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
+ vidconsole_putc_xy(con, NULL, VID_TO_POS(i * 8), 0, ' ' + i);
ut_asserteq(363, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
@@ -1442,7 +1442,7 @@ static int dm_test_video_sync_damage(struct unit_test_state *uts)
ut_assert(!vid_bbox_valid(&priv->damage));
/* Write a small piece of text at a specific position */
- vidconsole_putc_xy(con, VID_TO_POS(400), 67, 'T');
+ vidconsole_putc_xy(con, NULL, VID_TO_POS(400), 67, 'T');
/* Check priv->damage before sync - should have text damage */
ut_assert(vid_bbox_valid(&priv->damage));