Loading minui/graphics_fbdev.cpp +50 −37 Original line number Diff line number Diff line Loading @@ -69,21 +69,20 @@ void MinuiBackendFbdev::SetDisplayedFramebuffer(size_t n) { } GRSurface* MinuiBackendFbdev::Init() { android::base::unique_fd fd(open("/dev/graphics/fb0", O_RDWR | O_CLOEXEC)); if (fd == -1) { perror("cannot open fb0"); return nullptr; } fb_fix_screeninfo fi; void* bits = nullptr; uint8_t fb_count = 0; std::string fb_path = "/dev/graphics/fb0"; android::base::unique_fd fd(open(fb_path.c_str(), O_RDWR | O_CLOEXEC)); while (fd != -1) { if (ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) { perror("failed to get fb0 info"); return nullptr; perror("failed to get fb info"); goto next_fb; } if (ioctl(fd, FBIOGET_VSCREENINFO, &vi) < 0) { perror("failed to get fb0 info"); return nullptr; perror("failed to get fb info"); goto next_fb; } // We print this out for informational purposes only, but Loading @@ -98,17 +97,31 @@ GRSurface* MinuiBackendFbdev::Init() { // (ie, BGRX, or 565), patches welcome... printf( "fb0 reports (possibly inaccurate):\n" "fb%d reports (possibly inaccurate):\n" " vi.bits_per_pixel = %d\n" " vi.red.offset = %3d .length = %3d\n" " vi.green.offset = %3d .length = %3d\n" " vi.blue.offset = %3d .length = %3d\n", vi.bits_per_pixel, vi.red.offset, vi.red.length, vi.green.offset, vi.green.length, vi.blue.offset, vi.blue.length); fb_count, vi.bits_per_pixel, vi.red.offset, vi.red.length, vi.green.offset, vi.green.length, vi.blue.offset, vi.blue.length); void* bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (bits == MAP_FAILED) { perror("failed to mmap framebuffer"); goto next_fb; } // Found a valid fb break; next_fb: fb_count++; fb_path.replace(fb_path.length()-1, 1, std::to_string(fb_count)); fd.reset(open(fb_path.c_str(), O_RDWR | O_CLOEXEC)); } if (fd == -1) { perror("cannot open any framebuffer"); return nullptr; } Loading Loading
minui/graphics_fbdev.cpp +50 −37 Original line number Diff line number Diff line Loading @@ -69,21 +69,20 @@ void MinuiBackendFbdev::SetDisplayedFramebuffer(size_t n) { } GRSurface* MinuiBackendFbdev::Init() { android::base::unique_fd fd(open("/dev/graphics/fb0", O_RDWR | O_CLOEXEC)); if (fd == -1) { perror("cannot open fb0"); return nullptr; } fb_fix_screeninfo fi; void* bits = nullptr; uint8_t fb_count = 0; std::string fb_path = "/dev/graphics/fb0"; android::base::unique_fd fd(open(fb_path.c_str(), O_RDWR | O_CLOEXEC)); while (fd != -1) { if (ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) { perror("failed to get fb0 info"); return nullptr; perror("failed to get fb info"); goto next_fb; } if (ioctl(fd, FBIOGET_VSCREENINFO, &vi) < 0) { perror("failed to get fb0 info"); return nullptr; perror("failed to get fb info"); goto next_fb; } // We print this out for informational purposes only, but Loading @@ -98,17 +97,31 @@ GRSurface* MinuiBackendFbdev::Init() { // (ie, BGRX, or 565), patches welcome... printf( "fb0 reports (possibly inaccurate):\n" "fb%d reports (possibly inaccurate):\n" " vi.bits_per_pixel = %d\n" " vi.red.offset = %3d .length = %3d\n" " vi.green.offset = %3d .length = %3d\n" " vi.blue.offset = %3d .length = %3d\n", vi.bits_per_pixel, vi.red.offset, vi.red.length, vi.green.offset, vi.green.length, vi.blue.offset, vi.blue.length); fb_count, vi.bits_per_pixel, vi.red.offset, vi.red.length, vi.green.offset, vi.green.length, vi.blue.offset, vi.blue.length); void* bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (bits == MAP_FAILED) { perror("failed to mmap framebuffer"); goto next_fb; } // Found a valid fb break; next_fb: fb_count++; fb_path.replace(fb_path.length()-1, 1, std::to_string(fb_count)); fd.reset(open(fb_path.c_str(), O_RDWR | O_CLOEXEC)); } if (fd == -1) { perror("cannot open any framebuffer"); return nullptr; } Loading