Re: [PATCH 1/5] drm: drm_bridge: add cec_init/exit bridge ops

2021-02-19 Thread Tomi Valkeinen
On 11/02/2021 12:36, Hans Verkuil wrote:
> Add bridge cec_init/exit ops. These ops will be responsible for
> creating and destroying the CEC adapter for the bridge that supports
> CEC.
> 
> Signed-off-by: Hans Verkuil 
> ---
>  drivers/gpu/drm/drm_bridge_connector.c | 23 +++
>  include/drm/drm_bridge.h   | 31 ++
>  2 files changed, 54 insertions(+)

Reviewed-by: Tomi Valkeinen 

 Tomi

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


Re: [PATCH 4/5] drm/omap: hdmi5: add CEC support

2021-02-19 Thread Tomi Valkeinen
Hi Hans,

On 11/02/2021 12:37, Hans Verkuil wrote:
> Add HDMI CEC support for OMAP5.
> 
> Many thanks to Tomi for helping out how to enable CEC for omap5.
> 
> Signed-off-by: Hans Verkuil 
> Thanks-to: Tomi Valkeinen 
> ---
>  drivers/gpu/drm/omapdrm/dss/Kconfig  |   8 +
>  drivers/gpu/drm/omapdrm/dss/Makefile |   1 +
>  drivers/gpu/drm/omapdrm/dss/hdmi.h   |   1 +
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c  |  63 +--
>  drivers/gpu/drm/omapdrm/dss/hdmi5_cec.c  | 201 +++
>  drivers/gpu/drm/omapdrm/dss/hdmi5_cec.h  |  42 +
>  drivers/gpu/drm/omapdrm/dss/hdmi5_core.c |  28 +++-
>  drivers/gpu/drm/omapdrm/dss/hdmi5_core.h |  33 +++-
>  8 files changed, 358 insertions(+), 19 deletions(-)
>  create mode 100644 drivers/gpu/drm/omapdrm/dss/hdmi5_cec.c
>  create mode 100644 drivers/gpu/drm/omapdrm/dss/hdmi5_cec.h
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig 
> b/drivers/gpu/drm/omapdrm/dss/Kconfig
> index e11b258a2294..67a1ba14703b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/Kconfig
> +++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
> @@ -83,6 +83,14 @@ config OMAP5_DSS_HDMI
> Definition Multimedia Interface. See https://www.hdmi.org/ for HDMI
> specification.
>  
> +config OMAP5_DSS_HDMI_CEC
> + bool "Enable HDMI CEC support for OMAP5"
> + depends on OMAP5_DSS_HDMI
> + select CEC_CORE
> + default y
> + help
> +   When selected the HDMI transmitter will support the CEC feature.
> +
>  config OMAP2_DSS_SDI
>   bool "SDI support"
>   default n
> diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile 
> b/drivers/gpu/drm/omapdrm/dss/Makefile
> index f967e6948f2e..94fe0fa3b3c2 100644
> --- a/drivers/gpu/drm/omapdrm/dss/Makefile
> +++ b/drivers/gpu/drm/omapdrm/dss/Makefile
> @@ -17,4 +17,5 @@ omapdss-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += hdmi_common.o 
> hdmi_wp.o hdmi_pll.o \
>  omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi4_core.o
>  omapdss-$(CONFIG_OMAP4_DSS_HDMI_CEC) += hdmi4_cec.o
>  omapdss-$(CONFIG_OMAP5_DSS_HDMI) += hdmi5.o hdmi5_core.o
> +omapdss-$(CONFIG_OMAP5_DSS_HDMI_CEC) += hdmi5_cec.o
>  ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h 
> b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> index c4a4e07f0b99..72d8ae441da6 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
> @@ -261,6 +261,7 @@ struct hdmi_core_data {
>   struct hdmi_wp_data *wp;
>   unsigned int core_pwr_cnt;
>   struct cec_adapter *adap;
> + struct clk *cec_clk;
>  };
>  
>  static inline void hdmi_write_reg(void __iomem *base_addr, const u32 idx,
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
> b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 54e5cb5aa52d..b674d8ba173f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -29,12 +29,14 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
>  
>  #include "omapdss.h"
>  #include "hdmi5_core.h"
> +#include "hdmi5_cec.h"
>  #include "dss.h"
>  
>  static int hdmi_runtime_get(struct omap_hdmi *hdmi)
> @@ -104,6 +106,10 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
>   } else if (irqstatus & HDMI_IRQ_LINK_DISCONNECT) {
>   hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
>   }

Empty line here, please.

> + if (irqstatus & HDMI_IRQ_CORE) {
> + hdmi5_cec_irq(>core);
> + hdmi5_core_handle_irqs(>core);
> + }

It's a bit odd to call two functions here. Would it work if
hdmi5_core_handle_irqs() would read and clear HDMI_CORE_IH_CEC_STAT0,
and call hdmi5_cec_irq() if the stat != 0 ?

And it would be nice if hdmi5_core.c would enable and disable core
interrupt, but maybe that can be left for later if the need ever comes
to handle other interrupts than cec.

>  
>   return IRQ_HANDLED;
>  }
> @@ -112,9 +118,12 @@ static int hdmi_power_on_core(struct omap_hdmi *hdmi)
>  {
>   int r;
>  
> + if (hdmi->core.core_pwr_cnt++)
> + return 0;
> +
>   r = regulator_enable(hdmi->vdda_reg);
>   if (r)
> - return r;
> + goto err_reg_enable;
>  
>   r = hdmi_runtime_get(hdmi);
>   if (r)
> @@ -129,12 +138,17 @@ static int hdmi_power_on_core(struct omap_hdmi *hdmi)
>  
>  err_runtime_get:
>   regulator_disable(hdmi->vdda_reg);
> +err_reg_enable:
> + hdmi->core.core_pwr_cnt--;
>  
>   return r;
>  }
>  
>  static void hdmi_power_off_core(struct omap_hdmi *hdmi)
>  {
> + if (--h

Re: [PATCH 5/5] ARM: dts: dra7/omap5: add cec clock

2021-02-19 Thread Tomi Valkeinen
Hi Hans,

On 11/02/2021 12:37, Hans Verkuil wrote:
> Add cec clock to the dra7 and omap5 device trees.
> 
> Signed-off-by: Hans Verkuil 
> ---
>  arch/arm/boot/dts/dra7.dtsi  | 5 +++--
>  arch/arm/boot/dts/omap5.dtsi | 5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
> index ce1194744f84..efe579ddb324 100644
> --- a/arch/arm/boot/dts/dra7.dtsi
> +++ b/arch/arm/boot/dts/dra7.dtsi
> @@ -879,8 +879,9 @@ hdmi: encoder@0 {
>   interrupts =  IRQ_TYPE_LEVEL_HIGH>;
>   status = "disabled";
>   clocks = <_clkctrl 
> DRA7_DSS_DSS_CORE_CLKCTRL 9>,
> -  <_clkctrl 
> DRA7_DSS_DSS_CORE_CLKCTRL 10>;
> - clock-names = "fck", "sys_clk";
> +  <_clkctrl 
> DRA7_DSS_DSS_CORE_CLKCTRL 10>,
> +  <_clkctrl 
> DRA7_DSS_DSS_CORE_CLKCTRL 11>;
> + clock-names = "fck", "sys_clk", 
> "cec";
>   dmas = <_xbar 76>;
>   dma-names = "audio_tx";
>   };
> diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
> index 5f1a8bd13880..2bb1000aeae9 100644
> --- a/arch/arm/boot/dts/omap5.dtsi
> +++ b/arch/arm/boot/dts/omap5.dtsi
> @@ -580,8 +580,9 @@ hdmi: encoder@0 {
>   interrupts =  IRQ_TYPE_LEVEL_HIGH>;
>   status = "disabled";
>   clocks = <_clkctrl 
> OMAP5_DSS_CORE_CLKCTRL 9>,
> -  <_clkctrl 
> OMAP5_DSS_CORE_CLKCTRL 10>;
> - clock-names = "fck", "sys_clk";
> +  <_clkctrl 
> OMAP5_DSS_CORE_CLKCTRL 10>,
> +  <_clkctrl 
> OMAP5_DSS_CORE_CLKCTRL 11>;
> + clock-names = "fck", "sys_clk", 
> "cec";
>   dmas = < 76>;
>   dma-names = "audio_tx";
>   };
> 

If I read right, the cec clock is mandatory after adding the CEC support
in the previous patch. So please move this patch before the patch 4, and
also update the bindings in ti,omap5-dss.txt to list the cec clock.

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


Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core

2021-02-16 Thread Tomi Valkeinen
On 11/02/2021 19:35, Tony Lindgren wrote:
> * Tomi Valkeinen  [210211 07:35]:
>> On 08/02/2021 19:55, Tony Lindgren wrote:
>>> Hi,
>>>
>>> * Tomi Valkeinen  [201124 12:47]:
>>>> 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.
>>>
>>> Looks like this patch causes the following warnings:
>>>
>>> DSI: omapdss DSI error: Failed to receive BTA
>>> DSI: omapdss DSI error: bta sync failed
>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>> DSI: omapdss DSI error: Failed to receive BTA
>>> DSI: omapdss DSI error: bta sync failed
>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>> DSI: omapdss DSI error: Failed to receive BTA
>>> DSI: omapdss DSI error: bta sync failed
>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>> ...
>>>
>>> Any ideas? The display works for me despite the constant
>>> warnings.
>>
>> Which board is that? Do the errors start right from the boot, or only
>> after running something in userspace?
> 
> This is with droid4, that's about the only device I use with a display
> on regular basis. I'm pretty sure some earlier version of Sebastian's
> patches worked fine.

OMAP4 SDP doesn't produce these errors and the HW looks rather
identical. Although I noticed something odd there, running kmstest
--flip on the first display works fine, but running on the second
display gets a bit erratic fps. Which is a bit odd as everything should
be identical.

So these errors start from the boot? Or only when running something
specific?

Is there a bootloader that initializes the display?

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


Re: [RESEND PATCH] drm/tilcdc: fix raster control register setting

2021-02-16 Thread Tomi Valkeinen
On 16/02/2021 22:22, Dario Binacchi wrote:
> The fdd property of the tilcdc_panel_info structure must set the reqdly
> bit field  (bit 12 to 19) of the raster control register. The previous
> statement set the least significant bit instead.
> 
> Signed-off-by: Dario Binacchi 
> 
> ---
> 
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index 30213708fc99..238068e28729 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -393,7 +393,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
>   return;
>   }
>   }
> - reg |= info->fdd < 12;
> + reg |= info->fdd << 12;
>   tilcdc_write(dev, LCDC_RASTER_CTRL_REG, reg);
>  
>   if (info->invert_pxl_clk)
> 

This is interesting, looks like this has always been broken, and in many
cases sets bits 0, which is the enable bit. So we enable LCDC before
even setting the fb address. How does this not blow up LCDC totally?

The fix looks correct to me, but it will change the register value for
boards that have apparently been working for years.

Dario, did you test this on actual HW, or did you just spot the error?

Reviewed-by: Tomi Valkeinen 

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


Re: [PATCH] drm/tilcdc: fix raster control register setting

2021-02-15 Thread Tomi Valkeinen
Adding Jyri with the non-TI address.

 Tomi

On 14/02/2021 15:16, Dario Binacchi wrote:
> The fdd property of the tilcdc_panel_info structure must set the reqdly
> bit field  (bit 12 to 19) of the raster control register. The previous
> statement set the least significant bit instead.
> 
> Signed-off-by: Dario Binacchi 
> 
> ---
> 
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index 30213708fc99..238068e28729 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -393,7 +393,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
>   return;
>   }
>   }
> - reg |= info->fdd < 12;
> + reg |= info->fdd << 12;
>   tilcdc_write(dev, LCDC_RASTER_CTRL_REG, reg);
>  
>   if (info->invert_pxl_clk)
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core

2021-02-10 Thread Tomi Valkeinen
On 08/02/2021 19:55, Tony Lindgren wrote:
> Hi,
> 
> * Tomi Valkeinen  [201124 12:47]:
>> 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.
> 
> Looks like this patch causes the following warnings:
> 
> DSI: omapdss DSI error: Failed to receive BTA
> DSI: omapdss DSI error: bta sync failed
> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> DSI: omapdss DSI error: Failed to receive BTA
> DSI: omapdss DSI error: bta sync failed
> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> DSI: omapdss DSI error: Failed to receive BTA
> DSI: omapdss DSI error: bta sync failed
> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> ...
> 
> Any ideas? The display works for me despite the constant
> warnings.

Which board is that? Do the errors start right from the boot, or only
after running something in userspace?

 Tomi

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


Re: [PATCH] drm/tilcdc: send vblank event when disabling crtc

2021-01-28 Thread Tomi Valkeinen
Dropped the @ti.com addresses and added the new ones.

 Tomi

On 29/01/2021 07:58, quanyang.w...@windriver.com wrote:
> From: Quanyang Wang 
> 
> When run xrandr to change resolution on Beaglebone Black board, it will
> print the error information:
> 
> root@beaglebone:~# xrandr -display :0 --output HDMI-1 --mode 720x400
> [drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
> [drm:drm_atomic_helper_wait_for_dependencies] *ERROR* [CRTC:32:tilcdc crtc] 
> commit wait timed out
> [drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
> [drm:drm_atomic_helper_wait_for_dependencies] *ERROR* [CONNECTOR:34:HDMI-A-1] 
> commit wait timed out
> [drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
> [drm:drm_atomic_helper_wait_for_dependencies] *ERROR* [PLANE:31:plane-0] 
> commit wait timed out
> tilcdc 4830e000.lcdc: already pending page flip!
> 
> This is because there is operation sequence as below:
> 
> drm_atomic_connector_commit_dpms(mode is DRM_MODE_DPMS_OFF):
> ...
> drm_atomic_helper_setup_commit <- init_completion(commit_A->flip_done)
> drm_atomic_helper_commit_tail
> tilcdc_crtc_atomic_disable
> tilcdc_plane_atomic_update <- drm_crtc_send_vblank_event in 
> tilcdc_crtc_irq
>   is skipped since tilcdc_crtc->enabled 
> is 0
> tilcdc_crtc_atomic_flush   <- drm_crtc_send_vblank_event is skipped 
> since
>   crtc->state->event is set to be NULL in
>   tilcdc_plane_atomic_update
> drm_mode_setcrtc:
> ...
> drm_atomic_helper_setup_commit <- init_completion(commit_B->flip_done)
> drm_atomic_helper_wait_for_dependencies
> drm_crtc_commit_wait   <- wait for commit_A->flip_done completing
> 
> Just as shown above, the steps which could complete commit_A->flip_done
> are all skipped and commit_A->flip_done will never be completed. This will
> result a time-out ERROR when drm_crtc_commit_wait check the 
> commit_A->flip_done.
> So add drm_crtc_send_vblank_event in tilcdc_crtc_atomic_disable to
> complete commit_A->flip_done.
> 
> Fixes: cb345decb4d2 ("drm/tilcdc: Use standard drm_atomic_helper_commit")
> Signed-off-by: Quanyang Wang 
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index 30213708fc99..d99afd19ca08 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -515,6 +515,15 @@ static void tilcdc_crtc_off(struct drm_crtc *crtc, bool 
> shutdown)
>  
>   drm_crtc_vblank_off(crtc);
>  
> + spin_lock_irq(>dev->event_lock);
> +
> + if (crtc->state->event) {
> + drm_crtc_send_vblank_event(crtc, crtc->state->event);
> + crtc->state->event = NULL;
> + }
> +
> + spin_unlock_irq(>dev->event_lock);
> +
>   tilcdc_crtc_disable_irqs(dev);
>  
>   pm_runtime_put_sync(dev->dev);
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm/omap: dsi: fix unreachable code in dsi_vc_send_short()

2021-01-27 Thread Tomi Valkeinen
On 27/01/2021 03:51, menglong8.d...@gmail.com wrote:
> From: Menglong Dong 
> 
> The 'r' in dsi_vc_send_short() is of type 'unsigned int', so the
> 'r < 0' can't be true.
> 
> Fix this by introducing a 'err' of type 'int' insteaded.
> 
> Fixes: 1ed6253856cb ("drm/omap: dsi: switch dsi_vc_send_long/short to 
> mipi_dsi_msg")
> 
> Signed-off-by: Menglong Dong 
> Reviewed-by: Sebastian Reichel 
> ---
> v2:
> - remove word wrap in 'Fixes' tag
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
> b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 8e11612f5fe1..febcc87ddfe1 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -2149,11 +2149,12 @@ static int dsi_vc_send_short(struct dsi_data *dsi, 
> int vc,
>const struct mipi_dsi_msg *msg)
>  {
>   struct mipi_dsi_packet pkt;
> + int err;
>   u32 r;
>  
> - r = mipi_dsi_create_packet(, msg);
> - if (r < 0)
> - return r;
> + err = mipi_dsi_create_packet(, msg);
> + if (err)
> + return err;
>  
>   WARN_ON(!dsi_bus_is_locked(dsi));
>  

Thanks! I'll apply to drm-misc-next.

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


Re: [PATCHv1] video: omapfb2: Make standard and custom DSI command mode panel driver mutually exclusive

2021-01-12 Thread Tomi Valkeinen
Hi,

On 12/01/2021 14:02, Sebastian Reichel wrote:
> [replace Tomi's TI mail address with something working]
> 
> Hi,
> 
> On Fri, Jan 08, 2021 at 08:58:39PM +0100, Sam Ravnborg wrote:
>> Hi Sebastian,
>>
>> On Fri, Jan 08, 2021 at 12:24:41PM +0100, Sebastian Reichel wrote:
>>> Standard DRM panel driver for DSI command mode panel used by omapfb2 is also
>>> available now. Just like the other panels its module name clashes with the
>>> module from drivers/video/fbdev/omap2/omapfb/displays, part of the 
>>> deprecated
>>> omapfb2 fbdev driver. As omapfb2 can only be compiled when the omapdrm 
>>> driver
>>> is disabled, and the DRM panel drivers are useless in that case, make the
>>> omapfb2 panel depend on the standard DRM panels being disabled to fix
>>> the name clash.
>>>
>>> Fixes: cf64148abcfd ("drm/panel: Move OMAP's DSI command mode panel driver")
>>> Reported-by: Stephen Rothwell 
>>> Signed-off-by: Sebastian Reichel 
>>
>> For a backport this looks good:
>> Acked-by: Sam Ravnborg 
> 
> Thanks.

Thanks. I'll push to drm-misc-next, as that's where the commit that
breaks this is.

>> But why is it it we need omapfb at all when we have omapdrm?
> 
> I think there are two reasons omapfb has not been killed yet. One
> reason was missing support for manually updated DSI panels, which
> have been working since 1 or 2 kernel releases now. The other reason
> is some people using it in combination with an out-of-tree PowerVR
> kernel driver. There is currently work going on to use a more recent
> PowerVR driver based on omapdrm driven by Maemo Leste people.

omapfb also has a custom sysfw API, so applications that depend on it
would not work anymore. I don't know if there are such applications, though.

>> Can we sunset all or some parts of omap support in video/?
>> If not, what is missing to do so.
> 
> IDK the exact status of the PowerVR work and have not been using
> omapfb myself for years. I don't think there is a reason to rush
> this, so my suggestion is removing it in 3 steps giving people
> the chance to complain:
> 
> 1. Add 'depends on EXPERT' to 'FB_OMAP2' and add deprecation notice
>referencing omapdrm in help text in 5.12
> 2. Add 'depends on BROKEN' in 5.13
> 3. Drop drivers/video/fbdev/omap2 afterwards

I'd love to remove omapfb, but I also fear that there are still people
using it. We can try the above sequence, but it's probably better to go
slower, as people may not be using the latest kernels.

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


[PATCH] MAINTAINERS: Update addresses for TI display drivers

2020-12-16 Thread Tomi Valkeinen
Update the maintainer email addresses for TI display drivers.

Signed-off-by: Tomi Valkeinen 
---
 MAINTAINERS | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 281de213ef47..c21471497a18 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5932,8 +5932,8 @@ F:
Documentation/devicetree/bindings/display/st,stm32-ltdc.yaml
 F: drivers/gpu/drm/stm
 
 DRM DRIVERS FOR TI KEYSTONE
-M: Jyri Sarha 
-M: Tomi Valkeinen 
+M: Jyri Sarha 
+M: Tomi Valkeinen 
 L: dri-devel@lists.freedesktop.org
 S: Maintained
 T: git git://anongit.freedesktop.org/drm/drm-misc
@@ -5943,15 +5943,15 @@ F:  
Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml
 F: drivers/gpu/drm/tidss/
 
 DRM DRIVERS FOR TI LCDC
-M: Jyri Sarha 
-R: Tomi Valkeinen 
+M: Jyri Sarha 
+R: Tomi Valkeinen 
 L: dri-devel@lists.freedesktop.org
 S: Maintained
 F: Documentation/devicetree/bindings/display/tilcdc/
 F: drivers/gpu/drm/tilcdc/
 
 DRM DRIVERS FOR TI OMAP
-M: Tomi Valkeinen 
+M: Tomi Valkeinen 
 L: dri-devel@lists.freedesktop.org
 S: Maintained
 F: Documentation/devicetree/bindings/display/ti/
-- 
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: Delete useless kfree code

2020-12-15 Thread Tomi Valkeinen

On 14/12/2020 15:46, Zheng Yongjun wrote:

The parameter of kfree function is NULL, so kfree code is useless, delete it.

Signed-off-by: Zheng Yongjun 
---
  drivers/gpu/drm/omapdrm/tcm-sita.c | 1 -
  1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/tcm-sita.c 
b/drivers/gpu/drm/omapdrm/tcm-sita.c
index 817be3c41863..af59e9c03917 100644
--- a/drivers/gpu/drm/omapdrm/tcm-sita.c
+++ b/drivers/gpu/drm/omapdrm/tcm-sita.c
@@ -254,6 +254,5 @@ struct tcm *sita_init(u16 width, u16 height)
return tcm;
  
  error:

-   kfree(tcm);
return NULL;
  }


Thanks, I'll merge this.

 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 v4 1/2] drm: automatic legacy gamma support

2020-12-15 Thread Tomi Valkeinen

On 11/12/2020 13:42, Tomi Valkeinen wrote:


+/**
+ * drm_crtc_supports_legacy_gamma - does the crtc support legacy gamma 
correction table
+ * @crtc: CRTC object
+ *
+ * Returns true/false if the given crtc supports setting the legacy gamma
+ * correction table.
+ */
+static bool drm_crtc_supports_legacy_gamma(struct drm_crtc *crtc)
+{
+   uint32_t gamma_id = crtc->dev->mode_config.gamma_lut_property->base.id;


Userspace-mode strikes again... I'll change uint32_t's to u32 while applying. (But in my defense, 
there were uint32_t uses already in the code touched by these patches, and drm seems to have lots of 
uint32_t all around...)


 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 v6 71/84] drm/panel: panel-dsi-cm: remove extra 'if'

2020-12-15 Thread Tomi Valkeinen
We have a useless 'if' in the dsicm_bl_update_status(), a left over from
the conversion to DRM model. Drop the if.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c 
b/drivers/gpu/drm/panel/panel-dsi-cm.c
index 067745fb682f..f5240fd82459 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -202,11 +202,9 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
 
mutex_lock(>lock);
 
-   if (ddata->enabled) {
-   if (!r)
-   r = dsicm_dcs_write_1(
-   ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
-   }
+   if (ddata->enabled)
+   r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
+ level);
 
mutex_unlock(>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 v6 79/84] drm/omap: dsi: cleanup initial vc setup

2020-12-15 Thread Tomi Valkeinen
As we now have a fixed setup for VCs (VC0 for video stream, VC1 for
commands), we can simplify the VC setup.

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

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index d9075aec2a0b..40bfd92321c1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2019,40 +2019,6 @@ static void dsi_vc_initial_config(struct dsi_data *dsi, 
int vc)
dsi->vc[vc].source = DSI_VC_SOURCE_L4;
 }
 
-static int dsi_vc_config_source(struct dsi_data *dsi, int vc,
-   enum dsi_vc_source source)
-{
-   if (dsi->vc[vc].source == source)
-   return 0;
-
-   DSSDBG("Source config of VC %d", vc);
-
-   dsi_sync_vc(dsi, vc);
-
-   dsi_vc_enable(dsi, vc, 0);
-
-   /* VC_BUSY */
-   if (!wait_for_bit_change(dsi, DSI_VC_CTRL(vc), 15, 0)) {
-   DSSERR("vc(%d) busy when trying to config for VP\n", vc);
-   return -EIO;
-   }
-
-   /* SOURCE, 0 = L4, 1 = video port */
-   REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), source, 1, 1);
-
-   /* DCS_CMD_ENABLE */
-   if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) {
-   bool enable = source == DSI_VC_SOURCE_VP;
-   REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 30, 30);
-   }
-
-   dsi_vc_enable(dsi, vc, 1);
-
-   dsi->vc[vc].source = source;
-
-   return 0;
-}
-
 static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
bool enable)
 {
@@ -2074,10 +2040,6 @@ static void dsi_vc_enable_hs(struct omap_dss_device 
*dssdev, int vc,
dsi_if_enable(dsi, 1);
 
dsi_force_tx_stop_mode_io(dsi);
-
-   /* start the DDR clock by sending a NULL packet */
-   if (dsi->vm_timings.ddr_clk_always_on && enable)
-   dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
 }
 
 static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
@@ -2272,8 +2234,6 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
return -EINVAL;
}
 
-   dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
-
dsi_vc_write_long_header(dsi, vc, msg->channel, msg->type, msg->tx_len, 
0);
 
p = msg->tx_buf;
@@ -2333,8 +2293,6 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
DSSDBG("dsi_vc_send_short(vc%d, dt %#x, b1 %#x, b2 %#x)\n",
   vc, msg->type, pkt.header[1], pkt.header[2]);
 
-   dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
-
if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(vc)), 16, 16)) {
DSSERR("ERROR FIFO FULL, aborting transfer\n");
return -EINVAL;
@@ -3353,8 +3311,6 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
 
DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h);
 
-   dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_VP);
-
bytespp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) / 8;
bytespl = w * bytespp;
bytespf = bytespl * h;
@@ -3519,14 +3475,12 @@ static int dsi_update_channel(struct omap_dss_device 
*dssdev, int vc)
 
dsi_set_ulps_auto(dsi, false);
 
-   dsi_vc_enable_hs(dssdev, vc, true);
-
/*
 * Send NOP between the frames. If we don't send something here, the
 * updates stop working. This is probably related to DSI spec stating
 * that the DSI host should transition to LP at least once per frame.
 */
-   r = _dsi_send_nop(dsi, vc, dsi->dsidev->channel);
+   r = _dsi_send_nop(dsi, VC_CMD, dsi->dsidev->channel);
if (r < 0) {
DSSWARN("failed to send nop between frames: %d\n", r);
goto err;
@@ -3651,6 +3605,35 @@ static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
return 0;
 }
 
+static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
+{
+   /* Setup VC_CMD for LP and cpu transfers */
+   REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_CMD), 0, 9, 9); /* LP */
+
+   REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_CMD), 0, 1, 1); /* SOURCE_L4 */
+   dsi->vc[VC_CMD].source = DSI_VC_SOURCE_L4;
+
+   /* Setup VC_VIDEO for HS and dispc transfers */
+   REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 9, 9); /* HS */
+
+   REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 1, 1); /* SOURCE_VP */
+   dsi->vc[VC_VIDEO].source = DSI_VC_SOURCE_VP;
+
+   if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC)
+   REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 30, 30); /* 
DCS_CMD_ENABLE */
+
+   dsi_vc_enable(dsi, VC_CMD, 1);
+   dsi_vc_enable(dsi, VC_VIDEO, 1);
+
+   dsi_if_enable(dsi, 1);
+
+   dsi_force_tx_stop_mode_io(dsi);
+
+   /* start t

[PATCH v6 51/84] drm/omap: remove unused display.c

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

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 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", >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 c418bad28afe..48e4a1fc70b6 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 v6 83/84] drm/omap: dsi: fix DCS_CMD_ENABLE

2020-12-15 Thread Tomi Valkeinen
We only need to set VC_CTRL:DCS_CMD_ENABLE for command mode panels when
the HW has DSI_QUIRK_DCS_CMD_CONFIG_VC quirk. The old code did this
right by accident, but now we set DCS_CMD_ENABLE for video mode panels
too.

Fix this by skipping the set for video mode.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 400d88b02cae..0dd5c0381080 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3403,7 +3403,8 @@ static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 1, 1); /* SOURCE_VP */
dsi->vc[VC_VIDEO].source = DSI_VC_SOURCE_VP;
 
-   if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC)
+   if ((dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) &&
+   !(dsi->dsidev->mode_flags & MIPI_DSI_MODE_VIDEO))
REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 30, 30); /* 
DCS_CMD_ENABLE */
 
dsi_vc_enable(dsi, VC_CMD, 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 v6 58/84] drm/omap: pll: fix iteration loop check

2020-12-15 Thread Tomi Valkeinen
If the PLL calc function is given bad parameters, n_start/m_start may be
higher than n_stop/m_stop, which leads to the loops iterating through
the whole u32 number space.

Fix this by failing early on such cases.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/pll.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c 
b/drivers/gpu/drm/omapdrm/dss/pll.c
index 241a338ace29..4c8246a3ded9 100644
--- a/drivers/gpu/drm/omapdrm/dss/pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/pll.c
@@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned 
long clkin,
n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max);
n_inc = 1;
 
+   if (n_start > n_stop)
+   return false;
+
if (hw->errata_i886) {
swap(n_start, n_stop);
n_inc = -1;
@@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned 
long clkin,
hw->m_max);
m_inc = 1;
 
+   if (m_start > m_stop)
+   continue;
+
if (hw->errata_i886) {
swap(m_start, m_stop);
m_inc = -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 v6 47/84] drm/omap: simplify DSI manual update code

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 9eae61ddbda9..efa261e4a18a 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)
@@ -5446,7 +5444,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 = _ops;
+   out->dsi_ops = _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 cc4b7d2629bd..76586934df37 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 0d1543537b92..09a255c942c1 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(>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 v6 66/84] drm/omap: dsi: pass vc and channel to various functions

2020-12-15 Thread Tomi Valkeinen
To start fixing the issues related to channels and vcs described in the
previous commit, pass vc and/or channel to various functions which will
need it do properly handle different DSI channels and VCs.

No functional changes.

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

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 08dd76b4549a..7c8fe5da3099 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -214,9 +214,9 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool 
enable);
 static int dsi_display_init_dispc(struct dsi_data *dsi);
 static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
-static int dsi_vc_send_null(struct dsi_data *dsi, int vc);
+static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel);
 
-static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
+static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
   const struct mipi_dsi_msg *msg);
 
 static void dsi_display_disable(struct omap_dss_device *dssdev);
@@ -2457,7 +2457,7 @@ static void dsi_vc_enable_hs(struct omap_dss_device 
*dssdev, int vc,
 
/* start the DDR clock by sending a NULL packet */
if (dsi->vm_timings.ddr_clk_always_on && enable)
-   dsi_vc_send_null(dsi, vc);
+   dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
 
dsi->in_lp_mode = !enable;
 }
@@ -2607,7 +2607,8 @@ static int dsi_vc_send_bta_sync(struct omap_dss_device 
*dssdev, int vc)
 }
 
 static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int vc,
-   u8 data_type, u16 len, u8 ecc)
+   int channel, u8 data_type, u16 len,
+   u8 ecc)
 {
u32 val;
u8 data_id;
@@ -2635,7 +2636,7 @@ static inline void dsi_vc_write_long_payload(struct 
dsi_data *dsi, int vc,
dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(vc), val);
 }
 
-static int dsi_vc_send_long(struct dsi_data *dsi,
+static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
const struct mipi_dsi_msg *msg)
 {
/*u32 val; */
@@ -2655,7 +2656,7 @@ static int dsi_vc_send_long(struct dsi_data *dsi,
 
dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
 
-   dsi_vc_write_long_header(dsi, msg->channel, msg->type, msg->tx_len, 0);
+   dsi_vc_write_long_header(dsi, vc, msg->channel, msg->type, msg->tx_len, 
0);
 
p = msg->tx_buf;
for (i = 0; i < msg->tx_len >> 2; i++) {
@@ -2698,7 +2699,7 @@ static int dsi_vc_send_long(struct dsi_data *dsi,
return r;
 }
 
-static int dsi_vc_send_short(struct dsi_data *dsi,
+static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
 const struct mipi_dsi_msg *msg)
 {
struct mipi_dsi_packet pkt;
@@ -2729,26 +2730,26 @@ static int dsi_vc_send_short(struct dsi_data *dsi,
return 0;
 }
 
-static int dsi_vc_send_null(struct dsi_data *dsi, int vc)
+static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel)
 {
const struct mipi_dsi_msg msg = {
.channel = vc,
.type = MIPI_DSI_NULL_PACKET,
};
 
-   return dsi_vc_send_long(dsi, );
+   return dsi_vc_send_long(dsi, vc, );
 }
 
-static int dsi_vc_write_common(struct omap_dss_device *dssdev,
+static int dsi_vc_write_common(struct omap_dss_device *dssdev, int vc,
   const struct mipi_dsi_msg *msg)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
 
if (mipi_dsi_packet_format_is_short(msg->type))
-   r = dsi_vc_send_short(dsi, msg);
+   r = dsi_vc_send_short(dsi, vc, msg);
else
-   r = dsi_vc_send_long(dsi, msg);
+   r = dsi_vc_send_long(dsi, vc, msg);
 
if (r < 0)
return r;
@@ -2884,7 +2885,7 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int 
vc, u8 *buf,
return r;
 }
 
-static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
+static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int vc,
   const struct mipi_dsi_msg *msg)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
@@ -2895,7 +2896,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
if (dsi->debug_read)
DSSDBG("%s(ch %d, cmd %x)\n", __func__, channel, cmd);
 
-   r = dsi_vc_send_short(dsi, msg);
+   r = dsi_vc_send_short(dsi, vc, msg);
if (r)
goto err;
 
@@ -2919,13 +2920,13 @@ static int dsi_vc_dcs_read(struct omap_dss_device 
*dssdev,
return r;
 }
 

[PATCH v6 82/84] drm/omap: dsi: remove ulps support

2020-12-15 Thread Tomi Valkeinen
ULPS is a niche power-saving feature which only really affects command
mode panels showing a static picture. I know the ULPS code used to work
very long time ago, but I could not get it working with the current
driver. As the ULPS code is not trivial and includes delayed work (so
lots of chances for race issues), and just keeping DSI video and command
mode panels working has been challenging enough even without ULPS, lets
remove ULPS support.

When the DSI driver works reliably for command and video mode displays,
someone interested can work on ULPS and add it back if the power saving
is substantial enough.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 297 +-
 drivers/gpu/drm/omapdrm/dss/dsi.h |   4 -
 2 files changed, 8 insertions(+), 293 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 749f591a3d5e..400d88b02cae 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -53,8 +53,6 @@
 #define REG_FLD_MOD(dsi, idx, val, start, end) \
dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, 
end))
 
-static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
-
 static int dsi_init_dispc(struct dsi_data *dsi);
 static void dsi_uninit_dispc(struct dsi_data *dsi);
 
@@ -688,44 +686,6 @@ static int dsi_unregister_isr_vc(struct dsi_data *dsi, int 
vc,
return r;
 }
 
-static int dsi_register_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
-   void *arg, u32 mask)
-{
-   unsigned long flags;
-   int r;
-
-   spin_lock_irqsave(>irq_lock, flags);
-
-   r = _dsi_register_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio,
-   ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
-
-   if (r == 0)
-   _omap_dsi_set_irqs_cio(dsi);
-
-   spin_unlock_irqrestore(>irq_lock, flags);
-
-   return r;
-}
-
-static int dsi_unregister_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
- void *arg, u32 mask)
-{
-   unsigned long flags;
-   int r;
-
-   spin_lock_irqsave(>irq_lock, flags);
-
-   r = _dsi_unregister_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio,
-   ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
-
-   if (r == 0)
-   _omap_dsi_set_irqs_cio(dsi);
-
-   spin_unlock_irqrestore(>irq_lock, flags);
-
-   return r;
-}
-
 static u32 dsi_get_errors(struct dsi_data *dsi)
 {
unsigned long flags;
@@ -1452,56 +1412,6 @@ static void dsi_cio_timings(struct dsi_data *dsi)
dsi_write_reg(dsi, DSI_DSIPHY_CFG2, r);
 }
 
-/* lane masks have lane 0 at lsb. mask_p for positive lines, n for negative */
-static void dsi_cio_enable_lane_override(struct dsi_data *dsi,
-unsigned int mask_p,
-unsigned int mask_n)
-{
-   int i;
-   u32 l;
-   u8 lptxscp_start = dsi->num_lanes_supported == 3 ? 22 : 26;
-
-   l = 0;
-
-   for (i = 0; i < dsi->num_lanes_supported; ++i) {
-   unsigned int p = dsi->lanes[i].polarity;
-
-   if (mask_p & (1 << i))
-   l |= 1 << (i * 2 + (p ? 0 : 1));
-
-   if (mask_n & (1 << i))
-   l |= 1 << (i * 2 + (p ? 1 : 0));
-   }
-
-   /*
-* Bits in REGLPTXSCPDAT4TO0DXDY:
-* 17: DY0 18: DX0
-* 19: DY1 20: DX1
-* 21: DY2 22: DX2
-* 23: DY3 24: DX3
-* 25: DY4 26: DX4
-*/
-
-   /* Set the lane override configuration */
-
-   /* REGLPTXSCPDAT4TO0DXDY */
-   REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, l, lptxscp_start, 17);
-
-   /* Enable lane override */
-
-   /* ENLPTXSCPDAT */
-   REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 1, 27, 27);
-}
-
-static void dsi_cio_disable_lane_override(struct dsi_data *dsi)
-{
-   /* Disable lane override */
-   REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */
-   /* Reset the lane override configuration */
-   /* REGLPTXSCPDAT4TO0DXDY */
-   REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 22, 17);
-}
-
 static int dsi_cio_wait_tx_clk_esc_reset(struct dsi_data *dsi)
 {
int t, i;
@@ -1676,32 +1586,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
l = FLD_MOD(l, 0x1fff, 12, 0);  /* STOP_STATE_COUNTER_IO */
dsi_write_reg(dsi, DSI_TIMING1, l);
 
-   if (dsi->ulps_enabled) {
-   unsigned int mask_p;
-   int i;
-
-   DSSDBG("manual ulps exit\n");
-
-   /* ULPS is exited by Mark-1 state for 1ms, followed by
-* stop state. DSS HW cannot do this via the normal
-* ULPS exit sequence, as after reset the D

[PATCH v6 49/84] ARM: omap2plus_defconfig: Update for moved DSI command mode panel

2020-12-15 Thread Tomi Valkeinen
From: Sebastian Reichel 

The DSI command mode panel is no longer specific
to OMAP and thus the config option has been renamed
slightly.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
Cc: Tony Lindgren 
Reviewed-by: Laurent Pinchart 
Acked-by: Tony Lindgren 
---
 arch/arm/configs/omap2plus_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/configs/omap2plus_defconfig 
b/arch/arm/configs/omap2plus_defconfig
index 34793aabdb65..1857717a49bf 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -369,8 +369,8 @@ CONFIG_DRM_OMAP=m
 CONFIG_OMAP5_DSS_HDMI=y
 CONFIG_OMAP2_DSS_SDI=y
 CONFIG_OMAP2_DSS_DSI=y
-CONFIG_DRM_OMAP_PANEL_DSI_CM=m
 CONFIG_DRM_TILCDC=m
+CONFIG_DRM_PANEL_DSI_CM=m
 CONFIG_DRM_PANEL_SIMPLE=m
 CONFIG_DRM_PANEL_LG_LB035Q02=m
 CONFIG_DRM_PANEL_NEC_NL8048HL11=m
-- 
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 v6 40/84] drm/omap: dsi: Register a drm_bridge

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 6f66ef0be166..9eae61ddbda9 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 
@@ -438,6 +439,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 {
@@ -450,6 +452,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(>lock);
-   r = __dsi_calc_config(dsi, mode, );
-   mutex_unlock(>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,
@@ -5389,6 +5351,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(>lock);
+   r = __dsi_calc_config(dsi, mode, );
+   mutex_unlock(>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(>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(>output);
+}
+
+static void dsi_bridge_disable(struct drm_bridge *bridge)
+{
+   struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+   dsi_disable_video_outputs(>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.funcs = _bridge_funcs;
+   dsi->bridge.of_node = dsi-

[PATCH v6 65/84] drm/omap: dsi: rename 'channel' to 'vc'

2020-12-15 Thread Tomi Valkeinen
The "channel" usage in omap dsi driver is confusing. We have three
different "channels":

1) DSI virtual channel ID. This is a number from 0 to 3, included in the
packet payload.

2) VC. This is a register block in the DSI IP. There are four of those
blocks. A VC is a DSI "pipeline", with defined fifo settings, data
source (cpu or dispc), and some other settings. It has no relation to
the 1).

3) dispc channel. It's the "pipeline" number dispc uses to send pixel
data.

The previous patch handled the third case.

 To start fixing 1) and 2), we first rename all uses of 'channel' to
'vc', as in most of the cases that is the correct thing to use.

However, in some places 1) and 2) have gotten mixed up (i.e. the code
uses msg->channel when it should use vc), which will be fixed in the
following patch.

Note that mixing 1) and 2) currently is "fine", as at the moment we only
support DSI peripherals with DSI virtual channel 0, and we always use
VC0 to send data. So both 1) and 2) are always 0.

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

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 789c26baad86..08dd76b4549a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -214,7 +214,7 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool 
enable);
 static int dsi_display_init_dispc(struct dsi_data *dsi);
 static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
-static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
+static int dsi_vc_send_null(struct dsi_data *dsi, int vc);
 
 static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
   const struct mipi_dsi_msg *msg);
@@ -376,7 +376,7 @@ struct dsi_data {
/* space for a copy used by the interrupt handler */
struct dsi_isr_tables isr_tables_copy;
 
-   int update_channel;
+   int update_vc;
 #ifdef DSI_PERF_MEASURE
unsigned int update_bytes;
 #endif
@@ -639,7 +639,7 @@ static void print_irq_status(u32 status)
 #undef PIS
 }
 
-static void print_irq_status_vc(int channel, u32 status)
+static void print_irq_status_vc(int vc, u32 status)
 {
if (status == 0)
return;
@@ -650,7 +650,7 @@ static void print_irq_status_vc(int channel, u32 status)
 #define PIS(x) (status & DSI_VC_IRQ_##x) ? (#x " ") : ""
 
pr_debug("DSI VC(%d) IRQ 0x%x: %s%s%s%s%s%s%s%s%s\n",
-   channel,
+   vc,
status,
PIS(CS),
PIS(ECC_CORR),
@@ -1031,7 +1031,7 @@ static int dsi_unregister_isr(struct dsi_data *dsi, 
omap_dsi_isr_t isr,
return r;
 }
 
-static int dsi_register_isr_vc(struct dsi_data *dsi, int channel,
+static int dsi_register_isr_vc(struct dsi_data *dsi, int vc,
   omap_dsi_isr_t isr, void *arg, u32 mask)
 {
unsigned long flags;
@@ -1040,18 +1040,18 @@ static int dsi_register_isr_vc(struct dsi_data *dsi, 
int channel,
spin_lock_irqsave(>irq_lock, flags);
 
r = _dsi_register_isr(isr, arg, mask,
-   dsi->isr_tables.isr_table_vc[channel],
-   ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
+   dsi->isr_tables.isr_table_vc[vc],
+   ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]));
 
if (r == 0)
-   _omap_dsi_set_irqs_vc(dsi, channel);
+   _omap_dsi_set_irqs_vc(dsi, vc);
 
spin_unlock_irqrestore(>irq_lock, flags);
 
return r;
 }
 
-static int dsi_unregister_isr_vc(struct dsi_data *dsi, int channel,
+static int dsi_unregister_isr_vc(struct dsi_data *dsi, int vc,
 omap_dsi_isr_t isr, void *arg, u32 mask)
 {
unsigned long flags;
@@ -1060,11 +1060,11 @@ static int dsi_unregister_isr_vc(struct dsi_data *dsi, 
int channel,
spin_lock_irqsave(>irq_lock, flags);
 
r = _dsi_unregister_isr(isr, arg, mask,
-   dsi->isr_tables.isr_table_vc[channel],
-   ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
+   dsi->isr_tables.isr_table_vc[vc],
+   ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]));
 
if (r == 0)
-   _omap_dsi_set_irqs_vc(dsi, channel);
+   _omap_dsi_set_irqs_vc(dsi, vc);
 
spin_unlock_irqrestore(>irq_lock, flags);
 
@@ -2234,9 +2234,9 @@ static int dsi_force_tx_stop_mode_io(struct dsi_data *dsi)
return 0;
 }
 
-static bool dsi_vc_is_enabled(struct dsi_data *dsi, int channel)
+static bool dsi_vc_is_enabled(struct dsi_data *dsi, int vc)
 {
-   return REG_GET(dsi, DS

[PATCH v6 45/84] drm/omap: drop DSS ops_flags

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 0547c69a2c1b..c073efaed1b4 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 94cf50d837b0..d92df480180e 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -735,7 +735,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, >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 v6 61/84] drm/omap: dsi: send nop instead of page & column

2020-12-15 Thread Tomi Valkeinen
The OMAP DSI command mode panel driver used to send page & column
address before each frame update, and this code was moved into the DSI
host driver when converting it to the DRM bridge model.

However, it's not really required to send the page & column address
before each frame. It's also something that doesn't really belong to the
DSI host driver, so we should drop the code.

That said, frame updates break if we don't send _something_ between the
frames. A NOP command does the trick.

It is not clear if this behavior is as expected from a DSI command mode
frame transfer, or is it a feature/issue with OMAP DSI driver, or a
feature/issue in the command mode panel used.

Most likely this is related to the following from the DSI spec:

"To enable PHY synchronization the host processor should periodically
end HS transmission and drive the Data Lanes to the LP state. This
transition should take place at least once per frame."

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 46 ---
 1 file changed, 17 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c5682b2e26eb..e24db2431fb8 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3881,35 +3881,19 @@ static int _dsi_update(struct dsi_data *dsi)
return 0;
 }
 
-static int _dsi_update_window(struct dsi_data *dsi, int channel,
- int x, int y, int w, int h)
-{
-   int x1 = x, x2 = (x + w - 1);
-   int y1 = y, y2 = (y + h - 1);
-   u8 payloadX[5] = { MIPI_DCS_SET_COLUMN_ADDRESS,
-  x1 >> 8, x1 & 0xff, x2 >> 8, x2 & 0xff };
-   u8 payloadY[5] = { MIPI_DCS_SET_PAGE_ADDRESS,
-  y1 >> 8, y1 & 0xff, y2 >> 8, y2 & 0xff };
-   struct mipi_dsi_msg msgX = { 0 }, msgY = { 0 };
-   int ret;
+static int _dsi_send_nop(struct dsi_data *dsi, int channel)
+{
+   const u8 payload[] = { MIPI_DCS_NOP };
+   const struct mipi_dsi_msg msg = {
+   .channel = channel,
+   .type = MIPI_DSI_DCS_SHORT_WRITE,
+   .tx_len = 1,
+   .tx_buf = payload,
+   };
 
WARN_ON(!dsi_bus_is_locked(dsi));
 
-   msgX.type = MIPI_DSI_DCS_LONG_WRITE;
-   msgX.channel = channel;
-   msgX.tx_buf = payloadX;
-   msgX.tx_len = sizeof(payloadX);
-
-   msgY.type = MIPI_DSI_DCS_LONG_WRITE;
-   msgY.channel = channel;
-   msgY.tx_buf = payloadY;
-   msgY.tx_len = sizeof(payloadY);
-
-   ret = _omap_dsi_host_transfer(dsi, );
-   if (ret != 0)
-   return ret;
-
-   return _omap_dsi_host_transfer(dsi, );
+   return _omap_dsi_host_transfer(dsi, );
 }
 
 static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
@@ -3941,10 +3925,14 @@ static int dsi_update_channel(struct omap_dss_device 
*dssdev, int channel)
 
dsi_set_ulps_auto(dsi, false);
 
-   r = _dsi_update_window(dsi, channel, 0, 0, dsi->vm.hactive,
-  dsi->vm.vactive);
+   /*
+* Send NOP between the frames. If we don't send something here, the
+* updates stop working. This is probably related to DSI spec stating
+* that the DSI host should transition to LP at least once per frame.
+*/
+   r = _dsi_send_nop(dsi, channel);
if (r < 0) {
-   DSSWARN("window update error: %d\n", r);
+   DSSWARN("failed to send nop between frames: %d\n", 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 v6 73/84] drm/panel: panel-dsi-cm: drop unneeded includes

2020-12-15 Thread Tomi Valkeinen
Drop unneeded includes.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c 
b/drivers/gpu/drm/panel/panel-dsi-cm.c
index c549329dc4b9..af381d756ac1 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -11,8 +11,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 
-- 
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 v6 72/84] drm/panel: panel-dsi-cm: add panel database to driver

2020-12-15 Thread Tomi Valkeinen
Add a panel database to the driver instead of reading propertes from DT
data. This is similar to panel-simple, and I believe it's more future
safe way to handle the panels.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Sam Ravnborg 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 104 +--
 1 file changed, 66 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c 
b/drivers/gpu/drm/panel/panel-dsi-cm.c
index f5240fd82459..c549329dc4b9 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -21,10 +21,7 @@
 #include 
 #include 
 
-#include 
 #include 
-#include 
-#include 
 
 #define DCS_GET_ID10xda
 #define DCS_GET_ID20xdb
@@ -32,6 +29,18 @@
 
 #define DCS_REGULATOR_SUPPLY_NUM 2
 
+static const struct of_device_id dsicm_of_match[];
+
+struct dsic_panel_data {
+   u32 xres;
+   u32 yres;
+   u32 refresh;
+   u32 width_mm;
+   u32 height_mm;
+   u32 max_hs_rate;
+   u32 max_lp_rate;
+};
+
 struct panel_drv_data {
struct mipi_dsi_device *dsi;
struct drm_panel panel;
@@ -47,16 +56,14 @@ struct panel_drv_data {
 */
unsigned long   hw_guard_wait;  /* max guard time in jiffies */
 
-   /* panel HW configuration from DT or platform data */
+   const struct dsic_panel_data *panel_data;
+
struct gpio_desc *reset_gpio;
 
struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
 
bool use_dsi_backlight;
 
-   int width_mm;
-   int height_mm;
-
/* runtime variables */
bool enabled;
 
@@ -450,11 +457,8 @@ static int dsicm_get_modes(struct drm_panel *panel,
return -ENOMEM;
}
 
-   drm_mode_set_name(mode);
-   mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
-
-   connector->display_info.width_mm = ddata->width_mm;
-   connector->display_info.height_mm = ddata->height_mm;
+   connector->display_info.width_mm = ddata->panel_data->width_mm;
+   connector->display_info.height_mm = ddata->panel_data->height_mm;
 
drm_mode_probed_add(connector, mode);
 
@@ -471,15 +475,10 @@ static const struct drm_panel_funcs dsicm_panel_funcs = {
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 {
-   struct device_node *node = dsi->dev.of_node;
struct backlight_device *backlight;
struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
-   struct display_timing timing;
-   struct videomode vm = {
-   .hactive = 864,
-   .vactive = 480,
-   };
int err;
+   struct drm_display_mode *mode = >mode;
 
ddata->reset_gpio = devm_gpiod_get(>dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(ddata->reset_gpio)) {
@@ -488,23 +487,16 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
return err;
}
 
-   err = of_get_display_timing(node, "panel-timing", );
-   if (!err) {
-   videomode_from_timing(, );
-   } else {
-   dev_warn(>dev,
-"failed to get video timing, using defaults\n");
-   }
-
-   if (!vm.pixelclock)
-   vm.pixelclock = vm.hactive * vm.vactive * 60;
-   drm_display_mode_from_videomode(, >mode);
-
-   ddata->width_mm = 0;
-   of_property_read_u32(node, "width-mm", >width_mm);
-
-   ddata->height_mm = 0;
-   of_property_read_u32(node, "height-mm", >height_mm);
+   mode->hdisplay = mode->hsync_start = mode->hsync_end = mode->htotal =
+   ddata->panel_data->xres;
+   mode->vdisplay = mode->vsync_start = mode->vsync_end = mode->vtotal =
+   ddata->panel_data->yres;
+   mode->clock = ddata->panel_data->xres * ddata->panel_data->yres *
+   ddata->panel_data->refresh / 1000;
+   mode->width_mm = ddata->panel_data->width_mm;
+   mode->height_mm = ddata->panel_data->height_mm;
+   mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+   drm_mode_set_name(mode);
 
ddata->supplies[0].supply = "vpnl";
ddata->supplies[1].supply = "vddi";
@@ -542,6 +534,10 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
mipi_dsi_set_drvdata(dsi, ddata);
ddata->dsi = dsi;
 
+   ddata->panel_data = of_device_get_match_data(dev);
+   if (!ddata->panel_data)
+   return -ENODEV;
+
r = dsicm_probe_of(dsi);
if (r)
return r;
@@ -578,8 +574,8 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
dsi->format = MIPI_DSI_FMT_RGB888;
dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |

[PATCH v6 84/84] drm/omap: dsi: allow DSI commands to be sent early

2020-12-15 Thread Tomi Valkeinen
Panel drivers can send DSI commands in panel's prepare(), which happens
before the bridge's enable() is called. The OMAP DSI driver currently
only sets up the DSI interface at bridge's enable(), so prepare() cannot
be used to send DSI commands.

This patch fixes the issue by making it possible to enable the DSI
interface any time a command is about to be sent. Disabling the
interface is be done via delayed work.

Clarifications for the delayed disable work and the panel doing DSI
transactions:

bridge_enable: If the disable callback is called just before
bridge_enable takes the dsi_bus_lock, no problem, bridge_enable just
enables the interface again. If the callback is ran just after
bridge_enable's dsi_bus_unlock, no problem, dsi->video_enabled == true
so the callback does nothing.

bridge_disable: similar to bridge-enable, the callback won't do anything
if video_enabled == true, and after bridge-disable has turned the video
and the interface off, there's nothing to do for the callback.

omap_dsi_host_detach: this is called when the panel does
mipi_dsi_detach(), and we expect the panel to _not_ do any DSI
transactions after (or during) mipi_dsi_detatch(), so there are no
race conditions.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 50 +++
 drivers/gpu/drm/omapdrm/dss/dsi.h |  3 ++
 2 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 0dd5c0381080..8e11612f5fe1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3500,6 +3500,9 @@ static void dsi_enable(struct dsi_data *dsi)
 
WARN_ON(!dsi_bus_is_locked(dsi));
 
+   if (WARN_ON(dsi->iface_enabled))
+   return;
+
mutex_lock(>lock);
 
r = dsi_runtime_get(dsi);
@@ -3512,6 +3515,8 @@ static void dsi_enable(struct dsi_data *dsi)
if (r)
goto err_init_dsi;
 
+   dsi->iface_enabled = true;
+
mutex_unlock(>lock);
 
return;
@@ -3527,6 +3532,9 @@ static void dsi_disable(struct dsi_data *dsi)
 {
WARN_ON(!dsi_bus_is_locked(dsi));
 
+   if (WARN_ON(!dsi->iface_enabled))
+   return;
+
mutex_lock(>lock);
 
dsi_sync_vc(dsi, 0);
@@ -3538,6 +3546,8 @@ static void dsi_disable(struct dsi_data *dsi)
 
dsi_runtime_put(dsi);
 
+   dsi->iface_enabled = false;
+
mutex_unlock(>lock);
 }
 
@@ -4226,10 +4236,12 @@ static ssize_t omap_dsi_host_transfer(struct 
mipi_dsi_host *host,
 
dsi_bus_lock(dsi);
 
-   if (dsi->video_enabled)
-   r = _omap_dsi_host_transfer(dsi, vc, msg);
-   else
-   r = -EIO;
+   if (!dsi->iface_enabled) {
+   dsi_enable(dsi);
+   schedule_delayed_work(>dsi_disable_work, 
msecs_to_jiffies(2000));
+   }
+
+   r = _omap_dsi_host_transfer(dsi, vc, msg);
 
dsi_bus_unlock(dsi);
 
@@ -4394,6 +4406,15 @@ static int omap_dsi_host_detach(struct mipi_dsi_host 
*host,
if (WARN_ON(dsi->dsidev != client))
return -EINVAL;
 
+   cancel_delayed_work_sync(>dsi_disable_work);
+
+   dsi_bus_lock(dsi);
+
+   if (dsi->iface_enabled)
+   dsi_disable(dsi);
+
+   dsi_bus_unlock(dsi);
+
omap_dsi_unregister_te_irq(dsi);
dsi->dsidev = NULL;
return 0;
@@ -4629,9 +4650,12 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
struct omap_dss_device *dssdev = >output;
 
+   cancel_delayed_work_sync(>dsi_disable_work);
+
dsi_bus_lock(dsi);
 
-   dsi_enable(dsi);
+   if (!dsi->iface_enabled)
+   dsi_enable(dsi);
 
dsi_enable_video_output(dssdev, VC_VIDEO);
 
@@ -4645,6 +4669,8 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
struct omap_dss_device *dssdev = >output;
 
+   cancel_delayed_work_sync(>dsi_disable_work);
+
dsi_bus_lock(dsi);
 
dsi->video_enabled = false;
@@ -4837,6 +4863,18 @@ static const struct soc_device_attribute 
dsi_soc_devices[] = {
{ /* sentinel */ }
 };
 
+static void omap_dsi_disable_work_callback(struct work_struct *work)
+{
+   struct dsi_data *dsi = container_of(work, struct dsi_data, 
dsi_disable_work.work);
+
+   dsi_bus_lock(dsi);
+
+   if (dsi->iface_enabled && !dsi->video_enabled)
+   dsi_disable(dsi);
+
+   dsi_bus_unlock(dsi);
+}
+
 static int dsi_probe(struct platform_device *pdev)
 {
const struct soc_device_attribute *soc;
@@ -4870,6 +4908,8 @@ static int dsi_probe(struct platform_device *pdev)
INIT_DEFERRABLE_WORK(>framedone_timeout_work,
 dsi_framedone_timeout_work_callback)

[PATCH v6 55/84] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI

2020-12-15 Thread Tomi Valkeinen
Use the common MIPI_DCS_GET_ERROR_COUNT_ON_DSI define instead of
driver's own.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c 
b/drivers/gpu/drm/panel/panel-dsi-cm.c
index 21df1997e7d1..5c28f08b2288 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 
-#define DCS_READ_NUM_ERRORS0x05
 #define DCS_GET_ID10xda
 #define DCS_GET_ID20xdb
 #define DCS_GET_ID30xdc
@@ -224,7 +223,7 @@ static ssize_t num_dsi_errors_show(struct device *dev,
mutex_lock(>lock);
 
if (ddata->enabled)
-   r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, );
+   r = dsicm_dcs_read_1(ddata, MIPI_DCS_GET_ERROR_COUNT_ON_DSI, 
);
 
mutex_unlock(>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 v6 78/84] drm/omap: dsi: rename dsi_display_* functions

2020-12-15 Thread Tomi Valkeinen
The function names have evolved to be very confusing, and bunch of them
have "display" in them even if the function doesn't deal with display as
such (e.g. dsi_display_enable which just enables the DSI interface).
Rename them by dropping the "display".

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 36 +++
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index dd4132a594a3..d9075aec2a0b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -55,8 +55,8 @@
 
 static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
 
-static int dsi_display_init_dispc(struct dsi_data *dsi);
-static void dsi_display_uninit_dispc(struct dsi_data *dsi);
+static int dsi_init_dispc(struct dsi_data *dsi);
+static void dsi_uninit_dispc(struct dsi_data *dsi);
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel);
 
@@ -3259,7 +3259,7 @@ static void dsi_enable_video_output(struct 
omap_dss_device *dssdev, int vc)
u16 word_count;
int r;
 
-   r = dsi_display_init_dispc(dsi);
+   r = dsi_init_dispc(dsi);
if (r) {
dev_err(dsi->dev, "failed to init dispc!\n");
return;
@@ -3311,7 +3311,7 @@ static void dsi_enable_video_output(struct 
omap_dss_device *dssdev, int vc)
dsi_vc_enable(dsi, vc, false);
}
 err_pix_fmt:
-   dsi_display_uninit_dispc(dsi);
+   dsi_uninit_dispc(dsi);
dev_err(dsi->dev, "failed to enable DSI encoder!\n");
return;
 }
@@ -,7 +,7 @@ static void dsi_disable_video_output(struct 
omap_dss_device *dssdev, int vc)
 
dss_mgr_disable(>output);
 
-   dsi_display_uninit_dispc(dsi);
+   dsi_uninit_dispc(dsi);
 }
 
 static void dsi_update_screen_dispc(struct dsi_data *dsi)
@@ -3579,7 +3579,7 @@ static int dsi_configure_dispc_clocks(struct dsi_data 
*dsi)
return 0;
 }
 
-static int dsi_display_init_dispc(struct dsi_data *dsi)
+static int dsi_init_dispc(struct dsi_data *dsi)
 {
enum omap_channel dispc_channel = dsi->output.dispc_channel;
int r;
@@ -3624,7 +3624,7 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
return r;
 }
 
-static void dsi_display_uninit_dispc(struct dsi_data *dsi)
+static void dsi_uninit_dispc(struct dsi_data *dsi)
 {
enum omap_channel dispc_channel = dsi->output.dispc_channel;
 
@@ -3651,7 +3651,7 @@ static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
return 0;
 }
 
-static int dsi_display_init_dsi(struct dsi_data *dsi)
+static int dsi_init_dsi(struct dsi_data *dsi)
 {
int r;
 
@@ -3715,7 +3715,7 @@ static int dsi_display_init_dsi(struct dsi_data *dsi)
return r;
 }
 
-static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
+static void dsi_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
   bool enter_ulps)
 {
if (enter_ulps && !dsi->ulps_enabled)
@@ -3738,7 +3738,7 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, 
bool disconnect_lanes,
}
 }
 
-static void dsi_display_enable(struct dsi_data *dsi)
+static void dsi_enable(struct dsi_data *dsi)
 {
int r;
 
@@ -3752,7 +3752,7 @@ static void dsi_display_enable(struct dsi_data *dsi)
 
_dsi_initialize_irq(dsi);
 
-   r = dsi_display_init_dsi(dsi);
+   r = dsi_init_dsi(dsi);
if (r)
goto err_init_dsi;
 
@@ -3764,10 +3764,10 @@ static void dsi_display_enable(struct dsi_data *dsi)
dsi_runtime_put(dsi);
 err_get_dsi:
mutex_unlock(>lock);
-   DSSDBG("dsi_display_ulps_enable FAILED\n");
+   DSSDBG("dsi_enable FAILED\n");
 }
 
-static void dsi_display_disable(struct dsi_data *dsi,
+static void dsi_disable(struct dsi_data *dsi,
bool disconnect_lanes, bool enter_ulps)
 {
WARN_ON(!dsi_bus_is_locked(dsi));
@@ -3779,7 +3779,7 @@ static void dsi_display_disable(struct dsi_data *dsi,
dsi_sync_vc(dsi, 2);
dsi_sync_vc(dsi, 3);
 
-   dsi_display_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
+   dsi_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
 
dsi_runtime_put(dsi);
 
@@ -3809,7 +3809,7 @@ static void omap_dsi_ulps_work_callback(struct 
work_struct *work)
 
dsi_enable_te(dsi, false);
 
-   dsi_display_disable(dsi, false, true);
+   dsi_disable(dsi, false, true);
 
dsi_bus_unlock(dsi);
 }
@@ -3830,7 +3830,7 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool 
enable)
return;
 
dsi_bus_lock(dsi);
-   dsi_display_enable(dsi);
+   dsi_enable(dsi);
dsi_enable_te(dsi, true);
dsi_bus_unl

[PATCH v6 80/84] drm/omap: dsi: split video mode enable/disable into separate func

2020-12-15 Thread Tomi Valkeinen
Clean up the code by separating video-mode enable/disable code into
functions of their own.

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

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 40bfd92321c1..a17d7345fc9a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3209,12 +3209,61 @@ static int dsi_configure_pins(struct dsi_data *dsi,
return 0;
 }
 
-static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
+static int dsi_enable_video_mode(struct dsi_data *dsi, int vc)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
u8 data_type;
u16 word_count;
+
+   switch (dsi->pix_fmt) {
+   case MIPI_DSI_FMT_RGB888:
+   data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
+   break;
+   case MIPI_DSI_FMT_RGB666:
+   data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
+   break;
+   case MIPI_DSI_FMT_RGB666_PACKED:
+   data_type = MIPI_DSI_PACKED_PIXEL_STREAM_18;
+   break;
+   case MIPI_DSI_FMT_RGB565:
+   data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   dsi_if_enable(dsi, false);
+   dsi_vc_enable(dsi, vc, false);
+
+   /* MODE, 1 = video mode */
+   REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 4, 4);
+
+   word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
+
+   dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, data_type,
+   word_count, 0);
+
+   dsi_vc_enable(dsi, vc, true);
+   dsi_if_enable(dsi, true);
+
+   return 0;
+}
+
+static void dsi_disable_video_mode(struct dsi_data *dsi, int vc)
+{
+   dsi_if_enable(dsi, false);
+   dsi_vc_enable(dsi, vc, false);
+
+   /* MODE, 0 = command mode */
+   REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);
+
+   dsi_vc_enable(dsi, vc, true);
+   dsi_if_enable(dsi, true);
+}
+
+static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
 
r = dsi_init_dispc(dsi);
@@ -3224,37 +3273,9 @@ static void dsi_enable_video_output(struct 
omap_dss_device *dssdev, int vc)
}
 
if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-   switch (dsi->pix_fmt) {
-   case MIPI_DSI_FMT_RGB888:
-   data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
-   break;
-   case MIPI_DSI_FMT_RGB666:
-   data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
-   break;
-   case MIPI_DSI_FMT_RGB666_PACKED:
-   data_type = MIPI_DSI_PACKED_PIXEL_STREAM_18;
-   break;
-   case MIPI_DSI_FMT_RGB565:
-   data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16;
-   break;
-   default:
-   r = -EINVAL;
-   goto err_pix_fmt;
-   }
-
-   dsi_if_enable(dsi, false);
-   dsi_vc_enable(dsi, vc, false);
-
-   /* MODE, 1 = video mode */
-   REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 4, 4);
-
-   word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
-
-   dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, 
data_type,
-   word_count, 0);
-
-   dsi_vc_enable(dsi, vc, true);
-   dsi_if_enable(dsi, true);
+   r = dsi_enable_video_mode(dsi, vc);
+   if (r)
+   goto err_video_mode;
}
 
r = dss_mgr_enable(>output);
@@ -3268,7 +3289,7 @@ static void dsi_enable_video_output(struct 
omap_dss_device *dssdev, int vc)
dsi_if_enable(dsi, false);
dsi_vc_enable(dsi, vc, false);
}
-err_pix_fmt:
+err_video_mode:
dsi_uninit_dispc(dsi);
dev_err(dsi->dev, "failed to enable DSI encoder!\n");
return;
@@ -3278,16 +3299,8 @@ static void dsi_disable_video_output(struct 
omap_dss_device *dssdev, int vc)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
 
-   if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-   dsi_if_enable(dsi, false);
-   dsi_vc_enable(dsi, vc, false);
-
-   /* MODE, 0 = command mode */
-   REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);
-
-   dsi_vc_enable(dsi, vc, true);
-   dsi_if_enable(dsi, true);
-   }
+   if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
+   dsi_disable_video_mode(dsi, vc);
 
 

[PATCH v6 63/84] drm/omap: dsi: drop useless channel checks

2020-12-15 Thread Tomi Valkeinen
A DSI peripheral can have virtual channel ID of 0-3. This should be
always the case, and there's no need in the driver to validate the
channel.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 96193a04b2b8..32e6170abd95 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3899,9 +3899,6 @@ static int dsi_update_channel(struct omap_dss_device 
*dssdev, int channel)
struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
 
-   if (channel > 3)
-   return -EINVAL;
-
dsi_bus_lock(dsi);
 
if (!dsi->video_enabled) {
@@ -5065,12 +5062,8 @@ static int omap_dsi_host_attach(struct mipi_dsi_host 
*host,
struct mipi_dsi_device *client)
 {
struct dsi_data *dsi = host_to_omap(host);
-   unsigned int channel = client->channel;
int r;
 
-   if (channel > 3)
-   return -EINVAL;
-
if (dsi->dsidev) {
DSSERR("dsi client already attached\n");
return -EBUSY;
@@ -5120,10 +5113,6 @@ static int omap_dsi_host_detach(struct mipi_dsi_host 
*host,
struct mipi_dsi_device *client)
 {
struct dsi_data *dsi = host_to_omap(host);
-   unsigned int channel = client->channel;
-
-   if (channel > 3)
-   return -EINVAL;
 
if (WARN_ON(dsi->dsidev != client))
return -EINVAL;
-- 
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 v6 77/84] drm/omap: dsi: display_disable cleanup

2020-12-15 Thread Tomi Valkeinen
We can drop dsi_display_disable() which just calls
_dsi_display_disable(), and rename _dsi_display_disable() to
dsi_display_disable().

The WARN_ON(!dsi_bus_is_locked(dsi)) in dsi_display_disable is extra and
can be dropped, as _dsi_display_disable() has the same WARN_ON().

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 19 +++
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 8ae2f265ada0..dd4132a594a3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -63,8 +63,6 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int 
channel);
 static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
   const struct mipi_dsi_msg *msg);
 
-static void dsi_display_disable(struct omap_dss_device *dssdev);
-
 #ifdef DSI_PERF_MEASURE
 static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
@@ -3769,7 +3767,7 @@ static void dsi_display_enable(struct dsi_data *dsi)
DSSDBG("dsi_display_ulps_enable FAILED\n");
 }
 
-static void _dsi_display_disable(struct dsi_data *dsi,
+static void dsi_display_disable(struct dsi_data *dsi,
bool disconnect_lanes, bool enter_ulps)
 {
WARN_ON(!dsi_bus_is_locked(dsi));
@@ -3788,17 +3786,6 @@ static void _dsi_display_disable(struct dsi_data *dsi,
mutex_unlock(>lock);
 }
 
-static void dsi_display_disable(struct omap_dss_device *dssdev)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   WARN_ON(!dsi_bus_is_locked(dsi));
-
-   DSSDBG("dsi_display_disable\n");
-
-   _dsi_display_disable(dsi, true, false);
-}
-
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
dsi->te_enabled = enable;
@@ -3822,7 +3809,7 @@ static void omap_dsi_ulps_work_callback(struct 
work_struct *work)
 
dsi_enable_te(dsi, false);
 
-   _dsi_display_disable(dsi, false, true);
+   dsi_display_disable(dsi, false, true);
 
dsi_bus_unlock(dsi);
 }
@@ -4956,7 +4943,7 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
 
dsi_disable_video_output(dssdev, VC_VIDEO);
 
-   dsi_display_disable(dssdev);
+   dsi_display_disable(dsi, true, false);
 
dsi_bus_unlock(dsi);
 }
-- 
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 v6 46/84] drm/omap: drop dssdev display field

2020-12-15 Thread Tomi Valkeinen
From: Sebastian Reichel 

All displays are now using a drm_panel or a drm_bridge that models the
connector instead of dssdev, so this field is always 0 and can be
dropped.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
---
 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 332eb0d02c6d..f4a9fcf66b94 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 c073efaed1b4..cc4b7d2629bd 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 v6 74/84] drm/omap: dsi: move structs & defines to dsi.h

2020-12-15 Thread Tomi Valkeinen
Move structs and defines to a private dsi.h header file to make dsi.c a
bit easier to navigate. Also move the (now) private structs and defines
from omapdss.h to dsi.h.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 384 +
 drivers/gpu/drm/omapdrm/dss/dsi.h | 459 ++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  64 
 3 files changed, 460 insertions(+), 447 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/dss/dsi.h

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 6af42753b85a..116406966d15 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -45,73 +45,7 @@
 
 #define DSI_CATCH_MISSING_TE
 
-struct dsi_reg { u16 module; u16 idx; };
-
-#define DSI_REG(mod, idx)  ((const struct dsi_reg) { mod, idx })
-
-/* DSI Protocol Engine */
-
-#define DSI_PROTO  0
-#define DSI_PROTO_SZ   0x200
-
-#define DSI_REVISION   DSI_REG(DSI_PROTO, 0x)
-#define DSI_SYSCONFIG  DSI_REG(DSI_PROTO, 0x0010)
-#define DSI_SYSSTATUS  DSI_REG(DSI_PROTO, 0x0014)
-#define DSI_IRQSTATUS  DSI_REG(DSI_PROTO, 0x0018)
-#define DSI_IRQENABLE  DSI_REG(DSI_PROTO, 0x001C)
-#define DSI_CTRL   DSI_REG(DSI_PROTO, 0x0040)
-#define DSI_GNQDSI_REG(DSI_PROTO, 0x0044)
-#define DSI_COMPLEXIO_CFG1 DSI_REG(DSI_PROTO, 0x0048)
-#define DSI_COMPLEXIO_IRQ_STATUS   DSI_REG(DSI_PROTO, 0x004C)
-#define DSI_COMPLEXIO_IRQ_ENABLE   DSI_REG(DSI_PROTO, 0x0050)
-#define DSI_CLK_CTRL   DSI_REG(DSI_PROTO, 0x0054)
-#define DSI_TIMING1DSI_REG(DSI_PROTO, 0x0058)
-#define DSI_TIMING2DSI_REG(DSI_PROTO, 0x005C)
-#define DSI_VM_TIMING1 DSI_REG(DSI_PROTO, 0x0060)
-#define DSI_VM_TIMING2 DSI_REG(DSI_PROTO, 0x0064)
-#define DSI_VM_TIMING3 DSI_REG(DSI_PROTO, 0x0068)
-#define DSI_CLK_TIMING DSI_REG(DSI_PROTO, 0x006C)
-#define DSI_TX_FIFO_VC_SIZEDSI_REG(DSI_PROTO, 0x0070)
-#define DSI_RX_FIFO_VC_SIZEDSI_REG(DSI_PROTO, 0x0074)
-#define DSI_COMPLEXIO_CFG2 DSI_REG(DSI_PROTO, 0x0078)
-#define DSI_RX_FIFO_VC_FULLNESSDSI_REG(DSI_PROTO, 0x007C)
-#define DSI_VM_TIMING4 DSI_REG(DSI_PROTO, 0x0080)
-#define DSI_TX_FIFO_VC_EMPTINESS   DSI_REG(DSI_PROTO, 0x0084)
-#define DSI_VM_TIMING5 DSI_REG(DSI_PROTO, 0x0088)
-#define DSI_VM_TIMING6 DSI_REG(DSI_PROTO, 0x008C)
-#define DSI_VM_TIMING7 DSI_REG(DSI_PROTO, 0x0090)
-#define DSI_STOPCLK_TIMING DSI_REG(DSI_PROTO, 0x0094)
-#define DSI_VC_CTRL(n) DSI_REG(DSI_PROTO, 0x0100 + (n * 0x20))
-#define DSI_VC_TE(n)   DSI_REG(DSI_PROTO, 0x0104 + (n * 0x20))
-#define DSI_VC_LONG_PACKET_HEADER(n)   DSI_REG(DSI_PROTO, 0x0108 + (n * 0x20))
-#define DSI_VC_LONG_PACKET_PAYLOAD(n)  DSI_REG(DSI_PROTO, 0x010C + (n * 0x20))
-#define DSI_VC_SHORT_PACKET_HEADER(n)  DSI_REG(DSI_PROTO, 0x0110 + (n * 0x20))
-#define DSI_VC_IRQSTATUS(n)DSI_REG(DSI_PROTO, 0x0118 + (n * 0x20))
-#define DSI_VC_IRQENABLE(n)DSI_REG(DSI_PROTO, 0x011C + (n * 0x20))
-
-/* DSIPHY_SCP */
-
-#define DSI_PHY1
-#define DSI_PHY_OFFSET 0x200
-#define DSI_PHY_SZ 0x40
-
-#define DSI_DSIPHY_CFG0DSI_REG(DSI_PHY, 0x)
-#define DSI_DSIPHY_CFG1DSI_REG(DSI_PHY, 0x0004)
-#define DSI_DSIPHY_CFG2DSI_REG(DSI_PHY, 0x0008)
-#define DSI_DSIPHY_CFG5DSI_REG(DSI_PHY, 0x0014)
-#define DSI_DSIPHY_CFG10   DSI_REG(DSI_PHY, 0x0028)
-
-/* DSI_PLL_CTRL_SCP */
-
-#define DSI_PLL2
-#define DSI_PLL_OFFSET 0x300
-#define DSI_PLL_SZ 0x20
-
-#define DSI_PLL_CONTROLDSI_REG(DSI_PLL, 0x)
-#define DSI_PLL_STATUS DSI_REG(DSI_PLL, 0x0004)
-#define DSI_PLL_GO DSI_REG(DSI_PLL, 0x0008)
-#define DSI_PLL_CONFIGURATION1 DSI_REG(DSI_PLL, 0x000C)
-#define DSI_PLL_CONFIGURATION2 DSI_REG(DSI_PLL, 0x0010)
+#include "dsi.h"
 
 #define REG_GET(dsi, idx, start, end) \
FLD_GET(dsi_read_reg(dsi, idx), start, end)
@@ -119,96 +53,6 @@ struct dsi_reg { u16 module; u16 idx; };
 #define REG_FLD_MOD(dsi, idx, val, start, end) \
dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, 
end))
 
-/* Global interrupts */
-#define DSI_IRQ_VC0(1 << 0)
-#define DSI_IRQ_VC1(1 << 1)
-#define DSI_IRQ_VC2(1 << 2)
-#define DSI_IRQ_VC3(1 &

[PATCH v6 81/84] drm/omap: dsi: fix and cleanup ddr_clk_always_on

2020-12-15 Thread Tomi Valkeinen
The driver ignores MIPI_DSI_CLOCK_NON_CONTINUOUS, and always uses
non-continuous clock.

Fix this by using MIPI_DSI_CLOCK_NON_CONTINUOUS and at the same time,
drop ddr_clk_always_on field which seems pretty useless.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 12 +---
 drivers/gpu/drm/omapdrm/dss/dsi.h |  2 --
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a17d7345fc9a..749f591a3d5e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1736,11 +1736,10 @@ static int dsi_cio_init(struct dsi_data *dsi)
 
dsi_cio_timings(dsi);
 
-   if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-   /* DDR_CLK_ALWAYS_ON */
-   REG_FLD_MOD(dsi, DSI_CLK_CTRL,
-   dsi->vm_timings.ddr_clk_always_on, 13, 13);
-   }
+   /* DDR_CLK_ALWAYS_ON */
+   REG_FLD_MOD(dsi, DSI_CLK_CTRL,
+   !(dsi->dsidev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS),
+   13, 13);
 
dsi->ulps_enabled = false;
 
@@ -3643,7 +3642,7 @@ static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
dsi_force_tx_stop_mode_io(dsi);
 
/* start the DDR clock by sending a NULL packet */
-   if (dsi->vm_timings.ddr_clk_always_on)
+   if (!(dsi->dsidev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS))
dsi_vc_send_null(dsi, VC_CMD, dsi->dsidev->channel);
 }
 
@@ -4152,7 +4151,6 @@ static bool dsi_vm_calc_blanking(struct dsi_clk_calc_ctx 
*ctx)
dsi_vm->hfp_blanking_mode = 1;
dsi_vm->hbp_blanking_mode = 1;
 
-   dsi_vm->ddr_clk_always_on = cfg->ddr_clk_always_on;
dsi_vm->window_sync = 4;
 
/* setup DISPC videomode */
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h 
b/drivers/gpu/drm/omapdrm/dss/dsi.h
index 478fc10bd18d..476069fda082 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.h
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
@@ -212,7 +212,6 @@ struct omap_dss_dsi_videomode_timings {
 
enum omap_dss_dsi_trans_mode trans_mode;
 
-   bool ddr_clk_always_on;
int window_sync;
 };
 
@@ -224,7 +223,6 @@ struct omap_dss_dsi_config {
unsigned long hs_clk_min, hs_clk_max;
unsigned long lp_clk_min, lp_clk_max;
 
-   bool ddr_clk_always_on;
enum omap_dss_dsi_trans_mode trans_mode;
 };
 
-- 
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 v6 69/84] drm/omap: dsi: enable HS before sending the frame

2020-12-15 Thread Tomi Valkeinen
We currently use a single VC for sending commands and pixel data. The
LP/HS mode for pixel data is correctly set to HS by accident, as we have
set the VC to HS already earlier.

However, if we use a different VC for video data, the VC is in LP mode.
Fix this by always enabling HS mode before starting a frame update.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 6d97ca018a62..fb21b3235042 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3915,6 +3915,8 @@ static int dsi_update_channel(struct omap_dss_device 
*dssdev, int vc)
 
dsi_set_ulps_auto(dsi, false);
 
+   dsi_vc_enable_hs(dssdev, vc, true);
+
/*
 * Send NOP between the frames. If we don't send something here, the
 * updates stop working. This is probably related to DSI spec stating
-- 
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 v6 62/84] drm/omap: dsi: simplify VC handling

2020-12-15 Thread Tomi Valkeinen
The VC handling has gotten quite tangled up. As the first step to clean
it up, lets define that we only support a single DSI peripheral (which
was really already the case), and we always use VC0 (define VC_DEFAULT
0) register block to send data to the peripheral.

We can thus have a single mipi_dsi_device pointer and remove the
for-loops which made passes over all the four VCs (just the first one
was ever used).

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

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index e24db2431fb8..96193a04b2b8 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -360,9 +360,10 @@ struct dsi_data {
bool vdds_dsi_enabled;
struct regulator *vdds_dsi_reg;
 
+   struct mipi_dsi_device *dsidev;
+
struct {
enum dsi_vc_source source;
-   struct mipi_dsi_device *dest;
enum fifo_size tx_fifo_size;
enum fifo_size rx_fifo_size;
} vc[4];
@@ -452,6 +453,8 @@ static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
 #endif
 
+#define VC_DEFAULT 0
+
 #define drm_bridge_to_dsi(bridge) \
container_of(bridge, struct dsi_data, bridge)
 
@@ -3718,16 +3721,11 @@ static void dsi_disable_video_output(struct 
omap_dss_device *dssdev, int channel
 static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
-   unsigned int i;
 
dsi_bus_lock(dsi);
dsi->video_enabled = false;
 
-   for (i = 0; i < 4; i++) {
-   if (!dsi->vc[i].dest)
-   continue;
-   dsi_disable_video_output(dssdev, i);
-   }
+   dsi_disable_video_output(dssdev, VC_DEFAULT);
 
dsi_display_disable(dssdev);
 
@@ -3911,11 +3909,6 @@ static int dsi_update_channel(struct omap_dss_device 
*dssdev, int channel)
goto err;
}
 
-   if (!dsi->vc[channel].dest) {
-   r = -ENODEV;
-   goto err;
-   }
-
if (dsi->vm.hactive == 0 || dsi->vm.vactive == 0) {
r = -EINVAL;
goto err;
@@ -3956,16 +3949,7 @@ static int dsi_update_channel(struct omap_dss_device 
*dssdev, int channel)
 
 static int dsi_update_all(struct omap_dss_device *dssdev)
 {
-   unsigned int i;
-   int r;
-
-   for (i = 0; i < 4; i++) {
-   r = dsi_update_channel(dssdev, i);
-   if (r && r != -ENODEV)
-   return r;
-   }
-
-   return r;
+   return dsi_update_channel(dssdev, VC_DEFAULT);
 }
 
 /* Display funcs */
@@ -4193,17 +4177,12 @@ static void dsi_display_enable(struct omap_dss_device 
*dssdev)
 static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
-   unsigned int i;
 
dsi_bus_lock(dsi);
 
dsi_display_enable(dssdev);
 
-   for (i = 0; i < 4; i++) {
-   if (!dsi->vc[i].dest)
-   continue;
-   dsi_enable_video_output(dssdev, i);
-   }
+   dsi_enable_video_output(dssdev, VC_DEFAULT);
 
dsi->video_enabled = true;
 
@@ -5092,8 +5071,8 @@ static int omap_dsi_host_attach(struct mipi_dsi_host 
*host,
if (channel > 3)
return -EINVAL;
 
-   if (dsi->vc[channel].dest) {
-   DSSERR("cannot get VC for display %s", dev_name(>dev));
+   if (dsi->dsidev) {
+   DSSERR("dsi client already attached\n");
return -EBUSY;
}
 
@@ -5114,7 +5093,7 @@ static int omap_dsi_host_attach(struct mipi_dsi_host 
*host,
dsi->mode = OMAP_DSS_DSI_CMD_MODE;
}
 
-   dsi->vc[channel].dest = client;
+   dsi->dsidev = client;
dsi->pix_fmt = client->format;
 
INIT_DEFERRABLE_WORK(>ulps_work,
@@ -5146,11 +5125,11 @@ static int omap_dsi_host_detach(struct mipi_dsi_host 
*host,
if (channel > 3)
return -EINVAL;
 
-   if (dsi->vc[channel].dest != client)
+   if (WARN_ON(dsi->dsidev != client))
return -EINVAL;
 
omap_dsi_unregister_te_irq(dsi);
-   dsi->vc[channel].dest = NULL;
+   dsi->dsidev = NULL;
return 0;
 }
 
@@ -5682,10 +5661,8 @@ static int dsi_probe(struct platform_device *pdev)
}
 
/* DSI VCs initialization */
-   for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
+   for (i = 0; i < ARRAY_SIZE(dsi->vc); i++)
dsi->vc[i].source = DSI_VC_SOURCE_L4;
-   dsi->vc[i].dest = NULL;
-   }
 
r = dsi_get_clocks(dsi);
if (r)
-- 
Texas

[PATCH v6 76/84] drm/omap: dsi: display_enable cleanup

2020-12-15 Thread Tomi Valkeinen
We can drop dsi_display_enable(), which just calls
_dsi_display_enable(), and rename _dsi_display_enable() to
dsi_display_enable().

The WARN_ON(!dsi_bus_is_locked(dsi)) in dsi_display_enable is extra and
can be dropped, as _dsi_display_enable() has the same WARN_ON().

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 320342385172..8ae2f265ada0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3740,7 +3740,7 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, 
bool disconnect_lanes,
}
 }
 
-static void _dsi_display_enable(struct dsi_data *dsi)
+static void dsi_display_enable(struct dsi_data *dsi)
 {
int r;
 
@@ -3769,16 +3769,6 @@ static void _dsi_display_enable(struct dsi_data *dsi)
DSSDBG("dsi_display_ulps_enable FAILED\n");
 }
 
-static void dsi_display_enable(struct omap_dss_device *dssdev)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-   DSSDBG("dsi_display_enable\n");
-
-   WARN_ON(!dsi_bus_is_locked(dsi));
-
-   _dsi_display_enable(dsi);
-}
-
 static void _dsi_display_disable(struct dsi_data *dsi,
bool disconnect_lanes, bool enter_ulps)
 {
@@ -3853,7 +3843,7 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool 
enable)
return;
 
dsi_bus_lock(dsi);
-   _dsi_display_enable(dsi);
+   dsi_display_enable(dsi);
dsi_enable_te(dsi, true);
dsi_bus_unlock(dsi);
}
@@ -4944,7 +4934,7 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
 
dsi_bus_lock(dsi);
 
-   dsi_display_enable(dssdev);
+   dsi_display_enable(dsi);
 
dsi_enable_video_output(dssdev, VC_VIDEO);
 
-- 
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 v6 60/84] drm/panel: panel-dsi-cm: set column & page at setup

2020-12-15 Thread Tomi Valkeinen
Set the column & page address once during setup, instead of relying the
DSI host driver to set those.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c 
b/drivers/gpu/drm/panel/panel-dsi-cm.c
index c2e702172df2..067745fb682f 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -170,6 +170,22 @@ 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)
+{
+   struct mipi_dsi_device *dsi = ddata->dsi;
+   int r;
+
+   r = mipi_dsi_dcs_set_column_address(dsi, 0, ddata->mode.hdisplay - 1);
+   if (r < 0)
+   return r;
+
+   r = mipi_dsi_dcs_set_page_address(dsi, 0, ddata->mode.vdisplay - 1);
+   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);
@@ -307,6 +323,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
+   r = dsicm_set_update_window(ddata);
+   if (r)
+   goto err;
+
r = mipi_dsi_dcs_set_display_on(ddata->dsi);
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 v6 75/84] drm/omap: dsi: move enable/disable to bridge enable/disable

2020-12-15 Thread Tomi Valkeinen
Clean up the code by inlining dsi_enable_video_outputs and
dsi_disable_video_outputs functions.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 55 +--
 1 file changed, 22 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 116406966d15..320342385172 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3338,20 +3338,6 @@ static void dsi_disable_video_output(struct 
omap_dss_device *dssdev, int vc)
dsi_display_uninit_dispc(dsi);
 }
 
-static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   dsi_bus_lock(dsi);
-   dsi->video_enabled = false;
-
-   dsi_disable_video_output(dssdev, VC_VIDEO);
-
-   dsi_display_disable(dssdev);
-
-   dsi_bus_unlock(dsi);
-}
-
 static void dsi_update_screen_dispc(struct dsi_data *dsi)
 {
unsigned int bytespp;
@@ -3793,23 +3779,6 @@ static void dsi_display_enable(struct omap_dss_device 
*dssdev)
_dsi_display_enable(dsi);
 }
 
-static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
-{
-   struct dsi_data *dsi = to_dsi_data(dssdev);
-
-   dsi_bus_lock(dsi);
-
-   dsi_display_enable(dssdev);
-
-   dsi_enable_video_output(dssdev, VC_VIDEO);
-
-   dsi->video_enabled = true;
-
-   dsi_set_ulps_auto(dsi, true);
-
-   dsi_bus_unlock(dsi);
-}
-
 static void _dsi_display_disable(struct dsi_data *dsi,
bool disconnect_lanes, bool enter_ulps)
 {
@@ -4971,15 +4940,35 @@ static void dsi_bridge_mode_set(struct drm_bridge 
*bridge,
 static void dsi_bridge_enable(struct drm_bridge *bridge)
 {
struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+   struct omap_dss_device *dssdev = >output;
 
-   dsi_enable_video_outputs(>output);
+   dsi_bus_lock(dsi);
+
+   dsi_display_enable(dssdev);
+
+   dsi_enable_video_output(dssdev, VC_VIDEO);
+
+   dsi->video_enabled = true;
+
+   dsi_set_ulps_auto(dsi, true);
+
+   dsi_bus_unlock(dsi);
 }
 
 static void dsi_bridge_disable(struct drm_bridge *bridge)
 {
struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+   struct omap_dss_device *dssdev = >output;
+
+   dsi_bus_lock(dsi);
+
+   dsi->video_enabled = false;
+
+   dsi_disable_video_output(dssdev, VC_VIDEO);
 
-   dsi_disable_video_outputs(>output);
+   dsi_display_disable(dssdev);
+
+   dsi_bus_unlock(dsi);
 }
 
 static const struct drm_bridge_funcs dsi_bridge_funcs = {
-- 
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 v6 39/84] drm/panel: Move OMAP's DSI command mode panel driver

2020-12-15 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 
Acked-by: Sam Ravnborg 
Acked-by: Laurent Pinchart 
---
 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 8fec45b2ce02..4894913936e9 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -57,6 +57,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 03496695e03f..cae4d976c069 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -4,6 +4,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 v6 36/84] drm/omap: panel-dsi-cm: support unbinding

2020-12-15 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 
Acked-by: Laurent Pinchart 
---
 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 95b0696436b0..3e46aa6d5ead 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -597,7 +597,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);
 
@@ -627,11 +627,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 v6 57/84] ARM: dts: omap5: add address-cells & size-cells to dsi

2020-12-15 Thread Tomi Valkeinen
Add address-cells & size-cells to DSI nodes so that board files do not
need to define them.

Signed-off-by: Tomi Valkeinen 
Cc: Tony Lindgren 
Acked-by: Tony Lindgren 
Reviewed-by: Sebastian Reichel 
---
 arch/arm/boot/dts/omap5.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 2bf2e5839a7f..e6f6947965ef 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -517,6 +517,9 @@ dsi1: encoder@0 {
clocks = <_clkctrl 
OMAP5_DSS_CORE_CLKCTRL 8>,
 <_clkctrl 
OMAP5_DSS_CORE_CLKCTRL 10>;
clock-names = "fck", "sys_clk";
+
+   #address-cells = <1>;
+   #size-cells = <0>;
};
};
 
@@ -549,6 +552,9 @@ dsi2: encoder@0 {
clocks = <_clkctrl 
OMAP5_DSS_CORE_CLKCTRL 8>,
 <_clkctrl 
OMAP5_DSS_CORE_CLKCTRL 10>;
clock-names = "fck", "sys_clk";
+
+   #address-cells = <1>;
+   #size-cells = <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 v6 53/84] drm/omap: remove dispc_ops

2020-12-15 Thread Tomi Valkeinen
dispc_ops was created to help with the multi-module architecture and
giving us the possibility of multiple dispc implementations. Neither of
these is valid anymore, and we can remove dispc_ops and use direct
calls to dispc.

Signed-off-by: Tomi Valkeinen 
Acked-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/base.c|   5 --
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 101 +++---
 drivers/gpu/drm/omapdrm/dss/dss.h |  71 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  71 --
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  30 
 drivers/gpu/drm/omapdrm/omap_drv.c|  15 ++--
 drivers/gpu/drm/omapdrm/omap_drv.h|   2 +-
 drivers/gpu/drm/omapdrm/omap_irq.c|  34 -
 drivers/gpu/drm/omapdrm/omap_plane.c  |  12 +--
 9 files changed, 143 insertions(+), 198 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 028c0cd73934..050ca7eafac5 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -21,11 +21,6 @@ struct dispc_device *dispc_get_dispc(struct dss_device *dss)
return dss->dispc;
 }
 
-const struct dispc_ops *dispc_get_ops(struct dss_device *dss)
-{
-   return dss->dispc_ops;
-}
-
 /* 
-
  * OMAP DSS Devices Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 599183879caf..319f90f3b099 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -351,8 +351,6 @@ static unsigned long dispc_plane_pclk_rate(struct 
dispc_device *dispc,
 static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
   enum omap_plane_id plane);
 
-static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
-
 static inline void dispc_write_reg(struct dispc_device *dispc, u16 idx, u32 
val)
 {
__raw_writel(val, dispc->base + idx);
@@ -379,12 +377,12 @@ static void mgr_fld_write(struct dispc_device *dispc, 
enum omap_channel channel,
REG_FLD_MOD(dispc, rfld->reg, val, rfld->high, rfld->low);
 }
 
-static int dispc_get_num_ovls(struct dispc_device *dispc)
+int dispc_get_num_ovls(struct dispc_device *dispc)
 {
return dispc->feat->num_ovls;
 }
 
-static int dispc_get_num_mgrs(struct dispc_device *dispc)
+int dispc_get_num_mgrs(struct dispc_device *dispc)
 {
return dispc->feat->num_mgrs;
 }
@@ -670,13 +668,13 @@ void dispc_runtime_put(struct dispc_device *dispc)
WARN_ON(r < 0 && r != -ENOSYS);
 }
 
-static u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
+u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
   enum omap_channel channel)
 {
return mgr_desc[channel].vsync_irq;
 }
 
-static u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
+u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
   enum omap_channel channel)
 {
if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc->feat->no_framedone_tv)
@@ -685,18 +683,18 @@ static u32 dispc_mgr_get_framedone_irq(struct 
dispc_device *dispc,
return mgr_desc[channel].framedone_irq;
 }
 
-static u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
+u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
   enum omap_channel channel)
 {
return mgr_desc[channel].sync_lost_irq;
 }
 
-static u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
+u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
 {
return DISPC_IRQ_FRAMEDONEWB;
 }
 
-static void dispc_mgr_enable(struct dispc_device *dispc,
+void dispc_mgr_enable(struct dispc_device *dispc,
 enum omap_channel channel, bool enable)
 {
mgr_fld_write(dispc, channel, DISPC_MGR_FLD_ENABLE, enable);
@@ -710,13 +708,13 @@ static bool dispc_mgr_is_enabled(struct dispc_device 
*dispc,
return !!mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
 }
 
-static bool dispc_mgr_go_busy(struct dispc_device *dispc,
+bool dispc_mgr_go_busy(struct dispc_device *dispc,
  enum omap_channel channel)
 {
return mgr_fld_read(dispc, channel, DISPC_MGR_FLD_GO) == 1;
 }
 
-static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
+void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
 {
WARN_ON(!dispc_mgr_is_enabled(dispc, channel));
WARN_ON(dispc_mgr_go_busy(dispc, channel));
@@ -726,12 +724,12 @@ static void dispc_mgr_go(struct dispc_device *dispc, enum 
omap_channel channel)
mgr_fld_write(dispc, channel, DISPC_MGR_FLD_GO, 1);
 }
 
-static bool dispc_wb_go_busy(struct dispc_device *dispc)
+bool dispc_wb_go_busy(stru

[PATCH v6 17/84] drm/omap: dsi: drop unused memory_read()

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 .../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 e4e86e70e333..870271fc0498 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -930,97 +930,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(>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(>dsi->dev, "short read\n");
-   break;
-   }
-
-   if (signal_pending(current)) {
-   dev_err(>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(>lock);
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -1093,8 +1002,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 f77fa2d6a1dc..856110481e95 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 v6 68/84] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode

2020-12-15 Thread Tomi Valkeinen
Simplify and optimize dsi_vc_enable_hs() so that it can be called
without checking the current HS/LP mode. Make dsi_vc_enable_hs() return
if the VC is already in the correct mode.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 9499e424ec90..6d97ca018a62 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -341,7 +341,6 @@ struct dsi_data {
int irq;
 
bool is_enabled;
-   bool in_lp_mode;
 
struct clk *dss_clk;
struct regmap *syscon;
@@ -2443,6 +2442,9 @@ static void dsi_vc_enable_hs(struct omap_dss_device 
*dssdev, int vc,
 
DSSDBG("dsi_vc_enable_hs(%d, %d)\n", vc, enable);
 
+   if (REG_GET(dsi, DSI_VC_CTRL(vc), 9, 9) == enable)
+   return;
+
WARN_ON(!dsi_bus_is_locked(dsi));
 
dsi_vc_enable(dsi, vc, 0);
@@ -2458,8 +2460,6 @@ static void dsi_vc_enable_hs(struct omap_dss_device 
*dssdev, int vc,
/* start the DDR clock by sending a NULL packet */
if (dsi->vm_timings.ddr_clk_always_on && enable)
dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
-
-   dsi->in_lp_mode = !enable;
 }
 
 static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
@@ -4888,9 +4888,7 @@ static ssize_t _omap_dsi_host_transfer(struct dsi_data 
*dsi, int vc,
struct omap_dss_device *dssdev = >output;
int r;
 
-   if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode)
-   dsi_vc_enable_hs(dssdev, vc,
-!(msg->flags & MIPI_DSI_MSG_USE_LPM));
+   dsi_vc_enable_hs(dssdev, vc, !(msg->flags & MIPI_DSI_MSG_USE_LPM));
 
switch (msg->type) {
case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
-- 
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 v6 67/84] drm/omap: dsi: untangle vc & channel

2020-12-15 Thread Tomi Valkeinen
DSI virtual channel and hardware VC blocks have gotten tangled as
described in the previous commits. This has not caused any issues, as
the value for both is 0, so it happens to work.

To fix the issue, change the code to use the correct one of the two.

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

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 7c8fe5da3099..9499e424ec90 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2615,7 +2615,7 @@ static inline void dsi_vc_write_long_header(struct 
dsi_data *dsi, int vc,
 
WARN_ON(!dsi_bus_is_locked(dsi));
 
-   data_id = data_type | vc << 6;
+   data_id = data_type | channel << 6;
 
val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
FLD_VAL(ecc, 31, 24);
@@ -2649,12 +2649,12 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int 
vc,
DSSDBG("dsi_vc_send_long, %d bytes\n", msg->tx_len);
 
/* len + header */
-   if (dsi->vc[msg->channel].tx_fifo_size * 32 * 4 < msg->tx_len + 4) {
+   if (dsi->vc[vc].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, msg->channel, DSI_VC_SOURCE_L4);
+   dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
 
dsi_vc_write_long_header(dsi, vc, msg->channel, msg->type, msg->tx_len, 
0);
 
@@ -2668,7 +2668,7 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
b3 = *p++;
b4 = *p++;
 
-   dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, b4);
+   dsi_vc_write_long_payload(dsi, vc, b1, b2, b3, b4);
}
 
i = msg->tx_len % 4;
@@ -2693,7 +2693,7 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
break;
}
 
-   dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, 0);
+   dsi_vc_write_long_payload(dsi, vc, b1, b2, b3, 0);
}
 
return r;
@@ -2712,12 +2712,12 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int 
vc,
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",
-  msg->channel, msg->type, pkt.header[1], pkt.header[2]);
+   DSSDBG("dsi_vc_send_short(vc%d, dt %#x, b1 %#x, b2 %#x)\n",
+  vc, msg->type, pkt.header[1], pkt.header[2]);
 
-   dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
+   dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
 
-   if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(msg->channel)), 16, 16)) {
+   if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(vc)), 16, 16)) {
DSSERR("ERROR FIFO FULL, aborting transfer\n");
return -EINVAL;
}
@@ -2725,7 +2725,7 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
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(msg->channel), r);
+   dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc), r);
 
return 0;
 }
@@ -2733,7 +2733,7 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
 static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel)
 {
const struct mipi_dsi_msg msg = {
-   .channel = vc,
+   .channel = channel,
.type = MIPI_DSI_NULL_PACKET,
};
 
@@ -2761,16 +2761,16 @@ static int dsi_vc_write_common(struct omap_dss_device 
*dssdev, int vc,
 * In that case we can return early.
 */
 
-   r = dsi_vc_send_bta_sync(dssdev, msg->channel);
+   r = dsi_vc_send_bta_sync(dssdev, vc);
if (r) {
DSSERR("bta sync failed\n");
return r;
}
 
/* RX_FIFO_NOT_EMPTY */
-   if (REG_GET(dsi, DSI_VC_CTRL(msg->channel), 20, 20)) {
+   if (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
DSSERR("rx fifo not empty after write, dumping data:\n");
-   dsi_vc_flush_receive_data(dsi, msg->channel);
+   dsi_vc_flush_receive_data(dsi, vc);
return -EIO;
}
 
@@ -2890,21 +2890,20 @@ static int dsi_vc_dcs_read(struct omap_dss_device 
*dssdev, int vc,
 {
struct dsi_data *dsi = to_dsi_data(dssdev);
u8 cmd = ((u8 *)msg->tx_buf)[0];
-   u8 channel = msg->channel;
int r;
 
if (dsi->debug_read)
-

[PATCH v6 38/84] drm/omap: remove global dss_device variable

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 3d2aa9d4ab6b..68c5d058b2e9 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 d7b2f5bcac16..0556711f57cd 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1308,6 +1308,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);
@@ -1316,9 +1317,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,
+, sizeof(pdata));
if (IS_ERR(drm_pdev)) {
component_unbind_all(dev, NULL);
return PTR_ERR(drm_pdev);
@@ -1335,8 +1336,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 dd2e25548677..2345caf7721c 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 42c2ed752095..825478c01968 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -568,6 +568,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;
 
@@ -582,7 +583,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);
 
@@ -677,9 +678,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(>dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(>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 v6 44/84] drm/omap: drop unused DSS next pointer

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 fb8b6a6dca1c..332eb0d02c6d 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 c74b3c6164f5..0547c69a2c1b 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 5affdf078134..374a4ce6d931 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 943348912be8..4dd05bc732da 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(, 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 v6 33/84] drm/omap: drop omapdss-boot-init

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 311039024595..3019ac1013b2 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 6a33a56a4b4e..
--- 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 - https://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;
-   l

[PATCH v6 54/84] drm/omap: remove dss_mgr_ops

2020-12-15 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 
Acked-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 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 fee6e1dd474c..58a7e763fbe3 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 cd1cfcb2abd0..7378e855c278 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_

[PATCH v6 30/84] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations

2020-12-15 Thread Tomi Valkeinen
From: Sebastian Reichel 

Complete the direction reversal of the DSS device enable/disable
operations started by commit 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 
Reviewed-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 74 +--
 drivers/gpu/drm/omapdrm/omap_encoder.c| 28 ++-
 2 files changed, 45 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ccaf6ffe4f86..b72930dcbdf4 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -284,27 +284,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 = >vm,
-   .hs_clk_min = 15000,
-   .hs_clk_max = 3,
-   .lp_clk_min = 700,
-   .lp_clk_max = 1000,
-   };
-
-   r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
-   if (r) {
-   dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
-   return r;
-   }
-
-   r = src->ops->dsi.set_config(src, _config);
-   if (r) {
-   dev_err(>dsi->dev, "failed to configure DSI\n");
-   goto err_regulators;
-   }
-
-   src->ops->enable(src);
 
dsicm_hw_reset(ddata);
 
@@ -359,12 +338,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(ARRAY_SIZE(ddata->supplies), 
ddata->supplies);
-   if (r)
-   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
-
return r;
 }
 
@@ -373,6 +346,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);
@@ -384,14 +359,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(ARRAY_SIZE(ddata->supplies), 
ddata->supplies);
-   if (r)
-   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
-
-   ddata->enabled = false;
 }
 
 static int dsicm_connect(struct omap_dss_device *src,
@@ -411,6 +378,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 = >vm,
+   .hs_clk_min = 15000,
+   .hs_clk_max = 3,
+   .lp_clk_min = 700,
+   .lp_clk_max = 1000,
+   };
+
+   r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
+   if (r)
+   dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
+
+   r = src->ops->dsi.set_config(src, _config);
+   if (r) {
+   dev_err(>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);
@@ -445,6 +435,16 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
mutex_unlock(>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(ARRAY_SIZE(ddata->supplies), 
ddata->supplies);
+   if (r)
+   dev_err(>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;
@@ -498,8 +498,10 @@ static const struct omap_dss_device_ops dsicm_ops = {
.connect= dsicm_connect,
.disconnect = dsicm_disconnect,
 
+   .pre_enable = dsicm_pre_enable,
.enable = dsicm_

[PATCH v6 28/84] drm/omap: dsi: do ULPS in host driver

2020-12-15 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.

Note that for now ULPS is always disabled.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
Acked-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 266 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c |  71 +++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   2 -
 3 files changed, 60 insertions(+), 279 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 8253d3048a53..b4aa3bc98062 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -15,7 +15,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -65,22 +64,12 @@ struct panel_drv_data {
bool enabled;
 
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;
@@ -204,94 +193,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, >ulps_work,
-   msecs_to_jiffies(ddata->ulps_timeout));
-}
-
-static void dsicm_cancel_ulps_work(struct panel_drv_data *ddata)
-{
-   cancel_delayed_work(>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(>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, true);
-   if (r) {
-   dev_err(>dsi->dev, "failed to re-enable TE");
-   goto err2;
-   }
-
-   dsicm_queue_ulps_work(ddata);
-
-   ddata->ulps_enabled = false;
-
-   return 0;
-
-err2:
-   dev_err(>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);
@@ -309,7 +210,6 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
mutex_lock(>lock);
 
if (ddata->enabled) {
-   r = dsicm_wake_up(ddata);
if (!r)
r = dsicm_dcs_write_1(
ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
@@ -339,18 +239,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(>lock);
 
-   if (ddata->enabled) {
-   r = dsicm_wake_up(ddata);
-   if (!r)
-   r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
-   );
-   } else {
-   r = -ENODEV;
-   }
+   if (ddata->enabled)
+   r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, );
 
mutex_unlock(>lock);
 
@@ -365,17 +259,12 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
 {
struct panel_drv_data *ddata = dev_get_drvdata(dev);

[PATCH v6 27/84] drm/omap: dsi: untangle ulps ops from enable/disable

2020-12-15 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 | 53 ++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  5 +-
 3 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index efbca64355d6..8253d3048a53 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -230,7 +230,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;
 
@@ -255,7 +255,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, true);
@@ -582,7 +582,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(ARRAY_SIZE(ddata->supplies), 
ddata->supplies);
if (r)
@@ -608,7 +608,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(ARRAY_SIZE(ddata->supplies), 
ddata->supplies);
if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 211415135682..5853f89aebbe 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4052,14 +4052,11 @@ 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_enable(struct dsi_data *dsi)
 {
-   struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
 
-   DSSDBG("dsi_display_enable\n");
-
-   dsi_bus_lock(dsi);
+   WARN_ON(!dsi_bus_is_locked(dsi));
 
mutex_lock(>lock);
 
@@ -4075,25 +4072,29 @@ static void dsi_display_enable(struct omap_dss_device 
*dssdev)
 
mutex_unlock(>lock);
 
-   dsi_bus_unlock(dsi);
-
return;
 
 err_init_dsi:
dsi_runtime_put(dsi);
 err_get_dsi:
mutex_unlock(>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_disable\n");
+   DSSDBG("dsi_display_enable\n");
 
dsi_bus_lock(dsi);
+   _dsi_display_enable(dsi);
+   dsi_bus_unlock(dsi);
+}
+
+static void _dsi_display_disable(struct dsi_data *dsi,
+   bool disconnect_lanes, bool enter_ulps)
+{
+   WARN_ON(!dsi_bus_is_locked(dsi));
 
mutex_lock(>lock);
 
@@ -4107,6 +4108,31 @@ static void dsi_display_disable(struct omap_dss_device 
*dssdev,
dsi_runtime_put(dsi);
 
mutex_unlock(>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_bus_lock(dsi);
+   _dsi_display_disable(dsi, true, false);
+   dsi_bus_unlock(dsi);
+}
+
+static void dsi_ulps(struct omap_dss_device *dssdev, bool enable)
+{
+   struct dsi_data *dsi = to_dsi_data(dssdev);
+
+   DSSDBG("dsi_ulps %d\n", enable);
+
+   dsi_bus_lock(dsi);
+
+   if (enable)
+   _dsi_display_disable(dsi, false, true);
+   else
+   _dsi_display_enable(dsi);
 
dsi_bus_unlock(dsi);
 }
@@ -4812,9 +4838,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/omapdr

[PATCH v6 70/84] drm/omap: dsi: use separate VCs for cmd and video

2020-12-15 Thread Tomi Valkeinen
For command mode panels we can use a single VC for sending command and
video data, even if we have to change the data source for that VC when
going from command to video or vice versa.

However, with video mode panels we want to keep the pixel data VC
enabled, and use another VC for command data, and the commands will get
interleaved into the pixel data.

This patch makes the driver use VC0 for commands and VC1 for video.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index fb21b3235042..6af42753b85a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -452,7 +452,9 @@ static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
 #endif
 
-#define VC_DEFAULT 0
+/* Note: for some reason video mode seems to work only if VC_VIDEO is 0 */
+#define VC_VIDEO   0
+#define VC_CMD 1
 
 #define drm_bridge_to_dsi(bridge) \
container_of(bridge, struct dsi_data, bridge)
@@ -3725,7 +3727,7 @@ static void dsi_disable_video_outputs(struct 
omap_dss_device *dssdev)
dsi_bus_lock(dsi);
dsi->video_enabled = false;
 
-   dsi_disable_video_output(dssdev, VC_DEFAULT);
+   dsi_disable_video_output(dssdev, VC_VIDEO);
 
dsi_display_disable(dssdev);
 
@@ -3948,7 +3950,7 @@ static int dsi_update_channel(struct omap_dss_device 
*dssdev, int vc)
 
 static int dsi_update_all(struct omap_dss_device *dssdev)
 {
-   return dsi_update_channel(dssdev, VC_DEFAULT);
+   return dsi_update_channel(dssdev, VC_VIDEO);
 }
 
 /* Display funcs */
@@ -4181,7 +4183,7 @@ static void dsi_enable_video_outputs(struct 
omap_dss_device *dssdev)
 
dsi_display_enable(dssdev);
 
-   dsi_enable_video_output(dssdev, VC_DEFAULT);
+   dsi_enable_video_output(dssdev, VC_VIDEO);
 
dsi->video_enabled = true;
 
@@ -4938,7 +4940,7 @@ static ssize_t omap_dsi_host_transfer(struct 
mipi_dsi_host *host,
 {
struct dsi_data *dsi = host_to_omap(host);
int r;
-   int vc = VC_DEFAULT;
+   int vc = VC_CMD;
 
dsi_bus_lock(dsi);
 
-- 
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 v6 20/84] drm/omap: dsi: drop useless sync()

2020-12-15 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 c1afb71af01c..f1e917afcbe4 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -844,23 +844,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(>dsi->dev, "sync\n");
-
-   mutex_lock(>lock);
-   src->ops->dsi.bus_lock(src);
-   src->ops->dsi.bus_unlock(src);
-   mutex_unlock(>lock);
-
-   dev_dbg(>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;
@@ -949,7 +932,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 68b3ec4d2553..b02a75d55133 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 7d66269ad998..b6700f2043be 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(>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 v6 34/84] drm/omap: dsi: implement check timings

2020-12-15 Thread Tomi Valkeinen
From: Sebastian Reichel 

Implement check timings, which will check if it's 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 a609a602e5ae..6f66ef0be166 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 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;
@@ -4790,44 +4791,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, );
-   cfg.vm = 
-
-   mutex_lock(>lock);
 
+   cfg.vm = 
cfg.mode = dsi->mode;
cfg.pixel_format = dsi->pix_fmt;
 
if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
-   ok = dsi_vm_calc(dsi, , );
+   ok = dsi_vm_calc(dsi, , ctx);
else
-   ok = dsi_cm_calc(dsi, , );
+   ok = dsi_cm_calc(dsi, , 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, >dsi_cinfo);
 
-   dsi_pll_calc_dsi_fck(dsi, _cinfo);
+   r = dsi_lp_clock_calc(ctx->dsi_cinfo.clkout[HSDIV_DSI],
+   cfg.lp_clk_min, cfg.lp_clk_max, >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, >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(>lock);
+
+   r = __dsi_calc_config(dsi, mode, );
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.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(>lock);
+   r = __dsi_calc_config(dsi, mode, );
+   mutex_unlock(>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 v6 42/84] drm/omap: remove unused omap_connector

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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   |  19 
 6 files changed, 6 insertions(+), 190 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 9d14a314e564..
--- 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 - https://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,
-  _mode);
-   if (status != MODE_OK)
-   goto done;
-
-   /* Check if vrefresh is still valid. */
-   if (drm_mode_vrefresh(mode) != drm_mode_vrefresh(_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 = _connector-&g

[PATCH v6 64/84] drm/omap: dsi: cleanup dispc channel usage

2020-12-15 Thread Tomi Valkeinen
The "channel" usage in omap dsi driver is confusing. As the first step,
change "channel" to "dispc_channel" when dealing with the dispc channel.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 32e6170abd95..789c26baad86 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3975,10 +3975,10 @@ static int dsi_configure_dispc_clocks(struct dsi_data 
*dsi)
 
 static int dsi_display_init_dispc(struct dsi_data *dsi)
 {
-   enum omap_channel channel = dsi->output.dispc_channel;
+   enum omap_channel dispc_channel = dsi->output.dispc_channel;
int r;
 
-   dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
+   dss_select_lcd_clk_source(dsi->dss, dispc_channel, dsi->module_id == 0 ?
DSS_CLK_SRC_PLL1_1 :
DSS_CLK_SRC_PLL2_1);
 
@@ -4014,19 +4014,19 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
dss_mgr_unregister_framedone_handler(>output,
dsi_framedone_irq_callback, dsi);
 err:
-   dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
+   dss_select_lcd_clk_source(dsi->dss, dispc_channel, DSS_CLK_SRC_FCK);
return r;
 }
 
 static void dsi_display_uninit_dispc(struct dsi_data *dsi)
 {
-   enum omap_channel channel = dsi->output.dispc_channel;
+   enum omap_channel dispc_channel = dsi->output.dispc_channel;
 
if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
dss_mgr_unregister_framedone_handler(>output,
dsi_framedone_irq_callback, dsi);
 
-   dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
+   dss_select_lcd_clk_source(dsi->dss, dispc_channel, DSS_CLK_SRC_FCK);
 }
 
 static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
@@ -4843,12 +4843,12 @@ static int dsi_set_config(struct omap_dss_device 
*dssdev,
 }
 
 /*
- * Return a hardcoded channel for the DSI output. This should work for
+ * Return a hardcoded dispc channel for the DSI output. This should work for
  * current use cases, but this can be later expanded to either resolve
  * the channel in some more dynamic manner, or get the channel as a user
  * parameter.
  */
-static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
+static enum omap_channel dsi_get_dispc_channel(struct dsi_data *dsi)
 {
switch (dsi->data->model) {
case DSI_MODEL_OMAP3:
@@ -5400,7 +5400,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->dispc_channel = dsi_get_dispc_channel(dsi);
out->dsi_ops = _ops;
out->of_port = 0;
out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE
-- 
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 v6 59/84] drm/omap: dsi: set trans_mode according to client mode_flags

2020-12-15 Thread Tomi Valkeinen
The DSI host driver currently ignores the video mode flags in
client->mode_flags. Add the code to take the transfer mode from client's
mode_flags.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index f5972f0bce0b..c5682b2e26eb 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5137,6 +5137,13 @@ static int omap_dsi_host_attach(struct mipi_dsi_host 
*host,
dsi->config.lp_clk_min = 700; // TODO: get from client?
dsi->config.lp_clk_max = client->lp_rate;
 
+   if (client->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
+   dsi->config.trans_mode = OMAP_DSS_DSI_BURST_MODE;
+   else if (client->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)
+   dsi->config.trans_mode = OMAP_DSS_DSI_PULSE_MODE;
+   else
+   dsi->config.trans_mode = OMAP_DSS_DSI_EVENT_MODE;
+
dsi->ulps_auto_idle = false;
 
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 v6 26/84] drm/omap: dsi: do bus locking in host driver

2020-12-15 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   | 44 +--
 drivers/gpu/drm/omapdrm/dss/dsi.c | 41 +++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 --
 3 files changed, 28 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index a79c95a040a8..efbca64355d6 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -295,7 +295,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);
-   struct omap_dss_device *src = ddata->src;
int r = 0;
int level;
 
@@ -310,14 +309,10 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
mutex_lock(>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(>lock);
@@ -343,21 +338,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(>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,
);
-
-   src->ops->dsi.bus_unlock(src);
} else {
r = -ENODEV;
}
@@ -374,20 +364,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(>lock);
 
if (ddata->enabled) {
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_wake_up(ddata);
if (!r)
r = dsicm_get_id(ddata, , , );
-
-   src->ops->dsi.bus_unlock(src);
} else {
r = -ENODEV;
}
@@ -405,7 +390,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;
 
@@ -416,14 +400,10 @@ static ssize_t dsicm_store_ulps(struct device *dev,
mutex_lock(>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(>lock);
@@ -453,7 +433,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;
 
@@ -466,9 +445,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(>lock);
@@ -669,17 +646,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(>lock);
 
-   src->ops->dsi.bus_lock(src);
-
r = dsicm_power_on(ddata);
-
-   src->ops->dsi.bus_unlock(src);
-
if (r)
goto err;
 
@@ -696,7 +667,6 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 static void dsicm_disable(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *src = ddata->src

[PATCH v6 50/84] drm/omap: squash omapdrm sub-modules into one

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 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|  24 +
 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|  20 +++-
 10 files changed, 155 insertions(+), 202 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 

[PATCH v6 18/84] drm/omap: dsi: drop unused get_te()

2020-12-15 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 870271fc0498..498efe3d7eb1 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -918,18 +918,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(>lock);
-   r = ddata->te_enabled;
-   mutex_unlock(>lock);
-
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -1001,7 +989,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 856110481e95..ad9e90b5a7ab 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 v6 23/84] drm/omap: dsi: lp/hs switching support for transfer()

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 6 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 9 +++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h   | 2 --
 3 files changed, 10 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 8534d0633e37..6a32a0402fa3 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) {
@@ -573,7 +573,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)
@@ -616,7 +616,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 bf7bee0b9334..501784137708 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;
@@ -2433,6 +2434,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)
@@ -4690,6 +4693,10 @@ 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 = >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:
@@ -4750,8 +4757,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 b02a75d55133..b020e8e57e0e 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 v6 35/84] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 72dce2fa8ced..95b0696436b0 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -214,7 +214,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);
@@ -234,7 +234,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);
@@ -254,8 +254,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[] = {
_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 v6 56/84] drm/panel: panel-dsi-cm: cleanup tear enable

2020-12-15 Thread Tomi Valkeinen
Simplify the code by moving code from _dsicm_enable_te() into
dsicm_power_on().

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 23 ---
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c 
b/drivers/gpu/drm/panel/panel-dsi-cm.c
index 5c28f08b2288..c2e702172df2 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -68,8 +68,6 @@ 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);
-
 static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable)
 {
struct backlight_device *backlight;
@@ -313,10 +311,13 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = _dsicm_enable_te(ddata, true);
+   r = mipi_dsi_dcs_set_tear_on(ddata->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
if (r)
goto err;
 
+   /* possible panel bug */
+   msleep(100);
+
ddata->enabled = true;
 
if (!ddata->intro_printed) {
@@ -417,22 +418,6 @@ static int dsicm_disable(struct drm_panel *panel)
return r;
 }
 
-static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
-{
-   struct mipi_dsi_device *dsi = ddata->dsi;
-   int r;
-
-   if (enable)
-   r = mipi_dsi_dcs_set_tear_on(dsi, 
MIPI_DSI_DCS_TEAR_MODE_VBLANK);
-   else
-   r = mipi_dsi_dcs_set_tear_off(dsi);
-
-   /* possible panel bug */
-   msleep(100);
-
-   return r;
-}
-
 static int dsicm_get_modes(struct drm_panel *panel,
   struct drm_connector *connector)
 {
-- 
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 v6 43/84] drm/omap: simplify omap_display_id

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 81e0972c07cc..259743cd14f0 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 v6 37/84] drm/omap: panel-dsi-cm: fix remove()

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 3e46aa6d5ead..21df1997e7d1 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -612,9 +612,6 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
if (ddata->extbldev)
put_device(>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 v6 32/84] drm/omap: dsi: convert to drm_panel

2020-12-15 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   | 203 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 128 +--
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |   1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   8 -
 4 files changed, 182 insertions(+), 158 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index da925d23b629..72dce2fa8ced 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 
@@ -19,11 +17,14 @@
 #include 
 
 #include 
+#include 
+#include 
+#include 
 
+#include 
 #include 
 #include 
-
-#include "../dss/omapdss.h"
+#include 
 
 #define DCS_READ_NUM_ERRORS0x05
 #define DCS_GET_ID10xda
@@ -34,11 +35,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;
 
@@ -66,7 +64,10 @@ struct panel_drv_data {
bool intro_printed;
 };
 
-#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);
 
@@ -281,7 +282,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;
 
@@ -318,10 +318,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) {
@@ -341,15 +337,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);
@@ -359,51 +352,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 = >vm,
-   .hs_clk_min = 15000,
-   .hs_clk_max = 3,
-   .lp_clk_min = 700,
-   .lp_clk_max = 1000,
-   };
 
r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
if (r)
dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
 
-   r = src->ops->dsi.set_config(src, _config);
-   if (r) {
-   dev_err(>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(>lock);
@@ -416,33 +383,39 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 
dsicm_bl_power(ddata, true);
 
-   return;
+   return 0;
 err:
-   dev_dbg(>dsi->dev, "enable failed

[PATCH v6 31/84] drm/omap: dsi: drop custom panel capability support

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 b72930dcbdf4..da925d23b629 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -593,9 +593,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 56cff14061ee..be95f93e9241 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4728,6 +4728,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 742f3d68daef..d95034611b67 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 dc0bc6f2aa06..0d1543537b92 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,
   );
@@ -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;
+

[PATCH v6 48/84] drm/omap: dsi: simplify pin config

2020-12-15 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 drops a pointless
conversion and means the pins can be configured earlier.

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

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index efa261e4a18a..aeea113e9bbc 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3570,12 +3570,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;
@@ -3588,9 +3585,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;
@@ -3602,15 +3596,15 @@ 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];
 
-   if (dx < 0 || dx >= dsi->num_lanes_supported * 2)
+   if (dx >= dsi->num_lanes_supported * 2)
return -EINVAL;
 
-   if (dy < 0 || dy >= dsi->num_lanes_supported * 2)
+   if (dy >= dsi->num_lanes_supported * 2)
return -EINVAL;
 
if (dx & 1) {
@@ -5477,9 +5471,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)
@@ -5507,11 +5500,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(>output, _cfg);
+   r = dsi_configure_pins(dsi, num_pins, lane_arr);
if (r) {
dev_err(dsi->dev, "failed to configure pins");
goto err;
@@ -5724,6 +5713,12 @@ static int dsi_probe(struct platform_device *pdev)
dsi->host.ops = _dsi_host_ops;
dsi->host.dev = >dev;
 
+   r = dsi_probe_of(dsi);
+   if (r) {
+   DSSERR("Invalid DSI DT data\n");
+   goto err_pm_disable;
+   }
+
r = mipi_dsi_host_register(>host);
if (r < 0) {
dev_err(>dev, "failed to register DSI host: %d\n", r);
@@ -5734,12 +5729,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(>dev, _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 76586934df37..22c7576882cc 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 v6 41/84] drm/omap: remove legacy DSS device operations

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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   | 56 
 5 files changed, 193 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 68c5d058b2e9..fb8b6a6dca1c 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(>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 0556711f57cd..6dd40d746b37 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1568,15 +1568,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 2345caf7721c..c74b3c6164f5 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 {
-   in

[PATCH v6 52/84] drm/omap: drop unused owner field

2020-12-15 Thread Tomi Valkeinen
dssdev->owner is set, but never used. We can drop the field.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Sebastian Reichel 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 1 -
 drivers/gpu/drm/omapdrm/dss/dsi.c | 1 -
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 1 -
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 --
 drivers/gpu/drm/omapdrm/dss/sdi.c | 1 -
 drivers/gpu/drm/omapdrm/dss/venc.c| 1 -
 7 files changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 1d2992daef40..030f997eccd0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -641,7 +641,6 @@ static int dpi_init_output_port(struct dpi_data *dpi, 
struct device_node *port)
out->type = OMAP_DISPLAY_TYPE_DPI;
out->dispc_channel = dpi_get_channel(dpi);
out->of_port = port_num;
-   out->owner = THIS_MODULE;
 
r = omapdss_device_init_output(out, >bridge);
if (r < 0) {
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index aeea113e9bbc..f5972f0bce0b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5439,7 +5439,6 @@ static int dsi_init_output(struct dsi_data *dsi)
out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
out->dispc_channel = dsi_get_channel(dsi);
out->dsi_ops = _ops;
-   out->owner = THIS_MODULE;
out->of_port = 0;
out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE
   | DRM_BUS_FLAG_DE_HIGH
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 8de41e74e8f8..35b750cebaeb 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -707,7 +707,6 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
out->type = OMAP_DISPLAY_TYPE_HDMI;
out->name = "hdmi.0";
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-   out->owner = THIS_MODULE;
out->of_port = 0;
 
r = omapdss_device_init_output(out, >bridge);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 54e5cb5aa52d..65085d886da5 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -681,7 +681,6 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
out->type = OMAP_DISPLAY_TYPE_HDMI;
out->name = "hdmi.0";
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-   out->owner = THIS_MODULE;
out->of_port = 0;
 
r = omapdss_device_init_output(out, >bridge);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 48e4a1fc70b6..17345cc5c638 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -263,8 +263,6 @@ struct omapdss_dsi_ops {
 struct omap_dss_device {
struct device *dev;
 
-   struct module *owner;
-
struct dss_device *dss;
struct drm_bridge *bridge;
struct drm_bridge *next_bridge;
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
b/drivers/gpu/drm/omapdrm/dss/sdi.c
index 033fd30074b0..35827b4487bd 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -314,7 +314,6 @@ static int sdi_init_output(struct sdi_device *sdi)
out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
/* We have SDI only on OMAP3, where it's on port 1 */
out->of_port = 1;
-   out->owner = THIS_MODULE;
out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE /* 15.5.9.1.2 */
   | DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c 
b/drivers/gpu/drm/omapdrm/dss/venc.c
index d92df480180e..e522c17955d0 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -733,7 +733,6 @@ static int venc_init_output(struct venc_device *venc)
out->type = OMAP_DISPLAY_TYPE_VENC;
out->name = "venc.0";
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-   out->owner = THIS_MODULE;
out->of_port = 0;
 
r = omapdss_device_init_output(out, >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 v6 29/84] drm/omap: dsi: move panel refresh function to host

2020-12-15 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 | 91 +--
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 13 +--
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 11 +--
 4 files changed, 88 insertions(+), 95 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index b4aa3bc98062..ccaf6ffe4f86 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -172,27 +172,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);
@@ -466,48 +445,6 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
mutex_unlock(>lock);
 }
 
-static void dsicm_framedone_cb(int err, void *data)
-{
-   struct panel_drv_data *ddata = data;
-
-   dev_dbg(>dsi->dev, "framedone, err %d\n", err);
-}
-
-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(>dsi->dev, "update %d, %d, %d x %d\n", x, y, w, h);
-
-   mutex_lock(>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;
-
-   mutex_unlock(>lock);
-
-   return 0;
-err:
-   mutex_unlock(>lock);
-   return r;
-}
-
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
struct mipi_dsi_device *dsi = ddata->dsi;
@@ -568,10 +505,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;
@@ -652,7 +585,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
dssdev = >dssdev;
dssdev->dev = dev;
dssdev->ops = _ops;
-   dssdev->driver = _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 c7f366ae4764..56cff14061ee 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
@@ -384,9 +387,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
@@ -3804,8 +3804,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");
 }
@@ -3837,6 +3835,8 @@ static void dsi_framedone_irq_callback(void *data)
 
cancel_delayed_work(>framedone_timeout_work);
 
+   DSSDBG("Framedone received!\n");
+
dsi_handle_fr

[PATCH v6 25/84] drm/omap: dsi: drop custom enable_te() API

2020-12-15 Thread Tomi Valkeinen
From: Sebastian Reichel 

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

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
---
 .../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 0520666a7a77..a79c95a040a8 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -768,7 +768,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;
 
@@ -777,8 +776,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 9f8e1fd89036..b326ad91c01c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4107,10 +4107,8 @@ static void dsi_display_disable(struct omap_dss_device 
*dssdev,
mutex_unlock(>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) {
@@ -4720,6 +4718,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 = >output;
+   int r;
 
if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode)
dsi_vc_enable_hs(dssdev, msg->channel,
@@ -4735,16 +4734,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)
@@ -4791,8 +4809,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 b020e8e57e0e..2525960aa869 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 v6 06/84] drm/omap: panel-dsi-cm: convert to transfer API

2020-12-15 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 
Acked-by: Laurent Pinchart 
---
 .../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 4119f0bfe111..6dc5a5f32e57 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 = _cmd,
+   .rx_len = 1,
+   .rx_buf = data
+   };
 
-   return 0;
+   return src->ops->dsi.transfer(src, );
 }
 
 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 = _cmd,
+   .tx_len = 1,
+   };
 
-   return src->ops->dsi.dcs_write(src, ddata->channel, _cmd, 1);
+   return src->ops->dsi.transfer(src, );
 }
 
 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 = ,
+   .tx_len = 2,
+   };
 
-   return src->ops->dsi.dcs_write(src, ddata->channel, buf, 2);
+   return src->ops->dsi.transfer(src, );
 }
 
 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 = ,
+   .tx_len = 1,
+   };
 
hw_guard_wait(ddata);
 
-   cmd = MIPI_DCS_ENTER_SLEEP_MODE;
-   r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, , 1);
+   r = src->ops->dsi.transfer(src, );
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));
+   r = src->ops->dsi.transfer(src, );
  

[PATCH v6 19/84] drm/omap: dsi: drop unused enable_te()

2020-12-15 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 498efe3d7eb1..c1afb71af01c 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -881,43 +881,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(>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(>lock);
-
-   return 0;
-err:
-   src->ops->dsi.bus_unlock(src);
-   mutex_unlock(>lock);
-
-   return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -987,8 +950,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 ad9e90b5a7ab..68b3ec4d2553 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 v6 15/84] drm/omap: panel-dsi-cm: drop hardcoded VC

2020-12-15 Thread Tomi Valkeinen
From: Sebastian Reichel 

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

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
---
 .../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 0a2f6c1234a9..4e5d4450c155 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(>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(>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(>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 v6 10/84] drm/omap: dsi: simplify read functions

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 e191ed80707d..7763dafb619f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2744,60 +2744,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)
 {
@@ -2906,13 +2852,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;
 
@@ -2920,47 +2871,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(, 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_syn

[PATCH v6 12/84] drm/omap: dsi: introduce mipi_dsi_host

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 121 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c |  53 ++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   4 -
 3 files changed, 102 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 704d0d3309ad..58e669d869b6 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, );
+   return dsi->host->ops->transfer(dsi->host, );
 }
 
 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, );
+   return dsi->host->ops->transfer(dsi->host, );
 }
 
 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, );
+   return dsi->host->ops->transfer(dsi->host, );
 }
 
 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, );
+   r = dsi->host->ops->transfer(dsi->host, );
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, );
+   r = dsi->host->ops->transfer(dsi->host, );
if (r)
return r;
 
-   r = src->ops->dsi.transfer(src, );
+   r = dsi->host->ops->transfer(dsi->host, );
if (r)
return r;
 
@@ -326,7 +325,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
return 0;
 
 err:
-   dev_err(>pdev->dev, "enter ULPS failed");
+   dev_err(>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_data *ddata)
 
r = _dsicm_enable_te(ddata, true);
if (r) {
-   dev_err(>

[PATCH v6 13/84] drm/omap: panel-dsi-cm: use DSI helpers

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 .../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 58e669d869b6..0a8efa447581 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 = _cmd,
-   .rx_len = 1,
-   .rx_buf = data
-   };
-
-   return dsi->host->ops->transfer(dsi->host, );
-}
-
-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 = _cmd,
-   .tx_len = 1,
-   };
-
-   return dsi->host->ops->transfer(dsi->host, );
+   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 = ,
-   .tx_len = 2,
-   };
-
-   return dsi->host->ops->transfer(dsi->host, );
+   return mipi_dsi_dcs_write(ddata->dsi, dcs_cmd, , 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 = ,
-   .tx_len = 1,
-   };
 
hw_guard_wait(ddata);
 
-   r = dsi->host->ops->transfer(dsi->host, );
+   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, );
-   if (r)
+   r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
+   if (r < 0)
return r;
 
-   r = dsi->host->ops->transfer(dsi->host, );
-   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);
if (r)
goto err;
 
-   r 

[PATCH v6 00/84] Convert DSI code to use drm_mipi_dsi and drm_panel

2020-12-15 Thread Tomi Valkeinen
Hi,

This is the sixth and hopefully last version of the OMAP DSI conversion
series. The previous version is here:

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

This version has only cosmetic changes and added reviewed-bys, and I'm
mainly sending this so that I'm able to dim apply it. because of that,
and the amount of patches in the series, I'm not cc'ing anyone in this
one to avoid needless spamming.

 Tomi

Sebastian Reichel (49):
  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 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 (35):
  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
  drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  drm/panel: panel-dsi-cm: cleanup tear enable
  ARM: dts: omap5: add address-cells & size-cells to dsi
  drm/omap: pll: fix iteration loop check
  drm/omap: dsi: set trans_mode according to client mode_flags
  drm/panel: panel-dsi-cm: set column & page at setup
  drm/omap: dsi: send nop instead of page & column
  drm/omap: dsi: simplify VC handling
  drm/omap: dsi: drop useless channel checks
  drm/omap: dsi: cleanup dispc channel usage
  drm/omap: dsi: rename 'channel' to 'vc'
  drm/omap: dsi: pass vc and channel to various functions
  drm/omap: dsi: untangle vc & channel
  drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode
  drm/omap: dsi: enable HS before sending the frame
  drm/omap: dsi: use separate VCs for cmd and video
  drm/panel: panel-dsi-cm: remove extra 'if'
  drm/panel: panel-dsi-cm: add panel database to driver
  drm/panel: panel-dsi-cm: drop unneeded includes
  drm/omap: dsi: move structs & defines to dsi.h
  drm/omap: dsi: move enable/disable to bridge enable/disable
  drm/omap: dsi: display_enable cleanup
  drm/omap: dsi: display_disable cleanup
  drm/omap: dsi: rename dsi_display_* functions
  drm/omap: dsi: cleanup initial vc setup
  drm/omap: dsi: split video mode enable/disable into separate func
  drm/omap: dsi: fix and cleanup ddr_clk_always_on
  drm/omap: dsi: remove ulps support
  drm/omap: dsi: fix DCS_CMD_ENABLE
  drm/omap: dsi: allow DSI commands to be sent early

 arch/arm/boot/dts/omap5.dtsi  |6 +
 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 

[PATCH v6 02/84] drm/omap: drop unused dsi.configure_pins

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 e39ce0c0c9a9..458cadb07d15 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, >pin_config);
-   if (r) {
-   dev_err(>pdev->dev,
-   "failed to configure DSI pins\n");
-   goto err_vddi;
-   }
-   }
-
r = src->ops->dsi.set_config(src, _config);
if (r) {
dev_err(>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 735a4e9027d0..2ba1287dda36 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4890,7 +4890,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 28c2cffc362e..6f068f881cb3 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 v6 05/84] drm/omap: dsi: add generic transfer function

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 91c8c1f29ae2..1e73fb175bfe 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4840,6 +4840,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)
+{
+   /*
+* TODO: no_sync can be used to optimize performance by sending e.g.
+* column and page information without syncing in between. It's not
+* absolutely 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)
 {
@@ -4894,6 +4946,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 c3d65da2e7cf..4e1988f05a27 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 v6 09/84] drm/omap: dsi: simplify write function

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 e11b258a2294..311039024595 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 84688e977a5c..e191ed80707d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2698,97 +2698,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(, 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 v6 14/84] drm/omap: dsi: request VC via mipi_dsi_attach

2020-12-15 Thread Tomi Valkeinen
From: Sebastian Reichel 

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

To use mipi_dsi_attach() we need to fill in the mipi_dsi_device fields,
and some of these fields overlap with the fields in omap_dss_dsi_config.
In later patches the latter will get dropped.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
---
 .../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 0a8efa447581..0a2f6c1234a9 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 = >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 = 2;
+   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(>dev.kobj, _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(>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 6a8579c69157..d960335574f3 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];
@@ -4689,32 +4689,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)
 {
@@ -4791,23 +4765,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(>dev));
+   return -EBUSY;
+   }
+
+   dsi->vc[channel].dest = client;
return 0;
 }

[PATCH v6 22/84] drm/omap: panel-dsi-cm: use bulk regulator API

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 .../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 1f4d67566e75..8534d0633e37 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;
 
@@ -556,28 +557,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(>dsi->dev,
-   "failed to enable VPNL: %d\n", r);
-   return r;
-   }
-   }
-
-   if (ddata->vddi) {
-   r = regulator_enable(ddata->vddi);
-   if (r) {
-   dev_err(>dsi->dev,
-   "failed to enable VDDI: %d\n", r);
-   goto err_vpnl;
-   }
+   r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
+   if (r) {
+   dev_err(>dsi->dev, "failed to enable supplies: %d\n", r);
+   return r;
}
 
r = src->ops->dsi.set_config(src, _config);
if (r) {
dev_err(>dsi->dev, "failed to configure DSI\n");
-   goto err_vddi;
+   goto err_regulators;
}
 
src->ops->enable(src);
@@ -636,12 +625,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(ARRAY_SIZE(ddata->supplies), 
ddata->supplies);
+   if (r)
+   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
 
return r;
 }
@@ -665,10 +652,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(ARRAY_SIZE(ddata->supplies), 
ddata->supplies);
+   if (r)
+   dev_err(>dsi->dev, "failed to disable supplies: %d\n", 
r);
 
ddata->enabled = false;
 }
@@ -972,21 +958,12 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
ddata->height_mm = 0;
of_property_read_u32(node, "height-mm", >height_mm);
 
-   ddata->vpnl = devm_regulator_get_optional(>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(>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(>dev, ARRAY_SIZE(ddata->supplies),
+ ddata->supplies);
+   if (err)
+   return err;
 
backlight = devm_of_find_backlight(>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 v6 11/84] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 88 ++-
 1 file changed, 39 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 7763dafb619f..70eb1f372633 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2601,8 +2601,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;
@@ -2611,20 +2611,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);
 
@@ -2633,10 +2633,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;
 
@@ -2658,65 +2658,63 @@ 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(, 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,
+   };
+
+   return dsi_vc_send_long(

[PATCH v6 03/84] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 .../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 458cadb07d15..4119f0bfe111 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 = >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 2ba1287dda36..2d7350f34628 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)
 {
@@ -3241,7 +3226,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 = >vm;
/*
 * Don't use line buffers if width is greater than the video
@@ -3372,7 +3357,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 = >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;
@@ -3500,7 +3485,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;
@@ -3621,7 +3606,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 = >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;
@@ -3728,7 +3713,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;
@@ -3739,16 +3724,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_DSS_DSI_FMT_RGB666:
+ 

[PATCH v6 16/84] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 4e5d4450c155..e4e86e70e333 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
@@ -334,7 +332,8 @@ static int dsicm_bl_update_status(struct backlight_device 
*dev)
 
r = dsicm_wake_up(ddata);
if (!r)
-   r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, level);
+   r = dsicm_dcs_write_1(
+   ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
 
src->ops->dsi.bus_unlock(src);
}
@@ -597,11 +596,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 v6 08/84] drm/omap: dsi: drop virtual channel logic

2020-12-15 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.

The change here is not strictly speaking correct, as it combines the VC
(DSI's "configuration block") and virtual channel ID (the ID sent in the
DSI packets). But as we currently only support a single DSI command mode
panel, this works fine: we always use VC0, and VC ID 0.

This needs more work to support video mode panels, but that can be done
after moving to DRM bridge and panel model, after which we can do that
work with the proper APIs.

Signed-off-by: Sebastian Reichel 
Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
---
 .../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 6dc5a5f32e57..704d0d3309ad 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 = >pdev->dev;
int r;
 
-   r = src->ops->dsi.request_vc(src, >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(>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 d2566992d065..84688e977a5c 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;
@@ -2581,7 +2580,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);
@@ -2685,7 +2684,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);
 
@@ -4787,45 +4786,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);

[PATCH v6 04/84] drm/omap: constify write buffers

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 2d7350f34628..91c8c1f29ae2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2603,11 +2603,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;
 
@@ -2700,7 +2700,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;
@@ -2731,7 +2731,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);
 
@@ -2740,7 +2740,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);
 
@@ -2749,7 +2749,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);
@@ -2778,15 +2778,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);
@@ -2812,7 +2812,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;
@@ -2985,7 +2985,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 a316b347785b..c3d65da2e7cf 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

[PATCH v6 21/84] drm/omap: dsi: use pixel-format and mode from attach

2020-12-15 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 f1e917afcbe4..1f4d67566e75 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -549,8 +549,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 = >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 d960335574f3..bf7bee0b9334 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4576,24 +4576,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(>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, );
+   if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
+   ok = dsi_vm_calc(dsi, , );
else
-   ok = dsi_cm_calc(dsi, config, );
+   ok = dsi_cm_calc(dsi, , );
 
if (!ok) {
DSSERR("failed to find suitable DSI clock settings\n");
@@ -4604,7 +4599,7 @@ static int dsi_set_config(struct omap_dss_device *dssdev,
dsi_pll_calc_dsi_fck(dsi, _cinfo);
 
r = dsi_lp_clock_calc(ctx.dsi_cinfo.clkout[HSDIV_DSI],
-   config->lp_clk_min, config->lp_clk_max, >user_lp_cinfo);
+   cfg.lp_clk_min, cfg.lp_clk_max, >user_lp_cinfo);
if (r) {
DSSERR("failed to find suitable DSI LP clock settings\n");
goto err;
@@ -4782,7 +4777,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 v6 07/84] drm/omap: dsi: unexport specific data transfer functions

2020-12-15 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 
Reviewed-by: Laurent Pinchart 
---
 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 1e73fb175bfe..d2566992d065 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4947,18 +4947,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 4e1988f05a27..88b73188203e 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 v6 24/84] drm/omap: dsi: move TE GPIO handling into core

2020-12-15 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   | 104 +
 drivers/gpu/drm/omapdrm/dss/dsi.c | 145 --
 2 files changed, 140 insertions(+), 109 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 6a32a0402fa3..0520666a7a77 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -11,7 +11,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -54,7 +53,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];
 
@@ -66,12 +64,6 @@ struct panel_drv_data {
/* runtime variables */
bool enabled;
 
-   bool te_enabled;
-
-   atomic_t do_update;
-
-   struct delayed_work te_timeout_work;
-
bool intro_printed;
 
struct workqueue_struct *workqueue;
@@ -83,8 +75,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 +230,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;
@@ -277,9 +264,6 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
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 +274,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
dev_err(>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);
 
@@ -600,7 +581,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
if (r)
goto err;
 
-   r = _dsicm_enable_te(ddata, ddata->te_enabled);
+   r = _dsicm_enable_te(ddata, true);
if (r)
goto err;
 
@@ -744,43 +725,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(>do_update, 1, 0);
-
-   if (old) {
-   cancel_delayed_work(>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(>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(>dsi->dev, "TE not received for 250ms!\n");
-
-   atomic_set(>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)
 {
@@ -808,16 +752,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(>te_timeout_work,
-   msecs_to_jiffies(250));
-   atomic_set(>do_update, 1);
-   } else {

[PATCH v6 01/84] Revert "drm/omap: dss: Remove unused omap_dss_device operations"

2020-12-15 Thread Tomi Valkeinen
From: Sebastian Reichel 

This reverts commit e086558ae923 ("drm/omap: dss: Remove unused
omap_dss_device operations")

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 
Reviewed-by: Laurent Pinchart 
---
 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 cf50430e6363..3d2aa9d4ab6b 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 a48a9a254e33..28c2cffc362e 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 57e92a4d5937..a2b08d32baad 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(, bus_flags);
 
-   /* Set timings for the dss manager. */
+   /* Set timings for all devices in the display pipeline. */
dss_mgr_set_timings(output, );
+
+   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

Re: [PATCH v5 29/29] drm/omap: dsi: allow DSI commands to be sent early

2020-12-15 Thread Tomi Valkeinen

Hi Sebastian,

On 14/12/2020 19:17, Sebastian Reichel wrote:

Hi,

On Tue, Dec 08, 2020 at 02:28:55PM +0200, Tomi Valkeinen wrote:

Panel drivers can send DSI commands in panel's prepare(), which happens
before the bridge's enable() is called. The OMAP DSI driver currently
only sets up the DSI interface at bridge's enable(), so prepare() cannot
be used to send DSI commands.

This patch fixes the issue by making it possible to enable the DSI
interface any time a command is about to be sent. Disabling the
interface is be done via delayed work.

Signed-off-by: Tomi Valkeinen 
---


Reviewed-by: Sebastian Reichel 

Would be nice to include the information why locking is ok from your
reply mails to the patch description. It was helpful for reviewing
the patch :)


Thanks for the reviews! I've made the changes you suggested.

I'll do some testing on top of the latest drm-misc-next, and send the whole series once more, so 
that I'm able to dim apply it.


I'm planning to push this to drm-misc-next tomorrow.

 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 v5 27/29] drm/omap: dsi: remove ulps support

2020-12-14 Thread Tomi Valkeinen
On 14/12/2020 19:39, Sebastian Reichel wrote:
> Hi,
> 
> On Tue, Dec 08, 2020 at 02:28:53PM +0200, Tomi Valkeinen wrote:
>> ULPS doesn't work, and I have been unable to get it to work. As ULPS
>> is a minor power-saving feature which requires substantial amount of
>> non-trivial code, and we have trouble just getting and
>> keeping DSI working at all, remove ULPS support.
>>
>> When the DSI driver works reliably for command and video mode displays,
>> someone interested can add it back.
>>
>> Signed-off-by: Tomi Valkeinen 
>> Reviewed-by: Laurent Pinchart 
>> ---
> 
> Is it really 'minor power-saving'? If I search for DSI and ULPS among
> the first results is a TI datasheet for SN65DSI84, which claims device
> active current in the more than 100mA range and ULPS current in the
> less than 10mA range.

I don't have any numbers, just my guesses. For videomode displays or command 
mode displays in active
use, I don't think ULPS matters much. The link is mostly not in ULPS. And if 
the display is blanked,
things are off, so again not in ULPS.

It's only for command mode displays, when updated rarely, where I think ULPS 
matters. Which, of
course, is probably not unusual use case if you have a cmdmode display. But 
whether OMAP DSI power
savings matches SN65DSI84, I have no clue.

> Considering all known omapdrm DSI users are battery powered devices
> caring for saving as much power as possible, it might be good to just
> keep this until it is being fixed considering this is very close to
> the end of the series anyways?

I don't like to leave known to be broken code around, unless someone has plans 
to work on it. I
wouldn't be surprised to see ULPS still broken two years from now =). It should 
be trivial to add
the relevant bits back later.

But I can leave it here if you think it's better, presuming it doesn't have 
bigger conflicts with
the 29/29 or break anything. However, I have only a few days left in TI, which 
is why I'm rushing
here a bit (*). If I hit problems, I either have to drop the whole series, or 
push it in its current
form.

 Tomi

(*) But I will fix possible issues caused by my push, of course.

-- 
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


<    2   3   4   5   6   7   8   9   10   11   >