drm/tilcdc: Choose console BPP that supports RGB
authorJyri Sarha <jsarha@ti.com>
Sat, 13 Aug 2016 18:08:20 +0000 (21:08 +0300)
committerJyri Sarha <jsarha@ti.com>
Thu, 1 Sep 2016 19:32:23 +0000 (22:32 +0300)
Choose console BPP that supports RGB and remove the old fbdev bpp
selection code. LCDC on AM335x has red and blue wires switched between
24 bit and 16 bit colors. If 24 format is wired for RGB colors, the 16
bit format is wired for BGR. drm_fbdev_cma_init() does not currently
like anything else but RGB formats, so we must choose such bytes per
pixel value that supports RGB.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/tilcdc/tilcdc_drv.c
drivers/gpu/drm/tilcdc/tilcdc_drv.h
drivers/gpu/drm/tilcdc/tilcdc_external.c
drivers/gpu/drm/tilcdc/tilcdc_external.h
drivers/gpu/drm/tilcdc/tilcdc_panel.c
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c

index f7c3ca858bb80203872f7550ea0efe7ebc5fec9e..f8892e9ad169cee8f20e70e689b1302267318331 100644 (file)
@@ -240,7 +240,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
        struct platform_device *pdev = dev->platformdev;
        struct device_node *node = pdev->dev.of_node;
        struct tilcdc_drm_private *priv;
-       struct tilcdc_module *mod;
        struct resource *res;
        u32 bpp = 0;
        int ret;
@@ -336,6 +335,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
                DBG("Revision 1 LCDC supports only RGB565 format");
                priv->pixelformats = tilcdc_rev1_formats;
                priv->num_pixelformats = ARRAY_SIZE(tilcdc_rev1_formats);
+               bpp = 16;
        } else {
                const char *str = "\0";
 
@@ -345,17 +345,20 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
                        priv->pixelformats = tilcdc_crossed_formats;
                        priv->num_pixelformats =
                                ARRAY_SIZE(tilcdc_crossed_formats);
+                       bpp = 32; /* Choose bpp with RGB support for fbdef */
                } else if (0 == strcmp(str, "straight")) {
                        DBG("Configured for straight blue and red wires");
                        priv->pixelformats = tilcdc_straight_formats;
                        priv->num_pixelformats =
                                ARRAY_SIZE(tilcdc_straight_formats);
+                       bpp = 16; /* Choose bpp with RGB support for fbdef */
                } else {
                        DBG("Blue and red wiring '%s' unknown, use legacy mode",
                            str);
                        priv->pixelformats = tilcdc_legacy_formats;
                        priv->num_pixelformats =
                                ARRAY_SIZE(tilcdc_legacy_formats);
+                       bpp = 16; /* This is just a guess */
                }
        }
 
@@ -372,7 +375,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
                if (ret < 0)
                        goto fail_mode_config_cleanup;
 
-               ret = tilcdc_add_external_encoders(dev, &bpp);
+               ret = tilcdc_add_external_encoders(dev);
                if (ret < 0)
                        goto fail_component_cleanup;
        }
@@ -395,13 +398,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
                goto fail_vblank_cleanup;
        }
 
-       list_for_each_entry(mod, &module_list, list) {
-               DBG("%s: preferred_bpp: %d", mod->name, mod->preferred_bpp);
-               bpp = mod->preferred_bpp;
-               if (bpp > 0)
-                       break;
-       }
-
        drm_mode_config_reset(dev);
 
        priv->fbdev = drm_fbdev_cma_init(dev, bpp,
index 0e19c14003862e41fc489ae97f3000a7f369f500..a6e5e6d4970c8a4a4f3dd1b2217dd2646b184b50 100644 (file)
@@ -116,7 +116,6 @@ struct tilcdc_module {
        const char *name;
        struct list_head list;
        const struct tilcdc_module_ops *funcs;
-       unsigned int preferred_bpp;
 };
 
 void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
index 849b23ebc455d1814e2a41fca493e41957c85019..68e895021005cc62034110748f8f1bf028a2391d 100644 (file)
@@ -52,7 +52,7 @@ static int tilcdc_external_mode_valid(struct drm_connector *connector,
        return MODE_OK;
 }
 
-static int tilcdc_add_external_encoder(struct drm_device *dev, int *bpp,
+static int tilcdc_add_external_encoder(struct drm_device *dev,
                                       struct drm_connector *connector)
 {
        struct tilcdc_drm_private *priv = dev->dev_private;
@@ -64,7 +64,6 @@ static int tilcdc_add_external_encoder(struct drm_device *dev, int *bpp,
        /* Only tda998x is supported at the moment. */
        tilcdc_crtc_set_simulate_vesa_sync(priv->crtc, true);
        tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_tda998x);
-       *bpp = panel_info_tda998x.bpp;
 
        connector_funcs = devm_kzalloc(dev->dev, sizeof(*connector_funcs),
                                       GFP_KERNEL);
@@ -94,7 +93,7 @@ static int tilcdc_add_external_encoder(struct drm_device *dev, int *bpp,
        return 0;
 }
 
-int tilcdc_add_external_encoders(struct drm_device *dev, int *bpp)
+int tilcdc_add_external_encoders(struct drm_device *dev)
 {
        struct tilcdc_drm_private *priv = dev->dev_private;
        struct drm_connector *connector;
@@ -108,7 +107,7 @@ int tilcdc_add_external_encoders(struct drm_device *dev, int *bpp)
                        if (connector == priv->connectors[i])
                                found = true;
                if (!found) {
-                       ret = tilcdc_add_external_encoder(dev, bpp, connector);
+                       ret = tilcdc_add_external_encoder(dev, connector);
                        if (ret)
                                return ret;
                }
index 6aabe2788760f24296cf5d8f5fa2ae6bd9fe0a99..c700e0c1623e41e2e5d2dc07e5c924f323b10770 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __TILCDC_EXTERNAL_H__
 #define __TILCDC_EXTERNAL_H__
 
-int tilcdc_add_external_encoders(struct drm_device *dev, int *bpp);
+int tilcdc_add_external_encoders(struct drm_device *dev);
 void tilcdc_remove_external_encoders(struct drm_device *dev);
 int tilcdc_get_external_components(struct device *dev,
                                   struct component_match **match);
index 4ac1d25eb79b49c14755b96a35e1086f826cd815..7b3650901930ce0607d3db3211ef9a59a1be37aa 100644 (file)
@@ -397,8 +397,6 @@ static int panel_probe(struct platform_device *pdev)
                goto fail_timings;
        }
 
-       mod->preferred_bpp = panel_mod->info->bpp;
-
        return 0;
 
 fail_timings:
index 741c7b5b8302d6b058a927c8ca2a1b683cbfe53c..c6a70da6473dc9f14e413794fb9d58d86f4336c8 100644 (file)
@@ -327,8 +327,6 @@ static int tfp410_probe(struct platform_device *pdev)
                goto fail;
        }
 
-       mod->preferred_bpp = dvi_info.bpp;
-
        i2c_node = of_find_node_by_phandle(i2c_phandle);
        if (!i2c_node) {
                dev_err(&pdev->dev, "could not get i2c bus node\n");