blob: 0dfcd402c5401142c9b6b35f357fcf7cf5b1dc4c [file] [log] [blame]
Dzmitry Sankouskiaea2d2d2023-03-07 13:21:11 +03001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2015 Google, Inc
4 * (C) Copyright 2015
5 * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
6 * (C) Copyright 2023 Dzmitry Sankouski <dsankouski@gmail.com>
7 */
8
9#include <video_font.h> /* Get font data, width and height */
10
11#define VIDEO_FONT_BYTE_WIDTH ((VIDEO_FONT_WIDTH / 8) + (VIDEO_FONT_WIDTH % 8 > 0))
12
13#define FLIPPED_DIRECTION 1
14#define NORMAL_DIRECTION 0
15
16/**
17 * Checks if bits per pixel supported.
18 *
19 * @param bpix framebuffer bits per pixel.
20 *
21 * @returns 0, if supported, or else -ENOSYS.
22 */
23int check_bpix_support(int bpix);
24
25/**
26 * Fill 1 pixel in framebuffer, and go to next one.
27 *
28 * @param dstp a pointer to pointer to framebuffer.
29 * @param value value to write to framebuffer.
30 * @param pbytes framebuffer bytes per pixel.
31 * @param step framebuffer pointer increment. Usually is equal to pbytes,
32 * and may be negative to control filling direction.
33 */
34void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step);
35
36/**
37 * Fills 1 character in framebuffer vertically. Vertically means we're filling char font data rows
38 * across the lines.
39 *
40 * @param pfont a pointer to character font data.
41 * @param line a pointer to pointer to framebuffer. It's a point for upper left char corner
42 * @param vid_priv driver private data.
43 * @param direction controls character orientation. Can be normal or flipped.
44 * When normal: When flipped:
45 *|-----------------------------------------------|
46 *| line stepping | |
47 *| | | stepping -> |
48 *| * | | * * * |
49 *| * * v | * |
50 *| * | * |
51 *| * | * * ^ |
52 *| * * * | * | |
53 *| | | |
54 *| stepping -> | line stepping |
55 *|---!!we're starting from upper left char corner|
56 *|-----------------------------------------------|
57 *
58 * @returns 0, if success, or else error code.
59 */
60int fill_char_vertically(uchar *pfont, void **line, struct video_priv *vid_priv,
61 bool direction);
62
63/**
64 * Fills 1 character in framebuffer horizontally.
65 * Horizontally means we're filling char font data columns across the lines.
66 *
67 * @param pfont a pointer to character font data.
68 * @param line a pointer to pointer to framebuffer. It's a point for upper left char corner
69 * @param vid_priv driver private data.
70 * @param direction controls character orientation. Can be normal or flipped.
71 * When normal: When flipped:
72 *|-----------------------------------------------|
73 *| * | line stepping |
74 *| ^ * * * * * | | |
75 *| | * * | v * * |
76 *| | | * * * * * |
77 *| line stepping | * |
78 *| | |
79 *| stepping -> | <- stepping |
80 *|---!!we're starting from upper left char corner|
81 *|-----------------------------------------------|
82 *
83 * @returns 0, if success, or else error code.
84 */
85int fill_char_horizontally(uchar *pfont, void **line, struct video_priv *vid_priv,
86 bool direction);
87
88/**
89 * console probe function.
90 *
91 * @param dev a pointer to device.
92 *
93 * @returns 0, if success, or else error code.
94 */
95int console_probe(struct udevice *dev);