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