From 4deabce17c8be66154eacce77a1407b2c414668c Mon Sep 17 00:00:00 2001 From: Matt Sealey Date: Mon, 14 Feb 2011 02:52:44 -0600 Subject: [PATCH] framebuffer: method for selecting a close bpp by default that matches the IPU DI connected lines from platform data. MX will get 32-bit by default and SB will get 16-bit by default without much trouble --- drivers/video/mxc/mxc_ipuv3_fb.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/video/mxc/mxc_ipuv3_fb.c b/drivers/video/mxc/mxc_ipuv3_fb.c index ead99f78b96..b272fc2ca37 100644 --- a/drivers/video/mxc/mxc_ipuv3_fb.c +++ b/drivers/video/mxc/mxc_ipuv3_fb.c @@ -124,6 +124,25 @@ static uint32_t bpp_to_pixfmt(struct fb_info *fbi) return pixfmt; } +static uint32_t pixfmt_to_bpp(uint32_t pixfmt) +{ + uint32_t bpp; + + switch (pixfmt) { + case IPU_PIX_FMT_BGR24: + case IPU_PIX_FMT_BGR32: + case IPU_PIX_FMT_RGB24: + bpp = 32; + break; + case IPU_PIX_FMT_RGB565: + default: + bpp = 16; + break; + } + + return bpp; +} + static irqreturn_t mxcfb_irq_handler(int irq, void *dev_id); static int mxcfb_blank(int blank, struct fb_info *info); static int mxcfb_map_video_memory(struct fb_info *fbi); @@ -615,7 +634,7 @@ static int mxcfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) if ((var->bits_per_pixel != 32) && (var->bits_per_pixel != 24) && (var->bits_per_pixel != 16) && (var->bits_per_pixel != 12) && (var->bits_per_pixel != 8)) - var->bits_per_pixel = 16; + var->bits_per_pixel = mxc_fbi->default_bpp; switch (var->bits_per_pixel) { case 8: @@ -1713,12 +1732,15 @@ static int mxcfb_probe(struct platform_device *pdev) fbi->var.xres = 240; fbi->var.yres = 320; + if (plat_data && !mxcfbi->ipu_di_pix_fmt) { + mxcfbi->ipu_di_pix_fmt = plat_data->interface_pix_fmt; + /* try and use a bit depth closest to the bit depth we use for the panel */ + mxcfbi->default_bpp = pixfmt_to_bpp(plat_data->interface_pix_fmt); + } + if (!mxcfbi->default_bpp) mxcfbi->default_bpp = 16; - if (plat_data && !mxcfbi->ipu_di_pix_fmt) - mxcfbi->ipu_di_pix_fmt = plat_data->interface_pix_fmt; - if (plat_data && plat_data->mode && plat_data->num_modes) fb_videomode_to_modelist(plat_data->mode, plat_data->num_modes, &fbi->modelist);