NiLuJe / FBInk

FrameBuffer eInker, a small tool & library to print text & images to an eInk Linux framebuffer
https://www.mobileread.com/forums/showthread.php?t=299110
GNU General Public License v3.0
332 stars 23 forks source link

fbink_reinit: allow on kindle #67

Closed yparitcher closed 2 years ago

yparitcher commented 2 years ago

You now have a API user :) I use fbink_set_fb_info in my kindle screensaver to set rotation, and it calls fbink_reinit to normalize state, currently fbink_set_fb_info is returning the ENOSYS from fbink_reinit and i have to call fbink_init to get back to a sane state.

https://github.com/yparitcher/kindle-zmanim/blob/41ecec2a8fe8e34e6f40b970426e0b1b17351768/src/kzman.c#L274-L304

void goingToSS()
{
    fbink_dump(fbfd, &dump);
    fbink_init(fbfd, &configCT);
    FBInkState state = {0};
    fbink_get_state(&configCT, &state);
    current_rota = state.current_rota;
    int ret = fbink_set_fb_info(fbfd, rota, KEEP_CURRENT_BITDEPTH, KEEP_CURRENT_GRAYSCALE, &configCT);
    if (ret && ret != -ENOSYS) {syslog(LOG_INFO, "Error rotating: %d\n", ret);}

    if (!program)
    {
        screenswitch = !screenswitch;
    }
    printSS();
}

void outOfSS()
{
    syslog(LOG_INFO, "outOfScreenSaver\n");

    syslog(LOG_INFO, "Rota: %d\n", current_rota);
    int ret = fbink_set_fb_info(fbfd, current_rota, KEEP_CURRENT_BITDEPTH, KEEP_CURRENT_GRAYSCALE, &configCT);
    if (ret && ret != -ENOSYS) {syslog(LOG_INFO, "Error reseting rotation: %d\n", ret);}

    if (access("/var/tmp/koreader.sh" , F_OK)) {
        syslog(LOG_INFO, "Restoring dump\n");
        fbink_restore(fbfd, &configRF, &dump);
    }
    fbink_free_dump_data(&dump);
}

This change is Reviewable

NiLuJe commented 2 years ago

Ha, cool, thanks ;).