@@ -152,7 +152,7 @@ static bool twin_fbdev_apply_config(twin_fbdev_t *tx)
152152 break ;
153153 default :
154154 log_error ("Unsupported bits per pixel: %d" , tx -> fb_var .bits_per_pixel );
155- break ;
155+ return false ;
156156 }
157157
158158 /* Read unchangable information of the framebuffer */
@@ -189,7 +189,7 @@ static bool twin_fbdev_update_damage(void *closure)
189189 twin_fbdev_t * tx = PRIV (closure );
190190 twin_screen_t * screen = SCREEN (closure );
191191
192- if (!tx -> vt_active && (tx -> fb_base = = MAP_FAILED ) &&
192+ if (!tx -> vt_active && (tx -> fb_base ! = MAP_FAILED ) &&
193193 twin_screen_damaged (screen ))
194194 twin_screen_update (screen );
195195
@@ -302,6 +302,9 @@ twin_context_t *twin_fbdev_init(int width, int height)
302302 if (tx -> fb_base != MAP_FAILED )
303303 munmap (tx -> fb_base , tx -> fb_len );
304304bail_vt_fd :
305+ /* Restore VT mode before closing */
306+ ioctl (tx -> vt_fd , VT_SETMODE , & tx -> old_vtm );
307+ ioctl (tx -> vt_fd , KDSETMODE , KD_TEXT );
305308 close (tx -> vt_fd );
306309bail_fb_fd :
307310 close (tx -> fb_fd );
@@ -325,7 +328,13 @@ static void twin_fbdev_exit(twin_context_t *ctx)
325328 return ;
326329
327330 twin_fbdev_t * tx = PRIV (ctx );
328- twin_vt_mode (tx -> vt_fd , KD_TEXT );
331+
332+ /* Restore VT mode before cleanup */
333+ if (tx -> vt_fd >= 0 ) {
334+ ioctl (tx -> vt_fd , VT_SETMODE , & tx -> old_vtm );
335+ ioctl (tx -> vt_fd , KDSETMODE , KD_TEXT );
336+ }
337+
329338 munmap (tx -> fb_base , tx -> fb_len );
330339 twin_linux_input_destroy (tx -> input );
331340 close (tx -> vt_fd );
@@ -334,6 +343,15 @@ static void twin_fbdev_exit(twin_context_t *ctx)
334343 free (ctx );
335344}
336345
346+ /* Poll function for fbdev backend
347+ * The fbdev backend uses linux_input background thread for event handling,
348+ * so this poll function just returns true to continue the main loop.
349+ */
350+ static bool twin_fbdev_poll (twin_context_t * ctx maybe_unused )
351+ {
352+ return true;
353+ }
354+
337355/* Start function for fbdev backend
338356 * Note: fbdev uses Linux input system with background thread for events,
339357 * so we use the standard dispatcher for work queue and timeout processing.
@@ -355,6 +373,7 @@ static void twin_fbdev_start(twin_context_t *ctx,
355373const twin_backend_t g_twin_backend = {
356374 .init = twin_fbdev_init ,
357375 .configure = twin_fbdev_configure ,
376+ .poll = twin_fbdev_poll ,
358377 .start = twin_fbdev_start ,
359378 .exit = twin_fbdev_exit ,
360379};
0 commit comments