sysfb_simplefb.c (d391c58271072d0b0fad93c82018d495b2633448) sysfb_simplefb.c (8633ef82f101c040427b57d4df7b706261420b94)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Generic System Framebuffers on x86
3 * Generic System Framebuffers
4 * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
5 */
6
7/*
8 * simple-framebuffer probing
9 * Try to convert "screen_info" into a "simple-framebuffer" compatible mode.
10 * If the mode is incompatible, we return "false" and let the caller create
11 * legacy nodes instead.

--- 6 unchanged lines hidden (view full) ---

18#include <linux/platform_data/simplefb.h>
19#include <linux/platform_device.h>
20#include <linux/screen_info.h>
21#include <linux/sysfb.h>
22
23static const char simplefb_resname[] = "BOOTFB";
24static const struct simplefb_format formats[] = SIMPLEFB_FORMATS;
25
4 * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
5 */
6
7/*
8 * simple-framebuffer probing
9 * Try to convert "screen_info" into a "simple-framebuffer" compatible mode.
10 * If the mode is incompatible, we return "false" and let the caller create
11 * legacy nodes instead.

--- 6 unchanged lines hidden (view full) ---

18#include <linux/platform_data/simplefb.h>
19#include <linux/platform_device.h>
20#include <linux/screen_info.h>
21#include <linux/sysfb.h>
22
23static const char simplefb_resname[] = "BOOTFB";
24static const struct simplefb_format formats[] = SIMPLEFB_FORMATS;
25
26/* try parsing x86 screen_info into a simple-framebuffer mode struct */
27__init bool parse_mode(const struct screen_info *si,
28 struct simplefb_platform_data *mode)
26/* try parsing screen_info into a simple-framebuffer mode struct */
27__init bool sysfb_parse_mode(const struct screen_info *si,
28 struct simplefb_platform_data *mode)
29{
30 const struct simplefb_format *f;
31 __u8 type;
32 unsigned int i;
33
34 type = si->orig_video_isVGA;
35 if (type != VIDEO_TYPE_VLFB && type != VIDEO_TYPE_EFI)
36 return false;

--- 15 unchanged lines hidden (view full) ---

52 mode->stride = si->lfb_linelength;
53 return true;
54 }
55 }
56
57 return false;
58}
59
29{
30 const struct simplefb_format *f;
31 __u8 type;
32 unsigned int i;
33
34 type = si->orig_video_isVGA;
35 if (type != VIDEO_TYPE_VLFB && type != VIDEO_TYPE_EFI)
36 return false;

--- 15 unchanged lines hidden (view full) ---

52 mode->stride = si->lfb_linelength;
53 return true;
54 }
55 }
56
57 return false;
58}
59
60__init int create_simplefb(const struct screen_info *si,
61 const struct simplefb_platform_data *mode)
60__init int sysfb_create_simplefb(const struct screen_info *si,
61 const struct simplefb_platform_data *mode)
62{
63 struct platform_device *pd;
64 struct resource res;
65 u64 base, size;
66 u32 length;
62{
63 struct platform_device *pd;
64 struct resource res;
65 u64 base, size;
66 u32 length;
67 int ret;
67
68 /*
69 * If the 64BIT_BASE capability is set, ext_lfb_base will contain the
70 * upper half of the base address. Assemble the address, then make sure
71 * it is valid and we can actually access it.
72 */
73 base = si->lfb_base;
74 if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)

--- 25 unchanged lines hidden (view full) ---

100 memset(&res, 0, sizeof(res));
101 res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
102 res.name = simplefb_resname;
103 res.start = base;
104 res.end = res.start + length - 1;
105 if (res.end <= res.start)
106 return -EINVAL;
107
68
69 /*
70 * If the 64BIT_BASE capability is set, ext_lfb_base will contain the
71 * upper half of the base address. Assemble the address, then make sure
72 * it is valid and we can actually access it.
73 */
74 base = si->lfb_base;
75 if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)

--- 25 unchanged lines hidden (view full) ---

101 memset(&res, 0, sizeof(res));
102 res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
103 res.name = simplefb_resname;
104 res.start = base;
105 res.end = res.start + length - 1;
106 if (res.end <= res.start)
107 return -EINVAL;
108
108 pd = platform_device_register_resndata(NULL, "simple-framebuffer", 0,
109 &res, 1, mode, sizeof(*mode));
110 return PTR_ERR_OR_ZERO(pd);
109 pd = platform_device_alloc("simple-framebuffer", 0);
110 if (!pd)
111 return -ENOMEM;
112
113 sysfb_apply_efi_quirks(pd);
114
115 ret = platform_device_add_resources(pd, &res, 1);
116 if (ret)
117 return ret;
118
119 ret = platform_device_add_data(pd, mode, sizeof(*mode));
120 if (ret)
121 return ret;
122
123 return platform_device_add(pd);
111}
124}