[PATCH v3 56/56] drm/omap: remove dss_mgr_ops

2020-11-05 Thread Tomi Valkeinen
dss_mgr_ops was needed with the multi-module architecture, but is no
longer needed. We can thus remove it and use direct calls.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dss.h |  1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 42 +++
 drivers/gpu/drm/omapdrm/dss/output.c  | 33 +
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 38 +---
 drivers/gpu/drm/omapdrm/omap_crtc.h   |  2 --
 drivers/gpu/drm/omapdrm/omap_drv.c|  4 +--
 6 files changed, 33 insertions(+), 87 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 96f702314c8c..a547527bb2f3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -257,7 +257,6 @@ struct dss_device {
struct dss_pll  *video2_pll;
 
struct dispc_device *dispc;
-   const struct dss_mgr_ops *mgr_ops;
struct omap_drm_private *mgr_ops_priv;
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index fba5f05e5e48..9df322ca467d 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -338,31 +338,23 @@ enum dss_writeback_channel {
DSS_WB_LCD3_MGR =   7,
 };
 
-struct dss_mgr_ops {
-   void (*start_update)(struct omap_drm_private *priv,
-enum omap_channel channel);
-   int (*enable)(struct omap_drm_private *priv,
- enum omap_channel channel);
-   void (*disable)(struct omap_drm_private *priv,
-   enum omap_channel channel);
-   void (*set_timings)(struct omap_drm_private *priv,
-   enum omap_channel channel,
-   const struct videomode *vm);
-   void (*set_lcd_config)(struct omap_drm_private *priv,
-  enum omap_channel channel,
-  const struct dss_lcd_mgr_config *config);
-   int (*register_framedone_handler)(struct omap_drm_private *priv,
-   enum omap_channel channel,
-   void (*handler)(void *), void *data);
-   void (*unregister_framedone_handler)(struct omap_drm_private *priv,
-   enum omap_channel channel,
-   void (*handler)(void *), void *data);
-};
-
-int dss_install_mgr_ops(struct dss_device *dss,
-   const struct dss_mgr_ops *mgr_ops,
-   struct omap_drm_private *priv);
-void dss_uninstall_mgr_ops(struct dss_device *dss);
+void omap_crtc_dss_start_update(struct omap_drm_private *priv,
+  enum omap_channel channel);
+void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable);
+int omap_crtc_dss_enable(struct omap_drm_private *priv, enum omap_channel 
channel);
+void omap_crtc_dss_disable(struct omap_drm_private *priv, enum omap_channel 
channel);
+void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
+   enum omap_channel channel,
+   const struct videomode *vm);
+void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
+   enum omap_channel channel,
+   const struct dss_lcd_mgr_config *config);
+int omap_crtc_dss_register_framedone(
+   struct omap_drm_private *priv, enum omap_channel channel,
+   void (*handler)(void *), void *data);
+void omap_crtc_dss_unregister_framedone(
+   struct omap_drm_private *priv, enum omap_channel channel,
+   void (*handler)(void *), void *data);
 
 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
const struct videomode *vm);
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index 7a14d2b5b2f7..2121c947947b 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -81,54 +81,35 @@ void omapdss_device_cleanup_output(struct omap_dss_device 
*out)
out->next_bridge : out->bridge);
 }
 
-int dss_install_mgr_ops(struct dss_device *dss,
-   const struct dss_mgr_ops *mgr_ops,
-   struct omap_drm_private *priv)
-{
-   if (dss->mgr_ops)
-   return -EBUSY;
-
-   dss->mgr_ops = mgr_ops;
-   dss->mgr_ops_priv = priv;
-
-   return 0;
-}
-
-void dss_uninstall_mgr_ops(struct dss_device *dss)
-{
-   dss->mgr_ops = NULL;
-   dss->mgr_ops_priv = NULL;
-}
-
 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
 const struct videomode *vm)
 {
-   dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv,
+   omap_crtc_dss_set_timings(dssdev->dss->mgr_ops_priv,
  dssdev->dispc_channel, vm);
 }
 
 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
  

[PATCH v3 53/56] drm/omap: remove unused display.c

2020-11-05 Thread Tomi Valkeinen
The functions in display.c are not used, so drop the file.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/Makefile  |  2 +-
 drivers/gpu/drm/omapdrm/dss/display.c | 58 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 --
 3 files changed, 1 insertion(+), 63 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/display.c

diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index 33fe7e937680..21e8277ff88f 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -18,7 +18,7 @@ omapdrm-y := omap_drv.o \
 
 omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
 
-omapdrm-y += dss/base.o dss/display.o dss/output.o dss/dss.o dss/dispc.o \
+omapdrm-y += dss/base.o dss/output.o dss/dss.o dss/dispc.o \
dss/dispc_coefs.o dss/pll.o dss/video-pll.o
 omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
 omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
deleted file mode 100644
index 7b7ee2019eae..
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ /dev/null
@@ -1,58 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2009 Nokia Corporation
- * Author: Tomi Valkeinen 
- *
- * Some code and ideas taken from drivers/video/omap/ driver
- * by Imre Deak.
- */
-
-#define DSS_SUBSYS_NAME "DISPLAY"
-
-#include 
-#include 
-
-#include 
-#include 
-
-#include "omapdss.h"
-
-static int disp_num_counter;
-
-void omapdss_display_init(struct omap_dss_device *dssdev)
-{
-   int id;
-
-   /*
-* Note: this presumes that all displays either have an DT alias, or
-* none has.
-*/
-   id = of_alias_get_id(dssdev->dev->of_node, "display");
-   if (id < 0)
-   id = disp_num_counter++;
-
-   /* Use 'label' property for name, if it exists */
-   of_property_read_string(dssdev->dev->of_node, "label", &dssdev->name);
-
-   if (dssdev->name == NULL)
-   dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
- "display%u", id);
-}
-
-int omapdss_display_get_modes(struct drm_connector *connector,
- const struct videomode *vm)
-{
-   struct drm_display_mode *mode;
-
-   mode = drm_mode_create(connector->dev);
-   if (!mode)
-   return 0;
-
-   drm_display_mode_from_videomode(vm, mode);
-
-   mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
-   drm_mode_set_name(mode);
-   drm_mode_probed_add(connector, mode);
-
-   return 1;
-}
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 4e7ae164de4f..90e41c635e45 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -300,10 +300,6 @@ struct dss_pdata {
struct dss_device *dss;
 };
 
-void omapdss_display_init(struct omap_dss_device *dssdev);
-int omapdss_display_get_modes(struct drm_connector *connector,
- const struct videomode *vm);
-
 void omapdss_device_register(struct omap_dss_device *dssdev);
 void omapdss_device_unregister(struct omap_dss_device *dssdev);
 struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 35/56] drm/omap: dsi: implement check timings

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Implement check timings, which will check if its possible to
configure the clocks for the provided mode using the same code
as the set_config() hook.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 70 +++
 1 file changed, 44 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a1a867a7d91d..f643321434e9 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -280,6 +280,11 @@ struct dsi_isr_tables {
struct dsi_isr_data isr_table_cio[DSI_MAX_NR_ISRS];
 };
 
+struct dsi_lp_clock_info {
+   unsigned long lp_clk;
+   u16 lp_clk_div;
+};
+
 struct dsi_clk_calc_ctx {
struct dsi_data *dsi;
struct dss_pll *pll;
@@ -294,16 +299,12 @@ struct dsi_clk_calc_ctx {
 
struct dss_pll_clock_info dsi_cinfo;
struct dispc_clock_info dispc_cinfo;
+   struct dsi_lp_clock_info user_lp_cinfo;
 
struct videomode vm;
struct omap_dss_dsi_videomode_timings dsi_vm;
 };
 
-struct dsi_lp_clock_info {
-   unsigned long lp_clk;
-   u16 lp_clk_div;
-};
-
 struct dsi_module_id_data {
u32 address;
int id;
@@ -4789,44 +4790,55 @@ static bool dsi_is_video_mode(struct omap_dss_device 
*dssdev)
return (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE);
 }
 
-static int dsi_set_config(struct omap_dss_device *dssdev,
-   const struct drm_display_mode *mode)
+static int __dsi_calc_config(struct dsi_data *dsi,
+   const struct drm_display_mode *mode,
+   struct dsi_clk_calc_ctx *ctx)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-   struct dsi_clk_calc_ctx ctx;
-   struct videomode vm;
struct omap_dss_dsi_config cfg = dsi->config;
+   struct videomode vm;
bool ok;
int r;
 
drm_display_mode_to_videomode(mode, &vm);
-   cfg.vm = &vm;
-
-   mutex_lock(&dsi->lock);
 
+   cfg.vm = &vm;
cfg.mode = dsi->mode;
cfg.pixel_format = dsi->pix_fmt;
 
if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
-   ok = dsi_vm_calc(dsi, &cfg, &ctx);
+   ok = dsi_vm_calc(dsi, &cfg, ctx);
else
-   ok = dsi_cm_calc(dsi, &cfg, &ctx);
+   ok = dsi_cm_calc(dsi, &cfg, ctx);
 
-   if (!ok) {
-   DSSERR("failed to find suitable DSI clock settings\n");
-   r = -EINVAL;
-   goto err;
-   }
+   if (!ok)
+   return -EINVAL;
+
+   dsi_pll_calc_dsi_fck(dsi, &ctx->dsi_cinfo);
 
-   dsi_pll_calc_dsi_fck(dsi, &ctx.dsi_cinfo);
+   r = dsi_lp_clock_calc(ctx->dsi_cinfo.clkout[HSDIV_DSI],
+   cfg.lp_clk_min, cfg.lp_clk_max, &ctx->user_lp_cinfo);
+   if (r)
+   return r;
+
+   return 0;
+}
 
-   r = dsi_lp_clock_calc(ctx.dsi_cinfo.clkout[HSDIV_DSI],
-   cfg.lp_clk_min, cfg.lp_clk_max, &dsi->user_lp_cinfo);
+static int dsi_set_config(struct omap_dss_device *dssdev,
+   const struct drm_display_mode *mode)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+   struct dsi_clk_calc_ctx ctx;
+   int r;
+
+   mutex_lock(&dsi->lock);
+
+   r = __dsi_calc_config(dsi, mode, &ctx);
if (r) {
-   DSSERR("failed to find suitable DSI LP clock settings\n");
+   DSSERR("failed to find suitable DSI clock settings\n");
goto err;
}
 
+   dsi->user_lp_cinfo = ctx.user_lp_cinfo;
dsi->user_dsi_cinfo = ctx.dsi_cinfo;
dsi->user_dispc_cinfo = ctx.dispc_cinfo;
 
@@ -5004,11 +5016,17 @@ static void dsi_set_timings(struct omap_dss_device 
*dssdev,
 static int dsi_check_timings(struct omap_dss_device *dssdev,
 struct drm_display_mode *mode)
 {
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+   struct dsi_clk_calc_ctx ctx;
+   int r;
+
DSSDBG("dsi_check_timings\n");
 
-   /* TODO */
+   mutex_lock(&dsi->lock);
+   r = __dsi_calc_config(dsi, mode, &ctx);
+   mutex_unlock(&dsi->lock);
 
-   return 0;
+   return r;
 }
 
 static int dsi_connect(struct omap_dss_device *src,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 30/56] drm/omap: dsi: move panel refresh function to host

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This moves the panel refresh/update function from the panel
driver into the DSI host driver to prepare for common drm_panel
support.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  68 
 drivers/gpu/drm/omapdrm/dss/dsi.c | 101 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  13 +--
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  11 +-
 4 files changed, 97 insertions(+), 96 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 030a8fa140db..1582960f9e90 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -177,27 +177,6 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 
*id1, u8 *id2, u8 *id3)
return 0;
 }
 
-static int dsicm_set_update_window(struct panel_drv_data *ddata,
-   u16 x, u16 y, u16 w, u16 h)
-{
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   int r;
-   u16 x1 = x;
-   u16 x2 = x + w - 1;
-   u16 y1 = y;
-   u16 y2 = y + h - 1;
-
-   r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
-   if (r < 0)
-   return r;
-
-   r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
-   if (r < 0)
-   return r;
-
-   return 0;
-}
-
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
@@ -470,48 +449,6 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
mutex_unlock(&ddata->lock);
 }
 
-static void dsicm_framedone_cb(int err, void *data)
-{
-   struct panel_drv_data *ddata = data;
-
-   dev_dbg(&ddata->dsi->dev, "framedone, err %d\n", err);
-   mutex_unlock(&ddata->lock);
-}
-
-static int dsicm_update(struct omap_dss_device *dssdev,
-   u16 x, u16 y, u16 w, u16 h)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
-   int r;
-
-   dev_dbg(&ddata->dsi->dev, "update %d, %d, %d x %d\n", x, y, w, h);
-
-   mutex_lock(&ddata->lock);
-
-   if (!ddata->enabled) {
-   r = 0;
-   goto err;
-   }
-
-   /* XXX no need to send this every frame, but dsi break if not done */
-   r = dsicm_set_update_window(ddata, 0, 0, ddata->vm.hactive,
-   ddata->vm.vactive);
-   if (r)
-   goto err;
-
-   r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
-   ddata);
-   if (r)
-   goto err;
-
-   /* note: no unlock here. unlock is src framedone_cb */
-   return 0;
-err:
-   mutex_unlock(&ddata->lock);
-   return r;
-}
-
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
struct mipi_dsi_device *dsi = ddata->dsi;
@@ -572,10 +509,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
.check_timings  = dsicm_check_timings,
 };
 
-static const struct omap_dss_driver dsicm_dss_driver = {
-   .update = dsicm_update,
-};
-
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 {
struct device_node *node = dsi->dev.of_node;
@@ -658,7 +591,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
dssdev = &ddata->dssdev;
dssdev->dev = dev;
dssdev->ops = &dsicm_ops;
-   dssdev->driver = &dsicm_dss_driver;
dssdev->type = OMAP_DISPLAY_TYPE_DSI;
dssdev->display = true;
dssdev->owner = THIS_MODULE;
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 0f264654792d..0aa0d21cf896 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -214,6 +214,9 @@ static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
 
+static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
+  const struct mipi_dsi_msg *msg);
+
 /* DSI PLL HSDIV indices */
 #define HSDIV_DISPC0
 #define HSDIV_DSI  1
@@ -383,9 +386,6 @@ struct dsi_data {
 
struct delayed_work ulps_work;
 
-   void (*framedone_callback)(int, void *);
-   void *framedone_data;
-
struct delayed_work framedone_timeout_work;
 
 #ifdef DSI_CATCH_MISSING_TE
@@ -3802,8 +3802,6 @@ static void dsi_handle_framedone(struct dsi_data *dsi, 
int error)
dsi_set_ulps_auto(dsi, true);
dsi_bus_unlock(dsi);
 
-   dsi->framedone_callback(error, dsi->framedone_data);
-
if (!error)
dsi_perf_show(dsi, "DISPC");
 }
@@ -3835,6 +3833,8 @@ static void dsi_framed

[PATCH v3 27/56] drm/omap: dsi: do bus locking in host driver

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This moves the bus locking into the host driver and unexports
the custom API in preparation for drm_panel support.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 46 +--
 drivers/gpu/drm/omapdrm/dss/dsi.c | 33 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 --
 3 files changed, 23 insertions(+), 59 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index dc2c045cc6b0..4be0c9dbcc43 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -298,7 +298,6 @@ static int dsicm_wake_up(struct panel_drv_data *ddata)
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
-   struct omap_dss_device *src = ddata->src;
int r = 0;
int level;
 
@@ -313,15 +312,11 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
mutex_lock(&ddata->lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_wake_up(ddata);
if (!r) {
r = dsicm_dcs_write_1(ddata,
MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
}
-
-   src->ops->dsi.bus_unlock(src);
}
 
mutex_unlock(&ddata->lock);
@@ -347,21 +342,16 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
-   struct omap_dss_device *src = ddata->src;
u8 errors = 0;
int r;
 
mutex_lock(&ddata->lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_wake_up(ddata);
if (!r)
r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
&errors);
-
-   src->ops->dsi.bus_unlock(src);
} else {
r = -ENODEV;
}
@@ -378,20 +368,15 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
-   struct omap_dss_device *src = ddata->src;
u8 id1, id2, id3;
int r;
 
mutex_lock(&ddata->lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_wake_up(ddata);
if (!r)
r = dsicm_get_id(ddata, &id1, &id2, &id3);
-
-   src->ops->dsi.bus_unlock(src);
} else {
r = -ENODEV;
}
@@ -409,7 +394,6 @@ static ssize_t dsicm_store_ulps(struct device *dev,
const char *buf, size_t count)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
-   struct omap_dss_device *src = ddata->src;
unsigned long t;
int r;
 
@@ -420,14 +404,10 @@ static ssize_t dsicm_store_ulps(struct device *dev,
mutex_lock(&ddata->lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
if (t)
r = dsicm_enter_ulps(ddata);
else
r = dsicm_wake_up(ddata);
-
-   src->ops->dsi.bus_unlock(src);
}
 
mutex_unlock(&ddata->lock);
@@ -457,7 +437,6 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
const char *buf, size_t count)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
-   struct omap_dss_device *src = ddata->src;
unsigned long t;
int r;
 
@@ -470,9 +449,7 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
 
if (ddata->enabled) {
/* dsicm_wake_up will restart the timer */
-   src->ops->dsi.bus_lock(src);
r = dsicm_wake_up(ddata);
-   src->ops->dsi.bus_unlock(src);
}
 
mutex_unlock(&ddata->lock);
@@ -673,17 +650,11 @@ static void dsicm_disconnect(struct omap_dss_device *src,
 static void dsicm_enable(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
int r;
 
mutex_lock(&ddata->lock);
 
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_power_on(ddata);
-
-   src->ops->dsi.bus_unlock(src);
-
if (r)
goto err;
 
@@ -700,7 +671,6 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 static void dsicm_disable(struct omap_dss_device *dssd

[PATCH v3 49/56] drm/omap: simplify DSI manual update code

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Move dsi_ops into the main structure, since all other ops
are gone. Instead of checking the device type we can simply
check if dsi_ops are set.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 10 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  6 +-
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 16 
 3 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index bbcdb62e1571..f47d7e3bb631 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5011,11 +5011,9 @@ static int dsi_get_clocks(struct dsi_data *dsi)
return 0;
 }
 
-static const struct omap_dss_device_ops dsi_ops = {
-   .dsi = {
-   .update = dsi_update_all,
-   .is_video_mode = dsi_is_video_mode,
-   },
+static const struct omapdss_dsi_ops dsi_ops = {
+   .update = dsi_update_all,
+   .is_video_mode = dsi_is_video_mode,
 };
 
 static irqreturn_t omap_dsi_te_irq_handler(int irq, void *dev_id)
@@ -5450,7 +5448,7 @@ static int dsi_init_output(struct dsi_data *dsi)
out->type = OMAP_DISPLAY_TYPE_DSI;
out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
out->dispc_channel = dsi_get_channel(dsi);
-   out->ops = &dsi_ops;
+   out->dsi_ops = &dsi_ops;
out->owner = THIS_MODULE;
out->of_port = 0;
out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index c2199c4946ec..a1236b8ef7ea 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -275,10 +275,6 @@ struct omapdss_dsi_ops {
bool (*is_video_mode)(struct omap_dss_device *dssdev);
 };
 
-struct omap_dss_device_ops {
-   const struct omapdss_dsi_ops dsi;
-};
-
 struct omap_dss_device {
struct device *dev;
 
@@ -300,7 +296,7 @@ struct omap_dss_device {
 
const char *name;
 
-   const struct omap_dss_device_ops *ops;
+   const struct omapdss_dsi_ops *dsi_ops;
u32 bus_flags;
 
/* OMAP DSS output specific fields */
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index f6b968060cf0..5ab557c477ef 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -366,17 +366,10 @@ static void omap_crtc_manual_display_update(struct 
work_struct *data)
struct drm_device *dev = omap_crtc->base.dev;
int ret;
 
-   if (!dssdev) {
-   dev_err_once(dev->dev, "missing display dssdev!");
+   if (!dssdev || !dssdev->dsi_ops || !dssdev->dsi_ops->update)
return;
-   }
-
-   if (dssdev->type != OMAP_DISPLAY_TYPE_DSI || !dssdev->ops->dsi.update) {
-   dev_err_once(dev->dev, "no DSI update callback found!");
-   return;
-   }
 
-   ret = dssdev->ops->dsi.update(dssdev);
+   ret = dssdev->dsi_ops->update(dssdev);
if (ret < 0) {
spin_lock_irq(&dev->event_lock);
omap_crtc->pending = false;
@@ -550,11 +543,10 @@ static bool omap_crtc_is_manually_updated(struct drm_crtc 
*crtc)
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
struct omap_dss_device *dssdev = omap_crtc->pipe->output;
 
-   if (dssdev->type != OMAP_DISPLAY_TYPE_DSI ||
-   !dssdev->ops->dsi.is_video_mode)
+   if (!dssdev || !dssdev->dsi_ops || !dssdev->dsi_ops->is_video_mode)
return false;
 
-   if (dssdev->ops->dsi.is_video_mode(dssdev))
+   if (dssdev->dsi_ops->is_video_mode(dssdev))
return false;
 
DBG("detected manually updated display!");
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 40/56] drm/panel: Move OMAP's DSI command mode panel driver

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

The panel driver is no longer using any OMAP specific APIs, so
let's move it into the generic panel directory.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
Cc: Thierry Reding 
Cc: Sam Ravnborg 
---
 drivers/gpu/drm/omapdrm/Kconfig|  1 -
 drivers/gpu/drm/omapdrm/Makefile   |  1 -
 drivers/gpu/drm/omapdrm/displays/Kconfig   | 10 --
 drivers/gpu/drm/omapdrm/displays/Makefile  |  2 --
 drivers/gpu/drm/panel/Kconfig  |  9 +
 drivers/gpu/drm/panel/Makefile |  1 +
 .../gpu/drm/{omapdrm/displays => panel}/panel-dsi-cm.c |  0
 7 files changed, 10 insertions(+), 14 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/displays/Kconfig
 delete mode 100644 drivers/gpu/drm/omapdrm/displays/Makefile
 rename drivers/gpu/drm/{omapdrm/displays => panel}/panel-dsi-cm.c (100%)

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index 5417e7a47072..cea3f44ea6d4 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -12,6 +12,5 @@ config DRM_OMAP
 if DRM_OMAP
 
 source "drivers/gpu/drm/omapdrm/dss/Kconfig"
-source "drivers/gpu/drm/omapdrm/displays/Kconfig"
 
 endif
diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index f115253115c5..66a73eae6f7c 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -5,7 +5,6 @@
 #
 
 obj-y += dss/
-obj-y += displays/
 
 omapdrm-y := omap_drv.o \
omap_irq.o \
diff --git a/drivers/gpu/drm/omapdrm/displays/Kconfig 
b/drivers/gpu/drm/omapdrm/displays/Kconfig
deleted file mode 100644
index f2be594c7eff..
--- a/drivers/gpu/drm/omapdrm/displays/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-menu "OMAPDRM External Display Device Drivers"
-
-config DRM_OMAP_PANEL_DSI_CM
-   tristate "Generic DSI Command Mode Panel"
-   depends on BACKLIGHT_CLASS_DEVICE
-   help
- Driver for generic DSI command mode panels.
-
-endmenu
diff --git a/drivers/gpu/drm/omapdrm/displays/Makefile 
b/drivers/gpu/drm/omapdrm/displays/Makefile
deleted file mode 100644
index 488ddf153613..
--- a/drivers/gpu/drm/omapdrm/displays/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_DRM_OMAP_PANEL_DSI_CM) += panel-dsi-cm.o
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index b9dbedf8f15e..a71f95afc52e 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -48,6 +48,15 @@ config DRM_PANEL_BOE_TV101WUM_NL6
  Say Y here if you want to support for BOE TV101WUM and AUO KD101N80
  45NA WUXGA PANEL DSI Video Mode panel
 
+config DRM_PANEL_DSI_CM
+   tristate "Generic DSI command mode panels"
+   depends on OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ DRM panel driver for DSI command mode panels with support for
+ embedded and external backlights.
+
 config DRM_PANEL_LVDS
tristate "Generic LVDS panel driver"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 2ba560bca61d..c553e968e9a9 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o
 obj-$(CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596) += 
panel-asus-z00t-tm5p5-n35596.o
 obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o
 obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o
+obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o
 obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
 obj-$(CONFIG_DRM_PANEL_ELIDA_KD35T133) += panel-elida-kd35t133.o
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/panel/panel-dsi-cm.c
similarity index 100%
rename from drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
rename to drivers/gpu/drm/panel/panel-dsi-cm.c
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 29/56] drm/omap: dsi: do ULPS in host driver

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Move ULPS handling into the DSI host controller, so that we
no longer need a custom API for the DSI client.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 273 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c |  63 +++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   2 -
 3 files changed, 62 insertions(+), 276 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 78247dcb1848..030a8fa140db 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -16,7 +16,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -69,21 +68,13 @@ struct panel_drv_data {
 
bool intro_printed;
 
-   struct workqueue_struct *workqueue;
-
bool ulps_enabled;
-   unsigned int ulps_timeout;
-   struct delayed_work ulps_work;
 };
 
 #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
-static int dsicm_panel_reset(struct panel_drv_data *ddata);
-
-static void dsicm_ulps_work(struct work_struct *work);
-
 static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable)
 {
struct backlight_device *backlight;
@@ -207,94 +198,6 @@ static int dsicm_set_update_window(struct panel_drv_data 
*ddata,
return 0;
 }
 
-static void dsicm_queue_ulps_work(struct panel_drv_data *ddata)
-{
-   if (ddata->ulps_timeout > 0)
-   queue_delayed_work(ddata->workqueue, &ddata->ulps_work,
-   msecs_to_jiffies(ddata->ulps_timeout));
-}
-
-static void dsicm_cancel_ulps_work(struct panel_drv_data *ddata)
-{
-   cancel_delayed_work(&ddata->ulps_work);
-}
-
-static int dsicm_enter_ulps(struct panel_drv_data *ddata)
-{
-   struct omap_dss_device *src = ddata->src;
-   int r;
-
-   if (ddata->ulps_enabled)
-   return 0;
-
-   dsicm_cancel_ulps_work(ddata);
-
-   r = _dsicm_enable_te(ddata, false);
-   if (r)
-   goto err;
-
-   src->ops->dsi.ulps(src, true);
-
-   ddata->ulps_enabled = true;
-
-   return 0;
-
-err:
-   dev_err(&ddata->dsi->dev, "enter ULPS failed");
-   dsicm_panel_reset(ddata);
-
-   ddata->ulps_enabled = false;
-
-   dsicm_queue_ulps_work(ddata);
-
-   return r;
-}
-
-static int dsicm_exit_ulps(struct panel_drv_data *ddata)
-{
-   struct omap_dss_device *src = ddata->src;
-   int r;
-
-   if (!ddata->ulps_enabled)
-   return 0;
-
-   src->ops->dsi.ulps(src, false);
-   ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
-
-   r = _dsicm_enable_te(ddata, ddata->te_enabled);
-   if (r) {
-   dev_err(&ddata->dsi->dev, "failed to re-enable TE");
-   goto err2;
-   }
-
-   dsicm_queue_ulps_work(ddata);
-
-   ddata->ulps_enabled = false;
-
-   return 0;
-
-err2:
-   dev_err(&ddata->dsi->dev, "failed to exit ULPS");
-
-   r = dsicm_panel_reset(ddata);
-   if (!r)
-   ddata->ulps_enabled = false;
-
-   dsicm_queue_ulps_work(ddata);
-
-   return r;
-}
-
-static int dsicm_wake_up(struct panel_drv_data *ddata)
-{
-   if (ddata->ulps_enabled)
-   return dsicm_exit_ulps(ddata);
-
-   dsicm_cancel_ulps_work(ddata);
-   dsicm_queue_ulps_work(ddata);
-   return 0;
-}
-
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
@@ -312,11 +215,8 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
mutex_lock(&ddata->lock);
 
if (ddata->enabled) {
-   r = dsicm_wake_up(ddata);
-   if (!r) {
-   r = dsicm_dcs_write_1(ddata,
-   MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
-   }
+   r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
+ level);
}
 
mutex_unlock(&ddata->lock);
@@ -343,18 +243,12 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
u8 errors = 0;
-   int r;
+   int r = -ENODEV;
 
mutex_lock(&ddata->lock);
 
-   if (ddata->enabled) {
-   r = dsicm_wake_up(ddata);
-   if (!r)
-   r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
-   &errors);
-   } else {
-   r = -ENODEV;
-   }
+   if (ddata->enabled)
+   r = dsicm_dcs_read_1(ddata, DCS_

[PATCH v3 28/56] drm/omap: dsi: untangle ulps ops from enable/disable

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Create a custom function pointer for ULPS and use it instead of
reusing disable/enable functions for ULPS mode switch. This allows
us to use the common disable/enable functions pointers for DSI.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  8 ++--
 drivers/gpu/drm/omapdrm/dss/dsi.c | 42 ++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  5 +--
 3 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 4be0c9dbcc43..78247dcb1848 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -233,7 +233,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   src->ops->dsi.disable(src, false, true);
+   src->ops->dsi.ulps(src, true);
 
ddata->ulps_enabled = true;
 
@@ -258,7 +258,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
if (!ddata->ulps_enabled)
return 0;
 
-   src->ops->enable(src);
+   src->ops->dsi.ulps(src, false);
ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
r = _dsicm_enable_te(ddata, ddata->te_enabled);
@@ -586,7 +586,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
-   src->ops->dsi.disable(src, true, false);
+   src->ops->disable(src);
 err_regulators:
r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
if (r)
@@ -612,7 +612,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
dsicm_hw_reset(ddata);
}
 
-   src->ops->dsi.disable(src, true, false);
+   src->ops->disable(src);
 
r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index d54b743c2b48..937362ade4b4 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4055,13 +4055,10 @@ static void dsi_display_uninit_dsi(struct dsi_data 
*dsi, bool disconnect_lanes,
}
 }
 
-static void dsi_display_enable(struct omap_dss_device *dssdev)
+static void dsi_display_ulps_enable(struct dsi_data *dsi)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
 
-   DSSDBG("dsi_display_enable\n");
-
WARN_ON(!dsi_bus_is_locked(dsi));
 
mutex_lock(&dsi->lock);
@@ -4084,16 +4081,19 @@ static void dsi_display_enable(struct omap_dss_device 
*dssdev)
dsi_runtime_put(dsi);
 err_get_dsi:
mutex_unlock(&dsi->lock);
-   DSSDBG("dsi_display_enable FAILED\n");
+   DSSDBG("dsi_display_ulps_enable FAILED\n");
 }
 
-static void dsi_display_disable(struct omap_dss_device *dssdev,
-   bool disconnect_lanes, bool enter_ulps)
+static void dsi_display_enable(struct omap_dss_device *dssdev)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
+   DSSDBG("dsi_display_enable\n");
+   dsi_display_ulps_enable(dsi);
+}
 
-   DSSDBG("dsi_display_disable\n");
-
+static void dsi_display_ulps_disable(struct dsi_data *dsi,
+   bool disconnect_lanes, bool enter_ulps)
+{
WARN_ON(!dsi_bus_is_locked(dsi));
 
mutex_lock(&dsi->lock);
@@ -4110,6 +4110,27 @@ static void dsi_display_disable(struct omap_dss_device 
*dssdev,
mutex_unlock(&dsi->lock);
 }
 
+static void dsi_display_disable(struct omap_dss_device *dssdev)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+
+   DSSDBG("dsi_display_disable\n");
+
+   dsi_display_ulps_disable(dsi, true, false);
+}
+
+static void dsi_ulps(struct omap_dss_device *dssdev, bool enable)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+
+   DSSDBG("dsi_ulps\n");
+
+   if (enable)
+   dsi_display_ulps_disable(dsi, false, true);
+   else
+   dsi_display_ulps_enable(dsi);
+}
+
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
dsi->te_enabled = enable;
@@ -4812,9 +4833,10 @@ static const struct omap_dss_device_ops dsi_ops = {
.connect = dsi_connect,
.disconnect = dsi_disconnect,
.enable = dsi_display_enable,
+   .disable = dsi_display_disable,
 
.dsi = {
-   .disable = dsi_display_disable,
+   .ulps = dsi_ulps,
 
.set_config = dsi_set_config,
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 43eba2ea1f96..0d82ba34ca89 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -281,10 +281,9 @@ struct om

[PATCH v3 26/56] drm/omap: dsi: drop custom enable_te() API

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Instead of using the custon enable_te() API, this automatically
enables/disables TE core support when a matching packet is send
to the panel.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  3 --
 drivers/gpu/drm/omapdrm/dss/dsi.c | 34 ++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  2 --
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 43f63b5a120b..dc2c045cc6b0 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -772,7 +772,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
-   struct omap_dss_device *src = ddata->src;
struct mipi_dsi_device *dsi = ddata->dsi;
int r;
 
@@ -781,8 +780,6 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, 
bool enable)
else
r = mipi_dsi_dcs_set_tear_off(dsi);
 
-   src->ops->dsi.enable_te(src, enable);
-
/* possible panel bug */
msleep(100);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 921e7a1e1014..41431ca34568 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4110,10 +4110,8 @@ static void dsi_display_disable(struct omap_dss_device 
*dssdev,
mutex_unlock(&dsi->lock);
 }
 
-static int dsi_enable_te(struct omap_dss_device *dssdev, bool enable)
+static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
dsi->te_enabled = enable;
 
if (dsi->te_gpio) {
@@ -4723,6 +4721,7 @@ static ssize_t omap_dsi_host_transfer(struct 
mipi_dsi_host *host,
 {
struct dsi_data *dsi = host_to_omap(host);
struct omap_dss_device *dssdev = &dsi->output;
+   int r;
 
if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode) {
dsi_vc_enable_hs(dssdev, msg->channel,
@@ -4739,16 +4738,35 @@ static ssize_t omap_dsi_host_transfer(struct 
mipi_dsi_host *host,
case MIPI_DSI_DCS_LONG_WRITE:
case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
case MIPI_DSI_NULL_PACKET:
-   return dsi_vc_write_common(dssdev, msg);
+   r = dsi_vc_write_common(dssdev, msg);
+   break;
case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
-   return dsi_vc_generic_read(dssdev, msg);
+   r = dsi_vc_generic_read(dssdev, msg);
+   break;
case MIPI_DSI_DCS_READ:
-   return dsi_vc_dcs_read(dssdev, msg);
+   r = dsi_vc_dcs_read(dssdev, msg);
+   break;
+   default:
+   r = -EINVAL;
+   break;
}
 
-   return -EINVAL;
+   if (r < 0)
+   return r;
+
+   if (msg->type == MIPI_DSI_DCS_SHORT_WRITE ||
+   msg->type == MIPI_DSI_DCS_SHORT_WRITE_PARAM) {
+   u8 cmd = ((u8 *)msg->tx_buf)[0];
+
+   if (cmd == MIPI_DCS_SET_TEAR_OFF)
+   dsi_enable_te(dsi, false);
+   else if (cmd == MIPI_DCS_SET_TEAR_ON)
+   dsi_enable_te(dsi, true);
+   }
+
+   return 0;
 }
 
 static int dsi_get_clocks(struct dsi_data *dsi)
@@ -4795,8 +4813,6 @@ static const struct omap_dss_device_ops dsi_ops = {
.disable_video_output = dsi_disable_video_output,
 
.update = dsi_update,
-
-   .enable_te = dsi_enable_te,
},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 2d44a8e32fcc..1520a5f752b7 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -288,8 +288,6 @@ struct omapdss_dsi_ops {
int (*set_config)(struct omap_dss_device *dssdev,
const struct omap_dss_dsi_config *cfg);
 
-   int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
-
int (*update)(struct omap_dss_device *dssdev, int channel,
void (*callback)(int, void *), void *data);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 33/56] drm/omap: dsi: convert to drm_panel

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This converts the DSI module to expect common drm_panel display
drivers instead of dssdev based ones.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 204 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 133 ++--
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |   1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   8 -
 4 files changed, 189 insertions(+), 157 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index d9b3444b4faf..3668b3f0aff2 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -6,8 +6,6 @@
  * Author: Tomi Valkeinen 
  */
 
-/* #define DEBUG */
-
 #include 
 #include 
 #include 
@@ -20,11 +18,14 @@
 #include 
 
 #include 
+#include 
+#include 
+#include 
 
+#include 
 #include 
 #include 
-
-#include "../dss/omapdss.h"
+#include 
 
 #define DCS_READ_NUM_ERRORS0x05
 #define DCS_GET_ID10xda
@@ -35,11 +36,8 @@
 
 struct panel_drv_data {
struct mipi_dsi_device *dsi;
-
-   struct omap_dss_device dssdev;
-   struct omap_dss_device *src;
-
-   struct videomode vm;
+   struct drm_panel panel;
+   struct drm_display_mode mode;
 
struct mutex lock;
 
@@ -71,7 +69,11 @@ struct panel_drv_data {
bool ulps_enabled;
 };
 
-#define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
+
+static inline struct panel_drv_data *panel_to_ddata(struct drm_panel *panel)
+{
+   return container_of(panel, struct panel_drv_data, panel);
+}
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
@@ -285,7 +287,6 @@ static void dsicm_hw_reset(struct panel_drv_data *ddata)
 
 static int dsicm_power_on(struct panel_drv_data *ddata)
 {
-   struct omap_dss_device *src = ddata->src;
u8 id1, id2, id3;
int r;
 
@@ -322,10 +323,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = src->ops->dsi.enable_video_output(src, ddata->dsi->channel);
-   if (r)
-   goto err;
-
ddata->enabled = true;
 
if (!ddata->intro_printed) {
@@ -345,15 +342,12 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
return r;
 }
 
-static void dsicm_power_off(struct panel_drv_data *ddata)
+static int dsicm_power_off(struct panel_drv_data *ddata)
 {
-   struct omap_dss_device *src = ddata->src;
int r;
 
ddata->enabled = false;
 
-   src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
-
r = mipi_dsi_dcs_set_display_off(ddata->dsi);
if (!r)
r = dsicm_sleep_in(ddata);
@@ -363,51 +357,25 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
"error disabling panel, issuing HW reset\n");
dsicm_hw_reset(ddata);
}
-}
-
-static int dsicm_connect(struct omap_dss_device *src,
-struct omap_dss_device *dst)
-{
-   struct panel_drv_data *ddata = to_panel_data(dst);
-
-   ddata->src = src;
-   return 0;
-}
-
-static void dsicm_disconnect(struct omap_dss_device *src,
-struct omap_dss_device *dst)
-{
-   struct panel_drv_data *ddata = to_panel_data(dst);
 
-   ddata->src = NULL;
+   return r;
 }
 
-static void dsicm_pre_enable(struct omap_dss_device *dssdev)
+static int dsicm_prepare(struct drm_panel *panel)
 {
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
+   struct panel_drv_data *ddata = panel_to_ddata(panel);
int r;
-   struct omap_dss_dsi_config dsi_config = {
-   .vm = &ddata->vm,
-   .hs_clk_min = 15000,
-   .hs_clk_max = 3,
-   .lp_clk_min = 700,
-   .lp_clk_max = 1000,
-   };
 
r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
if (r)
dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
 
-   r = src->ops->dsi.set_config(src, &dsi_config);
-   if (r) {
-   dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
-   }
+   return r;
 }
 
-static void dsicm_enable(struct omap_dss_device *dssdev)
+static int dsicm_enable(struct drm_panel *panel)
 {
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct panel_drv_data *ddata = panel_to_ddata(panel);
int r;
 
mutex_lock(&ddata->lock);
@@ -420,33 +388,39 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 
dsicm_bl_power(ddata, true);
 
-   return;
+   return 0;
 err:
-   dev_d

[PATCH v3 44/56] drm/omap: simplify omap_display_id

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

We no longer need to check for the DSS API, since all encoders,
panels and connectors have been converted to the bridge API.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 20b5b4e9071c..dbb8e95234b3 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -206,14 +206,7 @@ static int omap_display_id(struct omap_dss_device *output)
 {
struct device_node *node = NULL;
 
-   if (output->next) {
-   struct omap_dss_device *display = output;
-
-   while (display->next)
-   display = display->next;
-
-   node = display->dev->of_node;
-   } else if (output->bridge) {
+   if (output->bridge) {
struct drm_bridge *bridge = output->bridge;
 
while (drm_bridge_get_next_bridge(bridge))
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 50/56] drm/omap: dsi: simplify pin config

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Simplify DSI pin config, which always originates from DT
nowadays. With the code being fully contained in the DSI
encoder, we can drop the public structure.

Since the function is no longer exposed, it now directly
takes the private DSI data pointer. This drop a pointless
conversion and means the pins can be configured earlier.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 33 +--
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 15 
 2 files changed, 11 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index f47d7e3bb631..76e4f607d8cf 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3568,12 +3568,9 @@ static void dsi_proto_timings(struct dsi_data *dsi)
}
 }
 
-static int dsi_configure_pins(struct omap_dss_device *dssdev,
-   const struct omap_dsi_pin_config *pin_cfg)
+static int dsi_configure_pins(struct dsi_data *dsi,
+   int num_pins, const u32 *pins)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-   int num_pins;
-   const int *pins;
struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
int num_lanes;
int i;
@@ -3586,9 +3583,6 @@ static int dsi_configure_pins(struct omap_dss_device 
*dssdev,
DSI_LANE_DATA4,
};
 
-   num_pins = pin_cfg->num_pins;
-   pins = pin_cfg->pins;
-
if (num_pins < 4 || num_pins > dsi->num_lanes_supported * 2
|| num_pins % 2 != 0)
return -EINVAL;
@@ -3600,7 +3594,7 @@ static int dsi_configure_pins(struct omap_dss_device 
*dssdev,
 
for (i = 0; i < num_pins; i += 2) {
u8 lane, pol;
-   int dx, dy;
+   u32 dx, dy;
 
dx = pins[i];
dy = pins[i + 1];
@@ -5481,9 +5475,8 @@ static int dsi_probe_of(struct dsi_data *dsi)
struct property *prop;
u32 lane_arr[10];
int len, num_pins;
-   int r, i;
+   int r;
struct device_node *ep;
-   struct omap_dsi_pin_config pin_cfg;
 
ep = of_graph_get_endpoint_by_regs(node, 0, 0);
if (!ep)
@@ -5511,11 +5504,7 @@ static int dsi_probe_of(struct dsi_data *dsi)
goto err;
}
 
-   pin_cfg.num_pins = num_pins;
-   for (i = 0; i < num_pins; ++i)
-   pin_cfg.pins[i] = (int)lane_arr[i];
-
-   r = dsi_configure_pins(&dsi->output, &pin_cfg);
+   r = dsi_configure_pins(dsi, num_pins, lane_arr);
if (r) {
dev_err(dsi->dev, "failed to configure pins");
goto err;
@@ -5728,6 +5717,12 @@ static int dsi_probe(struct platform_device *pdev)
dsi->host.ops = &omap_dsi_host_ops;
dsi->host.dev = &pdev->dev;
 
+   r = dsi_probe_of(dsi);
+   if (r) {
+   DSSERR("Invalid DSI DT data\n");
+   goto err_pm_disable;
+   }
+
r = mipi_dsi_host_register(&dsi->host);
if (r < 0) {
dev_err(&pdev->dev, "failed to register DSI host: %d\n", r);
@@ -5738,12 +5733,6 @@ static int dsi_probe(struct platform_device *pdev)
if (r)
goto err_dsi_host_unregister;
 
-   r = dsi_probe_of(dsi);
-   if (r) {
-   DSSERR("Invalid DSI DT data\n");
-   goto err_uninit_output;
-   }
-
r = component_add(&pdev->dev, &dsi_component_ops);
if (r)
goto err_uninit_output;
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index a1236b8ef7ea..4a0826c8fed5 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -243,21 +243,6 @@ struct omap_overlay_manager_info {
struct omap_dss_cpr_coefs cpr_coefs;
 };
 
-/* 22 pins means 1 clk lane and 10 data lanes */
-#define OMAP_DSS_MAX_DSI_PINS 22
-
-struct omap_dsi_pin_config {
-   int num_pins;
-   /*
-* pin numbers in the following order:
-* clk+, clk-
-* data1+, data1-
-* data2+, data2-
-* ...
-*/
-   int pins[OMAP_DSS_MAX_DSI_PINS];
-};
-
 struct omap_dss_writeback_info {
u32 paddr;
u32 p_uv_addr;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 32/56] drm/omap: dsi: drop custom panel capability support

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Due to previous changes the DSI encoder gets the capabilities
via DSI client's mode_flags and no longer needs the omapdss
specific caps. The core code now checks if the DSI encoder
is actually configured into command mode instead of just checking
the panel capabilities.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c |  3 ---
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  8 
 drivers/gpu/drm/omapdrm/dss/omapdss.h   |  8 +---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 17 -
 4 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 45d417870498..d9b3444b4faf 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -599,9 +599,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
dssdev->of_port = 0;
dssdev->ops_flags = OMAP_DSS_DEVICE_OP_MODES;
 
-   dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE |
-   OMAP_DSS_DISPLAY_CAP_TEAR_ELIM;
-
omapdss_display_init(dssdev);
omapdss_device_register(dssdev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 0aa0d21cf896..620cef8bb1f2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4727,6 +4727,13 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
dsi_vm_calc_pll_cb, ctx);
 }
 
+static bool dsi_is_video_mode(struct omap_dss_device *dssdev)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+
+   return (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE);
+}
+
 static int dsi_set_config(struct omap_dss_device *dssdev,
const struct omap_dss_dsi_config *config)
 {
@@ -4947,6 +4954,7 @@ static const struct omap_dss_device_ops dsi_ops = {
.disable_video_output = dsi_disable_video_output,
 
.update = dsi_update_all,
+   .is_video_mode = dsi_is_video_mode,
},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index de4c779c358a..4200611525d5 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -123,11 +123,6 @@ enum omap_dss_dsi_mode {
OMAP_DSS_DSI_VIDEO_MODE,
 };
 
-enum omap_display_caps {
-   OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE  = 1 << 0,
-   OMAP_DSS_DISPLAY_CAP_TEAR_ELIM  = 1 << 1,
-};
-
 enum omap_dss_display_state {
OMAP_DSS_DISPLAY_DISABLED = 0,
OMAP_DSS_DISPLAY_ACTIVE,
@@ -282,6 +277,7 @@ struct omap_dss_writeback_info {
 
 struct omapdss_dsi_ops {
int (*update)(struct omap_dss_device *dssdev);
+   bool (*is_video_mode)(struct omap_dss_device *dssdev);
 
/* legacy API used by omapdss panels */
int (*set_config)(struct omap_dss_device *dssdev,
@@ -354,8 +350,6 @@ struct omap_dss_device {
unsigned long ops_flags;
u32 bus_flags;
 
-   enum omap_display_caps caps;
-
enum omap_dss_display_state state;
 
/* OMAP DSS output specific fields */
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 3068e4fffa16..f6b968060cf0 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -496,8 +496,7 @@ static enum drm_mode_status omap_crtc_mode_valid(struct 
drm_crtc *crtc,
 * valid DISPC mode. DSI will calculate and configure the
 * proper DISPC mode later.
 */
-   if (omap_crtc->pipe->output->next == NULL ||
-   omap_crtc->pipe->output->next->type != OMAP_DISPLAY_TYPE_DSI) {
+   if (omap_crtc->pipe->output->type != OMAP_DISPLAY_TYPE_DSI) {
r = priv->dispc_ops->mgr_check_timings(priv->dispc,
   omap_crtc->channel,
   &vm);
@@ -549,17 +548,17 @@ static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc)
 static bool omap_crtc_is_manually_updated(struct drm_crtc *crtc)
 {
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
-   struct omap_dss_device *display = omap_crtc->pipe->output->next;
+   struct omap_dss_device *dssdev = omap_crtc->pipe->output;
 
-   if (!display)
+   if (dssdev->type != OMAP_DISPLAY_TYPE_DSI ||
+   !dssdev->ops->dsi.is_video_mode)
return false;
 
-   if (display->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
-   DBG("detected manually updated display!");
-   return true;
-   }
+   if (dssdev->ops->dsi.is_video_mode(dssdev))
+   return false;
 
-   return false;
+   DBG("dete

[PATCH v3 37/56] drm/omap: panel-dsi-cm: support unbinding

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Now, that the driver implements the common DRM panel API
the unbind no longer needs to be suppressed.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 5159dd51a353..086c7d71fe17 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -607,7 +607,7 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
return r;
 }
 
-static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
+static int dsicm_remove(struct mipi_dsi_device *dsi)
 {
struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
 
@@ -637,11 +637,10 @@ MODULE_DEVICE_TABLE(of, dsicm_of_match);
 
 static struct mipi_dsi_driver dsicm_driver = {
.probe = dsicm_probe,
-   .remove = __exit_p(dsicm_remove),
+   .remove = dsicm_remove,
.driver = {
.name = "panel-dsi-cm",
.of_match_table = dsicm_of_match,
-   .suppress_bind_attrs = true,
},
 };
 module_mipi_dsi_driver(dsicm_driver);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 36/56] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Use DEVICE_ATTR_RO helper instead of plain DEVICE_ATTR,
which makes the code a bit shorter and easier to read.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 3668b3f0aff2..5159dd51a353 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -219,7 +219,7 @@ static const struct backlight_ops dsicm_bl_ops = {
.update_status  = dsicm_bl_update_status,
 };
 
-static ssize_t dsicm_num_errors_show(struct device *dev,
+static ssize_t num_dsi_errors_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
@@ -239,7 +239,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", errors);
 }
 
-static ssize_t dsicm_hw_revision_show(struct device *dev,
+static ssize_t hw_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);
@@ -259,8 +259,8 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3);
 }
 
-static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL);
-static DEVICE_ATTR(hw_revision, S_IRUGO, dsicm_hw_revision_show, NULL);
+static DEVICE_ATTR_RO(num_dsi_errors);
+static DEVICE_ATTR_RO(hw_revision);
 
 static struct attribute *dsicm_attrs[] = {
&dev_attr_num_dsi_errors.attr,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 47/56] drm/omap: drop DSS ops_flags

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

The omapdss device's ops_flags field is no longer
used and can be dropped.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 9 -
 drivers/gpu/drm/omapdrm/dss/venc.c| 1 -
 2 files changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 1f02d3e406dc..916c55101629 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -279,14 +279,6 @@ struct omap_dss_device_ops {
const struct omapdss_dsi_ops dsi;
 };
 
-/**
- * enum omap_dss_device_ops_flag - Indicates which device ops are supported
- * @OMAP_DSS_DEVICE_OP_MODES: The device supports reading modes
- */
-enum omap_dss_device_ops_flag {
-   OMAP_DSS_DEVICE_OP_MODES = BIT(3),
-};
-
 struct omap_dss_device {
struct device *dev;
 
@@ -315,7 +307,6 @@ struct omap_dss_device {
const char *name;
 
const struct omap_dss_device_ops *ops;
-   unsigned long ops_flags;
u32 bus_flags;
 
/* OMAP DSS output specific fields */
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c 
b/drivers/gpu/drm/omapdrm/dss/venc.c
index 5c027c81760f..6e418a0f7572 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -732,7 +732,6 @@ static int venc_init_output(struct venc_device *venc)
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
out->owner = THIS_MODULE;
out->of_port = 0;
-   out->ops_flags = OMAP_DSS_DEVICE_OP_MODES;
 
r = omapdss_device_init_output(out, &venc->bridge);
if (r < 0) {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 45/56] drm/omap: drop unused DSS next pointer

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Since all encoders and panels are using the bridge API now,
we next pointer is no longer useful and can be dropped.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/base.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  1 -
 drivers/gpu/drm/omapdrm/dss/output.c   | 13 +
 drivers/gpu/drm/omapdrm/omap_encoder.c |  4 
 4 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index c2791305c332..d62713b241d2 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -135,7 +135,7 @@ struct omap_dss_device *omapdss_device_next_output(struct 
omap_dss_device *from)
goto done;
}
 
-   if (dssdev->id && (dssdev->next || dssdev->bridge))
+   if (dssdev->id && (dssdev->bridge))
goto done;
}
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 5d6edec5a427..1f02d3e406dc 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -293,7 +293,6 @@ struct omap_dss_device {
struct module *owner;
 
struct dss_device *dss;
-   struct omap_dss_device *next;
struct drm_bridge *bridge;
struct drm_bridge *next_bridge;
struct drm_panel *panel;
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index ce21c798cca6..40cb353572f6 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -30,7 +30,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
return 0;
}
 
-   out->next = omapdss_find_device_by_node(remote_node);
out->bridge = of_drm_find_bridge(remote_node);
out->panel = of_drm_find_panel(remote_node);
if (IS_ERR(out->panel))
@@ -38,12 +37,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 
of_node_put(remote_node);
 
-   if (out->next && out->type != out->next->type) {
-   dev_err(out->dev, "output type and display type don't match\n");
-   ret = -EINVAL;
-   goto error;
-   }
-
if (out->panel) {
struct drm_bridge *bridge;
 
@@ -69,7 +62,7 @@ int omapdss_device_init_output(struct omap_dss_device *out,
out->bridge = local_bridge;
}
 
-   if (!out->next && !out->bridge) {
+   if (!out->bridge) {
ret = -EPROBE_DEFER;
goto error;
}
@@ -78,7 +71,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 
 error:
omapdss_device_cleanup_output(out);
-   out->next = NULL;
return ret;
 }
 EXPORT_SYMBOL(omapdss_device_init_output);
@@ -88,9 +80,6 @@ void omapdss_device_cleanup_output(struct omap_dss_device 
*out)
if (out->bridge && out->panel)
drm_panel_bridge_remove(out->next_bridge ?
out->next_bridge : out->bridge);
-
-   if (out->next)
-   omapdss_device_put(out->next);
 }
 EXPORT_SYMBOL(omapdss_device_cleanup_output);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c 
b/drivers/gpu/drm/omapdrm/omap_encoder.c
index 610c5a2f2771..5f5fa01240a7 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -75,7 +75,6 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
 {
struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
struct omap_dss_device *output = omap_encoder->output;
-   struct omap_dss_device *dssdev;
struct drm_device *dev = encoder->dev;
struct drm_connector *connector;
struct drm_bridge *bridge;
@@ -98,9 +97,6 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
 *
 * A better solution is to use DRM's bus-flags through the whole driver.
 */
-   for (dssdev = output; dssdev; dssdev = dssdev->next)
-   omap_encoder_update_videomode_flags(&vm, dssdev->bus_flags);
-
for (bridge = output->bridge; bridge;
 bridge = drm_bridge_get_next_bridge(bridge)) {
if (!bridge->timings)
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 34/56] drm/omap: drop omapdss-boot-init

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

The table of compatible values needed to be prefixed with "omapdss,"
is empty, so all of this code is doing nothing now. Let's drop it.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/Kconfig   |   4 -
 drivers/gpu/drm/omapdrm/dss/Makefile  |   2 -
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   | 228 --
 3 files changed, 234 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c

diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig 
b/drivers/gpu/drm/omapdrm/dss/Kconfig
index fd7dfa28ce97..6ec80771af3d 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -1,7 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
-config OMAP2_DSS_INIT
-   bool
-
 config OMAP_DSS_BASE
tristate
 
@@ -9,7 +6,6 @@ menuconfig OMAP2_DSS
tristate "OMAP2+ Display Subsystem support"
select OMAP_DSS_BASE
select VIDEOMODE_HELPERS
-   select OMAP2_DSS_INIT
select HDMI
help
  OMAP2+ Display Subsystem support.
diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile 
b/drivers/gpu/drm/omapdrm/dss/Makefile
index f967e6948f2e..811966cd7468 100644
--- a/drivers/gpu/drm/omapdrm/dss/Makefile
+++ b/drivers/gpu/drm/omapdrm/dss/Makefile
@@ -1,6 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
-
 obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o
 omapdss-base-y := base.o display.o output.o
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c 
b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
deleted file mode 100644
index 18560ca4bbb0..
--- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
+++ /dev/null
@@ -1,228 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
- * Author: Tomi Valkeinen 
- */
-
-/*
- * As omapdss panel drivers are omapdss specific, but we want to define the
- * DT-data in generic manner, we convert the compatible strings of the panel 
and
- * encoder nodes from "panel-foo" to "omapdss,panel-foo". This way we can have
- * both correct DT data and omapdss specific drivers.
- *
- * When we get generic panel drivers to the kernel, this file will be removed.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static struct list_head dss_conv_list __initdata;
-
-static const char prefix[] __initconst = "omapdss,";
-
-struct dss_conv_node {
-   struct list_head list;
-   struct device_node *node;
-   bool root;
-};
-
-static int __init omapdss_count_strings(const struct property *prop)
-{
-   const char *p = prop->value;
-   int l = 0, total = 0;
-   int i;
-
-   for (i = 0; total < prop->length; total += l, p += l, i++)
-   l = strlen(p) + 1;
-
-   return i;
-}
-
-static void __init omapdss_update_prop(struct device_node *node, char *compat,
-   int len)
-{
-   struct property *prop;
-
-   prop = kzalloc(sizeof(*prop), GFP_KERNEL);
-   if (!prop)
-   return;
-
-   prop->name = "compatible";
-   prop->value = compat;
-   prop->length = len;
-
-   of_update_property(node, prop);
-}
-
-static void __init omapdss_prefix_strcpy(char *dst, int dst_len,
-   const char *src, int src_len)
-{
-   size_t total = 0;
-
-   while (total < src_len) {
-   size_t l = strlen(src) + 1;
-
-   strcpy(dst, prefix);
-   dst += strlen(prefix);
-
-   strcpy(dst, src);
-   dst += l;
-
-   src += l;
-   total += l;
-   }
-}
-
-/* prepend compatible property strings with "omapdss," */
-static void __init omapdss_omapify_node(struct device_node *node)
-{
-   struct property *prop;
-   char *new_compat;
-   int num_strs;
-   int new_len;
-
-   prop = of_find_property(node, "compatible", NULL);
-
-   if (!prop || !prop->value)
-   return;
-
-   if (strnlen(prop->value, prop->length) >= prop->length)
-   return;
-
-   /* is it already prefixed? */
-   if (strncmp(prefix, prop->value, strlen(prefix)) == 0)
-   return;
-
-   num_strs = omapdss_count_strings(prop);
-
-   new_len = prop->length + strlen(prefix) * num_strs;
-   new_compat = kmalloc(new_len, GFP_KERNEL);
-
-   omapdss_prefix_strcpy(new_compat, new_len, prop->value, prop->length);
-
-   omapdss_update_prop(node, new_compat, new_len);
-}
-
-static void __init omapdss_add_to_list(struct device_node *node, bool root)
-{
-   struct dss_conv_node *n = kmalloc(sizeof(*n), GFP_KERNEL);
-   if (n) {
-   n->node = node;
-   n->root = root;
-   list_add(&n->

[PATCH v3 46/56] drm/omap: drop empty omap_encoder helper functions

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Cleanup empty functions for encoder enable, disable and atomic check.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_encoder.c | 28 --
 1 file changed, 28 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c 
b/drivers/gpu/drm/omapdrm/omap_encoder.c
index 5f5fa01240a7..e24411fb9dac 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -113,36 +113,8 @@ static void omap_encoder_mode_set(struct drm_encoder 
*encoder,
dss_mgr_set_timings(output, &vm);
 }
 
-static void omap_encoder_disable(struct drm_encoder *encoder)
-{
-   struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
-   struct omap_dss_device *dssdev = omap_encoder->output;
-   struct drm_device *dev = encoder->dev;
-
-   dev_dbg(dev->dev, "disable(%s)\n", dssdev->name);
-}
-
-static void omap_encoder_enable(struct drm_encoder *encoder)
-{
-   struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
-   struct omap_dss_device *dssdev = omap_encoder->output;
-   struct drm_device *dev = encoder->dev;
-
-   dev_dbg(dev->dev, "enable(%s)\n", dssdev->name);
-}
-
-static int omap_encoder_atomic_check(struct drm_encoder *encoder,
-struct drm_crtc_state *crtc_state,
-struct drm_connector_state *conn_state)
-{
-   return 0;
-}
-
 static const struct drm_encoder_helper_funcs omap_encoder_helper_funcs = {
.mode_set = omap_encoder_mode_set,
-   .disable = omap_encoder_disable,
-   .enable = omap_encoder_enable,
-   .atomic_check = omap_encoder_atomic_check,
 };
 
 /* initialize encoder */
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 52/56] drm/omap: squash omapdrm sub-modules into one

2020-11-05 Thread Tomi Valkeinen
At the moment we have three different modules: omapdss-base, omapdss,
omapdrm. This setup is finally obsolete, as the last omapdrm specific
panel has been converted to DRM panel.

We can thus remove omapdss-base and omapdss, and just compile everything
into omapdrm.ko.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/Kconfig   | 119 ++-
 drivers/gpu/drm/omapdrm/Makefile  |  17 +++-
 drivers/gpu/drm/omapdrm/dss/Kconfig   | 132 --
 drivers/gpu/drm/omapdrm/dss/Makefile  |  18 
 drivers/gpu/drm/omapdrm/dss/base.c|  23 +
 drivers/gpu/drm/omapdrm/dss/display.c |   2 -
 drivers/gpu/drm/omapdrm/dss/dss.c |  11 +--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   3 +
 drivers/gpu/drm/omapdrm/dss/output.c  |  11 ---
 drivers/gpu/drm/omapdrm/omap_drv.c|  12 ++-
 10 files changed, 148 insertions(+), 200 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/Kconfig
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/Makefile

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index cea3f44ea6d4..e7281da5bc6a 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -5,12 +5,129 @@ config DRM_OMAP
depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
select OMAP2_DSS
select DRM_KMS_HELPER
+   select VIDEOMODE_HELPERS
+   select HDMI
default n
help
  DRM display driver for OMAP2/3/4 based boards.
 
 if DRM_OMAP
 
-source "drivers/gpu/drm/omapdrm/dss/Kconfig"
+config OMAP2_DSS_DEBUG
+   bool "Debug support"
+   default n
+   help
+ This enables printing of debug messages. Alternatively, debug messages
+ can also be enabled by setting CONFIG_DYNAMIC_DEBUG and then setting
+ appropriate flags in /dynamic_debug/control.
+
+config OMAP2_DSS_DEBUGFS
+   bool "Debugfs filesystem support"
+   depends on DEBUG_FS
+   default n
+   help
+ This enables debugfs for OMAPDSS at /omapdss. This enables
+ querying about clock configuration and register configuration of dss,
+ dispc, dsi, hdmi and rfbi.
+
+config OMAP2_DSS_COLLECT_IRQ_STATS
+   bool "Collect DSS IRQ statistics"
+   depends on OMAP2_DSS_DEBUGFS
+   default n
+   help
+ Collect DSS IRQ statistics, printable via debugfs.
+
+ The statistics can be found from
+ /omapdss/dispc_irq for DISPC interrupts, and
+ /omapdss/dsi_irq for DSI interrupts.
+
+config OMAP2_DSS_DPI
+   bool "DPI support"
+   default y
+   help
+ DPI Interface. This is the Parallel Display Interface.
+
+config OMAP2_DSS_VENC
+   bool "VENC support"
+   default y
+   help
+ OMAP Video Encoder support for S-Video and composite TV-out.
+
+config OMAP2_DSS_HDMI_COMMON
+   bool
+
+config OMAP4_DSS_HDMI
+   bool "HDMI support for OMAP4"
+   default y
+   select OMAP2_DSS_HDMI_COMMON
+   help
+ HDMI support for OMAP4 based SoCs.
+
+config OMAP4_DSS_HDMI_CEC
+   bool "Enable HDMI CEC support for OMAP4"
+   depends on OMAP4_DSS_HDMI
+   select CEC_CORE
+   default y
+   help
+ When selected the HDMI transmitter will support the CEC feature.
+
+config OMAP5_DSS_HDMI
+   bool "HDMI support for OMAP5"
+   default n
+   select OMAP2_DSS_HDMI_COMMON
+   help
+ HDMI Interface for OMAP5 and similar cores. This adds the High
+ Definition Multimedia Interface. See http://www.hdmi.org/ for HDMI
+ specification.
+
+config OMAP2_DSS_SDI
+   bool "SDI support"
+   default n
+   help
+ SDI (Serial Display Interface) support.
+
+ SDI is a high speed one-way display serial bus between the host
+ processor and a display.
+
+config OMAP2_DSS_DSI
+   bool "DSI support"
+   default n
+   select DRM_MIPI_DSI
+   help
+ MIPI DSI (Display Serial Interface) support.
+
+ DSI is a high speed half-duplex serial interface between the host
+ processor and a peripheral, such as a display or a framebuffer chip.
+
+ See http://www.mipi.org/ for DSI specifications.
+
+config OMAP2_DSS_MIN_FCK_PER_PCK
+   int "Minimum FCK/PCK ratio (for scaling)"
+   range 0 32
+   default 0
+   help
+ This can be used to adjust the minimum FCK/PCK ratio.
+
+ With this you can make sure that DISPC FCK is at least
+ n x PCK. Video plane scaling requires higher FCK than
+ normally.
+
+ If this is set to 0, there's no extra constraint on the
+ DISPC FCK. However, the FCK will at minimum be
+ 2xPCK (if active matrix) or 3xPCK (if passive matrix).
+
+ Max FCK is 173MHz, so this doesn't work if your PCK
+ is very high.
+
+config OMAP2_DS

[PATCH v3 41/56] drm/omap: dsi: Register a drm_bridge

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

In order to integrate with a chain of drm_bridge, the internal DSI
output has to expose its operations through the drm_bridge API.
Register a bridge at initialisation time to do so and remove the
omap_dss_device operations that are now unused.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 134 --
 1 file changed, 89 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index f643321434e9..bbcdb62e1571 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -437,6 +438,7 @@ struct dsi_data {
struct omap_dss_dsi_videomode_timings vm_timings;
 
struct omap_dss_device output;
+   struct drm_bridge bridge;
 };
 
 struct dsi_packet_sent_handler_data {
@@ -449,6 +451,9 @@ static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
 #endif
 
+#define drm_bridge_to_dsi(bridge) \
+   container_of(bridge, struct dsi_data, bridge)
+
 static inline struct dsi_data *to_dsi_data(struct omap_dss_device *dssdev)
 {
return dev_get_drvdata(dssdev->dev);
@@ -5006,50 +5011,7 @@ static int dsi_get_clocks(struct dsi_data *dsi)
return 0;
 }
 
-static void dsi_set_timings(struct omap_dss_device *dssdev,
-   const struct drm_display_mode *mode)
-{
-   DSSDBG("dsi_set_timings\n");
-   dsi_set_config(dssdev, mode);
-}
-
-static int dsi_check_timings(struct omap_dss_device *dssdev,
-struct drm_display_mode *mode)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-   struct dsi_clk_calc_ctx ctx;
-   int r;
-
-   DSSDBG("dsi_check_timings\n");
-
-   mutex_lock(&dsi->lock);
-   r = __dsi_calc_config(dsi, mode, &ctx);
-   mutex_unlock(&dsi->lock);
-
-   return r;
-}
-
-static int dsi_connect(struct omap_dss_device *src,
-  struct omap_dss_device *dst)
-{
-   return omapdss_device_connect(dst->dss, dst, dst->next);
-}
-
-static void dsi_disconnect(struct omap_dss_device *src,
-  struct omap_dss_device *dst)
-{
-   omapdss_device_disconnect(dst, dst->next);
-}
-
 static const struct omap_dss_device_ops dsi_ops = {
-   .connect = dsi_connect,
-   .disconnect = dsi_disconnect,
-   .enable = dsi_enable_video_outputs,
-   .disable = dsi_disable_video_outputs,
-
-   .check_timings = dsi_check_timings,
-   .set_timings = dsi_set_timings,
-
.dsi = {
.update = dsi_update_all,
.is_video_mode = dsi_is_video_mode,
@@ -5393,6 +5355,83 @@ static const struct component_ops dsi_component_ops = {
.unbind = dsi_unbind,
 };
 
+/* 
-
+ * DRM Bridge Operations
+ */
+
+static int dsi_bridge_attach(struct drm_bridge *bridge,
+enum drm_bridge_attach_flags flags)
+{
+   struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+   if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
+   return -EINVAL;
+
+   return drm_bridge_attach(bridge->encoder, dsi->output.next_bridge,
+bridge, flags);
+}
+
+static enum drm_mode_status
+dsi_bridge_mode_valid(struct drm_bridge *bridge,
+ const struct drm_display_info *info,
+ const struct drm_display_mode *mode)
+{
+   struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+   struct dsi_clk_calc_ctx ctx;
+   int r;
+
+   mutex_lock(&dsi->lock);
+   r = __dsi_calc_config(dsi, mode, &ctx);
+   mutex_unlock(&dsi->lock);
+
+   return r ? MODE_CLOCK_RANGE : MODE_OK;
+}
+
+static void dsi_bridge_mode_set(struct drm_bridge *bridge,
+   const struct drm_display_mode *mode,
+   const struct drm_display_mode *adjusted_mode)
+{
+   struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+   dsi_set_config(&dsi->output, adjusted_mode);
+}
+
+static void dsi_bridge_enable(struct drm_bridge *bridge)
+{
+   struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+   dsi_enable_video_outputs(&dsi->output);
+}
+
+static void dsi_bridge_disable(struct drm_bridge *bridge)
+{
+   struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+   dsi_disable_video_outputs(&dsi->output);
+}
+
+static const struct drm_bridge_funcs dsi_bridge_funcs = {
+   .attach = dsi_bridge_attach,
+   .mode_valid = dsi_bridge_mode_valid,
+   .mode_set = dsi_bridge_mode_set,
+   .enable = dsi_bridge_enable,
+   .disable = dsi_bridge_disable,
+};
+
+static void dsi_bridge_init(struct dsi_data *dsi)
+{
+   dsi->bridge.fun

[PATCH v3 38/56] drm/omap: panel-dsi-cm: fix remove()

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Do not try to reset the panel after DSI has been
detached, since the DSI clocks may have been disabled
at this point. The panel will be disabled and unprepared
before being removed and a reset will be done when being
probed again.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 086c7d71fe17..795db22d148d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -622,9 +622,6 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
if (ddata->extbldev)
put_device(&ddata->extbldev->dev);
 
-   /* reset, to be sure that the panel is in a valid state */
-   dsicm_hw_reset(ddata);
-
return 0;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 48/56] drm/omap: drop dssdev display field

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

All displays are using drm_panel instead off dssdev
now, so this field is always 0 and can be dropped.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/base.c| 2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 6 --
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index d62713b241d2..d9a5e7b9d401 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -198,7 +198,7 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
}
 
if (!dst->id && !omapdss_device_is_connected(dst)) {
-   WARN_ON(!dst->display);
+   WARN_ON(1);
return;
}
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 916c55101629..c2199c4946ec 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -298,12 +298,6 @@ struct omap_dss_device {
 */
enum omap_display_type type;
 
-   /*
-* True if the device is a display (panel or connector) at the end of
-* the pipeline, false otherwise.
-*/
-   bool display;
-
const char *name;
 
const struct omap_dss_device_ops *ops;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 42/56] drm/omap: remove legacy DSS device operations

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

All DSS devices have been converted to bridge API, so
the device operations are always NULL. This removes
the device ops function pointers and all code using it.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/base.c   | 66 
 drivers/gpu/drm/omapdrm/dss/dss.c|  8 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h| 34 
 drivers/gpu/drm/omapdrm/omap_connector.c | 29 ---
 drivers/gpu/drm/omapdrm/omap_encoder.c   | 40 --
 5 files changed, 177 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 8e08c49b4f97..c2791305c332 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -161,8 +161,6 @@ int omapdss_device_connect(struct dss_device *dss,
   struct omap_dss_device *src,
   struct omap_dss_device *dst)
 {
-   int ret;
-
dev_dbg(&dss->pdev->dev, "connect(%s, %s)\n",
src ? dev_name(src->dev) : "NULL",
dst ? dev_name(dst->dev) : "NULL");
@@ -181,14 +179,6 @@ int omapdss_device_connect(struct dss_device *dss,
 
dst->dss = dss;
 
-   if (dst->ops && dst->ops->connect) {
-   ret = dst->ops->connect(src, dst);
-   if (ret < 0) {
-   dst->dss = NULL;
-   return ret;
-   }
-   }
-
return 0;
 }
 EXPORT_SYMBOL_GPL(omapdss_device_connect);
@@ -212,66 +202,10 @@ void omapdss_device_disconnect(struct omap_dss_device 
*src,
return;
}
 
-   WARN_ON(dst->state != OMAP_DSS_DISPLAY_DISABLED);
-
-   if (dst->ops && dst->ops->disconnect)
-   dst->ops->disconnect(src, dst);
dst->dss = NULL;
 }
 EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
 
-void omapdss_device_pre_enable(struct omap_dss_device *dssdev)
-{
-   if (!dssdev)
-   return;
-
-   omapdss_device_pre_enable(dssdev->next);
-
-   if (dssdev->ops && dssdev->ops->pre_enable)
-   dssdev->ops->pre_enable(dssdev);
-}
-EXPORT_SYMBOL_GPL(omapdss_device_pre_enable);
-
-void omapdss_device_enable(struct omap_dss_device *dssdev)
-{
-   if (!dssdev)
-   return;
-
-   if (dssdev->ops && dssdev->ops->enable)
-   dssdev->ops->enable(dssdev);
-
-   omapdss_device_enable(dssdev->next);
-
-   dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
-}
-EXPORT_SYMBOL_GPL(omapdss_device_enable);
-
-void omapdss_device_disable(struct omap_dss_device *dssdev)
-{
-   if (!dssdev)
-   return;
-
-   omapdss_device_disable(dssdev->next);
-
-   if (dssdev->ops && dssdev->ops->disable)
-   dssdev->ops->disable(dssdev);
-}
-EXPORT_SYMBOL_GPL(omapdss_device_disable);
-
-void omapdss_device_post_disable(struct omap_dss_device *dssdev)
-{
-   if (!dssdev)
-   return;
-
-   if (dssdev->ops && dssdev->ops->post_disable)
-   dssdev->ops->post_disable(dssdev);
-
-   omapdss_device_post_disable(dssdev->next);
-
-   dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
-}
-EXPORT_SYMBOL_GPL(omapdss_device_post_disable);
-
 /* 
-
  * Components Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 6e86f4e67a2c..6a160138bf88 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1565,15 +1565,7 @@ static int dss_remove(struct platform_device *pdev)
 
 static void dss_shutdown(struct platform_device *pdev)
 {
-   struct omap_dss_device *dssdev = NULL;
-
DSSDBG("shutdown\n");
-
-   for_each_dss_output(dssdev) {
-   if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE &&
-   dssdev->ops && dssdev->ops->disable)
-   dssdev->ops->disable(dssdev);
-   }
 }
 
 static int dss_runtime_suspend(struct device *dev)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 42d1ec3aaf0c..5d6edec5a427 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -123,11 +123,6 @@ enum omap_dss_dsi_mode {
OMAP_DSS_DSI_VIDEO_MODE,
 };
 
-enum omap_dss_display_state {
-   OMAP_DSS_DISPLAY_DISABLED = 0,
-   OMAP_DSS_DISPLAY_ACTIVE,
-};
-
 enum omap_dss_rotation_type {
OMAP_DSS_ROT_NONE   = 0,
OMAP_DSS_ROT_TILER  = 1 << 0,
@@ -281,24 +276,6 @@ struct omapdss_dsi_ops {
 };
 
 struct omap_dss_device_ops {
-   int (*connect)(struct omap_dss

[PATCH v3 43/56] drm/omap: remove unused omap_connector

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Remove unused code. Connectors are now created via drm_bridge_connector_init()
and no longer OMAP specific.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/Makefile |   1 -
 drivers/gpu/drm/omapdrm/omap_connector.c | 128 ---
 drivers/gpu/drm/omapdrm/omap_connector.h |  28 -
 drivers/gpu/drm/omapdrm/omap_drv.c   |  19 ++--
 drivers/gpu/drm/omapdrm/omap_drv.h   |   1 -
 drivers/gpu/drm/omapdrm/omap_encoder.c   |  11 --
 6 files changed, 6 insertions(+), 182 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/omap_connector.c
 delete mode 100644 drivers/gpu/drm/omapdrm/omap_connector.h

diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index 66a73eae6f7c..2a404e045b78 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -12,7 +12,6 @@ omapdrm-y := omap_drv.o \
omap_crtc.o \
omap_plane.o \
omap_encoder.o \
-   omap_connector.o \
omap_fb.o \
omap_gem.o \
omap_gem_dmabuf.o \
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c 
b/drivers/gpu/drm/omapdrm/omap_connector.c
deleted file mode 100644
index c6d9b4268841..
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ /dev/null
@@ -1,128 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- * Author: Rob Clark 
- */
-
-#include 
-#include 
-#include 
-
-#include "omap_drv.h"
-
-/*
- * connector funcs
- */
-
-#define to_omap_connector(x) container_of(x, struct omap_connector, base)
-
-struct omap_connector {
-   struct drm_connector base;
-   struct omap_dss_device *output;
-};
-
-static enum drm_connector_status omap_connector_detect(
-   struct drm_connector *connector, bool force)
-{
-   return connector_status_connected;
-}
-
-static void omap_connector_destroy(struct drm_connector *connector)
-{
-   struct omap_connector *omap_connector = to_omap_connector(connector);
-
-   DBG("%s", connector->name);
-
-   drm_connector_unregister(connector);
-   drm_connector_cleanup(connector);
-
-   omapdss_device_put(omap_connector->output);
-
-   kfree(omap_connector);
-}
-
-static int omap_connector_get_modes(struct drm_connector *connector)
-{
-   DBG("%s", connector->name);
-
-   /* We can't retrieve modes. The KMS core will add the default modes. */
-   return 0;
-}
-
-enum drm_mode_status omap_connector_mode_fixup(struct omap_dss_device *dssdev,
-   const struct drm_display_mode *mode,
-   struct drm_display_mode *adjusted_mode)
-{
-   return MODE_OK;
-}
-
-static enum drm_mode_status omap_connector_mode_valid(struct drm_connector 
*connector,
-struct drm_display_mode *mode)
-{
-   struct omap_connector *omap_connector = to_omap_connector(connector);
-   struct drm_display_mode new_mode = {};
-   enum drm_mode_status status;
-
-   status = omap_connector_mode_fixup(omap_connector->output, mode,
-  &new_mode);
-   if (status != MODE_OK)
-   goto done;
-
-   /* Check if vrefresh is still valid. */
-   if (drm_mode_vrefresh(mode) != drm_mode_vrefresh(&new_mode))
-   status = MODE_NOCLOCK;
-
-done:
-   DBG("connector: mode %s: " DRM_MODE_FMT,
-   (status == MODE_OK) ? "valid" : "invalid",
-   DRM_MODE_ARG(mode));
-
-   return status;
-}
-
-static const struct drm_connector_funcs omap_connector_funcs = {
-   .reset = drm_atomic_helper_connector_reset,
-   .detect = omap_connector_detect,
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = omap_connector_destroy,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-static const struct drm_connector_helper_funcs omap_connector_helper_funcs = {
-   .get_modes = omap_connector_get_modes,
-   .mode_valid = omap_connector_mode_valid,
-};
-
-/* initialize connector */
-struct drm_connector *omap_connector_init(struct drm_device *dev,
- struct omap_dss_device *output,
- struct drm_encoder *encoder)
-{
-   struct drm_connector *connector = NULL;
-   struct omap_connector *omap_connector;
-
-   DBG("%s", output->name);
-
-   omap_connector = kzalloc(sizeof(*omap_connector), GFP_KERNEL);
-   if (!omap_connector)
-   goto fail;
-
-   omap_connector->output = omapdss_device_get(output);
-
-   connector = &omap_connector->base;
-   c

[PATCH v3 39/56] drm/omap: remove global dss_device variable

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

We can simply provide the device to the omapdrm driver
via pdata. omapdss_is_initialized() is no longer required
(even before this patch), since omapdrm device is only
registered after the pointer is initialized.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/base.c| 14 --
 drivers/gpu/drm/omapdrm/dss/dss.c |  9 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  9 +++--
 drivers/gpu/drm/omapdrm/omap_drv.c|  6 ++
 4 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 455b410f7401..8e08c49b4f97 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -16,20 +16,6 @@
 #include "dss.h"
 #include "omapdss.h"
 
-static struct dss_device *dss_device;
-
-struct dss_device *omapdss_get_dss(void)
-{
-   return dss_device;
-}
-EXPORT_SYMBOL(omapdss_get_dss);
-
-void omapdss_set_dss(struct dss_device *dss)
-{
-   dss_device = dss;
-}
-EXPORT_SYMBOL(omapdss_set_dss);
-
 struct dispc_device *dispc_get_dispc(struct dss_device *dss)
 {
return dss->dispc;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 6ccbc29c4ce4..6e86f4e67a2c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1305,6 +1305,7 @@ static int dss_bind(struct device *dev)
 {
struct dss_device *dss = dev_get_drvdata(dev);
struct platform_device *drm_pdev;
+   struct dss_pdata pdata;
int r;
 
r = component_bind_all(dev, NULL);
@@ -1313,9 +1314,9 @@ static int dss_bind(struct device *dev)
 
pm_set_vt_switch(0);
 
-   omapdss_set_dss(dss);
-
-   drm_pdev = platform_device_register_simple("omapdrm", 0, NULL, 0);
+   pdata.dss = dss;
+   drm_pdev = platform_device_register_data(NULL, "omapdrm", 0,
+&pdata, sizeof(pdata));
if (IS_ERR(drm_pdev)) {
component_unbind_all(dev, NULL);
return PTR_ERR(drm_pdev);
@@ -1332,8 +1333,6 @@ static void dss_unbind(struct device *dev)
 
platform_device_unregister(dss->drm_pdev);
 
-   omapdss_set_dss(NULL);
-
component_unbind_all(dev, NULL);
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 3ee3063b6a2d..42d1ec3aaf0c 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -356,12 +356,9 @@ struct omap_dss_device {
unsigned int of_port;
 };
 
-struct dss_device *omapdss_get_dss(void);
-void omapdss_set_dss(struct dss_device *dss);
-static inline bool omapdss_is_initialized(void)
-{
-   return !!omapdss_get_dss();
-}
+struct dss_pdata {
+   struct dss_device *dss;
+};
 
 void omapdss_display_init(struct omap_dss_device *dssdev);
 int omapdss_display_get_modes(struct drm_connector *connector,
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 53d5e184ee77..b342f5b6ced0 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -577,6 +577,7 @@ static const struct soc_device_attribute 
omapdrm_soc_devices[] = {
 static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 {
const struct soc_device_attribute *soc;
+   struct dss_pdata *pdata = dev->platform_data;
struct drm_device *ddev;
int ret;
 
@@ -591,7 +592,7 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
ddev->dev_private = priv;
 
priv->dev = dev;
-   priv->dss = omapdss_get_dss();
+   priv->dss = pdata->dss;
priv->dispc = dispc_get_dispc(priv->dss);
priv->dispc_ops = dispc_get_ops(priv->dss);
 
@@ -686,9 +687,6 @@ static int pdev_probe(struct platform_device *pdev)
struct omap_drm_private *priv;
int ret;
 
-   if (omapdss_is_initialized() == false)
-   return -EPROBE_DEFER;
-
ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(&pdev->dev, "Failed to set the DMA mask\n");
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 31/56] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Complete the direction reversal of the DSS device enable/disable
operations started by 19b4200d8f4b ("drm/omap: Reverse direction
of the DSS device enable/disable operations").

This effectively drops the requirement of calling DSS specific
code from the DSI panel driver moving it a bit further to a
standard drm_panel driver.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 74 +--
 drivers/gpu/drm/omapdrm/omap_encoder.c| 24 ++
 2 files changed, 45 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 1582960f9e90..45d417870498 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -288,27 +288,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
struct omap_dss_device *src = ddata->src;
u8 id1, id2, id3;
int r;
-   struct omap_dss_dsi_config dsi_config = {
-   .vm = &ddata->vm,
-   .hs_clk_min = 15000,
-   .hs_clk_max = 3,
-   .lp_clk_min = 700,
-   .lp_clk_max = 1000,
-   };
-
-   r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-   if (r) {
-   dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
-   return r;
-   }
-
-   r = src->ops->dsi.set_config(src, &dsi_config);
-   if (r) {
-   dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
-   goto err_regulators;
-   }
-
-   src->ops->enable(src);
 
dsicm_hw_reset(ddata);
 
@@ -363,12 +342,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
-   src->ops->disable(src);
-err_regulators:
-   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-   if (r)
-   dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", 
r);
-
return r;
 }
 
@@ -377,6 +350,8 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
struct omap_dss_device *src = ddata->src;
int r;
 
+   ddata->enabled = false;
+
src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
 
r = mipi_dsi_dcs_set_display_off(ddata->dsi);
@@ -388,14 +363,6 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
"error disabling panel, issuing HW reset\n");
dsicm_hw_reset(ddata);
}
-
-   src->ops->disable(src);
-
-   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-   if (r)
-   dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", 
r);
-
-   ddata->enabled = false;
 }
 
 static int dsicm_connect(struct omap_dss_device *src,
@@ -415,6 +382,29 @@ static void dsicm_disconnect(struct omap_dss_device *src,
ddata->src = NULL;
 }
 
+static void dsicm_pre_enable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *src = ddata->src;
+   int r;
+   struct omap_dss_dsi_config dsi_config = {
+   .vm = &ddata->vm,
+   .hs_clk_min = 15000,
+   .hs_clk_max = 3,
+   .lp_clk_min = 700,
+   .lp_clk_max = 1000,
+   };
+
+   r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r)
+   dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
+
+   r = src->ops->dsi.set_config(src, &dsi_config);
+   if (r) {
+   dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
+   }
+}
+
 static void dsicm_enable(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
@@ -449,6 +439,16 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
mutex_unlock(&ddata->lock);
 }
 
+static void dsicm_post_disable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   int r;
+
+   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r)
+   dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", 
r);
+}
+
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
struct mipi_dsi_device *dsi = ddata->dsi;
@@ -502,8 +502,10 @@ static const struct omap_dss_device_ops dsicm_ops = {
.connect= dsicm_connect,
.disconnect = dsicm_disconnect,
 
+   .pre_enable

[PATCH v3 10/56] drm/omap: dsi: simplify write function

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Simplify the write related messages handling by using the functionality
provided by CONFIG_DRM_MIPI_DSI.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/Kconfig |   1 +
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 146 +++-
 2 files changed, 34 insertions(+), 113 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig 
b/drivers/gpu/drm/omapdrm/dss/Kconfig
index 2658c521b702..fd7dfa28ce97 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -95,6 +95,7 @@ config OMAP2_DSS_SDI
 config OMAP2_DSS_DSI
bool "DSI support"
default n
+   select DRM_MIPI_DSI
help
  MIPI DSI (Display Serial Interface) support.
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 348be32505a2..e1595c0608f2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2696,97 +2696,50 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int 
channel)
return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0);
 }
 
-static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
- const u8 *data, int len,
- enum dss_dsi_content_type type)
-{
-   int r;
-
-   if (len == 0) {
-   BUG_ON(type == DSS_DSI_CONTENT_DCS);
-   r = dsi_vc_send_short(dsi, channel,
-   MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM, 0, 0);
-   } else if (len == 1) {
-   r = dsi_vc_send_short(dsi, channel,
-   type == DSS_DSI_CONTENT_GENERIC ?
-   MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM :
-   MIPI_DSI_DCS_SHORT_WRITE, data[0], 0);
-   } else if (len == 2) {
-   r = dsi_vc_send_short(dsi, channel,
-   type == DSS_DSI_CONTENT_GENERIC ?
-   MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM :
-   MIPI_DSI_DCS_SHORT_WRITE_PARAM,
-   data[0] | (data[1] << 8), 0);
-   } else {
-   r = dsi_vc_send_long(dsi, channel,
-   type == DSS_DSI_CONTENT_GENERIC ?
-   MIPI_DSI_GENERIC_LONG_WRITE :
-   MIPI_DSI_DCS_LONG_WRITE, data, len, 0);
-   }
-
-   return r;
-}
-
-static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len)
+static int dsi_vc_write_common(struct omap_dss_device *dssdev,
+  const struct mipi_dsi_msg *msg)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
+   struct mipi_dsi_packet packet;
+   int r;
 
-   return dsi_vc_write_nosync_common(dsi, channel, data, len,
-   DSS_DSI_CONTENT_DCS);
-}
+   r = mipi_dsi_create_packet(&packet, msg);
+   if (r < 0)
+   return r;
 
-static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int 
channel,
-   const u8 *data, int len)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
+   if (mipi_dsi_packet_format_is_short(msg->type)) {
+   u16 data = packet.header[1] | (packet.header[2] << 8);
 
-   return dsi_vc_write_nosync_common(dsi, channel, data, len,
-   DSS_DSI_CONTENT_GENERIC);
-}
+   r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
+   } else {
+   r = dsi_vc_send_long(dsi, msg->channel, msg->type,
+msg->tx_buf, msg->tx_len, 0);
+   }
 
-static int dsi_vc_write_common(struct omap_dss_device *dssdev,
-  int channel, const u8 *data, int len,
-  enum dss_dsi_content_type type)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-   int r;
+   if (r < 0)
+   return r;
 
-   r = dsi_vc_write_nosync_common(dsi, channel, data, len, type);
-   if (r)
-   goto err;
+   /*
+* TODO: we do not always have to do the BTA sync, for example
+* we can improve performance by setting the update window
+* information without sending BTA sync between the commands.
+* In that case we can return early.
+*/
 
-   r = dsi_vc_send_bta_sync(dssdev, channel);
-   if (r)
-   goto err;
+   r = dsi_vc_send_bta_sync(dssdev, msg->channel);
+   if (r) {
+   DSSERR("bta sync failed\n");
+   return r;
+   }
 
/* RX_FIFO_NOT_EMPTY */
-   if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
+   if (REG_GET(dsi, DSI_VC_CTRL(msg->channel), 20, 20)) {
 

[PATCH v3 00/56] Convert DSI code to use drm_mipi_dsi and drm_panel

2020-11-05 Thread Tomi Valkeinen
Hi,

This is third version of the series sent by Sebastian in February:

https://www.spinics.net/lists/linux-omap/msg153465.html

I took the patches from his git tree, and rebased on 5.10-rc2. There
were some conflicts and compilation errors, and one bug that made dsi to
not work (videomode variable was not initialized to 0).

I then fixed the few checkpatch and sparse issues. Overall, Sebastian's
patches are pretty much as they were previously. I did drop Laurent's
reviewed-bys, as it's been a long time since the previous series, and
the patches are not identical anyway.

The topmost 5 patches are new ones, cleanups enabled by the DSI
conversion. They could be handled separately, but it's such a nice
cleanup, and I've been waiting for years to get this done, so here they
are. That said, there are still a _lot_ of cleanups to do.

Almost all of the patches are omapdrm changes. The two non-omapdrm
changes are:
- After converting panel-dsi-cm to common DRM panel model, it is moved
  to drm's panel directory.
- Add MIPI_DSI_MODE_ULPS_IDLE flag

I have tested these with OMAP4 SDP, AM5 EVM and OMAP4 Panda. SDP has
command mode panel, and I don't have any videomode panels.

Sebastian, I hope you're ok with all this? I did send you an email, but
didn't get a reply yet, so I thought to just proceed. If you want to
handle this in some other way, or don't want your
authorship/signed-off-by in some of the commits, just tell.

 Tomi

Sebastian Reichel (51):
  drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE
  Revert "drm/omap: dss: Remove unused omap_dss_device operations"
  drm/omap: drop unused dsi.configure_pins
  drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*
  drm/omap: constify write buffers
  drm/omap: dsi: add generic transfer function
  drm/omap: panel-dsi-cm: convert to transfer API
  drm/omap: dsi: unexport specific data transfer functions
  drm/omap: dsi: drop virtual channel logic
  drm/omap: dsi: simplify write function
  drm/omap: dsi: simplify read functions
  drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg
  drm/omap: dsi: introduce mipi_dsi_host
  drm/omap: panel-dsi-cm: use DSI helpers
  drm/omap: dsi: request VC via mipi_dsi_attach
  drm/omap: panel-dsi-cm: drop hardcoded VC
  drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines
  drm/omap: dsi: drop unused memory_read()
  drm/omap: dsi: drop unused get_te()
  drm/omap: dsi: drop unused enable_te()
  drm/omap: dsi: drop useless sync()
  drm/omap: dsi: use pixel-format and mode from attach
  drm/omap: panel-dsi-cm: use bulk regulator API
  drm/omap: dsi: lp/hs switching support for transfer()
  drm/omap: dsi: move TE GPIO handling into core
  drm/omap: dsi: drop custom enable_te() API
  drm/omap: dsi: do bus locking in host driver
  drm/omap: dsi: untangle ulps ops from enable/disable
  drm/omap: dsi: do ULPS in host driver
  drm/omap: dsi: move panel refresh function to host
  drm/omap: dsi: Reverse direction of the DSS device enable/disable
operations
  drm/omap: dsi: drop custom panel capability support
  drm/omap: dsi: convert to drm_panel
  drm/omap: drop omapdss-boot-init
  drm/omap: dsi: implement check timings
  drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO
  drm/omap: panel-dsi-cm: support unbinding
  drm/omap: panel-dsi-cm: fix remove()
  drm/omap: remove global dss_device variable
  drm/panel: Move OMAP's DSI command mode panel driver
  drm/omap: dsi: Register a drm_bridge
  drm/omap: remove legacy DSS device operations
  drm/omap: remove unused omap_connector
  drm/omap: simplify omap_display_id
  drm/omap: drop unused DSS next pointer
  drm/omap: drop empty omap_encoder helper functions
  drm/omap: drop DSS ops_flags
  drm/omap: drop dssdev display field
  drm/omap: simplify DSI manual update code
  drm/omap: dsi: simplify pin config
  ARM: omap2plus_defconfig: Update for moved DSI command mode panel

Tomi Valkeinen (5):
  drm/omap: squash omapdrm sub-modules into one
  drm/omap: remove unused display.c
  drm/omap: drop unused owner field
  drm/omap: remove dispc_ops
  drm/omap: remove dss_mgr_ops

 arch/arm/configs/omap2plus_defconfig  |2 +-
 drivers/gpu/drm/omapdrm/Kconfig   |  120 +-
 drivers/gpu/drm/omapdrm/Makefile  |   19 +-
 drivers/gpu/drm/omapdrm/displays/Kconfig  |   10 -
 drivers/gpu/drm/omapdrm/displays/Makefile |2 -
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 1385 -
 drivers/gpu/drm/omapdrm/dss/Kconfig   |  135 --
 drivers/gpu/drm/omapdrm/dss/Makefile  |   20 -
 drivers/gpu/drm/omapdrm/dss/base.c|   87 +-
 drivers/gpu/drm/omapdrm/dss/dispc.c   |  101 +-
 drivers/gpu/drm/omapdrm/dss/display.c |   60 -
 drivers/gpu/drm/omapdrm/dss/dpi.c |1 -
 drivers/gpu/drm/omapdrm/dss/dsi.c | 1069 -
 drivers/gpu/drm/omapdrm/dss/dss.c |   28 +-
 drivers/gpu/drm/omapdrm/dss/dss.h   

[PATCH v3 24/56] drm/omap: dsi: lp/hs switching support for transfer()

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Integrate low-power / high-speed bus switching into transfer
function and drop the omapdrm specific enable_hs() callback.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c |  6 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 10 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h   |  2 --
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 1e742cf798b6..8890ee2ba830 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -269,7 +269,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
return 0;
 
src->ops->enable(src);
-   src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
+   ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
r = _dsicm_enable_te(ddata, true);
if (r) {
@@ -574,7 +574,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
-   src->ops->dsi.enable_hs(src, ddata->dsi->channel, false);
+   ddata->dsi->mode_flags |= MIPI_DSI_MODE_LPM;
 
r = dsicm_sleep_out(ddata);
if (r)
@@ -617,7 +617,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
ddata->intro_printed = true;
}
 
-   src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
+   ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
return 0;
 err:
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index e341aca92462..003d26cead5a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -329,6 +329,7 @@ struct dsi_data {
int irq;
 
bool is_enabled;
+   bool in_lp_mode;
 
struct clk *dss_clk;
struct regmap *syscon;
@@ -2431,6 +2432,8 @@ static void dsi_vc_enable_hs(struct omap_dss_device 
*dssdev, int channel,
/* start the DDR clock by sending a NULL packet */
if (dsi->vm_timings.ddr_clk_always_on && enable)
dsi_vc_send_null(dsi, channel);
+
+   dsi->in_lp_mode = !enable;
 }
 
 static void dsi_vc_flush_long_data(struct dsi_data *dsi, int channel)
@@ -4693,6 +4696,11 @@ static ssize_t omap_dsi_host_transfer(struct 
mipi_dsi_host *host,
struct dsi_data *dsi = host_to_omap(host);
struct omap_dss_device *dssdev = &dsi->output;
 
+   if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode) {
+   dsi_vc_enable_hs(dssdev, msg->channel,
+!(msg->flags & MIPI_DSI_MSG_USE_LPM));
+   }
+
switch (msg->type) {
case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
@@ -4753,8 +4761,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 
.disable = dsi_display_disable,
 
-   .enable_hs = dsi_vc_enable_hs,
-
.set_config = dsi_set_config,
 
.enable_video_output = dsi_enable_video_output,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9bbd2c0f3187..2d44a8e32fcc 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -288,8 +288,6 @@ struct omapdss_dsi_ops {
int (*set_config)(struct omap_dss_device *dssdev,
const struct omap_dss_dsi_config *cfg);
 
-   void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
-   bool enable);
int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
 
int (*update)(struct omap_dss_device *dssdev, int channel,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 06/56] drm/omap: dsi: add generic transfer function

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This prepares the driver for becoming a mipi_dsi_host implementation,
which provides a generic transfer function instead of all kind of
different read/write functions. The implementation will become more
elegant after unexporting the specific functions in the following
patches.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 54 +++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ++
 2 files changed, 57 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 22d74d762a10..59a62d1d41cb 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4842,6 +4842,58 @@ static void dsi_release_vc(struct omap_dss_device 
*dssdev, int channel)
}
 }
 
+static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev,
+const struct mipi_dsi_msg *msg)
+{
+   /*
+* no_sync can be used to optimize performance by sending e.g. column
+* and page information without syncing in between. It's not absolutley
+* required, so postpone this feature for now.
+*/
+   bool no_sync = false;
+   u16 val;
+
+   switch (msg->type) {
+   case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
+   case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
+   case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
+   case MIPI_DSI_GENERIC_LONG_WRITE:
+   if (no_sync)
+   return dsi_vc_generic_write_nosync(dssdev, msg->channel,
+  msg->tx_buf,
+  msg->tx_len);
+   else
+   return dsi_vc_generic_write(dssdev, msg->channel,
+   msg->tx_buf, msg->tx_len);
+   case MIPI_DSI_DCS_SHORT_WRITE:
+   case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+   case MIPI_DSI_DCS_LONG_WRITE:
+   if (no_sync)
+   return dsi_vc_dcs_write_nosync(dssdev, msg->channel,
+  msg->tx_buf,
+  msg->tx_len);
+   else
+   return dsi_vc_dcs_write(dssdev, msg->channel,
+   msg->tx_buf, msg->tx_len);
+   case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+   case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+   case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+   return dsi_vc_generic_read(dssdev, msg->channel,
+  msg->tx_buf, msg->tx_len,
+  msg->rx_buf, msg->rx_len);
+   case MIPI_DSI_DCS_READ:
+   return dsi_vc_dcs_read(dssdev, msg->channel,
+  ((u8 *)msg->tx_buf)[0],
+  msg->rx_buf, msg->rx_len);
+   case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
+   val = le16_to_cpu(*((__le16 *)msg->tx_buf));
+   return dsi_vc_set_max_rx_packet_size(dssdev, msg->channel, val);
+   case MIPI_DSI_NULL_PACKET:
+   return dsi_vc_send_null(to_dsi_data(dssdev), msg->channel);
+   }
+
+   return -EINVAL;
+}
 
 static int dsi_get_clocks(struct dsi_data *dsi)
 {
@@ -4896,6 +4948,8 @@ static const struct omap_dss_device_ops dsi_ops = {
.set_vc_id = dsi_set_vc_id,
.release_vc = dsi_release_vc,
 
+   .transfer = omap_dsi_transfer,
+
.dcs_write = dsi_vc_dcs_write,
.dcs_write_nosync = dsi_vc_dcs_write_nosync,
.dcs_read = dsi_vc_dcs_read,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 8e96ab2f20b6..654618e5a4e5 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -308,6 +308,9 @@ struct omapdss_dsi_ops {
void (*release_vc)(struct omap_dss_device *dssdev, int channel);
 
/* data transfer */
+   ssize_t (*transfer)(struct omap_dss_device *dssdev,
+   const struct mipi_dsi_msg *msg);
+
int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
const u8 *data, int len);
int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 08/56] drm/omap: dsi: unexport specific data transfer functions

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

After converting all DSI drivers, unexport the specific transfer
functions.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 12 
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 20 
 2 files changed, 32 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 59a62d1d41cb..2270730b16db 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4949,18 +4949,6 @@ static const struct omap_dss_device_ops dsi_ops = {
.release_vc = dsi_release_vc,
 
.transfer = omap_dsi_transfer,
-
-   .dcs_write = dsi_vc_dcs_write,
-   .dcs_write_nosync = dsi_vc_dcs_write_nosync,
-   .dcs_read = dsi_vc_dcs_read,
-
-   .gen_write = dsi_vc_generic_write,
-   .gen_write_nosync = dsi_vc_generic_write_nosync,
-   .gen_read = dsi_vc_generic_read,
-
-   .bta_sync = dsi_vc_send_bta_sync,
-
-   .set_max_rx_packet_size = dsi_vc_set_max_rx_packet_size,
},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 654618e5a4e5..9ead877cb24c 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -310,26 +310,6 @@ struct omapdss_dsi_ops {
/* data transfer */
ssize_t (*transfer)(struct omap_dss_device *dssdev,
const struct mipi_dsi_msg *msg);
-
-   int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len);
-   int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len);
-   int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
-   u8 *data, int len);
-
-   int (*gen_write)(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len);
-   int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
-   const u8 *data, int len);
-   int (*gen_read)(struct omap_dss_device *dssdev, int channel,
-   const u8 *reqdata, int reqlen,
-   u8 *data, int len);
-
-   int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
-
-   int (*set_max_rx_packet_size)(struct omap_dss_device *dssdev,
-   int channel, u16 plen);
 };
 
 struct omap_dss_device_ops {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 07/56] drm/omap: panel-dsi-cm: convert to transfer API

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This converts the panel-dsi-cm driver to use the transfer
API instead of specific functions, so that the specific
functions can be unexported and squashed into the generic
transfer function.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 132 +-
 1 file changed, 95 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index b8f3a7aacbf4..8b2e80129bd8 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -140,45 +140,61 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
struct omap_dss_device *src = ddata->src;
-   int r;
-   u8 buf[1];
-
-   r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, buf, 1);
-
-   if (r < 0)
-   return r;
-
-   *data = buf[0];
+   const struct mipi_dsi_msg msg = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_DCS_READ,
+   .tx_len = 1,
+   .tx_buf = &dcs_cmd,
+   .rx_len = 1,
+   .rx_buf = data
+   };
 
-   return 0;
+   return src->ops->dsi.transfer(src, &msg);
 }
 
 static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
 {
struct omap_dss_device *src = ddata->src;
+   const struct mipi_dsi_msg msg = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_DCS_SHORT_WRITE,
+   .tx_buf = &dcs_cmd,
+   .tx_len = 1,
+   };
 
-   return src->ops->dsi.dcs_write(src, ddata->channel, &dcs_cmd, 1);
+   return src->ops->dsi.transfer(src, &msg);
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 
param)
 {
struct omap_dss_device *src = ddata->src;
-   u8 buf[2] = { dcs_cmd, param };
+   const u8 buf[] = { dcs_cmd, param };
+   const struct mipi_dsi_msg msg = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_DCS_SHORT_WRITE_PARAM,
+   .tx_buf = &buf,
+   .tx_len = 2,
+   };
 
-   return src->ops->dsi.dcs_write(src, ddata->channel, buf, 2);
+   return src->ops->dsi.transfer(src, &msg);
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
struct omap_dss_device *src = ddata->src;
-   u8 cmd;
int r;
+   const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
+   const struct mipi_dsi_msg msg = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_DCS_SHORT_WRITE,
+   .tx_buf = &cmd,
+   .tx_len = 1,
+   };
 
hw_guard_wait(ddata);
 
-   cmd = MIPI_DCS_ENTER_SLEEP_MODE;
-   r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, &cmd, 1);
+   r = src->ops->dsi.transfer(src, &msg);
if (r)
return r;
 
@@ -233,28 +249,43 @@ static int dsicm_set_update_window(struct panel_drv_data 
*ddata,
u16 y1 = y;
u16 y2 = y + h - 1;
 
-   u8 buf[5];
-   buf[0] = MIPI_DCS_SET_COLUMN_ADDRESS;
-   buf[1] = (x1 >> 8) & 0xff;
-   buf[2] = (x1 >> 0) & 0xff;
-   buf[3] = (x2 >> 8) & 0xff;
-   buf[4] = (x2 >> 0) & 0xff;
+   const u8 paramX[] = {
+   MIPI_DCS_SET_COLUMN_ADDRESS,
+   (x1 >> 8) & 0xff,
+   (x1 >> 0) & 0xff,
+   (x2 >> 8) & 0xff,
+   (x2 >> 0) & 0xff,
+   };
 
-   r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, 
sizeof(buf));
-   if (r)
-   return r;
+   const struct mipi_dsi_msg msgX = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_GENERIC_LONG_WRITE,
+   .tx_buf = paramX,
+   .tx_len = 5,
+   };
+
+   const u8 paramY[] = {
+   MIPI_DCS_SET_PAGE_ADDRESS,
+   (y1 >> 8) & 0xff,
+   (y1 >> 0) & 0xff,
+   (y2 >> 8) & 0xff,
+   (y2 >> 0) & 0xff,
+   };
 
-   buf[0] = MIPI_DCS_SET_PAGE_ADDRESS;
-   buf[1] = (y1 >> 8) & 0xff;
-   buf[2] = (y1 >> 0) & 0xff;
-   buf[3] = (y2 >> 8) & 0xff;
-   buf[4] = (y2 >> 0) & 0xff;
+   const struct mipi_dsi_msg msgY = {
+   .channel = ddata->channel,
+   .type = MIPI_DSI_GENERIC_LONG_WRITE,
+   .tx_buf = paramY,
+   .tx_len = 5,
+   };
 
-   r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, 
sizeof(buf)

[PATCH v3 11/56] drm/omap: dsi: simplify read functions

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Simplify the read related message handling by using the functionality
provided by CONFIG_DRM_MIPI_DSI.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 110 +-
 1 file changed, 34 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index e1595c0608f2..bbdc52ee3559 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2742,60 +2742,6 @@ static int dsi_vc_write_common(struct omap_dss_device 
*dssdev,
return 0;
 }
 
-static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel,
-   u8 dcs_cmd)
-{
-   int r;
-
-   if (dsi->debug_read)
-   DSSDBG("dsi_vc_dcs_send_read_request(ch%d, dcs_cmd %x)\n",
-   channel, dcs_cmd);
-
-   r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
-   if (r) {
-   DSSERR("dsi_vc_dcs_send_read_request(ch %d, cmd 0x%02x)"
-   " failed\n", channel, dcs_cmd);
-   return r;
-   }
-
-   return 0;
-}
-
-static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel,
-   const u8 *reqdata, int reqlen)
-{
-   u16 data;
-   u8 data_type;
-   int r;
-
-   if (dsi->debug_read)
-   DSSDBG("dsi_vc_generic_send_read_request(ch %d, reqlen %d)\n",
-   channel, reqlen);
-
-   if (reqlen == 0) {
-   data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
-   data = 0;
-   } else if (reqlen == 1) {
-   data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
-   data = reqdata[0];
-   } else if (reqlen == 2) {
-   data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
-   data = reqdata[0] | (reqdata[1] << 8);
-   } else {
-   BUG();
-   return -EINVAL;
-   }
-
-   r = dsi_vc_send_short(dsi, channel, data_type, data, 0);
-   if (r) {
-   DSSERR("dsi_vc_generic_send_read_request(ch %d, reqlen %d)"
-   " failed\n", channel, reqlen);
-   return r;
-   }
-
-   return 0;
-}
-
 static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
   int buflen, enum dss_dsi_content_type type)
 {
@@ -2904,13 +2850,18 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, 
int channel, u8 *buf,
return r;
 }
 
-static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 
dcs_cmd,
-   u8 *buf, int buflen)
+static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
+  const struct mipi_dsi_msg *msg)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
+   u8 dcs_cmd = ((u8 *)msg->tx_buf)[0];
+   u8 channel = msg->channel;
int r;
 
-   r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
+   if (dsi->debug_read)
+   DSSDBG("%s(ch %d, cmd %x)\n", __func__, channel, dcs_cmd);
+
+   r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
if (r)
goto err;
 
@@ -2918,47 +2869,58 @@ static int dsi_vc_dcs_read(struct omap_dss_device 
*dssdev, int channel, u8 dcs_c
if (r)
goto err;
 
-   r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
+   r = dsi_vc_read_rx_fifo(dsi, channel, msg->rx_buf, msg->rx_len,
DSS_DSI_CONTENT_DCS);
if (r < 0)
goto err;
 
-   if (r != buflen) {
+   if (r != msg->rx_len) {
r = -EIO;
goto err;
}
 
return 0;
 err:
-   DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n", channel, dcs_cmd);
+   DSSERR("%s(ch %d, cmd 0x%02x) failed\n", __func__, msg->channel, 
dcs_cmd);
return r;
 }
 
-static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
-   const u8 *reqdata, int reqlen, u8 *buf, int buflen)
+static int dsi_vc_generic_read(struct omap_dss_device *dssdev,
+  const struct mipi_dsi_msg *msg)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
+   struct mipi_dsi_packet packet;
+   u16 data;
int r;
 
-   r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen);
+   r = mipi_dsi_create_packet(&packet, msg);
+   if (r < 0)
+   goto err;
+
+   data = packet.header[1] | (packet.header[2] << 8);
+
+   r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
if (r)
-   return r;
+   goto err;
 
-   r = dsi_vc_send_bta_sync(dssdev, channel);
+   r =

[PATCH v3 16/56] drm/omap: panel-dsi-cm: drop hardcoded VC

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Use dsi->channel everywhere, which originates from DT.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 20 +++
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index b1ca9b34ce17..25183744a61d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -27,9 +27,6 @@
 
 #include "../dss/omapdss.h"
 
-/* DSI Virtual channel. Hardcoded for now. */
-#define TCH 0
-
 #define DCS_READ_NUM_ERRORS0x05
 #define DCS_BRIGHTNESS 0x51
 #define DCS_CTRL_DISPLAY   0x53
@@ -73,7 +70,6 @@ struct panel_drv_data {
bool te_enabled;
 
atomic_t do_update;
-   int channel;
 
struct delayed_work te_timeout_work;
 
@@ -274,7 +270,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
return 0;
 
src->ops->enable(src);
-   src->ops->dsi.enable_hs(src, ddata->channel, true);
+   src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
 
r = _dsicm_enable_te(ddata, true);
if (r) {
@@ -591,7 +587,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
dsicm_hw_reset(ddata);
 
-   src->ops->dsi.enable_hs(src, ddata->channel, false);
+   src->ops->dsi.enable_hs(src, ddata->dsi->channel, false);
 
r = dsicm_sleep_out(ddata);
if (r)
@@ -622,7 +618,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = src->ops->dsi.enable_video_output(src, ddata->channel);
+   r = src->ops->dsi.enable_video_output(src, ddata->dsi->channel);
if (r)
goto err;
 
@@ -634,7 +630,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
ddata->intro_printed = true;
}
 
-   src->ops->dsi.enable_hs(src, ddata->channel, true);
+   src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
 
return 0;
 err:
@@ -658,7 +654,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
struct omap_dss_device *src = ddata->src;
int r;
 
-   src->ops->dsi.disable_video_output(src, ddata->channel);
+   src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
 
r = mipi_dsi_dcs_set_display_off(ddata->dsi);
if (!r)
@@ -777,7 +773,7 @@ static irqreturn_t dsicm_te_isr(int irq, void *data)
if (old) {
cancel_delayed_work(&ddata->te_timeout_work);
 
-   r = src->ops->dsi.update(src, ddata->channel, 
dsicm_framedone_cb,
+   r = src->ops->dsi.update(src, ddata->dsi->channel, 
dsicm_framedone_cb,
ddata);
if (r)
goto err;
@@ -834,7 +830,7 @@ static int dsicm_update(struct omap_dss_device *dssdev,
msecs_to_jiffies(250));
atomic_set(&ddata->do_update, 1);
} else {
-   r = src->ops->dsi.update(src, ddata->channel, 
dsicm_framedone_cb,
+   r = src->ops->dsi.update(src, ddata->dsi->channel, 
dsicm_framedone_cb,
ddata);
if (r)
goto err;
@@ -1110,8 +1106,6 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
struct display_timing timing;
int err;
 
-   ddata->channel = TCH;
-
ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(ddata->reset_gpio)) {
err = PTR_ERR(ddata->reset_gpio);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 02/56] Revert "drm/omap: dss: Remove unused omap_dss_device operations"

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This reverts commit 4ff8e98879e6eeae9d125dfcf3b642075d00089d.

This is still needed by DSI. E.g. unloading modules without this will
cause a crash.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/base.c | 26 +++
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  6 
 drivers/gpu/drm/omapdrm/omap_encoder.c | 44 +++---
 3 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index c7650a7c155d..455b410f7401 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -234,6 +234,18 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 }
 EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
 
+void omapdss_device_pre_enable(struct omap_dss_device *dssdev)
+{
+   if (!dssdev)
+   return;
+
+   omapdss_device_pre_enable(dssdev->next);
+
+   if (dssdev->ops && dssdev->ops->pre_enable)
+   dssdev->ops->pre_enable(dssdev);
+}
+EXPORT_SYMBOL_GPL(omapdss_device_pre_enable);
+
 void omapdss_device_enable(struct omap_dss_device *dssdev)
 {
if (!dssdev)
@@ -260,6 +272,20 @@ void omapdss_device_disable(struct omap_dss_device *dssdev)
 }
 EXPORT_SYMBOL_GPL(omapdss_device_disable);
 
+void omapdss_device_post_disable(struct omap_dss_device *dssdev)
+{
+   if (!dssdev)
+   return;
+
+   if (dssdev->ops && dssdev->ops->post_disable)
+   dssdev->ops->post_disable(dssdev);
+
+   omapdss_device_post_disable(dssdev->next);
+
+   dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
+}
+EXPORT_SYMBOL_GPL(omapdss_device_post_disable);
+
 /* 
-
  * Components Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index ab19d4af8de7..cbbe10b2b60d 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -342,11 +342,15 @@ struct omap_dss_device_ops {
void (*disconnect)(struct omap_dss_device *dssdev,
struct omap_dss_device *dst);
 
+   void (*pre_enable)(struct omap_dss_device *dssdev);
void (*enable)(struct omap_dss_device *dssdev);
void (*disable)(struct omap_dss_device *dssdev);
+   void (*post_disable)(struct omap_dss_device *dssdev);
 
int (*check_timings)(struct omap_dss_device *dssdev,
 struct drm_display_mode *mode);
+   void (*set_timings)(struct omap_dss_device *dssdev,
+   const struct drm_display_mode *mode);
 
int (*get_modes)(struct omap_dss_device *dssdev,
 struct drm_connector *connector);
@@ -445,8 +449,10 @@ int omapdss_device_connect(struct dss_device *dss,
   struct omap_dss_device *dst);
 void omapdss_device_disconnect(struct omap_dss_device *src,
   struct omap_dss_device *dst);
+void omapdss_device_pre_enable(struct omap_dss_device *dssdev);
 void omapdss_device_enable(struct omap_dss_device *dssdev);
 void omapdss_device_disable(struct omap_dss_device *dssdev);
+void omapdss_device_post_disable(struct omap_dss_device *dssdev);
 
 int omap_dss_get_num_overlay_managers(void);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c 
b/drivers/gpu/drm/omapdrm/omap_encoder.c
index ae4b867a67a3..18a79dde6815 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -113,8 +113,13 @@ static void omap_encoder_mode_set(struct drm_encoder 
*encoder,
bus_flags = connector->display_info.bus_flags;
omap_encoder_update_videomode_flags(&vm, bus_flags);
 
-   /* Set timings for the dss manager. */
+   /* Set timings for all devices in the display pipeline. */
dss_mgr_set_timings(output, &vm);
+
+   for (dssdev = output; dssdev; dssdev = dssdev->next) {
+   if (dssdev->ops && dssdev->ops->set_timings)
+   dssdev->ops->set_timings(dssdev, adjusted_mode);
+   }
 }
 
 static void omap_encoder_disable(struct drm_encoder *encoder)
@@ -127,10 +132,26 @@ static void omap_encoder_disable(struct drm_encoder 
*encoder)
 
/*
 * Disable the chain of external devices, starting at the one at the
-* internal encoder's output. This is used for DSI outputs only, as
-* dssdev->next is NULL for all other outputs.
+* internal encoder's output.
 */
omapdss_device_disable(dssdev->next);
+
+   /*
+* Disable the internal encoder. This will disable the DSS output. The
+* DSI is treated as an exception as DSI pipelines still use the legacy
+* flow where the pipeline output controls the encoder

[PATCH v3 12/56] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Simplify the DSI encoder by using mipi_dsi_msg for
dsi_vc_send_long and dsi_vc_send_short. Further improvements
require cleaning up the channel allocation code first.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 89 ++-
 1 file changed, 40 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index bbdc52ee3559..6fa7833e32ad 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2599,8 +2599,8 @@ static inline void dsi_vc_write_long_payload(struct 
dsi_data *dsi, int channel,
dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
 }
 
-static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
-   const u8 *data, u16 len, u8 ecc)
+static int dsi_vc_send_long(struct dsi_data *dsi,
+   const struct mipi_dsi_msg *msg)
 {
/*u32 val; */
int i;
@@ -2609,20 +2609,20 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int 
channel, u8 data_type,
u8 b1, b2, b3, b4;
 
if (dsi->debug_write)
-   DSSDBG("dsi_vc_send_long, %d bytes\n", len);
+   DSSDBG("dsi_vc_send_long, %d bytes\n", msg->tx_len);
 
/* len + header */
-   if (dsi->vc[channel].tx_fifo_size * 32 * 4 < len + 4) {
+   if (dsi->vc[msg->channel].tx_fifo_size * 32 * 4 < msg->tx_len + 4) {
DSSERR("unable to send long packet: packet too long.\n");
return -EINVAL;
}
 
-   dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
+   dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
 
-   dsi_vc_write_long_header(dsi, channel, data_type, len, ecc);
+   dsi_vc_write_long_header(dsi, msg->channel, msg->type, msg->tx_len, 0);
 
-   p = data;
-   for (i = 0; i < len >> 2; i++) {
+   p = msg->tx_buf;
+   for (i = 0; i < msg->tx_len >> 2; i++) {
if (dsi->debug_write)
DSSDBG("\tsending full packet %d\n", i);
 
@@ -2631,10 +2631,10 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int 
channel, u8 data_type,
b3 = *p++;
b4 = *p++;
 
-   dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, b4);
+   dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, b4);
}
 
-   i = len % 4;
+   i = msg->tx_len % 4;
if (i) {
b1 = 0; b2 = 0; b3 = 0;
 
@@ -2656,65 +2656,64 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int 
channel, u8 data_type,
break;
}
 
-   dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, 0);
+   dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, 0);
}
 
return r;
 }
 
-static int dsi_vc_send_short(struct dsi_data *dsi, int channel, u8 data_type,
-u16 data, u8 ecc)
+static int dsi_vc_send_short(struct dsi_data *dsi,
+const struct mipi_dsi_msg *msg)
 {
+   struct mipi_dsi_packet pkt;
u32 r;
-   u8 data_id;
+
+   r = mipi_dsi_create_packet(&pkt, msg);
+   if (r < 0)
+   return r;
 
WARN_ON(!dsi_bus_is_locked(dsi));
 
if (dsi->debug_write)
DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
-   channel,
-   data_type, data & 0xff, (data >> 8) & 0xff);
+   msg->channel,
+   msg->type, pkt.header[1], pkt.header[2]);
 
-   dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
+   dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
 
-   if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(channel)), 16, 16)) {
+   if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(msg->channel)), 16, 16)) {
DSSERR("ERROR FIFO FULL, aborting transfer\n");
return -EINVAL;
}
 
-   data_id = data_type | channel << 6;
-
-   r = (data_id << 0) | (data << 8) | (ecc << 24);
+   r = pkt.header[3] << 24 | pkt.header[2] << 16 | pkt.header[1] << 8 |
+   pkt.header[0];
 
-   dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel), r);
+   dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(msg->channel), r);
 
return 0;
 }
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
 {
-   return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0);
+   const struct mipi_dsi_msg msg = {
+   .channel = channel,
+   .type = MIPI_DSI_NULL_PACKET,
+   };
+
+   

[PATCH v3 01/56] drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

DSI command mode panels are self-refreshing displays, that
can be updated very rarely for static images. For this kind
of scenario some panels support, that the DSI bus switches
into ULPS mode until the panel needs to be refreshed.

This is problematic on some panels, so introduce a flag to
signal the DSI host implementation that the panel allows
going into ULPS mode.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 include/drm/drm_mipi_dsi.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 360e6377e84b..f36f89c14b4a 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -132,6 +132,8 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct 
device_node *node);
 #define MIPI_DSI_CLOCK_NON_CONTINUOUS  BIT(10)
 /* transmit data in low power */
 #define MIPI_DSI_MODE_LPM  BIT(11)
+/* allow going into ULPS mode while command mode panel is not updated */
+#define MIPI_DSI_MODE_ULPS_IDLEBIT(12)
 
 enum mipi_dsi_pixel_format {
MIPI_DSI_FMT_RGB888,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 22/56] drm/omap: dsi: use pixel-format and mode from attach

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

In order to reduce the amount of custom functionality, this moves
handling of pixel format and DSI mode from set_config() to dsi
attach.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 --
 drivers/gpu/drm/omapdrm/dss/dsi.c | 31 ---
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index a9609eed6bfa..2e9de33fc8d4 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -550,8 +550,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
u8 id1, id2, id3;
int r;
struct omap_dss_dsi_config dsi_config = {
-   .mode = OMAP_DSS_DSI_CMD_MODE,
-   .pixel_format = MIPI_DSI_FMT_RGB888,
.vm = &ddata->vm,
.hs_clk_min = 15000,
.hs_clk_max = 3,
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a16427f3bc23..e341aca92462 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4579,24 +4579,19 @@ static int dsi_set_config(struct omap_dss_device 
*dssdev,
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
struct dsi_clk_calc_ctx ctx;
+   struct omap_dss_dsi_config cfg = *config;
bool ok;
int r;
 
mutex_lock(&dsi->lock);
 
-   dsi->pix_fmt = config->pixel_format;
-   dsi->mode = config->mode;
+   cfg.mode = dsi->mode;
+   cfg.pixel_format = dsi->pix_fmt;
 
-   if (mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) < 0) {
-   DSSERR("invalid pixel format\n");
-   r = -EINVAL;
-   goto err;
-   }
-
-   if (config->mode == OMAP_DSS_DSI_VIDEO_MODE)
-   ok = dsi_vm_calc(dsi, config, &ctx);
+   if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
+   ok = dsi_vm_calc(dsi, &cfg, &ctx);
else
-   ok = dsi_cm_calc(dsi, config, &ctx);
+   ok = dsi_cm_calc(dsi, &cfg, &ctx);
 
if (!ok) {
DSSERR("failed to find suitable DSI clock settings\n");
@@ -4607,7 +4602,7 @@ static int dsi_set_config(struct omap_dss_device *dssdev,
dsi_pll_calc_dsi_fck(dsi, &ctx.dsi_cinfo);
 
r = dsi_lp_clock_calc(ctx.dsi_cinfo.clkout[HSDIV_DSI],
-   config->lp_clk_min, config->lp_clk_max, &dsi->user_lp_cinfo);
+   cfg.lp_clk_min, cfg.lp_clk_max, &dsi->user_lp_cinfo);
if (r) {
DSSERR("failed to find suitable DSI LP clock settings\n");
goto err;
@@ -4785,7 +4780,19 @@ static int omap_dsi_host_attach(struct mipi_dsi_host 
*host,
return -EBUSY;
}
 
+   if (mipi_dsi_pixel_format_to_bpp(client->format) < 0) {
+   DSSERR("invalid pixel format\n");
+   return -EINVAL;
+   }
+
dsi->vc[channel].dest = client;
+
+   dsi->pix_fmt = client->format;
+   if (client->mode_flags & MIPI_DSI_MODE_VIDEO)
+   dsi->mode = OMAP_DSS_DSI_VIDEO_MODE;
+   else
+   dsi->mode = OMAP_DSS_DSI_CMD_MODE;
+
return 0;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 14/56] drm/omap: panel-dsi-cm: use DSI helpers

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

After converting the driver to mipi_dsi_device we can use the generic
message helpers to simplify the driver a lot.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 125 +++---
 1 file changed, 18 insertions(+), 107 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index c3190223d192..ec36e62ddc3a 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -138,62 +138,22 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   const struct mipi_dsi_msg msg = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_DCS_READ,
-   .tx_len = 1,
-   .tx_buf = &dcs_cmd,
-   .rx_len = 1,
-   .rx_buf = data
-   };
-
-   return dsi->host->ops->transfer(dsi->host, &msg);
-}
-
-static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
-{
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   const struct mipi_dsi_msg msg = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_DCS_SHORT_WRITE,
-   .tx_buf = &dcs_cmd,
-   .tx_len = 1,
-   };
-
-   return dsi->host->ops->transfer(dsi->host, &msg);
+   return mipi_dsi_dcs_read(ddata->dsi, dcs_cmd, data, 1);
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 
param)
 {
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   const u8 buf[] = { dcs_cmd, param };
-   const struct mipi_dsi_msg msg = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_DCS_SHORT_WRITE_PARAM,
-   .tx_buf = &buf,
-   .tx_len = 2,
-   };
-
-   return dsi->host->ops->transfer(dsi->host, &msg);
+   return mipi_dsi_dcs_write(ddata->dsi, dcs_cmd, ¶m, 1);
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
-   struct mipi_dsi_device *dsi = ddata->dsi;
int r;
-   const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
-   const struct mipi_dsi_msg msg = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_DCS_SHORT_WRITE,
-   .tx_buf = &cmd,
-   .tx_len = 1,
-   };
 
hw_guard_wait(ddata);
 
-   r = dsi->host->ops->transfer(dsi->host, &msg);
+   r = mipi_dsi_dcs_enter_sleep_mode(ddata->dsi);
if (r)
return r;
 
@@ -210,7 +170,7 @@ static int dsicm_sleep_out(struct panel_drv_data *ddata)
 
hw_guard_wait(ddata);
 
-   r = dsicm_dcs_write_0(ddata, MIPI_DCS_EXIT_SLEEP_MODE);
+   r = mipi_dsi_dcs_exit_sleep_mode(ddata->dsi);
if (r)
return r;
 
@@ -248,45 +208,15 @@ static int dsicm_set_update_window(struct panel_drv_data 
*ddata,
u16 y1 = y;
u16 y2 = y + h - 1;
 
-   const u8 paramX[] = {
-   MIPI_DCS_SET_COLUMN_ADDRESS,
-   (x1 >> 8) & 0xff,
-   (x1 >> 0) & 0xff,
-   (x2 >> 8) & 0xff,
-   (x2 >> 0) & 0xff,
-   };
-
-   const struct mipi_dsi_msg msgX = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_GENERIC_LONG_WRITE,
-   .tx_buf = paramX,
-   .tx_len = 5,
-   };
-
-   const u8 paramY[] = {
-   MIPI_DCS_SET_PAGE_ADDRESS,
-   (y1 >> 8) & 0xff,
-   (y1 >> 0) & 0xff,
-   (y2 >> 8) & 0xff,
-   (y2 >> 0) & 0xff,
-   };
-
-   const struct mipi_dsi_msg msgY = {
-   .channel = ddata->channel,
-   .type = MIPI_DSI_GENERIC_LONG_WRITE,
-   .tx_buf = paramY,
-   .tx_len = 5,
-   };
-
-   r = dsi->host->ops->transfer(dsi->host, &msgX);
-   if (r)
+   r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
+   if (r < 0)
return r;
 
-   r = dsi->host->ops->transfer(dsi->host, &msgY);
-   if (r)
+   r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
+   if (r < 0)
return r;
 
-   return r;
+   return 0;
 }
 
 static void dsicm_queue_ulps_work(struct panel_drv_data *ddata)
@@ -680,12 +610,11 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_PIXEL_FORMAT,
-   MIPI_DCS_PIXEL_FMT_24BIT);
+   r = mipi_dsi_dcs_set_pixel_format(ddata->dsi, MIPI_DCS_PIXEL_FMT_24BIT);
  

[PATCH v3 09/56] drm/omap: dsi: drop virtual channel logic

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This drops the virtual channel logic. Afterwards DSI clients
request their channel number and get the virtual channel with
the same number or -EBUSY if already in use.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 11 ++---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 46 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 +-
 3 files changed, 12 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 8b2e80129bd8..ea76a89d1833 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -768,19 +768,12 @@ static int dsicm_connect(struct omap_dss_device *src,
struct device *dev = &ddata->pdev->dev;
int r;
 
-   r = src->ops->dsi.request_vc(src, &ddata->channel);
+   r = src->ops->dsi.request_vc(src, ddata->channel);
if (r) {
dev_err(dev, "failed to get virtual channel\n");
return r;
}
 
-   r = src->ops->dsi.set_vc_id(src, ddata->channel, TCH);
-   if (r) {
-   dev_err(dev, "failed to set VC_ID\n");
-   src->ops->dsi.release_vc(src, ddata->channel);
-   return r;
-   }
-
ddata->src = src;
return 0;
 }
@@ -1215,6 +1208,8 @@ static int dsicm_probe_of(struct platform_device *pdev)
struct display_timing timing;
int err;
 
+   ddata->channel = TCH;
+
ddata->reset_gpio = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(ddata->reset_gpio)) {
err = PTR_ERR(ddata->reset_gpio);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 2270730b16db..348be32505a2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -350,7 +350,6 @@ struct dsi_data {
struct omap_dss_device *dssdev;
enum fifo_size tx_fifo_size;
enum fifo_size rx_fifo_size;
-   int vc_id;
} vc[4];
 
struct mutex lock;
@@ -2579,7 +2578,7 @@ static inline void dsi_vc_write_long_header(struct 
dsi_data *dsi, int channel,
 
WARN_ON(!dsi_bus_is_locked(dsi));
 
-   data_id = data_type | dsi->vc[channel].vc_id << 6;
+   data_id = data_type | channel << 6;
 
val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
FLD_VAL(ecc, 31, 24);
@@ -2683,7 +2682,7 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int 
channel, u8 data_type,
return -EINVAL;
}
 
-   data_id = data_type | dsi->vc[channel].vc_id << 6;
+   data_id = data_type | channel << 6;
 
r = (data_id << 0) | (data << 8) | (ecc << 24);
 
@@ -4789,45 +4788,19 @@ static enum omap_channel dsi_get_channel(struct 
dsi_data *dsi)
}
 }
 
-static int dsi_request_vc(struct omap_dss_device *dssdev, int *channel)
+static int dsi_request_vc(struct omap_dss_device *dssdev, int channel)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
-   if (!dsi->vc[i].dssdev) {
-   dsi->vc[i].dssdev = dssdev;
-   *channel = i;
-   return 0;
-   }
-   }
 
-   DSSERR("cannot get VC for display %s", dssdev->name);
-   return -ENOSPC;
-}
-
-static int dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int 
vc_id)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   if (vc_id < 0 || vc_id > 3) {
-   DSSERR("VC ID out of range\n");
-   return -EINVAL;
-   }
-
-   if (channel < 0 || channel > 3) {
-   DSSERR("Virtual Channel out of range\n");
+   if (channel < 0 || channel > 3)
return -EINVAL;
-   }
 
-   if (dsi->vc[channel].dssdev != dssdev) {
-   DSSERR("Virtual Channel not allocated to display %s\n",
-   dssdev->name);
-   return -EINVAL;
+   if (dsi->vc[channel].dssdev) {
+   DSSERR("cannot get VC for display %s", dssdev->name);
+   return -EBUSY;
}
 
-   dsi->vc[channel].vc_id = vc_id;
-
+   dsi->vc[channel].dssdev = dssdev;
return 0;
 }
 
@@ -4838,7 +4811,6 @@ static void dsi_release_vc(struct omap_dss_device 
*dssdev, int channel)
if ((channel >= 0 && channel <= 3) &&
dsi->vc[channel].dssdev == dssdev) {
dsi->vc[channel].dssdev = NULL;
-   dsi->vc[channel

[PATCH v3 25/56] drm/omap: dsi: move TE GPIO handling into core

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

In preparation for removing custom DSS calls from the DSI
panel driver, this moves support for external tearing event
GPIOs into the DSI host driver. This way tearing events are
always handled in the core resulting in simplification of
the panel drivers.

The TE GPIO acquisition follows works in the same way as the
exynos DSI implementation.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 101 +
 drivers/gpu/drm/omapdrm/dss/dsi.c | 138 --
 2 files changed, 133 insertions(+), 106 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 8890ee2ba830..43f63b5a120b 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -54,7 +54,6 @@ struct panel_drv_data {
 
/* panel HW configuration from DT or platform data */
struct gpio_desc *reset_gpio;
-   struct gpio_desc *ext_te_gpio;
 
struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
 
@@ -68,10 +67,6 @@ struct panel_drv_data {
 
bool te_enabled;
 
-   atomic_t do_update;
-
-   struct delayed_work te_timeout_work;
-
bool intro_printed;
 
struct workqueue_struct *workqueue;
@@ -83,8 +78,6 @@ struct panel_drv_data {
 
 #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
 
-static irqreturn_t dsicm_te_isr(int irq, void *data);
-static void dsicm_te_timeout_work_callback(struct work_struct *work);
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
 static int dsicm_panel_reset(struct panel_drv_data *ddata);
@@ -240,9 +233,6 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   if (ddata->ext_te_gpio)
-   disable_irq(gpiod_to_irq(ddata->ext_te_gpio));
-
src->ops->dsi.disable(src, false, true);
 
ddata->ulps_enabled = true;
@@ -271,15 +261,12 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
src->ops->enable(src);
ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
-   r = _dsicm_enable_te(ddata, true);
+   r = _dsicm_enable_te(ddata, ddata->te_enabled);
if (r) {
dev_err(&ddata->dsi->dev, "failed to re-enable TE");
goto err2;
}
 
-   if (ddata->ext_te_gpio)
-   enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
-
dsicm_queue_ulps_work(ddata);
 
ddata->ulps_enabled = false;
@@ -290,11 +277,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
dev_err(&ddata->dsi->dev, "failed to exit ULPS");
 
r = dsicm_panel_reset(ddata);
-   if (!r) {
-   if (ddata->ext_te_gpio)
-   enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
+   if (!r)
ddata->ulps_enabled = false;
-   }
 
dsicm_queue_ulps_work(ddata);
 
@@ -745,43 +729,6 @@ static void dsicm_framedone_cb(int err, void *data)
src->ops->dsi.bus_unlock(src);
 }
 
-static irqreturn_t dsicm_te_isr(int irq, void *data)
-{
-   struct panel_drv_data *ddata = data;
-   struct omap_dss_device *src = ddata->src;
-   int old;
-   int r;
-
-   old = atomic_cmpxchg(&ddata->do_update, 1, 0);
-
-   if (old) {
-   cancel_delayed_work(&ddata->te_timeout_work);
-
-   r = src->ops->dsi.update(src, ddata->dsi->channel, 
dsicm_framedone_cb,
-   ddata);
-   if (r)
-   goto err;
-   }
-
-   return IRQ_HANDLED;
-err:
-   dev_err(&ddata->dsi->dev, "start update failed\n");
-   src->ops->dsi.bus_unlock(src);
-   return IRQ_HANDLED;
-}
-
-static void dsicm_te_timeout_work_callback(struct work_struct *work)
-{
-   struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
-   te_timeout_work.work);
-   struct omap_dss_device *src = ddata->src;
-
-   dev_err(&ddata->dsi->dev, "TE not received for 250ms!\n");
-
-   atomic_set(&ddata->do_update, 0);
-   src->ops->dsi.bus_unlock(src);
-}
-
 static int dsicm_update(struct omap_dss_device *dssdev,
u16 x, u16 y, u16 w, u16 h)
 {
@@ -809,16 +756,10 @@ static int dsicm_update(struct omap_dss_device *dssdev,
if (r)
goto err;
 
-   if (ddata->te_enabled && ddata->ext_te_gpio) {
-   schedule_delayed_work(&ddata->te_timeout_work,
-   msecs_to_jiffies(250));
-   atomic_set(&ddata->do_update, 1);
-   } else {
-   r = s

[PATCH v3 04/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This replaces OMAP specific enum for pixel format with
common implementation.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c | 55 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 13 ++---
 3 files changed, 28 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ff610d2a13fd..b8f3a7aacbf4 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -595,7 +595,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
int r;
struct omap_dss_dsi_config dsi_config = {
.mode = OMAP_DSS_DSI_CMD_MODE,
-   .pixel_format = OMAP_DSS_DSI_FMT_RGB888,
+   .pixel_format = MIPI_DSI_FMT_RGB888,
.vm = &ddata->vm,
.hs_clk_min = 15000,
.hs_clk_max = 3,
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 5598fc8f91db..86b9d435fb94 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include "omapdss.h"
@@ -410,7 +411,7 @@ struct dsi_data {
 
struct dss_lcd_mgr_config mgr_config;
struct videomode vm;
-   enum omap_dss_dsi_pixel_format pix_fmt;
+   enum mipi_dsi_pixel_format pix_fmt;
enum omap_dss_dsi_mode mode;
struct omap_dss_dsi_videomode_timings vm_timings;
 
@@ -514,22 +515,6 @@ static inline bool wait_for_bit_change(struct dsi_data 
*dsi,
return false;
 }
 
-static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
-{
-   switch (fmt) {
-   case OMAP_DSS_DSI_FMT_RGB888:
-   case OMAP_DSS_DSI_FMT_RGB666:
-   return 24;
-   case OMAP_DSS_DSI_FMT_RGB666_PACKED:
-   return 18;
-   case OMAP_DSS_DSI_FMT_RGB565:
-   return 16;
-   default:
-   BUG();
-   return 0;
-   }
-}
-
 #ifdef DSI_PERF_MEASURE
 static void dsi_perf_mark_setup(struct dsi_data *dsi)
 {
@@ -3239,7 +3224,7 @@ static void dsi_config_vp_num_line_buffers(struct 
dsi_data *dsi)
int num_line_buffers;
 
if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-   int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+   int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
const struct videomode *vm = &dsi->vm;
/*
 * Don't use line buffers if width is greater than the video
@@ -3370,7 +3355,7 @@ static void dsi_config_cmd_mode_interleaving(struct 
dsi_data *dsi)
int tclk_trail, ths_exit, exiths_clk;
bool ddr_alwon;
const struct videomode *vm = &dsi->vm;
-   int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+   int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
int ndl = dsi->num_lanes_used - 1;
int dsi_fclk_hsdiv = dsi->user_dsi_cinfo.mX[HSDIV_DSI] + 1;
int hsa_interleave_hs = 0, hsa_interleave_lp = 0;
@@ -3498,7 +3483,7 @@ static int dsi_proto_config(struct dsi_data *dsi)
dsi_set_lp_rx_timeout(dsi, 0x1fff, true, true);
dsi_set_hs_tx_timeout(dsi, 0x1fff, true, true);
 
-   switch (dsi_get_pixel_size(dsi->pix_fmt)) {
+   switch (mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt)) {
case 16:
buswidth = 0;
break;
@@ -3619,7 +3604,7 @@ static void dsi_proto_timings(struct dsi_data *dsi)
int window_sync = dsi->vm_timings.window_sync;
bool hsync_end;
const struct videomode *vm = &dsi->vm;
-   int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+   int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
int tl, t_he, width_bytes;
 
hsync_end = dsi->vm_timings.trans_mode == 
OMAP_DSS_DSI_PULSE_MODE;
@@ -3726,7 +3711,7 @@ static int dsi_configure_pins(struct omap_dss_device 
*dssdev,
 static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
-   int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+   int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
u8 data_type;
u16 word_count;
int r;
@@ -3737,16 +3722,16 @@ static int dsi_enable_video_output(struct 
omap_dss_device *dssdev, int channel)
 
if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
switch (dsi->pix_fmt) {
-   case OMAP_DSS_DSI_FMT_RGB888:
+   case MIPI_DSI_FMT_RGB888:
data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
break;
-   case OMAP_D

[PATCH v3 18/56] drm/omap: dsi: drop unused memory_read()

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

memory_read is not used, so we can drop the code.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 93 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 -
 2 files changed, 97 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index a7236d9c3046..dd9112ca76ba 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -931,97 +931,6 @@ static int dsicm_get_te(struct omap_dss_device *dssdev)
return r;
 }
 
-static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
-   u16 size)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct mipi_dsi_device *dsi = ddata->dsi;
-
-   return mipi_dsi_set_maximum_return_packet_size(dsi, size);
-}
-
-static int dsicm_memory_read(struct omap_dss_device *dssdev,
-   void *buf, size_t size,
-   u16 x, u16 y, u16 w, u16 h)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   struct omap_dss_device *src = ddata->src;
-   int r;
-   int first = 1;
-   int plen;
-   unsigned int buf_used = 0;
-
-   if (size < w * h * 3)
-   return -ENOMEM;
-
-   mutex_lock(&ddata->lock);
-
-   if (!ddata->enabled) {
-   r = -ENODEV;
-   goto err1;
-   }
-
-   size = min((u32)w * h * 3,
-  ddata->vm.hactive * ddata->vm.vactive * 3);
-
-   src->ops->dsi.bus_lock(src);
-
-   r = dsicm_wake_up(ddata);
-   if (r)
-   goto err2;
-
-   /* plen 1 or 2 goes into short packet. until checksum error is fixed,
-* use short packets. plen 32 works, but bigger packets seem to cause
-* an error. */
-   if (size % 2)
-   plen = 1;
-   else
-   plen = 2;
-
-   dsicm_set_update_window(ddata, x, y, w, h);
-
-   r = dsicm_set_max_rx_packet_size(dssdev, plen);
-   if (r)
-   goto err2;
-
-   while (buf_used < size) {
-   u8 dcs_cmd = first ? 0x2e : 0x3e;
-   first = 0;
-
-   r = mipi_dsi_dcs_read(dsi, dcs_cmd,
- buf + buf_used, size - buf_used);
-   if (r < 0) {
-   dev_err(dssdev->dev, "read error\n");
-   goto err3;
-   }
-
-   buf_used += r;
-
-   if (r < plen) {
-   dev_err(&ddata->dsi->dev, "short read\n");
-   break;
-   }
-
-   if (signal_pending(current)) {
-   dev_err(&ddata->dsi->dev, "signal pending, "
-   "aborting memory read\n");
-   r = -ERESTARTSYS;
-   goto err3;
-   }
-   }
-
-   r = buf_used;
-
-err3:
-   dsicm_set_max_rx_packet_size(dssdev, 1);
-err2:
-   src->ops->dsi.bus_unlock(src);
-err1:
-   mutex_unlock(&ddata->lock);
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -1094,8 +1003,6 @@ static const struct omap_dss_driver dsicm_dss_driver = {
 
.enable_te  = dsicm_enable_te,
.get_te = dsicm_get_te,
-
-   .memory_read= dsicm_memory_read,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 78041ef922cc..e67928373560 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -389,10 +389,6 @@ struct omap_dss_driver {
 
int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
int (*get_te)(struct omap_dss_device *dssdev);
-
-   int (*memory_read)(struct omap_dss_device *dssdev,
-   void *buf, size_t size,
-   u16 x, u16 y, u16 w, u16 h);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 13/56] drm/omap: dsi: introduce mipi_dsi_host

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

This moves from custom platform driver infrastructure to mipi_dsi_host
and mipi_dsi_device. Note, that this is a graduate step and the driver
only uses the devices types and transfer function, but not yet the new
device binding style or drm_panel.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 121 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c |  54 ++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   4 -
 3 files changed, 103 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ea76a89d1833..c3190223d192 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -39,13 +38,13 @@
 #define DCS_GET_ID30xdc
 
 struct panel_drv_data {
+   struct mipi_dsi_device *dsi;
+
struct omap_dss_device dssdev;
struct omap_dss_device *src;
 
struct videomode vm;
 
-   struct platform_device *pdev;
-
struct mutex lock;
 
struct backlight_device *bldev;
@@ -139,7 +138,7 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_DCS_READ,
@@ -149,12 +148,12 @@ static int dsicm_dcs_read_1(struct panel_drv_data *ddata, 
u8 dcs_cmd, u8 *data)
.rx_buf = data
};
 
-   return src->ops->dsi.transfer(src, &msg);
+   return dsi->host->ops->transfer(dsi->host, &msg);
 }
 
 static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
.type = MIPI_DSI_DCS_SHORT_WRITE,
@@ -162,12 +161,12 @@ static int dsicm_dcs_write_0(struct panel_drv_data 
*ddata, u8 dcs_cmd)
.tx_len = 1,
};
 
-   return src->ops->dsi.transfer(src, &msg);
+   return dsi->host->ops->transfer(dsi->host, &msg);
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 
param)
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
const u8 buf[] = { dcs_cmd, param };
const struct mipi_dsi_msg msg = {
.channel = ddata->channel,
@@ -176,13 +175,13 @@ static int dsicm_dcs_write_1(struct panel_drv_data 
*ddata, u8 dcs_cmd, u8 param)
.tx_len = 2,
};
 
-   return src->ops->dsi.transfer(src, &msg);
+   return dsi->host->ops->transfer(dsi->host, &msg);
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
int r;
const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
const struct mipi_dsi_msg msg = {
@@ -194,7 +193,7 @@ static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
hw_guard_wait(ddata);
 
-   r = src->ops->dsi.transfer(src, &msg);
+   r = dsi->host->ops->transfer(dsi->host, &msg);
if (r)
return r;
 
@@ -242,7 +241,7 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 
*id1, u8 *id2, u8 *id3)
 static int dsicm_set_update_window(struct panel_drv_data *ddata,
u16 x, u16 y, u16 w, u16 h)
 {
-   struct omap_dss_device *src = ddata->src;
+   struct mipi_dsi_device *dsi = ddata->dsi;
int r;
u16 x1 = x;
u16 x2 = x + w - 1;
@@ -279,11 +278,11 @@ static int dsicm_set_update_window(struct panel_drv_data 
*ddata,
.tx_len = 5,
};
 
-   r = src->ops->dsi.transfer(src, &msgX);
+   r = dsi->host->ops->transfer(dsi->host, &msgX);
if (r)
return r;
 
-   r = src->ops->dsi.transfer(src, &msgY);
+   r = dsi->host->ops->transfer(dsi->host, &msgY);
if (r)
return r;
 
@@ -326,7 +325,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
return 0;
 
 err:
-   dev_err(&ddata->pdev->dev, "enter ULPS failed");
+   dev_err(&ddata->dsi->dev, "enter ULPS failed");
dsicm_panel_reset(ddata);
 
ddata->ulps_enabled = false;
@@ -349,7 +348,7 @@ static int dsicm_exit_ulps(struct panel_drv_d

[PATCH v3 19/56] drm/omap: dsi: drop unused get_te()

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

The get_te() callback is not used, so we can drop the
custom API.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 13 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h   |  1 -
 2 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index dd9112ca76ba..92ac90035fec 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -919,18 +919,6 @@ static int dsicm_enable_te(struct omap_dss_device *dssdev, 
bool enable)
return r;
 }
 
-static int dsicm_get_te(struct omap_dss_device *dssdev)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   int r;
-
-   mutex_lock(&ddata->lock);
-   r = ddata->te_enabled;
-   mutex_unlock(&ddata->lock);
-
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -1002,7 +990,6 @@ static const struct omap_dss_driver dsicm_dss_driver = {
.sync   = dsicm_sync,
 
.enable_te  = dsicm_enable_te,
-   .get_te = dsicm_get_te,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index e67928373560..aa307f5ab9cf 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -388,7 +388,6 @@ struct omap_dss_driver {
int (*sync)(struct omap_dss_device *dssdev);
 
int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
-   int (*get_te)(struct omap_dss_device *dssdev);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 21/56] drm/omap: dsi: drop useless sync()

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

The DSI sync() function only locks the bus and then releases
it again. Currently the only invocation is directly before
update(), which locks the bus anyways.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c| 18 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  1 -
 drivers/gpu/drm/omapdrm/omap_crtc.c|  3 ---
 3 files changed, 22 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index f59775cabe2d..a9609eed6bfa 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -845,23 +845,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
return r;
 }
 
-static int dsicm_sync(struct omap_dss_device *dssdev)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
-
-   dev_dbg(&ddata->dsi->dev, "sync\n");
-
-   mutex_lock(&ddata->lock);
-   src->ops->dsi.bus_lock(src);
-   src->ops->dsi.bus_unlock(src);
-   mutex_unlock(&ddata->lock);
-
-   dev_dbg(&ddata->dsi->dev, "sync done\n");
-
-   return 0;
-}
-
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
struct omap_dss_device *src = ddata->src;
@@ -950,7 +933,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
 
 static const struct omap_dss_driver dsicm_dss_driver = {
.update = dsicm_update,
-   .sync   = dsicm_sync,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 55d5bca59f81..9bbd2c0f3187 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -385,7 +385,6 @@ struct omap_dss_device {
 struct omap_dss_driver {
int (*update)(struct omap_dss_device *dssdev,
   u16 x, u16 y, u16 w, u16 h);
-   int (*sync)(struct omap_dss_device *dssdev);
 };
 
 struct dss_device *omapdss_get_dss(void);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 328a4a74f534..dac9ccda98df 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -379,9 +379,6 @@ static void omap_crtc_manual_display_update(struct 
work_struct *data)
return;
}
 
-   if (dssdrv->sync)
-   dssdrv->sync(dssdev);
-
ret = dssdrv->update(dssdev, 0, 0, mode->hdisplay, mode->vdisplay);
if (ret < 0) {
spin_lock_irq(&dev->event_lock);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 20/56] drm/omap: dsi: drop unused enable_te()

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

enable_te() is not used, so the custom API can be dropped.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 39 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  2 -
 2 files changed, 41 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 92ac90035fec..f59775cabe2d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -882,43 +882,6 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, 
bool enable)
return r;
 }
 
-static int dsicm_enable_te(struct omap_dss_device *dssdev, bool enable)
-{
-   struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src;
-   int r;
-
-   mutex_lock(&ddata->lock);
-
-   if (ddata->te_enabled == enable)
-   goto end;
-
-   src->ops->dsi.bus_lock(src);
-
-   if (ddata->enabled) {
-   r = dsicm_wake_up(ddata);
-   if (r)
-   goto err;
-
-   r = _dsicm_enable_te(ddata, enable);
-   if (r)
-   goto err;
-   }
-
-   ddata->te_enabled = enable;
-
-   src->ops->dsi.bus_unlock(src);
-end:
-   mutex_unlock(&ddata->lock);
-
-   return 0;
-err:
-   src->ops->dsi.bus_unlock(src);
-   mutex_unlock(&ddata->lock);
-
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -988,8 +951,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
 static const struct omap_dss_driver dsicm_dss_driver = {
.update = dsicm_update,
.sync   = dsicm_sync,
-
-   .enable_te  = dsicm_enable_te,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index aa307f5ab9cf..55d5bca59f81 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -386,8 +386,6 @@ struct omap_dss_driver {
int (*update)(struct omap_dss_device *dssdev,
   u16 x, u16 y, u16 w, u16 h);
int (*sync)(struct omap_dss_device *dssdev);
-
-   int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 15/56] drm/omap: dsi: request VC via mipi_dsi_attach

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Drop custom request_vc/release_vc callbacks by using the
generic mipi_dsi_attach/mipi_dsi_detach functions.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 24 +---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 61 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 -
 3 files changed, 41 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ec36e62ddc3a..b1ca9b34ce17 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -693,14 +693,6 @@ static int dsicm_connect(struct omap_dss_device *src,
 struct omap_dss_device *dst)
 {
struct panel_drv_data *ddata = to_panel_data(dst);
-   struct device *dev = &ddata->dsi->dev;
-   int r;
-
-   r = src->ops->dsi.request_vc(src, ddata->channel);
-   if (r) {
-   dev_err(dev, "failed to get virtual channel\n");
-   return r;
-   }
 
ddata->src = src;
return 0;
@@ -711,7 +703,6 @@ static void dsicm_disconnect(struct omap_dss_device *src,
 {
struct panel_drv_data *ddata = to_panel_data(dst);
 
-   src->ops->dsi.release_vc(src, ddata->channel);
ddata->src = NULL;
 }
 
@@ -1276,8 +1267,21 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
goto err_bl;
}
 
+   dsi->lanes = 3;
+   dsi->format = MIPI_DSI_FMT_RGB888;
+   dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |
+ MIPI_DSI_MODE_EOT_PACKET;
+   dsi->hs_rate = 3;
+   dsi->lp_rate = 1000;
+
+   r = mipi_dsi_attach(dsi);
+   if (r < 0)
+   goto err_dsi_attach;
+
return 0;
 
+err_dsi_attach:
+   sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
 err_bl:
destroy_workqueue(ddata->workqueue);
 err_reg:
@@ -1294,6 +1298,8 @@ static int __exit dsicm_remove(struct mipi_dsi_device 
*dsi)
 
dev_dbg(&dsi->dev, "remove\n");
 
+   mipi_dsi_detach(dsi);
+
omapdss_device_unregister(dssdev);
 
if (omapdss_device_is_enabled(dssdev))
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index d1187a8af37f..a16427f3bc23 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -349,7 +349,7 @@ struct dsi_data {
 
struct {
enum dsi_vc_source source;
-   struct omap_dss_device *dssdev;
+   struct mipi_dsi_device *dest;
enum fifo_size tx_fifo_size;
enum fifo_size rx_fifo_size;
} vc[4];
@@ -4692,32 +4692,6 @@ static enum omap_channel dsi_get_channel(struct dsi_data 
*dsi)
}
 }
 
-static int dsi_request_vc(struct omap_dss_device *dssdev, int channel)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   if (channel < 0 || channel > 3)
-   return -EINVAL;
-
-   if (dsi->vc[channel].dssdev) {
-   DSSERR("cannot get VC for display %s", dssdev->name);
-   return -EBUSY;
-   }
-
-   dsi->vc[channel].dssdev = dssdev;
-   return 0;
-}
-
-static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   if ((channel >= 0 && channel <= 3) &&
-   dsi->vc[channel].dssdev == dssdev) {
-   dsi->vc[channel].dssdev = NULL;
-   }
-}
-
 static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
  const struct mipi_dsi_msg *msg)
 {
@@ -4794,23 +4768,40 @@ static const struct omap_dss_device_ops dsi_ops = {
.update = dsi_update,
 
.enable_te = dsi_enable_te,
-
-   .request_vc = dsi_request_vc,
-   .release_vc = dsi_release_vc,
},
 };
 
 static int omap_dsi_host_attach(struct mipi_dsi_host *host,
-struct mipi_dsi_device *dsi)
+   struct mipi_dsi_device *client)
 {
-   /* TODO: convert driver from custom binding method to this one */
+   struct dsi_data *dsi = host_to_omap(host);
+   unsigned int channel = client->channel;
+
+   if (channel > 3)
+   return -EINVAL;
+
+   if (dsi->vc[channel].dest) {
+   DSSERR("cannot get VC for display %s", dev_name(&client->dev));
+   return -EBUSY;
+   }
+
+   dsi->vc[channel].dest = client;
return 0;
 }
 
 static int omap_dsi_host_detach(struct mipi_dsi_host *host,
-struct mipi_dsi_device *dsi)
+   struct mipi_dsi_device

[PATCH v3 03/56] drm/omap: drop unused dsi.configure_pins

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

The panel-dsi-cm's ddata->pin_config is always NULL, so this
callback is never called. Instead the DSI encoder gets the pin
configuration directly from DT.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 11 ---
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h   |  2 --
 3 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index faca5c873bde..ff610d2a13fd 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -68,8 +68,6 @@ struct panel_drv_data {
int width_mm;
int height_mm;
 
-   struct omap_dsi_pin_config pin_config;
-
/* runtime variables */
bool enabled;
 
@@ -623,15 +621,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
}
}
 
-   if (ddata->pin_config.num_pins > 0) {
-   r = src->ops->dsi.configure_pins(src, &ddata->pin_config);
-   if (r) {
-   dev_err(&ddata->pdev->dev,
-   "failed to configure DSI pins\n");
-   goto err_vddi;
-   }
-   }
-
r = src->ops->dsi.set_config(src, &dsi_config);
if (r) {
dev_err(&ddata->pdev->dev, "failed to configure DSI\n");
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index eeccf40bae41..5598fc8f91db 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4892,7 +4892,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 
.enable_hs = dsi_vc_enable_hs,
 
-   .configure_pins = dsi_configure_pins,
.set_config = dsi_set_config,
 
.enable_video_output = dsi_enable_video_output,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index cbbe10b2b60d..b0424daaceed 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -292,8 +292,6 @@ struct omapdss_dsi_ops {
/* bus configuration */
int (*set_config)(struct omap_dss_device *dssdev,
const struct omap_dss_dsi_config *cfg);
-   int (*configure_pins)(struct omap_dss_device *dssdev,
-   const struct omap_dsi_pin_config *pin_cfg);
 
void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
bool enable);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 05/56] drm/omap: constify write buffers

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

The write buffers are not modified, so they can be constant.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 24 
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 10 +-
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 86b9d435fb94..22d74d762a10 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2601,11 +2601,11 @@ static inline void dsi_vc_write_long_payload(struct 
dsi_data *dsi, int channel,
 }
 
 static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
-   u8 *data, u16 len, u8 ecc)
+   const u8 *data, u16 len, u8 ecc)
 {
/*u32 val; */
int i;
-   u8 *p;
+   const u8 *p;
int r = 0;
u8 b1, b2, b3, b4;
 
@@ -2698,7 +2698,7 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int 
channel)
 }
 
 static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
- u8 *data, int len,
+ const u8 *data, int len,
  enum dss_dsi_content_type type)
 {
int r;
@@ -2729,7 +2729,7 @@ static int dsi_vc_write_nosync_common(struct dsi_data 
*dsi, int channel,
 }
 
 static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len)
+   const u8 *data, int len)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
 
@@ -2738,7 +2738,7 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device 
*dssdev, int channel,
 }
 
 static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int 
channel,
-   u8 *data, int len)
+   const u8 *data, int len)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
 
@@ -2747,7 +2747,7 @@ static int dsi_vc_generic_write_nosync(struct 
omap_dss_device *dssdev, int chann
 }
 
 static int dsi_vc_write_common(struct omap_dss_device *dssdev,
-  int channel, u8 *data, int len,
+  int channel, const u8 *data, int len,
   enum dss_dsi_content_type type)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
@@ -2776,15 +2776,15 @@ static int dsi_vc_write_common(struct omap_dss_device 
*dssdev,
return r;
 }
 
-static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel, u8 
*data,
-   int len)
+static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel,
+   const u8 *data, int len)
 {
return dsi_vc_write_common(dssdev, channel, data, len,
DSS_DSI_CONTENT_DCS);
 }
 
-static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, 
u8 *data,
-   int len)
+static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel,
+   const u8 *data, int len)
 {
return dsi_vc_write_common(dssdev, channel, data, len,
DSS_DSI_CONTENT_GENERIC);
@@ -2810,7 +2810,7 @@ static int dsi_vc_dcs_send_read_request(struct dsi_data 
*dsi, int channel,
 }
 
 static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel,
-   u8 *reqdata, int reqlen)
+   const u8 *reqdata, int reqlen)
 {
u16 data;
u8 data_type;
@@ -2983,7 +2983,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device 
*dssdev, int channel, u8 dcs_c
 }
 
 static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
-   u8 *reqdata, int reqlen, u8 *buf, int buflen)
+   const u8 *reqdata, int reqlen, u8 *buf, int buflen)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index c4bc1f919ab4..8e96ab2f20b6 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -309,18 +309,18 @@ struct omapdss_dsi_ops {
 
/* data transfer */
int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len);
+   const u8 *data, int len);
int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len);
+   const u8 *data, int len);
int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
u8 *data, int len);
 
int (*gen_write)(struct omap_dss_device *dssdev, int channel,
-   u8 *data, int len);
+   const u8 *data, int len);
int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
-   u8 *data

[PATCH v3 17/56] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Drop local definition of common MIPI DCS 1.3 defines.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 25183744a61d..a7236d9c3046 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -28,8 +28,6 @@
 #include "../dss/omapdss.h"
 
 #define DCS_READ_NUM_ERRORS0x05
-#define DCS_BRIGHTNESS 0x51
-#define DCS_CTRL_DISPLAY   0x53
 #define DCS_GET_ID10xda
 #define DCS_GET_ID20xdb
 #define DCS_GET_ID30xdc
@@ -333,8 +331,10 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
src->ops->dsi.bus_lock(src);
 
r = dsicm_wake_up(ddata);
-   if (!r)
-   r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, level);
+   if (!r) {
+   r = dsicm_dcs_write_1(ddata,
+   MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
+   }
 
src->ops->dsi.bus_unlock(src);
}
@@ -597,11 +597,11 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, 0xff);
+   r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff);
if (r)
goto err;
 
-   r = dsicm_dcs_write_1(ddata, DCS_CTRL_DISPLAY,
+   r = dsicm_dcs_write_1(ddata, MIPI_DCS_WRITE_CONTROL_DISPLAY,
(1<<2) | (1<<5));   /* BL | BCTRL */
if (r)
goto err;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 23/56] drm/omap: panel-dsi-cm: use bulk regulator API

2020-11-05 Thread Tomi Valkeinen
From: Sebastian Reichel 

Use bulk regulator API to simplify the code. This also switches
from _optional variant to normal variant, which will provide a
dummy regulator (i.e. if some always-enabled regulator is not
described in DT).

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 65 ++-
 1 file changed, 21 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 2e9de33fc8d4..1e742cf798b6 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -32,6 +32,8 @@
 #define DCS_GET_ID20xdb
 #define DCS_GET_ID30xdc
 
+#define DCS_REGULATOR_SUPPLY_NUM 2
+
 struct panel_drv_data {
struct mipi_dsi_device *dsi;
 
@@ -54,8 +56,7 @@ struct panel_drv_data {
struct gpio_desc *reset_gpio;
struct gpio_desc *ext_te_gpio;
 
-   struct regulator *vpnl;
-   struct regulator *vddi;
+   struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
 
bool use_dsi_backlight;
 
@@ -557,28 +558,16 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
.lp_clk_max = 1000,
};
 
-   if (ddata->vpnl) {
-   r = regulator_enable(ddata->vpnl);
-   if (r) {
-   dev_err(&ddata->dsi->dev,
-   "failed to enable VPNL: %d\n", r);
-   return r;
-   }
-   }
-
-   if (ddata->vddi) {
-   r = regulator_enable(ddata->vddi);
-   if (r) {
-   dev_err(&ddata->dsi->dev,
-   "failed to enable VDDI: %d\n", r);
-   goto err_vpnl;
-   }
+   r = regulator_bulk_enable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r) {
+   dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
+   return r;
}
 
r = src->ops->dsi.set_config(src, &dsi_config);
if (r) {
dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
-   goto err_vddi;
+   goto err_regulators;
}
 
src->ops->enable(src);
@@ -637,12 +626,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
dsicm_hw_reset(ddata);
 
src->ops->dsi.disable(src, true, false);
-err_vddi:
-   if (ddata->vddi)
-   regulator_disable(ddata->vddi);
-err_vpnl:
-   if (ddata->vpnl)
-   regulator_disable(ddata->vpnl);
+err_regulators:
+   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r)
+   dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", 
r);
 
return r;
 }
@@ -666,10 +653,9 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 
src->ops->dsi.disable(src, true, false);
 
-   if (ddata->vddi)
-   regulator_disable(ddata->vddi);
-   if (ddata->vpnl)
-   regulator_disable(ddata->vpnl);
+   r = regulator_bulk_disable(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+   if (r)
+   dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", 
r);
 
ddata->enabled = false;
 }
@@ -973,21 +959,12 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
ddata->height_mm = 0;
of_property_read_u32(node, "height-mm", &ddata->height_mm);
 
-   ddata->vpnl = devm_regulator_get_optional(&dsi->dev, "vpnl");
-   if (IS_ERR(ddata->vpnl)) {
-   err = PTR_ERR(ddata->vpnl);
-   if (err == -EPROBE_DEFER)
-   return err;
-   ddata->vpnl = NULL;
-   }
-
-   ddata->vddi = devm_regulator_get_optional(&dsi->dev, "vddi");
-   if (IS_ERR(ddata->vddi)) {
-   err = PTR_ERR(ddata->vddi);
-   if (err == -EPROBE_DEFER)
-   return err;
-   ddata->vddi = NULL;
-   }
+   ddata->supplies[0].supply = "vpnl";
+   ddata->supplies[1].supply = "vddi";
+   err = devm_regulator_bulk_get(&dsi->dev, DCS_REGULATOR_SUPPLY_NUM,
+ ddata->supplies);
+   if (err)
+   return err;
 
backlight = devm_of_find_backlight(&dsi->dev);
if (IS_ERR(backlight))
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 4/5] drm/omap: rearrange includes in omapdss.h

2020-11-03 Thread Tomi Valkeinen
Drop "uapi/" and rearrange alphabetically.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index ab19d4af8de7..8e9a2019f173 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -7,13 +7,13 @@
 #ifndef __OMAP_DRM_DSS_H
 #define __OMAP_DRM_DSS_H
 
-#include 
+#include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include 
+#include 
 
 #define DISPC_IRQ_FRAMEDONE(1 << 0)
 #define DISPC_IRQ_VSYNC(1 << 1)
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 3/5] drm/omap: Implement CTM property for CRTC using OVL managers CPR matrix

2020-11-03 Thread Tomi Valkeinen
From: Jyri Sarha 

Implement CTM color management property for OMAP CRTC using DSS
overlay manager's Color Phase Rotation matrix. The CPR matrix does not
exactly match the CTM property documentation. On DSS the CPR matrix is
applied after gamma table look up. However, it seems stupid to add a
custom property just for that.

Signed-off-by: Jyri Sarha 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 39 +++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index d40220b2f312..b2c251a8b404 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -391,6 +391,33 @@ static void omap_crtc_manual_display_update(struct 
work_struct *data)
}
 }
 
+static s16 omap_crtc_s31_32_to_s2_8(s64 coef)
+{
+   u64 sign_bit = 1ULL << 63;
+   u64 cbits = (u64)coef;
+
+   s16 ret = clamp_val(((cbits & ~sign_bit) >> 24), 0, 0x1ff);
+
+   if (cbits & sign_bit)
+   ret = -ret;
+
+   return ret;
+}
+
+static void omap_crtc_cpr_coefs_from_ctm(const struct drm_color_ctm *ctm,
+struct omap_dss_cpr_coefs *cpr)
+{
+   cpr->rr = omap_crtc_s31_32_to_s2_8(ctm->matrix[0]);
+   cpr->rg = omap_crtc_s31_32_to_s2_8(ctm->matrix[1]);
+   cpr->rb = omap_crtc_s31_32_to_s2_8(ctm->matrix[2]);
+   cpr->gr = omap_crtc_s31_32_to_s2_8(ctm->matrix[3]);
+   cpr->gg = omap_crtc_s31_32_to_s2_8(ctm->matrix[4]);
+   cpr->gb = omap_crtc_s31_32_to_s2_8(ctm->matrix[5]);
+   cpr->br = omap_crtc_s31_32_to_s2_8(ctm->matrix[6]);
+   cpr->bg = omap_crtc_s31_32_to_s2_8(ctm->matrix[7]);
+   cpr->bb = omap_crtc_s31_32_to_s2_8(ctm->matrix[8]);
+}
+
 static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
 {
struct omap_drm_private *priv = crtc->dev->dev_private;
@@ -402,7 +429,15 @@ static void omap_crtc_write_crtc_properties(struct 
drm_crtc *crtc)
info.default_color = 0x00;
info.trans_enabled = false;
info.partial_alpha_enabled = false;
-   info.cpr_enable = false;
+
+   if (crtc->state->ctm) {
+   struct drm_color_ctm *ctm = crtc->state->ctm->data;
+
+   info.cpr_enable = true;
+   omap_crtc_cpr_coefs_from_ctm(ctm, &info.cpr_coefs);
+   } else {
+   info.cpr_enable = false;
+   }
 
priv->dispc_ops->mgr_setup(priv->dispc, omap_crtc->channel, &info);
 }
@@ -842,7 +877,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
unsigned int gamma_lut_size = 256;
 
-   drm_crtc_enable_color_mgmt(crtc, gamma_lut_size, false, 0);
+   drm_crtc_enable_color_mgmt(crtc, gamma_lut_size, true, 0);
drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
}
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 0/5] drm/omap: add color mgmt support

2020-11-03 Thread Tomi Valkeinen
Hi,

This is a resend of the v1, after adding Pekka's reviewed-by, rebasing
to latest drm-misc, and re-testing. The cover letter from v1:

This series is based on patches sent about a year ago:

https://lists.freedesktop.org/archives/dri-devel/2019-September/233966.html
https://lists.freedesktop.org/archives/dri-devel/2019-September/233967.html

I've fixed the minor issues reported, and according to the recent
discussions with Pekka and Daniel, I have changed how the gamma works.

After these patches omapdrm will expose DEGAMMA_LUT (and no GAMMA_LUT),
and the legacy gamma-set ioctl will use DEGAMMA_LUT underneath. And on
top of that, we have the CTM and plane color mgmt.

 Tomi

Jyri Sarha (2):
  drm/omap: Implement CTM property for CRTC using OVL managers CPR
matrix
  drm/omap: Enable COLOR_ENCODING and COLOR_RANGE properties for planes

Tomi Valkeinen (3):
  drm: add legacy support for using degamma for gamma
  drm/omap: use degamma property for gamma table
  drm/omap: rearrange includes in omapdss.h

 drivers/gpu/drm/drm_atomic_helper.c   |  81 +++-
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 104 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  12 ++-
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  51 +++--
 drivers/gpu/drm/omapdrm/omap_plane.c  |  30 
 include/drm/drm_atomic_helper.h   |   4 +
 6 files changed, 209 insertions(+), 73 deletions(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 5/5] drm/omap: Enable COLOR_ENCODING and COLOR_RANGE properties for planes

2020-11-03 Thread Tomi Valkeinen
From: Jyri Sarha 

Adds support for COLOR_ENCODING and COLOR_RANGE properties to
omap_plane.c and dispc.c. The supported encodings and ranges are
presets are:

For COLOR_ENCODING:
- YCbCr BT.601 (default)
- YCbCr BT.709

For COLOR_RANGE:
- YCbCr limited range
- YCbCr full range (default)

Signed-off-by: Jyri Sarha 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 104 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   4 +
 drivers/gpu/drm/omapdrm/omap_plane.c  |  30 
 3 files changed, 97 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 48593932bddf..bf0c9d293077 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -874,50 +874,67 @@ static void dispc_ovl_write_color_conv_coef(struct 
dispc_device *dispc,
 #undef CVAL
 }
 
-static void dispc_wb_write_color_conv_coef(struct dispc_device *dispc,
-  const struct csc_coef_rgb2yuv *ct)
-{
-   const enum omap_plane_id plane = OMAP_DSS_WB;
-
-#define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0))
+/* YUV -> RGB, ITU-R BT.601, full range */
+static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt601_full = {
+   256,   0,  358, /* ry, rcb, rcr |1.000  0.000  1.402|*/
+   256, -88, -182, /* gy, gcb, gcr |1.000 -0.344 -0.714|*/
+   256, 452,0, /* by, bcb, bcr |1.000  1.772  0.000|*/
+   true,   /* full range */
+};
 
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 0), CVAL(ct->yg,  
ct->yr));
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 1), CVAL(ct->crr, 
ct->yb));
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 2), CVAL(ct->crb, 
ct->crg));
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 3), CVAL(ct->cbg, 
ct->cbr));
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 4), CVAL(0, ct->cbb));
+/* YUV -> RGB, ITU-R BT.601, limited range */
+static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt601_lim = {
+   298,0,  409,/* ry, rcb, rcr |1.164  0.000  1.596|*/
+   298, -100, -208,/* gy, gcb, gcr |1.164 -0.392 -0.813|*/
+   298,  516,0,/* by, bcb, bcr |1.164  2.017  0.000|*/
+   false,  /* limited range */
+};
 
-   REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), ct->full_range, 11, 11);
+/* YUV -> RGB, ITU-R BT.709, full range */
+static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt709_full = {
+   256,0,  402,/* ry, rcb, rcr |1.000  0.000  1.570|*/
+   256,  -48, -120,/* gy, gcb, gcr |1.000 -0.187 -0.467|*/
+   256,  475,0,/* by, bcb, bcr |1.000  1.856  0.000|*/
+   true,   /* full range */
+};
 
-#undef CVAL
-}
+/* YUV -> RGB, ITU-R BT.709, limited range */
+static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt709_lim = {
+   298,0,  459,/* ry, rcb, rcr |1.164  0.000  1.793|*/
+   298,  -55, -136,/* gy, gcb, gcr |1.164 -0.213 -0.533|*/
+   298,  541,0,/* by, bcb, bcr |1.164  2.112  0.000|*/
+   false,  /* limited range */
+};
 
-static void dispc_setup_color_conv_coef(struct dispc_device *dispc)
+static int dispc_ovl_set_csc(struct dispc_device *dispc,
+enum omap_plane_id plane,
+enum drm_color_encoding color_encoding,
+enum drm_color_range color_range)
 {
-   int i;
-   int num_ovl = dispc_get_num_ovls(dispc);
-
-   /* YUV -> RGB, ITU-R BT.601, limited range */
-   const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt601_lim = {
-   298,0,  409,/* ry, rcb, rcr */
-   298, -100, -208,/* gy, gcb, gcr */
-   298,  516,0,/* by, bcb, bcr */
-   false,  /* limited range */
-   };
+   const struct csc_coef_yuv2rgb *csc;
 
-   /* RGB -> YUV, ITU-R BT.601, limited range */
-   const struct csc_coef_rgb2yuv coefs_rgb2yuv_bt601_lim = {
-66, 129,  25,  /* yr,   yg,  yb */
-   -38, -74, 112,  /* cbr, cbg, cbb */
-   112, -94, -18,  /* crr, crg, crb */
-   false,  /* limited range */
-   };
+   switch (color_encoding) {
+   case DRM_COLOR_YCBCR_BT601:
+   if (color_range == DRM_COLOR_YCBCR_FULL_RANGE)
+   csc = &coefs_yuv2rgb_bt601_full;
+   else
+   csc = &coefs_yuv2rgb_bt601_lim;
+   break;
+   case DRM_COLOR_YCBCR_BT709:
+   if (color_range == DRM_COLOR_YCBCR_FULL_RANGE)
+   csc = &coefs_yuv2rgb_bt709_full;
+   else
+   csc = &coefs_yuv2rgb_bt709_lim

[PATCH v2 2/5] drm/omap: use degamma property for gamma table

2020-11-03 Thread Tomi Valkeinen
omapdrm supports gamma via GAMMA_LUT property. However, the HW we have
is:

gamma -> ctm -> out

instead of what the model DRM framework uses:

ctm -> gamma -> out

As the following patches add CTM support for omapdrm, lets first fix the
gamma.

This patch changes the property from GAMMA_LUT to DEGAMMA_LUT, and uses
drm_atomic_helper_legacy_degamma_set for gamma_set helper. Thus we will
have:

degamma -> ctm -> out

and the legacy ioctl will continue working as before.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Pekka Paalanen 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index d7442aa55f89..d40220b2f312 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -575,8 +575,8 @@ static int omap_crtc_atomic_check(struct drm_crtc *crtc,
  crtc);
struct drm_plane_state *pri_state;
 
-   if (crtc_state->color_mgmt_changed && crtc_state->gamma_lut) {
-   unsigned int length = crtc_state->gamma_lut->length /
+   if (crtc_state->color_mgmt_changed && crtc_state->degamma_lut) {
+   unsigned int length = crtc_state->degamma_lut->length /
sizeof(struct drm_color_lut);
 
if (length < 2)
@@ -617,10 +617,10 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_color_lut *lut = NULL;
unsigned int length = 0;
 
-   if (crtc->state->gamma_lut) {
+   if (crtc->state->degamma_lut) {
lut = (struct drm_color_lut *)
-   crtc->state->gamma_lut->data;
-   length = crtc->state->gamma_lut->length /
+   crtc->state->degamma_lut->data;
+   length = crtc->state->degamma_lut->length /
sizeof(*lut);
}
priv->dispc_ops->mgr_set_gamma(priv->dispc, omap_crtc->channel,
@@ -741,7 +741,7 @@ static const struct drm_crtc_funcs omap_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
.destroy = omap_crtc_destroy,
.page_flip = drm_atomic_helper_page_flip,
-   .gamma_set = drm_atomic_helper_legacy_gamma_set,
+   .gamma_set = drm_atomic_helper_legacy_degamma_set,
.atomic_duplicate_state = omap_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
.atomic_set_property = omap_crtc_atomic_set_property,
@@ -842,7 +842,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
unsigned int gamma_lut_size = 256;
 
-   drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
+   drm_crtc_enable_color_mgmt(crtc, gamma_lut_size, false, 0);
drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
}
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 1/5] drm: add legacy support for using degamma for gamma

2020-11-03 Thread Tomi Valkeinen
We currently have drm_atomic_helper_legacy_gamma_set() helper which can
be used to handle legacy gamma-set ioctl.
drm_atomic_helper_legacy_gamma_set() sets GAMMA_LUT, and clears
CTM and DEGAMMA_LUT. This works fine on HW where we have either:

degamma -> ctm -> gamma -> out

or

ctm -> gamma -> out

However, if the HW has gamma table before ctm, the atomic property
should be DEGAMMA_LUT, and thus we have:

degamma -> ctm -> out

This is fine for userspace which sets gamma table using the properties,
as the userspace can check for the existence of gamma & degamma, but the
legacy gamma-set ioctl does not work.

This patch adds a new helper, drm_atomic_helper_legacy_degamma_set(),
which can be used instead of drm_atomic_helper_legacy_gamma_set() when
the DEGAMMA_LUT is the underlying property that needs to be set.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Pekka Paalanen 
---
 drivers/gpu/drm/drm_atomic_helper.c | 81 ++---
 include/drm/drm_atomic_helper.h |  4 ++
 2 files changed, 65 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index ddd0e3239150..23cbed541dc7 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3499,24 +3499,11 @@ int drm_atomic_helper_page_flip_target(struct drm_crtc 
*crtc,
 }
 EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
 
-/**
- * drm_atomic_helper_legacy_gamma_set - set the legacy gamma correction table
- * @crtc: CRTC object
- * @red: red correction table
- * @green: green correction table
- * @blue: green correction table
- * @size: size of the tables
- * @ctx: lock acquire context
- *
- * Implements support for legacy gamma correction table for drivers
- * that support color management through the DEGAMMA_LUT/GAMMA_LUT
- * properties. See drm_crtc_enable_color_mgmt() and the containing chapter for
- * how the atomic color management and gamma tables work.
- */
-int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-  u16 *red, u16 *green, u16 *blue,
-  uint32_t size,
-  struct drm_modeset_acquire_ctx *ctx)
+static int legacy_gamma_degamma_set(struct drm_crtc *crtc,
+   u16 *red, u16 *green, u16 *blue,
+   uint32_t size,
+   struct drm_modeset_acquire_ctx *ctx,
+   bool use_degamma)
 {
struct drm_device *dev = crtc->dev;
struct drm_atomic_state *state;
@@ -3555,9 +3542,11 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc 
*crtc,
}
 
/* Reset DEGAMMA_LUT and CTM properties. */
-   replaced  = drm_property_replace_blob(&crtc_state->degamma_lut, NULL);
+   replaced  = drm_property_replace_blob(&crtc_state->degamma_lut,
+ use_degamma ? blob : NULL);
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
-   replaced |= drm_property_replace_blob(&crtc_state->gamma_lut, blob);
+   replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
+ use_degamma ? NULL : blob);
crtc_state->color_mgmt_changed |= replaced;
 
ret = drm_atomic_commit(state);
@@ -3567,8 +3556,60 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc 
*crtc,
drm_property_blob_put(blob);
return ret;
 }
+
+/**
+ * drm_atomic_helper_legacy_gamma_set - set the legacy gamma correction table 
using gamma_lut
+ * @crtc: CRTC object
+ * @red: red correction table
+ * @green: green correction table
+ * @blue: green correction table
+ * @size: size of the tables
+ * @ctx: lock acquire context
+ *
+ * Implements support for legacy gamma correction table for drivers
+ * that support color management through the DEGAMMA_LUT/GAMMA_LUT
+ * properties. See drm_crtc_enable_color_mgmt() and the containing chapter for
+ * how the atomic color management and gamma tables work.
+ *
+ * This function uses GAMMA_LUT property for the gamma table. This function
+ * can be used when the driver exposes either only GAMMA_LUT or both GAMMA_LUT
+ * and DEGAMMA_LUT.
+ */
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+  u16 *red, u16 *green, u16 *blue,
+  uint32_t size,
+  struct drm_modeset_acquire_ctx *ctx)
+{
+   return legacy_gamma_degamma_set(crtc, red, green, blue, size, ctx, 
false);
+}
 EXPORT_SYMBOL(drm_atomic_helper_legacy_gamma_set);
 
+/**
+ * drm_atomic_helper_legacy_degamma_set - set the legacy gamma correction 
table using degamma_lut
+ * @crtc: CRTC object
+ * @red: red correction table
+ * @green: green correction table
+ * @blue: green correction 

Re: [PATCH v2] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe

2020-11-03 Thread Tomi Valkeinen
On 02/11/2020 16:30, YueHaibing wrote:
> gpiod_to_irq() return negative value in case of error,
> the existing code doesn't handle negative error codes.
> If the HPD gpio supports IRQs (gpiod_to_irq returns a
> valid number), we use the IRQ. If it doesn't (gpiod_to_irq
> returns an error), it gets polled via detect(). 
> 
> Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI level 
> shifter")
> Signed-off-by: YueHaibing 
> ---
> v2: Add checking for >= 0 and update commit message
> ---
>  drivers/gpu/drm/bridge/ti-tpd12s015.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ti-tpd12s015.c 
> b/drivers/gpu/drm/bridge/ti-tpd12s015.c
> index 514cbf0eac75..e0e015243a60 100644
> --- a/drivers/gpu/drm/bridge/ti-tpd12s015.c
> +++ b/drivers/gpu/drm/bridge/ti-tpd12s015.c
> @@ -160,7 +160,7 @@ static int tpd12s015_probe(struct platform_device *pdev)
>  
>   /* Register the IRQ if the HPD GPIO is IRQ-capable. */
>   tpd->hpd_irq = gpiod_to_irq(tpd->hpd_gpio);
> - if (tpd->hpd_irq) {
> + if (tpd->hpd_irq >= 0) {
>   ret = devm_request_threaded_irq(&pdev->dev, tpd->hpd_irq, NULL,
>   tpd12s015_hpd_isr,
>   IRQF_TRIGGER_RISING |
> 

Reviewed-by: Tomi Valkeinen 

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe

2020-11-02 Thread Tomi Valkeinen
On 02/11/2020 11:36, Yuehaibing wrote:
> On 2020/11/2 14:57, Tomi Valkeinen wrote:
>> On 31/10/2020 09:19, Sam Ravnborg wrote:
>>> Hi YueHaibing
>>>
>>> Thanks for the fix. Appreciated but please update as per comments below.
>>>
>>> On Sat, Oct 31, 2020 at 11:16:48AM +0800, YueHaibing wrote:
>>>> gpiod_to_irq() return negative value in case of error,
>>>> the existing code handle negative error codes wrongly.
>>>>
>>>> Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI 
>>>> level shifter")
>>>> Signed-off-by: YueHaibing 
>>>> ---
>>>>  drivers/gpu/drm/bridge/ti-tpd12s015.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/bridge/ti-tpd12s015.c 
>>>> b/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>>> index 514cbf0eac75..a18d5197c16c 100644
>>>> --- a/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>>> +++ b/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>>> @@ -160,7 +160,7 @@ static int tpd12s015_probe(struct platform_device 
>>>> *pdev)
>>>>  
>>>>/* Register the IRQ if the HPD GPIO is IRQ-capable. */
>>>>tpd->hpd_irq = gpiod_to_irq(tpd->hpd_gpio);
>>>> -  if (tpd->hpd_irq) {
>>>> +  if (tpd->hpd_irq > 0) {
>>>>ret = devm_request_threaded_irq(&pdev->dev, tpd->hpd_irq, NULL,
>>>>tpd12s015_hpd_isr,
>>>>IRQF_TRIGGER_RISING |
>>>
>>> The current implmentation will skip devm_request_threaded_irq() in case
>>> or error - but continue with the rest of the function. So the
>>> driver fails to return an error code.
>>
>> That is intended. If the HPD gpio supports IRQs (gpiod_to_irq returns a 
>> valid number), we use the
>> IRQ. If it doesn't (gpiod_to_irq returns an error), it gets polled via 
>> detect(). Both are ok.
>>
>> I don't know if the gpiod_to_irq never returning 0 is something we should 
>> rely on. The docs say
>> gpiod_to_irq returns the irq number or an error, so I think checking for >= 
>> 0 matches the docs better.
>>
> 
> gpiod_to_irq() now never returns 0, see:
> https://elixir.bootlin.com/linux/v5.10-rc2/source/drivers/gpio/gpiolib.c#L3183
> 
> Also commit 4c37ce8608a8 ("gpio: make gpiod_to_irq() return negative for 
> NO_IRQ") says:
> 
> commit 4c37ce8608a8c6521726d4cd1d4f54424e8d095f
> Author: Linus Walleij 
> Date:   Mon May 2 13:13:10 2016 +0200
> 
> gpio: make gpiod_to_irq() return negative for NO_IRQ
> 
> If a translation returns zero, that means NO_IRQ, so we
> should return an error since the function is documented to
> return a negative code on error.
> 
> So checking for >0 is enough, my patch is correct.

Yes, but that is a gpiod_to_irq internal implementation detail. The 
documentation says it returns an
error code (negative) or a valid irq number. The documentation does not say 
gpiod_to_irq never
returns 0.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 5/5] drm/bridge: mhdp8564: Support format negotiation

2020-11-02 Thread Tomi Valkeinen
On 30/10/2020 00:39, Laurent Pinchart wrote:
> Hi Nikhil,
> 
> Thank you for the patch.
> 
> On Fri, Oct 16, 2020 at 04:09:17PM +0530, Nikhil Devshatwar wrote:
>> With new connector model, mhdp bridge will not create the connector and
>> SoC driver will rely on format negotiation to setup the encoder format.
>>
>> Support format negotiations hooks in the drm_bridge_funcs.
>> Support a single format for input.
>>
>> Signed-off-by: Nikhil Devshatwar 
>> ---
>>  .../drm/bridge/cadence/cdns-mhdp8546-core.c   | 29 +++
>>  1 file changed, 29 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c 
>> b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
>> index d0c65610ebb5..230f6e28f82f 100644
>> --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
>> +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
>> @@ -2078,6 +2078,34 @@ cdns_mhdp_bridge_atomic_reset(struct drm_bridge 
>> *bridge)
>>  return &cdns_mhdp_state->base;
>>  }
>>  
>> +static u32 *cdns_mhdp_get_input_bus_fmts(struct drm_bridge *bridge,
>> +  struct drm_bridge_state *bridge_state,
>> +  struct drm_crtc_state *crtc_state,
>> +  struct drm_connector_state *conn_state,
>> +  u32 output_fmt,
>> +  unsigned int *num_input_fmts)
>> +{
>> +u32 *input_fmts;
>> +u32 default_bus_format = MEDIA_BUS_FMT_RGB121212_1X36;
> 
> Display port supports quite a few different formats. See my reply to
> 4/5, except it's worse in the DP case :-) Especially given that multiple
> displays need to be taken into account. I'm afraid we need to decide how
> to map media bus formats to different DP use cases, possibly adding new
> bus formats as part of this exercise, and then revisit this patch.

I agree with the points you make here and for the tfp410 patch, but the point 
of these patches are
just to keep drivers working with the new connector model.

With the old model both tfp410 and mhdp create their own connector, and set the 
input bus format to
connector's display_info. With the new model, that doesn't happen and there's 
no bus format, and so
the display controller fails.

I see these more as fixes than implementing new features.

Nikhil, I think the output_fmt at the moment should always be FMT_FIXED. Maybe 
we can just check for
that.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe

2020-11-02 Thread Tomi Valkeinen
On 31/10/2020 09:19, Sam Ravnborg wrote:
> Hi YueHaibing
> 
> Thanks for the fix. Appreciated but please update as per comments below.
> 
> On Sat, Oct 31, 2020 at 11:16:48AM +0800, YueHaibing wrote:
>> gpiod_to_irq() return negative value in case of error,
>> the existing code handle negative error codes wrongly.
>>
>> Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI level 
>> shifter")
>> Signed-off-by: YueHaibing 
>> ---
>>  drivers/gpu/drm/bridge/ti-tpd12s015.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/ti-tpd12s015.c 
>> b/drivers/gpu/drm/bridge/ti-tpd12s015.c
>> index 514cbf0eac75..a18d5197c16c 100644
>> --- a/drivers/gpu/drm/bridge/ti-tpd12s015.c
>> +++ b/drivers/gpu/drm/bridge/ti-tpd12s015.c
>> @@ -160,7 +160,7 @@ static int tpd12s015_probe(struct platform_device *pdev)
>>  
>>  /* Register the IRQ if the HPD GPIO is IRQ-capable. */
>>  tpd->hpd_irq = gpiod_to_irq(tpd->hpd_gpio);
>> -if (tpd->hpd_irq) {
>> +if (tpd->hpd_irq > 0) {
>>  ret = devm_request_threaded_irq(&pdev->dev, tpd->hpd_irq, NULL,
>>  tpd12s015_hpd_isr,
>>  IRQF_TRIGGER_RISING |
> 
> The current implmentation will skip devm_request_threaded_irq() in case
> or error - but continue with the rest of the function. So the
> driver fails to return an error code.

That is intended. If the HPD gpio supports IRQs (gpiod_to_irq returns a valid 
number), we use the
IRQ. If it doesn't (gpiod_to_irq returns an error), it gets polled via 
detect(). Both are ok.

I don't know if the gpiod_to_irq never returning 0 is something we should rely 
on. The docs say
gpiod_to_irq returns the irq number or an error, so I think checking for >= 0 
matches the docs better.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/5] drm: bridge: Propagate the bus flags from bridge->timings

2020-10-30 Thread Tomi Valkeinen
Hi Boris,

On 30/10/2020 10:08, Boris Brezillon wrote:
> The "propagate output flags" and soon to be added "use
> timing->input_flags if present" logic should only be used as a fallback
> for bridges that do not support dynamic bus format/flags negotiation
> IMHO. Ideally we'd want to convert all bridges to do this dynamic bus
> format/flags negotiation and get rid of timings->input_bus_flags once
> this is done, but that's likely to take time. So, if your driver
> implements the ->atomic_check() hook and needs specific input flags,
> I'd recommend setting the input flags there instead of specifying it
> through timings->input_bus_flags.

What is bus flags negotiation? Don't we have negotiation only for bus formats? 
Bus flags are just
set, and the previous bridge in the chain has to use those flags.

Or do you just refer to setting the bus flags dynamically in atomic_check, 
versus static in
input_bus_flags?

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] fbcon: Disable accelerated scrolling

2020-10-30 Thread Tomi Valkeinen
On 29/10/2020 15:22, Daniel Vetter wrote:
> So ever since syzbot discovered fbcon, we have solid proof that it's
> full of bugs. And often the solution is to just delete code and remove
> features, e.g.  50145474f6ef ("fbcon: remove soft scrollback code").
> 
> Now the problem is that most modern-ish drivers really only treat
> fbcon as an dumb kernel console until userspace takes over, and Oops
> printer for some emergencies. Looking at drm drivers and the basic
> vesa/efi fbdev drivers shows that only 3 drivers support any kind of
> acceleration:
> 
> - nouveau, seems to be enabled by default
> - omapdrm, when a DMM remapper exists using remapper rewriting for
>   y/xpanning
> - gma500, but that is getting deleted now for the GTT remapper trick,
>   and the accelerated copyarea never set the FBINFO_HWACCEL_COPYAREA
>   flag, so unused (and could be deleted already I think).
> 
> No other driver supportes accelerated fbcon. And fbcon is the only
> user of this accel code (it's not exposed as uapi through ioctls),
> which means we could garbage collect fairly enormous amounts of code
> if we kill this.
> 
> Plus because syzbot only runs on virtual hardware, and none of the
> drivers for that have acceleration, we'd remove a huge gap in testing.
> And there's no other even remotely comprehensive testing aside from
> syzbot.
> 
> This patch here just disables the acceleration code by always
> redrawing when scrolling. The plan is that once this has been merged
> for well over a year in released kernels, we can start to go around
> and delete a lot of code.
> 
> v2:
> - Drop a few more unused local variables, somehow I missed the
> compiler warnings (Sam)
> - Fix typo in comment (Jiri)
> - add a todo entry for the cleanup (Thomas)
> 
> v3: Remove more unused variables (0day)
> 
> Reviewed-by: Thomas Zimmermann 
> Reviewed-by: Greg Kroah-Hartman 
> Acked-by: Sam Ravnborg 
> Cc: Jiri Slaby 
> Cc: Bartlomiej Zolnierkiewicz 
> Cc: Greg Kroah-Hartman 
> Cc: Linus Torvalds 
> Cc: Ben Skeggs 
> Cc: nouv...@lists.freedesktop.org
> Cc: Tomi Valkeinen 
> Cc: Daniel Vetter 
> Cc: Jiri Slaby 
> Cc: "Gustavo A. R. Silva" 
> Cc: Tetsuo Handa 
> Cc: Peilin Ye 
> Cc: George Kennedy 
> Cc: Nathan Chancellor 
> Cc: Peter Rosin 
> Signed-off-by: Daniel Vetter 
> ---
>  Documentation/gpu/todo.rst   | 18 +
>  drivers/video/fbdev/core/fbcon.c | 45 ++--
>  2 files changed, 26 insertions(+), 37 deletions(-)
> 
> diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
> index 6b224ef14455..bec99341a904 100644
> --- a/Documentation/gpu/todo.rst
> +++ b/Documentation/gpu/todo.rst
> @@ -277,6 +277,24 @@ Contact: Daniel Vetter, Noralf Tronnes
>  
>  Level: Advanced
>  
> +Garbage collect fbdev scrolling acceleration
> +
> +
> +Scroll acceleration is disabled in fbcon by hard-wiring p->scrollmode =
> +SCROLL_REDRAW. There's a ton of code this will allow us to remove:
> +- lots of code in fbcon.c
> +- a bunch of the hooks in fbcon_ops, maybe the remaining hooks could be 
> called
> +  directly instead of the function table (with a switch on p->rotate)
> +- fb_copyarea is unused after this, and can be deleted from all drivers
> +
> +Note that not all acceleration code can be deleted, since clearing and cursor
> +support is still accelerated, which might be good candidates for further
> +deletion projects.

Apparently omapdrm's accelerated panning has been broken for some time, and no 
one has noticed. It does:

strcmp(fbi->fix.id, MODULE_NAME), which is a comparison of omapdrmdrmfb == 
omapdrm and always fails.

Fixing that, and applying this patch, things work fine (unaccelerated, of 
course). I did notice a
single call to omap_fbdev_pan_display() when loading the drivers. This comes 
from fbcon_switch ->
bit_update_start -> fb_pan_display. Maybe this is from the clearing you mention 
above?

Reviewed-by: Tomi Valkeinen 

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/5] drm: bridge: Propagate the bus flags from bridge->timings

2020-10-30 Thread Tomi Valkeinen
On 30/10/2020 00:48, Laurent Pinchart wrote:

>>> And, hmm... It's too easy to get confused with these, but... If the bridge 
>>> defines timings, and
>>> timings->input_bus_flags != 0, should we always pick that, even if we got 
>>> something via
>>> output_flags? Logic being, if this bridge defines timings->input_bus_flags, 
>>> it probably wants that
>>> to be used regardless whether we got something from the next bridge.
> 
> timings->input_bus_flags is an API that predates format and flags
> propagation along the pipeline. I would assume that drivers that
> implement propagation should do so in a way that prioritize that API,
> and either not report flags in the timings (in which case giving
> priority to one or another wouldn't make a difference as both would
> never be provided together), or would report flags in the timings as a
> best effort fallback for display controller drivers that would look at
> them exclusively without supporting the new API. I would thus think that
> the flags obtained through format negotiation should be prioritized.

What do you mean "drivers that implement propagation"? Doesn't that come from 
the framework, not
from the drivers?

Say, we have two bridges, A -> B. A has timings->input_bus_flags.

When propagating the flags, we get something as B's input flags. Should A use 
B's input flags as A's
input flags, or should A use its timings->input_bus_flags? I was suggesting the 
latter. Nikhil's
patch does the latter, but only if B's input flags was 0.

A can override its input flags manually in atomic_check, but if the 
timings->input_bus_flags exists,
isn't it a sane choice to just pick that by default?

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 0/5] drm/tidss: Use new connector model for tidss

2020-10-29 Thread Tomi Valkeinen
On 28/10/2020 16:19, Nikhil Devshatwar wrote:

>> Also, with J7 EVM and DP, when I unload the modules I see:
>>
> I confirm the same issue.
> I doubt if it is because of the change I did.
> Will try to revert the patches and confirm again
My guess is that it's not your patches as such, but that the mhdp driver does 
not do irq related
cleanups properly and your patches bring the issue up.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: bridge: cdns: Kconfig: Switch over dependency to ARCH_K3

2020-10-27 Thread Tomi Valkeinen
On 26/10/2020 18:54, Nishanth Menon wrote:
> With the integration of chip-id detection scheme in kernel[1], there
> is no specific need to maintain multitudes of SoC specific config
> options, discussed as per [2], we have deprecated the usage in other
> places for v5.10-rc1. Fix the missing user so that we can clean up the
> configs in v5.11.
> 
> [1] drivers/soc/ti/k3-socinfo.c commit 907a2b7e2fc7 ("soc: ti: add k3 
> platforms chipid module driver")
> [2] 
> https://lore.kernel.org/linux-arm-kernel/20200908112534.t5bgrjf7y3a6l2ss@akan/
> 
> Fixes: afba7e6c5fc1 ("rm: bridge: cdns-mhdp8546: Add TI J721E wrapper")
> Cc: Swapnil Jakhade 
> Cc: Tomi Valkeinen 
> Cc: Laurent Pinchart 
> Cc: Yuti Amonkar 
> Cc: Jyri Sarha 
> Signed-off-by: Nishanth Menon 
> ---
>  drivers/gpu/drm/bridge/cadence/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bridge/cadence/Kconfig 
> b/drivers/gpu/drm/bridge/cadence/Kconfig
> index 511d67b16d14..ef8c230e0f62 100644
> --- a/drivers/gpu/drm/bridge/cadence/Kconfig
> +++ b/drivers/gpu/drm/bridge/cadence/Kconfig
> @@ -13,7 +13,7 @@ config DRM_CDNS_MHDP8546
>  if DRM_CDNS_MHDP8546
>  
>  config DRM_CDNS_MHDP8546_J721E
> - depends on ARCH_K3_J721E_SOC || COMPILE_TEST
> + depends on ARCH_K3 || COMPILE_TEST
>   bool "J721E Cadence DPI/DP wrapper support"
>   default y
>   help
> 

Reviewed-by: Tomi Valkeinen 

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 13/65] drm/omapdrm: Annotate dma-fence critical section in commit path

2020-10-26 Thread Tomi Valkeinen
On 23/10/2020 15:21, Daniel Vetter wrote:
> Nothing special, just put the end right after hw_done(). Note that in
> one path there's a wait for the flip/update to complete. But as far as
> I understand from comments and code that's only relevant for modesets,
> and skipped if there wasn't a modeset done on a given crtc.
> 
> For a bit more clarity pull the hw_done() call out of the if/else,
> that way it's a bit clearer flow. But happy to shuffle this around as
> is seen fit.
> 
> Signed-off-by: Daniel Vetter 
> Cc: Tomi Valkeinen 
> ---
>  drivers/gpu/drm/omapdrm/omap_drv.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
> b/drivers/gpu/drm/omapdrm/omap_drv.c
> index 2e598b8b72af..2b82a708eca6 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -68,6 +68,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state 
> *old_state)
>  {
>   struct drm_device *dev = old_state->dev;
>   struct omap_drm_private *priv = dev->dev_private;
> + bool fence_cookie = dma_fence_begin_signalling();
>  
>   priv->dispc_ops->runtime_get(priv->dispc);
>  
> @@ -90,8 +91,6 @@ static void omap_atomic_commit_tail(struct drm_atomic_state 
> *old_state)
>   omap_atomic_wait_for_completion(dev, old_state);
>  
>   drm_atomic_helper_commit_planes(dev, old_state, 0);
> -
> - drm_atomic_helper_commit_hw_done(old_state);
>   } else {
>   /*
>* OMAP3 DSS seems to have issues with the work-around above,
> @@ -101,10 +100,12 @@ static void omap_atomic_commit_tail(struct 
> drm_atomic_state *old_state)
>   drm_atomic_helper_commit_planes(dev, old_state, 0);
>  
>   drm_atomic_helper_commit_modeset_enables(dev, old_state);
> -
> - drm_atomic_helper_commit_hw_done(old_state);
>   }
>  
> + drm_atomic_helper_commit_hw_done(old_state);
> +
> + dma_fence_end_signalling(fence_cookie);
> +
>   /*
>* Wait for completion of the page flips to ensure that old buffers
>* can't be touched by the hardware anymore before cleaning up planes.
> 

Reviewed-by: Tomi Valkeinen 

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/5] drm: bridge: Propagate the bus flags from bridge->timings

2020-10-21 Thread Tomi Valkeinen
On 16/10/2020 13:39, Nikhil Devshatwar wrote:
> When the next bridge does not specify any bus flags, use the
> bridge->timings->input_bus_flags as fallback when propagating
> bus flags from next bridge to current bridge.
> 
> Signed-off-by: Nikhil Devshatwar 
> ---
>  drivers/gpu/drm/drm_bridge.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 64f0effb52ac..8353723323ab 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -975,6 +975,13 @@ drm_atomic_bridge_propagate_bus_flags(struct drm_bridge 
> *bridge,
>* duplicate the "dummy propagation" logic.
>*/
>   bridge_state->input_bus_cfg.flags = output_flags;
> +
> + /*
> +  * Use the bridge->timings->input_bus_flags as fallback if the next 
> bridge
> +  * does not specify the flags
> +  */
> + if (!bridge_state->input_bus_cfg.flags)
> + bridge_state->input_bus_cfg.flags = 
> bridge->timings->input_bus_flags;

According to docs, timings can be NULL.

And, hmm... It's too easy to get confused with these, but... If the bridge 
defines timings, and
timings->input_bus_flags != 0, should we always pick that, even if we got 
something via
output_flags? Logic being, if this bridge defines timings->input_bus_flags, it 
probably wants that
to be used regardless whether we got something from the next bridge.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/5] drm/tidss: Move to newer connector model

2020-10-21 Thread Tomi Valkeinen
On 16/10/2020 13:39, Nikhil Devshatwar wrote:
> To be able to support connector operations across multiple
> bridges, it is recommended that the connector should be
> created by the SoC driver instead of the bridges.
> 
> Modify the tidss modesetting initialization sequence to
> create the connector and attach bridges with flag
> DRM_BRIDGE_ATTACH_NO_CONNECTOR
> 
> Signed-off-by: Nikhil Devshatwar 
> ---
>  drivers/gpu/drm/tidss/tidss_drv.h |  3 +++
>  drivers/gpu/drm/tidss/tidss_kms.c | 15 ++-
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tidss/tidss_drv.h 
> b/drivers/gpu/drm/tidss/tidss_drv.h
> index 7de4bba52e6f..cfbf85a4d92b 100644
> --- a/drivers/gpu/drm/tidss/tidss_drv.h
> +++ b/drivers/gpu/drm/tidss/tidss_drv.h
> @@ -27,6 +27,9 @@ struct tidss_device {
>   unsigned int num_planes;
>   struct drm_plane *planes[TIDSS_MAX_PLANES];
>  
> + unsigned int num_connectors;
> + struct drm_connector *connectors[TIDSS_MAX_PORTS];
> +
>   spinlock_t wait_lock;   /* protects the irq masks */
>   dispc_irq_t irq_mask;   /* enabled irqs in addition to wait_list */
>  };
> diff --git a/drivers/gpu/drm/tidss/tidss_kms.c 
> b/drivers/gpu/drm/tidss/tidss_kms.c
> index 09485c7f0d6f..51c24b4a6a21 100644
> --- a/drivers/gpu/drm/tidss/tidss_kms.c
> +++ b/drivers/gpu/drm/tidss/tidss_kms.c
> @@ -7,6 +7,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -192,6 +193,7 @@ static int tidss_dispc_modeset_init(struct tidss_device 
> *tidss)
>   for (i = 0; i < num_pipes; ++i) {
>   struct tidss_plane *tplane;
>   struct tidss_crtc *tcrtc;
> + struct drm_connector *connector;
>   struct drm_encoder *enc;
>   u32 hw_plane_id = feat->vid_order[tidss->num_planes];
>   int ret;
> @@ -222,11 +224,22 @@ static int tidss_dispc_modeset_init(struct tidss_device 
> *tidss)
>   return PTR_ERR(enc);
>   }
>  
> - ret = drm_bridge_attach(enc, pipes[i].bridge, NULL, 0);
> + ret = drm_bridge_attach(enc, pipes[i].bridge, NULL,
> + DRM_BRIDGE_ATTACH_NO_CONNECTOR);
>   if (ret) {
>   dev_err(tidss->dev, "bridge attach failed: %d\n", ret);
>   return ret;
>   }
> +
> + connector = drm_bridge_connector_init(&tidss->ddev, enc);
> + if (IS_ERR(connector)) {
> + dev_err(tidss->dev, "bridge_connector create failed\n");
> + return PTR_ERR(connector);
> + }
> +
> + tidss->connectors[tidss->num_connectors++] = connector;
> +
> + drm_connector_attach_encoder(connector, enc);

This call may return an error.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 0/2] drm: add DisplayPort connector

2020-10-19 Thread Tomi Valkeinen
Hi,

This series adds the DT bindings and a driver for DisplayPort connector.

I have previously sent v1 and v2 with only the bindings. The bindings
are unchanged, but I updated the patch description slightly for eDP and
DP++.

 Tomi

Tomi Valkeinen (2):
  dt-bindings: dp-connector: add binding for DisplayPort connector
  drm/bridge: display-connector: add DP support

 .../display/connector/dp-connector.yaml   | 55 +++
 drivers/gpu/drm/bridge/display-connector.c| 46 +++-
 2 files changed, 99 insertions(+), 2 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/display/connector/dp-connector.yaml

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 2/2] drm/bridge: display-connector: add DP support

2020-10-19 Thread Tomi Valkeinen
Add DP support to display-connector driver. The driver will support HPD
via a GPIO and DP PWR.

DP PWR will be enabled at probe, which is not optimal, but I'm not sure
what would be a good place to enable and disable DP PWR. Perhaps
attach/detach, but I don't know if enabling HW is something that attach
is supposed to do.

In any case, I don't think there's much difference in power consumption
between the version in this patch and enabling the regulator later: if
the driver probes, supposedly it will attach very soon afterwards, and
we need to enable the DP PWR as soon as possible.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/bridge/display-connector.c | 46 +-
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/display-connector.c 
b/drivers/gpu/drm/bridge/display-connector.c
index 4d278573cdb9..04362feccd75 100644
--- a/drivers/gpu/drm/bridge/display-connector.c
+++ b/drivers/gpu/drm/bridge/display-connector.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,6 +21,8 @@ struct display_connector {
 
struct gpio_desc*hpd_gpio;
int hpd_irq;
+
+   struct regulator*dp_pwr;
 };
 
 static inline struct display_connector *
@@ -172,11 +175,12 @@ static int display_connector_probe(struct platform_device 
*pdev)
of_property_read_string(pdev->dev.of_node, "label", &label);
 
/*
-* Get the HPD GPIO for DVI and HDMI connectors. If the GPIO can provide
+* Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can 
provide
 * edge interrupts, register an interrupt handler.
 */
if (type == DRM_MODE_CONNECTOR_DVII ||
-   type == DRM_MODE_CONNECTOR_HDMIA) {
+   type == DRM_MODE_CONNECTOR_HDMIA ||
+   type == DRM_MODE_CONNECTOR_DisplayPort) {
conn->hpd_gpio = devm_gpiod_get_optional(&pdev->dev, "hpd",
 GPIOD_IN);
if (IS_ERR(conn->hpd_gpio)) {
@@ -223,6 +227,38 @@ static int display_connector_probe(struct platform_device 
*pdev)
}
}
 
+   /* Get the DP PWR for DP connector */
+   if (type == DRM_MODE_CONNECTOR_DisplayPort) {
+   int r;
+
+   conn->dp_pwr = devm_regulator_get_optional(&pdev->dev, 
"dp-pwr");
+
+   if (IS_ERR(conn->dp_pwr)) {
+   r = PTR_ERR(conn->dp_pwr);
+
+   switch (r) {
+   case -ENODEV:
+   conn->dp_pwr = NULL;
+   break;
+
+   case -EPROBE_DEFER:
+   return -EPROBE_DEFER;
+
+   default:
+   dev_err(&pdev->dev, "failed to get DP PWR 
regulator: %d\n", r);
+   return r;
+   }
+   }
+
+   if (conn->dp_pwr) {
+   r = regulator_enable(conn->dp_pwr);
+   if (r) {
+   dev_err(&pdev->dev, "failed to enable DP PWR 
regulator: %d\n", r);
+   return r;
+   }
+   }
+   }
+
conn->bridge.funcs = &display_connector_bridge_funcs;
conn->bridge.of_node = pdev->dev.of_node;
 
@@ -251,6 +287,9 @@ static int display_connector_remove(struct platform_device 
*pdev)
 {
struct display_connector *conn = platform_get_drvdata(pdev);
 
+   if (conn->dp_pwr)
+   regulator_disable(conn->dp_pwr);
+
drm_bridge_remove(&conn->bridge);
 
if (!IS_ERR(conn->bridge.ddc))
@@ -275,6 +314,9 @@ static const struct of_device_id display_connector_match[] 
= {
}, {
.compatible = "vga-connector",
.data = (void *)DRM_MODE_CONNECTOR_VGA,
+   }, {
+   .compatible = "dp-connector",
+   .data = (void *)DRM_MODE_CONNECTOR_DisplayPort,
},
{},
 };
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 1/2] dt-bindings: dp-connector: add binding for DisplayPort connector

2020-10-19 Thread Tomi Valkeinen
Add binding for DisplayPort connector. A few notes:

* Similar to hdmi-connector, it has hpd-gpios as an optional property,
  as the HPD could also be handled by, e.g., the DP bridge.

* dp-pwr-supply, which provides 3.3V on DP_PWR pin, is optional, as it
  is not strictly required: standard DP cables do not even have the pin
  connected.

* Connector type. Full size and mini connectors are identical except for
  the connector size and form, so I believe there is no functional need
  for this property. But similar to 'label' property, it might be used
  to present information about the connector to the userspace.

* No eDP. There's really no "eDP connector", as it's always a custom
  made connection between the DP and the DP panel, although the eDP spec
  does offer a few suggested pin setups. So possibly there is no need for
  edp-connector binding, but even if there is, I don't want to guess what
  it could look like, and could it be part of the dp-connector binding.

* No DP++. I'm not familiar with DP++. DP++ might need an i2c bus added
  to the bindings.

Signed-off-by: Tomi Valkeinen 
---
 .../display/connector/dp-connector.yaml   | 55 +++
 1 file changed, 55 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/connector/dp-connector.yaml

diff --git 
a/Documentation/devicetree/bindings/display/connector/dp-connector.yaml 
b/Documentation/devicetree/bindings/display/connector/dp-connector.yaml
new file mode 100644
index ..b5fc3e52899e
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/connector/dp-connector.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/connector/dp-connector.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DisplayPort Connector
+
+maintainers:
+  - Tomi Valkeinen 
+
+properties:
+  compatible:
+const: dp-connector
+
+  label: true
+
+  type:
+enum:
+  - full-size
+  - mini
+
+  hpd-gpios:
+description: A GPIO line connected to HPD
+maxItems: 1
+
+  dp-pwr-supply:
+description: Power supply for the DP_PWR pin
+maxItems: 1
+
+  port:
+description: Connection to controller providing DP signals
+
+required:
+  - compatible
+  - type
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+connector {
+compatible = "dp-connector";
+label = "dp0";
+type = "full-size";
+
+port {
+dp_connector_in: endpoint {
+remote-endpoint = <&dp_out>;
+};
+};
+};
+
+...
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 0/5] drm/tidss: Use new connector model for tidss

2020-10-19 Thread Tomi Valkeinen
Hi Nikhil,

On 16/10/2020 13:39, Nikhil Devshatwar wrote:
> This series moves the tidss to using new connectoe model, where the 
> SoC driver (tidss) creates the connector and all the bridges are 
> attached with the flag DRM_BRIDGE_ATTACH_NO_CONNECTOR
> 
> Since the bridges do not create the connector, the bus format and
> bus_flag is set after the format negotiation.
> Support format negotiations in the tfp410 and mhdp bridge drivers.
> 
> Nikhil Devshatwar (5):
>   drm/tidss: Move to newer connector model
>   drm/tidss: Set bus_format correctly from bridge/connector
>   drm: bridge: Propagate the bus flags from bridge->timings
>   drm/bridge: tfp410: Support format negotiation
>   drm/bridge: mhdp8564: Support format negotiation

I think the patch order could be a bit different. If you first change the tidss 
to use the new
connector model, and only afterwards fix the bridges we use, then there's a 
time when the displays
won't work.

Also, with J7 EVM and DP, when I unload the modules I see:

[   43.238895] irq 31: nobody cared (try booting with the "irqpoll" option)
[   43.245591] CPU: 0 PID: 349 Comm: irq/31-mhdp8546 Not tainted 
5.9.0-rc5-00605-g08a291316f86 #4
[   43.254186] Hardware name: Texas Instruments K3 J721E SoC (DT)
[   43.260006] Call trace:
[   43.262453]  dump_backtrace+0x0/0x1d8
[   43.266107]  show_stack+0x18/0x28
[   43.269416]  dump_stack+0xe0/0x14c
[   43.272810]  __report_bad_irq+0x4c/0xdc
[   43.276637]  note_interrupt+0x2cc/0x388
[   43.280465]  handle_irq_event_percpu+0x88/0x90
[   43.284898]  handle_irq_event+0x48/0xf8
[   43.288725]  handle_fasteoi_irq+0xcc/0x180
[   43.292811]  generic_handle_irq+0x30/0x48
[   43.296811]  __handle_domain_irq+0x94/0x108
[   43.300986]  gic_handle_irq+0x60/0x158
[   43.304726]  el1_irq+0xbc/0x180
[   43.307862]  _raw_spin_unlock_irq+0x48/0x90
[   43.312035]  irq_finalize_oneshot.part.0+0x68/0x108
[   43.316903]  irq_thread_fn+0x60/0xa0
[   43.320469]  irq_thread+0x1b8/0x248
[   43.323949]  kthread+0x128/0x160
[   43.327169]  ret_from_fork+0x10/0x34
[   43.330735] handlers:
[   43.333020] [<5367c4f9>] irq_default_primary_handler threaded 
[<7e02b601>]
cdns_mhdp_irq_handler [cdns_mhdp8546]
[   43.344607] Disabling IRQ #31

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: drm: Supporting new connector model in tidss

2020-10-06 Thread Tomi Valkeinen
Adding Boris who added bus format negotiation.

On 06/10/2020 00:31, Nikhil Devshatwar wrote:
> Hi all,
> 
> I am trying to convert the upstream tidss drm driver to new
> connector model.
> The connector is getting created by the tidss driver and bridges are
> attached with flag DRM_BRIDGE_ATTACH_NO_CONNECTOR
> Here are some questions, regarding this:

I was looking at this a bit, and below is my understanding. And I'm mostly 
talking about how things
should be with new code, not legacy code. Things are probably a bit more 
complex if you mix bridges
which implement different styles on how to deal with bus formats.

> 1) Most of the info regarding bus_format and bus flags is coming from
> the bridges. Is it okay to not populate connector->display_info with
> bus_format and flags?

drm_display_info describes the connected display and what goes on the wire to 
the display.

For monitors that's quite clear, and the data in display_info would reflect 
what the last bridge
needs to output. Most of the data comes from EDID, but I think bus format and 
flags do not. So a
bridge would need to fill them in, which doesn't make sense when we have a 
chain of bridges (which
would be the bridge to fill the data?). So for monitors, I think bus flags and 
formats in
display_info are unused.

For panels, I'm not sure. We have the bridge/panel.c which wraps the actual 
panel driver, so afaics
the panel is essentially the last bridge in the chain, and the connector is 
kind of a dummy
connector. But the panel driver fills in the display_info, and that's where the 
bridge/panel.c gets
the bus formats & flags for the negotiation.

Probably the above could be changed so that the panels take part of the 
negotiation process, and
then the bus formats and flags fields in the display_info could be removed.

> 2) The "drm_atomic_bridge_chain_select_bus_fmts" does the format
> negotiation. So is it okay for the encoder to simply pick the bus_format
> from the first bridge's state?

Yes, I think that is the idea. The first bridge's input is what the display 
controller's encoder
should output, and the negotiation should take care to provide something in the 
first bridge's state
for the input.

> 3) What is the meaning of MEDIA_BUS_FMT_FIXED? Does it mean that the
> bridge does not change the format from input to output?

I think it just means "undefined" here, and it's up to the drivers to decide 
what to do. I presume
this is mostly for drivers that don't support the new stuff, as each bridge 
should be able to tell
what formats & flags it supports.

> 4) The bus_flags are available in bridge->timings->input_bus_flags and
> also in bridge_state->input_bus_cfg.flags. Which one should be used?

I think bridge_state->input_bus_cfg. Although bridge->timings->input_bus_flags 
has some data that's
not in input_bus_cfg. If the drivers support the negotiation, I don't think
bridge->timings->input_bus_flags has any use.

Probably bridge->timings->input_bus_flags should be used as a fallback. So if a 
bridge is asked to
use MEDIA_BUS_FMT_FIXED as output (i.e. the next bridge doesn't support 
negotiation), then the
bridge might use a default format and also see if the next bridge has 
bridge->timings->input_bus_flags.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm: bridge: cdns-mhdp8546: fix compile warning

2020-10-01 Thread Tomi Valkeinen
Hi Dave,

Can you pick this up to drm-next? Fixes the x64 build warnings for the recent 
cdns-mhdp-5.10 pull.

 Tomi

On 29/09/2020 12:19, Tomi Valkeinen wrote:
> On x64 we get:
> 
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:751:10: warning: 
> conversion from 'long unsigned int' to 'unsigned int' changes value from 
> '18446744073709551613' to '4294967293' [-Woverflow]
> 
> The registers are 32 bit, so fix by casting to u32.
> 
> Fixes: fb43aa0acdfd ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP 
> bridge")
> Signed-off-by: Tomi Valkeinen 
> Reported-by: Stephen Rothwell 
> Reviewed-by: Swapnil Jakhade 
> Acked-by: Laurent Pinchart 
> ---
> 
> v2:
> 
> No changes to code, added tags.
> 
> 
>  drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c 
> b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
> index 621ebdbff8a3..d0c65610ebb5 100644
> --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
> +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
> @@ -748,7 +748,7 @@ static int cdns_mhdp_fw_activate(const struct firmware 
> *fw,
>* bridge should already be detached.
>*/
>   if (mhdp->bridge_attached)
> - writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
> + writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
>  mhdp->regs + CDNS_APB_INT_MASK);
>  
>   spin_unlock(&mhdp->start_lock);
> @@ -1689,7 +1689,7 @@ static int cdns_mhdp_attach(struct drm_bridge *bridge,
>  
>   /* Enable SW event interrupts */
>   if (hw_ready)
> - writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
> + writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
>  mhdp->regs + CDNS_APB_INT_MASK);
>  
>   return 0;
> @@ -2122,7 +2122,7 @@ static void cdns_mhdp_bridge_hpd_enable(struct 
> drm_bridge *bridge)
>  
>   /* Enable SW event interrupts */
>   if (mhdp->bridge_attached)
> - writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
> + writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
>  mhdp->regs + CDNS_APB_INT_MASK);
>  }
>  
> 

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 2/2] drm/tilcdc: Remove tilcdc_crtc_max_width(), use private data

2020-09-29 Thread Tomi Valkeinen
On 20/09/2020 19:59, Jyri Sarha wrote:
> We already have a private data member for maximum display width so
> let's use it and get rid of the redundant tilcdc_crtc_max_width().
> 
> The LCDC version probing is moved to before reading the device tree
> properties so that the version information is available when private
> data maximum width is initialized, if "max-width" property is not
> found.
> 
> Signed-off-by: Jyri Sarha 
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 16 +---
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c  | 38 +++-
>  drivers/gpu/drm/tilcdc/tilcdc_drv.h  |  7 ++---
>  3 files changed, 26 insertions(+), 35 deletions(-)

Reviewed-by: Tomi Valkeinen 

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm: bridge: cdns-mhdp8546: fix compile warning

2020-09-29 Thread Tomi Valkeinen
On x64 we get:

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:751:10: warning: conversion 
from 'long unsigned int' to 'unsigned int' changes value from 
'18446744073709551613' to '4294967293' [-Woverflow]

The registers are 32 bit, so fix by casting to u32.

Fixes: fb43aa0acdfd ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP 
bridge")
Signed-off-by: Tomi Valkeinen 
Reported-by: Stephen Rothwell 
Reviewed-by: Swapnil Jakhade 
Acked-by: Laurent Pinchart 
---

v2:

No changes to code, added tags.


 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c 
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index 621ebdbff8a3..d0c65610ebb5 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -748,7 +748,7 @@ static int cdns_mhdp_fw_activate(const struct firmware *fw,
 * bridge should already be detached.
 */
if (mhdp->bridge_attached)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 
spin_unlock(&mhdp->start_lock);
@@ -1689,7 +1689,7 @@ static int cdns_mhdp_attach(struct drm_bridge *bridge,
 
/* Enable SW event interrupts */
if (hw_ready)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 
return 0;
@@ -2122,7 +2122,7 @@ static void cdns_mhdp_bridge_hpd_enable(struct drm_bridge 
*bridge)
 
/* Enable SW event interrupts */
if (mhdp->bridge_attached)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: bridge: cdns-mhdp8546: fix compile warning

2020-09-25 Thread Tomi Valkeinen
On 25/09/2020 15:00, Laurent Pinchart wrote:
> On Fri, Sep 25, 2020 at 10:36:44AM +0300, Tomi Valkeinen wrote:
>> On 24/09/2020 14:48, Laurent Pinchart wrote:
>>> Hi Tomi,
>>>
>>> Thank you for the patch.
>>>
>>> On Wed, Sep 23, 2020 at 11:30:57AM +0300, Tomi Valkeinen wrote:
>>>> On x64 we get:
>>>>
>>>> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:751:10: warning: 
>>>> conversion from 'long unsigned int' to 'unsigned int' changes value from 
>>>> '18446744073709551613' to '4294967293' [-Woverflow]
>>>>
>>>> The registers are 32 bit, so fix by casting to u32.
>>>
>>> I wonder if we need a BIT32 macro... This is a common issue, it would be
>>> nice to handle it in the macros that define register fields.
>>
>> That's probably a good idea. I think
>>
>> #define BIT32(nr) (1u << (nr))
>>
>> should work correct on all archs. Although I'm not quite sure if nr should 
>> be cast to u32, but in my
>> tests a u64 nr doesn't cause type promotion to u64.
> 
> I don't think we need to support nr values larger than 2^32-1 ;-)

That's true, but we might have:

u64 nr = 1;
BIT32(nr)

Afaics, we don't need to cast nr to u32, but maybe that's still the safe thing 
to do.

>> Anyway, I'd like to merge this fix as it is to get rid of the warning for 
>> the merge window.
> 
> Sounds good to me.

Was that a reviewed-by? =)

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: bridge: cdns-mhdp8546: fix compile warning

2020-09-25 Thread Tomi Valkeinen
On 24/09/2020 14:48, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Wed, Sep 23, 2020 at 11:30:57AM +0300, Tomi Valkeinen wrote:
>> On x64 we get:
>>
>> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:751:10: warning: 
>> conversion from 'long unsigned int' to 'unsigned int' changes value from 
>> '18446744073709551613' to '4294967293' [-Woverflow]
>>
>> The registers are 32 bit, so fix by casting to u32.
> 
> I wonder if we need a BIT32 macro... This is a common issue, it would be
> nice to handle it in the macros that define register fields.

That's probably a good idea. I think

#define BIT32(nr) (1u << (nr))

should work correct on all archs. Although I'm not quite sure if nr should be 
cast to u32, but in my
tests a u64 nr doesn't cause type promotion to u64.

Anyway, I'd like to merge this fix as it is to get rid of the warning for the 
merge window.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCHv2] dt-bindings: dp-connector: add binding for DisplayPort connector

2020-09-24 Thread Tomi Valkeinen
On 23/09/2020 23:00, Rob Herring wrote:
> On Wed, Sep 23, 2020 at 11:15 AM Tomi Valkeinen  wrote:
>>
>> Hi Rob,
>>
>> On 23/09/2020 19:17, Rob Herring wrote:
>>
>>>> * No eDP. There's really no "eDP connector", as it's always a custom
>>>>made connection between the DP and the DP panel. So possibly there is
>>>>no need for edp-connector binding, but even if there is, I don't want
>>>>to guess what it could look like, and could it be part of the
>>>>dp-connector binding.
>>>
>>> I don't think that's true. Do an image search for 'edp pinout'. AFAICT,
>>> there's 2 lane 30 pin and 4 lane 40 pin. One image says 'Table 5-3 in
>>> eDP v1.2'. Of course, I'm sure there's custom ones too. From a binding
>>> perspective, we probably don't care about the differences, but just need
>>> to be able to describe HPD, backlight power, enable, and pwm, and LCD
>>> power.
>>
>> That's true. The eDP spec lists 4 different standard pinouts (how
>> strictly those are followed, I have no idea). But it does not define a
>> connector or a cable. And afaik eDP is defined to be not user-detachable.
> 
> Yes, but HPD is still used (or sometimes broken). We could just put
> that all in panel nodes, but IIRC the last time this came up the issue
> was handling devices with different panels stuffed by the
> manufacturer. An eDP connector binding would be one way to handle that
> as it is somewhat standardized while panel connections aren't at all.

HPD in DisplayPort, and especially in eDP, is not strictly speaking "cable 
inserted or removed", but
rather signaling that the monitor/panel is ready (e.g. after powering it up), 
or there has been a
link issue, or there has been a major change in settings, or signaling DP 
interrupt, etc. And HPD
(and EDID and some other things) are optional with eDP.

I don't think those rule out an edp-connector, but just things to consider.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: bridge: cdns-mhdp8546: fix compile warning

2020-09-24 Thread Tomi Valkeinen
On 23/09/2020 11:30, Tomi Valkeinen wrote:
> On x64 we get:
> 
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:751:10: warning: 
> conversion from 'long unsigned int' to 'unsigned int' changes value from 
> '18446744073709551613' to '4294967293' [-Woverflow]
> 
> The registers are 32 bit, so fix by casting to u32.
> 
> Fixes: fb43aa0acdfd ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP 
> bridge")
> Signed-off-by: Tomi Valkeinen 

I forgot to add

Reported-by: Stephen Rothwell 

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCHv2] dt-bindings: dp-connector: add binding for DisplayPort connector

2020-09-23 Thread Tomi Valkeinen

Hi Rob,

On 23/09/2020 19:17, Rob Herring wrote:


* No eDP. There's really no "eDP connector", as it's always a custom
   made connection between the DP and the DP panel. So possibly there is
   no need for edp-connector binding, but even if there is, I don't want
   to guess what it could look like, and could it be part of the
   dp-connector binding.


I don't think that's true. Do an image search for 'edp pinout'. AFAICT,
there's 2 lane 30 pin and 4 lane 40 pin. One image says 'Table 5-3 in
eDP v1.2'. Of course, I'm sure there's custom ones too. From a binding
perspective, we probably don't care about the differences, but just need
to be able to describe HPD, backlight power, enable, and pwm, and LCD
power.


That's true. The eDP spec lists 4 different standard pinouts (how 
strictly those are followed, I have no idea). But it does not define a 
connector or a cable. And afaik eDP is defined to be not user-detachable.


I think from the binding perspective the connectors present in the dts 
files are user-visible connectors, meant for plugging in and out. The 
connector node is the "end of the chain".


And non user-detachable ones (like MIPI DPI) do not have a connector in 
the dts, but just the video source and the panel linked together, and 
the panel is the end of the chain.


My thinking was that eDP is similar to MIPI DPI, and that we always 
define the eDP panel in the dts too. But I guess that might not be the 
case, as eDP does have all the bells and whistles to fully detect the 
panel. Although can it do all the probing needed for backlight and 
touch... And even then, should we have a generic-epd-panel present in 
the dts, or just a connector...


I don't know. So as I said, I'd rather leave eDP out for now (and you 
agreed, so no disagreement =).


I think we can later extend this binding, or if eDP just doesn't seem to 
fit into this, we can create a fully separate binding for eDP.


 Tomi

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/5] drm: add legacy support for using degamma for gamma

2020-09-23 Thread Tomi Valkeinen
We currently have drm_atomic_helper_legacy_gamma_set() helper which can
be used to handle legacy gamma-set ioctl.
drm_atomic_helper_legacy_gamma_set() sets GAMMA_LUT, and clears
CTM and DEGAMMA_LUT. This works fine on HW where we have either:

degamma -> ctm -> gamma -> out

or

ctm -> gamma -> out

However, if the HW has gamma table before ctm, the atomic property
should be DEGAMMA_LUT, and thus we have:

degamma -> ctm -> out

This is fine for userspace which sets gamma table using the properties,
as the userspace can check for the existence of gamma & degamma, but the
legacy gamma-set ioctl does not work.

This patch adds a new helper, drm_atomic_helper_legacy_degamma_set(),
which can be used instead of drm_atomic_helper_legacy_gamma_set() when
the DEGAMMA_LUT is the underlying property that needs to be set.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/drm_atomic_helper.c | 81 ++---
 include/drm/drm_atomic_helper.h |  4 ++
 2 files changed, 65 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 9e1ad493e689..5ba359114df6 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3469,24 +3469,11 @@ int drm_atomic_helper_page_flip_target(struct drm_crtc 
*crtc,
 }
 EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
 
-/**
- * drm_atomic_helper_legacy_gamma_set - set the legacy gamma correction table
- * @crtc: CRTC object
- * @red: red correction table
- * @green: green correction table
- * @blue: green correction table
- * @size: size of the tables
- * @ctx: lock acquire context
- *
- * Implements support for legacy gamma correction table for drivers
- * that support color management through the DEGAMMA_LUT/GAMMA_LUT
- * properties. See drm_crtc_enable_color_mgmt() and the containing chapter for
- * how the atomic color management and gamma tables work.
- */
-int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-  u16 *red, u16 *green, u16 *blue,
-  uint32_t size,
-  struct drm_modeset_acquire_ctx *ctx)
+static int legacy_gamma_degamma_set(struct drm_crtc *crtc,
+   u16 *red, u16 *green, u16 *blue,
+   uint32_t size,
+   struct drm_modeset_acquire_ctx *ctx,
+   bool use_degamma)
 {
struct drm_device *dev = crtc->dev;
struct drm_atomic_state *state;
@@ -3525,9 +3512,11 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc 
*crtc,
}
 
/* Reset DEGAMMA_LUT and CTM properties. */
-   replaced  = drm_property_replace_blob(&crtc_state->degamma_lut, NULL);
+   replaced  = drm_property_replace_blob(&crtc_state->degamma_lut,
+ use_degamma ? blob : NULL);
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
-   replaced |= drm_property_replace_blob(&crtc_state->gamma_lut, blob);
+   replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
+ use_degamma ? NULL : blob);
crtc_state->color_mgmt_changed |= replaced;
 
ret = drm_atomic_commit(state);
@@ -3537,8 +3526,60 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc 
*crtc,
drm_property_blob_put(blob);
return ret;
 }
+
+/**
+ * drm_atomic_helper_legacy_gamma_set - set the legacy gamma correction table 
using gamma_lut
+ * @crtc: CRTC object
+ * @red: red correction table
+ * @green: green correction table
+ * @blue: green correction table
+ * @size: size of the tables
+ * @ctx: lock acquire context
+ *
+ * Implements support for legacy gamma correction table for drivers
+ * that support color management through the DEGAMMA_LUT/GAMMA_LUT
+ * properties. See drm_crtc_enable_color_mgmt() and the containing chapter for
+ * how the atomic color management and gamma tables work.
+ *
+ * This function uses GAMMA_LUT property for the gamma table. This function
+ * can be used when the driver exposes either only GAMMA_LUT or both GAMMA_LUT
+ * and DEGAMMA_LUT.
+ */
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+  u16 *red, u16 *green, u16 *blue,
+  uint32_t size,
+  struct drm_modeset_acquire_ctx *ctx)
+{
+   return legacy_gamma_degamma_set(crtc, red, green, blue, size, ctx, 
false);
+}
 EXPORT_SYMBOL(drm_atomic_helper_legacy_gamma_set);
 
+/**
+ * drm_atomic_helper_legacy_degamma_set - set the legacy gamma correction 
table using degamma_lut
+ * @crtc: CRTC object
+ * @red: red correction table
+ * @green: green correction table
+ * @blue: green correction table
+ * @size: size of the tables
+ 

[PATCH 0/5] drm/omap: add color mgmt support

2020-09-23 Thread Tomi Valkeinen
Hi,

This series is based on patches sent about a year ago:

https://lists.freedesktop.org/archives/dri-devel/2019-September/233966.html
https://lists.freedesktop.org/archives/dri-devel/2019-September/233967.html

I've fixed the minor issues reported, and according to the recent
discussions with Pekka and Daniel, I have changed how the gamma works.

After these patches omapdrm will expose DEGAMMA_LUT (and no GAMMA_LUT),
and the legacy gamma-set ioctl will use DEGAMMA_LUT underneath. And on
top of that, we have the CTM and plane color mgmt.

 Tomi

Jyri Sarha (2):
  drm/omap: Implement CTM property for CRTC using OVL managers CPR
matrix
  drm/omap: Enable COLOR_ENCODING and COLOR_RANGE properties for planes

Tomi Valkeinen (3):
  drm: add legacy support for using degamma for gamma
  drm/omap: use degamma property for gamma table
  drm/omap: rearrange includes in omapdss.h

 drivers/gpu/drm/drm_atomic_helper.c   |  81 +++-
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 104 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  12 ++-
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  51 +++--
 drivers/gpu/drm/omapdrm/omap_plane.c  |  30 
 include/drm/drm_atomic_helper.h   |   4 +
 6 files changed, 209 insertions(+), 73 deletions(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/5] drm/omap: use degamma property for gamma table

2020-09-23 Thread Tomi Valkeinen
omapdrm supports gamma via GAMMA_LUT property. However, the HW we have
is:

gamma -> ctm -> out

instead of what the model DRM framework uses:

ctm -> gamma -> out

As the following patches add CTM support for omapdrm, lets first fix the
gamma.

This patch changes the property from GAMMA_LUT to DEGAMMA_LUT, and uses
drm_atomic_helper_legacy_degamma_set for gamma_set helper. Thus we will
have:

degamma -> ctm -> out

and the legacy ioctl will continue working as before.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 328a4a74f534..6116af920660 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -573,8 +573,8 @@ static int omap_crtc_atomic_check(struct drm_crtc *crtc,
 {
struct drm_plane_state *pri_state;
 
-   if (state->color_mgmt_changed && state->gamma_lut) {
-   unsigned int length = state->gamma_lut->length /
+   if (state->color_mgmt_changed && state->degamma_lut) {
+   unsigned int length = state->degamma_lut->length /
sizeof(struct drm_color_lut);
 
if (length < 2)
@@ -614,10 +614,10 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_color_lut *lut = NULL;
unsigned int length = 0;
 
-   if (crtc->state->gamma_lut) {
+   if (crtc->state->degamma_lut) {
lut = (struct drm_color_lut *)
-   crtc->state->gamma_lut->data;
-   length = crtc->state->gamma_lut->length /
+   crtc->state->degamma_lut->data;
+   length = crtc->state->degamma_lut->length /
sizeof(*lut);
}
priv->dispc_ops->mgr_set_gamma(priv->dispc, omap_crtc->channel,
@@ -738,7 +738,7 @@ static const struct drm_crtc_funcs omap_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
.destroy = omap_crtc_destroy,
.page_flip = drm_atomic_helper_page_flip,
-   .gamma_set = drm_atomic_helper_legacy_gamma_set,
+   .gamma_set = drm_atomic_helper_legacy_degamma_set,
.atomic_duplicate_state = omap_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
.atomic_set_property = omap_crtc_atomic_set_property,
@@ -839,7 +839,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
unsigned int gamma_lut_size = 256;
 
-   drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
+   drm_crtc_enable_color_mgmt(crtc, gamma_lut_size, false, 0);
drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
}
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/5] drm/omap: rearrange includes in omapdss.h

2020-09-23 Thread Tomi Valkeinen
Drop "uapi/" and rearrange alphabetically.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index ab19d4af8de7..8e9a2019f173 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -7,13 +7,13 @@
 #ifndef __OMAP_DRM_DSS_H
 #define __OMAP_DRM_DSS_H
 
-#include 
+#include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include 
+#include 
 
 #define DISPC_IRQ_FRAMEDONE(1 << 0)
 #define DISPC_IRQ_VSYNC(1 << 1)
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/5] drm/omap: Implement CTM property for CRTC using OVL managers CPR matrix

2020-09-23 Thread Tomi Valkeinen
From: Jyri Sarha 

Implement CTM color management property for OMAP CRTC using DSS
overlay manager's Color Phase Rotation matrix. The CPR matrix does not
exactly match the CTM property documentation. On DSS the CPR matrix is
applied after gamma table look up. However, it seems stupid to add a
custom property just for that.

Signed-off-by: Jyri Sarha 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 39 +++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 6116af920660..d2ff50322859 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -391,6 +391,33 @@ static void omap_crtc_manual_display_update(struct 
work_struct *data)
}
 }
 
+static s16 omap_crtc_s31_32_to_s2_8(s64 coef)
+{
+   u64 sign_bit = 1ULL << 63;
+   u64 cbits = (u64)coef;
+
+   s16 ret = clamp_val(((cbits & ~sign_bit) >> 24), 0, 0x1ff);
+
+   if (cbits & sign_bit)
+   ret = -ret;
+
+   return ret;
+}
+
+static void omap_crtc_cpr_coefs_from_ctm(const struct drm_color_ctm *ctm,
+struct omap_dss_cpr_coefs *cpr)
+{
+   cpr->rr = omap_crtc_s31_32_to_s2_8(ctm->matrix[0]);
+   cpr->rg = omap_crtc_s31_32_to_s2_8(ctm->matrix[1]);
+   cpr->rb = omap_crtc_s31_32_to_s2_8(ctm->matrix[2]);
+   cpr->gr = omap_crtc_s31_32_to_s2_8(ctm->matrix[3]);
+   cpr->gg = omap_crtc_s31_32_to_s2_8(ctm->matrix[4]);
+   cpr->gb = omap_crtc_s31_32_to_s2_8(ctm->matrix[5]);
+   cpr->br = omap_crtc_s31_32_to_s2_8(ctm->matrix[6]);
+   cpr->bg = omap_crtc_s31_32_to_s2_8(ctm->matrix[7]);
+   cpr->bb = omap_crtc_s31_32_to_s2_8(ctm->matrix[8]);
+}
+
 static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
 {
struct omap_drm_private *priv = crtc->dev->dev_private;
@@ -402,7 +429,15 @@ static void omap_crtc_write_crtc_properties(struct 
drm_crtc *crtc)
info.default_color = 0x00;
info.trans_enabled = false;
info.partial_alpha_enabled = false;
-   info.cpr_enable = false;
+
+   if (crtc->state->ctm) {
+   struct drm_color_ctm *ctm = crtc->state->ctm->data;
+
+   info.cpr_enable = true;
+   omap_crtc_cpr_coefs_from_ctm(ctm, &info.cpr_coefs);
+   } else {
+   info.cpr_enable = false;
+   }
 
priv->dispc_ops->mgr_setup(priv->dispc, omap_crtc->channel, &info);
 }
@@ -839,7 +874,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
unsigned int gamma_lut_size = 256;
 
-   drm_crtc_enable_color_mgmt(crtc, gamma_lut_size, false, 0);
+   drm_crtc_enable_color_mgmt(crtc, gamma_lut_size, true, 0);
drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
}
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/5] drm/omap: Enable COLOR_ENCODING and COLOR_RANGE properties for planes

2020-09-23 Thread Tomi Valkeinen
From: Jyri Sarha 

Adds support for COLOR_ENCODING and COLOR_RANGE properties to
omap_plane.c and dispc.c. The supported encodings and ranges are
presets are:

For COLOR_ENCODING:
- YCbCr BT.601 (default)
- YCbCr BT.709

For COLOR_RANGE:
- YCbCr limited range
- YCbCr full range (default)

Signed-off-by: Jyri Sarha 
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 104 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   4 +
 drivers/gpu/drm/omapdrm/omap_plane.c  |  30 
 3 files changed, 97 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 48593932bddf..bf0c9d293077 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -874,50 +874,67 @@ static void dispc_ovl_write_color_conv_coef(struct 
dispc_device *dispc,
 #undef CVAL
 }
 
-static void dispc_wb_write_color_conv_coef(struct dispc_device *dispc,
-  const struct csc_coef_rgb2yuv *ct)
-{
-   const enum omap_plane_id plane = OMAP_DSS_WB;
-
-#define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0))
+/* YUV -> RGB, ITU-R BT.601, full range */
+static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt601_full = {
+   256,   0,  358, /* ry, rcb, rcr |1.000  0.000  1.402|*/
+   256, -88, -182, /* gy, gcb, gcr |1.000 -0.344 -0.714|*/
+   256, 452,0, /* by, bcb, bcr |1.000  1.772  0.000|*/
+   true,   /* full range */
+};
 
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 0), CVAL(ct->yg,  
ct->yr));
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 1), CVAL(ct->crr, 
ct->yb));
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 2), CVAL(ct->crb, 
ct->crg));
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 3), CVAL(ct->cbg, 
ct->cbr));
-   dispc_write_reg(dispc, DISPC_OVL_CONV_COEF(plane, 4), CVAL(0, ct->cbb));
+/* YUV -> RGB, ITU-R BT.601, limited range */
+static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt601_lim = {
+   298,0,  409,/* ry, rcb, rcr |1.164  0.000  1.596|*/
+   298, -100, -208,/* gy, gcb, gcr |1.164 -0.392 -0.813|*/
+   298,  516,0,/* by, bcb, bcr |1.164  2.017  0.000|*/
+   false,  /* limited range */
+};
 
-   REG_FLD_MOD(dispc, DISPC_OVL_ATTRIBUTES(plane), ct->full_range, 11, 11);
+/* YUV -> RGB, ITU-R BT.709, full range */
+static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt709_full = {
+   256,0,  402,/* ry, rcb, rcr |1.000  0.000  1.570|*/
+   256,  -48, -120,/* gy, gcb, gcr |1.000 -0.187 -0.467|*/
+   256,  475,0,/* by, bcb, bcr |1.000  1.856  0.000|*/
+   true,   /* full range */
+};
 
-#undef CVAL
-}
+/* YUV -> RGB, ITU-R BT.709, limited range */
+static const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt709_lim = {
+   298,0,  459,/* ry, rcb, rcr |1.164  0.000  1.793|*/
+   298,  -55, -136,/* gy, gcb, gcr |1.164 -0.213 -0.533|*/
+   298,  541,0,/* by, bcb, bcr |1.164  2.112  0.000|*/
+   false,  /* limited range */
+};
 
-static void dispc_setup_color_conv_coef(struct dispc_device *dispc)
+static int dispc_ovl_set_csc(struct dispc_device *dispc,
+enum omap_plane_id plane,
+enum drm_color_encoding color_encoding,
+enum drm_color_range color_range)
 {
-   int i;
-   int num_ovl = dispc_get_num_ovls(dispc);
-
-   /* YUV -> RGB, ITU-R BT.601, limited range */
-   const struct csc_coef_yuv2rgb coefs_yuv2rgb_bt601_lim = {
-   298,0,  409,/* ry, rcb, rcr */
-   298, -100, -208,/* gy, gcb, gcr */
-   298,  516,0,/* by, bcb, bcr */
-   false,  /* limited range */
-   };
+   const struct csc_coef_yuv2rgb *csc;
 
-   /* RGB -> YUV, ITU-R BT.601, limited range */
-   const struct csc_coef_rgb2yuv coefs_rgb2yuv_bt601_lim = {
-66, 129,  25,  /* yr,   yg,  yb */
-   -38, -74, 112,  /* cbr, cbg, cbb */
-   112, -94, -18,  /* crr, crg, crb */
-   false,  /* limited range */
-   };
+   switch (color_encoding) {
+   case DRM_COLOR_YCBCR_BT601:
+   if (color_range == DRM_COLOR_YCBCR_FULL_RANGE)
+   csc = &coefs_yuv2rgb_bt601_full;
+   else
+   csc = &coefs_yuv2rgb_bt601_lim;
+   break;
+   case DRM_COLOR_YCBCR_BT709:
+   if (color_range == DRM_COLOR_YCBCR_FULL_RANGE)
+   csc = &coefs_yuv2rgb_bt709_full;
+   else
+   csc = &coefs_yuv2rgb_bt709_lim

[PATCH] drm: bridge: cdns-mhdp8546: fix compile warning

2020-09-23 Thread Tomi Valkeinen
On x64 we get:

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:751:10: warning: conversion 
from 'long unsigned int' to 'unsigned int' changes value from 
'18446744073709551613' to '4294967293' [-Woverflow]

The registers are 32 bit, so fix by casting to u32.

Fixes: fb43aa0acdfd ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP 
bridge")
Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c 
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index 621ebdbff8a3..d0c65610ebb5 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -748,7 +748,7 @@ static int cdns_mhdp_fw_activate(const struct firmware *fw,
 * bridge should already be detached.
 */
if (mhdp->bridge_attached)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 
spin_unlock(&mhdp->start_lock);
@@ -1689,7 +1689,7 @@ static int cdns_mhdp_attach(struct drm_bridge *bridge,
 
/* Enable SW event interrupts */
if (hw_ready)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 
return 0;
@@ -2122,7 +2122,7 @@ static void cdns_mhdp_bridge_hpd_enable(struct drm_bridge 
*bridge)
 
/* Enable SW event interrupts */
if (mhdp->bridge_attached)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: linux-next: build warning after merge of the drm tree

2020-09-23 Thread Tomi Valkeinen
Hi Stephen,

On 23/09/2020 06:36, Stephen Rothwell wrote:
> Hi all,
> 
> After merging the drm tree, today's linux-next build (x86_64 allmodconfig)
> produced this warning:
> 
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c: In function 
> 'cdns_mhdp_fw_activate':
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:751:10: warning: 
> conversion from 'long unsigned int' to 'unsigned int' changes value from 
> '18446744073709551613' to '4294967293' [-Woverflow]
>   751 |   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c: In function 
> 'cdns_mhdp_attach':
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:1692:10: warning: 
> conversion from 'long unsigned int' to 'unsigned int' changes value from 
> '18446744073709551613' to '4294967293' [-Woverflow]
>  1692 |   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c: In function 
> 'cdns_mhdp_bridge_hpd_enable':
> drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2125:10: warning: 
> conversion from 'long unsigned int' to 'unsigned int' changes value from 
> '18446744073709551613' to '4294967293' [-Woverflow]
>  2125 |   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
> 
> Introduced by commit
> 
>   fb43aa0acdfd ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP bridge")
> 

Thanks. I think we can just do:

diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c 
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index 621ebdbff8a3..d0c65610ebb5 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -748,7 +748,7 @@ static int cdns_mhdp_fw_activate(const struct firmware *fw,
 * bridge should already be detached.
 */
if (mhdp->bridge_attached)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 
spin_unlock(&mhdp->start_lock);
@@ -1689,7 +1689,7 @@ static int cdns_mhdp_attach(struct drm_bridge *bridge,
 
/* Enable SW event interrupts */
if (hw_ready)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 
return 0;
@@ -2122,7 +2122,7 @@ static void cdns_mhdp_bridge_hpd_enable(struct drm_bridge 
*bridge)
 
/* Enable SW event interrupts */
if (mhdp->bridge_attached)
-   writel(~CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 }

I'll send a patch.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/7] drm/omap: Implement CTM property for CRTC using OVL managers CPR matrix

2020-09-22 Thread Tomi Valkeinen
On 21/09/2020 14:49, Pekka Paalanen wrote:

> would it not be simplest if KMS UAPI specification defined the abstract
> color pipeline with all the blocks that may be exposed with
> driver-agnostic UAPI, and then just say that if a block is not present,
> it behaves as pass-through, a no-op?
> 
> Each block would be represented by standardised KMS properties, that
> either exist or don't.
> 
> I think that would be fairly easy for userspace to grasp, but I don't
> know if the abstract model itself would be feasible considering all the
> hardware out there.
> 
> If we happened to be limited to
> 
> FB -> plane-degamma -> plane-CTM -> plane-gamma -> (blending) ->
> degamma -> CTM -> gamma -> encoder -> wire
> 
> it would still be tractable.
> 
> No funny business with new KMS properties changing how old KMS
> properties behave. Old userspace understands and uses old KMS
> properties but not new KMS properties, so it wouldn't even work.

Isn't this how it's currently defined for the output side? So if I understand 
right, your suggestion
means that a HW that has:

gamma -> CTM -> out

would map those to DRM's degamma and CTM, and the userspace should use degamma 
to do gamma? I'm ok
with that, and it's probably more manageable than having properties which would 
describe the order
of the blocks.

While using degamma for gamma sounds a bit illogical, but thinking of it as:

pregamma -> ctm -> postgamma

sounds fine.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH -next] drm: omapdrm: dss: simplify the return expression of hdmi_init_pll_data

2020-09-21 Thread Tomi Valkeinen
Hi,

On 21/09/2020 16:10, Qinglang Miao wrote:
> Simplify the return expression.
> 
> Signed-off-by: Qinglang Miao 
> ---
>  drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 7 +--
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c 
> b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> index cf2b000f3..c3e85b636 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
> @@ -131,7 +131,6 @@ static int hdmi_init_pll_data(struct dss_device *dss,
>  {
>   struct dss_pll *pll = &hpll->pll;
>   struct clk *clk;
> - int r;
>  
>   clk = devm_clk_get(&pdev->dev, "sys_clk");
>   if (IS_ERR(clk)) {
> @@ -151,11 +150,7 @@ static int hdmi_init_pll_data(struct dss_device *dss,
>  
>   pll->ops = &hdmi_pll_ops;
>  
> - r = dss_pll_register(dss, pll);
> - if (r)
> - return r;
> -
> - return 0;
> + return dss_pll_register(dss, pll);
>  }
>  
>  int hdmi_pll_init(struct dss_device *dss, struct platform_device *pdev,
> 

I like it more when there's a return 0 at the end of the function, especially 
in functions where
there are multiple cases of if(...) return r. It's more easily readable, at 
least to my eyes.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/7] drm/omap: Implement CTM property for CRTC using OVL managers CPR matrix

2020-09-21 Thread Tomi Valkeinen
Hi,

On 04/09/2019 23:20, Ilia Mirkin wrote:

>> Implement CTM color management property for OMAP CRTC using DSS
>> overlay manager's Color Phase Rotation matrix. The CPR matrix does not
>> exactly match the CTM property documentation. On DSS the CPR matrix is
>> applied after gamma table look up. However, it seems stupid to add a
>> custom property just for that.
>
> In that case the DRM documentation should be updated to mention that
> both options are allowed.

 Ok, if that is alright. But if we do that, then I guess all the drivers
 implementing CTM should document the point where it is applied in the
 pipeline.
>>>
>>> Whatever solution we end up picking, I think it should at least be
>>> discussed with a broader upstream audience and not just swept under the
>>> omapdrm carpet :-)
>>>
>>
>> I'll try to write something and send the next series to wider audience.
>> Let's see what jury says.
> 
> In case it's useful ... the pipeline normally goes degamma -> ctm ->
> gamma. If your ctm is applied after gamma, perhaps you can just rename
> "gamma" to "degamma" and be done? (There's the unfortunate case of
> legacy gamma which does end up in "GAMMA" when using atomic helpers.
> But in such a case, you won't have a CTM.)

Waking up old thread, as I started looking at these patches again. So the 
problem was that DRM
defines the output color transformations as:

degamma -> ctm -> gamma -> out

whereas OMAP DSS has

gamma -> ctm -> out

The omapdrm driver could declare the gamma table as degamma, as suggested by 
Ilia, and for the
legacy drmModeCrtcSetGamma, the omapdrm driver could implement its own version, 
and use the degamma
table internally (with no ctm).

For legacy, that would work fine and as expected, but I think the atomic 
version would be a bit odd,
with only degamma, and no gamma.

Quick grep for drm_crtc_enable_color_mgmt shows that there are other drivers 
that have CTM and
gamma, but no degamma. I wonder if all those have ctm -> gamma -> out, or are 
they similar to OMAP DSS.

Any thoughts on how to proceed with this?

Should we have a property that describes the order? Or new property name for 
gamma before ctm
(PREGAMMA)? Or just have it as degamma, and let the userspace deal with it 
(i.e. figure out there's
no gamma, but there's degamma, so use degamma)?

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[GIT PULL] cdns-mhdp bridge for 5.10

2020-09-18 Thread Tomi Valkeinen
Hi Dave, Daniel,

Here's a pull requests for Cadence MHDP DisplayPort bridge driver. It's almost
-rc6, but I'd like to see this merged in 5.10 to make it easier to get the last
bits (mainly dts files) merged in 5.11.

The MHDP driver compile-time-depends on two PHY patches (queued in phy tree),
for which there's a stable git branch based on -rc1 provided by Vinod:

git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy phy-attrs-5.10

I have merged this stable branch here to keep MHDP compiling.

This is based on latest drm-next.

 Tomi   

The following changes since commit b40be05ed255d9a0257fb66ab2728ecca2c9d597:

  Merge branch 'for-5.10-drm-sg-fix' of https://github.com/mszyprow/linux into 
drm-next (2020-09-17 16:07:11 +1000)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux.git 
tags/cdns-mhdp-5.10

for you to fetch changes up to afba7e6c5fc190b687f3d87bc6d1029d1500c059:

  drm: bridge: cdns-mhdp8546: Add TI J721E wrapper (2020-09-18 15:16:02 +0300)


Cadence MHDP8546 DisplayPort bridge driver


Swapnil Jakhade (4):
  phy: Add new PHY attribute max_link_rate
  phy: cadence-torrent: Set Torrent PHY attributes
  drm: bridge: Add support for Cadence MHDP8546 DPI/DP bridge
  drm: bridge: cdns-mhdp8546: Add TI J721E wrapper

Tomi Valkeinen (1):
  Merge tag 'phy-attrs-5.10' of git://git.kernel.org/.../phy/linux-phy into 
5.10/dp-pull

Yuti Amonkar (1):
  dt-bindings: drm/bridge: Document Cadence MHDP8546 bridge bindings

 .../bindings/display/bridge/cdns,mhdp8546.yaml |  169 ++
 drivers/gpu/drm/bridge/Kconfig |2 +
 drivers/gpu/drm/bridge/Makefile|1 +
 drivers/gpu/drm/bridge/cadence/Kconfig |   24 +
 drivers/gpu/drm/bridge/cadence/Makefile|4 +
 .../gpu/drm/bridge/cadence/cdns-mhdp8546-core.c| 2532 
 .../gpu/drm/bridge/cadence/cdns-mhdp8546-core.h|  400 
 .../gpu/drm/bridge/cadence/cdns-mhdp8546-j721e.c   |   78 +
 .../gpu/drm/bridge/cadence/cdns-mhdp8546-j721e.h   |   19 +
 drivers/phy/cadence/phy-cadence-torrent.c  |4 +
 include/linux/phy/phy.h|2 +
 11 files changed, 3235 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/cdns,mhdp8546.yaml
 create mode 100644 drivers/gpu/drm/bridge/cadence/Kconfig
 create mode 100644 drivers/gpu/drm/bridge/cadence/Makefile
 create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
 create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h
 create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-j721e.c
 create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-j721e.h


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 1/2] dt-bindings: display: ti,am65x-dss: add missing properties to dt-schema

2020-09-18 Thread Tomi Valkeinen
On 18/09/2020 04:18, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Wed, Sep 16, 2020 at 04:10:08PM +0300, Tomi Valkeinen wrote:
>> Add assigned-clocks, assigned-clock-parents and dma-coherent optional
>> properties.
>>
>> Signed-off-by: Tomi Valkeinen 
>> Reviewed-by: Rob Herring 
>> ---
>>  .../devicetree/bindings/display/ti/ti,am65x-dss.yaml  | 11 +++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml 
>> b/Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
>> index 4f9185462ed3..4dc30738ee57 100644
>> --- a/Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
>> +++ b/Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
>> @@ -55,6 +55,14 @@ properties:
>>- const: vp1
>>- const: vp2
>>  
>> +  assigned-clocks:
>> +minItems: 1
>> +maxItems: 3
>> +
>> +  assigned-clock-parents:
>> +minItems: 1
>> +maxItems: 3
>> +
> 
> Those properties can occur in any node that has clocks. Do we need to
> specify them explicitly in every schema ?

I don't really know the dt-schema stuff well enough yet to have a good answer, 
but if this
information would come from somewhere else, it would somehow need to know:

- are there clocks in this schema (i.e. is assigned-clocks allowed or not)
- how many clocks there are (for min and max items)

This would also apply to assigned-clock-rates.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCHv2] dt-bindings: dp-connector: add binding for DisplayPort connector

2020-09-17 Thread Tomi Valkeinen
On 17/09/2020 14:22, Ville Syrjälä wrote:
> On Thu, Sep 17, 2020 at 08:52:10AM +0300, Tomi Valkeinen wrote:
>> Add binding for DisplayPort connector. A few notes:
>>
>> * Similar to hdmi-connector, it has hpd-gpios as an optional property,
>>   as the HPD could also be handled by, e.g., the DP bridge.
>>
>> * dp-pwr-supply, which provides 3.3V on DP_PWR pin, is optional, as it
>>   is not strictly required: standard DP cables do not even have the pin
>>   connected.
>>
>> * Connector type. Full size and mini connectors are identical except for
>>   the connector size and form, so I believe there is no functional need
>>   for this property. But similar to 'label' property, it might be used
>>   to present information about the connector to the userspace.
>>
>> * No eDP. There's really no "eDP connector", as it's always a custom
>>   made connection between the DP and the DP panel. So possibly there is
>>   no need for edp-connector binding, but even if there is, I don't want
>>   to guess what it could look like, and could it be part of the
>>   dp-connector binding.
>>
>> * No DP++. I'm not familiar with DP++, but I think it's all handled by
>>   the DP bridge, and does not need any new properties to the dp-connector.
> 
> You might need an i2c bus for this. It's up to the source device
> to either hook up just AUX CH, or both AUX CH and DDC to a DP++
> connector. If just AUX CH is wired up you are limited to using
> only type2 DP dual mode adapters, whereas if you also have DDC
> the crappier type1 adapters will also work.

Ok, thanks for the clarifications on this.

> I guess it's possible some bridges might handle all that for you.
> But eg. on i915 we always set up both AUX CH and DDC, and some
> extra circuitry on the board will isolate one or the other
> depending on what kind of dongle/cable gets plugged in
> (identified via the CONFIG pins).

Is that automatic on i915? I could imagine a gpio-controlled mux doing the 
isolation, and then we
need some driver controlling the gpio.

I could add the ddc bus the same way as on hdmi-connector.yaml, but perhaps 
it's better to leave
that for someone with a DP++ board. Afaics, there should be no problems adding 
this later.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCHv2] dt-bindings: dp-connector: add binding for DisplayPort connector

2020-09-17 Thread Tomi Valkeinen
Add binding for DisplayPort connector. A few notes:

* Similar to hdmi-connector, it has hpd-gpios as an optional property,
  as the HPD could also be handled by, e.g., the DP bridge.

* dp-pwr-supply, which provides 3.3V on DP_PWR pin, is optional, as it
  is not strictly required: standard DP cables do not even have the pin
  connected.

* Connector type. Full size and mini connectors are identical except for
  the connector size and form, so I believe there is no functional need
  for this property. But similar to 'label' property, it might be used
  to present information about the connector to the userspace.

* No eDP. There's really no "eDP connector", as it's always a custom
  made connection between the DP and the DP panel. So possibly there is
  no need for edp-connector binding, but even if there is, I don't want
  to guess what it could look like, and could it be part of the
  dp-connector binding.

* No DP++. I'm not familiar with DP++, but I think it's all handled by
  the DP bridge, and does not need any new properties to the dp-connector.

Signed-off-by: Tomi Valkeinen 
---

Changes in v2: Add connector type.


 .../display/connector/dp-connector.yaml   | 55 +++
 1 file changed, 55 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/connector/dp-connector.yaml

diff --git 
a/Documentation/devicetree/bindings/display/connector/dp-connector.yaml 
b/Documentation/devicetree/bindings/display/connector/dp-connector.yaml
new file mode 100644
index ..b5fc3e52899e
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/connector/dp-connector.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/connector/dp-connector.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DisplayPort Connector
+
+maintainers:
+  - Tomi Valkeinen 
+
+properties:
+  compatible:
+const: dp-connector
+
+  label: true
+
+  type:
+enum:
+  - full-size
+  - mini
+
+  hpd-gpios:
+description: A GPIO line connected to HPD
+maxItems: 1
+
+  dp-pwr-supply:
+description: Power supply for the DP_PWR pin
+maxItems: 1
+
+  port:
+description: Connection to controller providing DP signals
+
+required:
+  - compatible
+  - type
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+connector {
+compatible = "dp-connector";
+label = "dp0";
+type = "full-size";
+
+port {
+dp_connector_in: endpoint {
+remote-endpoint = <&dp_out>;
+};
+};
+};
+
+...
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


<    6   7   8   9   10   11   12   13   14   15   >