[afa6e74] | 1 | /*
|
---|
[7c014d1] | 2 | * Copyright (c) 2011 Martin Decky
|
---|
[afa6e74] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[0eb58f1] | 29 | #ifndef FB_FB_H_
|
---|
| 30 | #define FB_FB_H_
|
---|
[afa6e74] | 31 |
|
---|
[7c014d1] | 32 | #include <sys/types.h>
|
---|
| 33 | #include <bool.h>
|
---|
| 34 | #include <loc.h>
|
---|
| 35 | #include <io/console.h>
|
---|
| 36 | #include <io/style.h>
|
---|
| 37 | #include <io/color.h>
|
---|
| 38 | #include <fb.h>
|
---|
| 39 | #include <screenbuffer.h>
|
---|
| 40 | #include <imgmap.h>
|
---|
[76fca31] | 41 |
|
---|
[7c014d1] | 42 | struct fbdev;
|
---|
| 43 | struct fbvp;
|
---|
[afa6e74] | 44 |
|
---|
[7c014d1] | 45 | typedef struct {
|
---|
| 46 | int (* yield)(struct fbdev *dev);
|
---|
| 47 | int (* claim)(struct fbdev *dev);
|
---|
| 48 | void (* pointer_update)(struct fbdev *dev, sysarg_t x, sysarg_t y,
|
---|
| 49 | bool visible);
|
---|
| 50 |
|
---|
| 51 | int (* get_resolution)(struct fbdev *dev, sysarg_t *width,
|
---|
| 52 | sysarg_t *height);
|
---|
| 53 | void (* font_metrics)(struct fbdev *dev, sysarg_t width,
|
---|
| 54 | sysarg_t height, sysarg_t *cols, sysarg_t *rows);
|
---|
| 55 |
|
---|
| 56 | int (* vp_create)(struct fbdev *dev, struct fbvp *vp);
|
---|
| 57 | void (* vp_destroy)(struct fbdev *dev, struct fbvp *vp);
|
---|
| 58 |
|
---|
| 59 | void (* vp_clear)(struct fbdev *dev, struct fbvp *vp);
|
---|
| 60 | console_caps_t (* vp_get_caps)(struct fbdev *dev, struct fbvp *vp);
|
---|
| 61 |
|
---|
| 62 | void (* vp_cursor_update)(struct fbdev *dev, struct fbvp *vp,
|
---|
| 63 | sysarg_t prev_col, sysarg_t prev_row, sysarg_t col, sysarg_t row,
|
---|
| 64 | bool visible);
|
---|
| 65 | void (* vp_cursor_flash)(struct fbdev *dev, struct fbvp *vp,
|
---|
| 66 | sysarg_t col, sysarg_t row);
|
---|
| 67 |
|
---|
| 68 | void (* vp_char_update)(struct fbdev *dev, struct fbvp *vp, sysarg_t col,
|
---|
| 69 | sysarg_t row);
|
---|
| 70 |
|
---|
| 71 | void (* vp_imgmap_damage)(struct fbdev *dev, struct fbvp *vp,
|
---|
| 72 | imgmap_t *imgmap, sysarg_t col, sysarg_t row, sysarg_t cols,
|
---|
| 73 | sysarg_t rows);
|
---|
| 74 | } fbdev_ops_t;
|
---|
[ce5bcb4] | 75 |
|
---|
[7c014d1] | 76 | typedef struct fbdev {
|
---|
| 77 | link_t link;
|
---|
| 78 |
|
---|
| 79 | atomic_t refcnt;
|
---|
| 80 | bool claimed;
|
---|
| 81 |
|
---|
| 82 | sysarg_t index;
|
---|
| 83 | service_id_t dsid;
|
---|
| 84 | struct fbvp *active_vp;
|
---|
| 85 |
|
---|
| 86 | list_t vps;
|
---|
| 87 | list_t frontbufs;
|
---|
| 88 | list_t imagemaps;
|
---|
| 89 | list_t sequences;
|
---|
| 90 |
|
---|
| 91 | fbdev_ops_t ops;
|
---|
| 92 | void *data;
|
---|
| 93 | } fbdev_t;
|
---|
| 94 |
|
---|
| 95 | typedef struct fbvp {
|
---|
| 96 | link_t link;
|
---|
| 97 |
|
---|
| 98 | sysarg_t x;
|
---|
| 99 | sysarg_t y;
|
---|
| 100 |
|
---|
| 101 | sysarg_t width;
|
---|
| 102 | sysarg_t height;
|
---|
| 103 |
|
---|
| 104 | sysarg_t cols;
|
---|
| 105 | sysarg_t rows;
|
---|
| 106 |
|
---|
| 107 | char_attrs_t attrs;
|
---|
| 108 | list_t sequences;
|
---|
| 109 |
|
---|
| 110 | screenbuffer_t *backbuf;
|
---|
| 111 | sysarg_t top_row;
|
---|
| 112 |
|
---|
| 113 | bool cursor_active;
|
---|
| 114 | bool cursor_flash;
|
---|
| 115 |
|
---|
| 116 | void *data;
|
---|
| 117 | } fbvp_t;
|
---|
| 118 |
|
---|
| 119 | typedef struct {
|
---|
| 120 | link_t link;
|
---|
| 121 |
|
---|
| 122 | size_t size;
|
---|
| 123 | unsigned int flags;
|
---|
| 124 | void *data;
|
---|
| 125 | } frontbuf_t;
|
---|
| 126 |
|
---|
| 127 | typedef struct {
|
---|
| 128 | link_t link;
|
---|
| 129 | link_t seq_link;
|
---|
| 130 |
|
---|
| 131 | size_t size;
|
---|
| 132 | unsigned int flags;
|
---|
| 133 | void *data;
|
---|
| 134 | } imagemap_t;
|
---|
| 135 |
|
---|
| 136 | typedef struct {
|
---|
| 137 | link_t link;
|
---|
| 138 |
|
---|
| 139 | list_t imagemaps;
|
---|
| 140 | size_t count;
|
---|
| 141 | } sequence_t;
|
---|
| 142 |
|
---|
| 143 | typedef struct {
|
---|
| 144 | link_t link;
|
---|
| 145 |
|
---|
| 146 | sequence_t *seq;
|
---|
| 147 | size_t current;
|
---|
| 148 | } sequence_vp_t;
|
---|
| 149 |
|
---|
| 150 | extern fbdev_t *fbdev_register(fbdev_ops_t *, void *);
|
---|
| 151 |
|
---|
| 152 | #endif
|
---|