Change of vterm handling logic on backend chardev input event (#40)
[lunaix-os.git] / lunaix-os / hal / gfxa / vga / vga_gfxm_ops.c
1 #include "vga.h"
2 #include <hal/gfxm.h>
3 #include <klibc/string.h>
4
5 static int
6 __vga_gfxa_update_profile(struct gfxa* gfxa)
7 {
8     struct vga* v = (struct vga*)gfxa->hw_obj;
9     struct disp_profile* profile = &gfxa->disp_info;
10
11     v->crt.depth = profile->mon.depth;
12     v->options = VGA_MODE_GFX;
13
14     vga_config_rect(
15       v, profile->mon.w_px, profile->mon.h_px, profile->mon.freq, 0);
16
17     int err = vga_reload_config(v);
18
19     if (!err && profile->clut.val) {
20         vga_update_palette(v, profile->clut.val, profile->clut.len);
21     }
22
23     return err;
24 }
25
26 static int
27 __vga_gfxa_rreads(struct gfxa* gfxa, u32_t* map, void* rxbuf, size_t map_sz)
28 {
29     return 0;
30 }
31
32 static int
33 __vga_gfxa_rwrites(struct gfxa* gfxa, u32_t* map, void* txbuf, size_t map_sz)
34 {
35     return 0;
36 }
37
38 static int
39 __vga_gfxa_vmcpy(struct gfxa* gfxa, void* buf, off_t off, size_t sz)
40 {
41     struct vga* v = (struct vga*)gfxa->hw_obj;
42
43     if (off + sz > v->fb_sz) {
44         return 0;
45     }
46
47     ptr_t vram_start = v->fb + off;
48     memcpy((void*)vram_start, buf, sz);
49
50     return sz;
51 }
52
53 static int
54 __vga_gfxa_lfbcpy(struct gfxa* gfxa, void* buf, off_t off, size_t sz)
55 {
56     return __vga_gfxa_vmcpy(gfxa, buf, off, sz);
57 }
58
59 static int
60 __vga_gfxa_hwioctl(struct gfxa* gfxa, int req, va_list args)
61 {
62     // TODO
63     return 0;
64 }
65
66 struct gfxa_ops vga_gfxa_ops = { .update_profile = __vga_gfxa_update_profile,
67                                  .rreads = __vga_gfxa_rreads,
68                                  .rwrites = __vga_gfxa_rwrites,
69                                  .vmcpy = __vga_gfxa_vmcpy,
70                                  .lfbcpy = __vga_gfxa_lfbcpy,
71                                  .hwioctl = __vga_gfxa_hwioctl };