|
48 | 48 | #include <linux/miscdevice.h> |
49 | 49 | #include <linux/slab.h> |
50 | 50 | #include <linux/screen_info.h> |
| 51 | +#include <linux/vt.h> |
| 52 | +#include <linux/console.h> |
51 | 53 |
|
52 | 54 | #include <linux/uaccess.h> |
53 | 55 |
|
@@ -168,6 +170,53 @@ void vga_set_default_device(struct pci_dev *pdev) |
168 | 170 | vga_default = pci_dev_get(pdev); |
169 | 171 | } |
170 | 172 |
|
| 173 | +/** |
| 174 | + * vga_remove_vgacon - deactivete vga console |
| 175 | + * |
| 176 | + * Unbind and unregister vgacon in case pdev is the default vga |
| 177 | + * device. Can be called by gpu drivers on initialization to make |
| 178 | + * sure vga register access done by vgacon will not disturb the |
| 179 | + * device. |
| 180 | + * |
| 181 | + * @pdev: pci device. |
| 182 | + */ |
| 183 | +#if !defined(CONFIG_VGA_CONSOLE) |
| 184 | +int vga_remove_vgacon(struct pci_dev *pdev) |
| 185 | +{ |
| 186 | + return 0; |
| 187 | +} |
| 188 | +#elif !defined(CONFIG_DUMMY_CONSOLE) |
| 189 | +int vga_remove_vgacon(struct pci_dev *pdev) |
| 190 | +{ |
| 191 | + return -ENODEV; |
| 192 | +} |
| 193 | +#else |
| 194 | +int vga_remove_vgacon(struct pci_dev *pdev) |
| 195 | +{ |
| 196 | + int ret = 0; |
| 197 | + |
| 198 | + if (pdev != vga_default) |
| 199 | + return 0; |
| 200 | + vgaarb_info(&pdev->dev, "deactivate vga console\n"); |
| 201 | + |
| 202 | + console_lock(); |
| 203 | + if (con_is_bound(&vga_con)) |
| 204 | + ret = do_take_over_console(&dummy_con, 0, |
| 205 | + MAX_NR_CONSOLES - 1, 1); |
| 206 | + if (ret == 0) { |
| 207 | + ret = do_unregister_con_driver(&vga_con); |
| 208 | + |
| 209 | + /* Ignore "already unregistered". */ |
| 210 | + if (ret == -ENODEV) |
| 211 | + ret = 0; |
| 212 | + } |
| 213 | + console_unlock(); |
| 214 | + |
| 215 | + return ret; |
| 216 | +} |
| 217 | +#endif |
| 218 | +EXPORT_SYMBOL(vga_remove_vgacon); |
| 219 | + |
171 | 220 | static inline void vga_irq_set_state(struct vga_device *vgadev, bool state) |
172 | 221 | { |
173 | 222 | if (vgadev->irq_set_state) |
|
0 commit comments