2 * Generic System Framebuffers on x86
3 * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
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)
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.
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.
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.
32 #include <linux/err.h>
33 #include <linux/init.h>
34 #include <linux/kernel.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>
41 static __init
int sysfb_init(void)
43 struct screen_info
*si
= &screen_info
;
44 struct simplefb_platform_data mode
;
45 struct platform_device
*pd
;
50 sysfb_apply_efi_quirks();
52 /* try to create a simple-framebuffer device */
53 compatible
= parse_mode(si
, &mode
);
55 ret
= create_simplefb(si
, &mode
);
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";
66 name
= "platform-framebuffer";
68 pd
= platform_device_register_resndata(NULL
, name
, 0,
69 NULL
, 0, si
, sizeof(*si
));
70 return IS_ERR(pd
) ? PTR_ERR(pd
) : 0;
73 /* must execute after PCI subsystem for EFI quirks */
74 device_initcall(sysfb_init
);