@@ -19,10 +19,13 @@ STRUCT_SECTION_END_EXTERN(cfb_font);
1919#define LSB_BIT_MASK (x ) BIT_MASK(x)
2020#define MSB_BIT_MASK (x ) (BIT_MASK(x) << (8 - x))
2121
22+ #ifndef CONFIG_CBF_PARTIAL_UPDATES
2223#define DISP_NUM_PARTS (4)
24+ #endif
2325#define DISP_BUF_SIZE (960 * 640 / 8)
2426
2527static uint8_t fb_buf [DISP_BUF_SIZE ];
28+ static int upd_win_x = -1 , upd_win_y = -1 , upd_win_ex = -1 , upd_win_ey = -1 ;
2629
2730static inline uint8_t byte_reverse (uint8_t b )
2831{
@@ -458,6 +461,26 @@ int cfb_framebuffer_invert(const struct device *dev)
458461 return 0 ;
459462}
460463
464+ int cfb_framebuffer_set_updated_window (const struct device * dev , int x , int y , int ex , int ey )
465+ {
466+ const struct display_driver_api * api = dev -> api ;
467+ struct display_capabilities cfg ;
468+
469+ api -> get_capabilities (dev , & cfg );
470+
471+ if (x < 0 || x > cfg .x_resolution || x > ex || ex > cfg .x_resolution || y < 0 ||
472+ y > cfg .y_resolution || y > ey || ey > cfg .y_resolution ) {
473+ return -1 ;
474+ }
475+
476+ upd_win_x = (x < upd_win_x || upd_win_x < 0 ) ? (x & ~7 ) : upd_win_x ;
477+ upd_win_ex = ex > upd_win_ex ? ((ex + 7 ) & ~7 ) : upd_win_ex ;
478+ upd_win_y = (y < upd_win_y || upd_win_y < 0 ) ? (y & ~7 ) : upd_win_y ;
479+ upd_win_ey = ey > upd_win_ey ? ((ey + 7 ) & ~7 ) : upd_win_ey ;
480+
481+ return 0 ;
482+ }
483+
461484int cfb_framebuffer_finalize (const struct device * dev )
462485{
463486 const struct display_driver_api * api = dev -> api ;
@@ -470,27 +493,44 @@ int cfb_framebuffer_finalize(const struct device *dev)
470493 return - ENODEV ;
471494 }
472495
496+ #ifndef CONFIG_CBF_PARTIAL_UPDATES
473497 desc .buf_size = fb -> size / DISP_NUM_PARTS ;
474498 desc .width = fb -> x_res ;
475499 desc .height = fb -> y_res / DISP_NUM_PARTS ;
476500 desc .pitch = fb -> x_res ;
501+ #else
502+ /* partial updates are implemented for full lines of frame buffer */
503+ desc .width = fb -> x_res ;
504+ desc .height = (upd_win_y < 0 || upd_win_ey < 0 ) ? fb -> y_res : upd_win_ey - upd_win_y ;
505+ desc .pitch = fb -> x_res ;
506+ desc .buf_size = desc .width * desc .height / fb -> ppt ;
507+ #endif
477508
478509 if (invert ) {
479510 cfb_invert (fb );
480511 }
481512
482513 api -> blanking_on (dev );
483514
515+ #ifndef CONFIG_CBF_PARTIAL_UPDATES
484516 for (int i = 0 ; i < fb -> y_res ; i += fb -> y_res / DISP_NUM_PARTS ) {
485517 err = api -> write (dev , 0 , i , & desc , & fb -> buf [i * (fb -> x_res / 8U )]);
486518 }
519+ #else
520+ err = api -> write (dev , 0 , upd_win_y , & desc , & fb -> buf [upd_win_y * (fb -> x_res / 8U )]);
521+ #endif
487522
488523 api -> blanking_off (dev );
489524
490525 if (invert ) {
491526 cfb_invert (fb );
492527 }
493528
529+ upd_win_x = -1 ;
530+ upd_win_ex = -1 ;
531+ upd_win_y = -1 ;
532+ upd_win_ey = -1 ;
533+
494534 return err ;
495535}
496536
0 commit comments