Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 Google, Inc |
| 4 | * (C) Copyright 2015 |
| 5 | * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 6 | * (C) Copyright 2023 Dzmitry Sankouski <dsankouski@gmail.com> |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 9 | #include <charset.h> |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 10 | #include <dm.h> |
| 11 | #include <video.h> |
| 12 | #include <video_console.h> |
| 13 | #include <video_font.h> /* Get font data, width and height */ |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 14 | #include "vidconsole_internal.h" |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 15 | |
| 16 | static int console_set_row_1(struct udevice *dev, uint row, int clr) |
| 17 | { |
| 18 | struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 19 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 20 | struct video_fontdata *fontdata = priv->fontdata; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 21 | int pbytes = VNBYTES(vid_priv->bpix); |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 22 | void *start, *dst, *line; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 23 | int i, j; |
| 24 | |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 25 | start = vid_priv->fb + vid_priv->line_length - |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 26 | (row + 1) * fontdata->height * pbytes; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 27 | line = start; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 28 | for (j = 0; j < vid_priv->ysize; j++) { |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 29 | dst = line; |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 30 | for (i = 0; i < fontdata->height; i++) |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 31 | fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 32 | line += vid_priv->line_length; |
| 33 | } |
| 34 | |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 35 | video_damage(dev->parent, |
| 36 | vid_priv->xsize - ((row + 1) * fontdata->height), |
| 37 | 0, |
| 38 | fontdata->height, |
| 39 | vid_priv->ysize); |
| 40 | |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc, |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 45 | uint count) |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 46 | { |
| 47 | struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 48 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 49 | struct video_fontdata *fontdata = priv->fontdata; |
Simon Glass | 80daa3f | 2020-07-02 21:12:16 -0600 | [diff] [blame] | 50 | int pbytes = VNBYTES(vid_priv->bpix); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 51 | void *dst; |
| 52 | void *src; |
Alexander Graf | f88b6a2 | 2022-06-10 00:59:21 +0200 | [diff] [blame] | 53 | int j; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 54 | |
| 55 | dst = vid_priv->fb + vid_priv->line_length - |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 56 | (rowdst + count) * fontdata->height * pbytes; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 57 | src = vid_priv->fb + vid_priv->line_length - |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 58 | (rowsrc + count) * fontdata->height * pbytes; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 59 | |
| 60 | for (j = 0; j < vid_priv->ysize; j++) { |
Alexander Graf | f88b6a2 | 2022-06-10 00:59:21 +0200 | [diff] [blame] | 61 | memmove(dst, src, fontdata->height * pbytes * count); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 62 | src += vid_priv->line_length; |
| 63 | dst += vid_priv->line_length; |
| 64 | } |
| 65 | |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 66 | video_damage(dev->parent, |
| 67 | vid_priv->xsize - ((rowdst + count) * fontdata->height), |
| 68 | 0, |
| 69 | count * fontdata->height, |
| 70 | vid_priv->ysize); |
| 71 | |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 75 | static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp) |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 76 | { |
Simon Glass | 52c10c5 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 77 | struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 78 | struct udevice *vid = dev->parent; |
| 79 | struct video_priv *vid_priv = dev_get_uclass_priv(vid); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 80 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 81 | struct video_fontdata *fontdata = priv->fontdata; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 82 | int pbytes = VNBYTES(vid_priv->bpix); |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 83 | int x, linenum, ret; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 84 | void *start, *line; |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 85 | u8 ch = console_utf_to_cp437(cp); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 86 | uchar *pfont = fontdata->video_fontdata + |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 87 | ch * fontdata->char_pixel_bytes; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 88 | |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 89 | if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac) |
| 90 | return -EAGAIN; |
Simon Glass | 80daa3f | 2020-07-02 21:12:16 -0600 | [diff] [blame] | 91 | linenum = VID_TO_PIXEL(x_frac) + 1; |
| 92 | x = y + 1; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 93 | start = vid_priv->fb + linenum * vid_priv->line_length - x * pbytes; |
| 94 | line = start; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 95 | |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 96 | ret = fill_char_horizontally(pfont, &line, vid_priv, fontdata, FLIPPED_DIRECTION); |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 97 | if (ret) |
| 98 | return ret; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 99 | |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 100 | /* We draw backwards from 'start, so account for the first line */ |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 101 | video_damage(dev->parent, |
| 102 | vid_priv->xsize - y - fontdata->height, |
| 103 | linenum - 1, |
| 104 | fontdata->height, |
| 105 | fontdata->width); |
| 106 | |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 107 | return VID_TO_POS(fontdata->width); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 110 | static int console_set_row_2(struct udevice *dev, uint row, int clr) |
| 111 | { |
| 112 | struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 113 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 114 | struct video_fontdata *fontdata = priv->fontdata; |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 115 | void *start, *line, *dst, *end; |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 116 | int pixels = fontdata->height * vid_priv->xsize; |
Alexander Graf | f88b6a2 | 2022-06-10 00:59:21 +0200 | [diff] [blame] | 117 | int i; |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 118 | int pbytes = VNBYTES(vid_priv->bpix); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 119 | |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 120 | start = vid_priv->fb + vid_priv->ysize * vid_priv->line_length - |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 121 | (row + 1) * fontdata->height * vid_priv->line_length; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 122 | line = start; |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 123 | dst = line; |
| 124 | for (i = 0; i < pixels; i++) |
| 125 | fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); |
| 126 | end = dst; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 127 | |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 128 | video_damage(dev->parent, |
| 129 | 0, |
| 130 | vid_priv->ysize - (row + 1) * fontdata->height, |
| 131 | vid_priv->xsize, |
| 132 | fontdata->height); |
| 133 | |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc, |
| 138 | uint count) |
| 139 | { |
| 140 | struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 141 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 142 | struct video_fontdata *fontdata = priv->fontdata; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 143 | void *dst; |
| 144 | void *src; |
| 145 | void *end; |
| 146 | |
| 147 | end = vid_priv->fb + vid_priv->ysize * vid_priv->line_length; |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 148 | dst = end - (rowdst + count) * fontdata->height * |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 149 | vid_priv->line_length; |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 150 | src = end - (rowsrc + count) * fontdata->height * |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 151 | vid_priv->line_length; |
Alexander Graf | f88b6a2 | 2022-06-10 00:59:21 +0200 | [diff] [blame] | 152 | memmove(dst, src, fontdata->height * vid_priv->line_length * count); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 153 | |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 154 | video_damage(dev->parent, |
| 155 | 0, |
| 156 | vid_priv->ysize - (rowdst + count) * fontdata->height, |
| 157 | vid_priv->xsize, |
| 158 | count * fontdata->height); |
| 159 | |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 160 | return 0; |
| 161 | } |
| 162 | |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 163 | static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp) |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 164 | { |
Simon Glass | 52c10c5 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 165 | struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 166 | struct udevice *vid = dev->parent; |
| 167 | struct video_priv *vid_priv = dev_get_uclass_priv(vid); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 168 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 169 | struct video_fontdata *fontdata = priv->fontdata; |
Simon Glass | 80daa3f | 2020-07-02 21:12:16 -0600 | [diff] [blame] | 170 | int pbytes = VNBYTES(vid_priv->bpix); |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 171 | int linenum, x, ret; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 172 | void *start, *line; |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 173 | u8 ch = console_utf_to_cp437(cp); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 174 | uchar *pfont = fontdata->video_fontdata + |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 175 | ch * fontdata->char_pixel_bytes; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 176 | |
Simon Glass | 52c10c5 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 177 | if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac) |
| 178 | return -EAGAIN; |
Simon Glass | 80daa3f | 2020-07-02 21:12:16 -0600 | [diff] [blame] | 179 | linenum = vid_priv->ysize - y - 1; |
Simon Glass | f50a6b9 | 2020-07-02 21:12:17 -0600 | [diff] [blame] | 180 | x = vid_priv->xsize - VID_TO_PIXEL(x_frac) - 1; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 181 | start = vid_priv->fb + linenum * vid_priv->line_length + x * pbytes; |
| 182 | line = start; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 183 | |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 184 | ret = fill_char_vertically(pfont, &line, vid_priv, fontdata, FLIPPED_DIRECTION); |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 185 | if (ret) |
| 186 | return ret; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 187 | |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 188 | video_damage(dev->parent, |
| 189 | x - fontdata->width + 1, |
| 190 | linenum - fontdata->height + 1, |
| 191 | fontdata->width, |
| 192 | fontdata->height); |
| 193 | |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 194 | return VID_TO_POS(fontdata->width); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | static int console_set_row_3(struct udevice *dev, uint row, int clr) |
| 198 | { |
| 199 | struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 200 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 201 | struct video_fontdata *fontdata = priv->fontdata; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 202 | int pbytes = VNBYTES(vid_priv->bpix); |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 203 | void *start, *dst, *line; |
Alexander Graf | f88b6a2 | 2022-06-10 00:59:21 +0200 | [diff] [blame] | 204 | int i, j; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 205 | |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 206 | start = vid_priv->fb + row * fontdata->height * pbytes; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 207 | line = start; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 208 | for (j = 0; j < vid_priv->ysize; j++) { |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 209 | dst = line; |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 210 | for (i = 0; i < fontdata->height; i++) |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 211 | fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 212 | line += vid_priv->line_length; |
| 213 | } |
| 214 | |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 215 | video_damage(dev->parent, |
| 216 | row * fontdata->height, |
| 217 | 0, |
| 218 | fontdata->height, |
| 219 | vid_priv->ysize); |
| 220 | |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 221 | return 0; |
| 222 | } |
| 223 | |
| 224 | static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc, |
| 225 | uint count) |
| 226 | { |
| 227 | struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 228 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 229 | struct video_fontdata *fontdata = priv->fontdata; |
Simon Glass | 80daa3f | 2020-07-02 21:12:16 -0600 | [diff] [blame] | 230 | int pbytes = VNBYTES(vid_priv->bpix); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 231 | void *dst; |
| 232 | void *src; |
Alexander Graf | f88b6a2 | 2022-06-10 00:59:21 +0200 | [diff] [blame] | 233 | int j; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 234 | |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 235 | dst = vid_priv->fb + rowdst * fontdata->height * pbytes; |
| 236 | src = vid_priv->fb + rowsrc * fontdata->height * pbytes; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 237 | |
| 238 | for (j = 0; j < vid_priv->ysize; j++) { |
Alexander Graf | f88b6a2 | 2022-06-10 00:59:21 +0200 | [diff] [blame] | 239 | memmove(dst, src, fontdata->height * pbytes * count); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 240 | src += vid_priv->line_length; |
| 241 | dst += vid_priv->line_length; |
| 242 | } |
| 243 | |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 244 | video_damage(dev->parent, |
| 245 | rowdst * fontdata->height, |
| 246 | 0, |
| 247 | count * fontdata->height, |
| 248 | vid_priv->ysize); |
| 249 | |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 250 | return 0; |
| 251 | } |
| 252 | |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 253 | static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp) |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 254 | { |
Simon Glass | 52c10c5 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 255 | struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 256 | struct udevice *vid = dev->parent; |
| 257 | struct video_priv *vid_priv = dev_get_uclass_priv(vid); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 258 | struct console_simple_priv *priv = dev_get_priv(dev); |
| 259 | struct video_fontdata *fontdata = priv->fontdata; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 260 | int pbytes = VNBYTES(vid_priv->bpix); |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 261 | int linenum, x, ret; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 262 | void *start, *line; |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 263 | u8 ch = console_utf_to_cp437(cp); |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 264 | uchar *pfont = fontdata->video_fontdata + |
Janne Grunau | 5548c36 | 2024-03-16 22:50:19 +0100 | [diff] [blame] | 265 | ch * fontdata->char_pixel_bytes; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 266 | |
Simon Glass | 52c10c5 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 267 | if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac) |
| 268 | return -EAGAIN; |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 269 | x = y; |
| 270 | linenum = vid_priv->ysize - VID_TO_PIXEL(x_frac) - 1; |
| 271 | start = vid_priv->fb + linenum * vid_priv->line_length + y * pbytes; |
Simon Glass | 42301da | 2020-07-02 21:12:26 -0600 | [diff] [blame] | 272 | line = start; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 273 | |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 274 | ret = fill_char_horizontally(pfont, &line, vid_priv, fontdata, NORMAL_DIRECTION); |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 275 | if (ret) |
| 276 | return ret; |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 277 | |
Alexander Graf | 1b47cf2 | 2022-06-10 00:59:17 +0200 | [diff] [blame] | 278 | video_damage(dev->parent, |
| 279 | y, |
| 280 | linenum - fontdata->width + 1, |
| 281 | fontdata->height, |
| 282 | fontdata->width); |
| 283 | |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 284 | return VID_TO_POS(fontdata->width); |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 287 | struct vidconsole_ops console_ops_1 = { |
| 288 | .putc_xy = console_putc_xy_1, |
| 289 | .move_rows = console_move_rows_1, |
| 290 | .set_row = console_set_row_1, |
Dzmitry Sankouski | bb165e4 | 2023-03-07 13:21:16 +0300 | [diff] [blame] | 291 | .get_font_size = console_simple_get_font_size, |
| 292 | .get_font = console_simple_get_font, |
| 293 | .select_font = console_simple_select_font, |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | struct vidconsole_ops console_ops_2 = { |
| 297 | .putc_xy = console_putc_xy_2, |
| 298 | .move_rows = console_move_rows_2, |
| 299 | .set_row = console_set_row_2, |
Dzmitry Sankouski | bb165e4 | 2023-03-07 13:21:16 +0300 | [diff] [blame] | 300 | .get_font_size = console_simple_get_font_size, |
| 301 | .get_font = console_simple_get_font, |
| 302 | .select_font = console_simple_select_font, |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 303 | }; |
| 304 | |
| 305 | struct vidconsole_ops console_ops_3 = { |
| 306 | .putc_xy = console_putc_xy_3, |
| 307 | .move_rows = console_move_rows_3, |
| 308 | .set_row = console_set_row_3, |
Dzmitry Sankouski | bb165e4 | 2023-03-07 13:21:16 +0300 | [diff] [blame] | 309 | .get_font_size = console_simple_get_font_size, |
| 310 | .get_font = console_simple_get_font, |
| 311 | .select_font = console_simple_select_font, |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 312 | }; |
| 313 | |
| 314 | U_BOOT_DRIVER(vidconsole_1) = { |
| 315 | .name = "vidconsole1", |
| 316 | .id = UCLASS_VIDEO_CONSOLE, |
| 317 | .ops = &console_ops_1, |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 318 | .probe = console_probe, |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 319 | .priv_auto = sizeof(struct console_simple_priv), |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 320 | }; |
| 321 | |
| 322 | U_BOOT_DRIVER(vidconsole_2) = { |
| 323 | .name = "vidconsole2", |
| 324 | .id = UCLASS_VIDEO_CONSOLE, |
| 325 | .ops = &console_ops_2, |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 326 | .probe = console_probe, |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 327 | .priv_auto = sizeof(struct console_simple_priv), |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 328 | }; |
| 329 | |
| 330 | U_BOOT_DRIVER(vidconsole_3) = { |
| 331 | .name = "vidconsole3", |
| 332 | .id = UCLASS_VIDEO_CONSOLE, |
| 333 | .ops = &console_ops_3, |
Dzmitry Sankouski | aea2d2d | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 334 | .probe = console_probe, |
Dzmitry Sankouski | 7fa964a | 2023-03-07 13:21:14 +0300 | [diff] [blame] | 335 | .priv_auto = sizeof(struct console_simple_priv), |
Simon Glass | 87aae88 | 2016-01-18 19:52:19 -0700 | [diff] [blame] | 336 | }; |