aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/simplefb.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-08-02 08:05:20 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2013-08-02 19:17:44 -0400
commit5ef76da644bf346d29200007d8d3779e7009dabb (patch)
treee9e248f6a7f06211d03a8d89cf5466d5adcb885d /drivers/video/simplefb.c
parent5ae90d8e467e625e447000cb4335c4db973b1095 (diff)
fbdev: simplefb: add init through platform_data
If we create proper platform-devices in x86 boot-code, we can use simplefb for VBE or EFI framebuffers, too. However, there is normally no OF support so we introduce a platform_data object so x86 boot-code can pass the parameters via plain old platform-data. This also removes the OF dependency as it is not needed. The headers provide proper dummies for the case OF is disabled. Furthermore, we move the FORMAT-definitions to the common platform header so initialization code can use it to transform "struct screen_info" to the right format-name. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Link: http://lkml.kernel.org/r/1375445127-15480-2-git-send-email-dh.herrmann@gmail.com Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'drivers/video/simplefb.c')
-rw-r--r--drivers/video/simplefb.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/drivers/video/simplefb.c b/drivers/video/simplefb.c
index e2e9e3e61b72..588698986ce1 100644
--- a/drivers/video/simplefb.c
+++ b/drivers/video/simplefb.c
@@ -24,6 +24,7 @@
24#include <linux/fb.h> 24#include <linux/fb.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/platform_data/simplefb.h>
27#include <linux/platform_device.h> 28#include <linux/platform_device.h>
28 29
29static struct fb_fix_screeninfo simplefb_fix = { 30static struct fb_fix_screeninfo simplefb_fix = {
@@ -73,18 +74,7 @@ static struct fb_ops simplefb_ops = {
73 .fb_imageblit = cfb_imageblit, 74 .fb_imageblit = cfb_imageblit,
74}; 75};
75 76
76struct simplefb_format { 77static struct simplefb_format simplefb_formats[] = SIMPLEFB_FORMATS;
77 const char *name;
78 u32 bits_per_pixel;
79 struct fb_bitfield red;
80 struct fb_bitfield green;
81 struct fb_bitfield blue;
82 struct fb_bitfield transp;
83};
84
85static struct simplefb_format simplefb_formats[] = {
86 { "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0} },
87};
88 78
89struct simplefb_params { 79struct simplefb_params {
90 u32 width; 80 u32 width;
@@ -139,6 +129,33 @@ static int simplefb_parse_dt(struct platform_device *pdev,
139 return 0; 129 return 0;
140} 130}
141 131
132static int simplefb_parse_pd(struct platform_device *pdev,
133 struct simplefb_params *params)
134{
135 struct simplefb_platform_data *pd = pdev->dev.platform_data;
136 int i;
137
138 params->width = pd->width;
139 params->height = pd->height;
140 params->stride = pd->stride;
141
142 params->format = NULL;
143 for (i = 0; i < ARRAY_SIZE(simplefb_formats); i++) {
144 if (strcmp(pd->format, simplefb_formats[i].name))
145 continue;
146
147 params->format = &simplefb_formats[i];
148 break;
149 }
150
151 if (!params->format) {
152 dev_err(&pdev->dev, "Invalid format value\n");
153 return -EINVAL;
154 }
155
156 return 0;
157}
158
142static int simplefb_probe(struct platform_device *pdev) 159static int simplefb_probe(struct platform_device *pdev)
143{ 160{
144 int ret; 161 int ret;
@@ -149,7 +166,12 @@ static int simplefb_probe(struct platform_device *pdev)
149 if (fb_get_options("simplefb", NULL)) 166 if (fb_get_options("simplefb", NULL))
150 return -ENODEV; 167 return -ENODEV;
151 168
152 ret = simplefb_parse_dt(pdev, &params); 169 ret = -ENODEV;
170 if (pdev->dev.platform_data)
171 ret = simplefb_parse_pd(pdev, &params);
172 else if (pdev->dev.of_node)
173 ret = simplefb_parse_dt(pdev, &params);
174
153 if (ret) 175 if (ret)
154 return ret; 176 return ret;
155 177