diff options
Diffstat (limited to 'arch/x86/kernel/sysfb.c')
-rw-r--r-- | arch/x86/kernel/sysfb.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/x86/kernel/sysfb.c b/arch/x86/kernel/sysfb.c new file mode 100644 index 000000000000..193ec2ce46c7 --- /dev/null +++ b/arch/x86/kernel/sysfb.c | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * Generic System Framebuffers on x86 | ||
3 | * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms of the GNU General Public License as published by the Free | ||
7 | * Software Foundation; either version 2 of the License, or (at your option) | ||
8 | * any later version. | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * Simple-Framebuffer support for x86 systems | ||
13 | * Create a platform-device for any available boot framebuffer. The | ||
14 | * simple-framebuffer platform device is already available on DT systems, so | ||
15 | * this module parses the global "screen_info" object and creates a suitable | ||
16 | * platform device compatible with the "simple-framebuffer" DT object. If | ||
17 | * the framebuffer is incompatible, we instead create a legacy | ||
18 | * "vesa-framebuffer", "efi-framebuffer" or "platform-framebuffer" device and | ||
19 | * pass the screen_info as platform_data. This allows legacy drivers | ||
20 | * to pick these devices up without messing with simple-framebuffer drivers. | ||
21 | * The global "screen_info" is still valid at all times. | ||
22 | * | ||
23 | * If CONFIG_X86_SYSFB is not selected, we never register "simple-framebuffer" | ||
24 | * platform devices, but only use legacy framebuffer devices for | ||
25 | * backwards compatibility. | ||
26 | * | ||
27 | * TODO: We set the dev_id field of all platform-devices to 0. This allows | ||
28 | * other x86 OF/DT parsers to create such devices, too. However, they must | ||
29 | * start at offset 1 for this to work. | ||
30 | */ | ||
31 | |||
32 | #include <linux/err.h> | ||
33 | #include <linux/init.h> | ||
34 | #include <linux/kernel.h> | ||
35 | #include <linux/mm.h> | ||
36 | #include <linux/platform_data/simplefb.h> | ||
37 | #include <linux/platform_device.h> | ||
38 | #include <linux/screen_info.h> | ||
39 | #include <asm/sysfb.h> | ||
40 | |||
41 | static __init int sysfb_init(void) | ||
42 | { | ||
43 | struct screen_info *si = &screen_info; | ||
44 | struct simplefb_platform_data mode; | ||
45 | struct platform_device *pd; | ||
46 | const char *name; | ||
47 | bool compatible; | ||
48 | int ret; | ||
49 | |||
50 | sysfb_apply_efi_quirks(); | ||
51 | |||
52 | /* try to create a simple-framebuffer device */ | ||
53 | compatible = parse_mode(si, &mode); | ||
54 | if (compatible) { | ||
55 | ret = create_simplefb(si, &mode); | ||
56 | if (!ret) | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | /* if the FB is incompatible, create a legacy framebuffer device */ | ||
61 | if (si->orig_video_isVGA == VIDEO_TYPE_EFI) | ||
62 | name = "efi-framebuffer"; | ||
63 | else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB) | ||
64 | name = "vesa-framebuffer"; | ||
65 | else | ||
66 | name = "platform-framebuffer"; | ||
67 | |||
68 | pd = platform_device_register_resndata(NULL, name, 0, | ||
69 | NULL, 0, si, sizeof(*si)); | ||
70 | return IS_ERR(pd) ? PTR_ERR(pd) : 0; | ||
71 | } | ||
72 | |||
73 | /* must execute after PCI subsystem for EFI quirks */ | ||
74 | device_initcall(sysfb_init); | ||