From 3e366ebe0e70d1c1f4e450b3e11e6176ca06613f Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 7 Jul 2021 20:28:26 -0400 Subject: [PATCH] set up framebuffer graphics --- src/info/main.c | 2 ++ src/lib/input.h | 4 ++++ src/lib/linux.c | 22 ++++++++++++++++++++++ src/lib/sprite.h | 3 +++ src/lib/termdesc.c | 10 ++++++++++ 5 files changed, 41 insertions(+) diff --git a/src/info/main.c b/src/info/main.c index 1366a803d..fe70c6c3b 100644 --- a/src/info/main.c +++ b/src/info/main.c @@ -334,6 +334,8 @@ tinfo_debug_bitmaps(struct ncplane* n, const tinfo* ti, const char* indent){ }else{ ncplane_printf(n, "%ssixel colorregs: %u\n", indent, ti->color_registers); } + }else if(ti->linux_fb_fd >= 0){ + ncplane_printf(n, "%sframebuffer graphics supported\n", indent); }else if(ti->pixel_move == NULL){ ncplane_printf(n, "%siTerm2 graphics support\n", indent); }else if(ti->sixel_maxy_pristine){ diff --git a/src/lib/input.h b/src/lib/input.h index 78657a894..d503d67e2 100644 --- a/src/lib/input.h +++ b/src/lib/input.h @@ -16,7 +16,11 @@ struct ncsharedstats; typedef enum { TERMINAL_UNKNOWN, // no useful information from queries; use termname + // the very limited linux VGA/serial console, or possibly the (deprecated, + // pixel-drawable, RGBA8888) linux framebuffer console. *not* fbterm. TERMINAL_LINUX, // ioctl()s + // the linux KMS/DRM console, *not* kmscon, but DRM direct dumb buffers + TERMINAL_LINUXDRM, // ioctl()s TERMINAL_XTERM, // XTVERSION == 'XTerm(ver)' TERMINAL_VTE, // TDA: "~VTE" TERMINAL_KITTY, // XTGETTCAP['TN'] == 'xterm-kitty' diff --git a/src/lib/linux.c b/src/lib/linux.c index 43495e1d5..09cc62900 100644 --- a/src/lib/linux.c +++ b/src/lib/linux.c @@ -10,6 +10,28 @@ #include #include + +int fbcon_blit(struct ncplane* nc, int linesize, const void* data, + int leny, int lenx, const struct blitterargs* bargs, int bpp){ + (void)nc; + (void)linesize; + (void)data; + (void)leny; + (void)lenx; + (void)bargs; + (void)bpp; + logerror("Haven't implemented yet FIXME\n"); + return -1; +} + +int fbcon_draw(const struct ncpile *p, sprixel* s, FILE* out){ + (void)p; + (void)s; + (void)out; + logerror("Haven't implemented yet FIXME\n"); + return -1; +} + // each row is a contiguous set of bits, starting at the msb static inline size_t row_bytes(const struct console_font_op* cfo){ diff --git a/src/lib/sprite.h b/src/lib/sprite.h index 2df2cd98a..e8ed045c6 100644 --- a/src/lib/sprite.h +++ b/src/lib/sprite.h @@ -193,6 +193,9 @@ int iterm_blit(struct ncplane* nc, int linesize, const void* data, int leny, int lenx, const struct blitterargs* bargs); int kitty_blit_animated(struct ncplane* n, int linesize, const void* data, int leny, int lenx, const struct blitterargs* bargs); +int fbcon_blit(struct ncplane* nc, int linesize, const void* data, + int leny, int lenx, const struct blitterargs* bargs); +int fbcon_draw(const struct ncpile *p, sprixel* s, FILE* out); #ifdef __cplusplus } diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index 74adefc19..35e0a4381 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -109,6 +109,15 @@ setup_kitty_bitmaps(tinfo* ti, int fd, int sixel_maxy_pristine){ sprite_init(ti, fd); } +// kitty 0.19.3 didn't have C=1, and thus needs sixel_maxy_pristine. it also +// lacked animation, and thus requires the older interface. +static inline void +setup_fbcon_bitmaps(tinfo* ti){ + // FIXME + ti->pixel_draw = fbcon_draw; + set_pixel_blitter(fbcon_blit); +} + static bool query_rgb(void){ bool rgb = (tigetflag("RGB") > 1 || tigetflag("Tc") > 1); @@ -543,6 +552,7 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd, } if(ti->linux_fb_fd >= 0){ termname = "Linux framebuffer"; + setup_fbcon_bitmaps(ti); }else{ termname = "Linux console"; }