drm/panel: Add Boe Himax8279d MIPI-DSI LCD panel
PATCH 1/1 drm/panel: Add Boe Himax8279d MIPI-DSI LCD panel
Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI panel.
V9:
- Adjust init code, make the format more concise
- kill off default_off_cmds (Emil)
- use mipi_dsi_dcs_set_display_{on,off} in their enable/disable callbacks. (Emil)
- Adjusting the delay function (Emil)
V8:
- modify PARENTHESIS_ALIGNMENT format (Sam)
- use gpios are required API replace optional gpio API (Emil)
V7:
- Modify communication address
V6:
- Add the information of the reviewer
- Remove unnecessary delays, The udelay_range code gracefully returns without hitting the scheduler on a delay of 0. (Derek)
- Merge the same data structures, like display_mode and off_cmds (Derek)
- Optimize the processing of results returned by devm_gpiod_get_optional (Derek)
V5:
- Add the information of the reviewer (Sam)
- Delete unnecessary header files #include <linux/fb.h> (Sam)
- The config DRM_PANEL_BOE_HIMAX8279D appears twice. Drop one of them (Sam)
- ADD static, set_gpios function is not used outside this module (Sam)
V4:
- Frefix all function maes with boe_ (Sam)
- Fsed "enable_gpio" replace "reset_gpio", Make it look clearer (Sam)
- Sort include lines alphabetically (Sam)
- Fixed entries in the makefile must be sorted alphabetically (Sam)
- Add send_mipi_cmds function to avoid duplicating the code (Sam)
- Add the necessary delay(reset_delay_t5) between reset and sending the initialization command (Rock wang)
V3:
- Remove unnecessary delays in sending initialization commands (Jitao Shi)
V2:
- Use SPDX identifier (Sam)
- Use necessary header files replace drmP.h (Sam)
- Delete unnecessary header files #include <linux/err.h> (Sam)
- Specifies a GPIOs array to control the reset timing, instead of reading "dsi-reset-sequence" data from DTS (Sam)
- Delete backlight_disable() function when already disabled (Sam)
- Use devm_of_find_backlight() replace of_find_backlight_by_node() (Sam)
- Move the necessary data in the DTS to the current file, like porch, display_mode and Init code etc. (Sam)
- Add compatible device "boe,himax8279d10p" (Sam)
V1:
- Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI panel.
--- MAINTAINERS | 6 + drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 2 + drivers/gpu/drm/panel/panel-boe-himax8279d.c | 990 +++++++++++++++++++ 4 files changed, 1009 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-boe-himax8279d.c
MAINTAINERS +6 -0
@@ -5135,6 +5135,12 @@ T: git git://anongit.freedesktop.org/drm/drm-misc S: Maintained F: drivers/gpu/drm/bochs/ +DRM DRIVER FOR BOE HIMAX8279D PANELS +M: Jerry Han <[email protected]> +S: Maintained +F: drivers/gpu/drm/panel/panel-boe-himax8279d.c +F: Documentation/devicetree/bindings/display/panel/boe,himax8279d.txt + DRM DRIVER FOR FARADAY TVE200 TV ENCODER M: Linus Walleij <[email protected]> T: git git://anongit.freedesktop.org/drm/drm-misc
drivers/gpu/drm/panel/Kconfig +11 -0
@@ -18,6 +18,17 @@ config DRM_PANEL_ARM_VERSATILE reference designs. The panel is detected using special registers in the Versatile family syscon registers. +config DRM_PANEL_BOE_HIMAX8279D + tristate "Boe Himax8279d 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 Boe Himax8279d + TFT-LCD modules. The panel has a 1200x1920 resolution and uses + 24 bit RGB per pixel. It provides a MIPI DSI interface to + the host and has a built-in LED backlight. + config DRM_PANEL_LVDS tristate "Generic LVDS panel driver" depends on OF
drivers/gpu/drm/panel/Makefile +2 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o +obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += panel-feiyang-fy07024di26a30d.o
@@ -36,5 +37,6 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.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_BOE_HIMAX8279D) += panel-boe-himax8279d.o obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +990 -0
990 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Jerry,
Quoted 56 lines · Jerry Han
Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI panel.
V9:
- Adjust init code, make the format more concise
- kill offdefault_off_cmds(Emil)
- use mipi_dsi_dcs_set_display_{on,off} in their enable/disable callbacks. (Emil)
- Adjusting the delay function (Emil)V8:
- modifyPARENTHESIS_ALIGNMENTformat (Sam)
- use gpios are required API replace optional gpio API (Emil)V7:
- Modify communication addressV6:
- Add the information of the reviewer
- Remove unnecessary delays, Theudelay_rangecode gracefully returns without hitting the scheduler on a delay of 0. (Derek)
- Merge the same data structures, likedisplay_modeandoff_cmds(Derek)
- Optimize the processing of results returned bydevm_gpiod_get_optional(Derek)V5:
- Add the information of the reviewer (Sam)
- Delete unnecessary header files #include <linux/fb.h> (Sam)
- The configDRM_PANEL_BOE_HIMAX8279Dappears twice. Drop one of them (Sam)
- ADD static,set_gpiosfunction is not used outside this module (Sam)V4:
- Frefix all function maes withboe_(Sam)
- Fsed "enable_gpio" replace "reset_gpio", Make it look clearer (Sam)
- Sort include lines alphabetically (Sam)
- Fixed entries in the makefile must be sorted alphabetically (Sam)
- Addsend_mipi_cmdsfunction to avoid duplicating the code (Sam)
- Add the necessarydelay(reset_delay_t5)between reset and sending the initialization command (Rock wang)V3:
- Remove unnecessary delays in sending initialization commands (Jitao Shi)V2:
- Use SPDX identifier (Sam)
- Use necessary header files replacedrmP.h(Sam)
- Delete unnecessary header files #include <linux/err.h> (Sam)
- Specifies a GPIOs array to control the reset timing, instead of reading "dsi-reset-sequence" data from DTS (Sam)
- Deletebacklight_disable()function when already disabled (Sam)
- Usedevm_of_find_backlight()replaceof_find_backlight_by_node()(Sam)
- Move the necessary data in the DTS to the current file, like porch,display_modeand Init code etc. (Sam)
- Add compatible device "boe,himax8279d10p" (Sam)
Quoted 8 lines
V1:
- Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI panel.Signed-off-by Jerry Han <[email protected]>Reviewed-by Sam Ravnborg <[email protected]>Reviewed-by Derek Basehore <[email protected]>Reviewed-by Emil Velikov <[email protected]>
Please don't add tags unless they are explicitly provided by the individual. Namely you're just sending this revision, so I'm yet to review it.
Quoted 61 lines
Cc Jitao Shi <[email protected]>Cc Rock wang <[email protected]>--- MAINTAINERS | 6 + drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 2 + drivers/gpu/drm/panel/panel-boe-himax8279d.c | 990 +++++++++++++++++++ 4 files changed, 1009 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-boe-himax8279d.cMAINTAINERS +6
-0@@ -5135,6 +5135,12 @@ T: git git://anongit.freedesktop.org/drm/drm-misc S: Maintained F: drivers/gpu/drm/bochs/ +DRM DRIVER FOR BOE HIMAX8279D PANELS +M: Jerry Han <[email protected]> +S: Maintained +F: drivers/gpu/drm/panel/panel-boe-himax8279d.c +F: Documentation/devicetree/bindings/display/panel/boe,himax8279d.txt + DRM DRIVER FOR FARADAY TVE200 TV ENCODER M: Linus Walleij <[email protected]> T: git git://anongit.freedesktop.org/drm/drm-miscdrivers/gpu/drm/panel/Kconfig +11
-0@@ -18,6 +18,17 @@ config DRM_PANEL_ARM_VERSATILE reference designs. The panel is detected using special registers in the Versatile family syscon registers. +config DRM_PANEL_BOE_HIMAX8279D + tristate "Boe Himax8279d 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 Boe Himax8279d + TFT-LCD modules. The panel has a 1200x1920 resolution and uses + 24 bit RGB per pixel. It provides a MIPI DSI interface to + the host and has a built-in LED backlight. + config DRM_PANEL_LVDS tristate "Generic LVDS panel driver" depends on OFdrivers/gpu/drm/panel/Makefile +1
-0@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o +obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += panel-feiyang-fy07024di26a30d.o
drivers/gpu/drm/panel/Makefile obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o · line 40
Quoted 4 lines
drivers/gpu/drm/panel/Makefile +1
-0@@ -36,5 +37,6 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.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_BOE_HIMAX8279D) += panel-boe-himax8279d.o
Are you sure this line is needed? The entry is already there, in the prior hunk.
Quoted 28 lines
drivers/gpu/drm/panel/Makefile +0
-0obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.odrivers/gpu/drm/panel/panel-boe-himax8279d.c new file +20
-0@@ -0,0 +1,990 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2019, Huaqin Telecom Technology Co., Ltd +* +* Author: Jerry Han <[email protected]> +* +*/ + +#include <linux/backlight.h> +#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/regulator/consumer.h> + +#include <drm/drm_device.h> +#include <drm/drm_mipi_dsi.h>
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 30
Quoted 10 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +10
-0+#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; +};
Since len is always 1, I'd use
struct panel_cmd {
char cmd;
char data;
};
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 35
Quoted 5 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +5
-0+ +#define _INIT_CMD (...) { \ + .len = sizeof((char[]){__VA_ARGS__}), \ + .data = (char[]){__VA_ARGS__} } +
... and kill this macro.
<snip>
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 71
Quoted 6 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +6
-0+ +static void set_gpios (struct panel_info *pinfo,int enable) +{ +gpiod_set_value (pinfo->enable_gpio, enable); +gpiod_set_value (pinfo->pp33_gpio, enable); +gpiod_set_value (pinfo->pp18_gpio, enable);
Function is always called with "enabled = 0". I lets rename the function to "disable_gpios" and drop the enable argument.
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 82
Quoted 11 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +11
-0+} + +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 ; +
We don't need this check, since cmd will never be NULL.
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 87
Quoted 5 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +5
-0+for (i =0 ; cmds[i].len !=0 ; i++) { +const struct panel_cmd *cmd = &cmds[i]; + + err =mipi_dsi_dcs_write (pinfo->link, cmd->data[0 ], + cmd->data +1 ,1 );
With the above suggestion, this becomes
err = mipi_dsi_dcs_write_buffer(pinfo->link, &cmds[i], sizeof(struct panel_cmd));
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 99
Quoted 12 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +12
-0+ +if (err <0 ) +return err; + } + +return 0 ; +} + +static int boe_panel_disable (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +
if (!pinfo->enabled)
return 0;
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 71
Quoted 2 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +2
-0+backlight_disable (pinfo->backlight); +
IMHO it's nice to call mipi_dsi_dcs_set_display_off() here. Although some drivers do that in unprepare, so feel free to take or leave this comment.
Quoted 9 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +9
-0+ pinfo->enabled = false; + +return 0 ; +} + +static int boe_panel_unprepare (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int err;
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 120
Quoted 10 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +10
-0+ +if (!pinfo->prepared) +return 0 ; + + err = mi`pi_dsi_dcs_set_display_off(pinfo->link); +if (err <0 ) { +DRM_DEV_ERROR (panel->dev,"failed to set display off: %d\n" , + err); + goto poweroff; + }
I'd drop the goto and let the code continue with the teardown.
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 126
Quoted 6 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +6
-0+ + err =mipi_dsi_dcs_enter_sleep_mode (pinfo->link); +if (err <0 ) { +DRM_DEV_ERROR (panel->dev,"failed to enter sleep mode: %d\n" , + err); + goto poweroff;
Same here.
Quoted 4 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +4
-0+ } + +/* sleep_mode_delay: 1ms - 2ms */ +usleep_range (1000 ,2000 );
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 140
Quoted 10 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +10
-0+ +set_gpios (pinfo,0 ); + + pinfo->prepared = false; + +return 0 ; + +poweroff: +set_gpios (pinfo,0 ); +return err;
... and drop the now unused label.
Quoted 7 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +7
-0+} + +static int boe_panel_prepare (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int err; +
...
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 177
Quoted 4 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +4
-0+if (err <0 ) { +DRM_DEV_ERROR (panel->dev,"failed to send DCS Init Code: %d\n" , + err); + goto poweroff;
Let's use something more descriptive, say "disable_gpios"?
<snip>
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 216
Quoted 8 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +8
-0+static int boe_panel_enable (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int ret; + +if (pinfo->enabled) +return 0 ; +
If you like the suggestion in _disable above, them please move the mipi_dsi_dcs_set_display_on + follow-up usleep in here.
Quoted 12 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +12
-0+ ret =backlight_enable (pinfo->backlight); +if (ret) { +DRM_DEV_ERROR (panel->drm->dev, +"Failed to enable backlight %d\n" , ret); +return ret; + } + + pinfo->enabled = true; + +return 0 ; +} +
<snip>
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 861
Quoted 9 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +9
-0+static const struct of_device_id panel_of_match[] = { + { .compatible ="boe,himax8279d8p" , + .data = &boe_himax8279d8p_panel_desc + }, { .compatible ="boe,himax8279d10p" , + .data = &boe_himax8279d10p_panel_desc + }, { +/* sentinel */ + } +};
Style nitpick:
static const struct of_device_id panel_of_match[] = {
{
.compatible = "boe,himax8279d8p",
.data = &boe_himax8279d8p_panel_desc,
},
{
.compatible = "boe,himax8279d10p",
.data = &boe_himax8279d10p_panel_desc,
},
{
/* sentinel */ },
};
Quoted 7 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +7
-0+MODULE_DEVICE_TABLE (of, panel_of_match); + +static int panel_add (struct panel_info *pinfo) +{ +struct device *dev = &pinfo->link->dev; +int ret; +
...
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 908
Quoted 6 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +6
-0+ + ret =drm_panel_add (&pinfo->base); +if (ret <0 ) +return ret; + +return 0 ;
We can drop the ret check here:
return drm_panel_add(&pinfo->base);
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 913
Quoted 5 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +5
-0+} + +static void panel_del (struct panel_info *pinfo) +{ +if (pinfo->base.dev)
Do we need the if check here? If not, let's inline the function.
Quoted 17 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +17
-0+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;
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 940
Quoted 10 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +10
-0+ pinfo->desc = desc; + + pinfo->link = dsi; +mipi_dsi_set_drvdata (dsi, pinfo); + + err =panel_add (pinfo); +if (err <0 ) +return err; + +return mipi_dsi_attach (dsi);
We should call drm_panel_remove() when attach fails.
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 953
Quoted 13 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +13
-0+} + +static int panel_remove (struct mipi_dsi_device *dsi) +{ +struct panel_info *pinfo =mipi_dsi_get_drvdata (dsi); +int err; + + err =boe_panel_unprepare (&pinfo->base); +if (err <0 ) +DRM_DEV_ERROR (&dsi->dev,"failed to unprepare panel: %d\n" , + err); + + err =boe_panel_disable (&pinfo->base);
The sequence should be like in panel_shutdown - aka disable should be called and then unprepare.
HTH
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 430 lines
Hi Jerry,
Quoted 56 lines · Jerry Han
Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI panel.
V9:
- Adjust init code, make the format more concise
- kill offdefault_off_cmds(Emil)
- use mipi_dsi_dcs_set_display_{on,off} in their enable/disable callbacks. (Emil)
- Adjusting the delay function (Emil)V8:
- modifyPARENTHESIS_ALIGNMENTformat (Sam)
- use gpios are required API replace optional gpio API (Emil)V7:
- Modify communication addressV6:
- Add the information of the reviewer
- Remove unnecessary delays, Theudelay_rangecode gracefully returns without hitting the scheduler on a delay of 0. (Derek)
- Merge the same data structures, likedisplay_modeandoff_cmds(Derek)
- Optimize the processing of results returned bydevm_gpiod_get_optional(Derek)V5:
- Add the information of the reviewer (Sam)
- Delete unnecessary header files #include <linux/fb.h> (Sam)
- The configDRM_PANEL_BOE_HIMAX8279Dappears twice. Drop one of them (Sam)
- ADD static,set_gpiosfunction is not used outside this module (Sam)V4:
- Frefix all function maes withboe_(Sam)
- Fsed "enable_gpio" replace "reset_gpio", Make it look clearer (Sam)
- Sort include lines alphabetically (Sam)
- Fixed entries in the makefile must be sorted alphabetically (Sam)
- Addsend_mipi_cmdsfunction to avoid duplicating the code (Sam)
- Add the necessarydelay(reset_delay_t5)between reset and sending the initialization command (Rock wang)V3:
- Remove unnecessary delays in sending initialization commands (Jitao Shi)V2:
- Use SPDX identifier (Sam)
- Use necessary header files replacedrmP.h(Sam)
- Delete unnecessary header files #include <linux/err.h> (Sam)
- Specifies a GPIOs array to control the reset timing, instead of reading "dsi-reset-sequence" data from DTS (Sam)
- Deletebacklight_disable()function when already disabled (Sam)
- Usedevm_of_find_backlight()replaceof_find_backlight_by_node()(Sam)
- Move the necessary data in the DTS to the current file, like porch,display_modeand Init code etc. (Sam)
- Add compatible device "boe,himax8279d10p" (Sam)Quoted 8 lines
V1:
- Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI panel.Signed-off-by Jerry Han <[email protected]>Reviewed-by Sam Ravnborg <[email protected]>Reviewed-by Derek Basehore <[email protected]>Reviewed-by Emil Velikov <[email protected]>Please don't add tags unless they are explicitly provided by the individual. Namely you're just sending this revision, so I'm yet to review it.
Quoted 61 lines
Cc Jitao Shi <[email protected]>Cc Rock wang <[email protected]>--- MAINTAINERS | 6 + drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 2 + drivers/gpu/drm/panel/panel-boe-himax8279d.c | 990 +++++++++++++++++++ 4 files changed, 1009 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-boe-himax8279d.cMAINTAINERS +6
-0@@ -5135,6 +5135,12 @@ T: git git://anongit.freedesktop.org/drm/drm-misc S: Maintained F: drivers/gpu/drm/bochs/ +DRM DRIVER FOR BOE HIMAX8279D PANELS +M: Jerry Han <[email protected]> +S: Maintained +F: drivers/gpu/drm/panel/panel-boe-himax8279d.c +F: Documentation/devicetree/bindings/display/panel/boe,himax8279d.txt + DRM DRIVER FOR FARADAY TVE200 TV ENCODER M: Linus Walleij <[email protected]> T: git git://anongit.freedesktop.org/drm/drm-miscdrivers/gpu/drm/panel/Kconfig +11
-0@@ -18,6 +18,17 @@ config DRM_PANEL_ARM_VERSATILE reference designs. The panel is detected using special registers in the Versatile family syscon registers. +config DRM_PANEL_BOE_HIMAX8279D + tristate "Boe Himax8279d 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 Boe Himax8279d + TFT-LCD modules. The panel has a 1200x1920 resolution and uses + 24 bit RGB per pixel. It provides a MIPI DSI interface to + the host and has a built-in LED backlight. + config DRM_PANEL_LVDS tristate "Generic LVDS panel driver" depends on OFdrivers/gpu/drm/panel/Makefile +1
-0@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o +obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += panel-feiyang-fy07024di26a30d.odrivers/gpu/drm/panel/Makefile obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o · line 40
Quoted 4 lines
drivers/gpu/drm/panel/Makefile +1
-0@@ -36,5 +37,6 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.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_BOE_HIMAX8279D) += panel-boe-himax8279d.oAre you sure this line is needed? The entry is already there, in the prior hunk.
Quoted 28 lines
drivers/gpu/drm/panel/Makefile +0
-0obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.odrivers/gpu/drm/panel/panel-boe-himax8279d.c new file +20
-0@@ -0,0 +1,990 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2019, Huaqin Telecom Technology Co., Ltd +* +* Author: Jerry Han <[email protected]> +* +*/ + +#include <linux/backlight.h> +#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/regulator/consumer.h> + +#include <drm/drm_device.h> +#include <drm/drm_mipi_dsi.h> drivers/gpu/drm/panel/panel-boe-himax8279d.c line 30
Quoted 10 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +10
-0+#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; +};Since len is always 1, I'd use
struct panel_cmd { char cmd; char data; };drivers/gpu/drm/panel/panel-boe-himax8279d.c line 35
Quoted 5 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +5
-0+ +#define _INIT_CMD (...) { \ + .len = sizeof((char[]){__VA_ARGS__}), \ + .data = (char[]){__VA_ARGS__} } +... and kill this macro.
<snip>
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 71
Quoted 6 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +6
-0+ +static void set_gpios (struct panel_info *pinfo,int enable) +{ +gpiod_set_value (pinfo->enable_gpio, enable); +gpiod_set_value (pinfo->pp33_gpio, enable); +gpiod_set_value (pinfo->pp18_gpio, enable);Function is always called with "enabled = 0". I lets rename the function to "
disable_gpios" and drop the enable argument.drivers/gpu/drm/panel/panel-boe-himax8279d.c line 82
Quoted 11 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +11
-0+} + +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 ; +We don't need this check, since cmd will never be NULL.
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 87
Quoted 5 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +5
-0+for (i =0 ; cmds[i].len !=0 ; i++) { +const struct panel_cmd *cmd = &cmds[i]; + + err =mipi_dsi_dcs_write (pinfo->link, cmd->data[0 ], + cmd->data +1 ,1 );With the above suggestion, this becomes
err =mipi_dsi_dcs_write_buffer(pinfo->link, &cmds[i], sizeof(struct panel_cmd));drivers/gpu/drm/panel/panel-boe-himax8279d.c line 99
Quoted 12 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +12
-0+ +if (err <0 ) +return err; + } + +return 0 ; +} + +static int boe_panel_disable (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +if (!pinfo->enabled)
return 0;drivers/gpu/drm/panel/panel-boe-himax8279d.c line 71
Quoted 2 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +2
-0+backlight_disable (pinfo->backlight); +IMHO it's nice to call
mipi_dsi_dcs_set_display_off()here. Although some drivers do that in unprepare, so feel free to take or leave this comment.Quoted 9 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +9
-0+ pinfo->enabled = false; + +return 0 ; +} + +static int boe_panel_unprepare (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int err;drivers/gpu/drm/panel/panel-boe-himax8279d.c line 120
Quoted 10 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +10
-0+ +if (!pinfo->prepared) +return 0 ; + + err = mi`pi_dsi_dcs_set_display_off(pinfo->link); +if (err <0 ) { +DRM_DEV_ERROR (panel->dev,"failed to set display off: %d\n" , + err); + goto poweroff; + }I'd drop the goto and let the code continue with the teardown.
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 126
Quoted 6 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +6
-0+ + err =mipi_dsi_dcs_enter_sleep_mode (pinfo->link); +if (err <0 ) { +DRM_DEV_ERROR (panel->dev,"failed to enter sleep mode: %d\n" , + err); + goto poweroff;Same here.
Quoted 4 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +4
-0+ } + +/* sleep_mode_delay: 1ms - 2ms */ +usleep_range (1000 ,2000 );drivers/gpu/drm/panel/panel-boe-himax8279d.c line 140
Quoted 10 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +10
-0+ +set_gpios (pinfo,0 ); + + pinfo->prepared = false; + +return 0 ; + +poweroff: +set_gpios (pinfo,0 ); +return err;... and drop the now unused label.
Quoted 7 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +7
-0+} + +static int boe_panel_prepare (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int err; +...
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 177
Quoted 4 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +4
-0+if (err <0 ) { +DRM_DEV_ERROR (panel->dev,"failed to send DCS Init Code: %d\n" , + err); + goto poweroff;Let's use something more descriptive, say "
disable_gpios"?<snip>
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 216
Quoted 8 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +8
-0+static int boe_panel_enable (struct drm_panel *panel) +{ +struct panel_info *pinfo =to_panel_info (panel); +int ret; + +if (pinfo->enabled) +return 0 ; +If you like the suggestion in
_disableabove, them please move themipi_dsi_dcs_set_display_on+ follow-up usleep in here.Quoted 12 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +12
-0+ ret =backlight_enable (pinfo->backlight); +if (ret) { +DRM_DEV_ERROR (panel->drm->dev, +"Failed to enable backlight %d\n" , ret); +return ret; + } + + pinfo->enabled = true; + +return 0 ; +} +<snip>
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 861
Quoted 9 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +9
-0+static const struct of_device_id panel_of_match[] = { + { .compatible ="boe,himax8279d8p" , + .data = &boe_himax8279d8p_panel_desc + }, { .compatible ="boe,himax8279d10p" , + .data = &boe_himax8279d10p_panel_desc + }, { +/* sentinel */ + } +};Style nitpick:
static const struct of_device_id panel_of_match[] = { { .compatible = "boe,himax8279d8p", .data = &boe_himax8279d8p_panel_desc, }, { .compatible = "boe,himax8279d10p", .data = &boe_himax8279d10p_panel_desc, }, { /* sentinel */ }, };Quoted 7 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +7
-0+MODULE_DEVICE_TABLE (of, panel_of_match); + +static int panel_add (struct panel_info *pinfo) +{ +struct device *dev = &pinfo->link->dev; +int ret; +...
drivers/gpu/drm/panel/panel-boe-himax8279d.c line 908
Quoted 6 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +6
-0+ + ret =drm_panel_add (&pinfo->base); +if (ret <0 ) +return ret; + +return 0 ;We can drop the ret check here:
returndrm_panel_add(&pinfo->base);drivers/gpu/drm/panel/panel-boe-himax8279d.c line 913
Quoted 5 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +5
-0+} + +static void panel_del (struct panel_info *pinfo) +{ +if (pinfo->base.dev)Do we need the if check here? If not, let's inline the function.
Quoted 17 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +17
-0+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;drivers/gpu/drm/panel/panel-boe-himax8279d.c line 940
Quoted 10 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +10
-0+ pinfo->desc = desc; + + pinfo->link = dsi; +mipi_dsi_set_drvdata (dsi, pinfo); + + err =panel_add (pinfo); +if (err <0 ) +return err; + +return mipi_dsi_attach (dsi);We should call
drm_panel_remove()when attach fails.drivers/gpu/drm/panel/panel-boe-himax8279d.c line 953
Quoted 13 lines
drivers/gpu/drm/panel/panel-boe-himax8279d.c new file +13
-0+} + +static int panel_remove (struct mipi_dsi_device *dsi) +{ +struct panel_info *pinfo =mipi_dsi_get_drvdata (dsi); +int err; + + err =boe_panel_unprepare (&pinfo->base); +if (err <0 ) +DRM_DEV_ERROR (&dsi->dev,"failed to unprepare panel: %d\n" , + err); + + err =boe_panel_disable (&pinfo->base);The sequence should be like in
panel_shutdown- aka disable should be called and then unprepare.
Quoted 2 lines
HTH
Emil
Hi Emil:
Thank you for your valuable advice, let me learn a lot.
I have revised it according to your suggestion, please refer to
my latest submission.
Thanks
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel