1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/video/dummycon.c -- A dummy console driver
5 * To be used if there's no other console driver (e.g. for plain VGA text)
6 * available, usually until fbcon takes console over.
9 #include <linux/types.h>
10 #include <linux/kdev_t.h>
11 #include <linux/console.h>
12 #include <linux/vt_kern.h>
13 #include <linux/screen_info.h>
14 #include <linux/init.h>
15 #include <linux/module.h>
18 * Dummy console driver
21 #if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_VGA_CONSOLE)
23 #define DUMMY_COLUMNS vgacon_screen_info.orig_video_cols
24 #define DUMMY_ROWS vgacon_screen_info.orig_video_lines
26 /* set by Kconfig. Use 80x25 for 640x480 and 160x64 for 1280x1024 */
27 #define DUMMY_COLUMNS CONFIG_DUMMY_CONSOLE_COLUMNS
28 #define DUMMY_ROWS CONFIG_DUMMY_CONSOLE_ROWS
31 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
32 /* These are both protected by the console_lock */
33 static RAW_NOTIFIER_HEAD(dummycon_output_nh
);
34 static bool dummycon_putc_called
;
36 void dummycon_register_output_notifier(struct notifier_block
*nb
)
38 WARN_CONSOLE_UNLOCKED();
40 raw_notifier_chain_register(&dummycon_output_nh
, nb
);
42 if (dummycon_putc_called
)
43 nb
->notifier_call(nb
, 0, NULL
);
46 void dummycon_unregister_output_notifier(struct notifier_block
*nb
)
48 WARN_CONSOLE_UNLOCKED();
50 raw_notifier_chain_unregister(&dummycon_output_nh
, nb
);
53 static void dummycon_putc(struct vc_data
*vc
, u16 c
, unsigned int y
,
56 WARN_CONSOLE_UNLOCKED();
58 dummycon_putc_called
= true;
59 raw_notifier_call_chain(&dummycon_output_nh
, 0, NULL
);
62 static void dummycon_putcs(struct vc_data
*vc
, const u16
*s
, unsigned int count
,
63 unsigned int ypos
, unsigned int xpos
)
67 if (!dummycon_putc_called
) {
69 for (i
= 0 ; i
< count
; i
++) {
70 if (s
[i
] != vc
->vc_video_erase_char
)
76 dummycon_putc_called
= true;
79 raw_notifier_call_chain(&dummycon_output_nh
, 0, NULL
);
82 static bool dummycon_blank(struct vc_data
*vc
, enum vesa_blank_mode blank
,
85 /* Redraw, so that we get putc(s) for output done while blanked */
89 static void dummycon_putc(struct vc_data
*vc
, u16 c
, unsigned int y
,
91 static void dummycon_putcs(struct vc_data
*vc
, const u16
*s
, unsigned int count
,
92 unsigned int ypos
, unsigned int xpos
) { }
93 static bool dummycon_blank(struct vc_data
*vc
, enum vesa_blank_mode blank
,
100 static const char *dummycon_startup(void)
102 return "dummy device";
105 static void dummycon_init(struct vc_data
*vc
, bool init
)
107 vc
->vc_can_do_color
= 1;
109 vc
->vc_cols
= DUMMY_COLUMNS
;
110 vc
->vc_rows
= DUMMY_ROWS
;
112 vc_resize(vc
, DUMMY_COLUMNS
, DUMMY_ROWS
);
115 static void dummycon_deinit(struct vc_data
*vc
) { }
116 static void dummycon_clear(struct vc_data
*vc
, unsigned int sy
, unsigned int sx
,
117 unsigned int width
) { }
118 static void dummycon_cursor(struct vc_data
*vc
, bool enable
) { }
120 static bool dummycon_scroll(struct vc_data
*vc
, unsigned int top
,
121 unsigned int bottom
, enum con_scroll dir
,
127 static bool dummycon_switch(struct vc_data
*vc
)
133 * The console `switch' structure for the dummy console
135 * Most of the operations are dummies.
138 const struct consw dummy_con
= {
139 .owner
= THIS_MODULE
,
140 .con_startup
= dummycon_startup
,
141 .con_init
= dummycon_init
,
142 .con_deinit
= dummycon_deinit
,
143 .con_clear
= dummycon_clear
,
144 .con_putc
= dummycon_putc
,
145 .con_putcs
= dummycon_putcs
,
146 .con_cursor
= dummycon_cursor
,
147 .con_scroll
= dummycon_scroll
,
148 .con_switch
= dummycon_switch
,
149 .con_blank
= dummycon_blank
,
151 EXPORT_SYMBOL_GPL(dummy_con
);