aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/tilcdc
diff options
context:
space:
mode:
authorJyri Sarha <jsarha@ti.com>2016-08-11 12:09:43 -0400
committerJyri Sarha <jsarha@ti.com>2016-09-01 15:32:11 -0400
commitbcc5a6f5fc9f0d53aa896768d6f86d7e64d0b783 (patch)
treed0c7baa4215b436456cae33d0550c5bb46db9019 /drivers/gpu/drm/tilcdc
parent7eb9f069ff5dd39d44d7ecdf63eb99b429c7dad0 (diff)
drm/tilcdc: Add blue-and-red-crossed devicetree property
Add "blue-and-red-wiring"-device tree property and update devicetree binding document. The red and blue components are reversed between 24 and 16 bit modes on am335x LCDC output pins. To get 24 RGB format the red and blue wires has to be crossed and this in turn causes 16 colors output to be in BGR format. With straight wiring the 16 color is RGB and 24 bit is BGR. The new property describes whether the red and blue wires are crossed or not. If the property is not present or its value is not recognized the legacy mode is assumed. The legacy configuration supports RGB565, RGB888 and XRGB8888 formats. However, depending on wiring, the red and blue colors are swapped in either 16 or 24-bit color modes. For more details see section 3.1.1 in AM335x Silicon Errata: http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sprz360 Signed-off-by: Jyri Sarha <jsarha@ti.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/gpu/drm/tilcdc')
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_drv.c41
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_drv.h4
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_plane.c9
3 files changed, 48 insertions, 6 deletions
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 1f29a9314d11..f7c3ca858bb8 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -33,6 +33,20 @@
33 33
34static LIST_HEAD(module_list); 34static LIST_HEAD(module_list);
35 35
36static const u32 tilcdc_rev1_formats[] = { DRM_FORMAT_RGB565 };
37
38static const u32 tilcdc_straight_formats[] = { DRM_FORMAT_RGB565,
39 DRM_FORMAT_BGR888,
40 DRM_FORMAT_XBGR8888 };
41
42static const u32 tilcdc_crossed_formats[] = { DRM_FORMAT_BGR565,
43 DRM_FORMAT_RGB888,
44 DRM_FORMAT_XRGB8888 };
45
46static const u32 tilcdc_legacy_formats[] = { DRM_FORMAT_RGB565,
47 DRM_FORMAT_RGB888,
48 DRM_FORMAT_XRGB8888 };
49
36void tilcdc_module_init(struct tilcdc_module *mod, const char *name, 50void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
37 const struct tilcdc_module_ops *funcs) 51 const struct tilcdc_module_ops *funcs)
38{ 52{
@@ -318,6 +332,33 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
318 332
319 pm_runtime_put_sync(dev->dev); 333 pm_runtime_put_sync(dev->dev);
320 334
335 if (priv->rev == 1) {
336 DBG("Revision 1 LCDC supports only RGB565 format");
337 priv->pixelformats = tilcdc_rev1_formats;
338 priv->num_pixelformats = ARRAY_SIZE(tilcdc_rev1_formats);
339 } else {
340 const char *str = "\0";
341
342 of_property_read_string(node, "blue-and-red-wiring", &str);
343 if (0 == strcmp(str, "crossed")) {
344 DBG("Configured for crossed blue and red wires");
345 priv->pixelformats = tilcdc_crossed_formats;
346 priv->num_pixelformats =
347 ARRAY_SIZE(tilcdc_crossed_formats);
348 } else if (0 == strcmp(str, "straight")) {
349 DBG("Configured for straight blue and red wires");
350 priv->pixelformats = tilcdc_straight_formats;
351 priv->num_pixelformats =
352 ARRAY_SIZE(tilcdc_straight_formats);
353 } else {
354 DBG("Blue and red wiring '%s' unknown, use legacy mode",
355 str);
356 priv->pixelformats = tilcdc_legacy_formats;
357 priv->num_pixelformats =
358 ARRAY_SIZE(tilcdc_legacy_formats);
359 }
360 }
361
321 ret = modeset_init(dev); 362 ret = modeset_init(dev);
322 if (ret < 0) { 363 if (ret < 0) {
323 dev_err(dev->dev, "failed to initialize mode setting\n"); 364 dev_err(dev->dev, "failed to initialize mode setting\n");
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 13001df7dbe8..0e19c1400386 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -65,6 +65,10 @@ struct tilcdc_drm_private {
65 */ 65 */
66 uint32_t max_width; 66 uint32_t max_width;
67 67
68 /* Supported pixel formats */
69 const uint32_t *pixelformats;
70 uint32_t num_pixelformats;
71
68 /* The context for pm susped/resume cycle is stored here */ 72 /* The context for pm susped/resume cycle is stored here */
69 struct drm_atomic_state *saved_state; 73 struct drm_atomic_state *saved_state;
70 74
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index 41911e3110e8..74c65fa859b2 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -24,10 +24,6 @@
24 24
25#include "tilcdc_drv.h" 25#include "tilcdc_drv.h"
26 26
27static const u32 tilcdc_formats[] = { DRM_FORMAT_RGB565,
28 DRM_FORMAT_RGB888,
29 DRM_FORMAT_XRGB8888 };
30
31static struct drm_plane_funcs tilcdc_plane_funcs = { 27static struct drm_plane_funcs tilcdc_plane_funcs = {
32 .update_plane = drm_atomic_helper_update_plane, 28 .update_plane = drm_atomic_helper_update_plane,
33 .disable_plane = drm_atomic_helper_disable_plane, 29 .disable_plane = drm_atomic_helper_disable_plane,
@@ -114,12 +110,13 @@ static const struct drm_plane_helper_funcs plane_helper_funcs = {
114int tilcdc_plane_init(struct drm_device *dev, 110int tilcdc_plane_init(struct drm_device *dev,
115 struct drm_plane *plane) 111 struct drm_plane *plane)
116{ 112{
113 struct tilcdc_drm_private *priv = dev->dev_private;
117 int ret; 114 int ret;
118 115
119 ret = drm_plane_init(dev, plane, 1, 116 ret = drm_plane_init(dev, plane, 1,
120 &tilcdc_plane_funcs, 117 &tilcdc_plane_funcs,
121 tilcdc_formats, 118 priv->pixelformats,
122 ARRAY_SIZE(tilcdc_formats), 119 priv->num_pixelformats,
123 true); 120 true);
124 if (ret) { 121 if (ret) {
125 dev_err(dev->dev, "Failed to initialize plane: %d\n", ret); 122 dev_err(dev->dev, "Failed to initialize plane: %d\n", ret);