2 * linux/drivers/video/dummycon.c -- A dummy console driver
4 * To be used if there's no other console driver (e.g. for plain VGA text)
5 * available, usually until fbcon takes console over.
8 #include <linux/types.h>
9 #include <linux/kdev_t.h>
10 #include <linux/console.h>
11 #include <linux/vt_kern.h>
12 #include <linux/screen_info.h>
13 #include <linux/init.h>
14 #include <linux/module.h>
17 * Dummy console driver
21 #define DUMMY_COLUMNS screen_info.orig_video_cols
22 #define DUMMY_ROWS screen_info.orig_video_lines
24 /* set by Kconfig. Use 80x25 for 640x480 and 160x64 for 1280x1024 */
25 #define DUMMY_COLUMNS CONFIG_DUMMY_CONSOLE_COLUMNS
26 #define DUMMY_ROWS CONFIG_DUMMY_CONSOLE_ROWS
29 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
30 /* These are both protected by the console_lock */
31 static RAW_NOTIFIER_HEAD(dummycon_output_nh
);
32 static bool dummycon_putc_called
;
34 void dummycon_register_output_notifier(struct notifier_block
*nb
)
36 raw_notifier_chain_register(&dummycon_output_nh
, nb
);
38 if (dummycon_putc_called
)
39 nb
->notifier_call(nb
, 0, NULL
);
42 void dummycon_unregister_output_notifier(struct notifier_block
*nb
)
44 raw_notifier_chain_unregister(&dummycon_output_nh
, nb
);
47 static void dummycon_putc(struct vc_data
*vc
, int c
, int ypos
, int xpos
)
49 dummycon_putc_called
= true;
50 raw_notifier_call_chain(&dummycon_output_nh
, 0, NULL
);
53 static void dummycon_putcs(struct vc_data
*vc
, const unsigned short *s
,
54 int count
, int ypos
, int xpos
)
58 if (!dummycon_putc_called
) {
60 for (i
= 0 ; i
< count
; i
++) {
61 if (s
[i
] != vc
->vc_video_erase_char
)
67 dummycon_putc_called
= true;
70 raw_notifier_call_chain(&dummycon_output_nh
, 0, NULL
);
73 static int dummycon_blank(struct vc_data
*vc
, int blank
, int mode_switch
)
75 /* Redraw, so that we get putc(s) for output done while blanked */
79 static void dummycon_putc(struct vc_data
*vc
, int c
, int ypos
, int xpos
) { }
80 static void dummycon_putcs(struct vc_data
*vc
, const unsigned short *s
,
81 int count
, int ypos
, int xpos
) { }
82 static int dummycon_blank(struct vc_data
*vc
, int blank
, int mode_switch
)
88 static const char *dummycon_startup(void)
90 return "dummy device";
93 static void dummycon_init(struct vc_data
*vc
, int init
)
95 vc
->vc_can_do_color
= 1;
97 vc
->vc_cols
= DUMMY_COLUMNS
;
98 vc
->vc_rows
= DUMMY_ROWS
;
100 vc_resize(vc
, DUMMY_COLUMNS
, DUMMY_ROWS
);
103 static void dummycon_deinit(struct vc_data
*vc
) { }
104 static void dummycon_clear(struct vc_data
*vc
, int sy
, int sx
, int height
,
106 static void dummycon_cursor(struct vc_data
*vc
, int mode
) { }
108 static bool dummycon_scroll(struct vc_data
*vc
, unsigned int top
,
109 unsigned int bottom
, enum con_scroll dir
,
115 static int dummycon_switch(struct vc_data
*vc
)
120 static int dummycon_font_set(struct vc_data
*vc
, struct console_font
*font
,
126 static int dummycon_font_default(struct vc_data
*vc
,
127 struct console_font
*font
, char *name
)
132 static int dummycon_font_copy(struct vc_data
*vc
, int con
)
138 * The console `switch' structure for the dummy console
140 * Most of the operations are dummies.
143 const struct consw dummy_con
= {
144 .owner
= THIS_MODULE
,
145 .con_startup
= dummycon_startup
,
146 .con_init
= dummycon_init
,
147 .con_deinit
= dummycon_deinit
,
148 .con_clear
= dummycon_clear
,
149 .con_putc
= dummycon_putc
,
150 .con_putcs
= dummycon_putcs
,
151 .con_cursor
= dummycon_cursor
,
152 .con_scroll
= dummycon_scroll
,
153 .con_switch
= dummycon_switch
,
154 .con_blank
= dummycon_blank
,
155 .con_font_set
= dummycon_font_set
,
156 .con_font_default
= dummycon_font_default
,
157 .con_font_copy
= dummycon_font_copy
,
159 EXPORT_SYMBOL_GPL(dummy_con
);