From a3b3cbda1a6a310b0b9292b526fade9e9055928a Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 22 Oct 2013 13:47:25 +0000 Subject: [PATCH] o Add simplified structure describing framebuffer object. o Add EVENTHANDLER wrapper to register/unregister framebuffer w/o depend on new framebuffer methods. Sponsored by: The FreeBSD Foundation --- sys/sys/fbio.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/sys/sys/fbio.h b/sys/sys/fbio.h index 5745182316bc..05c4b08bc6d7 100644 --- a/sys/sys/fbio.h +++ b/sys/sys/fbio.h @@ -40,6 +40,10 @@ #ifndef _KERNEL #include +#else +#include +#include +#include #endif #include @@ -101,6 +105,75 @@ struct fbtype { }; #define FBIOGTYPE _IOR('F', 0, struct fbtype) +#define FBTYPE_GET_STRIDE(_fb) ((_fb)->fb_size / (_fb)->fb_height) +#define FBTYPE_GET_BPP(_fb) ((_fb)->fb_bpp) +#define FBTYPE_GET_BYTESPP(_fb) ((_fb)->fb_bpp / 8) + +#ifdef _KERNEL + +struct fb_info; + +typedef int fb_enter_t(void *priv); +typedef int fb_leave_t(void *priv); +typedef int fb_write_t(void *priv, int offset, void *data, int size); +typedef int fb_read_t(void *priv, int offset, void *data, int size); + +/* XXX: should use priv instead of fb_info too. */ +typedef void fb_wr1_t(struct fb_info *sc, uint32_t offset, uint8_t value); +typedef void fb_wr2_t(struct fb_info *sc, uint32_t offset, uint16_t value); +typedef void fb_wr4_t(struct fb_info *sc, uint32_t offset, uint32_t value); + +struct fb_info { + /* Raw copy of fbtype. Do not change. */ + int fb_type; /* as defined above */ + int fb_height; /* in pixels */ + int fb_width; /* in pixels */ + int fb_depth; /* bits to define color */ + int fb_cmsize; /* size of color map (entries) */ + int fb_size; /* total size in bytes */ + + /* Methods. */ + fb_write_t *fb_write; /* if NULL, direct mem write. */ + fb_read_t *fb_read; /* if NULL, direct mem read. */ + + fb_wr1_t *wr1; + fb_wr2_t *wr2; + fb_wr4_t *wr4; + fb_enter_t *enter; + fb_leave_t *leave; + + intptr_t fb_pbase; /* For FB mmap. */ + intptr_t fb_vbase; /* if NULL, use fb_write/fb_read. */ + void *fb_priv; /* First argument for read/write. */ + const char *fb_name; + uint32_t fb_flags; + int fb_stride; + int fb_bpp; /* bits per pixel */ +#define FB_FLAG_NOMMAP 1 /* mmap unsupported. */ + uint32_t fb_cmap[16]; +}; + +int fbd_list(void); +int fbd_register(struct fb_info *); +int fbd_unregister(struct fb_info *); + +static inline int +register_framebuffer(struct fb_info *info) +{ + + EVENTHANDLER_INVOKE(register_framebuffer, info); + return (0); +} + +static inline int +unregister_framebuffer(struct fb_info *info) +{ + + EVENTHANDLER_INVOKE(unregister_framebuffer, info); + return (0); +} +#endif + #ifdef notdef /* * General purpose structure for passing info in and out of frame buffers