Add support for Tianma nt36672a video mode panel
Subsystems (4)
v4 cover Add support for Tianma nt36672a video mode panel
Some Poco F1 phones from Xiaomi have an nt36672a video mode panel; add support for the same.
Most of the panel data is taken from downstream panel dts, and is converted to drm-panel based driver by me.
It has been validated with v5.8-rc5 on Poco F1 phone; my tree with other dependent patches is here [1]
[1]: https://git.linaro.org/people/sumit.semwal/linux-dev.git/log/?h=dev/poco-panel-upstreaming
---
v2: In dt-binding, removed ports node, making port@0 directly under panel@0 node.
Also updated the panel_on delay to a safer 200ms as needed for latest Android.
v3: Replaced port@0 with just port in panel@0 node.
v4: Since "0425662fdf05: drm: Nuke mode->vrefresh", we have to calculate
vrefresh on demand. Update for it.
Sumit Semwal (2):
dt-bindings: display: panel: Add bindings for Tianma nt36672a panel
drm: panel: Add tianma nt36672a panel driver
.../display/panel/tianma,nt36672a.yaml | 95 ++ MAINTAINERS | 7 + drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-tianma-nt36672a.c | 858 ++++++++++++++++++ 5 files changed, 972 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/tianma,nt36672a.yaml create mode 100644 drivers/gpu/drm/panel/panel-tianma-nt36672a.c
Signature · 6 lines
2.28.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 1/2 dt-bindings: display: panel: Add bindings for Tianma nt36672a panel
The nt36672a panel from Tianma is a FHD+ panel with a resolution of 1080x2246 and 6.18 inches size. It is found in some of the Poco F1 phones.
---
v2: remove ports node, making port@0 directly under panel@0 node.
v3: updated to replace port@0 to just 'port'.
--- .../display/panel/tianma,nt36672a.yaml | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/tianma,nt36672a.yaml
Documentation/devicetree/bindings/display/panel/tianma,nt36672a.yaml new file +95 -0
@@ -0,0 +1,95 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/tianma,nt36672a.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Tianma model NT36672A DSI Panel display driver + +maintainers: + - Sumit Semwal <[email protected]> + +description: | + The nt36672a panel from Tianma is a FHD+ LCD display panel with a resolution + of 1080x2246. It is a video mode DSI panel. + +allOf: + - $ref: panel-common.yaml# + +properties: + compatible: + const: tianma,nt36672a + + reg: + description: DSI virtual channel of the peripheral + + reset-gpios: + description: phandle of gpio for reset line - This should be 8mA, gpio + can be configured using mux, pinctrl, pinctrl-names (active high) + + vddio-supply: + description: phandle of the regulator that provides the supply voltage + Power IC supply + + vddpos-supply: + description: phandle of the positive boost supply regulator + + vddneg-supply: + description: phandle of the negative boost supply regulator + + pinctrl-names: + description: Pinctrl for panel active and suspend + + pinctrl-0: + description: Active pinctrls + + pinctrl-1: + description: Suspend pinctrls + + port: true + +required: + - compatible + - reg + - vddi0-supply + - vddpos-supply + - vddneg-supply + - reset-gpios + - pinctrl-names + - pinctrl-0 + - pinctrl-1 + - port + +unevaluatedProperties: false + +examples: + - |+ + #include <dt-bindings/gpio/gpio.h> + dsi0 { + #address-cells = <1>; + #size-cells = <0>; + + panel@0 { + compatible = "tianma,nt36672a"; + reg = <0>; + vddi0-supply = <&vreg_l14a_1p88>; + vddpos-supply = <&lab>; + vddneg-supply = <&ibb>; + + reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>; + + pinctrl-names = "panel_active", "panel_suspend"; + pinctrl-0 = <&sde_dsi_active>; + pinctrl-1 = <&sde_dsi_suspend>; + + #address-cells = <1>; + #size-cells = <0>; + port { + tianma_nt36672a_in_0: endpoint { + remote-endpoint = <&dsi0_out>; + }; + }; + }; + }; + +...
Signature · 6 lines
2.28.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 2/2 drm: panel: Add tianma nt36672a panel driver
In reply to Sumit SemwalSome 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 <[email protected]> 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.
---
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
MAINTAINERS +7 -0
@@ -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 <[email protected]> +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/
drivers/gpu/drm/panel/Kconfig +11 -0
@@ -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
drivers/gpu/drm/panel/Makefile +1 -0
@@ -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
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +858 -0
858 lines not on this page · raw message
Signature · 6 lines
2.28.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v4 2/2] drm: panel: Add tianma nt36672a panel driver
Hi Sumit.
Quoted 9 lines · 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 <[email protected]> helped us fix the reset sequence timing (from 10ms to 20ms), to get the bootanimation to work on Android.
Quoted 5 lines
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 <[email protected]>Cc Benni Steini <[email protected]>
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
Quoted 146 lines
---
v2: increase reset sequence timing to a safe 200ms
v4: Since "0425662fdf05: drm: Nukemode->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.cMAINTAINERS +7
-0@@ -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 <[email protected]> +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/drivers/gpu/drm/panel/Kconfig +11
-0@@ -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 && GPIOLIBdrivers/gpu/drm/panel/Makefile +1
-0@@ -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.odrivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +75
-0@@ -0,0 +1,858 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2020 Linaro Ltd +* Author: Sumit Semwal <[email protected]> +*/ + +#include <linux/delay.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> + +#include <linux/gpio/consumer.h> +#include <linux/pinctrl/consumer.h> +#include <linux/regulator/consumer.h> + +#include <drm/drm_device.h> +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> +#include <drm/drm_print.h> + +#include <video/mipi_display.h> + +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 , +100000 , +100000 +}; + +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)]; +
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 85
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+struct gpio_desc *reset_gpio; + +struct pinctrl *pinctrl; +struct pinctrl_state *active; +struct pinctrl_state *suspend; + + +bool prepared; +bool enabled; +};
Unless this driver is supposed to handle multiple panels connected to the same driver IC then there is no need for a panel_info.
If this driver is supposed to handle multiple panels connected to the same driver IC the binding should be updated.
A general compatible for the driver IC and a specific one for the panel.
Quoted 35 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +35
-0+ +static inline struct panel_info *to_panel_info (struct drm_panel *panel) +{ + return container_of(panel, struct panel_info, base); +} + +static int send_mipi_cmds (struct drm_panel *panel,const struct panel_cmd *cmds) +{ +struct panel_info *pinfo =to_panel_info (panel); +unsigned int i =0 ; +int err; + +if (!cmds) +return -EFAULT ; + +for (i =0 ; cmds[i].len !=0 ; i++) { +const struct panel_cmd *cmd = &cmds[i]; + +if (cmd->len ==2 ) + err =mipi_dsi_dcs_write (pinfo->link, + cmd->data[1 ],NULL ,0 ); +else + err =mipi_dsi_dcs_write (pinfo->link, + cmd->data[1 ], cmd->data +2 , + cmd->len -2 ); + +if (err <0 ) +return err; + + } + +return 0 ; +} + +static int panel_set_pinctrl_state (struct panel_info *panel,bool enable)
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 130
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+{ +int rc =0 ; +struct pinctrl_state *state; + +if (enable) + state = panel->active; +else + state = panel->suspend; + + rc =pinctrl_select_state (panel->pinctrl, state);
What is the purpose of this function?
No other panel drivers uses pinctrl_select_state() so I womder why this driver need it.
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 133
Quoted 3 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +3
-0+if (rc) +pr_err ("[%s] failed to set pin state, rc=%d\n" , panel->desc->panel_name, + rc);
100 char line length is OK, so put rc on the same line here.
Here pr_err() is used - later DRM_DEV_ERROR() is used. It would be nice to be consistent.
Quoted 176 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +176
-0+return rc; +} + +static int tianma_panel_disable (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); + + pinfo->enabled = false; + +return 0 ; +} + +static int tianma_panel_power_off (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int i, ret =0 ; + +gpiod_set_value (pinfo->reset_gpio,0 ); + + ret =panel_set_pinctrl_state (pinfo, false); +if (ret) { +pr_err ("[%s] failed to set pinctrl, rc=%d\n" , pinfo->desc->panel_name, ret); +return ret; + } + +for (i =0 ; i <ARRAY_SIZE (pinfo->supplies); i++) { + ret =regulator_set_load (pinfo->supplies[i].consumer, + regulator_disable_loads[i]); +if (ret) { +DRM_DEV_ERROR (panel->dev, +"regulator_set_load failed %d\n" , ret); +return ret; + } + } + + ret =regulator_bulk_disable (ARRAY_SIZE (pinfo->supplies), pinfo->supplies); +if (ret) { +DRM_DEV_ERROR (panel->dev, +"regulator_bulk_disable failed %d\n" , ret); + } +return ret; +} + +static int tianma_panel_unprepare (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int ret; + +if (!pinfo->prepared) +return 0 ; + +/* send off cmds */ + ret =send_mipi_cmds (panel, pinfo->desc->off_cmds); + +if (ret <0 ) { +DRM_DEV_ERROR (panel->dev, +"failed to send DCS off cmds: %d\n" , ret); + } + + ret =mipi_dsi_dcs_set_display_off (pinfo->link); +if (ret <0 ) { +DRM_DEV_ERROR (panel->dev, +"set_display_off cmd failed ret = %d\n" , + ret); + } + +/* 120ms delay required here as per DCS spec */ +msleep (120 ); + + ret =mipi_dsi_dcs_enter_sleep_mode (pinfo->link); +if (ret <0 ) { +DRM_DEV_ERROR (panel->dev, +"enter_sleep cmd failed ret = %d\n" , ret); + } +/* 0x3C = 60ms delay */ +msleep (60 ); + + ret =tianma_panel_power_off (panel); +if (ret <0 ) +DRM_DEV_ERROR (panel->dev,"power_off failed ret = %d\n" , ret); + + pinfo->prepared = false; + +return ret; + +} + +static int tianma_panel_power_on (struct panel_info *pinfo) +{ +int ret, i; + +for (i =0 ; i <ARRAY_SIZE (pinfo->supplies); i++) { + ret =regulator_set_load (pinfo->supplies[i].consumer, + regulator_enable_loads[i]); +if (ret) +return ret; + } + + ret =regulator_bulk_enable (ARRAY_SIZE (pinfo->supplies), pinfo->supplies); +if (ret <0 ) +return ret; + + ret =panel_set_pinctrl_state (pinfo, true); +if (ret) { +pr_err ("[%s] failed to set pinctrl, rc=%d\n" , pinfo->desc->panel_name, ret); +return ret; + } + +/* +* As per downstream kernel, Reset sequence of Tianma nt36672a panel requires the panel to +* be out of reset for 10ms, followed by being held in reset for 10ms. But for Android +* AOSP, we needed to bump it upto 200ms otherwise we get white screen sometimes. +* FIXME: Try to reduce this 200ms to a lesser value. +*/ +gpiod_set_value (pinfo->reset_gpio,0 ); +msleep (200 ); +gpiod_set_value (pinfo->reset_gpio,1 ); +msleep (200 ); + +return 0 ; +} + +static int tianma_panel_prepare (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int err; + +if (pinfo->prepared) +return 0 ; + + err =tianma_panel_power_on (pinfo); +if (err <0 ) + goto poweroff; + +/* send first part of init cmds */ + err =send_mipi_cmds (panel, pinfo->desc->on_cmds_1); + +if (err <0 ) { +DRM_DEV_ERROR (panel->dev, +"failed to send DCS Init 1st Code: %d\n" , err); + goto poweroff; + } + + err =mipi_dsi_dcs_set_display_on (pinfo->link); +if (err <0 ) { +DRM_DEV_ERROR (panel->dev, +"failed to Set Display ON: %d\n" , err); + goto poweroff; + } + + err =mipi_dsi_dcs_exit_sleep_mode (pinfo->link); +if (err <0 ) { +DRM_DEV_ERROR (panel->dev,"failed to exit sleep mode: %d\n" , + err); + goto poweroff; + } +/* 0x46 = 70 ms delay */ +msleep (70 ); + +/* Send rest of the init cmds */ + err =send_mipi_cmds (panel, pinfo->desc->on_cmds_2); + +if (err <0 ) { +DRM_DEV_ERROR (panel->dev, +"failed to send DCS Init 2nd Code: %d\n" , err); + goto poweroff; + } + +msleep (120 ); + + pinfo->prepared = true; + +return 0 ; + +poweroff: +gpiod_set_value (pinfo->reset_gpio,1 );
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 319
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+return err; +} + + +static int tianma_panel_enable (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); + +if (pinfo->enabled) +return 0 ;
->enabled is only used to avoid assignment to ->enabled. Looks like code that can be dropped.
Quoted 415 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +415
-0+ + pinfo->enabled = true; + +return 0 ; +} + +static int tianma_panel_get_modes (struct drm_panel *panel, +struct drm_connector *connector) +{ +struct panel_info *pinfo =to_panel_info (panel); +const struct drm_display_mode *m = pinfo->desc->display_mode; +struct drm_display_mode *mode; + + mode =drm_mode_duplicate (connector->dev, m); +if (!mode) { +DRM_DEV_ERROR (panel->dev,"failed to add mode %ux%u@%u\n" , + m->hdisplay, m->vdisplay,drm_mode_vrefresh (m)); +return -ENOMEM ; + } + + connector->display_info.width_mm = pinfo->desc->width_mm; + connector->display_info.height_mm = pinfo->desc->height_mm; + +drm_mode_set_name (mode); +drm_mode_probed_add (connector, mode); + +return 1 ; +} + +static const struct drm_panel_funcs panel_funcs = { + .disable = tianma_panel_disable, + .unprepare = tianma_panel_unprepare, + .prepare = tianma_panel_prepare, + .enable = tianma_panel_enable, + .get_modes = tianma_panel_get_modes, +}; + +static const struct panel_cmd tianma_nt36672a_on_cmds_1[] = { +/* skin enhancement mode */ +_INIT_CMD (0x00 ,0xFF ,0x22 ), +_INIT_CMD (0x00 ,0x00 ,0x40 ), +_INIT_CMD (0x00 ,0x01 ,0xC0 ), +_INIT_CMD (0x00 ,0x02 ,0x40 ), +_INIT_CMD (0x00 ,0x03 ,0x40 ), +_INIT_CMD (0x00 ,0x04 ,0x40 ), +_INIT_CMD (0x00 ,0x05 ,0x40 ), +_INIT_CMD (0x00 ,0x06 ,0x40 ), +_INIT_CMD (0x00 ,0x07 ,0x40 ), +_INIT_CMD (0x00 ,0x08 ,0x40 ), +_INIT_CMD (0x00 ,0x09 ,0x40 ), +_INIT_CMD (0x00 ,0x0A ,0x40 ), +_INIT_CMD (0x00 ,0x0B ,0x40 ), +_INIT_CMD (0x00 ,0x0C ,0x40 ), +_INIT_CMD (0x00 ,0x0D ,0x40 ), +_INIT_CMD (0x00 ,0x0E ,0x40 ), +_INIT_CMD (0x00 ,0x0F ,0x40 ), +_INIT_CMD (0x00 ,0x10 ,0x40 ), +_INIT_CMD (0x00 ,0x11 ,0x50 ), +_INIT_CMD (0x00 ,0x12 ,0x60 ), +_INIT_CMD (0x00 ,0x13 ,0x70 ), +_INIT_CMD (0x00 ,0x14 ,0x58 ), +_INIT_CMD (0x00 ,0x15 ,0x68 ), +_INIT_CMD (0x00 ,0x16 ,0x78 ), +_INIT_CMD (0x00 ,0x17 ,0x77 ), +_INIT_CMD (0x00 ,0x18 ,0x39 ), +_INIT_CMD (0x00 ,0x19 ,0x2D ), +_INIT_CMD (0x00 ,0x1A ,0x2E ), +_INIT_CMD (0x00 ,0x1B ,0x32 ), +_INIT_CMD (0x00 ,0x1C ,0x37 ), +_INIT_CMD (0x00 ,0x1D ,0x3A ), +_INIT_CMD (0x00 ,0x1E ,0x40 ), +_INIT_CMD (0x00 ,0x1F ,0x40 ), +_INIT_CMD (0x00 ,0x20 ,0x40 ), +_INIT_CMD (0x00 ,0x21 ,0x40 ), +_INIT_CMD (0x00 ,0x22 ,0x40 ), +_INIT_CMD (0x00 ,0x23 ,0x40 ), +_INIT_CMD (0x00 ,0x24 ,0x40 ), +_INIT_CMD (0x00 ,0x25 ,0x40 ), +_INIT_CMD (0x00 ,0x26 ,0x40 ), +_INIT_CMD (0x00 ,0x27 ,0x40 ), +_INIT_CMD (0x00 ,0x28 ,0x40 ), +_INIT_CMD (0x00 ,0x2D ,0x00 ), +_INIT_CMD (0x00 ,0x2F ,0x40 ), +_INIT_CMD (0x00 ,0x30 ,0x40 ), +_INIT_CMD (0x00 ,0x31 ,0x40 ), +_INIT_CMD (0x00 ,0x32 ,0x40 ), +_INIT_CMD (0x00 ,0x33 ,0x40 ), +_INIT_CMD (0x00 ,0x34 ,0x40 ), +_INIT_CMD (0x00 ,0x35 ,0x40 ), +_INIT_CMD (0x00 ,0x36 ,0x40 ), +_INIT_CMD (0x00 ,0x37 ,0x40 ), +_INIT_CMD (0x00 ,0x38 ,0x40 ), +_INIT_CMD (0x00 ,0x39 ,0x40 ), +_INIT_CMD (0x00 ,0x3A ,0x40 ), +_INIT_CMD (0x00 ,0x3B ,0x40 ), +_INIT_CMD (0x00 ,0x3D ,0x40 ), +_INIT_CMD (0x00 ,0x3F ,0x40 ), +_INIT_CMD (0x00 ,0x40 ,0x40 ), +_INIT_CMD (0x00 ,0x41 ,0x40 ), +_INIT_CMD (0x00 ,0x42 ,0x40 ), +_INIT_CMD (0x00 ,0x43 ,0x40 ), +_INIT_CMD (0x00 ,0x44 ,0x40 ), +_INIT_CMD (0x00 ,0x45 ,0x40 ), +_INIT_CMD (0x00 ,0x46 ,0x40 ), +_INIT_CMD (0x00 ,0x47 ,0x40 ), +_INIT_CMD (0x00 ,0x48 ,0x40 ), +_INIT_CMD (0x00 ,0x49 ,0x40 ), +_INIT_CMD (0x00 ,0x4A ,0x40 ), +_INIT_CMD (0x00 ,0x4B ,0x40 ), +_INIT_CMD (0x00 ,0x4C ,0x40 ), +_INIT_CMD (0x00 ,0x4D ,0x40 ), +_INIT_CMD (0x00 ,0x4E ,0x40 ), +_INIT_CMD (0x00 ,0x4F ,0x40 ), +_INIT_CMD (0x00 ,0x50 ,0x40 ), +_INIT_CMD (0x00 ,0x51 ,0x40 ), +_INIT_CMD (0x00 ,0x52 ,0x40 ), +_INIT_CMD (0x00 ,0x53 ,0x01 ), +_INIT_CMD (0x00 ,0x54 ,0x01 ), +_INIT_CMD (0x00 ,0x55 ,0xFE ), +_INIT_CMD (0x00 ,0x56 ,0x77 ), +_INIT_CMD (0x00 ,0x58 ,0xCD ), +_INIT_CMD (0x00 ,0x59 ,0xD0 ), +_INIT_CMD (0x00 ,0x5A ,0xD0 ), +_INIT_CMD (0x00 ,0x5B ,0x50 ), +_INIT_CMD (0x00 ,0x5C ,0x50 ), +_INIT_CMD (0x00 ,0x5D ,0x50 ), +_INIT_CMD (0x00 ,0x5E ,0x50 ), +_INIT_CMD (0x00 ,0x5F ,0x50 ), +_INIT_CMD (0x00 ,0x60 ,0x50 ), +_INIT_CMD (0x00 ,0x61 ,0x50 ), +_INIT_CMD (0x00 ,0x62 ,0x50 ), +_INIT_CMD (0x00 ,0x63 ,0x50 ), +_INIT_CMD (0x00 ,0x64 ,0x50 ), +_INIT_CMD (0x00 ,0x65 ,0x50 ), +_INIT_CMD (0x00 ,0x66 ,0x50 ), +_INIT_CMD (0x00 ,0x67 ,0x50 ), +_INIT_CMD (0x00 ,0x68 ,0x50 ), +_INIT_CMD (0x00 ,0x69 ,0x50 ), +_INIT_CMD (0x00 ,0x6A ,0x50 ), +_INIT_CMD (0x00 ,0x6B ,0x50 ), +_INIT_CMD (0x00 ,0x6C ,0x50 ), +_INIT_CMD (0x00 ,0x6D ,0x50 ), +_INIT_CMD (0x00 ,0x6E ,0x50 ), +_INIT_CMD (0x00 ,0x6F ,0x50 ), +_INIT_CMD (0x00 ,0x70 ,0x07 ), +_INIT_CMD (0x00 ,0x71 ,0x00 ), +_INIT_CMD (0x00 ,0x72 ,0x00 ), +_INIT_CMD (0x00 ,0x73 ,0x00 ), +_INIT_CMD (0x00 ,0x74 ,0x06 ), +_INIT_CMD (0x00 ,0x75 ,0x0C ), +_INIT_CMD (0x00 ,0x76 ,0x03 ), +_INIT_CMD (0x00 ,0x77 ,0x09 ), +_INIT_CMD (0x00 ,0x78 ,0x0F ), +_INIT_CMD (0x00 ,0x79 ,0x68 ), +_INIT_CMD (0x00 ,0x7A ,0x88 ), +_INIT_CMD (0x00 ,0x7C ,0x80 ), +_INIT_CMD (0x00 ,0x7D ,0x80 ), +_INIT_CMD (0x00 ,0x7E ,0x80 ), +_INIT_CMD (0x00 ,0x7F ,0x00 ), +_INIT_CMD (0x00 ,0x80 ,0x00 ), +_INIT_CMD (0x00 ,0x81 ,0x00 ), +_INIT_CMD (0x00 ,0x83 ,0x01 ), +_INIT_CMD (0x00 ,0x84 ,0x00 ), +_INIT_CMD (0x00 ,0x85 ,0x80 ), +_INIT_CMD (0x00 ,0x86 ,0x80 ), +_INIT_CMD (0x00 ,0x87 ,0x80 ), +_INIT_CMD (0x00 ,0x88 ,0x40 ), +_INIT_CMD (0x00 ,0x89 ,0x91 ), +_INIT_CMD (0x00 ,0x8A ,0x98 ), +_INIT_CMD (0x00 ,0x8B ,0x80 ), +_INIT_CMD (0x00 ,0x8C ,0x80 ), +_INIT_CMD (0x00 ,0x8D ,0x80 ), +_INIT_CMD (0x00 ,0x8E ,0x80 ), +_INIT_CMD (0x00 ,0x8F ,0x80 ), +_INIT_CMD (0x00 ,0x90 ,0x80 ), +_INIT_CMD (0x00 ,0x91 ,0x80 ), +_INIT_CMD (0x00 ,0x92 ,0x80 ), +_INIT_CMD (0x00 ,0x93 ,0x80 ), +_INIT_CMD (0x00 ,0x94 ,0x80 ), +_INIT_CMD (0x00 ,0x95 ,0x80 ), +_INIT_CMD (0x00 ,0x96 ,0x80 ), +_INIT_CMD (0x00 ,0x97 ,0x80 ), +_INIT_CMD (0x00 ,0x98 ,0x80 ), +_INIT_CMD (0x00 ,0x99 ,0x80 ), +_INIT_CMD (0x00 ,0x9A ,0x80 ), +_INIT_CMD (0x00 ,0x9B ,0x80 ), +_INIT_CMD (0x00 ,0x9C ,0x80 ), +_INIT_CMD (0x00 ,0x9D ,0x80 ), +_INIT_CMD (0x00 ,0x9E ,0x80 ), +_INIT_CMD (0x00 ,0x9F ,0x80 ), +_INIT_CMD (0x00 ,0xA0 ,0x8A ), +_INIT_CMD (0x00 ,0xA2 ,0x80 ), +_INIT_CMD (0x00 ,0xA6 ,0x80 ), +_INIT_CMD (0x00 ,0xA7 ,0x80 ), +_INIT_CMD (0x00 ,0xA9 ,0x80 ), +_INIT_CMD (0x00 ,0xAA ,0x80 ), +_INIT_CMD (0x00 ,0xAB ,0x80 ), +_INIT_CMD (0x00 ,0xAC ,0x80 ), +_INIT_CMD (0x00 ,0xAD ,0x80 ), +_INIT_CMD (0x00 ,0xAE ,0x80 ), +_INIT_CMD (0x00 ,0xAF ,0x80 ), +_INIT_CMD (0x00 ,0xB7 ,0x76 ), +_INIT_CMD (0x00 ,0xB8 ,0x76 ), +_INIT_CMD (0x00 ,0xB9 ,0x05 ), +_INIT_CMD (0x00 ,0xBA ,0x0D ), +_INIT_CMD (0x00 ,0xBB ,0x14 ), +_INIT_CMD (0x00 ,0xBC ,0x0F ), +_INIT_CMD (0x00 ,0xBD ,0x18 ), +_INIT_CMD (0x00 ,0xBE ,0x1F ), +_INIT_CMD (0x00 ,0xBF ,0x05 ), +_INIT_CMD (0x00 ,0xC0 ,0x0D ), +_INIT_CMD (0x00 ,0xC1 ,0x14 ), +_INIT_CMD (0x00 ,0xC2 ,0x03 ), +_INIT_CMD (0x00 ,0xC3 ,0x07 ), +_INIT_CMD (0x00 ,0xC4 ,0x0A ), +_INIT_CMD (0x00 ,0xC5 ,0xA0 ), +_INIT_CMD (0x00 ,0xC6 ,0x55 ), +_INIT_CMD (0x00 ,0xC7 ,0xFF ), +_INIT_CMD (0x00 ,0xC8 ,0x39 ), +_INIT_CMD (0x00 ,0xC9 ,0x44 ), +_INIT_CMD (0x00 ,0xCA ,0x12 ), +_INIT_CMD (0x00 ,0xCD ,0x80 ), +_INIT_CMD (0x00 ,0xDB ,0x80 ), +_INIT_CMD (0x00 ,0xDC ,0x80 ), +_INIT_CMD (0x00 ,0xDD ,0x80 ), +_INIT_CMD (0x00 ,0xE0 ,0x80 ), +_INIT_CMD (0x00 ,0xE1 ,0x80 ), +_INIT_CMD (0x00 ,0xE2 ,0x80 ), +_INIT_CMD (0x00 ,0xE3 ,0x80 ), +_INIT_CMD (0x00 ,0xE4 ,0x80 ), +_INIT_CMD (0x00 ,0xE5 ,0x40 ), +_INIT_CMD (0x00 ,0xE6 ,0x40 ), +_INIT_CMD (0x00 ,0xE7 ,0x40 ), +_INIT_CMD (0x00 ,0xE8 ,0x40 ), +_INIT_CMD (0x00 ,0xE9 ,0x40 ), +_INIT_CMD (0x00 ,0xEA ,0x40 ), +_INIT_CMD (0x00 ,0xEB ,0x40 ), +_INIT_CMD (0x00 ,0xEC ,0x40 ), +_INIT_CMD (0x00 ,0xED ,0x40 ), +_INIT_CMD (0x00 ,0xEE ,0x40 ), +_INIT_CMD (0x00 ,0xEF ,0x40 ), +_INIT_CMD (0x00 ,0xF0 ,0x40 ), +_INIT_CMD (0x00 ,0xF1 ,0x40 ), +_INIT_CMD (0x00 ,0xF2 ,0x40 ), +_INIT_CMD (0x00 ,0xF3 ,0x40 ), +_INIT_CMD (0x00 ,0xF4 ,0x40 ), +_INIT_CMD (0x00 ,0xF5 ,0x40 ), +_INIT_CMD (0x00 ,0xF6 ,0x40 ), +_INIT_CMD (0x00 ,0xFB ,0x1 ), +_INIT_CMD (0x00 ,0xFF ,0x23 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +/* dimming enable */ +_INIT_CMD (0x00 ,0x01 ,0x84 ), +_INIT_CMD (0x00 ,0x05 ,0x2D ), +_INIT_CMD (0x00 ,0x06 ,0x00 ), +/* resolution 1080*2246 */ +_INIT_CMD (0x00 ,0x11 ,0x01 ), +_INIT_CMD (0x00 ,0x12 ,0x7B ), +_INIT_CMD (0x00 ,0x15 ,0x6F ), +_INIT_CMD (0x00 ,0x16 ,0x0B ), +/* UI mode */ +_INIT_CMD (0x00 ,0x29 ,0x0A ), +_INIT_CMD (0x00 ,0x30 ,0xFF ), +_INIT_CMD (0x00 ,0x31 ,0xFF ), +_INIT_CMD (0x00 ,0x32 ,0xFF ), +_INIT_CMD (0x00 ,0x33 ,0xFF ), +_INIT_CMD (0x00 ,0x34 ,0xFF ), +_INIT_CMD (0x00 ,0x35 ,0xFF ), +_INIT_CMD (0x00 ,0x36 ,0xFF ), +_INIT_CMD (0x00 ,0x37 ,0xFF ), +_INIT_CMD (0x00 ,0x38 ,0xFC ), +_INIT_CMD (0x00 ,0x39 ,0xF8 ), +_INIT_CMD (0x00 ,0x3A ,0xF4 ), +_INIT_CMD (0x00 ,0x3B ,0xF1 ), +_INIT_CMD (0x00 ,0x3D ,0xEE ), +_INIT_CMD (0x00 ,0x3F ,0xEB ), +_INIT_CMD (0x00 ,0x40 ,0xE8 ), +_INIT_CMD (0x00 ,0x41 ,0xE5 ), +/* STILL mode */ +_INIT_CMD (0x00 ,0x2A ,0x13 ), +_INIT_CMD (0x00 ,0x45 ,0xFF ), +_INIT_CMD (0x00 ,0x46 ,0xFF ), +_INIT_CMD (0x00 ,0x47 ,0xFF ), +_INIT_CMD (0x00 ,0x48 ,0xFF ), +_INIT_CMD (0x00 ,0x49 ,0xFF ), +_INIT_CMD (0x00 ,0x4A ,0xFF ), +_INIT_CMD (0x00 ,0x4B ,0xFF ), +_INIT_CMD (0x00 ,0x4C ,0xFF ), +_INIT_CMD (0x00 ,0x4D ,0xED ), +_INIT_CMD (0x00 ,0x4E ,0xD5 ), +_INIT_CMD (0x00 ,0x4F ,0xBF ), +_INIT_CMD (0x00 ,0x50 ,0xA6 ), +_INIT_CMD (0x00 ,0x51 ,0x96 ), +_INIT_CMD (0x00 ,0x52 ,0x86 ), +_INIT_CMD (0x00 ,0x53 ,0x76 ), +_INIT_CMD (0x00 ,0x54 ,0x66 ), +/* MOVING mode */ +_INIT_CMD (0x00 ,0x2B ,0x0E ), +_INIT_CMD (0x00 ,0x58 ,0xFF ), +_INIT_CMD (0x00 ,0x59 ,0xFF ), +_INIT_CMD (0x00 ,0x5A ,0xFF ), +_INIT_CMD (0x00 ,0x5B ,0xFF ), +_INIT_CMD (0x00 ,0x5C ,0xFF ), +_INIT_CMD (0x00 ,0x5D ,0xFF ), +_INIT_CMD (0x00 ,0x5E ,0xFF ), +_INIT_CMD (0x00 ,0x5F ,0xFF ), +_INIT_CMD (0x00 ,0x60 ,0xF6 ), +_INIT_CMD (0x00 ,0x61 ,0xEA ), +_INIT_CMD (0x00 ,0x62 ,0xE1 ), +_INIT_CMD (0x00 ,0x63 ,0xD8 ), +_INIT_CMD (0x00 ,0x64 ,0xCE ), +_INIT_CMD (0x00 ,0x65 ,0xC3 ), +_INIT_CMD (0x00 ,0x66 ,0xBA ), +_INIT_CMD (0x00 ,0x67 ,0xB3 ), +_INIT_CMD (0x00 ,0xFF ,0x25 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0x05 ,0x04 ), +_INIT_CMD (0x00 ,0xFF ,0x26 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0x1C ,0xAF ), +_INIT_CMD (0x00 ,0xFF ,0x10 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0x51 ,0xFF ), +_INIT_CMD (0x00 ,0x53 ,0x24 ), +_INIT_CMD (0x00 ,0x55 ,0x00 ), + + {}, +}; + +static const struct panel_cmd tianma_nt36672a_on_cmds_2[] = { +_INIT_CMD (0x00 ,0xFF ,0x24 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0xC3 ,0x01 ), +_INIT_CMD (0x00 ,0xC4 ,0x54 ), +_INIT_CMD (0x00 ,0xFF ,0x10 ), + + {}, +}; + +static const struct panel_cmd tianma_nt36672a_off_cmds[] = { +_INIT_CMD (0x00 ,0xFF ,0x24 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0xC3 ,0x01 ), +_INIT_CMD (0x00 ,0xFF ,0x10 ), + + {}, +}; + +static const struct drm_display_mode tianma_panel_default_mode = { + .clock =161331 , + + .hdisplay =1080 , + .hsync_start =1080 +40 , + .hsync_end =1080 +40 +20 , + .htotal =1080 +40 +20 +44 , + + .vdisplay =2246 , + .vsync_start =2246 +15 , + .vsync_end =2246 +15 +2 , + .vtotal =2246 +15 +2 +8 , + + .type =DRM_MODE_TYPE_DRIVER |DRM_MODE_TYPE_PREFERRED , +}; + +static const struct panel_desc tianma_panel_desc = { + .display_mode = &tianma_panel_default_mode, + + .width_mm =68 , + .height_mm =136 , + + .mode_flags =MIPI_DSI_MODE_LPM |MIPI_DSI_MODE_VIDEO + |MIPI_DSI_MODE_VIDEO_HSE + |MIPI_DSI_CLOCK_NON_CONTINUOUS + |MIPI_DSI_MODE_VIDEO_BURST , + .format =MIPI_DSI_FMT_RGB888 , + .lanes =4 , + .on_cmds_1 = tianma_nt36672a_on_cmds_1, + .on_cmds_2 = tianma_nt36672a_on_cmds_2, + .off_cmds = tianma_nt36672a_off_cmds +}; + + +static const struct of_device_id panel_of_match[] = { + { .compatible ="tianma,nt36672a" , + .data = &tianma_panel_desc + }, + { +/* sentinel */ + } +}; +MODULE_DEVICE_TABLE (of, panel_of_match); + + +static int panel_pinctrl_init (struct panel_info *panel) +{ +struct device *dev = &panel->link->dev; +int rc =0 ; + + panel->pinctrl =devm_pinctrl_get (dev); +if (IS_ERR_OR_NULL (panel->pinctrl)) { + rc =PTR_ERR (panel->pinctrl); +pr_err ("failed to get pinctrl, rc=%d\n" , rc); + goto error; + } + + panel->active =pinctrl_lookup_state (panel->pinctrl, +"panel_active" ); +if (IS_ERR_OR_NULL (panel->active)) { + rc =PTR_ERR (panel->active); +pr_err ("failed to get pinctrl active state, rc=%d\n" , rc); + goto error; + } + + panel->suspend = +pinctrl_lookup_state (panel->pinctrl,"panel_suspend" );
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 744
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+ +if (IS_ERR_OR_NULL (panel->suspend)) { + rc =PTR_ERR (panel->suspend); +pr_err ("failed to get pinctrl suspend state, rc=%d\n" , rc); + goto error; + } + +error: +return rc; +}
I thought the core would handle pin-trl for us?
Have I missed something?
Quoted 19 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +19
-0+ +static int panel_add (struct panel_info *pinfo) +{ +struct device *dev = &pinfo->link->dev; +int i, ret; + +for (i =0 ; i <ARRAY_SIZE (pinfo->supplies); i++) + pinfo->supplies[i].supply = regulator_names[i]; + + ret =devm_regulator_bulk_get (dev,ARRAY_SIZE (pinfo->supplies), + pinfo->supplies); +if (ret <0 ) +return ret; + + pinfo->reset_gpio =devm_gpiod_get (dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (pinfo->reset_gpio)) { +DRM_DEV_ERROR (dev,"cannot get reset gpio %ld\n" , +PTR_ERR (pinfo->reset_gpio)); +return PTR_ERR (pinfo->reset_gpio);
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 773
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+ } + + ret =panel_pinctrl_init (pinfo); +if (ret <0 ) +return ret; + +drm_panel_init (&pinfo->base, dev, &panel_funcs, +DRM_MODE_CONNECTOR_DSI ); + + ret =drm_panel_add (&pinfo->base);
drm_panel_add() now returns void - use latest drm-misc-next to catch such issues.
Quoted 26 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +26
-0+if (ret <0 ) +return ret; +return 0 ; +} + +static void panel_del (struct panel_info *pinfo) +{ +if (pinfo->base.dev) +drm_panel_remove (&pinfo->base); +} + +static int panel_probe (struct mipi_dsi_device *dsi) +{ +struct panel_info *pinfo; +const struct panel_desc *desc; +int err; + + pinfo =devm_kzalloc (&dsi->dev,sizeof (*pinfo),GFP_KERNEL ); +if (!pinfo) +return -ENOMEM ; + + desc =of_device_get_match_data (&dsi->dev); + dsi->mode_flags = desc->mode_flags; + dsi->format = desc->format; + dsi->lanes = desc->lanes; + pinfo->desc = desc;
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 809
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+ pinfo->link = dsi; + +mipi_dsi_set_drvdata (dsi, pinfo); + + err =panel_add (pinfo); +if (err <0 ) +return err; + + err =mipi_dsi_attach (dsi); +return err;
Or return mipi_dsi_attach(dsi);
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 817
Quoted 8 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +8
-0+} + +static int panel_remove (struct mipi_dsi_device *dsi) +{ +struct panel_info *pinfo =mipi_dsi_get_drvdata (dsi); +int err; + + err =tianma_panel_unprepare (&pinfo->base);
Use drm_panel_unprepare() here - you may need functionality from drm_panel.
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 822
Quoted 5 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +5
-0+if (err <0 ) +DRM_DEV_ERROR (&dsi->dev,"failed to unprepare panel: %d\n" , + err); + + err =tianma_panel_disable (&pinfo->base);
USe drm_panel_disable() here.
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 832
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+if (err <0 ) +DRM_DEV_ERROR (&dsi->dev,"failed to disable panel: %d\n" , err); + + err =mipi_dsi_detach (dsi); +if (err <0 ) +DRM_DEV_ERROR (&dsi->dev,"failed to detach from DSI host: %d\n" , + err); + +drm_panel_detach (&pinfo->base); +panel_del (pinfo);
Call drm_panel_remove() here - no reason for a helper.
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 841
Quoted 9 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +9
-0+ +return 0 ; +} + +static void panel_shutdown (struct mipi_dsi_device *dsi) +{ +struct panel_info *pinfo =mipi_dsi_get_drvdata (dsi); + +tianma_panel_disable (&pinfo->base);
drm_panel_disable()
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 842
Quoted 1 line
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +1
-0+tianma_panel_unprepare (&pinfo->base);
drm_panel_unprepare()
Quoted 23 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +16
-0+} + +static struct mipi_dsi_driver panel_driver = { + .driver = { + .name ="panel-tianma-nt36672a" , + .of_match_table = panel_of_match, + }, + .probe = panel_probe, + .remove = panel_remove, + .shutdown = panel_shutdown, +}; +module_mipi_dsi_driver (panel_driver); + +MODULE_AUTHOR ("Sumit Semwal <[email protected]>" ); +MODULE_DESCRIPTION ("TIANMA NT36672A MIPI-DSI LCD panel" ); +MODULE_LICENSE ("GPL" );Signature · 6 lines
2.28.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v4 2/2] drm: panel: Add tianma nt36672a panel driver
Hello Sam,
Thanks very much for the review.
Quoted 189 lines · Sam Ravnborg
Hi Sumit.
Quoted 9 lines · 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 <[email protected]> helped us fix the reset sequence timing (from 10ms to 20ms), to get the bootanimation to work on Android.
Quoted 5 lines
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 <[email protected]>Cc Benni Steini <[email protected]>Checkpatch is not happy with this patch.
Please fix relevant warnings.My checkpatch options:
-q --emacs --strict --show-typesA lot of details in the following.
Sorry for not catching these before.Sam
Quoted 146 lines
---
v2: increase reset sequence timing to a safe 200ms
v4: Since "0425662fdf05: drm: Nukemode->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.cMAINTAINERS +7
-0@@ -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 <[email protected]> +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/drivers/gpu/drm/panel/Kconfig +11
-0@@ -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 && GPIOLIBdrivers/gpu/drm/panel/Makefile +1
-0@@ -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.odrivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +75
-0@@ -0,0 +1,858 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2020 Linaro Ltd +* Author: Sumit Semwal <[email protected]> +*/ + +#include <linux/delay.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> + +#include <linux/gpio/consumer.h> +#include <linux/pinctrl/consumer.h> +#include <linux/regulator/consumer.h> + +#include <drm/drm_device.h> +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> +#include <drm/drm_print.h> + +#include <video/mipi_display.h> + +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 , +100000 , +100000 +}; + +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)]; +drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 85
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+struct gpio_desc *reset_gpio; + +struct pinctrl *pinctrl; +struct pinctrl_state *active; +struct pinctrl_state *suspend; + + +bool prepared; +bool enabled; +};Unless this driver is supposed to handle multiple panels connected to the same driver IC then there is no need for a
panel_info.
Quoted 3 lines
If this driver is supposed to handle multiple panels connected to the same driver IC the binding should be updated.
A general compatible for the driver IC and a specific one for the panel.
I had not realised it, but after reading your comment here, I investigated, and it looks like this is a generic IC driver for novatek nt36672a, which is used with different panels in many downstream products. I will update this.
Sorry, the driver has come about without any TRMs or documentation, only by adapting downstream drivers to drm_panel base one, so I didn't have a lot of information about the panel or IC itself.
Quoted 41 lines
Quoted 41 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +40
-0+ +static inline struct panel_info *to_panel_info (struct drm_panel *panel) +{ + return container_of(panel, struct panel_info, base); +} + +static int send_mipi_cmds (struct drm_panel *panel,const struct panel_cmd *cmds) +{ +struct panel_info *pinfo =to_panel_info (panel); +unsigned int i =0 ; +int err; + +if (!cmds) +return -EFAULT ; + +for (i =0 ; cmds[i].len !=0 ; i++) { +const struct panel_cmd *cmd = &cmds[i]; + +if (cmd->len ==2 ) + err =mipi_dsi_dcs_write (pinfo->link, + cmd->data[1 ],NULL ,0 ); +else + err =mipi_dsi_dcs_write (pinfo->link, + cmd->data[1 ], cmd->data +2 , + cmd->len -2 ); + +if (err <0 ) +return err; + + } + +return 0 ; +} + +static int panel_set_pinctrl_state (struct panel_info *panel,bool enable) +{ +int rc =0 ; +struct pinctrl_state *state; + +if (enable)
Quoted 8 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 130
Quoted 5 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +5
-0+ state = panel->active; + else + state = panel->suspend; + + rc =pinctrl_select_state (panel->pinctrl, state);What is the purpose of this function?
No other panel drivers usespinctrl_select_state()so I womder why this driver need it.
Last I had checked, we needed to do this, otherwise there were some issues with the suspend-resume path. I will investigate further, but not having a serial console makes it a bit harder to check these kind of issues.
Quoted 8 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 133
Quoted 4 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +3
-0+if (rc) +pr_err ("[%s] failed to set pin state, rc=%d\n" , panel->desc->panel_name, + rc);100 char line length is OK, so put rc on the same line here.
Here
pr_err()is used - laterDRM_DEV_ERROR()is used. It would be nice to be consistent.
Agreed on the consistency; and all the pr_err usage is in pinctrl parts, so if we are able to remove it, this will go automatically.
Quoted 182 lines
Quoted 182 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +180
-0+return rc; +} + +static int tianma_panel_disable (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); + + pinfo->enabled = false; + +return 0 ; +} + +static int tianma_panel_power_off (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int i, ret =0 ; + +gpiod_set_value (pinfo->reset_gpio,0 ); + + ret =panel_set_pinctrl_state (pinfo, false); +if (ret) { +pr_err ("[%s] failed to set pinctrl, rc=%d\n" , pinfo->desc->panel_name, ret); +return ret; + } + +for (i =0 ; i <ARRAY_SIZE (pinfo->supplies); i++) { + ret =regulator_set_load (pinfo->supplies[i].consumer, + regulator_disable_loads[i]); +if (ret) { +DRM_DEV_ERROR (panel->dev, +"regulator_set_load failed %d\n" , ret); +return ret; + } + } + + ret =regulator_bulk_disable (ARRAY_SIZE (pinfo->supplies), pinfo->supplies); +if (ret) { +DRM_DEV_ERROR (panel->dev, +"regulator_bulk_disable failed %d\n" , ret); + } +return ret; +} + +static int tianma_panel_unprepare (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int ret; + +if (!pinfo->prepared) +return 0 ; + +/* send off cmds */ + ret =send_mipi_cmds (panel, pinfo->desc->off_cmds); + +if (ret <0 ) { +DRM_DEV_ERROR (panel->dev, +"failed to send DCS off cmds: %d\n" , ret); + } + + ret =mipi_dsi_dcs_set_display_off (pinfo->link); +if (ret <0 ) { +DRM_DEV_ERROR (panel->dev, +"set_display_off cmd failed ret = %d\n" , + ret); + } + +/* 120ms delay required here as per DCS spec */ +msleep (120 ); + + ret =mipi_dsi_dcs_enter_sleep_mode (pinfo->link); +if (ret <0 ) { +DRM_DEV_ERROR (panel->dev, +"enter_sleep cmd failed ret = %d\n" , ret); + } +/* 0x3C = 60ms delay */ +msleep (60 ); + + ret =tianma_panel_power_off (panel); +if (ret <0 ) +DRM_DEV_ERROR (panel->dev,"power_off failed ret = %d\n" , ret); + + pinfo->prepared = false; + +return ret; + +} + +static int tianma_panel_power_on (struct panel_info *pinfo) +{ +int ret, i; + +for (i =0 ; i <ARRAY_SIZE (pinfo->supplies); i++) { + ret =regulator_set_load (pinfo->supplies[i].consumer, + regulator_enable_loads[i]); +if (ret) +return ret; + } + + ret =regulator_bulk_enable (ARRAY_SIZE (pinfo->supplies), pinfo->supplies); +if (ret <0 ) +return ret; + + ret =panel_set_pinctrl_state (pinfo, true); +if (ret) { +pr_err ("[%s] failed to set pinctrl, rc=%d\n" , pinfo->desc->panel_name, ret); +return ret; + } + +/* +* As per downstream kernel, Reset sequence of Tianma nt36672a panel requires the panel to +* be out of reset for 10ms, followed by being held in reset for 10ms. But for Android +* AOSP, we needed to bump it upto 200ms otherwise we get white screen sometimes. +* FIXME: Try to reduce this 200ms to a lesser value. +*/ +gpiod_set_value (pinfo->reset_gpio,0 ); +msleep (200 ); +gpiod_set_value (pinfo->reset_gpio,1 ); +msleep (200 ); + +return 0 ; +} + +static int tianma_panel_prepare (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int err; + +if (pinfo->prepared) +return 0 ; + + err =tianma_panel_power_on (pinfo); +if (err <0 ) + goto poweroff; + +/* send first part of init cmds */ + err =send_mipi_cmds (panel, pinfo->desc->on_cmds_1); + +if (err <0 ) { +DRM_DEV_ERROR (panel->dev, +"failed to send DCS Init 1st Code: %d\n" , err); + goto poweroff; + } + + err =mipi_dsi_dcs_set_display_on (pinfo->link); +if (err <0 ) { +DRM_DEV_ERROR (panel->dev, +"failed to Set Display ON: %d\n" , err); + goto poweroff; + } + + err =mipi_dsi_dcs_exit_sleep_mode (pinfo->link); +if (err <0 ) { +DRM_DEV_ERROR (panel->dev,"failed to exit sleep mode: %d\n" , + err); + goto poweroff; + } +/* 0x46 = 70 ms delay */ +msleep (70 ); + +/* Send rest of the init cmds */ + err =send_mipi_cmds (panel, pinfo->desc->on_cmds_2); + +if (err <0 ) { +DRM_DEV_ERROR (panel->dev, +"failed to send DCS Init 2nd Code: %d\n" , err); + goto poweroff; + } + +msleep (120 ); + + pinfo->prepared = true; + +return 0 ; + +poweroff: +gpiod_set_value (pinfo->reset_gpio,1 ); +return err; +} + +
Quoted 9 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 319
Quoted 6 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +6
-0+static int tianma_panel_enable (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); + +if (pinfo->enabled) +return 0 ;->enabled is only used to avoid assignment to ->enabled. Looks like code that can be dropped.
Ack.
Quoted 419 lines
Quoted 419 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +419
-0+ + pinfo->enabled = true; + +return 0 ; +} + +static int tianma_panel_get_modes (struct drm_panel *panel, +struct drm_connector *connector) +{ +struct panel_info *pinfo =to_panel_info (panel); +const struct drm_display_mode *m = pinfo->desc->display_mode; +struct drm_display_mode *mode; + + mode =drm_mode_duplicate (connector->dev, m); +if (!mode) { +DRM_DEV_ERROR (panel->dev,"failed to add mode %ux%u@%u\n" , + m->hdisplay, m->vdisplay,drm_mode_vrefresh (m)); +return -ENOMEM ; + } + + connector->display_info.width_mm = pinfo->desc->width_mm; + connector->display_info.height_mm = pinfo->desc->height_mm; + +drm_mode_set_name (mode); +drm_mode_probed_add (connector, mode); + +return 1 ; +} + +static const struct drm_panel_funcs panel_funcs = { + .disable = tianma_panel_disable, + .unprepare = tianma_panel_unprepare, + .prepare = tianma_panel_prepare, + .enable = tianma_panel_enable, + .get_modes = tianma_panel_get_modes, +}; + +static const struct panel_cmd tianma_nt36672a_on_cmds_1[] = { +/* skin enhancement mode */ +_INIT_CMD (0x00 ,0xFF ,0x22 ), +_INIT_CMD (0x00 ,0x00 ,0x40 ), +_INIT_CMD (0x00 ,0x01 ,0xC0 ), +_INIT_CMD (0x00 ,0x02 ,0x40 ), +_INIT_CMD (0x00 ,0x03 ,0x40 ), +_INIT_CMD (0x00 ,0x04 ,0x40 ), +_INIT_CMD (0x00 ,0x05 ,0x40 ), +_INIT_CMD (0x00 ,0x06 ,0x40 ), +_INIT_CMD (0x00 ,0x07 ,0x40 ), +_INIT_CMD (0x00 ,0x08 ,0x40 ), +_INIT_CMD (0x00 ,0x09 ,0x40 ), +_INIT_CMD (0x00 ,0x0A ,0x40 ), +_INIT_CMD (0x00 ,0x0B ,0x40 ), +_INIT_CMD (0x00 ,0x0C ,0x40 ), +_INIT_CMD (0x00 ,0x0D ,0x40 ), +_INIT_CMD (0x00 ,0x0E ,0x40 ), +_INIT_CMD (0x00 ,0x0F ,0x40 ), +_INIT_CMD (0x00 ,0x10 ,0x40 ), +_INIT_CMD (0x00 ,0x11 ,0x50 ), +_INIT_CMD (0x00 ,0x12 ,0x60 ), +_INIT_CMD (0x00 ,0x13 ,0x70 ), +_INIT_CMD (0x00 ,0x14 ,0x58 ), +_INIT_CMD (0x00 ,0x15 ,0x68 ), +_INIT_CMD (0x00 ,0x16 ,0x78 ), +_INIT_CMD (0x00 ,0x17 ,0x77 ), +_INIT_CMD (0x00 ,0x18 ,0x39 ), +_INIT_CMD (0x00 ,0x19 ,0x2D ), +_INIT_CMD (0x00 ,0x1A ,0x2E ), +_INIT_CMD (0x00 ,0x1B ,0x32 ), +_INIT_CMD (0x00 ,0x1C ,0x37 ), +_INIT_CMD (0x00 ,0x1D ,0x3A ), +_INIT_CMD (0x00 ,0x1E ,0x40 ), +_INIT_CMD (0x00 ,0x1F ,0x40 ), +_INIT_CMD (0x00 ,0x20 ,0x40 ), +_INIT_CMD (0x00 ,0x21 ,0x40 ), +_INIT_CMD (0x00 ,0x22 ,0x40 ), +_INIT_CMD (0x00 ,0x23 ,0x40 ), +_INIT_CMD (0x00 ,0x24 ,0x40 ), +_INIT_CMD (0x00 ,0x25 ,0x40 ), +_INIT_CMD (0x00 ,0x26 ,0x40 ), +_INIT_CMD (0x00 ,0x27 ,0x40 ), +_INIT_CMD (0x00 ,0x28 ,0x40 ), +_INIT_CMD (0x00 ,0x2D ,0x00 ), +_INIT_CMD (0x00 ,0x2F ,0x40 ), +_INIT_CMD (0x00 ,0x30 ,0x40 ), +_INIT_CMD (0x00 ,0x31 ,0x40 ), +_INIT_CMD (0x00 ,0x32 ,0x40 ), +_INIT_CMD (0x00 ,0x33 ,0x40 ), +_INIT_CMD (0x00 ,0x34 ,0x40 ), +_INIT_CMD (0x00 ,0x35 ,0x40 ), +_INIT_CMD (0x00 ,0x36 ,0x40 ), +_INIT_CMD (0x00 ,0x37 ,0x40 ), +_INIT_CMD (0x00 ,0x38 ,0x40 ), +_INIT_CMD (0x00 ,0x39 ,0x40 ), +_INIT_CMD (0x00 ,0x3A ,0x40 ), +_INIT_CMD (0x00 ,0x3B ,0x40 ), +_INIT_CMD (0x00 ,0x3D ,0x40 ), +_INIT_CMD (0x00 ,0x3F ,0x40 ), +_INIT_CMD (0x00 ,0x40 ,0x40 ), +_INIT_CMD (0x00 ,0x41 ,0x40 ), +_INIT_CMD (0x00 ,0x42 ,0x40 ), +_INIT_CMD (0x00 ,0x43 ,0x40 ), +_INIT_CMD (0x00 ,0x44 ,0x40 ), +_INIT_CMD (0x00 ,0x45 ,0x40 ), +_INIT_CMD (0x00 ,0x46 ,0x40 ), +_INIT_CMD (0x00 ,0x47 ,0x40 ), +_INIT_CMD (0x00 ,0x48 ,0x40 ), +_INIT_CMD (0x00 ,0x49 ,0x40 ), +_INIT_CMD (0x00 ,0x4A ,0x40 ), +_INIT_CMD (0x00 ,0x4B ,0x40 ), +_INIT_CMD (0x00 ,0x4C ,0x40 ), +_INIT_CMD (0x00 ,0x4D ,0x40 ), +_INIT_CMD (0x00 ,0x4E ,0x40 ), +_INIT_CMD (0x00 ,0x4F ,0x40 ), +_INIT_CMD (0x00 ,0x50 ,0x40 ), +_INIT_CMD (0x00 ,0x51 ,0x40 ), +_INIT_CMD (0x00 ,0x52 ,0x40 ), +_INIT_CMD (0x00 ,0x53 ,0x01 ), +_INIT_CMD (0x00 ,0x54 ,0x01 ), +_INIT_CMD (0x00 ,0x55 ,0xFE ), +_INIT_CMD (0x00 ,0x56 ,0x77 ), +_INIT_CMD (0x00 ,0x58 ,0xCD ), +_INIT_CMD (0x00 ,0x59 ,0xD0 ), +_INIT_CMD (0x00 ,0x5A ,0xD0 ), +_INIT_CMD (0x00 ,0x5B ,0x50 ), +_INIT_CMD (0x00 ,0x5C ,0x50 ), +_INIT_CMD (0x00 ,0x5D ,0x50 ), +_INIT_CMD (0x00 ,0x5E ,0x50 ), +_INIT_CMD (0x00 ,0x5F ,0x50 ), +_INIT_CMD (0x00 ,0x60 ,0x50 ), +_INIT_CMD (0x00 ,0x61 ,0x50 ), +_INIT_CMD (0x00 ,0x62 ,0x50 ), +_INIT_CMD (0x00 ,0x63 ,0x50 ), +_INIT_CMD (0x00 ,0x64 ,0x50 ), +_INIT_CMD (0x00 ,0x65 ,0x50 ), +_INIT_CMD (0x00 ,0x66 ,0x50 ), +_INIT_CMD (0x00 ,0x67 ,0x50 ), +_INIT_CMD (0x00 ,0x68 ,0x50 ), +_INIT_CMD (0x00 ,0x69 ,0x50 ), +_INIT_CMD (0x00 ,0x6A ,0x50 ), +_INIT_CMD (0x00 ,0x6B ,0x50 ), +_INIT_CMD (0x00 ,0x6C ,0x50 ), +_INIT_CMD (0x00 ,0x6D ,0x50 ), +_INIT_CMD (0x00 ,0x6E ,0x50 ), +_INIT_CMD (0x00 ,0x6F ,0x50 ), +_INIT_CMD (0x00 ,0x70 ,0x07 ), +_INIT_CMD (0x00 ,0x71 ,0x00 ), +_INIT_CMD (0x00 ,0x72 ,0x00 ), +_INIT_CMD (0x00 ,0x73 ,0x00 ), +_INIT_CMD (0x00 ,0x74 ,0x06 ), +_INIT_CMD (0x00 ,0x75 ,0x0C ), +_INIT_CMD (0x00 ,0x76 ,0x03 ), +_INIT_CMD (0x00 ,0x77 ,0x09 ), +_INIT_CMD (0x00 ,0x78 ,0x0F ), +_INIT_CMD (0x00 ,0x79 ,0x68 ), +_INIT_CMD (0x00 ,0x7A ,0x88 ), +_INIT_CMD (0x00 ,0x7C ,0x80 ), +_INIT_CMD (0x00 ,0x7D ,0x80 ), +_INIT_CMD (0x00 ,0x7E ,0x80 ), +_INIT_CMD (0x00 ,0x7F ,0x00 ), +_INIT_CMD (0x00 ,0x80 ,0x00 ), +_INIT_CMD (0x00 ,0x81 ,0x00 ), +_INIT_CMD (0x00 ,0x83 ,0x01 ), +_INIT_CMD (0x00 ,0x84 ,0x00 ), +_INIT_CMD (0x00 ,0x85 ,0x80 ), +_INIT_CMD (0x00 ,0x86 ,0x80 ), +_INIT_CMD (0x00 ,0x87 ,0x80 ), +_INIT_CMD (0x00 ,0x88 ,0x40 ), +_INIT_CMD (0x00 ,0x89 ,0x91 ), +_INIT_CMD (0x00 ,0x8A ,0x98 ), +_INIT_CMD (0x00 ,0x8B ,0x80 ), +_INIT_CMD (0x00 ,0x8C ,0x80 ), +_INIT_CMD (0x00 ,0x8D ,0x80 ), +_INIT_CMD (0x00 ,0x8E ,0x80 ), +_INIT_CMD (0x00 ,0x8F ,0x80 ), +_INIT_CMD (0x00 ,0x90 ,0x80 ), +_INIT_CMD (0x00 ,0x91 ,0x80 ), +_INIT_CMD (0x00 ,0x92 ,0x80 ), +_INIT_CMD (0x00 ,0x93 ,0x80 ), +_INIT_CMD (0x00 ,0x94 ,0x80 ), +_INIT_CMD (0x00 ,0x95 ,0x80 ), +_INIT_CMD (0x00 ,0x96 ,0x80 ), +_INIT_CMD (0x00 ,0x97 ,0x80 ), +_INIT_CMD (0x00 ,0x98 ,0x80 ), +_INIT_CMD (0x00 ,0x99 ,0x80 ), +_INIT_CMD (0x00 ,0x9A ,0x80 ), +_INIT_CMD (0x00 ,0x9B ,0x80 ), +_INIT_CMD (0x00 ,0x9C ,0x80 ), +_INIT_CMD (0x00 ,0x9D ,0x80 ), +_INIT_CMD (0x00 ,0x9E ,0x80 ), +_INIT_CMD (0x00 ,0x9F ,0x80 ), +_INIT_CMD (0x00 ,0xA0 ,0x8A ), +_INIT_CMD (0x00 ,0xA2 ,0x80 ), +_INIT_CMD (0x00 ,0xA6 ,0x80 ), +_INIT_CMD (0x00 ,0xA7 ,0x80 ), +_INIT_CMD (0x00 ,0xA9 ,0x80 ), +_INIT_CMD (0x00 ,0xAA ,0x80 ), +_INIT_CMD (0x00 ,0xAB ,0x80 ), +_INIT_CMD (0x00 ,0xAC ,0x80 ), +_INIT_CMD (0x00 ,0xAD ,0x80 ), +_INIT_CMD (0x00 ,0xAE ,0x80 ), +_INIT_CMD (0x00 ,0xAF ,0x80 ), +_INIT_CMD (0x00 ,0xB7 ,0x76 ), +_INIT_CMD (0x00 ,0xB8 ,0x76 ), +_INIT_CMD (0x00 ,0xB9 ,0x05 ), +_INIT_CMD (0x00 ,0xBA ,0x0D ), +_INIT_CMD (0x00 ,0xBB ,0x14 ), +_INIT_CMD (0x00 ,0xBC ,0x0F ), +_INIT_CMD (0x00 ,0xBD ,0x18 ), +_INIT_CMD (0x00 ,0xBE ,0x1F ), +_INIT_CMD (0x00 ,0xBF ,0x05 ), +_INIT_CMD (0x00 ,0xC0 ,0x0D ), +_INIT_CMD (0x00 ,0xC1 ,0x14 ), +_INIT_CMD (0x00 ,0xC2 ,0x03 ), +_INIT_CMD (0x00 ,0xC3 ,0x07 ), +_INIT_CMD (0x00 ,0xC4 ,0x0A ), +_INIT_CMD (0x00 ,0xC5 ,0xA0 ), +_INIT_CMD (0x00 ,0xC6 ,0x55 ), +_INIT_CMD (0x00 ,0xC7 ,0xFF ), +_INIT_CMD (0x00 ,0xC8 ,0x39 ), +_INIT_CMD (0x00 ,0xC9 ,0x44 ), +_INIT_CMD (0x00 ,0xCA ,0x12 ), +_INIT_CMD (0x00 ,0xCD ,0x80 ), +_INIT_CMD (0x00 ,0xDB ,0x80 ), +_INIT_CMD (0x00 ,0xDC ,0x80 ), +_INIT_CMD (0x00 ,0xDD ,0x80 ), +_INIT_CMD (0x00 ,0xE0 ,0x80 ), +_INIT_CMD (0x00 ,0xE1 ,0x80 ), +_INIT_CMD (0x00 ,0xE2 ,0x80 ), +_INIT_CMD (0x00 ,0xE3 ,0x80 ), +_INIT_CMD (0x00 ,0xE4 ,0x80 ), +_INIT_CMD (0x00 ,0xE5 ,0x40 ), +_INIT_CMD (0x00 ,0xE6 ,0x40 ), +_INIT_CMD (0x00 ,0xE7 ,0x40 ), +_INIT_CMD (0x00 ,0xE8 ,0x40 ), +_INIT_CMD (0x00 ,0xE9 ,0x40 ), +_INIT_CMD (0x00 ,0xEA ,0x40 ), +_INIT_CMD (0x00 ,0xEB ,0x40 ), +_INIT_CMD (0x00 ,0xEC ,0x40 ), +_INIT_CMD (0x00 ,0xED ,0x40 ), +_INIT_CMD (0x00 ,0xEE ,0x40 ), +_INIT_CMD (0x00 ,0xEF ,0x40 ), +_INIT_CMD (0x00 ,0xF0 ,0x40 ), +_INIT_CMD (0x00 ,0xF1 ,0x40 ), +_INIT_CMD (0x00 ,0xF2 ,0x40 ), +_INIT_CMD (0x00 ,0xF3 ,0x40 ), +_INIT_CMD (0x00 ,0xF4 ,0x40 ), +_INIT_CMD (0x00 ,0xF5 ,0x40 ), +_INIT_CMD (0x00 ,0xF6 ,0x40 ), +_INIT_CMD (0x00 ,0xFB ,0x1 ), +_INIT_CMD (0x00 ,0xFF ,0x23 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +/* dimming enable */ +_INIT_CMD (0x00 ,0x01 ,0x84 ), +_INIT_CMD (0x00 ,0x05 ,0x2D ), +_INIT_CMD (0x00 ,0x06 ,0x00 ), +/* resolution 1080*2246 */ +_INIT_CMD (0x00 ,0x11 ,0x01 ), +_INIT_CMD (0x00 ,0x12 ,0x7B ), +_INIT_CMD (0x00 ,0x15 ,0x6F ), +_INIT_CMD (0x00 ,0x16 ,0x0B ), +/* UI mode */ +_INIT_CMD (0x00 ,0x29 ,0x0A ), +_INIT_CMD (0x00 ,0x30 ,0xFF ), +_INIT_CMD (0x00 ,0x31 ,0xFF ), +_INIT_CMD (0x00 ,0x32 ,0xFF ), +_INIT_CMD (0x00 ,0x33 ,0xFF ), +_INIT_CMD (0x00 ,0x34 ,0xFF ), +_INIT_CMD (0x00 ,0x35 ,0xFF ), +_INIT_CMD (0x00 ,0x36 ,0xFF ), +_INIT_CMD (0x00 ,0x37 ,0xFF ), +_INIT_CMD (0x00 ,0x38 ,0xFC ), +_INIT_CMD (0x00 ,0x39 ,0xF8 ), +_INIT_CMD (0x00 ,0x3A ,0xF4 ), +_INIT_CMD (0x00 ,0x3B ,0xF1 ), +_INIT_CMD (0x00 ,0x3D ,0xEE ), +_INIT_CMD (0x00 ,0x3F ,0xEB ), +_INIT_CMD (0x00 ,0x40 ,0xE8 ), +_INIT_CMD (0x00 ,0x41 ,0xE5 ), +/* STILL mode */ +_INIT_CMD (0x00 ,0x2A ,0x13 ), +_INIT_CMD (0x00 ,0x45 ,0xFF ), +_INIT_CMD (0x00 ,0x46 ,0xFF ), +_INIT_CMD (0x00 ,0x47 ,0xFF ), +_INIT_CMD (0x00 ,0x48 ,0xFF ), +_INIT_CMD (0x00 ,0x49 ,0xFF ), +_INIT_CMD (0x00 ,0x4A ,0xFF ), +_INIT_CMD (0x00 ,0x4B ,0xFF ), +_INIT_CMD (0x00 ,0x4C ,0xFF ), +_INIT_CMD (0x00 ,0x4D ,0xED ), +_INIT_CMD (0x00 ,0x4E ,0xD5 ), +_INIT_CMD (0x00 ,0x4F ,0xBF ), +_INIT_CMD (0x00 ,0x50 ,0xA6 ), +_INIT_CMD (0x00 ,0x51 ,0x96 ), +_INIT_CMD (0x00 ,0x52 ,0x86 ), +_INIT_CMD (0x00 ,0x53 ,0x76 ), +_INIT_CMD (0x00 ,0x54 ,0x66 ), +/* MOVING mode */ +_INIT_CMD (0x00 ,0x2B ,0x0E ), +_INIT_CMD (0x00 ,0x58 ,0xFF ), +_INIT_CMD (0x00 ,0x59 ,0xFF ), +_INIT_CMD (0x00 ,0x5A ,0xFF ), +_INIT_CMD (0x00 ,0x5B ,0xFF ), +_INIT_CMD (0x00 ,0x5C ,0xFF ), +_INIT_CMD (0x00 ,0x5D ,0xFF ), +_INIT_CMD (0x00 ,0x5E ,0xFF ), +_INIT_CMD (0x00 ,0x5F ,0xFF ), +_INIT_CMD (0x00 ,0x60 ,0xF6 ), +_INIT_CMD (0x00 ,0x61 ,0xEA ), +_INIT_CMD (0x00 ,0x62 ,0xE1 ), +_INIT_CMD (0x00 ,0x63 ,0xD8 ), +_INIT_CMD (0x00 ,0x64 ,0xCE ), +_INIT_CMD (0x00 ,0x65 ,0xC3 ), +_INIT_CMD (0x00 ,0x66 ,0xBA ), +_INIT_CMD (0x00 ,0x67 ,0xB3 ), +_INIT_CMD (0x00 ,0xFF ,0x25 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0x05 ,0x04 ), +_INIT_CMD (0x00 ,0xFF ,0x26 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0x1C ,0xAF ), +_INIT_CMD (0x00 ,0xFF ,0x10 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0x51 ,0xFF ), +_INIT_CMD (0x00 ,0x53 ,0x24 ), +_INIT_CMD (0x00 ,0x55 ,0x00 ), + + {}, +}; + +static const struct panel_cmd tianma_nt36672a_on_cmds_2[] = { +_INIT_CMD (0x00 ,0xFF ,0x24 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0xC3 ,0x01 ), +_INIT_CMD (0x00 ,0xC4 ,0x54 ), +_INIT_CMD (0x00 ,0xFF ,0x10 ), + + {}, +}; + +static const struct panel_cmd tianma_nt36672a_off_cmds[] = { +_INIT_CMD (0x00 ,0xFF ,0x24 ), +_INIT_CMD (0x00 ,0xFB ,0x01 ), +_INIT_CMD (0x00 ,0xC3 ,0x01 ), +_INIT_CMD (0x00 ,0xFF ,0x10 ), + + {}, +}; + +static const struct drm_display_mode tianma_panel_default_mode = { + .clock =161331 , + + .hdisplay =1080 , + .hsync_start =1080 +40 , + .hsync_end =1080 +40 +20 , + .htotal =1080 +40 +20 +44 , + + .vdisplay =2246 , + .vsync_start =2246 +15 , + .vsync_end =2246 +15 +2 , + .vtotal =2246 +15 +2 +8 , + + .type =DRM_MODE_TYPE_DRIVER |DRM_MODE_TYPE_PREFERRED , +}; + +static const struct panel_desc tianma_panel_desc = { + .display_mode = &tianma_panel_default_mode, + + .width_mm =68 , + .height_mm =136 , + + .mode_flags =MIPI_DSI_MODE_LPM |MIPI_DSI_MODE_VIDEO + |MIPI_DSI_MODE_VIDEO_HSE + |MIPI_DSI_CLOCK_NON_CONTINUOUS + |MIPI_DSI_MODE_VIDEO_BURST , + .format =MIPI_DSI_FMT_RGB888 , + .lanes =4 , + .on_cmds_1 = tianma_nt36672a_on_cmds_1, + .on_cmds_2 = tianma_nt36672a_on_cmds_2, + .off_cmds = tianma_nt36672a_off_cmds +}; + + +static const struct of_device_id panel_of_match[] = { + { .compatible ="tianma,nt36672a" , + .data = &tianma_panel_desc + }, + { +/* sentinel */ + } +}; +MODULE_DEVICE_TABLE (of, panel_of_match); + + +static int panel_pinctrl_init (struct panel_info *panel) +{ +struct device *dev = &panel->link->dev; +int rc =0 ; + + panel->pinctrl =devm_pinctrl_get (dev); +if (IS_ERR_OR_NULL (panel->pinctrl)) { + rc =PTR_ERR (panel->pinctrl); +pr_err ("failed to get pinctrl, rc=%d\n" , rc); + goto error; + } + + panel->active =pinctrl_lookup_state (panel->pinctrl, +"panel_active" ); +if (IS_ERR_OR_NULL (panel->active)) { + rc =PTR_ERR (panel->active); +pr_err ("failed to get pinctrl active state, rc=%d\n" , rc); + goto error; + } + + panel->suspend = +pinctrl_lookup_state (panel->pinctrl,"panel_suspend" ); + +if (IS_ERR_OR_NULL (panel->suspend)) { + rc =PTR_ERR (panel->suspend); +pr_err ("failed to get pinctrl suspend state, rc=%d\n" , rc);
Quoted 8 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 744
Quoted 6 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +6
-0+ goto error; + } + +error: +return rc; +}I thought the core would handle pin-trl for us?
Have I missed something?
Answered above.
Quoted 24 lines
Quoted 24 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +23
-0+ +static int panel_add (struct panel_info *pinfo) +{ +struct device *dev = &pinfo->link->dev; +int i, ret; + +for (i =0 ; i <ARRAY_SIZE (pinfo->supplies); i++) + pinfo->supplies[i].supply = regulator_names[i]; + + ret =devm_regulator_bulk_get (dev,ARRAY_SIZE (pinfo->supplies), + pinfo->supplies); +if (ret <0 ) +return ret; + + pinfo->reset_gpio =devm_gpiod_get (dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (pinfo->reset_gpio)) { +DRM_DEV_ERROR (dev,"cannot get reset gpio %ld\n" , +PTR_ERR (pinfo->reset_gpio)); +return PTR_ERR (pinfo->reset_gpio); + } + + ret =panel_pinctrl_init (pinfo); +if (ret <0 )
Quoted 8 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 773
Quoted 6 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +6
-0+return ret; + +drm_panel_init (&pinfo->base, dev, &panel_funcs, +DRM_MODE_CONNECTOR_DSI ); + + ret =drm_panel_add (&pinfo->base);
drm_panel_add()now returns void - use latest drm-misc-next to catch such issues.
Yes, of course. Will do.
Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +30
-0+if (ret <0 ) +return ret; +return 0 ; +} + +static void panel_del (struct panel_info *pinfo) +{ +if (pinfo->base.dev) +drm_panel_remove (&pinfo->base); +} + +static int panel_probe (struct mipi_dsi_device *dsi) +{ +struct panel_info *pinfo; +const struct panel_desc *desc; +int err; + + pinfo =devm_kzalloc (&dsi->dev,sizeof (*pinfo),GFP_KERNEL ); +if (!pinfo) +return -ENOMEM ; + + desc =of_device_get_match_data (&dsi->dev); + dsi->mode_flags = desc->mode_flags; + dsi->format = desc->format; + dsi->lanes = desc->lanes; + pinfo->desc = desc; + pinfo->link = dsi; + +mipi_dsi_set_drvdata (dsi, pinfo); +
Quoted 8 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 809
Quoted 6 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +6
-0+ err =panel_add (pinfo); +if (err <0 ) +return err; + + err =mipi_dsi_attach (dsi); +return err;Or return
mipi_dsi_attach(dsi);
Ack
Quoted 11 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 817
Quoted 9 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +8
-0+} + +static int panel_remove (struct mipi_dsi_device *dsi) +{ +struct panel_info *pinfo =mipi_dsi_get_drvdata (dsi); +int err; + + err =tianma_panel_unprepare (&pinfo->base);Use
drm_panel_unprepare()here - you may need functionality fromdrm_panel.
Ack
Quoted 6 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 822
Quoted 5 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +5
-0+if (err <0 ) +DRM_DEV_ERROR (&dsi->dev,"failed to unprepare panel: %d\n" , + err); + + err =tianma_panel_disable (&pinfo->base);USe
drm_panel_disable()here.
Ack
Quoted 12 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 832
Quoted 11 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +10
-0+if (err <0 ) +DRM_DEV_ERROR (&dsi->dev,"failed to disable panel: %d\n" , err); + + err =mipi_dsi_detach (dsi); +if (err <0 ) +DRM_DEV_ERROR (&dsi->dev,"failed to detach from DSI host: %d\n" , + err); + +drm_panel_detach (&pinfo->base); +panel_del (pinfo);Call
drm_panel_remove()here - no reason for a helper.
Agreed.
Quoted 11 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 841
Quoted 10 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +9
-0+ +return 0 ; +} + +static void panel_shutdown (struct mipi_dsi_device *dsi) +{ +struct panel_info *pinfo =mipi_dsi_get_drvdata (dsi); + +tianma_panel_disable (&pinfo->base);
drm_panel_disable()
Ack
Quoted 3 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c line 842
Quoted 2 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +1
-0+tianma_panel_unprepare (&pinfo->base);
drm_panel_unprepare()
Ack
Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/panel/panel-tianma-nt36672a.c new file +16
-1+} + +static struct mipi_dsi_driver panel_driver = { + .driver = { + .name ="panel-tianma-nt36672a" , + .of_match_table = panel_of_match, + }, + .probe = panel_probe, + .remove = panel_remove, + .shutdown = panel_shutdown, +}; +module_mipi_dsi_driver (panel_driver); + +MODULE_AUTHOR ("Sumit Semwal <[email protected]>" ); +MODULE_DESCRIPTION ("TIANMA NT36672A MIPI-DSI LCD panel" ); +MODULE_LICENSE ("GPL" ); --2.28.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Best,
Sumit.