1 /*
2  * Copyright (c) 2008-2010 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #pragma once
9 
10 #include <stdbool.h>
11 #include <sys/types.h>
12 #include <inttypes.h>
13 #include <lk/compiler.h>
14 
15 __BEGIN_CDECLS
16 
17 int display_init(void *framebuffer);
18 int display_enable(bool enable);
19 void display_pre_freq_change(void);
20 void display_post_freq_change(void);
21 
22 enum display_format {
23     DISPLAY_FORMAT_UNKNOWN,
24     DISPLAY_FORMAT_MONO_1,
25     DISPLAY_FORMAT_RGB_111,
26     DISPLAY_FORMAT_RGB_565,
27     DISPLAY_FORMAT_RGB_x888,
28     DISPLAY_FORMAT_ARGB_8888,
29 };
30 
31 enum image_format {
32     IMAGE_FORMAT_UNKNOWN,
33     IMAGE_FORMAT_MONO_1,
34     IMAGE_FORMAT_MONO_8,
35     IMAGE_FORMAT_RGB_x111,
36     IMAGE_FORMAT_RGB_332,
37     IMAGE_FORMAT_RGB_565,
38     IMAGE_FORMAT_RGB_2220,
39     IMAGE_FORMAT_RGB_x888,
40     IMAGE_FORMAT_ARGB_8888,
41 };
42 
43 struct display_info {
44     enum display_format format;
45     uint width;
46     uint height;
47 };
48 
49 status_t display_get_info(struct display_info *info) __NONNULL((1));
50 
51 struct display_image {
52     enum image_format format;
53     void *pixels;
54     uint width;
55     uint height;
56     int stride; // row length in pixels
57     int rowbytes; // row length in bytes
58 };
59 
60 status_t display_present(struct display_image *image, uint starty, uint endy)
61 __NONNULL((1));
62 
63 struct display_framebuffer {
64     enum display_format format;
65     struct display_image image;
66     // Update function
67     void (*flush)(uint starty, uint endy);
68 };
69 
70 status_t display_get_framebuffer(struct display_framebuffer *fb)
71 __NONNULL((1));
72 
73 __END_CDECLS
74 
75