mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
[linux] don't try to force framebuffer
This commit is contained in:
parent
130f1f6adb
commit
9580679298
@ -311,7 +311,7 @@ shim_lower_eighths(struct console_font_op* cfo, unsigned idx, int eighths){
|
||||
// add UCS2 codepoint |w| to |map| for font idx |fidx|
|
||||
static int
|
||||
add_to_map(struct unimapdesc* map, wchar_t w, unsigned fidx){
|
||||
logdebug("Adding mapping U+%04x -> %03u\n", w, fidx);
|
||||
logdebug("adding mapping U+%04x -> %03u\n", w, fidx);
|
||||
struct unipair* tmp = realloc(map->entries, sizeof(*map->entries) * (map->entry_ct + 1));
|
||||
if(tmp == NULL){
|
||||
return -1;
|
||||
@ -370,7 +370,7 @@ program_line_drawing_chars(int fd, struct unimapdesc* map){
|
||||
for(unsigned idx = 0 ; idx < map->entry_ct ; ++idx){
|
||||
for(size_t widx = 0 ; widx < wcslen(s->ws) ; ++widx){
|
||||
if(map->entries[idx].unicode == s->ws[widx]){
|
||||
logtrace("Found desired character U+%04x -> %03u\n",
|
||||
logtrace("found desired character U+%04x -> %03u\n",
|
||||
map->entries[idx].unicode, map->entries[idx].fontpos);
|
||||
found[widx] = true;
|
||||
if(fontidx == -1){
|
||||
@ -389,7 +389,7 @@ program_line_drawing_chars(int fd, struct unimapdesc* map){
|
||||
}
|
||||
}
|
||||
}else{
|
||||
logwarn("Couldn't find any glyphs for set %zu\n", sidx);
|
||||
logwarn("couldn't find any glyphs for set %zu\n", sidx);
|
||||
}
|
||||
free(found);
|
||||
}
|
||||
@ -400,7 +400,7 @@ program_line_drawing_chars(int fd, struct unimapdesc* map){
|
||||
logwarn("error setting kernel unicode map (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
loginfo("Successfully added %d kernel unicode mapping%s\n",
|
||||
loginfo("added %d kernel unicode mapping%s\n",
|
||||
toadd, toadd == 1 ? "" : "s");
|
||||
return 0;
|
||||
}
|
||||
@ -476,7 +476,7 @@ program_block_drawing_chars(tinfo* ti, int fd, struct console_font_op* cfo,
|
||||
if(map->entries[i].unicode >= 0x2580 && map->entries[i].unicode <= 0x259f){
|
||||
for(size_t s = 0 ; s < sizeof(half) / sizeof(*half) ; ++s){
|
||||
if(map->entries[i].unicode == half[s].w){
|
||||
logdebug("Found %lc at fontidx %u\n", half[s].w, i);
|
||||
logdebug("found %lc at fontidx %u\n", half[s].w, i);
|
||||
half[s].found = true;
|
||||
++halvesfound;
|
||||
break;
|
||||
@ -484,7 +484,7 @@ program_block_drawing_chars(tinfo* ti, int fd, struct console_font_op* cfo,
|
||||
}
|
||||
for(size_t s = 0 ; s < sizeof(quads) / sizeof(*quads) ; ++s){
|
||||
if(map->entries[i].unicode == quads[s].w){
|
||||
logdebug("Found %lc at fontidx %u\n", quads[s].w, i);
|
||||
logdebug("found %lc at fontidx %u\n", quads[s].w, i);
|
||||
quads[s].found = true;
|
||||
++numfound;
|
||||
break;
|
||||
@ -492,7 +492,7 @@ program_block_drawing_chars(tinfo* ti, int fd, struct console_font_op* cfo,
|
||||
}
|
||||
for(size_t s = 0 ; s < sizeof(eighths) / sizeof(*eighths) ; ++s){
|
||||
if(map->entries[i].unicode == eighths[s].w){
|
||||
logdebug("Found %lc at fontidx %u\n", eighths[s].w, i);
|
||||
logdebug("found %lc at fontidx %u\n", eighths[s].w, i);
|
||||
eighths[s].found = true;
|
||||
++numfound;
|
||||
break;
|
||||
@ -608,6 +608,9 @@ program_block_drawing_chars(tinfo* ti, int fd, struct console_font_op* cfo,
|
||||
}
|
||||
added += halvesadded;
|
||||
loginfo("successfully added %d kernel font glyph%s\n", added, added == 1 ? "" : "s");
|
||||
if(ti->linux_fb_fd){ // console doesn't imply framebuffer
|
||||
return 0;
|
||||
}
|
||||
unsigned pixely, pixelx;
|
||||
if(get_linux_fb_pixelgeom(ti, &pixely, &pixelx)){
|
||||
kill_fbcopy(&fbdup);
|
||||
@ -630,17 +633,17 @@ reprogram_linux_font(tinfo* ti, int fd, struct console_font_op* cfo,
|
||||
logwarn("error reading Linux kernelfont (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
loginfo("Kernel font size (glyphcount): %u\n", cfo->charcount);
|
||||
loginfo("Kernel font character geometry: %ux%u\n", cfo->width, cfo->height);
|
||||
loginfo("kernel font size (glyphcount): %u\n", cfo->charcount);
|
||||
loginfo("kernel font character geometry: %ux%u\n", cfo->width, cfo->height);
|
||||
if(cfo->charcount > 512){
|
||||
logwarn("Warning: kernel returned excess charcount\n");
|
||||
logwarn("warning: kernel returned excess charcount\n");
|
||||
return -1;
|
||||
}
|
||||
if(ioctl(fd, GIO_UNIMAP, map)){
|
||||
logwarn("error reading Linux unimap (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
loginfo("Kernel Unimap size: %u/%u\n", map->entry_ct, USHRT_MAX);
|
||||
loginfo("kernel unimap size: %u/%u\n", map->entry_ct, USHRT_MAX);
|
||||
// for certain sets of characters, we're not going to draw them in, but we
|
||||
// do want to ensure they map to something plausible...this doesn't reset
|
||||
// the framebuffer, even if we do some reprogramming.
|
||||
@ -712,10 +715,11 @@ int get_linux_fb_pixelgeom(tinfo* ti, unsigned* ypix, unsigned *xpix){
|
||||
}
|
||||
struct fb_var_screeninfo fbi = {};
|
||||
if(ioctl(ti->linux_fb_fd, FBIOGET_VSCREENINFO, &fbi)){
|
||||
logwarn("no framebuffer info from %s (%s?)\n", ti->linux_fb_dev, strerror(errno));
|
||||
logerror("no framebuffer info from %s %d (%s?)\n", ti->linux_fb_dev,
|
||||
ti->linux_fb_fd, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
loginfo("Linux %s geometry: %dx%d\n", ti->linux_fb_dev, fbi.yres, fbi.xres);
|
||||
loginfo("linux %s geometry: %dx%d\n", ti->linux_fb_dev, fbi.yres, fbi.xres);
|
||||
*ypix = fbi.yres;
|
||||
*xpix = fbi.xres;
|
||||
size_t len = *ypix * *xpix * fbi.bits_per_pixel / 8;
|
||||
@ -728,11 +732,11 @@ int get_linux_fb_pixelgeom(tinfo* ti, unsigned* ypix, unsigned *xpix){
|
||||
ti->linux_fbuffer = mmap(NULL, len, PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED, ti->linux_fb_fd, 0);
|
||||
if(ti->linux_fbuffer == MAP_FAILED){
|
||||
logerror("Couldn't map %zuB on %s (%s?)\n", len, ti->linux_fb_dev, strerror(errno));
|
||||
logerror("couldn't map %zuB on %s (%s?)\n", len, ti->linux_fb_dev, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
ti->linux_fb_len = len;
|
||||
loginfo("Mapped %zuB on %s\n", len, ti->linux_fb_dev);
|
||||
loginfo("mapped %zuB on %s\n", len, ti->linux_fb_dev);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -741,10 +745,10 @@ bool is_linux_framebuffer(tinfo* ti){
|
||||
// FIXME there might be multiple framebuffers present; how do we determine
|
||||
// which one is ours?
|
||||
const char* dev = "/dev/fb0";
|
||||
loginfo("Checking for Linux framebuffer at %s\n", dev);
|
||||
loginfo("checking for Linux framebuffer at %s\n", dev);
|
||||
int fd = open(dev, O_RDWR | O_CLOEXEC);
|
||||
if(fd < 0){
|
||||
logdebug("Couldn't open framebuffer device %s\n", dev);
|
||||
logdebug("couldn't open framebuffer device %s\n", dev);
|
||||
return false;
|
||||
}
|
||||
ti->linux_fb_fd = fd;
|
||||
|
@ -121,7 +121,7 @@ notcurses_stop_minimal(void* vnc){
|
||||
}
|
||||
}
|
||||
}
|
||||
logdebug("reset terminal, returning %d\n", ret);
|
||||
logdebug("restored terminal, returning %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user