0008-drm-omap-panel-dsi-cm-fix-driver.patch (3500B)
1 From 328a31aeb9e4cb56f312be7722010ede59ef96be Mon Sep 17 00:00:00 2001 2 From: Tony Lindgren <tony@atomide.com> 3 Date: Mon, 24 Jul 2017 19:33:05 +0200 4 Subject: [PATCH 08/17] drm/omap: panel-dsi-cm: fix driver 5 6 This adds support for get_timings() and check_timings() 7 to get the driver working and properly initializes the 8 timing information from DT. 9 10 Signed-off-by: Tony Lindgren <tony@atomide.com> 11 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> 12 --- 13 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 56 ++++++++++++++++++++++--- 14 1 file changed, 51 insertions(+), 5 deletions(-) 15 16 diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 17 index 92c556a..905b717 100644 18 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 19 +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 20 @@ -25,6 +25,7 @@ 21 #include <linux/of_gpio.h> 22 23 #include <video/mipi_display.h> 24 +#include <video/of_display_timing.h> 25 26 #include "../dss/omapdss.h" 27 28 @@ -1099,6 +1100,36 @@ static void dsicm_ulps_work(struct work_struct *work) 29 mutex_unlock(&ddata->lock); 30 } 31 32 +static void dsicm_get_timings(struct omap_dss_device *dssdev, 33 + struct videomode *vm) 34 +{ 35 + struct panel_drv_data *ddata = to_panel_data(dssdev); 36 + 37 + *vm = ddata->vm; 38 +} 39 + 40 +static int dsicm_check_timings(struct omap_dss_device *dssdev, 41 + struct videomode *vm) 42 +{ 43 + struct panel_drv_data *ddata = to_panel_data(dssdev); 44 + int ret = 0; 45 + 46 + if (vm->hactive != ddata->vm.hactive) 47 + ret = -EINVAL; 48 + 49 + if (vm->vactive != ddata->vm.vactive) 50 + ret = -EINVAL; 51 + 52 + if (ret) { 53 + dev_warn(dssdev->dev, "wrong resolution: %d x %d", 54 + vm->hactive, vm->vactive); 55 + dev_warn(dssdev->dev, "panel resolution: %d x %d", 56 + ddata->vm.hactive, ddata->vm.vactive); 57 + } 58 + 59 + return ret; 60 +} 61 + 62 static struct omap_dss_driver dsicm_ops = { 63 .connect = dsicm_connect, 64 .disconnect = dsicm_disconnect, 65 @@ -1109,6 +1140,9 @@ static struct omap_dss_driver dsicm_ops = { 66 .update = dsicm_update, 67 .sync = dsicm_sync, 68 69 + .get_timings = dsicm_get_timings, 70 + .check_timings = dsicm_check_timings, 71 + 72 .enable_te = dsicm_enable_te, 73 .get_te = dsicm_get_te, 74 75 @@ -1120,7 +1154,8 @@ static int dsicm_probe_of(struct platform_device *pdev) 76 struct device_node *node = pdev->dev.of_node; 77 struct panel_drv_data *ddata = platform_get_drvdata(pdev); 78 struct omap_dss_device *in; 79 - int gpio; 80 + struct display_timing timing; 81 + int gpio, err; 82 83 gpio = of_get_named_gpio(node, "reset-gpios", 0); 84 if (!gpio_is_valid(gpio)) { 85 @@ -1137,6 +1172,17 @@ static int dsicm_probe_of(struct platform_device *pdev) 86 return gpio; 87 } 88 89 + err = of_get_display_timing(node, "panel-timing", &timing); 90 + if (!err) { 91 + videomode_from_timing(&timing, &ddata->vm); 92 + if (!ddata->vm.pixelclock) 93 + ddata->vm.pixelclock = 94 + ddata->vm.hactive * ddata->vm.vactive * 60; 95 + } else { 96 + dev_warn(&pdev->dev, 97 + "failed to get video timing, using defaults\n"); 98 + } 99 + 100 in = omapdss_of_find_source_for_first_ep(node); 101 if (IS_ERR(in)) { 102 dev_err(&pdev->dev, "failed to find video source\n"); 103 @@ -1171,14 +1217,14 @@ static int dsicm_probe(struct platform_device *pdev) 104 if (!pdev->dev.of_node) 105 return -ENODEV; 106 107 - r = dsicm_probe_of(pdev); 108 - if (r) 109 - return r; 110 - 111 ddata->vm.hactive = 864; 112 ddata->vm.vactive = 480; 113 ddata->vm.pixelclock = 864 * 480 * 60; 114 115 + r = dsicm_probe_of(pdev); 116 + if (r) 117 + return r; 118 + 119 dssdev = &ddata->dssdev; 120 dssdev->dev = dev; 121 dssdev->driver = &dsicm_ops; 122 -- 123 2.1.4 124