1 From c02b843c2732bc7b15a3e35b5dd715d68225bbd1 Mon Sep 17 00:00:00 2001
2 From: Imre Deak <imre.deak@nokia.com>
3 Date: Wed, 8 Apr 2009 12:51:46 +0200
4 Subject: [PATCH] DSS2: pass the default FB color format through board info
6 Add a field to the FB memory region platform data, so that board
7 init code can pass a default color format to the driver. Set this
8 format as an initial setting for the given FB.
10 This is needed for an upcoming patch that adds detection of the
11 color format set by the bootloader.
13 Signed-off-by: Imre Deak <imre.deak@nokia.com>
15 drivers/video/omap2/omapfb/omapfb-main.c | 121 +++++++++++++++++++++++++++---
16 drivers/video/omap2/omapfb/omapfb.h | 2 +
17 include/linux/omapfb.h | 5 +
18 3 files changed, 117 insertions(+), 11 deletions(-)
20 diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
21 index 12ce0c3..67c67c2 100644
22 --- a/drivers/video/omap2/omapfb/omapfb-main.c
23 +++ b/drivers/video/omap2/omapfb/omapfb-main.c
24 @@ -370,6 +370,21 @@ static enum omap_color_mode fb_mode_to_dss_mode(struct fb_var_screeninfo *var)
28 +static int dss_mode_to_fb_mode(enum omap_color_mode dssmode,
29 + struct fb_var_screeninfo *var)
33 + for (i = 0; i < ARRAY_SIZE(omapfb_colormodes); ++i) {
34 + struct omapfb_colormode *mode = &omapfb_colormodes[i];
35 + if (dssmode == mode->dssmode) {
36 + assign_colormode_to_var(var, mode);
43 void set_fb_fix(struct fb_info *fbi)
45 struct fb_fix_screeninfo *fix = &fbi->fix;
46 @@ -1267,6 +1282,60 @@ static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size,
47 return omapfb_alloc_fbmem(fbi, size, paddr);
50 +static enum omap_color_mode fb_format_to_dss_mode(enum omapfb_color_format format)
52 + enum omap_color_mode mode;
55 + case OMAPFB_COLOR_RGB565:
56 + mode = OMAP_DSS_COLOR_RGB16;
58 + case OMAPFB_COLOR_YUV422:
59 + mode = OMAP_DSS_COLOR_YUV2;
61 + case OMAPFB_COLOR_CLUT_8BPP:
62 + mode = OMAP_DSS_COLOR_CLUT8;
64 + case OMAPFB_COLOR_CLUT_4BPP:
65 + mode = OMAP_DSS_COLOR_CLUT4;
67 + case OMAPFB_COLOR_CLUT_2BPP:
68 + mode = OMAP_DSS_COLOR_CLUT2;
70 + case OMAPFB_COLOR_CLUT_1BPP:
71 + mode = OMAP_DSS_COLOR_CLUT1;
73 + case OMAPFB_COLOR_RGB444:
74 + mode = OMAP_DSS_COLOR_RGB12U;
76 + case OMAPFB_COLOR_YUY422:
77 + mode = OMAP_DSS_COLOR_UYVY;
79 + case OMAPFB_COLOR_ARGB16:
80 + mode = OMAP_DSS_COLOR_ARGB16;
82 + case OMAPFB_COLOR_RGB24U:
83 + mode = OMAP_DSS_COLOR_RGB24U;
85 + case OMAPFB_COLOR_RGB24P:
86 + mode = OMAP_DSS_COLOR_RGB24P;
88 + case OMAPFB_COLOR_ARGB32:
89 + mode = OMAP_DSS_COLOR_ARGB32;
91 + case OMAPFB_COLOR_RGBA32:
92 + mode = OMAP_DSS_COLOR_RGBA32;
94 + case OMAPFB_COLOR_RGBX32:
95 + mode = OMAP_DSS_COLOR_RGBX32;
104 static int omapfb_parse_vram_param(const char *param, int max_entries,
105 unsigned long *sizes, unsigned long *paddrs)
107 @@ -1483,9 +1552,36 @@ int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi)
111 + var->bits_per_pixel = 0;
113 var->rotate = ofbi->rotation;
116 + * Check if there is a default color format set in the board file,
117 + * and use this format instead the default deducted from the
120 + if (fbdev->dev->platform_data) {
121 + struct omapfb_platform_data *opd;
124 + opd = fbdev->dev->platform_data;
125 + if (opd->mem_desc.region[id].format_used) {
126 + enum omap_color_mode mode;
127 + enum omapfb_color_format format;
129 + format = opd->mem_desc.region[id].format;
130 + mode = fb_format_to_dss_mode(format);
135 + r = dss_mode_to_fb_mode(mode, var);
143 display->get_resolution(display, &w, &h);
144 @@ -1502,16 +1598,18 @@ int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi)
145 var->xres_virtual = var->xres;
146 var->yres_virtual = var->yres;
148 - switch (display->get_recommended_bpp(display)) {
150 - var->bits_per_pixel = 16;
153 - var->bits_per_pixel = 32;
156 - dev_err(fbdev->dev, "illegal display bpp\n");
158 + if (!var->bits_per_pixel) {
159 + switch (display->get_recommended_bpp(display)) {
161 + var->bits_per_pixel = 16;
164 + var->bits_per_pixel = 32;
167 + dev_err(fbdev->dev, "illegal display bpp\n");
172 /* if there's no display, let's just guess some basic values */
173 @@ -1519,7 +1617,8 @@ int omapfb_fb_init(struct omapfb2_device *fbdev, struct fb_info *fbi)
175 var->xres_virtual = var->xres;
176 var->yres_virtual = var->yres;
177 - var->bits_per_pixel = 16;
178 + if (!var->bits_per_pixel)
179 + var->bits_per_pixel = 16;
182 r = check_fb_var(fbi, var);
183 diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h
184 index 65e9e6e..2607def 100644
185 --- a/drivers/video/omap2/omapfb/omapfb.h
186 +++ b/drivers/video/omap2/omapfb/omapfb.h
191 +#include <mach/display.h>
194 extern unsigned int omapfb_debug;
195 #define DBG(format, ...) \
196 diff --git a/include/linux/omapfb.h b/include/linux/omapfb.h
197 index 96190b2..7a34f22 100644
198 --- a/include/linux/omapfb.h
199 +++ b/include/linux/omapfb.h
200 @@ -298,6 +298,11 @@ struct omapfb_mem_region {
203 u8 type; /* OMAPFB_PLANE_MEM_* */
204 + enum omapfb_color_format format;/* OMAPFB_COLOR_* */
205 + unsigned format_used:1; /* Must be set when format is set.
206 + * Needed b/c of the badly chosen 0
207 + * base for OMAPFB_COLOR_* values
209 unsigned alloc:1; /* allocated by the driver */
210 unsigned map:1; /* kernel mapped by the driver */