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