diff options
-rw-r--r-- | drivers/video/Kconfig | 5 | ||||
-rw-r--r-- | drivers/video/simplefb.c | 48 | ||||
-rw-r--r-- | include/linux/platform_data/simplefb.h | 56 |
3 files changed, 93 insertions, 16 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 4cf1e1dd5621..34c3d960634d 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -2457,7 +2457,7 @@ config FB_HYPERV | |||
2457 | 2457 | ||
2458 | config FB_SIMPLE | 2458 | config FB_SIMPLE |
2459 | bool "Simple framebuffer support" | 2459 | bool "Simple framebuffer support" |
2460 | depends on (FB = y) && OF | 2460 | depends on (FB = y) |
2461 | select FB_CFB_FILLRECT | 2461 | select FB_CFB_FILLRECT |
2462 | select FB_CFB_COPYAREA | 2462 | select FB_CFB_COPYAREA |
2463 | select FB_CFB_IMAGEBLIT | 2463 | select FB_CFB_IMAGEBLIT |
@@ -2469,8 +2469,7 @@ config FB_SIMPLE | |||
2469 | pre-allocated frame buffer surface. | 2469 | pre-allocated frame buffer surface. |
2470 | 2470 | ||
2471 | Configuration re: surface address, size, and format must be provided | 2471 | Configuration re: surface address, size, and format must be provided |
2472 | through device tree, or potentially plain old platform data in the | 2472 | through device tree, or plain old platform data. |
2473 | future. | ||
2474 | 2473 | ||
2475 | source "drivers/video/omap/Kconfig" | 2474 | source "drivers/video/omap/Kconfig" |
2476 | source "drivers/video/omap2/Kconfig" | 2475 | source "drivers/video/omap2/Kconfig" |
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 | ||
29 | static struct fb_fix_screeninfo simplefb_fix = { | 30 | static 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 | ||
76 | struct simplefb_format { | 77 | static 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 | |||
85 | static struct simplefb_format simplefb_formats[] = { | ||
86 | { "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0} }, | ||
87 | }; | ||
88 | 78 | ||
89 | struct simplefb_params { | 79 | struct 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 | ||
132 | static 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 | |||
142 | static int simplefb_probe(struct platform_device *pdev) | 159 | static 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, ¶ms); | 169 | ret = -ENODEV; |
170 | if (pdev->dev.platform_data) | ||
171 | ret = simplefb_parse_pd(pdev, ¶ms); | ||
172 | else if (pdev->dev.of_node) | ||
173 | ret = simplefb_parse_dt(pdev, ¶ms); | ||
174 | |||
153 | if (ret) | 175 | if (ret) |
154 | return ret; | 176 | return ret; |
155 | 177 | ||
diff --git a/include/linux/platform_data/simplefb.h b/include/linux/platform_data/simplefb.h new file mode 100644 index 000000000000..5fa2c5e02ab8 --- /dev/null +++ b/include/linux/platform_data/simplefb.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * simplefb.h - Simple Framebuffer Device | ||
3 | * | ||
4 | * Copyright (C) 2013 David Herrmann <dh.herrmann@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifndef __PLATFORM_DATA_SIMPLEFB_H__ | ||
13 | #define __PLATFORM_DATA_SIMPLEFB_H__ | ||
14 | |||
15 | #include <drm/drm_fourcc.h> | ||
16 | #include <linux/fb.h> | ||
17 | #include <linux/kernel.h> | ||
18 | |||
19 | /* format array, use it to initialize a "struct simplefb_format" array */ | ||
20 | #define SIMPLEFB_FORMATS \ | ||
21 | { \ | ||
22 | { "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0}, DRM_FORMAT_RGB565 }, \ | ||
23 | } | ||
24 | |||
25 | /* | ||
26 | * Data-Format for Simple-Framebuffers | ||
27 | * @name: unique 0-terminated name that can be used to identify the mode | ||
28 | * @red,green,blue: Offsets and sizes of the single RGB parts | ||
29 | * @transp: Offset and size of the alpha bits. length=0 means no alpha | ||
30 | * @fourcc: 32bit DRM four-CC code (see drm_fourcc.h) | ||
31 | */ | ||
32 | struct simplefb_format { | ||
33 | const char *name; | ||
34 | u32 bits_per_pixel; | ||
35 | struct fb_bitfield red; | ||
36 | struct fb_bitfield green; | ||
37 | struct fb_bitfield blue; | ||
38 | struct fb_bitfield transp; | ||
39 | u32 fourcc; | ||
40 | }; | ||
41 | |||
42 | /* | ||
43 | * Simple-Framebuffer description | ||
44 | * If the arch-boot code creates simple-framebuffers without DT support, it | ||
45 | * can pass the width, height, stride and format via this platform-data object. | ||
46 | * The framebuffer location must be given as IORESOURCE_MEM resource. | ||
47 | * @format must be a format as described in "struct simplefb_format" above. | ||
48 | */ | ||
49 | struct simplefb_platform_data { | ||
50 | u32 width; | ||
51 | u32 height; | ||
52 | u32 stride; | ||
53 | const char *format; | ||
54 | }; | ||
55 | |||
56 | #endif /* __PLATFORM_DATA_SIMPLEFB_H__ */ | ||