1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/* Copyright (C) 2022-2026 Mintsuki and contributors.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef FLANTERM_FB_H
29#define FLANTERM_FB_H 1
30
31#include <stdint.h>
32#include <stddef.h>
33#include <stdbool.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#include "../flanterm.h"
40
41#ifdef FLANTERM_IN_FLANTERM
42
43#include "fb_private.h"
44
45#endif
46
47#define FLANTERM_FB_ROTATE_0 0
48#define FLANTERM_FB_ROTATE_90 1
49#define FLANTERM_FB_ROTATE_180 2
50#define FLANTERM_FB_ROTATE_270 3
51
52struct flanterm_context *flanterm_fb_init(
53 /* If _malloc and _free are nulled, use the bump allocated instance (1 use only). */
54 void *(*_malloc)(size_t size),
55 void (*_free)(void *ptr, size_t size),
56 uint32_t *framebuffer, size_t width, size_t height, size_t pitch,
57 uint8_t red_mask_size, uint8_t red_mask_shift,
58 uint8_t green_mask_size, uint8_t green_mask_shift,
59 uint8_t blue_mask_size, uint8_t blue_mask_shift,
60 uint32_t *canvas, /* If nulled, no canvas. */
61 uint32_t *ansi_colours, uint32_t *ansi_bright_colours, /* If nulled, default. */
62 uint32_t *default_bg, uint32_t *default_fg, /* If nulled, default. */
63 uint32_t *default_bg_bright, uint32_t *default_fg_bright, /* If nulled, default. */
64 /* If font is null, use default font and font_width and font_height ignored. */
65 void *font, size_t font_width, size_t font_height, size_t font_spacing,
66 /* If scale_x and scale_y are 0, automatically scale font based on resolution. */
67 size_t font_scale_x, size_t font_scale_y,
68 size_t margin,
69 /* One of FLANTERM_FB_ROTATE_* values. */
70 int rotation
71);
72
73void flanterm_fb_set_flush_callback(struct flanterm_context *ctx, void (*flush_callback)(volatile void *address, size_t length));
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif
80