video: mxc: search for display-timings in the mxcfb node, rather than ldb or mxc_lcdif
authorLothar Waßmann <LW@KARO-electronics.de>
Thu, 26 Feb 2015 10:57:01 +0000 (11:57 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 27 Feb 2015 08:19:18 +0000 (09:19 +0100)
The display-timings should be configurable for each individual display
port, rather than for the LCD or LDB interface in general.

Move the of_get_videomode() call to mxcfb_dispdrv_init() which is
called for each display port.

arch/arm/boot/dts/imx6dl-tx6dl-comtft.dts
arch/arm/boot/dts/imx6q-tx6q-1020-comtft.dts
arch/arm/boot/dts/imx6q-tx6q-1020.dts
drivers/video/mxc/ldb.c
drivers/video/mxc/mxc_dispdrv.h
drivers/video/mxc/mxc_ipuv3_fb.c
drivers/video/mxc/mxc_lcdif.c

index aea4834..1604a57 100644 (file)
@@ -18,8 +18,8 @@
        compatible = "karo,imx6dl-tx6dl", "fsl,imx6dl";
 
        aliases {
-               display = &lcd;
-               mxcfb0 = &display;
+               display = &mxcfb0;
+               mxcfb0 = &mxcfb0;
        };
 
        backlight: backlight {
@@ -44,7 +44,7 @@
                default-brightness-level = <50>;
        };
 
-       display: fb@2 {
+       mxcfb0: fb@2 {
                compatible = "fsl,mxc_sdc_fb";
                disp_dev = "lcd";
                interface_pix_fmt = "RGB24";
                int_clk = <1>;
                late_init = <0>;
                status = "okay";
-       };
-
-       lcd: lcd@0 {
-               compatible = "fsl,lcd";
-               ipu_id = <0>;
-               disp_id = <0>;
-               default_ifmt = "RGB24";
-               pinctrl-names = "default";
-               pinctrl-0 = <&pinctrl_disp0_2>;
-               status = "okay";
 
                display-timings {
                        native-mode = <&ET070001DM6>;
                        };
                };
        };
+
+       lcd: lcd@0 {
+               compatible = "fsl,lcd";
+               ipu_id = <0>;
+               disp_id = <0>;
+               default_ifmt = "RGB24";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_disp0_2>;
+               status = "okay";
+       };
 };
 
 &can1 {
index 44f3cc8..6116140 100644 (file)
@@ -18,8 +18,8 @@
        compatible = "karo,imx6q-tx6q", "fsl,imx6q";
 
        aliases {
-               display = &lcd;
-               mxcfb0 = &display;
+               display = &mxcfb0;
+               mxcfb0 = &mxcfb0;
        };
 
        backlight: backlight {
@@ -44,7 +44,7 @@
                default-brightness-level = <50>;
        };
 
-       display: fb@2 {
+       mxcfb0: fb@2 {
                compatible = "fsl,mxc_sdc_fb";
                disp_dev = "lcd";
                interface_pix_fmt = "RGB24";
                int_clk = <1>;
                late_init = <0>;
                status = "okay";
-       };
-
-       lcd: lcd@0 {
-               compatible = "fsl,lcd";
-               ipu_id = <0>;
-               disp_id = <0>;
-               default_ifmt = "RGB24";
-               pinctrl-names = "default";
-               pinctrl-0 = <&pinctrl_disp0_2>;
-               status = "okay";
 
                display-timings {
                        native-mode = <&ET070001DM6>;
                        };
                };
        };
+
+       lcd: lcd@0 {
+               compatible = "fsl,lcd";
+               ipu_id = <0>;
+               disp_id = <0>;
+               default_ifmt = "RGB24";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_disp0_2>;
+               status = "okay";
+       };
 };
 
 &can1 {
index 6c62f0c..fa3a825 100644 (file)
@@ -18,8 +18,8 @@
        compatible = "karo,imx6q-tx6q", "fsl,imx6q";
 
        aliases {
-               display = &lcd;
-               mxcfb0 = &display;
+               display = &mxcfb0;
+               mxcfb0 = &mxcfb0;
        };
 
        backlight: backlight {
@@ -44,7 +44,7 @@
                default-brightness-level = <50>;
        };
 
-       display: fb@2 {
+       mxcfb0: fb@2 {
                compatible = "fsl,mxc_sdc_fb";
                disp_dev = "lcd";
                interface_pix_fmt = "RGB24";
                int_clk = <1>;
                late_init = <0>;
                status = "okay";
-       };
-
-       lcd: lcd@0 {
-               compatible = "fsl,lcd";
-               ipu_id = <0>;
-               disp_id = <0>;
-               default_ifmt = "RGB24";
-               pinctrl-names = "default";
-               pinctrl-0 = <&pinctrl_disp0_2>;
-               status = "okay";
 
                display-timings {
                        VGA {
                        };
                };
        };
+
+       lcd: lcd@0 {
+               compatible = "fsl,lcd";
+               ipu_id = <0>;
+               disp_id = <0>;
+               default_ifmt = "RGB24";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_disp0_2>;
+               status = "okay";
+       };
 };
 
 &ds1339 {
index 6616e53..6d59442 100644 (file)
@@ -291,16 +291,6 @@ static int ldb_get_of_property(struct platform_device *pdev,
                return err;
        }
 
-       if (of_display_timings_exist(np) == 1) {
-               struct videomode vm = { };
-
-               err = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
-               if (err == 0) {
-                       fb_videomode_from_videomode(&vm, &ldb_modedb[0]);
-                       ldb_modedb_sz = 1;
-               }
-       }
-
        plat_data->mode = parse_ldb_mode(mode);
        plat_data->ext_ref = ext_ref;
        plat_data->ipu_id = ipu_id;
@@ -826,6 +816,11 @@ static int ldb_disp_init(struct mxc_dispdrv_handle *disp,
        if (is_imx6_ldb(plat_data))
                ldb_ipu_ldb_route(setting->dev_id, setting->disp_id, ldb);
 
+       if (setting->fbmode) {
+               ldb_modedb[0] = *setting->fbmode;
+               ldb_modedb_sz = 1;
+       }
+
        /* must use spec video mode defined by driver */
        ret = fb_find_mode(&setting->fbi->var, setting->fbi, setting->dft_mode_str,
                                ldb_modedb, ldb_modedb_sz, NULL, setting->default_bpp);
index 8c8877c..cdea912 100644 (file)
@@ -30,6 +30,8 @@ struct mxc_dispdrv_setting {
        int dev_id;
        int disp_id;
        enum display_flags disp_flags;
+
+       struct fb_videomode *fbmode;
 };
 
 struct mxc_dispdrv_driver {
index a854099..d4cdeb2 100644 (file)
@@ -48,7 +48,9 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/uaccess.h>
-
+#include <video/of_display_timing.h>
+#include <video/of_videomode.h>
+#include <video/videomode.h>
 #include "mxc_dispdrv.h"
 
 /*
@@ -1893,7 +1895,8 @@ static int mxcfb_dispdrv_init(struct platform_device *pdev,
                struct fb_info *fbi)
 {
        struct ipuv3_fb_platform_data *plat_data = pdev->dev.platform_data;
-       struct mxcfb_info *mxcfbi = (struct mxcfb_info *)fbi->par;
+       struct device_node *np = pdev->dev.of_node;
+       struct mxcfb_info *mxcfbi = fbi->par;
        struct mxc_dispdrv_setting setting = {};
        char disp_dev[32], *default_dev = "lcd";
        int ret = 0;
@@ -1909,6 +1912,21 @@ static int mxcfb_dispdrv_init(struct platform_device *pdev,
        else
                strlcpy(disp_dev, plat_data->disp_dev, sizeof(disp_dev));
 
+       if (of_display_timings_exist(np) == 1) {
+               struct videomode vm = { };
+
+               setting.fbmode = kzalloc(sizeof(*setting.fbmode), GFP_KERNEL);
+               if (setting.fbmode == NULL)
+                       return -ENOMEM;
+
+               ret = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
+               if (ret)
+                       goto err;
+
+               fb_videomode_from_videomode(&vm, setting.fbmode);
+               setting.disp_flags = vm.flags;
+               dev_dbg(&pdev->dev, "using video mode from DTB\n");
+       }
 
        dev_info(&pdev->dev, "register mxc display driver %s\n", disp_dev);
 
@@ -1916,7 +1934,7 @@ static int mxcfb_dispdrv_init(struct platform_device *pdev,
        if (IS_ERR(mxcfbi->dispdrv)) {
                ret = PTR_ERR(mxcfbi->dispdrv);
                dev_err(&pdev->dev, "NO mxc display driver found!\n");
-               return ret;
+               goto err;
        } else {
                /* fix-up  */
                mxcfbi->ipu_di_pix_fmt = setting.if_fmt;
@@ -1931,13 +1949,15 @@ static int mxcfb_dispdrv_init(struct platform_device *pdev,
                                setting.disp_id, setting.dev_id);
        }
 
+err:
+       kfree(setting.fbmode);
        return ret;
 }
 
 /*
  * Parse user specified options (`video=trident:')
  * example:
- *     video=mxcfb0:dev=lcd,800x480M-16@55,if=RGB565,bpp=16,noaccel
+ *     video=mxcfb0:dev=lcd,800x480M-16@55,if=RGB565,bpp=16,noaccel
  *     video=mxcfb0:dev=lcd,800x480M-16@55,if=RGB565,fbpix=RGB565
  */
 static int mxcfb_option_setup(struct platform_device *pdev, struct fb_info *fbi)
index d729d19..6c1b3c9 100644 (file)
@@ -154,7 +154,13 @@ static int lcdif_init(struct mxc_dispdrv_handle *disp,
        /* use platform defined ipu/di */
        setting->dev_id = plat_data->ipu_id;
        setting->disp_id = plat_data->disp_id;
-       setting->disp_flags = plat_data->disp_flags;
+
+       if (setting->fbmode) {
+               modedb[0] = *setting->fbmode;
+               modedb_sz = 1;
+       } else {
+               setting->disp_flags = plat_data->disp_flags;
+       }
 
        ret = fb_find_mode(&setting->fbi->var, setting->fbi, setting->dft_mode_str,
                                modedb, modedb_sz, NULL, setting->default_bpp);
@@ -212,18 +218,6 @@ static int lcd_get_of_property(struct device *dev,
                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))