@@ -85,7 +85,7 @@ static struct drm_panic_line panic_msg[] = {
85
85
PANIC_LINE ("" ), /* will be replaced by the panic description */
86
86
};
87
87
88
- #define PANIC_MSG_LINES ARRAY_SIZE(panic_msg)
88
+ static const size_t panic_msg_lines = ARRAY_SIZE (panic_msg );
89
89
90
90
static const struct drm_panic_line logo_ascii [] = {
91
91
PANIC_LINE (" .--. _" ),
@@ -97,7 +97,7 @@ static const struct drm_panic_line logo_ascii[] = {
97
97
PANIC_LINE (" \\___)=(___/" ),
98
98
};
99
99
100
- #define PANIC_LOGO_LINES ARRAY_SIZE(logo_ascii)
100
+ static const size_t logo_ascii_lines = ARRAY_SIZE (logo_ascii );
101
101
102
102
#if defined(CONFIG_LOGO ) && !defined(MODULE )
103
103
static const struct linux_logo * logo_mono ;
@@ -496,31 +496,44 @@ static void draw_txt_rectangle(struct drm_scanout_buffer *sb,
496
496
}
497
497
}
498
498
499
+ static void drm_panic_logo_rect (struct drm_rect * rect , const struct font_desc * font )
500
+ {
501
+ if (logo_mono ) {
502
+ drm_rect_init (rect , 0 , 0 , logo_mono -> width , logo_mono -> height );
503
+ } else {
504
+ int logo_width = get_max_line_len (logo_ascii , logo_ascii_lines ) * font -> width ;
505
+
506
+ drm_rect_init (rect , 0 , 0 , logo_width , logo_ascii_lines * font -> height );
507
+ }
508
+ }
509
+
510
+ static void drm_panic_logo_draw (struct drm_scanout_buffer * sb , struct drm_rect * rect ,
511
+ const struct font_desc * font , u32 fg_color )
512
+ {
513
+ if (logo_mono )
514
+ drm_panic_blit (sb , rect , logo_mono -> data ,
515
+ DIV_ROUND_UP (drm_rect_width (rect ), 8 ), 1 , fg_color );
516
+ else
517
+ draw_txt_rectangle (sb , font , logo_ascii , logo_ascii_lines , false, rect ,
518
+ fg_color );
519
+ }
520
+
499
521
static void draw_panic_static_user (struct drm_scanout_buffer * sb )
500
522
{
501
523
u32 fg_color = convert_from_xrgb8888 (CONFIG_DRM_PANIC_FOREGROUND_COLOR , sb -> format -> format );
502
524
u32 bg_color = convert_from_xrgb8888 (CONFIG_DRM_PANIC_BACKGROUND_COLOR , sb -> format -> format );
503
525
const struct font_desc * font = get_default_font (sb -> width , sb -> height , NULL , NULL );
504
526
struct drm_rect r_screen , r_logo , r_msg ;
505
- unsigned int logo_width , logo_height ;
506
527
unsigned int msg_width , msg_height ;
507
528
508
529
if (!font )
509
530
return ;
510
531
511
532
r_screen = DRM_RECT_INIT (0 , 0 , sb -> width , sb -> height );
533
+ drm_panic_logo_rect (& r_logo , font );
512
534
513
- if (logo_mono ) {
514
- logo_width = logo_mono -> width ;
515
- logo_height = logo_mono -> height ;
516
- } else {
517
- logo_width = get_max_line_len (logo_ascii , PANIC_LOGO_LINES ) * font -> width ;
518
- logo_height = PANIC_LOGO_LINES * font -> height ;
519
- }
520
- r_logo = DRM_RECT_INIT (0 , 0 , logo_width , logo_height );
521
-
522
- msg_width = min (get_max_line_len (panic_msg , PANIC_MSG_LINES ) * font -> width , sb -> width );
523
- msg_height = min (PANIC_MSG_LINES * font -> height , sb -> height );
535
+ msg_width = min (get_max_line_len (panic_msg , panic_msg_lines ) * font -> width , sb -> width );
536
+ msg_height = min (panic_msg_lines * font -> height , sb -> height );
524
537
r_msg = DRM_RECT_INIT (0 , 0 , msg_width , msg_height );
525
538
526
539
/* Center the panic message */
@@ -529,15 +542,10 @@ static void draw_panic_static_user(struct drm_scanout_buffer *sb)
529
542
/* Fill with the background color, and draw text on top */
530
543
drm_panic_fill (sb , & r_screen , bg_color );
531
544
532
- if (!drm_rect_overlap (& r_logo , & r_msg )) {
533
- if (logo_mono )
534
- drm_panic_blit (sb , & r_logo , logo_mono -> data , DIV_ROUND_UP (logo_width , 8 ),
535
- fg_color );
536
- else
537
- draw_txt_rectangle (sb , font , logo_ascii , PANIC_LOGO_LINES , false, & r_logo ,
538
- fg_color );
539
- }
540
- draw_txt_rectangle (sb , font , panic_msg , PANIC_MSG_LINES , true, & r_msg , fg_color );
545
+ if (!drm_rect_overlap (& r_logo , & r_msg ))
546
+ drm_panic_logo_draw (sb , & r_logo , font , fg_color );
547
+
548
+ draw_txt_rectangle (sb , font , panic_msg , panic_msg_lines , true, & r_msg , fg_color );
541
549
}
542
550
543
551
/*
@@ -647,7 +655,7 @@ static void drm_panic_set_description(const char *description)
647
655
u32 len ;
648
656
649
657
if (description ) {
650
- struct drm_panic_line * desc_line = & panic_msg [PANIC_MSG_LINES - 1 ];
658
+ struct drm_panic_line * desc_line = & panic_msg [panic_msg_lines - 1 ];
651
659
652
660
desc_line -> txt = description ;
653
661
len = strlen (description );
@@ -660,7 +668,7 @@ static void drm_panic_set_description(const char *description)
660
668
661
669
static void drm_panic_clear_description (void )
662
670
{
663
- struct drm_panic_line * desc_line = & panic_msg [PANIC_MSG_LINES - 1 ];
671
+ struct drm_panic_line * desc_line = & panic_msg [panic_msg_lines - 1 ];
664
672
665
673
desc_line -> len = 0 ;
666
674
desc_line -> txt = NULL ;
0 commit comments