2 * Copyright (c) 2015 Google, Inc
3 * (C) Copyright 2001-2015
4 * DENX Software Engineering -- wd@denx.de
5 * Compulab Ltd - http://compulab.co.il/
6 * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
8 * SPDX-License-Identifier: GPL-2.0+
14 #include <video_console.h>
15 #include <video_font.h> /* Get font data, width and height */
17 static int console_normal_set_row(struct udevice
*dev
, uint row
, int clr
)
19 struct video_priv
*vid_priv
= dev_get_uclass_priv(dev
->parent
);
21 int pixels
= VIDEO_FONT_HEIGHT
* vid_priv
->line_length
;
24 line
= vid_priv
->fb
+ row
* VIDEO_FONT_HEIGHT
* vid_priv
->line_length
;
25 switch (vid_priv
->bpix
) {
26 #ifdef CONFIG_VIDEO_BPP8
30 for (i
= 0; i
< pixels
; i
++)
35 #ifdef CONFIG_VIDEO_BPP16
39 for (i
= 0; i
< pixels
; i
++)
44 #ifdef CONFIG_VIDEO_BPP32
48 for (i
= 0; i
< pixels
; i
++)
60 static int console_normal_move_rows(struct udevice
*dev
, uint rowdst
,
61 uint rowsrc
, uint count
)
63 struct video_priv
*vid_priv
= dev_get_uclass_priv(dev
->parent
);
67 dst
= vid_priv
->fb
+ rowdst
* VIDEO_FONT_HEIGHT
* vid_priv
->line_length
;
68 src
= vid_priv
->fb
+ rowsrc
* VIDEO_FONT_HEIGHT
* vid_priv
->line_length
;
69 memmove(dst
, src
, VIDEO_FONT_HEIGHT
* vid_priv
->line_length
* count
);
74 static int console_normal_putc_xy(struct udevice
*dev
, uint x_frac
, uint y
,
77 struct vidconsole_priv
*vc_priv
= dev_get_uclass_priv(dev
);
78 struct udevice
*vid
= dev
->parent
;
79 struct video_priv
*vid_priv
= dev_get_uclass_priv(vid
);
81 void *line
= vid_priv
->fb
+ y
* vid_priv
->line_length
+
82 VID_TO_PIXEL(x_frac
) * VNBYTES(vid_priv
->bpix
);
84 if (x_frac
+ VID_TO_POS(vc_priv
->x_charsize
) > vc_priv
->xsize_frac
)
87 for (row
= 0; row
< VIDEO_FONT_HEIGHT
; row
++) {
88 uchar bits
= video_fontdata
[ch
* VIDEO_FONT_HEIGHT
+ row
];
90 switch (vid_priv
->bpix
) {
91 #ifdef CONFIG_VIDEO_BPP8
95 for (i
= 0; i
< VIDEO_FONT_WIDTH
; i
++) {
96 *dst
++ = (bits
& 0x80) ? vid_priv
->colour_fg
97 : vid_priv
->colour_bg
;
103 #ifdef CONFIG_VIDEO_BPP16
105 uint16_t *dst
= line
;
107 for (i
= 0; i
< VIDEO_FONT_WIDTH
; i
++) {
108 *dst
++ = (bits
& 0x80) ? vid_priv
->colour_fg
109 : vid_priv
->colour_bg
;
115 #ifdef CONFIG_VIDEO_BPP32
117 uint32_t *dst
= line
;
119 for (i
= 0; i
< VIDEO_FONT_WIDTH
; i
++) {
120 *dst
++ = (bits
& 0x80) ? vid_priv
->colour_fg
121 : vid_priv
->colour_bg
;
130 line
+= vid_priv
->line_length
;
133 return VID_TO_POS(VIDEO_FONT_WIDTH
);
136 static int console_normal_probe(struct udevice
*dev
)
138 struct vidconsole_priv
*vc_priv
= dev_get_uclass_priv(dev
);
139 struct udevice
*vid_dev
= dev
->parent
;
140 struct video_priv
*vid_priv
= dev_get_uclass_priv(vid_dev
);
142 vc_priv
->x_charsize
= VIDEO_FONT_WIDTH
;
143 vc_priv
->y_charsize
= VIDEO_FONT_HEIGHT
;
144 vc_priv
->cols
= vid_priv
->xsize
/ VIDEO_FONT_WIDTH
;
145 vc_priv
->rows
= vid_priv
->ysize
/ VIDEO_FONT_HEIGHT
;
150 struct vidconsole_ops console_normal_ops
= {
151 .putc_xy
= console_normal_putc_xy
,
152 .move_rows
= console_normal_move_rows
,
153 .set_row
= console_normal_set_row
,
156 U_BOOT_DRIVER(vidconsole_normal
) = {
157 .name
= "vidconsole0",
158 .id
= UCLASS_VIDEO_CONSOLE
,
159 .ops
= &console_normal_ops
,
160 .probe
= console_normal_probe
,