drm/panel: Add Novatek NT36536 panel driver
Subsystems (4)
v3 cover drm/panel: Add Novatek NT36536 panel driver
Add a driver for panels using the Novatek NT36536 Display Driver IC, including support for the CSOT PP8807HB1-1, a dual-link 10-bit panel found in LENOVO Legion Y700 Gen4.
---
Changes in v3:
- Only include needed device-id headers (Uwe)
- Link to v2: https://lore.kernel.org/dri-devel/[email protected]
Changes in v2:
- Collect tags
- Mention the CSOT PP8807HB1-1 is a dual-link panel (Krzysztof)
- Use devm_drm_panel_add() (Neil)
- Link to v1: https://lore.kernel.org/dri-devel/[email protected]
Pengyu Luo (2):
dt-bindings: display: panel: Add Novatek NT36536 drm/panel: Add Novatek NT36536 panel driver
.../display/panel/novatek,nt36536.yaml | 91 ++++ drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-novatek-nt36536.c | 488 ++++++++++++++++++ 4 files changed, 591 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/novatek,nt36536.yaml create mode 100644 drivers/gpu/drm/panel/panel-novatek-nt36536.c
Signature · 1 line
2.54.0
PATCH v3 1/2 dt-bindings: display: panel: Add Novatek NT36536
NT36536 is a driver IC used to drive MIPI-DSI panels. It is found in LENOVO Legion Y700 Gen4 with a dual-link 10-bit CSOT panel.
---
v3:
No changes.
v2:
- Collect tags
- Mention the CSOT PP8807HB1-1 is a dual-link panel (Krzysztof)
--- .../display/panel/novatek,nt36536.yaml | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/novatek,nt36536.yaml
Documentation/devicetree/bindings/display/panel/novatek,nt36536.yaml new file +91 -0
@@ -0,0 +1,91 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/novatek,nt36536.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36536 based DSI display Panels + +maintainers: + - Pengyu Luo <[email protected]> + +description: + The Novatek NT36536 is a generic DSI Panel IC used to drive dsi + panels. Support video mode panels from China Star Optoelectronics + Technology (CSOT), such as PP8807HB1-1 which is a dual-link 10-bit + panel. + +allOf: + - $ref: panel-common-dual.yaml# + +properties: + compatible: + items: + - enum: + - csot,pp8807hb1-1 + - const: novatek,nt36536 + + reg: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vddio-supply: + description: I/O source voltage rail + + vsp-supply: + description: Positive source voltage rail + + vsn-supply: + description: Negative source voltage rail + + backlight: true + ports: true + +required: + - compatible + - reg + - vddio-supply + - reset-gpios + - ports + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + dsi { + #address-cells = <1>; + #size-cells = <0>; + + panel@0 { + compatible = "csot,pp8807hb1-1", "novatek,nt36536"; + reg = <0>; + + vddio-supply = <&vreg_iovdd_1p8>; + reset-gpios = <&tlmm 98 GPIO_ACTIVE_LOW>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + panel_in_0: endpoint { + remote-endpoint = <&dsi0_out>; + }; + }; + + port@1{ + reg = <1>; + panel_in_1: endpoint { + remote-endpoint = <&dsi1_out>; + }; + }; + }; + }; + }; + +...
Signature · 1 line
2.54.0
PATCH v3 2/2 drm/panel: Add Novatek NT36536 panel driver
In reply to Pengyu LuoAdd a driver for panels using the Novatek NT36536 Display Driver IC, including support for the CSOT PP8807HB1-1, a dual-link 10-bit panel found in LENOVO Legion Y700 Gen4.
---
v3:
- Only include needed device-id headers (Uwe)
v2:
- Collect tags
- Use devm_drm_panel_add() (Neil)
--- drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-novatek-nt36536.c | 488 ++++++++++++++++++ 3 files changed, 500 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-novatek-nt36536.c
drivers/gpu/drm/panel/Kconfig +11 -0
@@ -662,6 +662,17 @@ config DRM_PANEL_NOVATEK_NT36523 around the Novatek NT36523 display controller, such as some Boe panels used in Xiaomi Mi Pad 5 and 5 Pro tablets. +config DRM_PANEL_NOVATEK_NT36536 + tristate "Novatek NT36536 panel driver" + depends on OF + depends on DRM_MIPI_DSI + depends on BACKLIGHT_CLASS_DEVICE + select DRM_KMS_HELPER + help + Say Y here if you want to enable support for Novatek NT36536-based + display panels, such as the one found in the LENOVO Legion Y700 + Gen4. + config DRM_PANEL_NOVATEK_NT36672A tristate "Novatek NT36672A DSI panel" depends on GPIOLIB
drivers/gpu/drm/panel/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35532) += panel-novatek-nt35532.o obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35560) += panel-novatek-nt35560.o obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35950) += panel-novatek-nt35950.o obj-$(CONFIG_DRM_PANEL_NOVATEK_NT36523) += panel-novatek-nt36523.o +obj-$(CONFIG_DRM_PANEL_NOVATEK_NT36536) += panel-novatek-nt36536.o obj-$(CONFIG_DRM_PANEL_NOVATEK_NT36672A) += panel-novatek-nt36672a.o obj-$(CONFIG_DRM_PANEL_NOVATEK_NT36672E) += panel-novatek-nt36672e.o obj-$(CONFIG_DRM_PANEL_NOVATEK_NT37700F) += panel-novatek-nt37700f.o
drivers/gpu/drm/panel/panel-novatek-nt36536.c new file +488 -0
488 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] Unrolled resource leak and ignored DSI errors in `novatek_prepare()`. - [Medium] DCS commands are…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Unrolled resource leak and ignored DSI errors in novatek_prepare().
- [Medium] DCS commands are sent unconditionally in backlight update handler.
- [Low] Missing Kconfig dependency for DSC helpers causes build failures.
- [Low] Manual call to drm_panel_remove() circumvents devres cleanup contract. --
--- Patch [2]: [PATCH v3 2/2] drm/panel: Add Novatek NT36536 panel driver --- commit c0321dc5c18b4a1a33b6415a4883e16993cea388
Author: Pengyu Luo <[email protected]>
drm/panel: Add Novatek NT36536 panel driver
This commit adds support for Novatek NT36536-based display panels, specifically enabling the CSOT PP8807HB1-1 dual-link 10-bit panel found in the LENOVO Legion Y700 Gen4.
Quoted 5 lines
drivers/gpu/drm/panel/Kconfig +0
-0
drivers/gpu/drm/panel/Kconfig config DRM_PANEL_NOVATEK_NT36523 · line 658
Quoted 9 lines
drivers/gpu/drm/panel/Kconfig +6
-0@@ -650,6 +650,17 @@ config DRM_PANEL_NOVATEK_NT36523 around the Novatek NT36523 display controller, such as some Boe panels used in Xiaomi Mi Pad 5 and 5 Pro tablets. +config DRM_PANEL_NOVATEK_NT36536 + tristate "Novatek NT36536 panel driver" + depends on OF + depends on DRM_MIPI_DSI + depends on BACKLIGHT_CLASS_DEVICE + select DRM_KMS_HELPER
[Severity: Low]
Does this Kconfig entry need to select DRM_DISPLAY_DSC_HELPER?
Because the driver unconditionally uses drm_dsc_pps_payload_pack(), compiling the driver without DSC helpers enabled globally will result in undefined reference linker errors. It seems this should also select DRM_DISPLAY_HELPER.
Quoted 4 lines
drivers/gpu/drm/panel/Kconfig +4
-0+ help + Say Y here if you want to enable support for Novatek NT36536-based + display panels, such as the one found in the LENOVO Legion Y700 + Gen4.
[ ... ]
Quoted 5 lines
drivers/gpu/drm/panel/panel-novatek-nt36536.c new file +0
-0
[ ... ]
Quoted 21 lines
drivers/gpu/drm/panel/panel-novatek-nt36536.c new file +21
-0+static int novatek_prepare (struct drm_panel *panel) +{ +struct novatek *ctx =to_novatek (panel); +struct mipi_dsi_device *dsi =to_primary_dsi (ctx); +struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; +struct drm_dsc_picture_parameter_set pps; +struct device *dev = &dsi->dev; +int ret; + + ret =regulator_bulk_enable (ARRAY_SIZE (novatek_supplies), + ctx->supplies); +if (ret <0 ) +return ret; + +novatek_reset (ctx); + + ret = ctx->desc->init_sequence (&dsi_ctx); +if (ret <0 ) { +dev_err (dev,"Failed to initialize panel: %d\n" , ret); +gpiod_set_value_cansleep (ctx->reset_gpio,1 ); + regulator_bulk_disable(ARRAY_SIZE(novatek_supplies),
drivers/gpu/drm/panel/panel-novatek-nt36536.c line 114
Quoted 10 lines
drivers/gpu/drm/panel/panel-novatek-nt36536.c new file +10
-0+ ctx->supplies); +return ret; + } + +drm_dsc_pps_payload_pack (&pps, &ctx->dsc); +mipi_dsi_picture_parameter_set_multi (&dsi_ctx, &pps); +mipi_dsi_compression_mode_multi (&dsi_ctx, true); +mipi_dsi_msleep (&dsi_ctx,28 ); + +return backlight_enable (ctx->backlight);
[Severity: High]
Does this error path leak resources and ignore DSI errors?
If backlight_enable() fails, it returns an error code directly. At this point, the panel regulators are still enabled and the reset GPIO is asserted. Returning an error causes the DRM core to consider the prepare phase failed, meaning novatek_unprepare() will never be called. This results in a permanent power leak.
Additionally, dsi_ctx.accum_err is completely ignored after sending DSC configuration commands, silently masking DSI transmission failures.
Quoted 1 line
+}
[ ... ]
drivers/gpu/drm/panel/panel-novatek-nt36536.c line 190
Quoted 7 lines
drivers/gpu/drm/panel/panel-novatek-nt36536.c new file +7
-0+static int novatek_bl_update_status (struct backlight_device *bl) +{ +struct novatek *ctx =bl_get_data (bl); +u16 brightness =backlight_get_brightness (bl); + +return mipi_dsi_dcs_set_display_brightness_large (to_primary_dsi (ctx), + brightness);
[Severity: Medium]
Can this send DCS commands unconditionally while the panel is unpowered?
Because the backlight brightness can be modified via sysfs at any time, this can execute when the panel is suspended, unpowered, and regulators are disabled. Sending DSI commands in this state typically results in DSI host controller timeouts and kernel error logs. Should the driver verify the panel is prepared before sending DCS commands?
Quoted 1 line
+}
[ ... ]
Quoted 2 lines
drivers/gpu/drm/panel/panel-novatek-nt36536.c new file +2
-0+static int novatek_probe (struct mipi_dsi_device *dsi) +{
[ ... ]
drivers/gpu/drm/panel/panel-novatek-nt36536.c line 433
Quoted 12 lines
drivers/gpu/drm/panel/panel-novatek-nt36536.c new file +12
-0+ ret =devm_drm_panel_add (dev, &ctx->panel); +if (ret <0 ) +return dev_err_probe (dev, ret,"failed to add panel\n" ); + +for (i =0 ; i < num_dsi; i++) { + ctx->dsi[i]->lanes = desc->lanes; + ctx->dsi[i]->format = desc->format; + ctx->dsi[i]->mode_flags = desc->mode_flags; + ctx->dsi[i]->dsc = &ctx->dsc; + ret =devm_mipi_dsi_attach (dev, ctx->dsi[i]); +if (ret <0 ) { +drm_panel_remove (&ctx->panel);
[Severity: Low]
Is this manual call to drm_panel_remove() redundant?
The panel is registered via devm_drm_panel_add(), which schedules drm_panel_remove() to run automatically via devres on failure. Manually calling drm_panel_remove() in the devm_mipi_dsi_attach() error path circumvents the devres cleanup contract and leads to duplicate removal attempts by the driver core.
Quoted 4 lines
drivers/gpu/drm/panel/panel-novatek-nt36536.c new file +4
-0+return dev_err_probe (dev, ret, +"Failed to attach to DSI host\n" ); + } + }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Hi,
Quoted 3 lines · Pengyu Luo
Add a driver for panels using the Novatek NT36536 Display Driver IC, including support for the CSOT PP8807HB1-1, a dual-link 10-bit panel found in LENOVO Legion Y700 Gen4.
Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)
[1/2] dt-bindings: display: panel: Add Novatek NT36536
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/bebb0bac0b0fd0ca39c640462a6334b07bd093b5 [2/2] drm/panel: Add Novatek NT36536 panel driver https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/0355a14085b93260a2211d7da9a79ddb2fd85556
Signature · 1 line
Neil
Hi,
Quoted 3 lines · Pengyu Luo
Add a driver for panels using the Novatek NT36536 Display Driver IC, including support for the CSOT PP8807HB1-1, a dual-link 10-bit panel found in LENOVO Legion Y700 Gen4.
Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)
[1/2] dt-bindings: display: panel: Add Novatek NT36536
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/38873dd52850c3d713f006c240a2ce0abad52271 [2/2] drm/panel: Add Novatek NT36536 panel driver https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/75a5dbd1f4f71b1382dae973538af00178ba55a0
Signature · 1 line
Neil