Re: [PATCH v4 2/2] drm: panel: Add tianma nt36672a panel driver

2020-08-14 Thread Sumit Semwal
Hello Sam,

Thanks very much for the review.
On Fri, 14 Aug 2020 at 01:16, Sam Ravnborg  wrote:
>
> Hi Sumit.
>
> On Tue, Aug 11, 2020 at 11:51:07PM +0530, Sumit Semwal wrote:
> > Some Poco F1 phones have an LCD panel from Tianma, model nt36672a,
> > with a resolution of 1080x2246 that operates in DSI video mode.
> >
> > Add the drm panel driver for it.
> >
> > During testing, Benni Steini  helped us fix
> > the reset sequence timing (from 10ms to 20ms), to get the bootanimation
> > to work on Android.
> >
> > With current AOSP, we need to increase it to 200ms - this seems to be a
> > safe high value to avoid a white screen occasionally.
> >
> > Signed-off-by: Sumit Semwal 
> > Cc: Benni Steini 
>
> Checkpatch is not happy with this patch.
> Please fix relevant warnings.
>
> My checkpatch options:
> -q --emacs --strict --show-types
>
> A lot of details in the following.
> Sorry for not catching these before.
>
> Sam
>
> >
> > ---
> > v2: increase reset sequence timing to a safe 200ms
> > v4: Since "0425662fdf05: drm: Nuke mode->vrefresh", we have to calculate
> > vrefresh on demand. Update for it.
> > ---
> >  MAINTAINERS   |   7 +
> >  drivers/gpu/drm/panel/Kconfig |  11 +
> >  drivers/gpu/drm/panel/Makefile|   1 +
> >  drivers/gpu/drm/panel/panel-tianma-nt36672a.c | 858 ++
> >  4 files changed, 877 insertions(+)
> >  create mode 100644 drivers/gpu/drm/panel/panel-tianma-nt36672a.c
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index f77df02e4121..9e4bc8da9b2d 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -5611,6 +5611,13 @@ T: git git://anongit.freedesktop.org/drm/drm-misc
> >  F:   Documentation/devicetree/bindings/display/ste,mcde.txt
> >  F:   drivers/gpu/drm/mcde/
> >
> > +DRM DRIVER FOR TIANMA NT36672A PANELS
> > +M:   Sumit Semwal 
> > +S:   Maintained
> > +T:   git git://anongit.freedesktop.org/drm/drm-misc
> > +F:   
> > Documentation/devicetree/bindings/display/panel/tianma,nt36672a-panel.yaml
> > +F:   drivers/gpu/drm/panel/panel-tianma-nt36672a.c
> > +
> >  DRM DRIVER FOR TDFX VIDEO CARDS
> >  S:   Orphan / Obsolete
> >  F:   drivers/gpu/drm/tdfx/
> > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> > index de2f2a452be5..8108a682dcb0 100644
> > --- a/drivers/gpu/drm/panel/Kconfig
> > +++ b/drivers/gpu/drm/panel/Kconfig
> > @@ -437,6 +437,17 @@ config DRM_PANEL_TPO_TD043MTEA1
> > Say Y here if you want to enable support for TPO TD043MTEA1 800x480
> > 4.3" panel (found on the OMAP3 Pandora board).
> >
> > +config DRM_PANEL_TIANMA_FHD_NT36672A
> > + tristate "TIANMA NT36672A panel"
> > + depends on OF
> > + depends on DRM_MIPI_DSI
> > + depends on BACKLIGHT_CLASS_DEVICE
> > + help
> > +   Say Y here if you want to enable support for the Tianma NT36672A
> > +   panel. It is seen mostly in Xiaomi Poco F1 mobile phone.
> > +   The panel has a 1080x2246 resolution and uses 24 bit RGB per pixel.
> > +   It provides a MIPI DSI interface to the host.
> > +
> >  config DRM_PANEL_TPO_TPG110
> >   tristate "TPO TPG 800x400 panel"
> >   depends on OF && SPI && GPIOLIB
> > diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> > index e45ceac6286f..472ae9ba8788 100644
> > --- a/drivers/gpu/drm/panel/Makefile
> > +++ b/drivers/gpu/drm/panel/Makefile
> > @@ -44,6 +44,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += 
> > panel-sitronix-st7703.o
> >  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
> >  obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
> >  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
> > +obj-$(CONFIG_DRM_PANEL_TIANMA_FHD_NT36672A) += panel-tianma-nt36672a.o
> >  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
> >  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
> >  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
> > diff --git a/drivers/gpu/drm/panel/panel-tianma-nt36672a.c 
> > b/drivers/gpu/drm/panel/panel-tianma-nt36672a.c
> > new file mode 100644
> > index ..2941975e039c
> > --- /dev/null
> > +++ b/drivers/gpu/drm/panel/panel-tianma-nt36672a.c
> > @@ -0,0 +1,858 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright (C) 2020 Linaro Ltd
> > + * Author: Sumit Semwal 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +struct panel_cmd {
> > + size_t len;
> > + const char *data;
> > +};
> > +
> > +#define _INIT_CMD(...) { \
> > + .len = sizeof((char[]){__VA_ARGS__}), \
> > + .data = (char[]){__VA_ARGS__} }
> > +
> > +static const char * const regulator_names[] = {
> > + "vddio",
> > + "vddpos",
> > + "vddneg",
> > +};
> > 

Re: [PATCH v4 2/2] drm: panel: Add tianma nt36672a panel driver

2020-08-13 Thread Sam Ravnborg
Hi Sumit.

On Tue, Aug 11, 2020 at 11:51:07PM +0530, Sumit Semwal wrote:
> Some Poco F1 phones have an LCD panel from Tianma, model nt36672a,
> with a resolution of 1080x2246 that operates in DSI video mode.
> 
> Add the drm panel driver for it.
> 
> During testing, Benni Steini  helped us fix
> the reset sequence timing (from 10ms to 20ms), to get the bootanimation
> to work on Android.
> 
> With current AOSP, we need to increase it to 200ms - this seems to be a
> safe high value to avoid a white screen occasionally.
> 
> Signed-off-by: Sumit Semwal 
> Cc: Benni Steini 

Checkpatch is not happy with this patch.
Please fix relevant warnings.

My checkpatch options:
-q --emacs --strict --show-types

A lot of details in the following.
Sorry for not catching these before.

Sam

> 
> ---
> v2: increase reset sequence timing to a safe 200ms
> v4: Since "0425662fdf05: drm: Nuke mode->vrefresh", we have to calculate
> vrefresh on demand. Update for it.
> ---
>  MAINTAINERS   |   7 +
>  drivers/gpu/drm/panel/Kconfig |  11 +
>  drivers/gpu/drm/panel/Makefile|   1 +
>  drivers/gpu/drm/panel/panel-tianma-nt36672a.c | 858 ++
>  4 files changed, 877 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-tianma-nt36672a.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f77df02e4121..9e4bc8da9b2d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5611,6 +5611,13 @@ T: git git://anongit.freedesktop.org/drm/drm-misc
>  F:   Documentation/devicetree/bindings/display/ste,mcde.txt
>  F:   drivers/gpu/drm/mcde/
>  
> +DRM DRIVER FOR TIANMA NT36672A PANELS
> +M:   Sumit Semwal 
> +S:   Maintained
> +T:   git git://anongit.freedesktop.org/drm/drm-misc
> +F:   
> Documentation/devicetree/bindings/display/panel/tianma,nt36672a-panel.yaml
> +F:   drivers/gpu/drm/panel/panel-tianma-nt36672a.c
> +
>  DRM DRIVER FOR TDFX VIDEO CARDS
>  S:   Orphan / Obsolete
>  F:   drivers/gpu/drm/tdfx/
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index de2f2a452be5..8108a682dcb0 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -437,6 +437,17 @@ config DRM_PANEL_TPO_TD043MTEA1
> Say Y here if you want to enable support for TPO TD043MTEA1 800x480
> 4.3" panel (found on the OMAP3 Pandora board).
>  
> +config DRM_PANEL_TIANMA_FHD_NT36672A
> + tristate "TIANMA NT36672A panel"
> + depends on OF
> + depends on DRM_MIPI_DSI
> + depends on BACKLIGHT_CLASS_DEVICE
> + help
> +   Say Y here if you want to enable support for the Tianma NT36672A
> +   panel. It is seen mostly in Xiaomi Poco F1 mobile phone.
> +   The panel has a 1080x2246 resolution and uses 24 bit RGB per pixel.
> +   It provides a MIPI DSI interface to the host.
> +
>  config DRM_PANEL_TPO_TPG110
>   tristate "TPO TPG 800x400 panel"
>   depends on OF && SPI && GPIOLIB
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index e45ceac6286f..472ae9ba8788 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -44,6 +44,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += 
> panel-sitronix-st7703.o
>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
> +obj-$(CONFIG_DRM_PANEL_TIANMA_FHD_NT36672A) += panel-tianma-nt36672a.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
> diff --git a/drivers/gpu/drm/panel/panel-tianma-nt36672a.c 
> b/drivers/gpu/drm/panel/panel-tianma-nt36672a.c
> new file mode 100644
> index ..2941975e039c
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-tianma-nt36672a.c
> @@ -0,0 +1,858 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2020 Linaro Ltd
> + * Author: Sumit Semwal 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +struct panel_cmd {
> + size_t len;
> + const char *data;
> +};
> +
> +#define _INIT_CMD(...) { \
> + .len = sizeof((char[]){__VA_ARGS__}), \
> + .data = (char[]){__VA_ARGS__} }
> +
> +static const char * const regulator_names[] = {
> + "vddio",
> + "vddpos",
> + "vddneg",
> +};
> +
> +static unsigned long const regulator_enable_loads[] = {
> + 62000,
> + 10,
> + 10
> +};
> +
> +static unsigned long const regulator_disable_loads[] = {
> + 80,
> + 100,
> + 100
> +};
> +
> +struct panel_desc {
> + const struct drm_display_mode *display_mode;
> + const char *panel_name;
> +
> + unsigned int width_mm;

[PATCH v4 2/2] drm: panel: Add tianma nt36672a panel driver

2020-08-11 Thread Sumit Semwal
Some Poco F1 phones have an LCD panel from Tianma, model nt36672a,
with a resolution of 1080x2246 that operates in DSI video mode.

Add the drm panel driver for it.

During testing, Benni Steini  helped us fix
the reset sequence timing (from 10ms to 20ms), to get the bootanimation
to work on Android.

With current AOSP, we need to increase it to 200ms - this seems to be a
safe high value to avoid a white screen occasionally.

Signed-off-by: Sumit Semwal 
Cc: Benni Steini 

---
v2: increase reset sequence timing to a safe 200ms
v4: Since "0425662fdf05: drm: Nuke mode->vrefresh", we have to calculate
vrefresh on demand. Update for it.
---
 MAINTAINERS   |   7 +
 drivers/gpu/drm/panel/Kconfig |  11 +
 drivers/gpu/drm/panel/Makefile|   1 +
 drivers/gpu/drm/panel/panel-tianma-nt36672a.c | 858 ++
 4 files changed, 877 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-tianma-nt36672a.c

diff --git a/MAINTAINERS b/MAINTAINERS
index f77df02e4121..9e4bc8da9b2d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5611,6 +5611,13 @@ T:   git git://anongit.freedesktop.org/drm/drm-misc
 F: Documentation/devicetree/bindings/display/ste,mcde.txt
 F: drivers/gpu/drm/mcde/
 
+DRM DRIVER FOR TIANMA NT36672A PANELS
+M: Sumit Semwal 
+S: Maintained
+T: git git://anongit.freedesktop.org/drm/drm-misc
+F: 
Documentation/devicetree/bindings/display/panel/tianma,nt36672a-panel.yaml
+F: drivers/gpu/drm/panel/panel-tianma-nt36672a.c
+
 DRM DRIVER FOR TDFX VIDEO CARDS
 S: Orphan / Obsolete
 F: drivers/gpu/drm/tdfx/
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index de2f2a452be5..8108a682dcb0 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -437,6 +437,17 @@ config DRM_PANEL_TPO_TD043MTEA1
  Say Y here if you want to enable support for TPO TD043MTEA1 800x480
  4.3" panel (found on the OMAP3 Pandora board).
 
+config DRM_PANEL_TIANMA_FHD_NT36672A
+   tristate "TIANMA NT36672A panel"
+   depends on OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ Say Y here if you want to enable support for the Tianma NT36672A
+ panel. It is seen mostly in Xiaomi Poco F1 mobile phone.
+ The panel has a 1080x2246 resolution and uses 24 bit RGB per pixel.
+ It provides a MIPI DSI interface to the host.
+
 config DRM_PANEL_TPO_TPG110
tristate "TPO TPG 800x400 panel"
depends on OF && SPI && GPIOLIB
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index e45ceac6286f..472ae9ba8788 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += 
panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
+obj-$(CONFIG_DRM_PANEL_TIANMA_FHD_NT36672A) += panel-tianma-nt36672a.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
diff --git a/drivers/gpu/drm/panel/panel-tianma-nt36672a.c 
b/drivers/gpu/drm/panel/panel-tianma-nt36672a.c
new file mode 100644
index ..2941975e039c
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-tianma-nt36672a.c
@@ -0,0 +1,858 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Linaro Ltd
+ * Author: Sumit Semwal 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct panel_cmd {
+   size_t len;
+   const char *data;
+};
+
+#define _INIT_CMD(...) { \
+   .len = sizeof((char[]){__VA_ARGS__}), \
+   .data = (char[]){__VA_ARGS__} }
+
+static const char * const regulator_names[] = {
+   "vddio",
+   "vddpos",
+   "vddneg",
+};
+
+static unsigned long const regulator_enable_loads[] = {
+   62000,
+   10,
+   10
+};
+
+static unsigned long const regulator_disable_loads[] = {
+   80,
+   100,
+   100
+};
+
+struct panel_desc {
+   const struct drm_display_mode *display_mode;
+   const char *panel_name;
+
+   unsigned int width_mm;
+   unsigned int height_mm;
+
+   unsigned long mode_flags;
+   enum mipi_dsi_pixel_format format;
+   unsigned int lanes;
+
+   const struct panel_cmd *on_cmds_1;
+   const struct panel_cmd *on_cmds_2;
+
+   const struct panel_cmd *off_cmds;
+};
+
+struct panel_info {
+   struct drm_panel base;
+   struct mipi_dsi_device *link;
+   const struct panel_desc *desc;
+
+   struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];
+
+   struct