]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/video/mxc/mxc_lcdif.c
video: mxc: use of_get_videomode() to set up the video timing
[karo-tx-linux.git] / drivers / video / mxc / mxc_lcdif.c
index dcfaf1c711a96fe6dea19f080fe3825cc035c916..e18731e238d91dd6cffefeac02a54171c0085e73 100644 (file)
@@ -19,6 +19,9 @@
 #include <linux/of_device.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
+#include <video/of_display_timing.h>
+#include <video/of_videomode.h>
+#include <video/videomode.h>
 
 #include "mxc_dispdrv.h"
 
@@ -26,10 +29,11 @@ struct mxc_lcd_platform_data {
        u32 default_ifmt;
        u32 ipu_id;
        u32 disp_id;
+       enum display_flags disp_flags;
 };
 
 struct mxc_lcdif_data {
-       struct platform_device *pdev;
+       struct device *dev;
        struct mxc_dispdrv_handle *disp_lcdif;
 };
 
@@ -143,8 +147,7 @@ static int lcdif_init(struct mxc_dispdrv_handle *disp,
 {
        int ret, i;
        struct mxc_lcdif_data *lcdif = mxc_dispdrv_getdata(disp);
-       struct mxc_lcd_platform_data *plat_data
-                       = lcdif->pdev->dev.platform_data;
+       struct mxc_lcd_platform_data *plat_data = lcdif->dev->platform_data;
        struct fb_videomode *modedb = lcdif_modedb;
        int modedb_sz = lcdif_modedb_sz;
 
@@ -179,35 +182,47 @@ void lcdif_deinit(struct mxc_dispdrv_handle *disp)
 }
 
 static struct mxc_dispdrv_driver lcdif_drv = {
-       .name   = DISPDRV_LCD,
-       .init   = lcdif_init,
+       .name   = DISPDRV_LCD,
+       .init   = lcdif_init,
        .deinit = lcdif_deinit,
 };
 
-static int lcd_get_of_property(struct platform_device *pdev,
+static int lcd_get_of_property(struct device *dev,
                                struct mxc_lcd_platform_data *plat_data)
 {
-       struct device_node *np = pdev->dev.of_node;
+       struct device_node *np = dev->of_node;
        int err;
        u32 ipu_id, disp_id;
        const char *default_ifmt;
 
        err = of_property_read_string(np, "default_ifmt", &default_ifmt);
        if (err) {
-               dev_err(&pdev->dev, "get of property default_ifmt fail\n");
+               dev_err(dev, "get of property default_ifmt fail\n");
                return err;
        }
        err = of_property_read_u32(np, "ipu_id", &ipu_id);
        if (err) {
-               dev_err(&pdev->dev, "get of property ipu_id fail\n");
+               dev_err(dev, "get of property ipu_id fail\n");
                return err;
        }
        err = of_property_read_u32(np, "disp_id", &disp_id);
        if (err) {
-               dev_err(&pdev->dev, "get of property disp_id fail\n");
+               dev_err(dev, "get of property disp_id fail\n");
                return err;
        }
 
+       {
+               struct videomode vm = { };
+
+               err = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
+               if (err == 0) {
+                       dev_dbg(dev, "Copying videomode from display-timings\n");
+                       fb_videomode_from_videomode(&vm, &lcdif_modedb[0]);
+                       plat_data->disp_flags = vm.flags;
+                       lcdif_modedb_sz = 1;
+               }
+       }
+
        plat_data->ipu_id = ipu_id;
        plat_data->disp_id = disp_id;
        if (!strncmp(default_ifmt, "RGB24", 5))
@@ -233,7 +248,7 @@ static int lcd_get_of_property(struct platform_device *pdev,
        else if (!strncmp(default_ifmt, "VYUY16", 6))
                                plat_data->default_ifmt = IPU_PIX_FMT_VYUY;
        else {
-               dev_err(&pdev->dev, "err default_ifmt!\n");
+               dev_err(dev, "err default_ifmt!\n");
                return -ENOENT;
        }
 
@@ -259,7 +274,7 @@ static int mxc_lcdif_probe(struct platform_device *pdev)
                return -ENOMEM;
        pdev->dev.platform_data = plat_data;
 
-       ret = lcd_get_of_property(pdev, plat_data);
+       ret = lcd_get_of_property(&pdev->dev, plat_data);
        if (ret < 0) {
                dev_err(&pdev->dev, "get lcd of property fail\n");
                return ret;
@@ -271,7 +286,7 @@ static int mxc_lcdif_probe(struct platform_device *pdev)
                return PTR_ERR(pinctrl);
        }
 
-       lcdif->pdev = pdev;
+       lcdif->dev = &pdev->dev;
        lcdif->disp_lcdif = mxc_dispdrv_register(&lcdif_drv);
        mxc_dispdrv_setdata(lcdif->disp_lcdif, lcdif);
 
@@ -283,7 +298,7 @@ static int mxc_lcdif_probe(struct platform_device *pdev)
 
 static int mxc_lcdif_remove(struct platform_device *pdev)
 {
-       struct mxc_lcdif_data *lcdif = dev_get_drvdata(&pdev->dev);
+       struct mxc_lcdif_data *lcdif = platform_get_drvdata(pdev);
 
        mxc_dispdrv_puthandle(lcdif->disp_lcdif);
        mxc_dispdrv_unregister(lcdif->disp_lcdif);