Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1570199 > unrolled thread
| Started by | Inki Dae <inki.dae@samsung.com> |
|---|---|
| First post | 2017-01-31 01:10 +0100 |
| Last post | 2017-02-01 06:50 +0100 |
| Articles | 20 on this page of 39 — 11 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <inki.dae@samsung.com> - 2017-01-31 01:10 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-01-31 10:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <inki.dae@samsung.com> - 2017-01-31 10:30 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Andrzej Hajda <a.hajda@samsung.com> - 2017-01-31 13:10 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-02-02 19:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Andrzej Hajda <a.hajda@samsung.com> - 2017-02-03 10:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Daniel Vetter <daniel@ffwll.ch> - 2017-02-03 10:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Andrzej Hajda <a.hajda@samsung.com> - 2017-02-06 10:20 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Daniel Vetter <daniel@ffwll.ch> - 2017-02-06 10:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-02-06 11:40 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Andrzej Hajda <a.hajda@samsung.com> - 2017-02-07 11:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Sean Paul <seanpaul@chromium.org> - 2017-01-31 15:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-01-31 16:10 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Sean Paul <seanpaul@chromium.org> - 2017-01-31 17:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-01-31 22:30 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Emil Velikov <emil.l.velikov@gmail.com> - 2017-01-31 22:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Eric Anholt <eric@anholt.net> - 2017-01-31 19:30 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-01-31 22:40 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Eric Anholt <eric@anholt.net> - 2017-02-01 00:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-02-01 16:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Emil Velikov <emil.l.velikov@gmail.com> - 2017-02-01 16:30 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Sean Paul <seanpaul@chromium.org> - 2017-02-01 20:10 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <inki.dae@samsung.com> - 2017-02-03 06:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <inki.dae@samsung.com> - 2017-02-03 05:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <inki.dae@samsung.com> - 2017-02-01 01:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-02-01 15:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <inki.dae@samsung.com> - 2017-02-02 13:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-02-02 21:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Jani Nikula <jani.nikula@linux.intel.com> - 2017-02-02 16:40 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-02-02 17:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Thierry Reding <thierry.reding@gmail.com> - 2017-01-31 23:00 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Daniel Vetter <daniel@ffwll.ch> - 2017-02-02 15:30 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Krzysztof Kozlowski <krzk@kernel.org> - 2017-01-31 10:30 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <inki.dae@samsung.com> - 2017-01-31 10:40 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Krzysztof Kozlowski <krzk@kernel.org> - 2017-01-31 11:10 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <daeinki@gmail.com> - 2017-01-31 11:50 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Krzysztof Kozlowski <krzk@kernel.org> - 2017-01-31 12:40 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Inki Dae <daeinki@gmail.com> - 2017-01-31 14:10 +0100
Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board Hoegeun Kwon <hoegeun.kwon@samsung.com> - 2017-02-01 06:50 +0100
Page 1 of 2 [1] 2 Next page →
| From | Inki Dae <inki.dae@samsung.com> |
|---|---|
| Date | 2017-01-31 01:10 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5ubg-28G-9@gated-at.bofh.it> |
2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글:
> Dear Thierry,
>
> Could you please review this patch?
Thierry, I think this patch has been reviewed enough but no comment from you. Seems you are busy. I will pick up this.
Thanks.
>
> Best Regards,
> Hoegeun Kwon
>
> On 01/11/2017 03:33 PM, Hoegeun Kwon wrote:
>> This patch add support for MIPI-DSI based S6E3HA2 AMOLED panel
>> driver. This panel has 1440x2560 resolution in 5.7-inch physical
>> panel in the TM2 device.
>>
>> Signed-off-by: Donghwa Lee <dh09.lee@samsung.com>
>> Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
>> Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
>> Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
>> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
>> ---
>> drivers/gpu/drm/panel/Kconfig | 6 +
>> drivers/gpu/drm/panel/Makefile | 1 +
>> drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 754 ++++++++++++++++++++++++++
>> 3 files changed, 761 insertions(+)
>> create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
>>
>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>> index 62aba97..d913c83 100644
>> --- a/drivers/gpu/drm/panel/Kconfig
>> +++ b/drivers/gpu/drm/panel/Kconfig
>> @@ -52,6 +52,12 @@ config DRM_PANEL_PANASONIC_VVX10F034N00
>> WUXGA (1920x1200) Novatek NT1397-based DSI panel as found in some
>> Xperia Z2 tablets
>> +config DRM_PANEL_SAMSUNG_S6E3HA2
>> + tristate "Samsung S6E3HA2 DSI video mode panel"
>> + depends on OF
>> + depends on DRM_MIPI_DSI
>> + select VIDEOMODE_HELPERS
>> +
>> config DRM_PANEL_SAMSUNG_S6E8AA0
>> tristate "Samsung S6E8AA0 DSI video mode panel"
>> depends on OF
>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>> index a5c7ec0..1d483b0 100644
>> --- a/drivers/gpu/drm/panel/Makefile
>> +++ b/drivers/gpu/drm/panel/Makefile
>> @@ -3,6 +3,7 @@ obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o
>> obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
>> obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += panel-panasonic-vvx10f034n00.o
>> obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
>> +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
>> obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
>> obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
>> obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
>> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
>> new file mode 100644
>> index 0000000..0b9c6f4
>> --- /dev/null
>> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
>> @@ -0,0 +1,754 @@
>> +/*
>> + * MIPI-DSI based s6e3ha2 AMOLED 5.7 inch panel driver.
>> + *
>> + * Copyright (c) 2016 Samsung Electronics Co., Ltd.
>> + * Donghwa Lee <dh09.lee@samsung.com>
>> + * Hyungwon Hwang <human.hwang@samsung.com>
>> + * Hoegeun Kwon <hoegeun.kwon@samsung.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +
>> +#include <drm/drmP.h>
>> +#include <drm/drm_mipi_dsi.h>
>> +#include <drm/drm_panel.h>
>> +#include <linux/backlight.h>
>> +#include <linux/gpio/consumer.h>
>> +#include <linux/regulator/consumer.h>
>> +
>> +#define S6E3HA2_MIN_BRIGHTNESS 0
>> +#define S6E3HA2_MAX_BRIGHTNESS 100
>> +#define S6E3HA2_DEFAULT_BRIGHTNESS 80
>> +
>> +#define S6E3HA2_NUM_GAMMA_STEPS 46
>> +#define S6E3HA2_GAMMA_CMD_CNT 35
>> +#define S6E3HA2_VINT_STATUS_MAX 10
>> +
>> +static const u8 gamma_tbl[S6E3HA2_NUM_GAMMA_STEPS][S6E3HA2_GAMMA_CMD_CNT] = {
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x82, 0x83,
>> + 0x85, 0x88, 0x8b, 0x8b, 0x84, 0x88, 0x82, 0x82, 0x89, 0x86, 0x8c,
>> + 0x94, 0x84, 0xb1, 0xaf, 0x8e, 0xcf, 0xad, 0xc9, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x84, 0x84,
>> + 0x85, 0x87, 0x8b, 0x8a, 0x84, 0x88, 0x82, 0x82, 0x89, 0x86, 0x8a,
>> + 0x93, 0x84, 0xb0, 0xae, 0x8e, 0xc9, 0xa8, 0xc5, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>> + 0x85, 0x86, 0x8a, 0x8a, 0x84, 0x88, 0x81, 0x84, 0x8a, 0x88, 0x8a,
>> + 0x91, 0x84, 0xb1, 0xae, 0x8b, 0xd5, 0xb2, 0xcc, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>> + 0x85, 0x86, 0x8a, 0x8a, 0x84, 0x87, 0x81, 0x84, 0x8a, 0x87, 0x8a,
>> + 0x91, 0x85, 0xae, 0xac, 0x8a, 0xc3, 0xa3, 0xc0, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x85, 0x85,
>> + 0x86, 0x85, 0x88, 0x89, 0x84, 0x89, 0x82, 0x84, 0x87, 0x85, 0x8b,
>> + 0x91, 0x88, 0xad, 0xab, 0x8a, 0xb7, 0x9b, 0xb6, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>> + 0x85, 0x86, 0x89, 0x8a, 0x84, 0x89, 0x83, 0x83, 0x86, 0x84, 0x8b,
>> + 0x90, 0x84, 0xb0, 0xae, 0x8b, 0xce, 0xad, 0xc8, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>> + 0x85, 0x87, 0x89, 0x8a, 0x83, 0x87, 0x82, 0x85, 0x88, 0x87, 0x89,
>> + 0x8f, 0x84, 0xac, 0xaa, 0x89, 0xb1, 0x98, 0xaf, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>> + 0x85, 0x86, 0x88, 0x89, 0x84, 0x88, 0x83, 0x82, 0x85, 0x84, 0x8c,
>> + 0x91, 0x86, 0xac, 0xaa, 0x89, 0xc2, 0xa5, 0xbd, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>> + 0x85, 0x87, 0x89, 0x8a, 0x83, 0x87, 0x82, 0x85, 0x88, 0x87, 0x88,
>> + 0x8b, 0x82, 0xad, 0xaa, 0x8a, 0xc2, 0xa5, 0xbd, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x88, 0x83, 0x82, 0x85, 0x84, 0x8a,
>> + 0x8e, 0x84, 0xae, 0xac, 0x89, 0xda, 0xb7, 0xd0, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x88, 0x83, 0x80, 0x83, 0x82, 0x8b,
>> + 0x8e, 0x85, 0xac, 0xaa, 0x89, 0xc8, 0xaa, 0xc1, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>> + 0x85, 0x86, 0x87, 0x89, 0x81, 0x85, 0x81, 0x84, 0x86, 0x84, 0x8c,
>> + 0x8c, 0x84, 0xa9, 0xa8, 0x87, 0xa3, 0x92, 0xa1, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x86, 0x83, 0x80, 0x83, 0x81, 0x8c,
>> + 0x8d, 0x84, 0xaa, 0xaa, 0x89, 0xce, 0xaf, 0xc5, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>> + 0x85, 0x86, 0x87, 0x89, 0x81, 0x83, 0x80, 0x83, 0x85, 0x85, 0x8c,
>> + 0x8c, 0x84, 0xa8, 0xa8, 0x88, 0xb5, 0x9f, 0xb0, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>> + 0x86, 0x86, 0x87, 0x88, 0x81, 0x83, 0x80, 0x83, 0x85, 0x85, 0x8c,
>> + 0x8b, 0x84, 0xab, 0xa8, 0x86, 0xd4, 0xb4, 0xc9, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>> + 0x86, 0x86, 0x87, 0x88, 0x81, 0x83, 0x80, 0x84, 0x84, 0x85, 0x8b,
>> + 0x8a, 0x83, 0xa6, 0xa5, 0x84, 0xbb, 0xa4, 0xb3, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>> + 0x86, 0x85, 0x86, 0x86, 0x82, 0x85, 0x81, 0x82, 0x83, 0x84, 0x8e,
>> + 0x8b, 0x83, 0xa4, 0xa3, 0x8a, 0xa1, 0x93, 0x9d, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
>> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x82, 0x82, 0x84, 0x8e,
>> + 0x8b, 0x83, 0xa4, 0xa2, 0x86, 0xc1, 0xa9, 0xb7, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
>> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x82, 0x82, 0x84, 0x8d,
>> + 0x89, 0x82, 0xa2, 0xa1, 0x84, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
>> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x83, 0x83, 0x85, 0x8c,
>> + 0x87, 0x7f, 0xa2, 0x9d, 0x88, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xbb, 0x00, 0xc5, 0x00, 0xb4, 0x87, 0x86, 0x86, 0x84, 0x83,
>> + 0x86, 0x87, 0x87, 0x87, 0x80, 0x82, 0x7f, 0x86, 0x86, 0x88, 0x8a,
>> + 0x84, 0x7e, 0x9d, 0x9c, 0x82, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xbd, 0x00, 0xc7, 0x00, 0xb7, 0x87, 0x85, 0x85, 0x84, 0x83,
>> + 0x86, 0x86, 0x86, 0x88, 0x81, 0x83, 0x80, 0x83, 0x84, 0x85, 0x8a,
>> + 0x85, 0x7e, 0x9c, 0x9b, 0x85, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xc0, 0x00, 0xca, 0x00, 0xbb, 0x87, 0x86, 0x85, 0x83, 0x83,
>> + 0x85, 0x86, 0x86, 0x88, 0x81, 0x83, 0x80, 0x84, 0x85, 0x86, 0x89,
>> + 0x83, 0x7d, 0x9c, 0x99, 0x87, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xc4, 0x00, 0xcd, 0x00, 0xbe, 0x87, 0x86, 0x85, 0x83, 0x83,
>> + 0x86, 0x85, 0x85, 0x87, 0x81, 0x82, 0x80, 0x82, 0x82, 0x83, 0x8a,
>> + 0x85, 0x7f, 0x9f, 0x9b, 0x86, 0xb4, 0xa1, 0xac, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xc7, 0x00, 0xd0, 0x00, 0xc2, 0x87, 0x85, 0x85, 0x83, 0x82,
>> + 0x85, 0x85, 0x85, 0x86, 0x82, 0x83, 0x80, 0x82, 0x82, 0x84, 0x87,
>> + 0x86, 0x80, 0x9e, 0x9a, 0x87, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xca, 0x00, 0xd2, 0x00, 0xc5, 0x87, 0x85, 0x84, 0x82, 0x82,
>> + 0x84, 0x85, 0x85, 0x86, 0x81, 0x82, 0x7f, 0x82, 0x82, 0x84, 0x88,
>> + 0x86, 0x81, 0x9d, 0x98, 0x86, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xce, 0x00, 0xd6, 0x00, 0xca, 0x86, 0x85, 0x84, 0x83, 0x83,
>> + 0x85, 0x84, 0x84, 0x85, 0x81, 0x82, 0x80, 0x81, 0x81, 0x82, 0x89,
>> + 0x86, 0x81, 0x9c, 0x97, 0x86, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xd1, 0x00, 0xd9, 0x00, 0xce, 0x86, 0x84, 0x83, 0x83, 0x82,
>> + 0x85, 0x85, 0x85, 0x86, 0x81, 0x83, 0x81, 0x82, 0x82, 0x83, 0x86,
>> + 0x83, 0x7f, 0x99, 0x95, 0x86, 0xbb, 0xa4, 0xb3, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xd4, 0x00, 0xdb, 0x00, 0xd1, 0x86, 0x85, 0x83, 0x83, 0x82,
>> + 0x85, 0x84, 0x84, 0x85, 0x80, 0x83, 0x82, 0x80, 0x80, 0x81, 0x87,
>> + 0x84, 0x81, 0x98, 0x93, 0x85, 0xae, 0x9c, 0xa8, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xd8, 0x00, 0xde, 0x00, 0xd6, 0x86, 0x84, 0x83, 0x81, 0x81,
>> + 0x83, 0x85, 0x85, 0x85, 0x82, 0x83, 0x81, 0x81, 0x81, 0x83, 0x86,
>> + 0x84, 0x80, 0x98, 0x91, 0x85, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xdc, 0x00, 0xe2, 0x00, 0xda, 0x85, 0x84, 0x83, 0x82, 0x82,
>> + 0x84, 0x84, 0x84, 0x85, 0x81, 0x82, 0x82, 0x80, 0x80, 0x81, 0x83,
>> + 0x82, 0x7f, 0x99, 0x93, 0x86, 0x94, 0x8b, 0x92, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xdf, 0x00, 0xe5, 0x00, 0xde, 0x85, 0x84, 0x82, 0x82, 0x82,
>> + 0x84, 0x83, 0x83, 0x84, 0x81, 0x81, 0x80, 0x83, 0x82, 0x84, 0x82,
>> + 0x81, 0x7f, 0x99, 0x92, 0x86, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>> + 0x82, 0x83, 0x83, 0x84, 0x80, 0x81, 0x80, 0x83, 0x83, 0x84, 0x80,
>> + 0x81, 0x7c, 0x99, 0x92, 0x87, 0xa1, 0x93, 0x9d, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x85, 0x84, 0x83, 0x81, 0x81,
>> + 0x82, 0x82, 0x82, 0x83, 0x80, 0x81, 0x80, 0x81, 0x80, 0x82, 0x83,
>> + 0x82, 0x80, 0x91, 0x8d, 0x83, 0x9a, 0x90, 0x96, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>> + 0x82, 0x83, 0x83, 0x84, 0x80, 0x81, 0x80, 0x81, 0x80, 0x82, 0x83,
>> + 0x81, 0x7f, 0x91, 0x8c, 0x82, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>> + 0x82, 0x83, 0x83, 0x83, 0x82, 0x82, 0x81, 0x81, 0x80, 0x82, 0x82,
>> + 0x82, 0x7f, 0x94, 0x89, 0x84, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>> + 0x82, 0x83, 0x83, 0x83, 0x82, 0x82, 0x81, 0x81, 0x80, 0x82, 0x83,
>> + 0x82, 0x7f, 0x91, 0x85, 0x81, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>> + 0x82, 0x83, 0x83, 0x83, 0x80, 0x80, 0x7f, 0x83, 0x82, 0x84, 0x83,
>> + 0x82, 0x7f, 0x90, 0x84, 0x81, 0x9a, 0x90, 0x96, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x80, 0x80,
>> + 0x82, 0x83, 0x83, 0x83, 0x80, 0x80, 0x7f, 0x80, 0x80, 0x81, 0x81,
>> + 0x82, 0x83, 0x7e, 0x80, 0x7c, 0xa4, 0x97, 0x9f, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xe9, 0x00, 0xec, 0x00, 0xe8, 0x84, 0x83, 0x82, 0x81, 0x81,
>> + 0x82, 0x82, 0x82, 0x83, 0x7f, 0x7f, 0x7f, 0x81, 0x80, 0x82, 0x83,
>> + 0x83, 0x84, 0x79, 0x7c, 0x79, 0xb1, 0xa0, 0xaa, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xed, 0x00, 0xf0, 0x00, 0xec, 0x83, 0x83, 0x82, 0x80, 0x80,
>> + 0x81, 0x82, 0x82, 0x82, 0x7f, 0x7f, 0x7e, 0x81, 0x81, 0x82, 0x80,
>> + 0x81, 0x81, 0x84, 0x84, 0x83, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xf1, 0x00, 0xf4, 0x00, 0xf1, 0x83, 0x82, 0x82, 0x80, 0x80,
>> + 0x81, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x7d,
>> + 0x7e, 0x7f, 0x84, 0x84, 0x83, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf5, 0x82, 0x82, 0x81, 0x80, 0x80,
>> + 0x80, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x7f, 0x7f, 0x7f, 0x82,
>> + 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x00, 0xfa, 0x00, 0xfb, 0x00, 0xfa, 0x81, 0x81, 0x81, 0x80, 0x80,
>> + 0x80, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 },
>> + { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>> + 0x00, 0x00 }
>> +};
>> +
>> +unsigned char vint_table[S6E3HA2_VINT_STATUS_MAX] = {
>> + 0x18, 0x19, 0x1a, 0x1b, 0x1c,
>> + 0x1d, 0x1e, 0x1f, 0x20, 0x21
>> +};
>> +
>> +struct s6e3ha2 {
>> + struct device *dev;
>> + struct drm_panel panel;
>> + struct backlight_device *bl_dev;
>> +
>> + struct regulator_bulk_data supplies[2];
>> + struct gpio_desc *reset_gpio;
>> + struct gpio_desc *enable_gpio;
>> +
>> + /* This field is tested by functions directly accessing DSI bus before
>> + * transfer, transfer is skipped if it is set. In case of transfer
>> + * failure or unexpected response the field is set to error value.
>> + * Such construct allows to eliminate many checks in higher level
>> + * functions.
>> + */
>> + int error;
>> +};
>> +
>> +static int s6e3ha2_clear_error(struct s6e3ha2 *ctx)
>> +{
>> + int ret = ctx->error;
>> +
>> + ctx->error = 0;
>> + return ret;
>> +}
>> +
>> +static void s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const void *data, size_t len)
>> +{
>> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>> + ssize_t ret;
>> +
>> + if (ctx->error < 0)
>> + return;
>> +
>> + ret = mipi_dsi_dcs_write_buffer(dsi, data, len);
>> + if (ret < 0) {
>> + dev_err(ctx->dev, "error %zd writing dcs seq: %*ph\n",
>> + ret, (int)len, data);
>> + ctx->error = ret;
>> + }
>> +}
>> +
>> +#define s6e3ha2_dcs_write_seq_static(ctx, seq...) do { \
>> + static const u8 d[] = { seq }; \
>> + s6e3ha2_dcs_write(ctx, d, ARRAY_SIZE(d)); \
>> +} while (0)
>> +
>> +static void s6e3ha2_test_key_on_f0(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0x5a, 0x5a);
>> +}
>> +
>> +static void s6e3ha2_test_key_off_f0(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0xa5, 0xa5);
>> +}
>> +
>> +static void s6e3ha2_test_key_on_fc(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0x5a, 0x5a);
>> +}
>> +
>> +static void s6e3ha2_test_key_off_fc(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0xa5, 0xa5);
>> +}
>> +
>> +static void s6e3ha2_single_dsi_set(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf2, 0x67);
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf9, 0x09);
>> +}
>> +
>> +static void s6e3ha2_freq_calibration(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfd, 0x1c);
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20, 0x39);
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0xa0);
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20);
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x12, 0x62,
>> + 0x40, 0x80, 0xc0, 0x28, 0x28, 0x28, 0x28, 0x39, 0xc5);
>> +}
>> +
>> +static void s6e3ha2_aor_control(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb2, 0x03, 0x10);
>> +}
>> +
>> +static void s6e3ha2_caps_elvss_set(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb6, 0x9c, 0x0a);
>> +}
>> +
>> +static void s6e3ha2_acl_off(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0x55, 0x00);
>> +}
>> +
>> +static void s6e3ha2_acl_off_opr(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb5, 0x40);
>> +}
>> +
>> +static void s6e3ha2_test_global(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x07);
>> +}
>> +
>> +static void s6e3ha2_test(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb8, 0x19);
>> +}
>> +
>> +static void s6e3ha2_touch_hsync_on1(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx,
>> + 0xbd, 0x33, 0x11, 0x02, 0x16, 0x02, 0x16);
>> +}
>> +
>> +static void s6e3ha2_pentile_control(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xc0, 0x00, 0x00, 0xd8, 0xd8);
>> +}
>> +
>> +static void s6e3ha2_poc_global(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x20);
>> +}
>> +
>> +static void s6e3ha2_poc_setting(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x08);
>> +}
>> +
>> +static void s6e3ha2_pcd_set_off(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xcc, 0x40, 0x51);
>> +}
>> +
>> +static void s6e3ha2_err_fg_set(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xed, 0x44);
>> +}
>> +
>> +static void s6e3ha2_hbm_off(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0x53, 0x00);
>> +}
>> +
>> +static void s6e3ha2_te_start_setting(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb9, 0x10, 0x09, 0xff, 0x00, 0x09);
>> +}
>> +
>> +static void s6e3ha2_gamma_update(struct s6e3ha2 *ctx)
>> +{
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x03);
>> + ndelay(100); /* need for 100ns delay */
>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x00);
>> +}
>> +
>> +static int s6e3ha2_get_brightness(struct backlight_device *bl_dev)
>> +{
>> + return bl_dev->props.brightness;
>> +}
>> +
>> +static void s6e3ha2_set_vint(struct s6e3ha2 *ctx)
>> +{
>> + struct backlight_device *bl_dev = ctx->bl_dev;
>> + unsigned int brightness = bl_dev->props.brightness;
>> + unsigned char data[] = { 0xf4, 0x8b,
>> + vint_table[brightness * (S6E3HA2_VINT_STATUS_MAX - 1) /
>> + S6E3HA2_MAX_BRIGHTNESS] };
>> +
>> + s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data));
>> +}
>> +
>> +static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness)
>> +{
>> + return (brightness * (S6E3HA2_NUM_GAMMA_STEPS - 1)) /
>> + S6E3HA2_MAX_BRIGHTNESS;
>> +}
>> +
>> +static int s6e3ha2_update_gamma(struct s6e3ha2 *ctx, unsigned int brightness)
>> +{
>> + struct backlight_device *bl_dev = ctx->bl_dev;
>> + unsigned int index = s6e3ha2_get_brightness_index(brightness);
>> + u8 data[S6E3HA2_GAMMA_CMD_CNT + 1] = { 0xca, };
>> +
>> + memcpy(data + 1, gamma_tbl + index, S6E3HA2_GAMMA_CMD_CNT);
>> + s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data));
>> +
>> + s6e3ha2_gamma_update(ctx);
>> + bl_dev->props.brightness = brightness;
>> +
>> + return 0;
>> +}
>> +
>> +static int s6e3ha2_set_brightness(struct backlight_device *bl_dev)
>> +{
>> + struct s6e3ha2 *ctx = bl_get_data(bl_dev);
>> + unsigned int brightness = bl_dev->props.brightness;
>> +
>> + if (brightness < S6E3HA2_MIN_BRIGHTNESS ||
>> + brightness > bl_dev->props.max_brightness) {
>> + dev_err(ctx->dev, "Invalid brightness: %u\n", brightness);
>> + return -EINVAL;
>> + }
>> +
>> + if (bl_dev->props.power > FB_BLANK_NORMAL)
>> + return -EPERM;
>> +
>> + s6e3ha2_test_key_on_f0(ctx);
>> + s6e3ha2_update_gamma(ctx, brightness);
>> + s6e3ha2_aor_control(ctx);
>> + s6e3ha2_set_vint(ctx);
>> + s6e3ha2_test_key_off_f0(ctx);
>> +
>> + return ctx->error;
>> +}
>> +
>> +static const struct backlight_ops s6e3ha2_bl_ops = {
>> + .get_brightness = s6e3ha2_get_brightness,
>> + .update_status = s6e3ha2_set_brightness,
>> +};
>> +
>> +static int s6e3ha2_panel_init(struct s6e3ha2 *ctx)
>> +{
>> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>> + int ret;
>> +
>> + ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
>> + if (ret < 0)
>> + return ret;
>> + usleep_range(5000, 6000);
>> +
>> + s6e3ha2_test_key_on_f0(ctx);
>> + s6e3ha2_single_dsi_set(ctx);
>> + s6e3ha2_test_key_on_fc(ctx);
>> + s6e3ha2_freq_calibration(ctx);
>> + s6e3ha2_test_key_off_fc(ctx);
>> + s6e3ha2_test_key_off_f0(ctx);
>> +
>> + return 0;
>> +}
>> +
>> +static int s6e3ha2_power_off(struct s6e3ha2 *ctx)
>> +{
>> + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
>> +}
>> +
>> +static int s6e3ha2_disable(struct drm_panel *panel)
>> +{
>> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
>> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>> + int ret;
>> +
>> + ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
>> + if (ret < 0)
>> + return ret;
>> +
>> + ret = mipi_dsi_dcs_set_display_off(dsi);
>> + if (ret < 0)
>> + return ret;
>> +
>> + msleep(40);
>> + ctx->bl_dev->props.power = FB_BLANK_NORMAL;
>> +
>> + return 0;
>> +}
>> +
>> +static int s6e3ha2_unprepare(struct drm_panel *panel)
>> +{
>> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
>> + int ret;
>> +
>> + ret = s6e3ha2_clear_error(ctx);
>> + if (!ret)
>> + ctx->bl_dev->props.power = FB_BLANK_POWERDOWN;
>> +
>> + return s6e3ha2_power_off(ctx);
>> +}
>> +
>> +static int s6e3ha2_power_on(struct s6e3ha2 *ctx)
>> +{
>> + int ret;
>> +
>> + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
>> + if (ret < 0)
>> + return ret;
>> +
>> + msleep(120);
>> +
>> + gpiod_set_value(ctx->enable_gpio, 0);
>> + usleep_range(5000, 6000);
>> + gpiod_set_value(ctx->enable_gpio, 1);
>> +
>> + gpiod_set_value(ctx->reset_gpio, 1);
>> + usleep_range(5000, 6000);
>> + gpiod_set_value(ctx->reset_gpio, 0);
>> + usleep_range(5000, 6000);
>> +
>> + return 0;
>> +}
>> +static int s6e3ha2_prepare(struct drm_panel *panel)
>> +{
>> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
>> + int ret;
>> +
>> + ret = s6e3ha2_power_on(ctx);
>> + if (ret < 0)
>> + return ret;
>> +
>> + ret = s6e3ha2_panel_init(ctx);
>> + if (ret < 0)
>> + goto err;
>> +
>> + ret = s6e3ha2_clear_error(ctx);
>> + if (ret < 0)
>> + goto err;
>> +
>> + ctx->bl_dev->props.power = FB_BLANK_NORMAL;
>> +
>> + return 0;
>> +
>> +err:
>> + s6e3ha2_power_off(ctx);
>> + return ret;
>> +}
>> +
>> +static int s6e3ha2_enable(struct drm_panel *panel)
>> +{
>> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
>> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>> + int ret;
>> +
>> + /* common setting */
>> + ret = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
>> + if (ret < 0)
>> + return ret;
>> +
>> + s6e3ha2_test_key_on_f0(ctx);
>> + s6e3ha2_test_key_on_fc(ctx);
>> + s6e3ha2_touch_hsync_on1(ctx);
>> + s6e3ha2_pentile_control(ctx);
>> + s6e3ha2_poc_global(ctx);
>> + s6e3ha2_poc_setting(ctx);
>> + s6e3ha2_test_key_off_fc(ctx);
>> +
>> + /* pcd setting off for TB */
>> + s6e3ha2_pcd_set_off(ctx);
>> + s6e3ha2_err_fg_set(ctx);
>> + s6e3ha2_te_start_setting(ctx);
>> +
>> + /* brightness setting */
>> + s6e3ha2_set_brightness(ctx->bl_dev);
>> + s6e3ha2_aor_control(ctx);
>> + s6e3ha2_caps_elvss_set(ctx);
>> + s6e3ha2_gamma_update(ctx);
>> + s6e3ha2_acl_off(ctx);
>> + s6e3ha2_acl_off_opr(ctx);
>> + s6e3ha2_hbm_off(ctx);
>> +
>> + /* elvss temp compensation */
>> + s6e3ha2_test_global(ctx);
>> + s6e3ha2_test(ctx);
>> + s6e3ha2_test_key_off_f0(ctx);
>> +
>> + if (ctx->error != 0)
>> + return ctx->error;
>> +
>> + ret = mipi_dsi_dcs_set_display_on(dsi);
>> + if (ret < 0)
>> + return ret;
>> +
>> + ctx->bl_dev->props.power = FB_BLANK_UNBLANK;
>> +
>> + return 0;
>> +}
>> +
>> +static const struct drm_display_mode default_mode = {
>> + .clock = 222372,
>> + .hdisplay = 1440,
>> + .hsync_start = 1440 + 1,
>> + .hsync_end = 1440 + 1 + 1,
>> + .htotal = 1440 + 1 + 1 + 1,
>> + .vdisplay = 2560,
>> + .vsync_start = 2560 + 1,
>> + .vsync_end = 2560 + 1 + 1,
>> + .vtotal = 2560 + 1 + 1 + 15,
>> + .vrefresh = 60,
>> + .flags = 0,
>> +};
>> +
>> +static int s6e3ha2_get_modes(struct drm_panel *panel)
>> +{
>> + struct drm_connector *connector = panel->connector;
>> + struct drm_display_mode *mode;
>> +
>> + mode = drm_mode_duplicate(panel->drm, &default_mode);
>> + if (!mode) {
>> + DRM_ERROR("failed to add mode %ux%ux@%u\n",
>> + default_mode.hdisplay, default_mode.vdisplay,
>> + default_mode.vrefresh);
>> + return -ENOMEM;
>> + }
>> +
>> + drm_mode_set_name(mode);
>> +
>> + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
>> + drm_mode_probed_add(connector, mode);
>> +
>> + connector->display_info.width_mm = 71;
>> + connector->display_info.height_mm = 125;
>> +
>> + return 1;
>> +}
>> +
>> +static const struct drm_panel_funcs s6e3ha2_drm_funcs = {
>> + .disable = s6e3ha2_disable,
>> + .unprepare = s6e3ha2_unprepare,
>> + .prepare = s6e3ha2_prepare,
>> + .enable = s6e3ha2_enable,
>> + .get_modes = s6e3ha2_get_modes,
>> +};
>> +
>> +static int s6e3ha2_probe(struct mipi_dsi_device *dsi)
>> +{
>> + struct device *dev = &dsi->dev;
>> + struct s6e3ha2 *ctx;
>> + int ret;
>> +
>> + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
>> + if (!ctx)
>> + return -ENOMEM;
>> +
>> + mipi_dsi_set_drvdata(dsi, ctx);
>> +
>> + ctx->dev = dev;
>> +
>> + dsi->lanes = 4;
>> + dsi->format = MIPI_DSI_FMT_RGB888;
>> + dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS;
>> +
>> + ctx->supplies[0].supply = "vdd3";
>> + ctx->supplies[1].supply = "vci";
>> +
>> + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
>> + ctx->supplies);
>> + if (ret < 0) {
>> + dev_err(dev, "failed to get regulators: %d\n", ret);
>> + return ret;
>> + }
>> +
>> + ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
>> + if (IS_ERR(ctx->reset_gpio)) {
>> + dev_err(dev, "cannot get reset-gpios %ld\n",
>> + PTR_ERR(ctx->reset_gpio));
>> + return PTR_ERR(ctx->reset_gpio);
>> + }
>> +
>> + ctx->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
>> + if (IS_ERR(ctx->enable_gpio)) {
>> + dev_err(dev, "cannot get enable-gpios %ld\n",
>> + PTR_ERR(ctx->enable_gpio));
>> + return PTR_ERR(ctx->enable_gpio);
>> + }
>> +
>> + ctx->bl_dev = backlight_device_register("s6e3ha2", dev, ctx,
>> + &s6e3ha2_bl_ops, NULL);
>> + if (IS_ERR(ctx->bl_dev)) {
>> + dev_err(dev, "failed to register backlight device\n");
>> + return PTR_ERR(ctx->bl_dev);
>> + }
>> +
>> + ctx->bl_dev->props.max_brightness = S6E3HA2_MAX_BRIGHTNESS;
>> + ctx->bl_dev->props.brightness = S6E3HA2_DEFAULT_BRIGHTNESS;
>> + ctx->bl_dev->props.power = FB_BLANK_POWERDOWN;
>> +
>> + drm_panel_init(&ctx->panel);
>> + ctx->panel.dev = dev;
>> + ctx->panel.funcs = &s6e3ha2_drm_funcs;
>> +
>> + ret = drm_panel_add(&ctx->panel);
>> + if (ret < 0)
>> + goto unregister_backlight;
>> +
>> + ret = mipi_dsi_attach(dsi);
>> + if (ret < 0)
>> + goto remove_panel;
>> +
>> + return ret;
>> +
>> +remove_panel:
>> + drm_panel_remove(&ctx->panel);
>> +
>> +unregister_backlight:
>> + backlight_device_unregister(ctx->bl_dev);
>> +
>> + return ret;
>> +}
>> +
>> +static int s6e3ha2_remove(struct mipi_dsi_device *dsi)
>> +{
>> + struct s6e3ha2 *ctx = mipi_dsi_get_drvdata(dsi);
>> +
>> + mipi_dsi_detach(dsi);
>> + drm_panel_remove(&ctx->panel);
>> + backlight_device_unregister(ctx->bl_dev);
>> +
>> + return 0;
>> +}
>> +
>> +static const struct of_device_id s6e3ha2_of_match[] = {
>> + { .compatible = "samsung,s6e3ha2" },
>> + { }
>> +};
>> +MODULE_DEVICE_TABLE(of, s6e3ha2_of_match);
>> +
>> +static struct mipi_dsi_driver s6e3ha2_driver = {
>> + .probe = s6e3ha2_probe,
>> + .remove = s6e3ha2_remove,
>> + .driver = {
>> + .name = "panel-samsung-s6e3ha2",
>> + .of_match_table = s6e3ha2_of_match,
>> + },
>> +};
>> +module_mipi_dsi_driver(s6e3ha2_driver);
>> +
>> +MODULE_AUTHOR("Donghwa Lee <dh09.lee@samsung.com>");
>> +MODULE_AUTHOR("Hyungwon Hwang <human.hwang@samsung.com>");
>> +MODULE_AUTHOR("Hoegeun Kwon <hoegeun.kwon@samsung.com>");
>> +MODULE_DESCRIPTION("MIPI-DSI based s6e3ha2 AMOLED Panel Driver");
>> +MODULE_LICENSE("GPL v2");
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
[toc] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2017-01-31 10:00 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5Csb-70d-41@gated-at.bofh.it> |
| In reply to | #1570199 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote:
>
>
> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글:
> > Dear Thierry,
> >
> > Could you please review this patch?
>
> Thierry, I think this patch has been reviewed enough but no comment
> from you. Seems you are busy. I will pick up this.
Sorry, but that's not how it works. This patch has gone through 8
revisions within 4 weeks, and I tend to ignore patches like that until
the dust settles.
Other than that, this continues the same madness that I've repeatedly
complained about in the past. The whole mechanism of running through a
series of writes and not caring about errors until the very end is
something we've discussed at length in the past. It also in large parts
duplicates a bunch of functions from other Samsung panel drivers that I
already said should eventually be moved to something saner.
This is now the third driver and nobody's giving a damn about improving
things.
Until somebody does, I'm going to have to NAK this.
Thierry
> > On 01/11/2017 03:33 PM, Hoegeun Kwon wrote:
> >> This patch add support for MIPI-DSI based S6E3HA2 AMOLED panel
> >> driver. This panel has 1440x2560 resolution in 5.7-inch physical
> >> panel in the TM2 device.
> >>
> >> Signed-off-by: Donghwa Lee <dh09.lee@samsung.com>
> >> Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
> >> Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
> >> Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
> >> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
> >> ---
> >> drivers/gpu/drm/panel/Kconfig | 6 +
> >> drivers/gpu/drm/panel/Makefile | 1 +
> >> drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 754 ++++++++++++++++++++++++++
> >> 3 files changed, 761 insertions(+)
> >> create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
> >>
> >> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> >> index 62aba97..d913c83 100644
> >> --- a/drivers/gpu/drm/panel/Kconfig
> >> +++ b/drivers/gpu/drm/panel/Kconfig
> >> @@ -52,6 +52,12 @@ config DRM_PANEL_PANASONIC_VVX10F034N00
> >> WUXGA (1920x1200) Novatek NT1397-based DSI panel as found in some
> >> Xperia Z2 tablets
> >> +config DRM_PANEL_SAMSUNG_S6E3HA2
> >> + tristate "Samsung S6E3HA2 DSI video mode panel"
> >> + depends on OF
> >> + depends on DRM_MIPI_DSI
> >> + select VIDEOMODE_HELPERS
> >> +
> >> config DRM_PANEL_SAMSUNG_S6E8AA0
> >> tristate "Samsung S6E8AA0 DSI video mode panel"
> >> depends on OF
> >> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> >> index a5c7ec0..1d483b0 100644
> >> --- a/drivers/gpu/drm/panel/Makefile
> >> +++ b/drivers/gpu/drm/panel/Makefile
> >> @@ -3,6 +3,7 @@ obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o
> >> obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
> >> obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += panel-panasonic-vvx10f034n00.o
> >> obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
> >> +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
> >> obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
> >> obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
> >> obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
> >> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
> >> new file mode 100644
> >> index 0000000..0b9c6f4
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
> >> @@ -0,0 +1,754 @@
> >> +/*
> >> + * MIPI-DSI based s6e3ha2 AMOLED 5.7 inch panel driver.
> >> + *
> >> + * Copyright (c) 2016 Samsung Electronics Co., Ltd.
> >> + * Donghwa Lee <dh09.lee@samsung.com>
> >> + * Hyungwon Hwang <human.hwang@samsung.com>
> >> + * Hoegeun Kwon <hoegeun.kwon@samsung.com>
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundation.
> >> + */
> >> +
> >> +#include <drm/drmP.h>
> >> +#include <drm/drm_mipi_dsi.h>
> >> +#include <drm/drm_panel.h>
> >> +#include <linux/backlight.h>
> >> +#include <linux/gpio/consumer.h>
> >> +#include <linux/regulator/consumer.h>
> >> +
> >> +#define S6E3HA2_MIN_BRIGHTNESS 0
> >> +#define S6E3HA2_MAX_BRIGHTNESS 100
> >> +#define S6E3HA2_DEFAULT_BRIGHTNESS 80
> >> +
> >> +#define S6E3HA2_NUM_GAMMA_STEPS 46
> >> +#define S6E3HA2_GAMMA_CMD_CNT 35
> >> +#define S6E3HA2_VINT_STATUS_MAX 10
> >> +
> >> +static const u8 gamma_tbl[S6E3HA2_NUM_GAMMA_STEPS][S6E3HA2_GAMMA_CMD_CNT] = {
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x82, 0x83,
> >> + 0x85, 0x88, 0x8b, 0x8b, 0x84, 0x88, 0x82, 0x82, 0x89, 0x86, 0x8c,
> >> + 0x94, 0x84, 0xb1, 0xaf, 0x8e, 0xcf, 0xad, 0xc9, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x84, 0x84,
> >> + 0x85, 0x87, 0x8b, 0x8a, 0x84, 0x88, 0x82, 0x82, 0x89, 0x86, 0x8a,
> >> + 0x93, 0x84, 0xb0, 0xae, 0x8e, 0xc9, 0xa8, 0xc5, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
> >> + 0x85, 0x86, 0x8a, 0x8a, 0x84, 0x88, 0x81, 0x84, 0x8a, 0x88, 0x8a,
> >> + 0x91, 0x84, 0xb1, 0xae, 0x8b, 0xd5, 0xb2, 0xcc, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
> >> + 0x85, 0x86, 0x8a, 0x8a, 0x84, 0x87, 0x81, 0x84, 0x8a, 0x87, 0x8a,
> >> + 0x91, 0x85, 0xae, 0xac, 0x8a, 0xc3, 0xa3, 0xc0, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x85, 0x85,
> >> + 0x86, 0x85, 0x88, 0x89, 0x84, 0x89, 0x82, 0x84, 0x87, 0x85, 0x8b,
> >> + 0x91, 0x88, 0xad, 0xab, 0x8a, 0xb7, 0x9b, 0xb6, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
> >> + 0x85, 0x86, 0x89, 0x8a, 0x84, 0x89, 0x83, 0x83, 0x86, 0x84, 0x8b,
> >> + 0x90, 0x84, 0xb0, 0xae, 0x8b, 0xce, 0xad, 0xc8, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
> >> + 0x85, 0x87, 0x89, 0x8a, 0x83, 0x87, 0x82, 0x85, 0x88, 0x87, 0x89,
> >> + 0x8f, 0x84, 0xac, 0xaa, 0x89, 0xb1, 0x98, 0xaf, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
> >> + 0x85, 0x86, 0x88, 0x89, 0x84, 0x88, 0x83, 0x82, 0x85, 0x84, 0x8c,
> >> + 0x91, 0x86, 0xac, 0xaa, 0x89, 0xc2, 0xa5, 0xbd, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
> >> + 0x85, 0x87, 0x89, 0x8a, 0x83, 0x87, 0x82, 0x85, 0x88, 0x87, 0x88,
> >> + 0x8b, 0x82, 0xad, 0xaa, 0x8a, 0xc2, 0xa5, 0xbd, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
> >> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x88, 0x83, 0x82, 0x85, 0x84, 0x8a,
> >> + 0x8e, 0x84, 0xae, 0xac, 0x89, 0xda, 0xb7, 0xd0, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
> >> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x88, 0x83, 0x80, 0x83, 0x82, 0x8b,
> >> + 0x8e, 0x85, 0xac, 0xaa, 0x89, 0xc8, 0xaa, 0xc1, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
> >> + 0x85, 0x86, 0x87, 0x89, 0x81, 0x85, 0x81, 0x84, 0x86, 0x84, 0x8c,
> >> + 0x8c, 0x84, 0xa9, 0xa8, 0x87, 0xa3, 0x92, 0xa1, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
> >> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x86, 0x83, 0x80, 0x83, 0x81, 0x8c,
> >> + 0x8d, 0x84, 0xaa, 0xaa, 0x89, 0xce, 0xaf, 0xc5, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
> >> + 0x85, 0x86, 0x87, 0x89, 0x81, 0x83, 0x80, 0x83, 0x85, 0x85, 0x8c,
> >> + 0x8c, 0x84, 0xa8, 0xa8, 0x88, 0xb5, 0x9f, 0xb0, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
> >> + 0x86, 0x86, 0x87, 0x88, 0x81, 0x83, 0x80, 0x83, 0x85, 0x85, 0x8c,
> >> + 0x8b, 0x84, 0xab, 0xa8, 0x86, 0xd4, 0xb4, 0xc9, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
> >> + 0x86, 0x86, 0x87, 0x88, 0x81, 0x83, 0x80, 0x84, 0x84, 0x85, 0x8b,
> >> + 0x8a, 0x83, 0xa6, 0xa5, 0x84, 0xbb, 0xa4, 0xb3, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
> >> + 0x86, 0x85, 0x86, 0x86, 0x82, 0x85, 0x81, 0x82, 0x83, 0x84, 0x8e,
> >> + 0x8b, 0x83, 0xa4, 0xa3, 0x8a, 0xa1, 0x93, 0x9d, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
> >> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x82, 0x82, 0x84, 0x8e,
> >> + 0x8b, 0x83, 0xa4, 0xa2, 0x86, 0xc1, 0xa9, 0xb7, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
> >> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x82, 0x82, 0x84, 0x8d,
> >> + 0x89, 0x82, 0xa2, 0xa1, 0x84, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
> >> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x83, 0x83, 0x85, 0x8c,
> >> + 0x87, 0x7f, 0xa2, 0x9d, 0x88, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xbb, 0x00, 0xc5, 0x00, 0xb4, 0x87, 0x86, 0x86, 0x84, 0x83,
> >> + 0x86, 0x87, 0x87, 0x87, 0x80, 0x82, 0x7f, 0x86, 0x86, 0x88, 0x8a,
> >> + 0x84, 0x7e, 0x9d, 0x9c, 0x82, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xbd, 0x00, 0xc7, 0x00, 0xb7, 0x87, 0x85, 0x85, 0x84, 0x83,
> >> + 0x86, 0x86, 0x86, 0x88, 0x81, 0x83, 0x80, 0x83, 0x84, 0x85, 0x8a,
> >> + 0x85, 0x7e, 0x9c, 0x9b, 0x85, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xc0, 0x00, 0xca, 0x00, 0xbb, 0x87, 0x86, 0x85, 0x83, 0x83,
> >> + 0x85, 0x86, 0x86, 0x88, 0x81, 0x83, 0x80, 0x84, 0x85, 0x86, 0x89,
> >> + 0x83, 0x7d, 0x9c, 0x99, 0x87, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xc4, 0x00, 0xcd, 0x00, 0xbe, 0x87, 0x86, 0x85, 0x83, 0x83,
> >> + 0x86, 0x85, 0x85, 0x87, 0x81, 0x82, 0x80, 0x82, 0x82, 0x83, 0x8a,
> >> + 0x85, 0x7f, 0x9f, 0x9b, 0x86, 0xb4, 0xa1, 0xac, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xc7, 0x00, 0xd0, 0x00, 0xc2, 0x87, 0x85, 0x85, 0x83, 0x82,
> >> + 0x85, 0x85, 0x85, 0x86, 0x82, 0x83, 0x80, 0x82, 0x82, 0x84, 0x87,
> >> + 0x86, 0x80, 0x9e, 0x9a, 0x87, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xca, 0x00, 0xd2, 0x00, 0xc5, 0x87, 0x85, 0x84, 0x82, 0x82,
> >> + 0x84, 0x85, 0x85, 0x86, 0x81, 0x82, 0x7f, 0x82, 0x82, 0x84, 0x88,
> >> + 0x86, 0x81, 0x9d, 0x98, 0x86, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xce, 0x00, 0xd6, 0x00, 0xca, 0x86, 0x85, 0x84, 0x83, 0x83,
> >> + 0x85, 0x84, 0x84, 0x85, 0x81, 0x82, 0x80, 0x81, 0x81, 0x82, 0x89,
> >> + 0x86, 0x81, 0x9c, 0x97, 0x86, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xd1, 0x00, 0xd9, 0x00, 0xce, 0x86, 0x84, 0x83, 0x83, 0x82,
> >> + 0x85, 0x85, 0x85, 0x86, 0x81, 0x83, 0x81, 0x82, 0x82, 0x83, 0x86,
> >> + 0x83, 0x7f, 0x99, 0x95, 0x86, 0xbb, 0xa4, 0xb3, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xd4, 0x00, 0xdb, 0x00, 0xd1, 0x86, 0x85, 0x83, 0x83, 0x82,
> >> + 0x85, 0x84, 0x84, 0x85, 0x80, 0x83, 0x82, 0x80, 0x80, 0x81, 0x87,
> >> + 0x84, 0x81, 0x98, 0x93, 0x85, 0xae, 0x9c, 0xa8, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xd8, 0x00, 0xde, 0x00, 0xd6, 0x86, 0x84, 0x83, 0x81, 0x81,
> >> + 0x83, 0x85, 0x85, 0x85, 0x82, 0x83, 0x81, 0x81, 0x81, 0x83, 0x86,
> >> + 0x84, 0x80, 0x98, 0x91, 0x85, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xdc, 0x00, 0xe2, 0x00, 0xda, 0x85, 0x84, 0x83, 0x82, 0x82,
> >> + 0x84, 0x84, 0x84, 0x85, 0x81, 0x82, 0x82, 0x80, 0x80, 0x81, 0x83,
> >> + 0x82, 0x7f, 0x99, 0x93, 0x86, 0x94, 0x8b, 0x92, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xdf, 0x00, 0xe5, 0x00, 0xde, 0x85, 0x84, 0x82, 0x82, 0x82,
> >> + 0x84, 0x83, 0x83, 0x84, 0x81, 0x81, 0x80, 0x83, 0x82, 0x84, 0x82,
> >> + 0x81, 0x7f, 0x99, 0x92, 0x86, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
> >> + 0x82, 0x83, 0x83, 0x84, 0x80, 0x81, 0x80, 0x83, 0x83, 0x84, 0x80,
> >> + 0x81, 0x7c, 0x99, 0x92, 0x87, 0xa1, 0x93, 0x9d, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x85, 0x84, 0x83, 0x81, 0x81,
> >> + 0x82, 0x82, 0x82, 0x83, 0x80, 0x81, 0x80, 0x81, 0x80, 0x82, 0x83,
> >> + 0x82, 0x80, 0x91, 0x8d, 0x83, 0x9a, 0x90, 0x96, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
> >> + 0x82, 0x83, 0x83, 0x84, 0x80, 0x81, 0x80, 0x81, 0x80, 0x82, 0x83,
> >> + 0x81, 0x7f, 0x91, 0x8c, 0x82, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
> >> + 0x82, 0x83, 0x83, 0x83, 0x82, 0x82, 0x81, 0x81, 0x80, 0x82, 0x82,
> >> + 0x82, 0x7f, 0x94, 0x89, 0x84, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
> >> + 0x82, 0x83, 0x83, 0x83, 0x82, 0x82, 0x81, 0x81, 0x80, 0x82, 0x83,
> >> + 0x82, 0x7f, 0x91, 0x85, 0x81, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
> >> + 0x82, 0x83, 0x83, 0x83, 0x80, 0x80, 0x7f, 0x83, 0x82, 0x84, 0x83,
> >> + 0x82, 0x7f, 0x90, 0x84, 0x81, 0x9a, 0x90, 0x96, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x80, 0x80,
> >> + 0x82, 0x83, 0x83, 0x83, 0x80, 0x80, 0x7f, 0x80, 0x80, 0x81, 0x81,
> >> + 0x82, 0x83, 0x7e, 0x80, 0x7c, 0xa4, 0x97, 0x9f, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xe9, 0x00, 0xec, 0x00, 0xe8, 0x84, 0x83, 0x82, 0x81, 0x81,
> >> + 0x82, 0x82, 0x82, 0x83, 0x7f, 0x7f, 0x7f, 0x81, 0x80, 0x82, 0x83,
> >> + 0x83, 0x84, 0x79, 0x7c, 0x79, 0xb1, 0xa0, 0xaa, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xed, 0x00, 0xf0, 0x00, 0xec, 0x83, 0x83, 0x82, 0x80, 0x80,
> >> + 0x81, 0x82, 0x82, 0x82, 0x7f, 0x7f, 0x7e, 0x81, 0x81, 0x82, 0x80,
> >> + 0x81, 0x81, 0x84, 0x84, 0x83, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xf1, 0x00, 0xf4, 0x00, 0xf1, 0x83, 0x82, 0x82, 0x80, 0x80,
> >> + 0x81, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x7d,
> >> + 0x7e, 0x7f, 0x84, 0x84, 0x83, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf5, 0x82, 0x82, 0x81, 0x80, 0x80,
> >> + 0x80, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x7f, 0x7f, 0x7f, 0x82,
> >> + 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x00, 0xfa, 0x00, 0xfb, 0x00, 0xfa, 0x81, 0x81, 0x81, 0x80, 0x80,
> >> + 0x80, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> >> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
> >> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> >> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 },
> >> + { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
> >> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> >> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
> >> + 0x00, 0x00 }
> >> +};
> >> +
> >> +unsigned char vint_table[S6E3HA2_VINT_STATUS_MAX] = {
> >> + 0x18, 0x19, 0x1a, 0x1b, 0x1c,
> >> + 0x1d, 0x1e, 0x1f, 0x20, 0x21
> >> +};
> >> +
> >> +struct s6e3ha2 {
> >> + struct device *dev;
> >> + struct drm_panel panel;
> >> + struct backlight_device *bl_dev;
> >> +
> >> + struct regulator_bulk_data supplies[2];
> >> + struct gpio_desc *reset_gpio;
> >> + struct gpio_desc *enable_gpio;
> >> +
> >> + /* This field is tested by functions directly accessing DSI bus before
> >> + * transfer, transfer is skipped if it is set. In case of transfer
> >> + * failure or unexpected response the field is set to error value.
> >> + * Such construct allows to eliminate many checks in higher level
> >> + * functions.
> >> + */
> >> + int error;
> >> +};
> >> +
> >> +static int s6e3ha2_clear_error(struct s6e3ha2 *ctx)
> >> +{
> >> + int ret = ctx->error;
> >> +
> >> + ctx->error = 0;
> >> + return ret;
> >> +}
> >> +
> >> +static void s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const void *data, size_t len)
> >> +{
> >> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
> >> + ssize_t ret;
> >> +
> >> + if (ctx->error < 0)
> >> + return;
> >> +
> >> + ret = mipi_dsi_dcs_write_buffer(dsi, data, len);
> >> + if (ret < 0) {
> >> + dev_err(ctx->dev, "error %zd writing dcs seq: %*ph\n",
> >> + ret, (int)len, data);
> >> + ctx->error = ret;
> >> + }
> >> +}
> >> +
> >> +#define s6e3ha2_dcs_write_seq_static(ctx, seq...) do { \
> >> + static const u8 d[] = { seq }; \
> >> + s6e3ha2_dcs_write(ctx, d, ARRAY_SIZE(d)); \
> >> +} while (0)
> >> +
> >> +static void s6e3ha2_test_key_on_f0(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0x5a, 0x5a);
> >> +}
> >> +
> >> +static void s6e3ha2_test_key_off_f0(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0xa5, 0xa5);
> >> +}
> >> +
> >> +static void s6e3ha2_test_key_on_fc(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0x5a, 0x5a);
> >> +}
> >> +
> >> +static void s6e3ha2_test_key_off_fc(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0xa5, 0xa5);
> >> +}
> >> +
> >> +static void s6e3ha2_single_dsi_set(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xf2, 0x67);
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xf9, 0x09);
> >> +}
> >> +
> >> +static void s6e3ha2_freq_calibration(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xfd, 0x1c);
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20, 0x39);
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0xa0);
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20);
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x12, 0x62,
> >> + 0x40, 0x80, 0xc0, 0x28, 0x28, 0x28, 0x28, 0x39, 0xc5);
> >> +}
> >> +
> >> +static void s6e3ha2_aor_control(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xb2, 0x03, 0x10);
> >> +}
> >> +
> >> +static void s6e3ha2_caps_elvss_set(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xb6, 0x9c, 0x0a);
> >> +}
> >> +
> >> +static void s6e3ha2_acl_off(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0x55, 0x00);
> >> +}
> >> +
> >> +static void s6e3ha2_acl_off_opr(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xb5, 0x40);
> >> +}
> >> +
> >> +static void s6e3ha2_test_global(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x07);
> >> +}
> >> +
> >> +static void s6e3ha2_test(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xb8, 0x19);
> >> +}
> >> +
> >> +static void s6e3ha2_touch_hsync_on1(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx,
> >> + 0xbd, 0x33, 0x11, 0x02, 0x16, 0x02, 0x16);
> >> +}
> >> +
> >> +static void s6e3ha2_pentile_control(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xc0, 0x00, 0x00, 0xd8, 0xd8);
> >> +}
> >> +
> >> +static void s6e3ha2_poc_global(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x20);
> >> +}
> >> +
> >> +static void s6e3ha2_poc_setting(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x08);
> >> +}
> >> +
> >> +static void s6e3ha2_pcd_set_off(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xcc, 0x40, 0x51);
> >> +}
> >> +
> >> +static void s6e3ha2_err_fg_set(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xed, 0x44);
> >> +}
> >> +
> >> +static void s6e3ha2_hbm_off(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0x53, 0x00);
> >> +}
> >> +
> >> +static void s6e3ha2_te_start_setting(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xb9, 0x10, 0x09, 0xff, 0x00, 0x09);
> >> +}
> >> +
> >> +static void s6e3ha2_gamma_update(struct s6e3ha2 *ctx)
> >> +{
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x03);
> >> + ndelay(100); /* need for 100ns delay */
> >> + s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x00);
> >> +}
> >> +
> >> +static int s6e3ha2_get_brightness(struct backlight_device *bl_dev)
> >> +{
> >> + return bl_dev->props.brightness;
> >> +}
> >> +
> >> +static void s6e3ha2_set_vint(struct s6e3ha2 *ctx)
> >> +{
> >> + struct backlight_device *bl_dev = ctx->bl_dev;
> >> + unsigned int brightness = bl_dev->props.brightness;
> >> + unsigned char data[] = { 0xf4, 0x8b,
> >> + vint_table[brightness * (S6E3HA2_VINT_STATUS_MAX - 1) /
> >> + S6E3HA2_MAX_BRIGHTNESS] };
> >> +
> >> + s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data));
> >> +}
> >> +
> >> +static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness)
> >> +{
> >> + return (brightness * (S6E3HA2_NUM_GAMMA_STEPS - 1)) /
> >> + S6E3HA2_MAX_BRIGHTNESS;
> >> +}
> >> +
> >> +static int s6e3ha2_update_gamma(struct s6e3ha2 *ctx, unsigned int brightness)
> >> +{
> >> + struct backlight_device *bl_dev = ctx->bl_dev;
> >> + unsigned int index = s6e3ha2_get_brightness_index(brightness);
> >> + u8 data[S6E3HA2_GAMMA_CMD_CNT + 1] = { 0xca, };
> >> +
> >> + memcpy(data + 1, gamma_tbl + index, S6E3HA2_GAMMA_CMD_CNT);
> >> + s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data));
> >> +
> >> + s6e3ha2_gamma_update(ctx);
> >> + bl_dev->props.brightness = brightness;
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static int s6e3ha2_set_brightness(struct backlight_device *bl_dev)
> >> +{
> >> + struct s6e3ha2 *ctx = bl_get_data(bl_dev);
> >> + unsigned int brightness = bl_dev->props.brightness;
> >> +
> >> + if (brightness < S6E3HA2_MIN_BRIGHTNESS ||
> >> + brightness > bl_dev->props.max_brightness) {
> >> + dev_err(ctx->dev, "Invalid brightness: %u\n", brightness);
> >> + return -EINVAL;
> >> + }
> >> +
> >> + if (bl_dev->props.power > FB_BLANK_NORMAL)
> >> + return -EPERM;
> >> +
> >> + s6e3ha2_test_key_on_f0(ctx);
> >> + s6e3ha2_update_gamma(ctx, brightness);
> >> + s6e3ha2_aor_control(ctx);
> >> + s6e3ha2_set_vint(ctx);
> >> + s6e3ha2_test_key_off_f0(ctx);
> >> +
> >> + return ctx->error;
> >> +}
> >> +
> >> +static const struct backlight_ops s6e3ha2_bl_ops = {
> >> + .get_brightness = s6e3ha2_get_brightness,
> >> + .update_status = s6e3ha2_set_brightness,
> >> +};
> >> +
> >> +static int s6e3ha2_panel_init(struct s6e3ha2 *ctx)
> >> +{
> >> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
> >> + int ret;
> >> +
> >> + ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
> >> + if (ret < 0)
> >> + return ret;
> >> + usleep_range(5000, 6000);
> >> +
> >> + s6e3ha2_test_key_on_f0(ctx);
> >> + s6e3ha2_single_dsi_set(ctx);
> >> + s6e3ha2_test_key_on_fc(ctx);
> >> + s6e3ha2_freq_calibration(ctx);
> >> + s6e3ha2_test_key_off_fc(ctx);
> >> + s6e3ha2_test_key_off_f0(ctx);
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static int s6e3ha2_power_off(struct s6e3ha2 *ctx)
> >> +{
> >> + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
> >> +}
> >> +
> >> +static int s6e3ha2_disable(struct drm_panel *panel)
> >> +{
> >> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
> >> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
> >> + int ret;
> >> +
> >> + ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + ret = mipi_dsi_dcs_set_display_off(dsi);
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + msleep(40);
> >> + ctx->bl_dev->props.power = FB_BLANK_NORMAL;
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static int s6e3ha2_unprepare(struct drm_panel *panel)
> >> +{
> >> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
> >> + int ret;
> >> +
> >> + ret = s6e3ha2_clear_error(ctx);
> >> + if (!ret)
> >> + ctx->bl_dev->props.power = FB_BLANK_POWERDOWN;
> >> +
> >> + return s6e3ha2_power_off(ctx);
> >> +}
> >> +
> >> +static int s6e3ha2_power_on(struct s6e3ha2 *ctx)
> >> +{
> >> + int ret;
> >> +
> >> + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + msleep(120);
> >> +
> >> + gpiod_set_value(ctx->enable_gpio, 0);
> >> + usleep_range(5000, 6000);
> >> + gpiod_set_value(ctx->enable_gpio, 1);
> >> +
> >> + gpiod_set_value(ctx->reset_gpio, 1);
> >> + usleep_range(5000, 6000);
> >> + gpiod_set_value(ctx->reset_gpio, 0);
> >> + usleep_range(5000, 6000);
> >> +
> >> + return 0;
> >> +}
> >> +static int s6e3ha2_prepare(struct drm_panel *panel)
> >> +{
> >> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
> >> + int ret;
> >> +
> >> + ret = s6e3ha2_power_on(ctx);
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + ret = s6e3ha2_panel_init(ctx);
> >> + if (ret < 0)
> >> + goto err;
> >> +
> >> + ret = s6e3ha2_clear_error(ctx);
> >> + if (ret < 0)
> >> + goto err;
> >> +
> >> + ctx->bl_dev->props.power = FB_BLANK_NORMAL;
> >> +
> >> + return 0;
> >> +
> >> +err:
> >> + s6e3ha2_power_off(ctx);
> >> + return ret;
> >> +}
> >> +
> >> +static int s6e3ha2_enable(struct drm_panel *panel)
> >> +{
> >> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
> >> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
> >> + int ret;
> >> +
> >> + /* common setting */
> >> + ret = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + s6e3ha2_test_key_on_f0(ctx);
> >> + s6e3ha2_test_key_on_fc(ctx);
> >> + s6e3ha2_touch_hsync_on1(ctx);
> >> + s6e3ha2_pentile_control(ctx);
> >> + s6e3ha2_poc_global(ctx);
> >> + s6e3ha2_poc_setting(ctx);
> >> + s6e3ha2_test_key_off_fc(ctx);
> >> +
> >> + /* pcd setting off for TB */
> >> + s6e3ha2_pcd_set_off(ctx);
> >> + s6e3ha2_err_fg_set(ctx);
> >> + s6e3ha2_te_start_setting(ctx);
> >> +
> >> + /* brightness setting */
> >> + s6e3ha2_set_brightness(ctx->bl_dev);
> >> + s6e3ha2_aor_control(ctx);
> >> + s6e3ha2_caps_elvss_set(ctx);
> >> + s6e3ha2_gamma_update(ctx);
> >> + s6e3ha2_acl_off(ctx);
> >> + s6e3ha2_acl_off_opr(ctx);
> >> + s6e3ha2_hbm_off(ctx);
> >> +
> >> + /* elvss temp compensation */
> >> + s6e3ha2_test_global(ctx);
> >> + s6e3ha2_test(ctx);
> >> + s6e3ha2_test_key_off_f0(ctx);
> >> +
> >> + if (ctx->error != 0)
> >> + return ctx->error;
> >> +
> >> + ret = mipi_dsi_dcs_set_display_on(dsi);
> >> + if (ret < 0)
> >> + return ret;
> >> +
> >> + ctx->bl_dev->props.power = FB_BLANK_UNBLANK;
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static const struct drm_display_mode default_mode = {
> >> + .clock = 222372,
> >> + .hdisplay = 1440,
> >> + .hsync_start = 1440 + 1,
> >> + .hsync_end = 1440 + 1 + 1,
> >> + .htotal = 1440 + 1 + 1 + 1,
> >> + .vdisplay = 2560,
> >> + .vsync_start = 2560 + 1,
> >> + .vsync_end = 2560 + 1 + 1,
> >> + .vtotal = 2560 + 1 + 1 + 15,
> >> + .vrefresh = 60,
> >> + .flags = 0,
> >> +};
> >> +
> >> +static int s6e3ha2_get_modes(struct drm_panel *panel)
> >> +{
> >> + struct drm_connector *connector = panel->connector;
> >> + struct drm_display_mode *mode;
> >> +
> >> + mode = drm_mode_duplicate(panel->drm, &default_mode);
> >> + if (!mode) {
> >> + DRM_ERROR("failed to add mode %ux%ux@%u\n",
> >> + default_mode.hdisplay, default_mode.vdisplay,
> >> + default_mode.vrefresh);
> >> + return -ENOMEM;
> >> + }
> >> +
> >> + drm_mode_set_name(mode);
> >> +
> >> + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> >> + drm_mode_probed_add(connector, mode);
> >> +
> >> + connector->display_info.width_mm = 71;
> >> + connector->display_info.height_mm = 125;
> >> +
> >> + return 1;
> >> +}
> >> +
> >> +static const struct drm_panel_funcs s6e3ha2_drm_funcs = {
> >> + .disable = s6e3ha2_disable,
> >> + .unprepare = s6e3ha2_unprepare,
> >> + .prepare = s6e3ha2_prepare,
> >> + .enable = s6e3ha2_enable,
> >> + .get_modes = s6e3ha2_get_modes,
> >> +};
> >> +
> >> +static int s6e3ha2_probe(struct mipi_dsi_device *dsi)
> >> +{
> >> + struct device *dev = &dsi->dev;
> >> + struct s6e3ha2 *ctx;
> >> + int ret;
> >> +
> >> + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> >> + if (!ctx)
> >> + return -ENOMEM;
> >> +
> >> + mipi_dsi_set_drvdata(dsi, ctx);
> >> +
> >> + ctx->dev = dev;
> >> +
> >> + dsi->lanes = 4;
> >> + dsi->format = MIPI_DSI_FMT_RGB888;
> >> + dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS;
> >> +
> >> + ctx->supplies[0].supply = "vdd3";
> >> + ctx->supplies[1].supply = "vci";
> >> +
> >> + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
> >> + ctx->supplies);
> >> + if (ret < 0) {
> >> + dev_err(dev, "failed to get regulators: %d\n", ret);
> >> + return ret;
> >> + }
> >> +
> >> + ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
> >> + if (IS_ERR(ctx->reset_gpio)) {
> >> + dev_err(dev, "cannot get reset-gpios %ld\n",
> >> + PTR_ERR(ctx->reset_gpio));
> >> + return PTR_ERR(ctx->reset_gpio);
> >> + }
> >> +
> >> + ctx->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
> >> + if (IS_ERR(ctx->enable_gpio)) {
> >> + dev_err(dev, "cannot get enable-gpios %ld\n",
> >> + PTR_ERR(ctx->enable_gpio));
> >> + return PTR_ERR(ctx->enable_gpio);
> >> + }
> >> +
> >> + ctx->bl_dev = backlight_device_register("s6e3ha2", dev, ctx,
> >> + &s6e3ha2_bl_ops, NULL);
> >> + if (IS_ERR(ctx->bl_dev)) {
> >> + dev_err(dev, "failed to register backlight device\n");
> >> + return PTR_ERR(ctx->bl_dev);
> >> + }
> >> +
> >> + ctx->bl_dev->props.max_brightness = S6E3HA2_MAX_BRIGHTNESS;
> >> + ctx->bl_dev->props.brightness = S6E3HA2_DEFAULT_BRIGHTNESS;
> >> + ctx->bl_dev->props.power = FB_BLANK_POWERDOWN;
> >> +
> >> + drm_panel_init(&ctx->panel);
> >> + ctx->panel.dev = dev;
> >> + ctx->panel.funcs = &s6e3ha2_drm_funcs;
> >> +
> >> + ret = drm_panel_add(&ctx->panel);
> >> + if (ret < 0)
> >> + goto unregister_backlight;
> >> +
> >> + ret = mipi_dsi_attach(dsi);
> >> + if (ret < 0)
> >> + goto remove_panel;
> >> +
> >> + return ret;
> >> +
> >> +remove_panel:
> >> + drm_panel_remove(&ctx->panel);
> >> +
> >> +unregister_backlight:
> >> + backlight_device_unregister(ctx->bl_dev);
> >> +
> >> + return ret;
> >> +}
> >> +
> >> +static int s6e3ha2_remove(struct mipi_dsi_device *dsi)
> >> +{
> >> + struct s6e3ha2 *ctx = mipi_dsi_get_drvdata(dsi);
> >> +
> >> + mipi_dsi_detach(dsi);
> >> + drm_panel_remove(&ctx->panel);
> >> + backlight_device_unregister(ctx->bl_dev);
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static const struct of_device_id s6e3ha2_of_match[] = {
> >> + { .compatible = "samsung,s6e3ha2" },
> >> + { }
> >> +};
> >> +MODULE_DEVICE_TABLE(of, s6e3ha2_of_match);
> >> +
> >> +static struct mipi_dsi_driver s6e3ha2_driver = {
> >> + .probe = s6e3ha2_probe,
> >> + .remove = s6e3ha2_remove,
> >> + .driver = {
> >> + .name = "panel-samsung-s6e3ha2",
> >> + .of_match_table = s6e3ha2_of_match,
> >> + },
> >> +};
> >> +module_mipi_dsi_driver(s6e3ha2_driver);
> >> +
> >> +MODULE_AUTHOR("Donghwa Lee <dh09.lee@samsung.com>");
> >> +MODULE_AUTHOR("Hyungwon Hwang <human.hwang@samsung.com>");
> >> +MODULE_AUTHOR("Hoegeun Kwon <hoegeun.kwon@samsung.com>");
> >> +MODULE_DESCRIPTION("MIPI-DSI based s6e3ha2 AMOLED Panel Driver");
> >> +MODULE_LICENSE("GPL v2");
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe devicetree" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
> >
[toc] | [prev] | [next] | [standalone]
| From | Inki Dae <inki.dae@samsung.com> |
|---|---|
| Date | 2017-01-31 10:30 +0100 |
| Message-ID | <t5CVc-7pw-21@gated-at.bofh.it> |
| In reply to | #1570495 |
2017년 01월 31일 17:54에 Thierry Reding 이(가) 쓴 글:
> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote:
>>
>>
>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글:
>>> Dear Thierry,
>>>
>>> Could you please review this patch?
>>
>> Thierry, I think this patch has been reviewed enough but no comment
>> from you. Seems you are busy. I will pick up this.
>
> Sorry, but that's not how it works. This patch has gone through 8
> revisions within 4 weeks, and I tend to ignore patches like that until
> the dust settles.
>
> Other than that, this continues the same madness that I've repeatedly
> complained about in the past. The whole mechanism of running through a
> series of writes and not caring about errors until the very end is
> something we've discussed at length in the past. It also in large parts
> duplicates a bunch of functions from other Samsung panel drivers that I
> already said should eventually be moved to something saner.
>
> This is now the third driver and nobody's giving a damn about improving
> things.
>
> Until somebody does, I'm going to have to NAK this.
Hoegeun had got review comments and updated his patch seriously. no feedback from maintainer would make him and new contributors to frustrate.
So please leave *the things* so that the contributors can understand *what they have to modify more* or *why maintainer ignores the patch*.
And also if you specify *the things* here than I would do what I can so *the things* could be cleared.
Thanks,
Inki Dae
>
> Thierry
>
>>> On 01/11/2017 03:33 PM, Hoegeun Kwon wrote:
>>>> This patch add support for MIPI-DSI based S6E3HA2 AMOLED panel
>>>> driver. This panel has 1440x2560 resolution in 5.7-inch physical
>>>> panel in the TM2 device.
>>>>
>>>> Signed-off-by: Donghwa Lee <dh09.lee@samsung.com>
>>>> Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
>>>> Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
>>>> Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
>>>> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
>>>> ---
>>>> drivers/gpu/drm/panel/Kconfig | 6 +
>>>> drivers/gpu/drm/panel/Makefile | 1 +
>>>> drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 754 ++++++++++++++++++++++++++
>>>> 3 files changed, 761 insertions(+)
>>>> create mode 100644 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
>>>>
>>>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>>>> index 62aba97..d913c83 100644
>>>> --- a/drivers/gpu/drm/panel/Kconfig
>>>> +++ b/drivers/gpu/drm/panel/Kconfig
>>>> @@ -52,6 +52,12 @@ config DRM_PANEL_PANASONIC_VVX10F034N00
>>>> WUXGA (1920x1200) Novatek NT1397-based DSI panel as found in some
>>>> Xperia Z2 tablets
>>>> +config DRM_PANEL_SAMSUNG_S6E3HA2
>>>> + tristate "Samsung S6E3HA2 DSI video mode panel"
>>>> + depends on OF
>>>> + depends on DRM_MIPI_DSI
>>>> + select VIDEOMODE_HELPERS
>>>> +
>>>> config DRM_PANEL_SAMSUNG_S6E8AA0
>>>> tristate "Samsung S6E8AA0 DSI video mode panel"
>>>> depends on OF
>>>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>>>> index a5c7ec0..1d483b0 100644
>>>> --- a/drivers/gpu/drm/panel/Makefile
>>>> +++ b/drivers/gpu/drm/panel/Makefile
>>>> @@ -3,6 +3,7 @@ obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o
>>>> obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
>>>> obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += panel-panasonic-vvx10f034n00.o
>>>> obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
>>>> +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o
>>>> obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o
>>>> obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
>>>> obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
>>>> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
>>>> new file mode 100644
>>>> index 0000000..0b9c6f4
>>>> --- /dev/null
>>>> +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
>>>> @@ -0,0 +1,754 @@
>>>> +/*
>>>> + * MIPI-DSI based s6e3ha2 AMOLED 5.7 inch panel driver.
>>>> + *
>>>> + * Copyright (c) 2016 Samsung Electronics Co., Ltd.
>>>> + * Donghwa Lee <dh09.lee@samsung.com>
>>>> + * Hyungwon Hwang <human.hwang@samsung.com>
>>>> + * Hoegeun Kwon <hoegeun.kwon@samsung.com>
>>>> + *
>>>> + * This program is free software; you can redistribute it and/or modify
>>>> + * it under the terms of the GNU General Public License version 2 as
>>>> + * published by the Free Software Foundation.
>>>> + */
>>>> +
>>>> +#include <drm/drmP.h>
>>>> +#include <drm/drm_mipi_dsi.h>
>>>> +#include <drm/drm_panel.h>
>>>> +#include <linux/backlight.h>
>>>> +#include <linux/gpio/consumer.h>
>>>> +#include <linux/regulator/consumer.h>
>>>> +
>>>> +#define S6E3HA2_MIN_BRIGHTNESS 0
>>>> +#define S6E3HA2_MAX_BRIGHTNESS 100
>>>> +#define S6E3HA2_DEFAULT_BRIGHTNESS 80
>>>> +
>>>> +#define S6E3HA2_NUM_GAMMA_STEPS 46
>>>> +#define S6E3HA2_GAMMA_CMD_CNT 35
>>>> +#define S6E3HA2_VINT_STATUS_MAX 10
>>>> +
>>>> +static const u8 gamma_tbl[S6E3HA2_NUM_GAMMA_STEPS][S6E3HA2_GAMMA_CMD_CNT] = {
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x82, 0x83,
>>>> + 0x85, 0x88, 0x8b, 0x8b, 0x84, 0x88, 0x82, 0x82, 0x89, 0x86, 0x8c,
>>>> + 0x94, 0x84, 0xb1, 0xaf, 0x8e, 0xcf, 0xad, 0xc9, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x84, 0x84,
>>>> + 0x85, 0x87, 0x8b, 0x8a, 0x84, 0x88, 0x82, 0x82, 0x89, 0x86, 0x8a,
>>>> + 0x93, 0x84, 0xb0, 0xae, 0x8e, 0xc9, 0xa8, 0xc5, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x8a, 0x8a, 0x84, 0x88, 0x81, 0x84, 0x8a, 0x88, 0x8a,
>>>> + 0x91, 0x84, 0xb1, 0xae, 0x8b, 0xd5, 0xb2, 0xcc, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x8a, 0x8a, 0x84, 0x87, 0x81, 0x84, 0x8a, 0x87, 0x8a,
>>>> + 0x91, 0x85, 0xae, 0xac, 0x8a, 0xc3, 0xa3, 0xc0, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x85, 0x85,
>>>> + 0x86, 0x85, 0x88, 0x89, 0x84, 0x89, 0x82, 0x84, 0x87, 0x85, 0x8b,
>>>> + 0x91, 0x88, 0xad, 0xab, 0x8a, 0xb7, 0x9b, 0xb6, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x89, 0x8a, 0x84, 0x89, 0x83, 0x83, 0x86, 0x84, 0x8b,
>>>> + 0x90, 0x84, 0xb0, 0xae, 0x8b, 0xce, 0xad, 0xc8, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x87, 0x89, 0x8a, 0x83, 0x87, 0x82, 0x85, 0x88, 0x87, 0x89,
>>>> + 0x8f, 0x84, 0xac, 0xaa, 0x89, 0xb1, 0x98, 0xaf, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x88, 0x89, 0x84, 0x88, 0x83, 0x82, 0x85, 0x84, 0x8c,
>>>> + 0x91, 0x86, 0xac, 0xaa, 0x89, 0xc2, 0xa5, 0xbd, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>>>> + 0x85, 0x87, 0x89, 0x8a, 0x83, 0x87, 0x82, 0x85, 0x88, 0x87, 0x88,
>>>> + 0x8b, 0x82, 0xad, 0xaa, 0x8a, 0xc2, 0xa5, 0xbd, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x89, 0x87, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x88, 0x83, 0x82, 0x85, 0x84, 0x8a,
>>>> + 0x8e, 0x84, 0xae, 0xac, 0x89, 0xda, 0xb7, 0xd0, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>>>> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x88, 0x83, 0x80, 0x83, 0x82, 0x8b,
>>>> + 0x8e, 0x85, 0xac, 0xaa, 0x89, 0xc8, 0xaa, 0xc1, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>>>> + 0x85, 0x86, 0x87, 0x89, 0x81, 0x85, 0x81, 0x84, 0x86, 0x84, 0x8c,
>>>> + 0x8c, 0x84, 0xa9, 0xa8, 0x87, 0xa3, 0x92, 0xa1, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>>>> + 0x85, 0x86, 0x87, 0x89, 0x84, 0x86, 0x83, 0x80, 0x83, 0x81, 0x8c,
>>>> + 0x8d, 0x84, 0xaa, 0xaa, 0x89, 0xce, 0xaf, 0xc5, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>>>> + 0x85, 0x86, 0x87, 0x89, 0x81, 0x83, 0x80, 0x83, 0x85, 0x85, 0x8c,
>>>> + 0x8c, 0x84, 0xa8, 0xa8, 0x88, 0xb5, 0x9f, 0xb0, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>>>> + 0x86, 0x86, 0x87, 0x88, 0x81, 0x83, 0x80, 0x83, 0x85, 0x85, 0x8c,
>>>> + 0x8b, 0x84, 0xab, 0xa8, 0x86, 0xd4, 0xb4, 0xc9, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>>>> + 0x86, 0x86, 0x87, 0x88, 0x81, 0x83, 0x80, 0x84, 0x84, 0x85, 0x8b,
>>>> + 0x8a, 0x83, 0xa6, 0xa5, 0x84, 0xbb, 0xa4, 0xb3, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x84, 0x84,
>>>> + 0x86, 0x85, 0x86, 0x86, 0x82, 0x85, 0x81, 0x82, 0x83, 0x84, 0x8e,
>>>> + 0x8b, 0x83, 0xa4, 0xa3, 0x8a, 0xa1, 0x93, 0x9d, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x82, 0x82, 0x84, 0x8e,
>>>> + 0x8b, 0x83, 0xa4, 0xa2, 0x86, 0xc1, 0xa9, 0xb7, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x82, 0x82, 0x84, 0x8d,
>>>> + 0x89, 0x82, 0xa2, 0xa1, 0x84, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xb8, 0x00, 0xc3, 0x00, 0xb1, 0x88, 0x86, 0x87, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x87, 0x87, 0x82, 0x85, 0x81, 0x83, 0x83, 0x85, 0x8c,
>>>> + 0x87, 0x7f, 0xa2, 0x9d, 0x88, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xbb, 0x00, 0xc5, 0x00, 0xb4, 0x87, 0x86, 0x86, 0x84, 0x83,
>>>> + 0x86, 0x87, 0x87, 0x87, 0x80, 0x82, 0x7f, 0x86, 0x86, 0x88, 0x8a,
>>>> + 0x84, 0x7e, 0x9d, 0x9c, 0x82, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xbd, 0x00, 0xc7, 0x00, 0xb7, 0x87, 0x85, 0x85, 0x84, 0x83,
>>>> + 0x86, 0x86, 0x86, 0x88, 0x81, 0x83, 0x80, 0x83, 0x84, 0x85, 0x8a,
>>>> + 0x85, 0x7e, 0x9c, 0x9b, 0x85, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xc0, 0x00, 0xca, 0x00, 0xbb, 0x87, 0x86, 0x85, 0x83, 0x83,
>>>> + 0x85, 0x86, 0x86, 0x88, 0x81, 0x83, 0x80, 0x84, 0x85, 0x86, 0x89,
>>>> + 0x83, 0x7d, 0x9c, 0x99, 0x87, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xc4, 0x00, 0xcd, 0x00, 0xbe, 0x87, 0x86, 0x85, 0x83, 0x83,
>>>> + 0x86, 0x85, 0x85, 0x87, 0x81, 0x82, 0x80, 0x82, 0x82, 0x83, 0x8a,
>>>> + 0x85, 0x7f, 0x9f, 0x9b, 0x86, 0xb4, 0xa1, 0xac, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xc7, 0x00, 0xd0, 0x00, 0xc2, 0x87, 0x85, 0x85, 0x83, 0x82,
>>>> + 0x85, 0x85, 0x85, 0x86, 0x82, 0x83, 0x80, 0x82, 0x82, 0x84, 0x87,
>>>> + 0x86, 0x80, 0x9e, 0x9a, 0x87, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xca, 0x00, 0xd2, 0x00, 0xc5, 0x87, 0x85, 0x84, 0x82, 0x82,
>>>> + 0x84, 0x85, 0x85, 0x86, 0x81, 0x82, 0x7f, 0x82, 0x82, 0x84, 0x88,
>>>> + 0x86, 0x81, 0x9d, 0x98, 0x86, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xce, 0x00, 0xd6, 0x00, 0xca, 0x86, 0x85, 0x84, 0x83, 0x83,
>>>> + 0x85, 0x84, 0x84, 0x85, 0x81, 0x82, 0x80, 0x81, 0x81, 0x82, 0x89,
>>>> + 0x86, 0x81, 0x9c, 0x97, 0x86, 0xa7, 0x98, 0xa1, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xd1, 0x00, 0xd9, 0x00, 0xce, 0x86, 0x84, 0x83, 0x83, 0x82,
>>>> + 0x85, 0x85, 0x85, 0x86, 0x81, 0x83, 0x81, 0x82, 0x82, 0x83, 0x86,
>>>> + 0x83, 0x7f, 0x99, 0x95, 0x86, 0xbb, 0xa4, 0xb3, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xd4, 0x00, 0xdb, 0x00, 0xd1, 0x86, 0x85, 0x83, 0x83, 0x82,
>>>> + 0x85, 0x84, 0x84, 0x85, 0x80, 0x83, 0x82, 0x80, 0x80, 0x81, 0x87,
>>>> + 0x84, 0x81, 0x98, 0x93, 0x85, 0xae, 0x9c, 0xa8, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xd8, 0x00, 0xde, 0x00, 0xd6, 0x86, 0x84, 0x83, 0x81, 0x81,
>>>> + 0x83, 0x85, 0x85, 0x85, 0x82, 0x83, 0x81, 0x81, 0x81, 0x83, 0x86,
>>>> + 0x84, 0x80, 0x98, 0x91, 0x85, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xdc, 0x00, 0xe2, 0x00, 0xda, 0x85, 0x84, 0x83, 0x82, 0x82,
>>>> + 0x84, 0x84, 0x84, 0x85, 0x81, 0x82, 0x82, 0x80, 0x80, 0x81, 0x83,
>>>> + 0x82, 0x7f, 0x99, 0x93, 0x86, 0x94, 0x8b, 0x92, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xdf, 0x00, 0xe5, 0x00, 0xde, 0x85, 0x84, 0x82, 0x82, 0x82,
>>>> + 0x84, 0x83, 0x83, 0x84, 0x81, 0x81, 0x80, 0x83, 0x82, 0x84, 0x82,
>>>> + 0x81, 0x7f, 0x99, 0x92, 0x86, 0x7b, 0x7b, 0x7c, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>>>> + 0x82, 0x83, 0x83, 0x84, 0x80, 0x81, 0x80, 0x83, 0x83, 0x84, 0x80,
>>>> + 0x81, 0x7c, 0x99, 0x92, 0x87, 0xa1, 0x93, 0x9d, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x85, 0x84, 0x83, 0x81, 0x81,
>>>> + 0x82, 0x82, 0x82, 0x83, 0x80, 0x81, 0x80, 0x81, 0x80, 0x82, 0x83,
>>>> + 0x82, 0x80, 0x91, 0x8d, 0x83, 0x9a, 0x90, 0x96, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>>>> + 0x82, 0x83, 0x83, 0x84, 0x80, 0x81, 0x80, 0x81, 0x80, 0x82, 0x83,
>>>> + 0x81, 0x7f, 0x91, 0x8c, 0x82, 0x8d, 0x88, 0x8b, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>>>> + 0x82, 0x83, 0x83, 0x83, 0x82, 0x82, 0x81, 0x81, 0x80, 0x82, 0x82,
>>>> + 0x82, 0x7f, 0x94, 0x89, 0x84, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>>>> + 0x82, 0x83, 0x83, 0x83, 0x82, 0x82, 0x81, 0x81, 0x80, 0x82, 0x83,
>>>> + 0x82, 0x7f, 0x91, 0x85, 0x81, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x81, 0x81,
>>>> + 0x82, 0x83, 0x83, 0x83, 0x80, 0x80, 0x7f, 0x83, 0x82, 0x84, 0x83,
>>>> + 0x82, 0x7f, 0x90, 0x84, 0x81, 0x9a, 0x90, 0x96, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xe4, 0x00, 0xe9, 0x00, 0xe3, 0x84, 0x83, 0x82, 0x80, 0x80,
>>>> + 0x82, 0x83, 0x83, 0x83, 0x80, 0x80, 0x7f, 0x80, 0x80, 0x81, 0x81,
>>>> + 0x82, 0x83, 0x7e, 0x80, 0x7c, 0xa4, 0x97, 0x9f, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xe9, 0x00, 0xec, 0x00, 0xe8, 0x84, 0x83, 0x82, 0x81, 0x81,
>>>> + 0x82, 0x82, 0x82, 0x83, 0x7f, 0x7f, 0x7f, 0x81, 0x80, 0x82, 0x83,
>>>> + 0x83, 0x84, 0x79, 0x7c, 0x79, 0xb1, 0xa0, 0xaa, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xed, 0x00, 0xf0, 0x00, 0xec, 0x83, 0x83, 0x82, 0x80, 0x80,
>>>> + 0x81, 0x82, 0x82, 0x82, 0x7f, 0x7f, 0x7e, 0x81, 0x81, 0x82, 0x80,
>>>> + 0x81, 0x81, 0x84, 0x84, 0x83, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xf1, 0x00, 0xf4, 0x00, 0xf1, 0x83, 0x82, 0x82, 0x80, 0x80,
>>>> + 0x81, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x7d,
>>>> + 0x7e, 0x7f, 0x84, 0x84, 0x83, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xf6, 0x00, 0xf7, 0x00, 0xf5, 0x82, 0x82, 0x81, 0x80, 0x80,
>>>> + 0x80, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x7f, 0x7f, 0x7f, 0x82,
>>>> + 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x00, 0xfa, 0x00, 0xfb, 0x00, 0xfa, 0x81, 0x81, 0x81, 0x80, 0x80,
>>>> + 0x80, 0x82, 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
>>>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
>>>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
>>>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 },
>>>> + { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
>>>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
>>>> + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
>>>> + 0x00, 0x00 }
>>>> +};
>>>> +
>>>> +unsigned char vint_table[S6E3HA2_VINT_STATUS_MAX] = {
>>>> + 0x18, 0x19, 0x1a, 0x1b, 0x1c,
>>>> + 0x1d, 0x1e, 0x1f, 0x20, 0x21
>>>> +};
>>>> +
>>>> +struct s6e3ha2 {
>>>> + struct device *dev;
>>>> + struct drm_panel panel;
>>>> + struct backlight_device *bl_dev;
>>>> +
>>>> + struct regulator_bulk_data supplies[2];
>>>> + struct gpio_desc *reset_gpio;
>>>> + struct gpio_desc *enable_gpio;
>>>> +
>>>> + /* This field is tested by functions directly accessing DSI bus before
>>>> + * transfer, transfer is skipped if it is set. In case of transfer
>>>> + * failure or unexpected response the field is set to error value.
>>>> + * Such construct allows to eliminate many checks in higher level
>>>> + * functions.
>>>> + */
>>>> + int error;
>>>> +};
>>>> +
>>>> +static int s6e3ha2_clear_error(struct s6e3ha2 *ctx)
>>>> +{
>>>> + int ret = ctx->error;
>>>> +
>>>> + ctx->error = 0;
>>>> + return ret;
>>>> +}
>>>> +
>>>> +static void s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const void *data, size_t len)
>>>> +{
>>>> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>>>> + ssize_t ret;
>>>> +
>>>> + if (ctx->error < 0)
>>>> + return;
>>>> +
>>>> + ret = mipi_dsi_dcs_write_buffer(dsi, data, len);
>>>> + if (ret < 0) {
>>>> + dev_err(ctx->dev, "error %zd writing dcs seq: %*ph\n",
>>>> + ret, (int)len, data);
>>>> + ctx->error = ret;
>>>> + }
>>>> +}
>>>> +
>>>> +#define s6e3ha2_dcs_write_seq_static(ctx, seq...) do { \
>>>> + static const u8 d[] = { seq }; \
>>>> + s6e3ha2_dcs_write(ctx, d, ARRAY_SIZE(d)); \
>>>> +} while (0)
>>>> +
>>>> +static void s6e3ha2_test_key_on_f0(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0x5a, 0x5a);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_test_key_off_f0(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0xa5, 0xa5);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_test_key_on_fc(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0x5a, 0x5a);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_test_key_off_fc(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0xa5, 0xa5);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_single_dsi_set(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf2, 0x67);
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf9, 0x09);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_freq_calibration(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfd, 0x1c);
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20, 0x39);
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0xa0);
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20);
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x12, 0x62,
>>>> + 0x40, 0x80, 0xc0, 0x28, 0x28, 0x28, 0x28, 0x39, 0xc5);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_aor_control(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb2, 0x03, 0x10);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_caps_elvss_set(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb6, 0x9c, 0x0a);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_acl_off(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0x55, 0x00);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_acl_off_opr(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb5, 0x40);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_test_global(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x07);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_test(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb8, 0x19);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_touch_hsync_on1(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx,
>>>> + 0xbd, 0x33, 0x11, 0x02, 0x16, 0x02, 0x16);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_pentile_control(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xc0, 0x00, 0x00, 0xd8, 0xd8);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_poc_global(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x20);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_poc_setting(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x08);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_pcd_set_off(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xcc, 0x40, 0x51);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_err_fg_set(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xed, 0x44);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_hbm_off(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0x53, 0x00);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_te_start_setting(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xb9, 0x10, 0x09, 0xff, 0x00, 0x09);
>>>> +}
>>>> +
>>>> +static void s6e3ha2_gamma_update(struct s6e3ha2 *ctx)
>>>> +{
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x03);
>>>> + ndelay(100); /* need for 100ns delay */
>>>> + s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x00);
>>>> +}
>>>> +
>>>> +static int s6e3ha2_get_brightness(struct backlight_device *bl_dev)
>>>> +{
>>>> + return bl_dev->props.brightness;
>>>> +}
>>>> +
>>>> +static void s6e3ha2_set_vint(struct s6e3ha2 *ctx)
>>>> +{
>>>> + struct backlight_device *bl_dev = ctx->bl_dev;
>>>> + unsigned int brightness = bl_dev->props.brightness;
>>>> + unsigned char data[] = { 0xf4, 0x8b,
>>>> + vint_table[brightness * (S6E3HA2_VINT_STATUS_MAX - 1) /
>>>> + S6E3HA2_MAX_BRIGHTNESS] };
>>>> +
>>>> + s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data));
>>>> +}
>>>> +
>>>> +static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness)
>>>> +{
>>>> + return (brightness * (S6E3HA2_NUM_GAMMA_STEPS - 1)) /
>>>> + S6E3HA2_MAX_BRIGHTNESS;
>>>> +}
>>>> +
>>>> +static int s6e3ha2_update_gamma(struct s6e3ha2 *ctx, unsigned int brightness)
>>>> +{
>>>> + struct backlight_device *bl_dev = ctx->bl_dev;
>>>> + unsigned int index = s6e3ha2_get_brightness_index(brightness);
>>>> + u8 data[S6E3HA2_GAMMA_CMD_CNT + 1] = { 0xca, };
>>>> +
>>>> + memcpy(data + 1, gamma_tbl + index, S6E3HA2_GAMMA_CMD_CNT);
>>>> + s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data));
>>>> +
>>>> + s6e3ha2_gamma_update(ctx);
>>>> + bl_dev->props.brightness = brightness;
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static int s6e3ha2_set_brightness(struct backlight_device *bl_dev)
>>>> +{
>>>> + struct s6e3ha2 *ctx = bl_get_data(bl_dev);
>>>> + unsigned int brightness = bl_dev->props.brightness;
>>>> +
>>>> + if (brightness < S6E3HA2_MIN_BRIGHTNESS ||
>>>> + brightness > bl_dev->props.max_brightness) {
>>>> + dev_err(ctx->dev, "Invalid brightness: %u\n", brightness);
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>> + if (bl_dev->props.power > FB_BLANK_NORMAL)
>>>> + return -EPERM;
>>>> +
>>>> + s6e3ha2_test_key_on_f0(ctx);
>>>> + s6e3ha2_update_gamma(ctx, brightness);
>>>> + s6e3ha2_aor_control(ctx);
>>>> + s6e3ha2_set_vint(ctx);
>>>> + s6e3ha2_test_key_off_f0(ctx);
>>>> +
>>>> + return ctx->error;
>>>> +}
>>>> +
>>>> +static const struct backlight_ops s6e3ha2_bl_ops = {
>>>> + .get_brightness = s6e3ha2_get_brightness,
>>>> + .update_status = s6e3ha2_set_brightness,
>>>> +};
>>>> +
>>>> +static int s6e3ha2_panel_init(struct s6e3ha2 *ctx)
>>>> +{
>>>> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>>>> + int ret;
>>>> +
>>>> + ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
>>>> + if (ret < 0)
>>>> + return ret;
>>>> + usleep_range(5000, 6000);
>>>> +
>>>> + s6e3ha2_test_key_on_f0(ctx);
>>>> + s6e3ha2_single_dsi_set(ctx);
>>>> + s6e3ha2_test_key_on_fc(ctx);
>>>> + s6e3ha2_freq_calibration(ctx);
>>>> + s6e3ha2_test_key_off_fc(ctx);
>>>> + s6e3ha2_test_key_off_f0(ctx);
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static int s6e3ha2_power_off(struct s6e3ha2 *ctx)
>>>> +{
>>>> + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
>>>> +}
>>>> +
>>>> +static int s6e3ha2_disable(struct drm_panel *panel)
>>>> +{
>>>> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
>>>> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>>>> + int ret;
>>>> +
>>>> + ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
>>>> + if (ret < 0)
>>>> + return ret;
>>>> +
>>>> + ret = mipi_dsi_dcs_set_display_off(dsi);
>>>> + if (ret < 0)
>>>> + return ret;
>>>> +
>>>> + msleep(40);
>>>> + ctx->bl_dev->props.power = FB_BLANK_NORMAL;
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static int s6e3ha2_unprepare(struct drm_panel *panel)
>>>> +{
>>>> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
>>>> + int ret;
>>>> +
>>>> + ret = s6e3ha2_clear_error(ctx);
>>>> + if (!ret)
>>>> + ctx->bl_dev->props.power = FB_BLANK_POWERDOWN;
>>>> +
>>>> + return s6e3ha2_power_off(ctx);
>>>> +}
>>>> +
>>>> +static int s6e3ha2_power_on(struct s6e3ha2 *ctx)
>>>> +{
>>>> + int ret;
>>>> +
>>>> + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
>>>> + if (ret < 0)
>>>> + return ret;
>>>> +
>>>> + msleep(120);
>>>> +
>>>> + gpiod_set_value(ctx->enable_gpio, 0);
>>>> + usleep_range(5000, 6000);
>>>> + gpiod_set_value(ctx->enable_gpio, 1);
>>>> +
>>>> + gpiod_set_value(ctx->reset_gpio, 1);
>>>> + usleep_range(5000, 6000);
>>>> + gpiod_set_value(ctx->reset_gpio, 0);
>>>> + usleep_range(5000, 6000);
>>>> +
>>>> + return 0;
>>>> +}
>>>> +static int s6e3ha2_prepare(struct drm_panel *panel)
>>>> +{
>>>> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
>>>> + int ret;
>>>> +
>>>> + ret = s6e3ha2_power_on(ctx);
>>>> + if (ret < 0)
>>>> + return ret;
>>>> +
>>>> + ret = s6e3ha2_panel_init(ctx);
>>>> + if (ret < 0)
>>>> + goto err;
>>>> +
>>>> + ret = s6e3ha2_clear_error(ctx);
>>>> + if (ret < 0)
>>>> + goto err;
>>>> +
>>>> + ctx->bl_dev->props.power = FB_BLANK_NORMAL;
>>>> +
>>>> + return 0;
>>>> +
>>>> +err:
>>>> + s6e3ha2_power_off(ctx);
>>>> + return ret;
>>>> +}
>>>> +
>>>> +static int s6e3ha2_enable(struct drm_panel *panel)
>>>> +{
>>>> + struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
>>>> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>>>> + int ret;
>>>> +
>>>> + /* common setting */
>>>> + ret = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
>>>> + if (ret < 0)
>>>> + return ret;
>>>> +
>>>> + s6e3ha2_test_key_on_f0(ctx);
>>>> + s6e3ha2_test_key_on_fc(ctx);
>>>> + s6e3ha2_touch_hsync_on1(ctx);
>>>> + s6e3ha2_pentile_control(ctx);
>>>> + s6e3ha2_poc_global(ctx);
>>>> + s6e3ha2_poc_setting(ctx);
>>>> + s6e3ha2_test_key_off_fc(ctx);
>>>> +
>>>> + /* pcd setting off for TB */
>>>> + s6e3ha2_pcd_set_off(ctx);
>>>> + s6e3ha2_err_fg_set(ctx);
>>>> + s6e3ha2_te_start_setting(ctx);
>>>> +
>>>> + /* brightness setting */
>>>> + s6e3ha2_set_brightness(ctx->bl_dev);
>>>> + s6e3ha2_aor_control(ctx);
>>>> + s6e3ha2_caps_elvss_set(ctx);
>>>> + s6e3ha2_gamma_update(ctx);
>>>> + s6e3ha2_acl_off(ctx);
>>>> + s6e3ha2_acl_off_opr(ctx);
>>>> + s6e3ha2_hbm_off(ctx);
>>>> +
>>>> + /* elvss temp compensation */
>>>> + s6e3ha2_test_global(ctx);
>>>> + s6e3ha2_test(ctx);
>>>> + s6e3ha2_test_key_off_f0(ctx);
>>>> +
>>>> + if (ctx->error != 0)
>>>> + return ctx->error;
>>>> +
>>>> + ret = mipi_dsi_dcs_set_display_on(dsi);
>>>> + if (ret < 0)
>>>> + return ret;
>>>> +
>>>> + ctx->bl_dev->props.power = FB_BLANK_UNBLANK;
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static const struct drm_display_mode default_mode = {
>>>> + .clock = 222372,
>>>> + .hdisplay = 1440,
>>>> + .hsync_start = 1440 + 1,
>>>> + .hsync_end = 1440 + 1 + 1,
>>>> + .htotal = 1440 + 1 + 1 + 1,
>>>> + .vdisplay = 2560,
>>>> + .vsync_start = 2560 + 1,
>>>> + .vsync_end = 2560 + 1 + 1,
>>>> + .vtotal = 2560 + 1 + 1 + 15,
>>>> + .vrefresh = 60,
>>>> + .flags = 0,
>>>> +};
>>>> +
>>>> +static int s6e3ha2_get_modes(struct drm_panel *panel)
>>>> +{
>>>> + struct drm_connector *connector = panel->connector;
>>>> + struct drm_display_mode *mode;
>>>> +
>>>> + mode = drm_mode_duplicate(panel->drm, &default_mode);
>>>> + if (!mode) {
>>>> + DRM_ERROR("failed to add mode %ux%ux@%u\n",
>>>> + default_mode.hdisplay, default_mode.vdisplay,
>>>> + default_mode.vrefresh);
>>>> + return -ENOMEM;
>>>> + }
>>>> +
>>>> + drm_mode_set_name(mode);
>>>> +
>>>> + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
>>>> + drm_mode_probed_add(connector, mode);
>>>> +
>>>> + connector->display_info.width_mm = 71;
>>>> + connector->display_info.height_mm = 125;
>>>> +
>>>> + return 1;
>>>> +}
>>>> +
>>>> +static const struct drm_panel_funcs s6e3ha2_drm_funcs = {
>>>> + .disable = s6e3ha2_disable,
>>>> + .unprepare = s6e3ha2_unprepare,
>>>> + .prepare = s6e3ha2_prepare,
>>>> + .enable = s6e3ha2_enable,
>>>> + .get_modes = s6e3ha2_get_modes,
>>>> +};
>>>> +
>>>> +static int s6e3ha2_probe(struct mipi_dsi_device *dsi)
>>>> +{
>>>> + struct device *dev = &dsi->dev;
>>>> + struct s6e3ha2 *ctx;
>>>> + int ret;
>>>> +
>>>> + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
>>>> + if (!ctx)
>>>> + return -ENOMEM;
>>>> +
>>>> + mipi_dsi_set_drvdata(dsi, ctx);
>>>> +
>>>> + ctx->dev = dev;
>>>> +
>>>> + dsi->lanes = 4;
>>>> + dsi->format = MIPI_DSI_FMT_RGB888;
>>>> + dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS;
>>>> +
>>>> + ctx->supplies[0].supply = "vdd3";
>>>> + ctx->supplies[1].supply = "vci";
>>>> +
>>>> + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
>>>> + ctx->supplies);
>>>> + if (ret < 0) {
>>>> + dev_err(dev, "failed to get regulators: %d\n", ret);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
>>>> + if (IS_ERR(ctx->reset_gpio)) {
>>>> + dev_err(dev, "cannot get reset-gpios %ld\n",
>>>> + PTR_ERR(ctx->reset_gpio));
>>>> + return PTR_ERR(ctx->reset_gpio);
>>>> + }
>>>> +
>>>> + ctx->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
>>>> + if (IS_ERR(ctx->enable_gpio)) {
>>>> + dev_err(dev, "cannot get enable-gpios %ld\n",
>>>> + PTR_ERR(ctx->enable_gpio));
>>>> + return PTR_ERR(ctx->enable_gpio);
>>>> + }
>>>> +
>>>> + ctx->bl_dev = backlight_device_register("s6e3ha2", dev, ctx,
>>>> + &s6e3ha2_bl_ops, NULL);
>>>> + if (IS_ERR(ctx->bl_dev)) {
>>>> + dev_err(dev, "failed to register backlight device\n");
>>>> + return PTR_ERR(ctx->bl_dev);
>>>> + }
>>>> +
>>>> + ctx->bl_dev->props.max_brightness = S6E3HA2_MAX_BRIGHTNESS;
>>>> + ctx->bl_dev->props.brightness = S6E3HA2_DEFAULT_BRIGHTNESS;
>>>> + ctx->bl_dev->props.power = FB_BLANK_POWERDOWN;
>>>> +
>>>> + drm_panel_init(&ctx->panel);
>>>> + ctx->panel.dev = dev;
>>>> + ctx->panel.funcs = &s6e3ha2_drm_funcs;
>>>> +
>>>> + ret = drm_panel_add(&ctx->panel);
>>>> + if (ret < 0)
>>>> + goto unregister_backlight;
>>>> +
>>>> + ret = mipi_dsi_attach(dsi);
>>>> + if (ret < 0)
>>>> + goto remove_panel;
>>>> +
>>>> + return ret;
>>>> +
>>>> +remove_panel:
>>>> + drm_panel_remove(&ctx->panel);
>>>> +
>>>> +unregister_backlight:
>>>> + backlight_device_unregister(ctx->bl_dev);
>>>> +
>>>> + return ret;
>>>> +}
>>>> +
>>>> +static int s6e3ha2_remove(struct mipi_dsi_device *dsi)
>>>> +{
>>>> + struct s6e3ha2 *ctx = mipi_dsi_get_drvdata(dsi);
>>>> +
>>>> + mipi_dsi_detach(dsi);
>>>> + drm_panel_remove(&ctx->panel);
>>>> + backlight_device_unregister(ctx->bl_dev);
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static const struct of_device_id s6e3ha2_of_match[] = {
>>>> + { .compatible = "samsung,s6e3ha2" },
>>>> + { }
>>>> +};
>>>> +MODULE_DEVICE_TABLE(of, s6e3ha2_of_match);
>>>> +
>>>> +static struct mipi_dsi_driver s6e3ha2_driver = {
>>>> + .probe = s6e3ha2_probe,
>>>> + .remove = s6e3ha2_remove,
>>>> + .driver = {
>>>> + .name = "panel-samsung-s6e3ha2",
>>>> + .of_match_table = s6e3ha2_of_match,
>>>> + },
>>>> +};
>>>> +module_mipi_dsi_driver(s6e3ha2_driver);
>>>> +
>>>> +MODULE_AUTHOR("Donghwa Lee <dh09.lee@samsung.com>");
>>>> +MODULE_AUTHOR("Hyungwon Hwang <human.hwang@samsung.com>");
>>>> +MODULE_AUTHOR("Hoegeun Kwon <hoegeun.kwon@samsung.com>");
>>>> +MODULE_DESCRIPTION("MIPI-DSI based s6e3ha2 AMOLED Panel Driver");
>>>> +MODULE_LICENSE("GPL v2");
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe devicetree" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>>>
[toc] | [prev] | [next] | [standalone]
| From | Andrzej Hajda <a.hajda@samsung.com> |
|---|---|
| Date | 2017-01-31 13:10 +0100 |
| Message-ID | <t5Fq2-xl-23@gated-at.bofh.it> |
| In reply to | #1570495 |
On 31.01.2017 09:54, Thierry Reding wrote:
> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote:
>>
>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글:
>>> Dear Thierry,
>>>
>>> Could you please review this patch?
>> Thierry, I think this patch has been reviewed enough but no comment
>> from you. Seems you are busy. I will pick up this.
> Sorry, but that's not how it works. This patch has gone through 8
> revisions within 4 weeks, and I tend to ignore patches like that until
> the dust settles.
>
> Other than that, this continues the same madness that I've repeatedly
> complained about in the past. The whole mechanism of running through a
> series of writes and not caring about errors until the very end is
> something we've discussed at length in the past.
Yes, we have discussed the pattern, but without any conclusion. The
pattern is correct, used in different places in kernel (see below for
examples) and significantly decreases source code size. Disallowing it
in panels subsystem just because of personal preferences of the
maintainer does not seem to be proper.
> It also in large parts
> duplicates a bunch of functions from other Samsung panel drivers that I
> already said should eventually be moved to something saner.
Currently there are two Samsung panel drivers, one is on SPI bus,
another one is on DSI.
I am (co-)author of both drivers, they have some similarities but I did
not see any gain in making additional abstractions over transport layer
just to make one or two small functions common.
Could you be more precise what are you talking about, or could you give
a link to the mail where you said it. Anything I remember was a
discussion about ugly magic initialization sequences due to poor
documentation.
And below promised examples of the error pattern, it was time consuming
to find them, so please at least read them :)
Almost exactly the same patterns for the same purpose:
1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63
Citation from the code:
To reduce the number of error checks in the code, we record the
first error
in atusb->err and reject all subsequent requests until the error is
cleared.
2. http://lxr.free-electrons.com/source/drivers/md/dm-thin.c?v=4.4#L917
3. http://lxr.free-electrons.com/source/net/9p/trans_fd.c?v=3.18#L297
4.
http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-ctrls.c#L2234
5. http://lxr.free-electrons.com/source/drivers/media/i2c/s5k5baf.c#L451
This is my driver, I mention it here just to show it was not a
problem to merge it to media subsystem.
Similar patterns:
6. http://lxr.free-electrons.com/source/fs/seq_file.c#L398
Do not process object if buffer is full, it allows to do not check
buffer size after every write, for example:
> seq_printf(m, " hardirq-safe locks: %11lu\n",
> nr_hardirq_safe);
> seq_printf(m, " hardirq-unsafe locks: %11lu\n",
> nr_hardirq_unsafe);
> seq_printf(m, " softirq-safe locks: %11lu\n",
> nr_softirq_safe);
> seq_printf(m, " softirq-unsafe locks: %11lu\n",
> nr_softirq_unsafe);
> seq_printf(m, " irq-safe locks: %11lu\n",
> nr_irq_safe);
> seq_printf(m, " irq-unsafe locks: %11lu\n",
> nr_irq_unsafe);
>
> seq_printf(m, " hardirq-read-safe locks: %11lu\n",
> nr_hardirq_read_safe);
> seq_printf(m, " hardirq-read-unsafe locks: %11lu\n",
> nr_hardirq_read_unsafe);
> seq_printf(m, " softirq-read-safe locks: %11lu\n",
> nr_softirq_read_safe);
> seq_printf(m, " softirq-read-unsafe locks: %11lu\n",
> nr_softirq_read_unsafe);
> seq_printf(m, " irq-read-safe locks: %11lu\n",
> nr_irq_read_safe);
> seq_printf(m, " irq-read-unsafe locks: %11lu\n",
> nr_irq_read_unsafe);
>
> seq_printf(m, " uncategorized locks: %11lu\n",
> nr_uncategorized);
> seq_printf(m, " unused locks: %11lu\n",
> nr_unused);
> seq_printf(m, " max locking depth: %11u\n",
> max_lockdep_depth);
Now try to imagine how it would look like if you add error checking
after each call.
7. http://lxr.free-electrons.com/source/lib/devres.c#L129
Postponed error check:
> */res = platform_get_resource(pdev, IORESOURCE_MEM, 0);/*
> /*b*/*/ase = devm_ioremap_resource(&pdev->dev, res);/*
> */if (IS_ERR(base))/*
> /**/*/return PTR_ERR(base);/*
Regards
Andrzej
[toc] | [prev] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2017-02-02 19:00 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t6tPQ-77C-39@gated-at.bofh.it> |
| In reply to | #1570656 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jan 31, 2017 at 01:05:20PM +0100, Andrzej Hajda wrote: > On 31.01.2017 09:54, Thierry Reding wrote: > > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > >> > >> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > >>> Dear Thierry, > >>> > >>> Could you please review this patch? > >> Thierry, I think this patch has been reviewed enough but no comment > >> from you. Seems you are busy. I will pick up this. > > Sorry, but that's not how it works. This patch has gone through 8 > > revisions within 4 weeks, and I tend to ignore patches like that until > > the dust settles. > > > > Other than that, this continues the same madness that I've repeatedly > > complained about in the past. The whole mechanism of running through a > > series of writes and not caring about errors until the very end is > > something we've discussed at length in the past. > > Yes, we have discussed the pattern, but without any conclusion. The > pattern is correct, used in different places in kernel (see below for > examples) and significantly decreases source code size. Disallowing it > in panels subsystem just because of personal preferences of the > maintainer does not seem to be proper. > > > It also in large parts > > duplicates a bunch of functions from other Samsung panel drivers that I > > already said should eventually be moved to something saner. > > Currently there are two Samsung panel drivers, one is on SPI bus, > another one is on DSI. > I am (co-)author of both drivers, they have some similarities but I did > not see any gain in making additional abstractions over transport layer > just to make one or two small functions common. > Could you be more precise what are you talking about, or could you give > a link to the mail where you said it. Anything I remember was a > discussion about ugly magic initialization sequences due to poor > documentation. > > And below promised examples of the error pattern, it was time consuming > to find them, so please at least read them :) I've done better, below is what I hope a list of good arguments why the pattern is a bad idea, and why in some cases it can be justified. > Almost exactly the same patterns for the same purpose: > > 1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63 > Citation from the code: > To reduce the number of error checks in the code, we record the > first error > in atusb->err and reject all subsequent requests until the error is > cleared. That's about the worst example you could've used. Have you even looked at the code that uses this? It's completely crazy. So here we have the atusb_control_msg() function that stores this error, but then also propagates it to its caller. One of these callers is atusb_read_reg(), which also propagates the error or returns the register value if the read was successful. Now the really insane part is how this is then used in something like atusb_write_subreg(): orig = atusb_read_reg(atusb, reg); tmp = orig & ~mask; tmp |= (value << shift) & mask; if (tmp != orig) ret = atusb_write_reg(atusb, reg, tmp); So let's assume that atusb_control_msg() fails in the call to atusb_read_reg(). You'll be returning an error code, mask out some bits, OR in new ones and write the result to the register. So not only does the code not bother to check for errors, but it will also happily go and corrupt registers when an error has occurred while reading. > 2. http://lxr.free-electrons.com/source/drivers/md/dm-thin.c?v=4.4#L917 This is completely different from the panel driver because it's used to store a value from within callbacks that can't return one. > 3. http://lxr.free-electrons.com/source/net/9p/trans_fd.c?v=3.18#L297 Essentially the same thing. > 4. > http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-ctrls.c#L2234 Looks like this could be replaced by the more idiomatic use of ERR_PTR() encoding error codes. But the most significant difference here is that each use of the handler_set_err() function is followed by a return. So instead of ignoring errors like you do in the panel drivers, this does recognize them and aborts early, rather than trying to go through the remainder of the code, irrespective of how small the chances are of it succeeding. Or ignoring that /even if/ the remainder didn't fail, the one operation that fail might have been essential to the operation of the device. > 5. http://lxr.free-electrons.com/source/drivers/media/i2c/s5k5baf.c#L451 That's a particularly good example of why you shouldn't be doing this kind of thing. Consider what would happen in these cases if for example there was a problem with the I2C interface. There's a bunch of read and write sequences in that driver that go completely without checking for errors. Imagine how that will look to a user when the communication to a chip doesn't work. They'll get a load of error messages all saying that communication timed out, or that the slave isn't responding or what not. And worse still, for timeouts you're also going to introduce a bunch of error messages interleaved with potentially other useful messages from other drivers or the core. Depending on the number of access you have it might take seconds for all of the error messages to drain before you notice somewhere at the end of the code that something went wrong and decide to abort whatever you were trying to do. > This is my driver, I mention it here just to show it was not a > problem to merge it to media subsystem. That just shows what everybody knows: that maintainers care about different things at different levels. > Similar patterns: > > 6. http://lxr.free-electrons.com/source/fs/seq_file.c#L398 > Do not process object if buffer is full, it allows to do not check > buffer size after every write, for example: > > seq_printf(m, " hardirq-safe locks: %11lu\n", > > nr_hardirq_safe); > > seq_printf(m, " hardirq-unsafe locks: %11lu\n", > > nr_hardirq_unsafe); > > seq_printf(m, " softirq-safe locks: %11lu\n", > > nr_softirq_safe); > > seq_printf(m, " softirq-unsafe locks: %11lu\n", > > nr_softirq_unsafe); > > seq_printf(m, " irq-safe locks: %11lu\n", > > nr_irq_safe); > > seq_printf(m, " irq-unsafe locks: %11lu\n", > > nr_irq_unsafe); > > > > seq_printf(m, " hardirq-read-safe locks: %11lu\n", > > nr_hardirq_read_safe); > > seq_printf(m, " hardirq-read-unsafe locks: %11lu\n", > > nr_hardirq_read_unsafe); > > seq_printf(m, " softirq-read-safe locks: %11lu\n", > > nr_softirq_read_safe); > > seq_printf(m, " softirq-read-unsafe locks: %11lu\n", > > nr_softirq_read_unsafe); > > seq_printf(m, " irq-read-safe locks: %11lu\n", > > nr_irq_read_safe); > > seq_printf(m, " irq-read-unsafe locks: %11lu\n", > > nr_irq_read_unsafe); > > > > seq_printf(m, " uncategorized locks: %11lu\n", > > nr_uncategorized); > > seq_printf(m, " unused locks: %11lu\n", > > nr_unused); > > seq_printf(m, " max locking depth: %11u\n", > > max_lockdep_depth); > > Now try to imagine how it would look like if you add error checking > after each call. I think that's a fairly sane use-case for this kind of pattern. The big difference is that this condition is checked in subsequent accesses to shortcut failure paths. It's also very different in that it performs writes to memory and those aren't going to fail. The root cause of this overflow would be static in nature and likely found doing basic testing and fixed by making the buffer larger. That's contrary to a driver doing I/O (I2C, SPI, DSI, ...) that can fail unexpectedly for any number of reasons. > > 7. http://lxr.free-electrons.com/source/lib/devres.c#L129 > Postponed error check: > > */res = platform_get_resource(pdev, IORESOURCE_MEM, 0);/* > > /*b*/*/ase = devm_ioremap_resource(&pdev->dev, res);/* > > */if (IS_ERR(base))/* > > /**/*/return PTR_ERR(base);/* Heh, I wrote that =) This is also quite different from your usage in the panel driver. We do not simply ignore failure from platform_get_resource(), instead we leave it up to devm_ioremap_resource() to turn it into a meaningful error code and message. The function does this very early on, so the error condition is not ignored, as it is in the panel driver. Also doing this helps with providing unified error codes and messages across all callers, and removing a lot of boiler plate from drivers that previously used to come up with all sorts of meaningless error codes and completely inconsistent messages. I hope this somewhat clarifies my opposition to your usage of the pattern. Thierry
[toc] | [prev] | [next] | [standalone]
| From | Andrzej Hajda <a.hajda@samsung.com> |
|---|---|
| Date | 2017-02-03 10:00 +0100 |
| Message-ID | <t6HSO-7MR-7@gated-at.bofh.it> |
| In reply to | #1572561 |
Hi Thierry,
Finally something technical :)
On 02.02.2017 18:58, Thierry Reding wrote:
> On Tue, Jan 31, 2017 at 01:05:20PM +0100, Andrzej Hajda wrote:
>> On 31.01.2017 09:54, Thierry Reding wrote:
>>> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote:
>>>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글:
>>>>> Dear Thierry,
>>>>>
>>>>> Could you please review this patch?
>>>> Thierry, I think this patch has been reviewed enough but no comment
>>>> from you. Seems you are busy. I will pick up this.
>>> Sorry, but that's not how it works. This patch has gone through 8
>>> revisions within 4 weeks, and I tend to ignore patches like that until
>>> the dust settles.
>>>
>>> Other than that, this continues the same madness that I've repeatedly
>>> complained about in the past. The whole mechanism of running through a
>>> series of writes and not caring about errors until the very end is
>>> something we've discussed at length in the past.
>> Yes, we have discussed the pattern, but without any conclusion. The
>> pattern is correct, used in different places in kernel (see below for
>> examples) and significantly decreases source code size. Disallowing it
>> in panels subsystem just because of personal preferences of the
>> maintainer does not seem to be proper.
>>
>>> It also in large parts
>>> duplicates a bunch of functions from other Samsung panel drivers that I
>>> already said should eventually be moved to something saner.
>> Currently there are two Samsung panel drivers, one is on SPI bus,
>> another one is on DSI.
>> I am (co-)author of both drivers, they have some similarities but I did
>> not see any gain in making additional abstractions over transport layer
>> just to make one or two small functions common.
>> Could you be more precise what are you talking about, or could you give
>> a link to the mail where you said it. Anything I remember was a
>> discussion about ugly magic initialization sequences due to poor
>> documentation.
>>
>> And below promised examples of the error pattern, it was time consuming
>> to find them, so please at least read them :)
> I've done better, below is what I hope a list of good arguments why the
> pattern is a bad idea, and why in some cases it can be justified.
>
>> Almost exactly the same patterns for the same purpose:
>>
>> 1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63
>> Citation from the code:
>> To reduce the number of error checks in the code, we record the
>> first error
>> in atusb->err and reject all subsequent requests until the error is
>> cleared.
> That's about the worst example you could've used. Have you even looked
> at the code that uses this? It's completely crazy. So here we have the
> atusb_control_msg() function that stores this error, but then also
> propagates it to its caller. One of these callers is atusb_read_reg(),
> which also propagates the error or returns the register value if the
> read was successful.
>
> Now the really insane part is how this is then used in something like
> atusb_write_subreg():
>
> orig = atusb_read_reg(atusb, reg);
> tmp = orig & ~mask;
> tmp |= (value << shift) & mask;
>
> if (tmp != orig)
> ret = atusb_write_reg(atusb, reg, tmp);
>
> So let's assume that atusb_control_msg() fails in the call to
> atusb_read_reg(). You'll be returning an error code, mask out some bits,
> OR in new ones and write the result to the register. So not only does
> the code not bother to check for errors, but it will also happily go and
> corrupt registers when an error has occurred while reading.
Not true, in case of error in atusb_read_reg atusb_write_reg will do
nothing because atusb->err is set !
And this is strong point of the idiom - you will not be able to perform
transfer until the error is explicitly cleared.
With this idiom it is enough to put guards only in one/two/few places,
in traditional error handling you just need to put checks after every
function call and it is quite common situation that developers forgot to
do that, for example look at mipi calls here [1] :)
[1]:
http://lxr.free-electrons.com/source/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c#L160
So the function is correct, but to avoid fooling unaware readers I would
add error checking after read:
orig = atusb_read_reg(atusb, reg);
if (atusb->err)
return err;
>> 2. http://lxr.free-electrons.com/source/drivers/md/dm-thin.c?v=4.4#L917
> This is completely different from the panel driver because it's used to
> store a value from within callbacks that can't return one.
This is internal framework of the driver, so nothing prevents developer
from implementing callbacks that return value.
Apparently storing error in the object(struct dm_thin_new_mapping) is
good and convenient :)
>
>> 3. http://lxr.free-electrons.com/source/net/9p/trans_fd.c?v=3.18#L297
> Essentially the same thing.
The same here.
>
>> 4.
>> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-ctrls.c#L2234
> Looks like this could be replaced by the more idiomatic use of ERR_PTR()
> encoding error codes. But the most significant difference here is that
> each use of the handler_set_err() function is followed by a return. So
> instead of ignoring errors like you do in the panel drivers, this does
> recognize them and aborts early, rather than trying to go through the
> remainder of the code, irrespective of how small the chances are of it
> succeeding. Or ignoring that /even if/ the remainder didn't fail, the
> one operation that fail might have been essential to the operation of
> the device.
I have an impression that you do not understand the idiom. It does not
allow to ignore error - as soon as the error is detected, guard is set
and no further harm can be done.
Going back to V4L2, look at the usage of the idiom [2]:
v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_gen, NULL);
v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_vid, NULL);
v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_aud, NULL);
v4l2_ctrl_add_handler(hdl_vid_cap, hdl_streaming, NULL);
v4l2_ctrl_add_handler(hdl_vid_cap, hdl_sdtv_cap, NULL);
v4l2_ctrl_add_handler(hdl_vid_cap, hdl_loop_cap, NULL);
if (hdl_vid_cap->error)
return hdl_vid_cap->error;
Again, the point is you do not need to use old construct, which enlarges
the code about three times:
err = func(obj,...);
if (err < 0)
return err;
Instead you just call func(obj,...), and the burden of error checking is
put into the function, but for this err must be stored in object.
[2]:
http://lxr.free-electrons.com/source/drivers/media/platform/vivid/vivid-ctrls.c#L1630
>
>> 5. http://lxr.free-electrons.com/source/drivers/media/i2c/s5k5baf.c#L451
> That's a particularly good example of why you shouldn't be doing this
> kind of thing. Consider what would happen in these cases if for example
> there was a problem with the I2C interface. There's a bunch of read and
> write sequences in that driver that go completely without checking for
> errors.
Not true, no further transfer will be performed.
> Imagine how that will look to a user when the communication to a
> chip doesn't work. They'll get a load of error messages all saying that
> communication timed out, or that the slave isn't responding or what not.
> And worse still, for timeouts you're also going to introduce a bunch of
> error messages interleaved with potentially other useful messages from
> other drivers or the core. Depending on the number of access you have it
> might take seconds for all of the error messages to drain before you
> notice somewhere at the end of the code that something went wrong and
> decide to abort whatever you were trying to do.
Again, not true at all.
>
>> This is my driver, I mention it here just to show it was not a
>> problem to merge it to media subsystem.
> That just shows what everybody knows: that maintainers care about
> different things at different levels.
>
>> Similar patterns:
>>
>> 6. http://lxr.free-electrons.com/source/fs/seq_file.c#L398
>> Do not process object if buffer is full, it allows to do not check
>> buffer size after every write, for example:
>>> seq_printf(m, " hardirq-safe locks: %11lu\n",
>>> nr_hardirq_safe);
>>> seq_printf(m, " hardirq-unsafe locks: %11lu\n",
>>> nr_hardirq_unsafe);
>>> seq_printf(m, " softirq-safe locks: %11lu\n",
>>> nr_softirq_safe);
>>> seq_printf(m, " softirq-unsafe locks: %11lu\n",
>>> nr_softirq_unsafe);
>>> seq_printf(m, " irq-safe locks: %11lu\n",
>>> nr_irq_safe);
>>> seq_printf(m, " irq-unsafe locks: %11lu\n",
>>> nr_irq_unsafe);
>>>
>>> seq_printf(m, " hardirq-read-safe locks: %11lu\n",
>>> nr_hardirq_read_safe);
>>> seq_printf(m, " hardirq-read-unsafe locks: %11lu\n",
>>> nr_hardirq_read_unsafe);
>>> seq_printf(m, " softirq-read-safe locks: %11lu\n",
>>> nr_softirq_read_safe);
>>> seq_printf(m, " softirq-read-unsafe locks: %11lu\n",
>>> nr_softirq_read_unsafe);
>>> seq_printf(m, " irq-read-safe locks: %11lu\n",
>>> nr_irq_read_safe);
>>> seq_printf(m, " irq-read-unsafe locks: %11lu\n",
>>> nr_irq_read_unsafe);
>>>
>>> seq_printf(m, " uncategorized locks: %11lu\n",
>>> nr_uncategorized);
>>> seq_printf(m, " unused locks: %11lu\n",
>>> nr_unused);
>>> seq_printf(m, " max locking depth: %11u\n",
>>> max_lockdep_depth);
>> Now try to imagine how it would look like if you add error checking
>> after each call.
> I think that's a fairly sane use-case for this kind of pattern. The big
> difference is that this condition is checked in subsequent accesses to
> shortcut failure paths. It's also very different in that it performs
> writes to memory and those aren't going to fail. The root cause of this
> overflow would be static in nature and likely found doing basic testing
> and fixed by making the buffer larger.
>
> That's contrary to a driver doing I/O (I2C, SPI, DSI, ...) that can fail
> unexpectedly for any number of reasons.
The idiom is still the same - storing error state in the object allows
to move error checking inside called functions, removing much of
redundant code from caller.
>
>> 7. http://lxr.free-electrons.com/source/lib/devres.c#L129
>> Postponed error check:
>>> */res = platform_get_resource(pdev, IORESOURCE_MEM, 0);/*
>>> /*b*/*/ase = devm_ioremap_resource(&pdev->dev, res);/*
>>> */if (IS_ERR(base))/*
>>> /**/*/return PTR_ERR(base);/*
> Heh, I wrote that =)
>
> This is also quite different from your usage in the panel driver. We do
> not simply ignore failure from platform_get_resource(), instead we leave
> it up to devm_ioremap_resource() to turn it into a meaningful error code
> and message. The function does this very early on, so the error
> condition is not ignored, as it is in the panel driver.
Claims about the panel again not true, reasons described above.
The similarity here is that you do not perform error checking in the
caller, you just blindly pass the 'object' to the next function, and
still everything is handled correctly.
>
> Also doing this helps with providing unified error codes and messages
> across all callers, and removing a lot of boiler plate from drivers that
> previously used to come up with all sorts of meaningless error codes and
> completely inconsistent messages.
I like this pattern and I agree with this reasoning I just want to allow
usage of it more widely, or at least not to block patches using it :)
Regards
Andrzej
[toc] | [prev] | [next] | [standalone]
| From | Daniel Vetter <daniel@ffwll.ch> |
|---|---|
| Date | 2017-02-03 10:00 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t6HSO-7MR-15@gated-at.bofh.it> |
| In reply to | #1572953 |
On Fri, Feb 03, 2017 at 09:54:42AM +0100, Andrzej Hajda wrote: > Hi Thierry, > > Finally something technical :) Please read Thierry's other response, I think a time-out on this thread would be good for everyone. Also I'm not sure you're introductory comment was good here, it can be read as extremely sarcastic and dismissive of Thierry. That doesn't help, and we expect everyone to be respective of each another here on dri-devel. Thierry, please keep your long w/e and only read this when you're back next week :-) Cheers, Daniel > > On 02.02.2017 18:58, Thierry Reding wrote: > > On Tue, Jan 31, 2017 at 01:05:20PM +0100, Andrzej Hajda wrote: > >> On 31.01.2017 09:54, Thierry Reding wrote: > >>> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > >>>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > >>>>> Dear Thierry, > >>>>> > >>>>> Could you please review this patch? > >>>> Thierry, I think this patch has been reviewed enough but no comment > >>>> from you. Seems you are busy. I will pick up this. > >>> Sorry, but that's not how it works. This patch has gone through 8 > >>> revisions within 4 weeks, and I tend to ignore patches like that until > >>> the dust settles. > >>> > >>> Other than that, this continues the same madness that I've repeatedly > >>> complained about in the past. The whole mechanism of running through a > >>> series of writes and not caring about errors until the very end is > >>> something we've discussed at length in the past. > >> Yes, we have discussed the pattern, but without any conclusion. The > >> pattern is correct, used in different places in kernel (see below for > >> examples) and significantly decreases source code size. Disallowing it > >> in panels subsystem just because of personal preferences of the > >> maintainer does not seem to be proper. > >> > >>> It also in large parts > >>> duplicates a bunch of functions from other Samsung panel drivers that I > >>> already said should eventually be moved to something saner. > >> Currently there are two Samsung panel drivers, one is on SPI bus, > >> another one is on DSI. > >> I am (co-)author of both drivers, they have some similarities but I did > >> not see any gain in making additional abstractions over transport layer > >> just to make one or two small functions common. > >> Could you be more precise what are you talking about, or could you give > >> a link to the mail where you said it. Anything I remember was a > >> discussion about ugly magic initialization sequences due to poor > >> documentation. > >> > >> And below promised examples of the error pattern, it was time consuming > >> to find them, so please at least read them :) > > I've done better, below is what I hope a list of good arguments why the > > pattern is a bad idea, and why in some cases it can be justified. > > > >> Almost exactly the same patterns for the same purpose: > >> > >> 1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63 > >> Citation from the code: > >> To reduce the number of error checks in the code, we record the > >> first error > >> in atusb->err and reject all subsequent requests until the error is > >> cleared. > > That's about the worst example you could've used. Have you even looked > > at the code that uses this? It's completely crazy. So here we have the > > atusb_control_msg() function that stores this error, but then also > > propagates it to its caller. One of these callers is atusb_read_reg(), > > which also propagates the error or returns the register value if the > > read was successful. > > > > Now the really insane part is how this is then used in something like > > atusb_write_subreg(): > > > > orig = atusb_read_reg(atusb, reg); > > tmp = orig & ~mask; > > tmp |= (value << shift) & mask; > > > > if (tmp != orig) > > ret = atusb_write_reg(atusb, reg, tmp); > > > > So let's assume that atusb_control_msg() fails in the call to > > atusb_read_reg(). You'll be returning an error code, mask out some bits, > > OR in new ones and write the result to the register. So not only does > > the code not bother to check for errors, but it will also happily go and > > corrupt registers when an error has occurred while reading. > > Not true, in case of error in atusb_read_reg atusb_write_reg will do > nothing because atusb->err is set ! > And this is strong point of the idiom - you will not be able to perform > transfer until the error is explicitly cleared. > With this idiom it is enough to put guards only in one/two/few places, > in traditional error handling you just need to put checks after every > function call and it is quite common situation that developers forgot to > do that, for example look at mipi calls here [1] :) > [1]: > http://lxr.free-electrons.com/source/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c#L160 > > So the function is correct, but to avoid fooling unaware readers I would > add error checking after read: > > orig = atusb_read_reg(atusb, reg); > if (atusb->err) > return err; > > > >> 2. http://lxr.free-electrons.com/source/drivers/md/dm-thin.c?v=4.4#L917 > > This is completely different from the panel driver because it's used to > > store a value from within callbacks that can't return one. > > This is internal framework of the driver, so nothing prevents developer > from implementing callbacks that return value. > Apparently storing error in the object(struct dm_thin_new_mapping) is > good and convenient :) > > > > >> 3. http://lxr.free-electrons.com/source/net/9p/trans_fd.c?v=3.18#L297 > > Essentially the same thing. > > The same here. > > > > >> 4. > >> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-ctrls.c#L2234 > > Looks like this could be replaced by the more idiomatic use of ERR_PTR() > > encoding error codes. But the most significant difference here is that > > each use of the handler_set_err() function is followed by a return. So > > instead of ignoring errors like you do in the panel drivers, this does > > recognize them and aborts early, rather than trying to go through the > > remainder of the code, irrespective of how small the chances are of it > > succeeding. Or ignoring that /even if/ the remainder didn't fail, the > > one operation that fail might have been essential to the operation of > > the device. > > I have an impression that you do not understand the idiom. It does not > allow to ignore error - as soon as the error is detected, guard is set > and no further harm can be done. > Going back to V4L2, look at the usage of the idiom [2]: > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_gen, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_vid, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_aud, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_streaming, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_sdtv_cap, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_loop_cap, NULL); > if (hdl_vid_cap->error) > return hdl_vid_cap->error; > > Again, the point is you do not need to use old construct, which enlarges > the code about three times: > err = func(obj,...); > if (err < 0) > return err; > > Instead you just call func(obj,...), and the burden of error checking is > put into the function, but for this err must be stored in object. > > [2]: > http://lxr.free-electrons.com/source/drivers/media/platform/vivid/vivid-ctrls.c#L1630 > > > > >> 5. http://lxr.free-electrons.com/source/drivers/media/i2c/s5k5baf.c#L451 > > That's a particularly good example of why you shouldn't be doing this > > kind of thing. Consider what would happen in these cases if for example > > there was a problem with the I2C interface. There's a bunch of read and > > write sequences in that driver that go completely without checking for > > errors. > > Not true, no further transfer will be performed. > > > Imagine how that will look to a user when the communication to a > > chip doesn't work. They'll get a load of error messages all saying that > > communication timed out, or that the slave isn't responding or what not. > > And worse still, for timeouts you're also going to introduce a bunch of > > error messages interleaved with potentially other useful messages from > > other drivers or the core. Depending on the number of access you have it > > might take seconds for all of the error messages to drain before you > > notice somewhere at the end of the code that something went wrong and > > decide to abort whatever you were trying to do. > > Again, not true at all. > > > > >> This is my driver, I mention it here just to show it was not a > >> problem to merge it to media subsystem. > > That just shows what everybody knows: that maintainers care about > > different things at different levels. > > > >> Similar patterns: > >> > >> 6. http://lxr.free-electrons.com/source/fs/seq_file.c#L398 > >> Do not process object if buffer is full, it allows to do not check > >> buffer size after every write, for example: > >>> seq_printf(m, " hardirq-safe locks: %11lu\n", > >>> nr_hardirq_safe); > >>> seq_printf(m, " hardirq-unsafe locks: %11lu\n", > >>> nr_hardirq_unsafe); > >>> seq_printf(m, " softirq-safe locks: %11lu\n", > >>> nr_softirq_safe); > >>> seq_printf(m, " softirq-unsafe locks: %11lu\n", > >>> nr_softirq_unsafe); > >>> seq_printf(m, " irq-safe locks: %11lu\n", > >>> nr_irq_safe); > >>> seq_printf(m, " irq-unsafe locks: %11lu\n", > >>> nr_irq_unsafe); > >>> > >>> seq_printf(m, " hardirq-read-safe locks: %11lu\n", > >>> nr_hardirq_read_safe); > >>> seq_printf(m, " hardirq-read-unsafe locks: %11lu\n", > >>> nr_hardirq_read_unsafe); > >>> seq_printf(m, " softirq-read-safe locks: %11lu\n", > >>> nr_softirq_read_safe); > >>> seq_printf(m, " softirq-read-unsafe locks: %11lu\n", > >>> nr_softirq_read_unsafe); > >>> seq_printf(m, " irq-read-safe locks: %11lu\n", > >>> nr_irq_read_safe); > >>> seq_printf(m, " irq-read-unsafe locks: %11lu\n", > >>> nr_irq_read_unsafe); > >>> > >>> seq_printf(m, " uncategorized locks: %11lu\n", > >>> nr_uncategorized); > >>> seq_printf(m, " unused locks: %11lu\n", > >>> nr_unused); > >>> seq_printf(m, " max locking depth: %11u\n", > >>> max_lockdep_depth); > >> Now try to imagine how it would look like if you add error checking > >> after each call. > > I think that's a fairly sane use-case for this kind of pattern. The big > > difference is that this condition is checked in subsequent accesses to > > shortcut failure paths. It's also very different in that it performs > > writes to memory and those aren't going to fail. The root cause of this > > overflow would be static in nature and likely found doing basic testing > > and fixed by making the buffer larger. > > > > That's contrary to a driver doing I/O (I2C, SPI, DSI, ...) that can fail > > unexpectedly for any number of reasons. > > The idiom is still the same - storing error state in the object allows > to move error checking inside called functions, removing much of > redundant code from caller. > > > > >> 7. http://lxr.free-electrons.com/source/lib/devres.c#L129 > >> Postponed error check: > >>> */res = platform_get_resource(pdev, IORESOURCE_MEM, 0);/* > >>> /*b*/*/ase = devm_ioremap_resource(&pdev->dev, res);/* > >>> */if (IS_ERR(base))/* > >>> /**/*/return PTR_ERR(base);/* > > Heh, I wrote that =) > > > > This is also quite different from your usage in the panel driver. We do > > not simply ignore failure from platform_get_resource(), instead we leave > > it up to devm_ioremap_resource() to turn it into a meaningful error code > > and message. The function does this very early on, so the error > > condition is not ignored, as it is in the panel driver. > > Claims about the panel again not true, reasons described above. > > The similarity here is that you do not perform error checking in the > caller, you just blindly pass the 'object' to the next function, and > still everything is handled correctly. > > > > > Also doing this helps with providing unified error codes and messages > > across all callers, and removing a lot of boiler plate from drivers that > > previously used to come up with all sorts of meaningless error codes and > > completely inconsistent messages. > > I like this pattern and I agree with this reasoning I just want to allow > usage of it more widely, or at least not to block patches using it :) > > > Regards > Andrzej > > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
[toc] | [prev] | [next] | [standalone]
| From | Andrzej Hajda <a.hajda@samsung.com> |
|---|---|
| Date | 2017-02-06 10:20 +0100 |
| Message-ID | <t7NCO-33M-13@gated-at.bofh.it> |
| In reply to | #1572956 |
On 03.02.2017 09:58, Daniel Vetter wrote: > On Fri, Feb 03, 2017 at 09:54:42AM +0100, Andrzej Hajda wrote: >> Hi Thierry, >> >> Finally something technical :) > Please read Thierry's other response, I think a time-out on this thread > would be good for everyone. > > Also I'm not sure you're introductory comment was good here, it can be > read as extremely sarcastic and dismissive of Thierry. That doesn't help, > and we expect everyone to be respective of each another here on dri-devel. I do not know why do you suggest that my response can be sarcastic. You can see our whole conversation from this thread even in this email, there is serious disagreement on the matter and we try to figure it out and we are focused on technical side, no whining, no personal attacks. I hope Thierry sees it also this way, if not, I clearly state that this phrase has no hidden meaning. I am just glad we can focus on technical side of the problem. I hope this will end any possible misreadings. Regards Andrzej > > Thierry, please keep your long w/e and only read this when you're back > next week :-) > > Cheers, Daniel > >> On 02.02.2017 18:58, Thierry Reding wrote: >>> On Tue, Jan 31, 2017 at 01:05:20PM +0100, Andrzej Hajda wrote: >>>> On 31.01.2017 09:54, Thierry Reding wrote: >>>>> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: >>>>>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: >>>>>>> Dear Thierry, >>>>>>> >>>>>>> Could you please review this patch? >>>>>> Thierry, I think this patch has been reviewed enough but no comment >>>>>> from you. Seems you are busy. I will pick up this. >>>>> Sorry, but that's not how it works. This patch has gone through 8 >>>>> revisions within 4 weeks, and I tend to ignore patches like that until >>>>> the dust settles. >>>>> >>>>> Other than that, this continues the same madness that I've repeatedly >>>>> complained about in the past. The whole mechanism of running through a >>>>> series of writes and not caring about errors until the very end is >>>>> something we've discussed at length in the past. >>>> Yes, we have discussed the pattern, but without any conclusion. The >>>> pattern is correct, used in different places in kernel (see below for >>>> examples) and significantly decreases source code size. Disallowing it >>>> in panels subsystem just because of personal preferences of the >>>> maintainer does not seem to be proper. >>>> >>>>> It also in large parts >>>>> duplicates a bunch of functions from other Samsung panel drivers that I >>>>> already said should eventually be moved to something saner. >>>> Currently there are two Samsung panel drivers, one is on SPI bus, >>>> another one is on DSI. >>>> I am (co-)author of both drivers, they have some similarities but I did >>>> not see any gain in making additional abstractions over transport layer >>>> just to make one or two small functions common. >>>> Could you be more precise what are you talking about, or could you give >>>> a link to the mail where you said it. Anything I remember was a >>>> discussion about ugly magic initialization sequences due to poor >>>> documentation. >>>> >>>> And below promised examples of the error pattern, it was time consuming >>>> to find them, so please at least read them :) >>> I've done better, below is what I hope a list of good arguments why the >>> pattern is a bad idea, and why in some cases it can be justified. >>> >>>> Almost exactly the same patterns for the same purpose: >>>> >>>> 1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63 >>>> Citation from the code: >>>> To reduce the number of error checks in the code, we record the >>>> first error >>>> in atusb->err and reject all subsequent requests until the error is >>>> cleared. >>> That's about the worst example you could've used. Have you even looked >>> at the code that uses this? It's completely crazy. So here we have the >>> atusb_control_msg() function that stores this error, but then also >>> propagates it to its caller. One of these callers is atusb_read_reg(), >>> which also propagates the error or returns the register value if the >>> read was successful. >>> >>> Now the really insane part is how this is then used in something like >>> atusb_write_subreg(): >>> >>> orig = atusb_read_reg(atusb, reg); >>> tmp = orig & ~mask; >>> tmp |= (value << shift) & mask; >>> >>> if (tmp != orig) >>> ret = atusb_write_reg(atusb, reg, tmp); >>> >>> So let's assume that atusb_control_msg() fails in the call to >>> atusb_read_reg(). You'll be returning an error code, mask out some bits, >>> OR in new ones and write the result to the register. So not only does >>> the code not bother to check for errors, but it will also happily go and >>> corrupt registers when an error has occurred while reading. >> Not true, in case of error in atusb_read_reg atusb_write_reg will do >> nothing because atusb->err is set ! >> And this is strong point of the idiom - you will not be able to perform >> transfer until the error is explicitly cleared. >> With this idiom it is enough to put guards only in one/two/few places, >> in traditional error handling you just need to put checks after every >> function call and it is quite common situation that developers forgot to >> do that, for example look at mipi calls here [1] :) >> [1]: >> http://lxr.free-electrons.com/source/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c#L160 >> >> So the function is correct, but to avoid fooling unaware readers I would >> add error checking after read: >> >> orig = atusb_read_reg(atusb, reg); >> if (atusb->err) >> return err; >> >> >>>> 2. http://lxr.free-electrons.com/source/drivers/md/dm-thin.c?v=4.4#L917 >>> This is completely different from the panel driver because it's used to >>> store a value from within callbacks that can't return one. >> This is internal framework of the driver, so nothing prevents developer >> from implementing callbacks that return value. >> Apparently storing error in the object(struct dm_thin_new_mapping) is >> good and convenient :) >> >>>> 3. http://lxr.free-electrons.com/source/net/9p/trans_fd.c?v=3.18#L297 >>> Essentially the same thing. >> The same here. >> >>>> 4. >>>> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-ctrls.c#L2234 >>> Looks like this could be replaced by the more idiomatic use of ERR_PTR() >>> encoding error codes. But the most significant difference here is that >>> each use of the handler_set_err() function is followed by a return. So >>> instead of ignoring errors like you do in the panel drivers, this does >>> recognize them and aborts early, rather than trying to go through the >>> remainder of the code, irrespective of how small the chances are of it >>> succeeding. Or ignoring that /even if/ the remainder didn't fail, the >>> one operation that fail might have been essential to the operation of >>> the device. >> I have an impression that you do not understand the idiom. It does not >> allow to ignore error - as soon as the error is detected, guard is set >> and no further harm can be done. >> Going back to V4L2, look at the usage of the idiom [2]: >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_gen, NULL); >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_vid, NULL); >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_aud, NULL); >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_streaming, NULL); >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_sdtv_cap, NULL); >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_loop_cap, NULL); >> if (hdl_vid_cap->error) >> return hdl_vid_cap->error; >> >> Again, the point is you do not need to use old construct, which enlarges >> the code about three times: >> err = func(obj,...); >> if (err < 0) >> return err; >> >> Instead you just call func(obj,...), and the burden of error checking is >> put into the function, but for this err must be stored in object. >> >> [2]: >> http://lxr.free-electrons.com/source/drivers/media/platform/vivid/vivid-ctrls.c#L1630 >> >>>> 5. http://lxr.free-electrons.com/source/drivers/media/i2c/s5k5baf.c#L451 >>> That's a particularly good example of why you shouldn't be doing this >>> kind of thing. Consider what would happen in these cases if for example >>> there was a problem with the I2C interface. There's a bunch of read and >>> write sequences in that driver that go completely without checking for >>> errors. >> Not true, no further transfer will be performed. >> >>> Imagine how that will look to a user when the communication to a >>> chip doesn't work. They'll get a load of error messages all saying that >>> communication timed out, or that the slave isn't responding or what not. >>> And worse still, for timeouts you're also going to introduce a bunch of >>> error messages interleaved with potentially other useful messages from >>> other drivers or the core. Depending on the number of access you have it >>> might take seconds for all of the error messages to drain before you >>> notice somewhere at the end of the code that something went wrong and >>> decide to abort whatever you were trying to do. >> Again, not true at all. >> >>>> This is my driver, I mention it here just to show it was not a >>>> problem to merge it to media subsystem. >>> That just shows what everybody knows: that maintainers care about >>> different things at different levels. >>> >>>> Similar patterns: >>>> >>>> 6. http://lxr.free-electrons.com/source/fs/seq_file.c#L398 >>>> Do not process object if buffer is full, it allows to do not check >>>> buffer size after every write, for example: >>>>> seq_printf(m, " hardirq-safe locks: %11lu\n", >>>>> nr_hardirq_safe); >>>>> seq_printf(m, " hardirq-unsafe locks: %11lu\n", >>>>> nr_hardirq_unsafe); >>>>> seq_printf(m, " softirq-safe locks: %11lu\n", >>>>> nr_softirq_safe); >>>>> seq_printf(m, " softirq-unsafe locks: %11lu\n", >>>>> nr_softirq_unsafe); >>>>> seq_printf(m, " irq-safe locks: %11lu\n", >>>>> nr_irq_safe); >>>>> seq_printf(m, " irq-unsafe locks: %11lu\n", >>>>> nr_irq_unsafe); >>>>> >>>>> seq_printf(m, " hardirq-read-safe locks: %11lu\n", >>>>> nr_hardirq_read_safe); >>>>> seq_printf(m, " hardirq-read-unsafe locks: %11lu\n", >>>>> nr_hardirq_read_unsafe); >>>>> seq_printf(m, " softirq-read-safe locks: %11lu\n", >>>>> nr_softirq_read_safe); >>>>> seq_printf(m, " softirq-read-unsafe locks: %11lu\n", >>>>> nr_softirq_read_unsafe); >>>>> seq_printf(m, " irq-read-safe locks: %11lu\n", >>>>> nr_irq_read_safe); >>>>> seq_printf(m, " irq-read-unsafe locks: %11lu\n", >>>>> nr_irq_read_unsafe); >>>>> >>>>> seq_printf(m, " uncategorized locks: %11lu\n", >>>>> nr_uncategorized); >>>>> seq_printf(m, " unused locks: %11lu\n", >>>>> nr_unused); >>>>> seq_printf(m, " max locking depth: %11u\n", >>>>> max_lockdep_depth); >>>> Now try to imagine how it would look like if you add error checking >>>> after each call. >>> I think that's a fairly sane use-case for this kind of pattern. The big >>> difference is that this condition is checked in subsequent accesses to >>> shortcut failure paths. It's also very different in that it performs >>> writes to memory and those aren't going to fail. The root cause of this >>> overflow would be static in nature and likely found doing basic testing >>> and fixed by making the buffer larger. >>> >>> That's contrary to a driver doing I/O (I2C, SPI, DSI, ...) that can fail >>> unexpectedly for any number of reasons. >> The idiom is still the same - storing error state in the object allows >> to move error checking inside called functions, removing much of >> redundant code from caller. >> >>>> 7. http://lxr.free-electrons.com/source/lib/devres.c#L129 >>>> Postponed error check: >>>>> */res = platform_get_resource(pdev, IORESOURCE_MEM, 0);/* >>>>> /*b*/*/ase = devm_ioremap_resource(&pdev->dev, res);/* >>>>> */if (IS_ERR(base))/* >>>>> /**/*/return PTR_ERR(base);/* >>> Heh, I wrote that =) >>> >>> This is also quite different from your usage in the panel driver. We do >>> not simply ignore failure from platform_get_resource(), instead we leave >>> it up to devm_ioremap_resource() to turn it into a meaningful error code >>> and message. The function does this very early on, so the error >>> condition is not ignored, as it is in the panel driver. >> Claims about the panel again not true, reasons described above. >> >> The similarity here is that you do not perform error checking in the >> caller, you just blindly pass the 'object' to the next function, and >> still everything is handled correctly. >> >>> Also doing this helps with providing unified error codes and messages >>> across all callers, and removing a lot of boiler plate from drivers that >>> previously used to come up with all sorts of meaningless error codes and >>> completely inconsistent messages. >> I like this pattern and I agree with this reasoning I just want to allow >> usage of it more widely, or at least not to block patches using it :) >> >> >> Regards >> Andrzej >> >> >> _______________________________________________ >> dri-devel mailing list >> dri-devel@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/dri-devel
[toc] | [prev] | [next] | [standalone]
| From | Daniel Vetter <daniel@ffwll.ch> |
|---|---|
| Date | 2017-02-06 10:50 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t7O5P-3el-13@gated-at.bofh.it> |
| In reply to | #1574485 |
Hi Andrzej, On Mon, Feb 06, 2017 at 10:12:41AM +0100, Andrzej Hajda wrote: > On 03.02.2017 09:58, Daniel Vetter wrote: > > On Fri, Feb 03, 2017 at 09:54:42AM +0100, Andrzej Hajda wrote: > >> Hi Thierry, > >> > >> Finally something technical :) > > Please read Thierry's other response, I think a time-out on this thread > > would be good for everyone. > > > > Also I'm not sure you're introductory comment was good here, it can be > > read as extremely sarcastic and dismissive of Thierry. That doesn't help, > > and we expect everyone to be respective of each another here on dri-devel. > > I do not know why do you suggest that my response can be sarcastic. > You can see our whole conversation from this thread even in this email, > there is serious disagreement on the matter and we try to figure it out > and we are focused on technical side, no whining, no personal attacks. > I hope Thierry sees it also this way, if not, I clearly state that this > phrase has no hidden meaning. I am just glad we can focus on technical > side of the problem. > I hope this will end any possible misreadings. Sorry, I didn't want to attack you at all, but assumed that you mean well. Like everyone else in this thread here. I just wanted to highlight that in a tricky situation like this, jokes can be misread easily. And personally I found it rather sarcastic, that's why I said "can". But since everyone here on dri-devel tries to be respectful of each another, no harm done. Cheers, Daniel > > Regards > Andrzej > > > > > > Thierry, please keep your long w/e and only read this when you're back > > next week :-) > > > > Cheers, Daniel > > > >> On 02.02.2017 18:58, Thierry Reding wrote: > >>> On Tue, Jan 31, 2017 at 01:05:20PM +0100, Andrzej Hajda wrote: > >>>> On 31.01.2017 09:54, Thierry Reding wrote: > >>>>> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > >>>>>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > >>>>>>> Dear Thierry, > >>>>>>> > >>>>>>> Could you please review this patch? > >>>>>> Thierry, I think this patch has been reviewed enough but no comment > >>>>>> from you. Seems you are busy. I will pick up this. > >>>>> Sorry, but that's not how it works. This patch has gone through 8 > >>>>> revisions within 4 weeks, and I tend to ignore patches like that until > >>>>> the dust settles. > >>>>> > >>>>> Other than that, this continues the same madness that I've repeatedly > >>>>> complained about in the past. The whole mechanism of running through a > >>>>> series of writes and not caring about errors until the very end is > >>>>> something we've discussed at length in the past. > >>>> Yes, we have discussed the pattern, but without any conclusion. The > >>>> pattern is correct, used in different places in kernel (see below for > >>>> examples) and significantly decreases source code size. Disallowing it > >>>> in panels subsystem just because of personal preferences of the > >>>> maintainer does not seem to be proper. > >>>> > >>>>> It also in large parts > >>>>> duplicates a bunch of functions from other Samsung panel drivers that I > >>>>> already said should eventually be moved to something saner. > >>>> Currently there are two Samsung panel drivers, one is on SPI bus, > >>>> another one is on DSI. > >>>> I am (co-)author of both drivers, they have some similarities but I did > >>>> not see any gain in making additional abstractions over transport layer > >>>> just to make one or two small functions common. > >>>> Could you be more precise what are you talking about, or could you give > >>>> a link to the mail where you said it. Anything I remember was a > >>>> discussion about ugly magic initialization sequences due to poor > >>>> documentation. > >>>> > >>>> And below promised examples of the error pattern, it was time consuming > >>>> to find them, so please at least read them :) > >>> I've done better, below is what I hope a list of good arguments why the > >>> pattern is a bad idea, and why in some cases it can be justified. > >>> > >>>> Almost exactly the same patterns for the same purpose: > >>>> > >>>> 1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63 > >>>> Citation from the code: > >>>> To reduce the number of error checks in the code, we record the > >>>> first error > >>>> in atusb->err and reject all subsequent requests until the error is > >>>> cleared. > >>> That's about the worst example you could've used. Have you even looked > >>> at the code that uses this? It's completely crazy. So here we have the > >>> atusb_control_msg() function that stores this error, but then also > >>> propagates it to its caller. One of these callers is atusb_read_reg(), > >>> which also propagates the error or returns the register value if the > >>> read was successful. > >>> > >>> Now the really insane part is how this is then used in something like > >>> atusb_write_subreg(): > >>> > >>> orig = atusb_read_reg(atusb, reg); > >>> tmp = orig & ~mask; > >>> tmp |= (value << shift) & mask; > >>> > >>> if (tmp != orig) > >>> ret = atusb_write_reg(atusb, reg, tmp); > >>> > >>> So let's assume that atusb_control_msg() fails in the call to > >>> atusb_read_reg(). You'll be returning an error code, mask out some bits, > >>> OR in new ones and write the result to the register. So not only does > >>> the code not bother to check for errors, but it will also happily go and > >>> corrupt registers when an error has occurred while reading. > >> Not true, in case of error in atusb_read_reg atusb_write_reg will do > >> nothing because atusb->err is set ! > >> And this is strong point of the idiom - you will not be able to perform > >> transfer until the error is explicitly cleared. > >> With this idiom it is enough to put guards only in one/two/few places, > >> in traditional error handling you just need to put checks after every > >> function call and it is quite common situation that developers forgot to > >> do that, for example look at mipi calls here [1] :) > >> [1]: > >> http://lxr.free-electrons.com/source/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c#L160 > >> > >> So the function is correct, but to avoid fooling unaware readers I would > >> add error checking after read: > >> > >> orig = atusb_read_reg(atusb, reg); > >> if (atusb->err) > >> return err; > >> > >> > >>>> 2. http://lxr.free-electrons.com/source/drivers/md/dm-thin.c?v=4.4#L917 > >>> This is completely different from the panel driver because it's used to > >>> store a value from within callbacks that can't return one. > >> This is internal framework of the driver, so nothing prevents developer > >> from implementing callbacks that return value. > >> Apparently storing error in the object(struct dm_thin_new_mapping) is > >> good and convenient :) > >> > >>>> 3. http://lxr.free-electrons.com/source/net/9p/trans_fd.c?v=3.18#L297 > >>> Essentially the same thing. > >> The same here. > >> > >>>> 4. > >>>> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-ctrls.c#L2234 > >>> Looks like this could be replaced by the more idiomatic use of ERR_PTR() > >>> encoding error codes. But the most significant difference here is that > >>> each use of the handler_set_err() function is followed by a return. So > >>> instead of ignoring errors like you do in the panel drivers, this does > >>> recognize them and aborts early, rather than trying to go through the > >>> remainder of the code, irrespective of how small the chances are of it > >>> succeeding. Or ignoring that /even if/ the remainder didn't fail, the > >>> one operation that fail might have been essential to the operation of > >>> the device. > >> I have an impression that you do not understand the idiom. It does not > >> allow to ignore error - as soon as the error is detected, guard is set > >> and no further harm can be done. > >> Going back to V4L2, look at the usage of the idiom [2]: > >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_gen, NULL); > >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_vid, NULL); > >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_aud, NULL); > >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_streaming, NULL); > >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_sdtv_cap, NULL); > >> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_loop_cap, NULL); > >> if (hdl_vid_cap->error) > >> return hdl_vid_cap->error; > >> > >> Again, the point is you do not need to use old construct, which enlarges > >> the code about three times: > >> err = func(obj,...); > >> if (err < 0) > >> return err; > >> > >> Instead you just call func(obj,...), and the burden of error checking is > >> put into the function, but for this err must be stored in object. > >> > >> [2]: > >> http://lxr.free-electrons.com/source/drivers/media/platform/vivid/vivid-ctrls.c#L1630 > >> > >>>> 5. http://lxr.free-electrons.com/source/drivers/media/i2c/s5k5baf.c#L451 > >>> That's a particularly good example of why you shouldn't be doing this > >>> kind of thing. Consider what would happen in these cases if for example > >>> there was a problem with the I2C interface. There's a bunch of read and > >>> write sequences in that driver that go completely without checking for > >>> errors. > >> Not true, no further transfer will be performed. > >> > >>> Imagine how that will look to a user when the communication to a > >>> chip doesn't work. They'll get a load of error messages all saying that > >>> communication timed out, or that the slave isn't responding or what not. > >>> And worse still, for timeouts you're also going to introduce a bunch of > >>> error messages interleaved with potentially other useful messages from > >>> other drivers or the core. Depending on the number of access you have it > >>> might take seconds for all of the error messages to drain before you > >>> notice somewhere at the end of the code that something went wrong and > >>> decide to abort whatever you were trying to do. > >> Again, not true at all. > >> > >>>> This is my driver, I mention it here just to show it was not a > >>>> problem to merge it to media subsystem. > >>> That just shows what everybody knows: that maintainers care about > >>> different things at different levels. > >>> > >>>> Similar patterns: > >>>> > >>>> 6. http://lxr.free-electrons.com/source/fs/seq_file.c#L398 > >>>> Do not process object if buffer is full, it allows to do not check > >>>> buffer size after every write, for example: > >>>>> seq_printf(m, " hardirq-safe locks: %11lu\n", > >>>>> nr_hardirq_safe); > >>>>> seq_printf(m, " hardirq-unsafe locks: %11lu\n", > >>>>> nr_hardirq_unsafe); > >>>>> seq_printf(m, " softirq-safe locks: %11lu\n", > >>>>> nr_softirq_safe); > >>>>> seq_printf(m, " softirq-unsafe locks: %11lu\n", > >>>>> nr_softirq_unsafe); > >>>>> seq_printf(m, " irq-safe locks: %11lu\n", > >>>>> nr_irq_safe); > >>>>> seq_printf(m, " irq-unsafe locks: %11lu\n", > >>>>> nr_irq_unsafe); > >>>>> > >>>>> seq_printf(m, " hardirq-read-safe locks: %11lu\n", > >>>>> nr_hardirq_read_safe); > >>>>> seq_printf(m, " hardirq-read-unsafe locks: %11lu\n", > >>>>> nr_hardirq_read_unsafe); > >>>>> seq_printf(m, " softirq-read-safe locks: %11lu\n", > >>>>> nr_softirq_read_safe); > >>>>> seq_printf(m, " softirq-read-unsafe locks: %11lu\n", > >>>>> nr_softirq_read_unsafe); > >>>>> seq_printf(m, " irq-read-safe locks: %11lu\n", > >>>>> nr_irq_read_safe); > >>>>> seq_printf(m, " irq-read-unsafe locks: %11lu\n", > >>>>> nr_irq_read_unsafe); > >>>>> > >>>>> seq_printf(m, " uncategorized locks: %11lu\n", > >>>>> nr_uncategorized); > >>>>> seq_printf(m, " unused locks: %11lu\n", > >>>>> nr_unused); > >>>>> seq_printf(m, " max locking depth: %11u\n", > >>>>> max_lockdep_depth); > >>>> Now try to imagine how it would look like if you add error checking > >>>> after each call. > >>> I think that's a fairly sane use-case for this kind of pattern. The big > >>> difference is that this condition is checked in subsequent accesses to > >>> shortcut failure paths. It's also very different in that it performs > >>> writes to memory and those aren't going to fail. The root cause of this > >>> overflow would be static in nature and likely found doing basic testing > >>> and fixed by making the buffer larger. > >>> > >>> That's contrary to a driver doing I/O (I2C, SPI, DSI, ...) that can fail > >>> unexpectedly for any number of reasons. > >> The idiom is still the same - storing error state in the object allows > >> to move error checking inside called functions, removing much of > >> redundant code from caller. > >> > >>>> 7. http://lxr.free-electrons.com/source/lib/devres.c#L129 > >>>> Postponed error check: > >>>>> */res = platform_get_resource(pdev, IORESOURCE_MEM, 0);/* > >>>>> /*b*/*/ase = devm_ioremap_resource(&pdev->dev, res);/* > >>>>> */if (IS_ERR(base))/* > >>>>> /**/*/return PTR_ERR(base);/* > >>> Heh, I wrote that =) > >>> > >>> This is also quite different from your usage in the panel driver. We do > >>> not simply ignore failure from platform_get_resource(), instead we leave > >>> it up to devm_ioremap_resource() to turn it into a meaningful error code > >>> and message. The function does this very early on, so the error > >>> condition is not ignored, as it is in the panel driver. > >> Claims about the panel again not true, reasons described above. > >> > >> The similarity here is that you do not perform error checking in the > >> caller, you just blindly pass the 'object' to the next function, and > >> still everything is handled correctly. > >> > >>> Also doing this helps with providing unified error codes and messages > >>> across all callers, and removing a lot of boiler plate from drivers that > >>> previously used to come up with all sorts of meaningless error codes and > >>> completely inconsistent messages. > >> I like this pattern and I agree with this reasoning I just want to allow > >> usage of it more widely, or at least not to block patches using it :) > >> > >> > >> Regards > >> Andrzej > >> > >> > >> _______________________________________________ > >> dri-devel mailing list > >> dri-devel@lists.freedesktop.org > >> https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
[toc] | [prev] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2017-02-06 11:40 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t7OSd-3KY-9@gated-at.bofh.it> |
| In reply to | #1572953 |
[Multipart message — attachments visible in raw view] — view raw
On Fri, Feb 03, 2017 at 09:54:42AM +0100, Andrzej Hajda wrote: > Hi Thierry, > > Finally something technical :) > > On 02.02.2017 18:58, Thierry Reding wrote: > > On Tue, Jan 31, 2017 at 01:05:20PM +0100, Andrzej Hajda wrote: > >> On 31.01.2017 09:54, Thierry Reding wrote: > >>> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > >>>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > >>>>> Dear Thierry, > >>>>> > >>>>> Could you please review this patch? > >>>> Thierry, I think this patch has been reviewed enough but no comment > >>>> from you. Seems you are busy. I will pick up this. > >>> Sorry, but that's not how it works. This patch has gone through 8 > >>> revisions within 4 weeks, and I tend to ignore patches like that until > >>> the dust settles. > >>> > >>> Other than that, this continues the same madness that I've repeatedly > >>> complained about in the past. The whole mechanism of running through a > >>> series of writes and not caring about errors until the very end is > >>> something we've discussed at length in the past. > >> Yes, we have discussed the pattern, but without any conclusion. The > >> pattern is correct, used in different places in kernel (see below for > >> examples) and significantly decreases source code size. Disallowing it > >> in panels subsystem just because of personal preferences of the > >> maintainer does not seem to be proper. > >> > >>> It also in large parts > >>> duplicates a bunch of functions from other Samsung panel drivers that I > >>> already said should eventually be moved to something saner. > >> Currently there are two Samsung panel drivers, one is on SPI bus, > >> another one is on DSI. > >> I am (co-)author of both drivers, they have some similarities but I did > >> not see any gain in making additional abstractions over transport layer > >> just to make one or two small functions common. > >> Could you be more precise what are you talking about, or could you give > >> a link to the mail where you said it. Anything I remember was a > >> discussion about ugly magic initialization sequences due to poor > >> documentation. > >> > >> And below promised examples of the error pattern, it was time consuming > >> to find them, so please at least read them :) > > I've done better, below is what I hope a list of good arguments why the > > pattern is a bad idea, and why in some cases it can be justified. > > > >> Almost exactly the same patterns for the same purpose: > >> > >> 1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63 > >> Citation from the code: > >> To reduce the number of error checks in the code, we record the > >> first error > >> in atusb->err and reject all subsequent requests until the error is > >> cleared. > > That's about the worst example you could've used. Have you even looked > > at the code that uses this? It's completely crazy. So here we have the > > atusb_control_msg() function that stores this error, but then also > > propagates it to its caller. One of these callers is atusb_read_reg(), > > which also propagates the error or returns the register value if the > > read was successful. > > > > Now the really insane part is how this is then used in something like > > atusb_write_subreg(): > > > > orig = atusb_read_reg(atusb, reg); > > tmp = orig & ~mask; > > tmp |= (value << shift) & mask; > > > > if (tmp != orig) > > ret = atusb_write_reg(atusb, reg, tmp); > > > > So let's assume that atusb_control_msg() fails in the call to > > atusb_read_reg(). You'll be returning an error code, mask out some bits, > > OR in new ones and write the result to the register. So not only does > > the code not bother to check for errors, but it will also happily go and > > corrupt registers when an error has occurred while reading. > > Not true, in case of error in atusb_read_reg atusb_write_reg will do > nothing because atusb->err is set ! > And this is strong point of the idiom - you will not be able to perform > transfer until the error is explicitly cleared. Yes, I see now that there's an additional check before further accesses can be made. So I have to apologize to the author and it turns out that the code isn't crazy. I suppose it's me that's too stupid to understand how this works. I wouldn't have been confused if this was using a more idiomatic way of doing things. The mere fact that code will read/modify/write registers unconditionally suggests that there's no error checking going on. Even if the code doesn't actually corrupt registers, it does have the effect of executing a bunch of instructions completely unnecessarily. To add to the confusion there are other parts in the driver that don't seem comfortable using the idiom and you'll actually see things like: ret = atusb_write_subreg(...); if (ret) return ret; If you ask me, that's bound to lead to mistakes at some point. > With this idiom it is enough to put guards only in one/two/few places, > in traditional error handling you just need to put checks after every > function call and it is quite common situation that developers forgot to > do that, for example look at mipi calls here [1] :) > [1]: > http://lxr.free-electrons.com/source/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c#L160 > > So the function is correct, but to avoid fooling unaware readers I would > add error checking after read: > > orig = atusb_read_reg(atusb, reg); > if (atusb->err) > return err; But then what's the point of storing the error somewhere in the first place? > >> 2. http://lxr.free-electrons.com/source/drivers/md/dm-thin.c?v=4.4#L917 > > This is completely different from the panel driver because it's used to > > store a value from within callbacks that can't return one. > > This is internal framework of the driver, so nothing prevents developer > from implementing callbacks that return value. > Apparently storing error in the object(struct dm_thin_new_mapping) is > good and convenient :) No, I think this comes from the fact that the device mapper and block I/O frameworks have infrastructure that doesn't allow the error code to be directly propagated (see the copy_complete() and overwrite_endio() callbacks). > >> 3. http://lxr.free-electrons.com/source/net/9p/trans_fd.c?v=3.18#L297 > > Essentially the same thing. > > The same here. Yes, this seems like it could easily be done using propagated error codes. > >> 4. > >> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-ctrls.c#L2234 > > Looks like this could be replaced by the more idiomatic use of ERR_PTR() > > encoding error codes. But the most significant difference here is that > > each use of the handler_set_err() function is followed by a return. So > > instead of ignoring errors like you do in the panel drivers, this does > > recognize them and aborts early, rather than trying to go through the > > remainder of the code, irrespective of how small the chances are of it > > succeeding. Or ignoring that /even if/ the remainder didn't fail, the > > one operation that fail might have been essential to the operation of > > the device. > > I have an impression that you do not understand the idiom. It does not > allow to ignore error - as soon as the error is detected, guard is set > and no further harm can be done. > Going back to V4L2, look at the usage of the idiom [2]: > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_gen, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_vid, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_aud, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_streaming, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_sdtv_cap, NULL); > v4l2_ctrl_add_handler(hdl_vid_cap, hdl_loop_cap, NULL); > if (hdl_vid_cap->error) > return hdl_vid_cap->error; > > Again, the point is you do not need to use old construct, which enlarges > the code about three times: > err = func(obj,...); > if (err < 0) > return err; > > Instead you just call func(obj,...), and the burden of error checking is > put into the function, but for this err must be stored in object. > > [2]: > http://lxr.free-electrons.com/source/drivers/media/platform/vivid/vivid-ctrls.c#L1630 There are a couple of pitfalls here: for example what do you do if the first two calls fail, but the third succeeds. The end result will be that the whole operation fails. What do you do if one of the operations has side-effects that you need to undo? If you don't know which one it was, how will you know? And yes, this does allow you to ignore errors. The function calls before the actual error handling will be executed regardless of errors that are stored. While in many cases the code seems to correctly shortcut if the guard is set, it also encodes many assumptions, not all of which may be understood by morons like me. The end result is that the code becomes more vulnerable to accidental mistakes. These will be hard to spot during review. Keeping code linear and simple makes it much more difficult to introduce bugs. > >> 5. http://lxr.free-electrons.com/source/drivers/media/i2c/s5k5baf.c#L451 > > That's a particularly good example of why you shouldn't be doing this > > kind of thing. Consider what would happen in these cases if for example > > there was a problem with the I2C interface. There's a bunch of read and > > write sequences in that driver that go completely without checking for > > errors. > > Not true, no further transfer will be performed. Indeed. Clearly I wasn't looking closely enough. How about knowing whether or not reads or writes succeed? To do so you would have to explicitly check the error code again. > > Imagine how that will look to a user when the communication to a > > chip doesn't work. They'll get a load of error messages all saying that > > communication timed out, or that the slave isn't responding or what not. > > And worse still, for timeouts you're also going to introduce a bunch of > > error messages interleaved with potentially other useful messages from > > other drivers or the core. Depending on the number of access you have it > > might take seconds for all of the error messages to drain before you > > notice somewhere at the end of the code that something went wrong and > > decide to abort whatever you were trying to do. > > Again, not true at all. So after looking at this is more detail, I'll grant you that it gives you a way to avoid checking for errors at every step of the way. There is a disadvantage because you keep executing a lot of code unnecessarily, and you make the code susceptible to mistakes because it contains a non-obvious assumption that contributors to your code may not be aware of. > >> This is my driver, I mention it here just to show it was not a > >> problem to merge it to media subsystem. > > That just shows what everybody knows: that maintainers care about > > different things at different levels. > > > >> Similar patterns: > >> > >> 6. http://lxr.free-electrons.com/source/fs/seq_file.c#L398 > >> Do not process object if buffer is full, it allows to do not check > >> buffer size after every write, for example: > >>> seq_printf(m, " hardirq-safe locks: %11lu\n", > >>> nr_hardirq_safe); > >>> seq_printf(m, " hardirq-unsafe locks: %11lu\n", > >>> nr_hardirq_unsafe); > >>> seq_printf(m, " softirq-safe locks: %11lu\n", > >>> nr_softirq_safe); > >>> seq_printf(m, " softirq-unsafe locks: %11lu\n", > >>> nr_softirq_unsafe); > >>> seq_printf(m, " irq-safe locks: %11lu\n", > >>> nr_irq_safe); > >>> seq_printf(m, " irq-unsafe locks: %11lu\n", > >>> nr_irq_unsafe); > >>> > >>> seq_printf(m, " hardirq-read-safe locks: %11lu\n", > >>> nr_hardirq_read_safe); > >>> seq_printf(m, " hardirq-read-unsafe locks: %11lu\n", > >>> nr_hardirq_read_unsafe); > >>> seq_printf(m, " softirq-read-safe locks: %11lu\n", > >>> nr_softirq_read_safe); > >>> seq_printf(m, " softirq-read-unsafe locks: %11lu\n", > >>> nr_softirq_read_unsafe); > >>> seq_printf(m, " irq-read-safe locks: %11lu\n", > >>> nr_irq_read_safe); > >>> seq_printf(m, " irq-read-unsafe locks: %11lu\n", > >>> nr_irq_read_unsafe); > >>> > >>> seq_printf(m, " uncategorized locks: %11lu\n", > >>> nr_uncategorized); > >>> seq_printf(m, " unused locks: %11lu\n", > >>> nr_unused); > >>> seq_printf(m, " max locking depth: %11u\n", > >>> max_lockdep_depth); > >> Now try to imagine how it would look like if you add error checking > >> after each call. > > I think that's a fairly sane use-case for this kind of pattern. The big > > difference is that this condition is checked in subsequent accesses to > > shortcut failure paths. It's also very different in that it performs > > writes to memory and those aren't going to fail. The root cause of this > > overflow would be static in nature and likely found doing basic testing > > and fixed by making the buffer larger. > > > > That's contrary to a driver doing I/O (I2C, SPI, DSI, ...) that can fail > > unexpectedly for any number of reasons. > > The idiom is still the same - storing error state in the object allows > to move error checking inside called functions, removing much of > redundant code from caller. Yes, the idiom is the same, but the use-case is also completely different, so I don't think you can apply the same rules. If you've got communication with an external peripheral, like in the case of SPI, I2C or DSI, I think the best thing to do is abort as early as possible on failure. The most likely reason for failure would be a persistent cause on the bus, in which case none of your accesses will succeed. If so I think it makes sense to let the user know what exactly went wrong and leave it at that. Continuing to execute code, even if no physical access to the hardware happens anymore, is a waste of time. Failures on such busses can happen for any number of reasons, and they can happen sporadically, so it's important to catch errors. For seq_buf in particular you have a static failure case, which is if somebody were trying to add more characters to the buffer than would fit. But callers will, most of the time, put exactly the same number of characters into that buffer. So if there was a failure once they'd notice quickly and the issue would get fixed, at which point it becomes very unlikely to ever happen again. So seq_buf is not expected to fail, whereas with peripheral busses you can't make that assumption. > >> 7. http://lxr.free-electrons.com/source/lib/devres.c#L129 > >> Postponed error check: > >>> */res = platform_get_resource(pdev, IORESOURCE_MEM, 0);/* > >>> /*b*/*/ase = devm_ioremap_resource(&pdev->dev, res);/* > >>> */if (IS_ERR(base))/* > >>> /**/*/return PTR_ERR(base);/* > > Heh, I wrote that =) > > > > This is also quite different from your usage in the panel driver. We do > > not simply ignore failure from platform_get_resource(), instead we leave > > it up to devm_ioremap_resource() to turn it into a meaningful error code > > and message. The function does this very early on, so the error > > condition is not ignored, as it is in the panel driver. > > Claims about the panel again not true, reasons described above. > > The similarity here is that you do not perform error checking in the > caller, you just blindly pass the 'object' to the next function, and > still everything is handled correctly. But we're not passing any object to the next function. We're passing the return value from an earlier call, one line above. We're not hiding an error code in some driver-specific structure. So the code is completely explicit. Maybe I should say a few words about why this is important to me because you may think this to be somewhat pedantic. This is fundamentally caused by the fact that once I merge code into a tree that I maintain, then the responsibility for that code becomes mine. That means I will not only be held accountable if it doesn't work, breaks or upsets build farms all over the world. It also means that I am the one that will need to make changes to it along the way. If the code is difficult for me to understand because it doesn't behave the way I'm used to, then that makes my life harder. Sometimes authors do stick around and care about their drivers, but often they'll just disappear, or ignore patches and bug reports about their drivers. So if worst comes to worst people will look to me to fix their problems. That's why I want it to be easy to read and modify the code that I maintain, because that way when users show up and complain about drivers I don't have to spend hours trying to understand what the original author was trying to achieve. The above is a variant of what others have termed "obviously correct". One good way to make code obviously correct is to make it simple. Thierry
[toc] | [prev] | [next] | [standalone]
| From | Andrzej Hajda <a.hajda@samsung.com> |
|---|---|
| Date | 2017-02-07 11:00 +0100 |
| Message-ID | <t8aJ4-1am-13@gated-at.bofh.it> |
| In reply to | #1574544 |
On 06.02.2017 11:39, Thierry Reding wrote:
> On Fri, Feb 03, 2017 at 09:54:42AM +0100, Andrzej Hajda wrote:
>> Hi Thierry,
>>
>> Finally something technical :)
>>
>> On 02.02.2017 18:58, Thierry Reding wrote:
>>> On Tue, Jan 31, 2017 at 01:05:20PM +0100, Andrzej Hajda wrote:
>>>> On 31.01.2017 09:54, Thierry Reding wrote:
>>>>> On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote:
>>>>>> 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글:
>>>>>>> Dear Thierry,
>>>>>>>
>>>>>>> Could you please review this patch?
>>>>>> Thierry, I think this patch has been reviewed enough but no comment
>>>>>> from you. Seems you are busy. I will pick up this.
>>>>> Sorry, but that's not how it works. This patch has gone through 8
>>>>> revisions within 4 weeks, and I tend to ignore patches like that until
>>>>> the dust settles.
>>>>>
>>>>> Other than that, this continues the same madness that I've repeatedly
>>>>> complained about in the past. The whole mechanism of running through a
>>>>> series of writes and not caring about errors until the very end is
>>>>> something we've discussed at length in the past.
>>>> Yes, we have discussed the pattern, but without any conclusion. The
>>>> pattern is correct, used in different places in kernel (see below for
>>>> examples) and significantly decreases source code size. Disallowing it
>>>> in panels subsystem just because of personal preferences of the
>>>> maintainer does not seem to be proper.
>>>>
>>>>> It also in large parts
>>>>> duplicates a bunch of functions from other Samsung panel drivers that I
>>>>> already said should eventually be moved to something saner.
>>>> Currently there are two Samsung panel drivers, one is on SPI bus,
>>>> another one is on DSI.
>>>> I am (co-)author of both drivers, they have some similarities but I did
>>>> not see any gain in making additional abstractions over transport layer
>>>> just to make one or two small functions common.
>>>> Could you be more precise what are you talking about, or could you give
>>>> a link to the mail where you said it. Anything I remember was a
>>>> discussion about ugly magic initialization sequences due to poor
>>>> documentation.
>>>>
>>>> And below promised examples of the error pattern, it was time consuming
>>>> to find them, so please at least read them :)
>>> I've done better, below is what I hope a list of good arguments why the
>>> pattern is a bad idea, and why in some cases it can be justified.
>>>
>>>> Almost exactly the same patterns for the same purpose:
>>>>
>>>> 1. http://lxr.free-electrons.com/source/drivers/net/ieee802154/atusb.c#L63
>>>> Citation from the code:
>>>> To reduce the number of error checks in the code, we record the
>>>> first error
>>>> in atusb->err and reject all subsequent requests until the error is
>>>> cleared.
>>> That's about the worst example you could've used. Have you even looked
>>> at the code that uses this? It's completely crazy. So here we have the
>>> atusb_control_msg() function that stores this error, but then also
>>> propagates it to its caller. One of these callers is atusb_read_reg(),
>>> which also propagates the error or returns the register value if the
>>> read was successful.
>>>
>>> Now the really insane part is how this is then used in something like
>>> atusb_write_subreg():
>>>
>>> orig = atusb_read_reg(atusb, reg);
>>> tmp = orig & ~mask;
>>> tmp |= (value << shift) & mask;
>>>
>>> if (tmp != orig)
>>> ret = atusb_write_reg(atusb, reg, tmp);
>>>
>>> So let's assume that atusb_control_msg() fails in the call to
>>> atusb_read_reg(). You'll be returning an error code, mask out some bits,
>>> OR in new ones and write the result to the register. So not only does
>>> the code not bother to check for errors, but it will also happily go and
>>> corrupt registers when an error has occurred while reading.
>> Not true, in case of error in atusb_read_reg atusb_write_reg will do
>> nothing because atusb->err is set !
>> And this is strong point of the idiom - you will not be able to perform
>> transfer until the error is explicitly cleared.
> Yes, I see now that there's an additional check before further accesses
> can be made. So I have to apologize to the author and it turns out that
> the code isn't crazy. I suppose it's me that's too stupid to understand
> how this works.
>
> I wouldn't have been confused if this was using a more idiomatic way of
> doing things. The mere fact that code will read/modify/write registers
> unconditionally suggests that there's no error checking going on. Even
> if the code doesn't actually corrupt registers, it does have the effect
> of executing a bunch of instructions completely unnecessarily.
If there are really time consuming tasks you can add always error check
before, as I showed below. Anyway this is error path so the delay
because of the idiom will be usually insignificant comparing to time of
hw error handling/recovery/timeouts etc.
>
> To add to the confusion there are other parts in the driver that don't
> seem comfortable using the idiom and you'll actually see things like:
>
> ret = atusb_write_subreg(...);
> if (ret)
> return ret;
>
> If you ask me, that's bound to lead to mistakes at some point.
I agree propagating error in two ways can be misleading, however I guess
in some cases it can be convenient, anyway this is small detail.
I guess it is still easier to forgot about error handling with classical
approach, here you add checks only before actions with side effects, in
classical approach you are obliged to put checks everywhere, to achieve
the same goal.
>
>> With this idiom it is enough to put guards only in one/two/few places,
>> in traditional error handling you just need to put checks after every
>> function call and it is quite common situation that developers forgot to
>> do that, for example look at mipi calls here [1] :)
>> [1]:
>> http://lxr.free-electrons.com/source/drivers/gpu/drm/i915/intel_dsi_panel_vbt.c#L160
>>
>> So the function is correct, but to avoid fooling unaware readers I would
>> add error checking after read:
>>
>> orig = atusb_read_reg(atusb, reg);
>> if (atusb->err)
>> return err;
> But then what's the point of storing the error somewhere in the first
> place?
Because you have still multiple places where you do not need to add checks.
And placing check here will save few cpu clocks, but of course without
it the code is still correct, it is just matter of taste and balance
between short code vs quick error paths.
>
>>>> 2. http://lxr.free-electrons.com/source/drivers/md/dm-thin.c?v=4.4#L917
>>> This is completely different from the panel driver because it's used to
>>> store a value from within callbacks that can't return one.
>> This is internal framework of the driver, so nothing prevents developer
>> from implementing callbacks that return value.
>> Apparently storing error in the object(struct dm_thin_new_mapping) is
>> good and convenient :)
> No, I think this comes from the fact that the device mapper and block
> I/O frameworks have infrastructure that doesn't allow the error code to
> be directly propagated (see the copy_complete() and overwrite_endio()
> callbacks).
>
>>>> 3. http://lxr.free-electrons.com/source/net/9p/trans_fd.c?v=3.18#L297
>>> Essentially the same thing.
>> The same here.
> Yes, this seems like it could easily be done using propagated error
> codes.
>
>>>> 4.
>>>> http://lxr.free-electrons.com/source/drivers/media/v4l2-core/v4l2-ctrls.c#L2234
>>> Looks like this could be replaced by the more idiomatic use of ERR_PTR()
>>> encoding error codes. But the most significant difference here is that
>>> each use of the handler_set_err() function is followed by a return. So
>>> instead of ignoring errors like you do in the panel drivers, this does
>>> recognize them and aborts early, rather than trying to go through the
>>> remainder of the code, irrespective of how small the chances are of it
>>> succeeding. Or ignoring that /even if/ the remainder didn't fail, the
>>> one operation that fail might have been essential to the operation of
>>> the device.
>> I have an impression that you do not understand the idiom. It does not
>> allow to ignore error - as soon as the error is detected, guard is set
>> and no further harm can be done.
>> Going back to V4L2, look at the usage of the idiom [2]:
>> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_gen, NULL);
>> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_vid, NULL);
>> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_aud, NULL);
>> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_streaming, NULL);
>> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_sdtv_cap, NULL);
>> v4l2_ctrl_add_handler(hdl_vid_cap, hdl_loop_cap, NULL);
>> if (hdl_vid_cap->error)
>> return hdl_vid_cap->error;
>>
>> Again, the point is you do not need to use old construct, which enlarges
>> the code about three times:
>> err = func(obj,...);
>> if (err < 0)
>> return err;
>>
>> Instead you just call func(obj,...), and the burden of error checking is
>> put into the function, but for this err must be stored in object.
>>
>> [2]:
>> http://lxr.free-electrons.com/source/drivers/media/platform/vivid/vivid-ctrls.c#L1630
> There are a couple of pitfalls here: for example what do you do if the
> first two calls fail, but the third succeeds.
No way, at the beginning of v4l2_ctrl_add_handler there is check:
if (hdl->error <http://lxr.free-electrons.com/ident?i=error>)
return hdl->error <http://lxr.free-electrons.com/ident?i=error>;
In fact this check is also in other functions: handler_new_ref,
v4l2_ctrl_new, handler_new_ref.
With this check after first error no further code is executed.
> The end result will be
> that the whole operation fails. What do you do if one of the operations
> has side-effects that you need to undo? If you don't know which one it
> was, how will you know?
You can always add explicit check after the operation which requires
special handling, like in traditional approach. The point is you do not
need to add checks which just propagate the error: "if (err < 0) return
err;".
The last sentence clearly suggests where the idiom is most suitable -
the object on which you should perform bunch of operations and you are
mainly interested if all operations succeeded. This is for example
creation of V4L2 control handler - we are not interested in handler with
some controls broken, we want fully working handler with all controls or
nothing. Another example are devices attached to some bus which can
fail, if we initialize it we want to perform bunch of writes, if any of
write fails whole initialization fails also.
>
> And yes, this does allow you to ignore errors. The function calls before
> the actual error handling will be executed regardless of errors that are
> stored. While in many cases the code seems to correctly shortcut if the
> guard is set, it also encodes many assumptions, not all of which may be
> understood by morons like me.
>
> The end result is that the code becomes more vulnerable to accidental
> mistakes. These will be hard to spot during review. Keeping code linear
> and simple makes it much more difficult to introduce bugs.
This is very disputable, error paths are the most error prone pieces of
code :) There are many places where these errors are not propagated, or
are propagated incorrectly, I suppose it is mainly due to fact it should
be put everywhere.
>
>>>> 5. http://lxr.free-electrons.com/source/drivers/media/i2c/s5k5baf.c#L451
>>> That's a particularly good example of why you shouldn't be doing this
>>> kind of thing. Consider what would happen in these cases if for example
>>> there was a problem with the I2C interface. There's a bunch of read and
>>> write sequences in that driver that go completely without checking for
>>> errors.
>> Not true, no further transfer will be performed.
> Indeed. Clearly I wasn't looking closely enough. How about knowing
> whether or not reads or writes succeed? To do so you would have to
> explicitly check the error code again.
If you need this information you can check, if don't you don't :)
>
>>> Imagine how that will look to a user when the communication to a
>>> chip doesn't work. They'll get a load of error messages all saying that
>>> communication timed out, or that the slave isn't responding or what not.
>>> And worse still, for timeouts you're also going to introduce a bunch of
>>> error messages interleaved with potentially other useful messages from
>>> other drivers or the core. Depending on the number of access you have it
>>> might take seconds for all of the error messages to drain before you
>>> notice somewhere at the end of the code that something went wrong and
>>> decide to abort whatever you were trying to do.
>> Again, not true at all.
> So after looking at this is more detail, I'll grant you that it gives
> you a way to avoid checking for errors at every step of the way. There
> is a disadvantage because you keep executing a lot of code
> unnecessarily, and you make the code susceptible to mistakes because
> it contains a non-obvious assumption that contributors to your code may
> not be aware of.
>
>>>> This is my driver, I mention it here just to show it was not a
>>>> problem to merge it to media subsystem.
>>> That just shows what everybody knows: that maintainers care about
>>> different things at different levels.
>>>
>>>> Similar patterns:
>>>>
>>>> 6. http://lxr.free-electrons.com/source/fs/seq_file.c#L398
>>>> Do not process object if buffer is full, it allows to do not check
>>>> buffer size after every write, for example:
>>>>> seq_printf(m, " hardirq-safe locks: %11lu\n",
>>>>> nr_hardirq_safe);
>>>>> seq_printf(m, " hardirq-unsafe locks: %11lu\n",
>>>>> nr_hardirq_unsafe);
>>>>> seq_printf(m, " softirq-safe locks: %11lu\n",
>>>>> nr_softirq_safe);
>>>>> seq_printf(m, " softirq-unsafe locks: %11lu\n",
>>>>> nr_softirq_unsafe);
>>>>> seq_printf(m, " irq-safe locks: %11lu\n",
>>>>> nr_irq_safe);
>>>>> seq_printf(m, " irq-unsafe locks: %11lu\n",
>>>>> nr_irq_unsafe);
>>>>>
>>>>> seq_printf(m, " hardirq-read-safe locks: %11lu\n",
>>>>> nr_hardirq_read_safe);
>>>>> seq_printf(m, " hardirq-read-unsafe locks: %11lu\n",
>>>>> nr_hardirq_read_unsafe);
>>>>> seq_printf(m, " softirq-read-safe locks: %11lu\n",
>>>>> nr_softirq_read_safe);
>>>>> seq_printf(m, " softirq-read-unsafe locks: %11lu\n",
>>>>> nr_softirq_read_unsafe);
>>>>> seq_printf(m, " irq-read-safe locks: %11lu\n",
>>>>> nr_irq_read_safe);
>>>>> seq_printf(m, " irq-read-unsafe locks: %11lu\n",
>>>>> nr_irq_read_unsafe);
>>>>>
>>>>> seq_printf(m, " uncategorized locks: %11lu\n",
>>>>> nr_uncategorized);
>>>>> seq_printf(m, " unused locks: %11lu\n",
>>>>> nr_unused);
>>>>> seq_printf(m, " max locking depth: %11u\n",
>>>>> max_lockdep_depth);
>>>> Now try to imagine how it would look like if you add error checking
>>>> after each call.
>>> I think that's a fairly sane use-case for this kind of pattern. The big
>>> difference is that this condition is checked in subsequent accesses to
>>> shortcut failure paths. It's also very different in that it performs
>>> writes to memory and those aren't going to fail. The root cause of this
>>> overflow would be static in nature and likely found doing basic testing
>>> and fixed by making the buffer larger.
>>>
>>> That's contrary to a driver doing I/O (I2C, SPI, DSI, ...) that can fail
>>> unexpectedly for any number of reasons.
>> The idiom is still the same - storing error state in the object allows
>> to move error checking inside called functions, removing much of
>> redundant code from caller.
> Yes, the idiom is the same, but the use-case is also completely
> different, so I don't think you can apply the same rules. If you've got
> communication with an external peripheral, like in the case of SPI, I2C
> or DSI, I think the best thing to do is abort as early as possible on
> failure. The most likely reason for failure would be a persistent cause
> on the bus, in which case none of your accesses will succeed. If so I
> think it makes sense to let the user know what exactly went wrong and
> leave it at that. Continuing to execute code, even if no physical access
> to the hardware happens anymore, is a waste of time.
>
> Failures on such busses can happen for any number of reasons, and they
> can happen sporadically, so it's important to catch errors. For seq_buf
> in particular you have a static failure case, which is if somebody were
> trying to add more characters to the buffer than would fit. But callers
> will, most of the time, put exactly the same number of characters into
> that buffer. So if there was a failure once they'd notice quickly and
> the issue would get fixed, at which point it becomes very unlikely to
> ever happen again.
>
> So seq_buf is not expected to fail, whereas with peripheral busses you
> can't make that assumption.
The error is logged as soon as it happens, you can easily check that
every time error is set, it is also logged.
This is another advantage of the idiom - you do not need to analyze, if
the error some function has returned was logged already, or you should
do it in the caller.
With the idiom you can log error in every place the error is set, to be
sure that it will not be silently omitted, of course sometimes you can
want to log in wider context, the idiom of course allows it.
>
>>>> 7. http://lxr.free-electrons.com/source/lib/devres.c#L129
>>>> Postponed error check:
>>>>> */res = platform_get_resource(pdev, IORESOURCE_MEM, 0);/*
>>>>> /*b*/*/ase = devm_ioremap_resource(&pdev->dev, res);/*
>>>>> */if (IS_ERR(base))/*
>>>>> /**/*/return PTR_ERR(base);/*
>>> Heh, I wrote that =)
>>>
>>> This is also quite different from your usage in the panel driver. We do
>>> not simply ignore failure from platform_get_resource(), instead we leave
>>> it up to devm_ioremap_resource() to turn it into a meaningful error code
>>> and message. The function does this very early on, so the error
>>> condition is not ignored, as it is in the panel driver.
>> Claims about the panel again not true, reasons described above.
>>
>> The similarity here is that you do not perform error checking in the
>> caller, you just blindly pass the 'object' to the next function, and
>> still everything is handled correctly.
> But we're not passing any object to the next function. We're passing the
> return value from an earlier call, one line above. We're not hiding an
> error code in some driver-specific structure. So the code is completely
> explicit.
>
> Maybe I should say a few words about why this is important to me because
> you may think this to be somewhat pedantic. This is fundamentally caused
> by the fact that once I merge code into a tree that I maintain, then the
> responsibility for that code becomes mine. That means I will not only be
> held accountable if it doesn't work, breaks or upsets build farms all
> over the world. It also means that I am the one that will need to make
> changes to it along the way. If the code is difficult for me to
> understand because it doesn't behave the way I'm used to, then that
> makes my life harder.
>
> Sometimes authors do stick around and care about their drivers, but
> often they'll just disappear, or ignore patches and bug reports about
> their drivers. So if worst comes to worst people will look to me to fix
> their problems. That's why I want it to be easy to read and modify the
> code that I maintain, because that way when users show up and complain
> about drivers I don't have to spend hours trying to understand what the
> original author was trying to achieve.
But this is common problem of all subsystems, there is nothing special
about panels.
>
> The above is a variant of what others have termed "obviously correct".
> One good way to make code obviously correct is to make it simple.
>
I understand what you want to say, but I cannot fully agree with it.
With such conservative approach Linux would not evolve at all :)
We need some balance between "code exactly as maintainer says, otherwise
you will be nacked" and "do whatever you want",
but I think in case of panel subsystem requirements are unnecessarily
very strict.
Ok, this part of the discussion is less technical, I guess it would be
good to have opinions of other maintainers about the subject.
Regards
Andrzej
[toc] | [prev] | [next] | [standalone]
| From | Sean Paul <seanpaul@chromium.org> |
|---|---|
| Date | 2017-01-31 15:50 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5HUS-1S1-15@gated-at.bofh.it> |
| In reply to | #1570495 |
On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > > > > > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > > > Dear Thierry, > > > > > > Could you please review this patch? > > > > Thierry, I think this patch has been reviewed enough but no comment > > from you. Seems you are busy. I will pick up this. > > Sorry, but that's not how it works. This patch has gone through 8 > revisions within 4 weeks, and I tend to ignore patches like that until > the dust settles. > Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, and picked up on 1/31. I don't think it's unreasonable to take it through another tree after that. I wonder if drm_panel would benefit from the -misc group maintainership model as drm_bridge does. By spreading out the workload, the high-maintenance patches would hopefully find someone to shepherd them through. > Other than that, this continues the same madness that I've repeatedly > complained about in the past. The whole mechanism of running through a > series of writes and not caring about errors until the very end is > something we've discussed at length in the past. It also in large parts > duplicates a bunch of functions from other Samsung panel drivers that I > already said should eventually be moved to something saner. > FWIW, this type of error handling isn't my preference either. If we must defer, I'd rather not keep it in ctx, but rather pass around an argument so it's more obvious we need to deal with it in the return. That said, this seems like a case of letting the perfect be the enemy of the good, surely something is better than nothing? Sean > This is now the third driver and nobody's giving a damn about improving > things. > > Until somebody does, I'm going to have to NAK this. > > Thierry > <snip> -- Sean Paul, Software Engineer, Google / Chromium OS
[toc] | [prev] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2017-01-31 16:10 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5Ied-2dH-7@gated-at.bofh.it> |
| In reply to | #1570802 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jan 31, 2017 at 09:38:53AM -0500, Sean Paul wrote: > On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: > > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > > > > > > > > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > > > > Dear Thierry, > > > > > > > > Could you please review this patch? > > > > > > Thierry, I think this patch has been reviewed enough but no comment > > > from you. Seems you are busy. I will pick up this. > > > > Sorry, but that's not how it works. This patch has gone through 8 > > revisions within 4 weeks, and I tend to ignore patches like that until > > the dust settles. > > > > Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, > and picked up on 1/31. I don't think it's unreasonable to take it through > another tree after that. > > I wonder if drm_panel would benefit from the -misc group maintainership model > as drm_bridge does. By spreading out the workload, the high-maintenance > patches would hopefully find someone to shepherd them through. Except that nobody except me really cares. If we let people take patches through separate trees or group-maintained trees they'll likely go in without too much thought. DRM panel is somewhat different from core DRM in this regard because its infrastructure is minimal and there's little outside the panel-simple driver. So we're still at a stage where we need to fine-tune what drivers should look like and how we can improve. > > Other than that, this continues the same madness that I've repeatedly > > complained about in the past. The whole mechanism of running through a > > series of writes and not caring about errors until the very end is > > something we've discussed at length in the past. It also in large parts > > duplicates a bunch of functions from other Samsung panel drivers that I > > already said should eventually be moved to something saner. > > > > FWIW, this type of error handling isn't my preference either. If we must defer, > I'd rather not keep it in ctx, but rather pass around an argument so it's more > obvious we need to deal with it in the return. That said, this seems like > a case of letting the perfect be the enemy of the good, surely something is > better than nothing? That's what I ended up saying the last two times. But this has got to stop at some point. If you look at most of the panel drivers, they look more like material for the staging tree rather than DRM proper. Yes, something is better than nothing, but we can't have this multiply further. Last time we discussed this there was some rough concensus that the initialization sequence would be split into separate functions, which is already mostly true for these drivers, and then settle on a common signature for these functions, which is also mostly the case already, and then have a table of functions that can be called one after another with error handling on each call. That way at least you can provide diagnostics about what function failed, and you can abort early because we have to assume that failures are fatal. Thierry
[toc] | [prev] | [next] | [standalone]
| From | Sean Paul <seanpaul@chromium.org> |
|---|---|
| Date | 2017-01-31 17:00 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5J0C-2tO-25@gated-at.bofh.it> |
| In reply to | #1570812 |
On Tue, Jan 31, 2017 at 04:02:26PM +0100, Thierry Reding wrote: > On Tue, Jan 31, 2017 at 09:38:53AM -0500, Sean Paul wrote: > > On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: > > > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > > > > > > > > > > > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > > > > > Dear Thierry, > > > > > > > > > > Could you please review this patch? > > > > > > > > Thierry, I think this patch has been reviewed enough but no comment > > > > from you. Seems you are busy. I will pick up this. > > > > > > Sorry, but that's not how it works. This patch has gone through 8 > > > revisions within 4 weeks, and I tend to ignore patches like that until > > > the dust settles. > > > > > > > Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, > > and picked up on 1/31. I don't think it's unreasonable to take it through > > another tree after that. > > > > I wonder if drm_panel would benefit from the -misc group maintainership model > > as drm_bridge does. By spreading out the workload, the high-maintenance > > patches would hopefully find someone to shepherd them through. > > Except that nobody except me really cares. I certainly haven't been paying attention. My excuse, at least, is that you're a great maintainer and I haven't thought the patches need a second look. Perhaps if we moved towards a group, more people would be vested/care? > If we let people take patches > through separate trees or group-maintained trees they'll likely go in > without too much thought. DRM panel is somewhat different from core DRM > in this regard because its infrastructure is minimal and there's little > outside the panel-simple driver. So we're still at a stage where we need > to fine-tune what drivers should look like and how we can improve. > Fair point. With drm_bridge, I've been lending review help, but deferring to Archit for merge on patches which I think he should look at. Gustavo is in a similar place with fences. drm_panel seems like something that should follow the same model. Maybe once more people (or one person) get up to speed on things, we could share the load. > > > Other than that, this continues the same madness that I've repeatedly > > > complained about in the past. The whole mechanism of running through a > > > series of writes and not caring about errors until the very end is > > > something we've discussed at length in the past. It also in large parts > > > duplicates a bunch of functions from other Samsung panel drivers that I > > > already said should eventually be moved to something saner. > > > > > > > FWIW, this type of error handling isn't my preference either. If we must defer, > > I'd rather not keep it in ctx, but rather pass around an argument so it's more > > obvious we need to deal with it in the return. That said, this seems like > > a case of letting the perfect be the enemy of the good, surely something is > > better than nothing? > > That's what I ended up saying the last two times. But this has got to > stop at some point. If you look at most of the panel drivers, they look > more like material for the staging tree rather than DRM proper. > > Yes, something is better than nothing, but we can't have this multiply > further. > So perhaps if we had more reviewers, we could tighten up the review feedback loop and avoid this while still getting things merged? I'm mostly thinking out load here, so take it for what it's worth. Sean > Last time we discussed this there was some rough concensus that the > initialization sequence would be split into separate functions, which is > already mostly true for these drivers, and then settle on a common > signature for these functions, which is also mostly the case already, > and then have a table of functions that can be called one after another > with error handling on each call. That way at least you can provide > diagnostics about what function failed, and you can abort early because > we have to assume that failures are fatal. > > Thierry > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Sean Paul, Software Engineer, Google / Chromium OS
[toc] | [prev] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2017-01-31 22:30 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5O9Z-5HH-41@gated-at.bofh.it> |
| In reply to | #1570847 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jan 31, 2017 at 10:49:51AM -0500, Sean Paul wrote: > On Tue, Jan 31, 2017 at 04:02:26PM +0100, Thierry Reding wrote: > > On Tue, Jan 31, 2017 at 09:38:53AM -0500, Sean Paul wrote: > > > On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: > > > > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > > > > > > > > > > > > > > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > > > > > > Dear Thierry, > > > > > > > > > > > > Could you please review this patch? > > > > > > > > > > Thierry, I think this patch has been reviewed enough but no comment > > > > > from you. Seems you are busy. I will pick up this. > > > > > > > > Sorry, but that's not how it works. This patch has gone through 8 > > > > revisions within 4 weeks, and I tend to ignore patches like that until > > > > the dust settles. > > > > > > > > > > Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, > > > and picked up on 1/31. I don't think it's unreasonable to take it through > > > another tree after that. > > > > > > I wonder if drm_panel would benefit from the -misc group maintainership model > > > as drm_bridge does. By spreading out the workload, the high-maintenance > > > patches would hopefully find someone to shepherd them through. > > > > Except that nobody except me really cares. > > I certainly haven't been paying attention. My excuse, at least, is that you're a > great maintainer and I haven't thought the patches need a second look. Perhaps > if we moved towards a group, more people would be vested/care? I doubt that group maintainership would change much about the lack of peer review. Peer review makes maintenance a lot easier. Usually when I see that a patch has been reviewed by someone that I think I can trust, I only give it a very brief look before applying. However, if there's been no other review I need to take a lot more time to review. > > If we let people take patches > > through separate trees or group-maintained trees they'll likely go in > > without too much thought. DRM panel is somewhat different from core DRM > > in this regard because its infrastructure is minimal and there's little > > outside the panel-simple driver. So we're still at a stage where we need > > to fine-tune what drivers should look like and how we can improve. > > > > Fair point. With drm_bridge, I've been lending review help, but deferring to > Archit for merge on patches which I think he should look at. Gustavo is in a > similar place with fences. drm_panel seems like something that should follow > the same model. Maybe once more people (or one person) get up to speed on > things, we could share the load. I certainly wouldn't mind more people reviewing panel patches. Applying them is the easy part. > > > > Other than that, this continues the same madness that I've repeatedly > > > > complained about in the past. The whole mechanism of running through a > > > > series of writes and not caring about errors until the very end is > > > > something we've discussed at length in the past. It also in large parts > > > > duplicates a bunch of functions from other Samsung panel drivers that I > > > > already said should eventually be moved to something saner. > > > > > > > > > > FWIW, this type of error handling isn't my preference either. If we must defer, > > > I'd rather not keep it in ctx, but rather pass around an argument so it's more > > > obvious we need to deal with it in the return. That said, this seems like > > > a case of letting the perfect be the enemy of the good, surely something is > > > better than nothing? > > > > That's what I ended up saying the last two times. But this has got to > > stop at some point. If you look at most of the panel drivers, they look > > more like material for the staging tree rather than DRM proper. > > > > Yes, something is better than nothing, but we can't have this multiply > > further. > > > > So perhaps if we had more reviewers, we could tighten up the review feedback > loop and avoid this while still getting things merged? Maybe. Like I said, I would very much welcome more review on panel patches. Thierry
[toc] | [prev] | [next] | [standalone]
| From | Emil Velikov <emil.l.velikov@gmail.com> |
|---|---|
| Date | 2017-01-31 22:50 +0100 |
| Message-ID | <t5Otk-5NY-19@gated-at.bofh.it> |
| In reply to | #1571130 |
On 31 January 2017 at 21:17, Thierry Reding <thierry.reding@gmail.com> wrote: > On Tue, Jan 31, 2017 at 10:49:51AM -0500, Sean Paul wrote: >> On Tue, Jan 31, 2017 at 04:02:26PM +0100, Thierry Reding wrote: >> > On Tue, Jan 31, 2017 at 09:38:53AM -0500, Sean Paul wrote: >> > > On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: >> > > > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: >> > > > > >> > > > > >> > > > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: >> > > > > > Dear Thierry, >> > > > > > >> > > > > > Could you please review this patch? >> > > > > >> > > > > Thierry, I think this patch has been reviewed enough but no comment >> > > > > from you. Seems you are busy. I will pick up this. >> > > > >> > > > Sorry, but that's not how it works. This patch has gone through 8 >> > > > revisions within 4 weeks, and I tend to ignore patches like that until >> > > > the dust settles. >> > > > >> > > >> > > Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, >> > > and picked up on 1/31. I don't think it's unreasonable to take it through >> > > another tree after that. >> > > >> > > I wonder if drm_panel would benefit from the -misc group maintainership model >> > > as drm_bridge does. By spreading out the workload, the high-maintenance >> > > patches would hopefully find someone to shepherd them through. >> > >> > Except that nobody except me really cares. >> >> I certainly haven't been paying attention. My excuse, at least, is that you're a >> great maintainer and I haven't thought the patches need a second look. Perhaps >> if we moved towards a group, more people would be vested/care? > > I doubt that group maintainership would change much about the lack of > peer review. Peer review makes maintenance a lot easier. Usually when I > see that a patch has been reviewed by someone that I think I can trust, > I only give it a very brief look before applying. However, if there's > been no other review I need to take a lot more time to review. > >> > If we let people take patches >> > through separate trees or group-maintained trees they'll likely go in >> > without too much thought. DRM panel is somewhat different from core DRM >> > in this regard because its infrastructure is minimal and there's little >> > outside the panel-simple driver. So we're still at a stage where we need >> > to fine-tune what drivers should look like and how we can improve. >> > >> >> Fair point. With drm_bridge, I've been lending review help, but deferring to >> Archit for merge on patches which I think he should look at. Gustavo is in a >> similar place with fences. drm_panel seems like something that should follow >> the same model. Maybe once more people (or one person) get up to speed on >> things, we could share the load. > > I certainly wouldn't mind more people reviewing panel patches. Applying > them is the easy part. > >> > > > Other than that, this continues the same madness that I've repeatedly >> > > > complained about in the past. The whole mechanism of running through a >> > > > series of writes and not caring about errors until the very end is >> > > > something we've discussed at length in the past. It also in large parts >> > > > duplicates a bunch of functions from other Samsung panel drivers that I >> > > > already said should eventually be moved to something saner. >> > > > >> > > >> > > FWIW, this type of error handling isn't my preference either. If we must defer, >> > > I'd rather not keep it in ctx, but rather pass around an argument so it's more >> > > obvious we need to deal with it in the return. That said, this seems like >> > > a case of letting the perfect be the enemy of the good, surely something is >> > > better than nothing? >> > >> > That's what I ended up saying the last two times. But this has got to >> > stop at some point. If you look at most of the panel drivers, they look >> > more like material for the staging tree rather than DRM proper. >> > >> > Yes, something is better than nothing, but we can't have this multiply >> > further. >> > >> >> So perhaps if we had more reviewers, we could tighten up the review feedback >> loop and avoid this while still getting things merged? > > Maybe. Like I said, I would very much welcome more review on panel > patches. > I think that there's a part that Inki and/or others might have forgotten. Being the sole/core person reviewing this leads to a bit too often repeat of the same principles ... which after a while gets a bit [pick your favourite non-cool word]. In one of my experiences [whist attempting to help out], one had to repeat/reword the exact same thing three times in order to be addressed :-\ -Emil
[toc] | [prev] | [next] | [standalone]
| From | Eric Anholt <eric@anholt.net> |
|---|---|
| Date | 2017-01-31 19:30 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5LlM-41b-19@gated-at.bofh.it> |
| In reply to | #1570812 |
[Multipart message — attachments visible in raw view] — view raw
Thierry Reding <thierry.reding@gmail.com> writes: > [ Unknown signature status ] > On Tue, Jan 31, 2017 at 09:38:53AM -0500, Sean Paul wrote: >> On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: >> > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: >> > > >> > > >> > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: >> > > > Dear Thierry, >> > > > >> > > > Could you please review this patch? >> > > >> > > Thierry, I think this patch has been reviewed enough but no comment >> > > from you. Seems you are busy. I will pick up this. >> > >> > Sorry, but that's not how it works. This patch has gone through 8 >> > revisions within 4 weeks, and I tend to ignore patches like that until >> > the dust settles. >> > >> >> Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, >> and picked up on 1/31. I don't think it's unreasonable to take it through >> another tree after that. >> >> I wonder if drm_panel would benefit from the -misc group maintainership model >> as drm_bridge does. By spreading out the workload, the high-maintenance >> patches would hopefully find someone to shepherd them through. > > Except that nobody except me really cares. If we let people take patches > through separate trees or group-maintained trees they'll likely go in > without too much thought. DRM panel is somewhat different from core DRM > in this regard because its infrastructure is minimal and there's little > outside the panel-simple driver. So we're still at a stage where we need > to fine-tune what drivers should look like and how we can improve. I would love to care and participate in review, but with the structure of your tree you're the only one whose review counts, so I don't participate. As is, I'm stuck out here with my panel driver I submitted on December 14th completely ignored, and no other developer will look at it because their review doesn't count and only yours does. I would love for drm-panel to be moved under -misc.
[toc] | [prev] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2017-01-31 22:40 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5OjE-5KQ-27@gated-at.bofh.it> |
| In reply to | #1570980 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jan 31, 2017 at 10:15:10AM -0800, Eric Anholt wrote: > Thierry Reding <thierry.reding@gmail.com> writes: > > > [ Unknown signature status ] > > On Tue, Jan 31, 2017 at 09:38:53AM -0500, Sean Paul wrote: > >> On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: > >> > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > >> > > > >> > > > >> > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > >> > > > Dear Thierry, > >> > > > > >> > > > Could you please review this patch? > >> > > > >> > > Thierry, I think this patch has been reviewed enough but no comment > >> > > from you. Seems you are busy. I will pick up this. > >> > > >> > Sorry, but that's not how it works. This patch has gone through 8 > >> > revisions within 4 weeks, and I tend to ignore patches like that until > >> > the dust settles. > >> > > >> > >> Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, > >> and picked up on 1/31. I don't think it's unreasonable to take it through > >> another tree after that. > >> > >> I wonder if drm_panel would benefit from the -misc group maintainership model > >> as drm_bridge does. By spreading out the workload, the high-maintenance > >> patches would hopefully find someone to shepherd them through. > > > > Except that nobody except me really cares. If we let people take patches > > through separate trees or group-maintained trees they'll likely go in > > without too much thought. DRM panel is somewhat different from core DRM > > in this regard because its infrastructure is minimal and there's little > > outside the panel-simple driver. So we're still at a stage where we need > > to fine-tune what drivers should look like and how we can improve. > > I would love to care and participate in review, but with the structure > of your tree you're the only one whose review counts, so I don't > participate. Really? What exactly do you think is special about the structure of my tree? I require patches to be on dri-devel (I pick them up from the patchwork instance at freedesktop.org), the tree is publicly available and reviewed-by tags get picked up automatically by patchwork. The panel tree works exactly like any other maintainer tree. And my review is *not* the only one that counts. I appreciate every Reviewed-by tag I see on panel patches because it means that I don't have to look as closely as I have to otherwise. It is true that I am responsible for those patches, that's why I get to have the final word on whether or not a patch gets applied. And that's no different from any other maintainer tree either. > As is, I'm stuck out here with my panel driver I submitted on December > 14th completely ignored, and no other developer will look at it because > their review doesn't count and only yours does. That's the same lame excuse as above. Nobody's keeping you or anyone else from reviewing panel patches. The truth is that reviewing code is hard and time-consuming, and that's why nobody can be bothered to do it. That has nothing whatsoever to do with how any specific maintainer operates. > I would love for drm-panel to be moved under -misc. Like that's going to magically motivate people to spend their time reviewing other patches. The only thing that group maintainership adds is redundancy. Thierry
[toc] | [prev] | [next] | [standalone]
| From | Eric Anholt <eric@anholt.net> |
|---|---|
| Date | 2017-02-01 00:00 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t5Pz3-6pn-3@gated-at.bofh.it> |
| In reply to | #1571151 |
[Multipart message — attachments visible in raw view] — view raw
Thierry Reding <thierry.reding@gmail.com> writes: > [ Unknown signature status ] > On Tue, Jan 31, 2017 at 10:15:10AM -0800, Eric Anholt wrote: >> Thierry Reding <thierry.reding@gmail.com> writes: >> >> > [ Unknown signature status ] >> > On Tue, Jan 31, 2017 at 09:38:53AM -0500, Sean Paul wrote: >> >> On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: >> >> > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: >> >> > > >> >> > > >> >> > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: >> >> > > > Dear Thierry, >> >> > > > >> >> > > > Could you please review this patch? >> >> > > >> >> > > Thierry, I think this patch has been reviewed enough but no comment >> >> > > from you. Seems you are busy. I will pick up this. >> >> > >> >> > Sorry, but that's not how it works. This patch has gone through 8 >> >> > revisions within 4 weeks, and I tend to ignore patches like that until >> >> > the dust settles. >> >> > >> >> >> >> Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, >> >> and picked up on 1/31. I don't think it's unreasonable to take it through >> >> another tree after that. >> >> >> >> I wonder if drm_panel would benefit from the -misc group maintainership model >> >> as drm_bridge does. By spreading out the workload, the high-maintenance >> >> patches would hopefully find someone to shepherd them through. >> > >> > Except that nobody except me really cares. If we let people take patches >> > through separate trees or group-maintained trees they'll likely go in >> > without too much thought. DRM panel is somewhat different from core DRM >> > in this regard because its infrastructure is minimal and there's little >> > outside the panel-simple driver. So we're still at a stage where we need >> > to fine-tune what drivers should look like and how we can improve. >> >> I would love to care and participate in review, but with the structure >> of your tree you're the only one whose review counts, so I don't >> participate. > > Really? What exactly do you think is special about the structure of my > tree? I require patches to be on dri-devel (I pick them up from the > patchwork instance at freedesktop.org), the tree is publicly available > and reviewed-by tags get picked up automatically by patchwork. > > The panel tree works exactly like any other maintainer tree. And my > review is *not* the only one that counts. I appreciate every Reviewed-by > tag I see on panel patches because it means that I don't have to look as > closely as I have to otherwise. > > It is true that I am responsible for those patches, that's why I get to > have the final word on whether or not a patch gets applied. And that's > no different from any other maintainer tree either. If me reviewing a patch isn't part of unblocking that patch getting in, then I won't bother because all I could end up doing is punishing the developer of the patch. Contributors have a hard enough time already.
[toc] | [prev] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2017-02-01 16:00 +0100 |
| Subject | Re: [PATCH v8 2/3] drm/panel: Add support for S6E3HA2 panel driver on TM2 board |
| Message-ID | <t64y5-7eg-1@gated-at.bofh.it> |
| In reply to | #1571193 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jan 31, 2017 at 02:54:53PM -0800, Eric Anholt wrote: > Thierry Reding <thierry.reding@gmail.com> writes: > > > [ Unknown signature status ] > > On Tue, Jan 31, 2017 at 10:15:10AM -0800, Eric Anholt wrote: > >> Thierry Reding <thierry.reding@gmail.com> writes: > >> > >> > [ Unknown signature status ] > >> > On Tue, Jan 31, 2017 at 09:38:53AM -0500, Sean Paul wrote: > >> >> On Tue, Jan 31, 2017 at 09:54:49AM +0100, Thierry Reding wrote: > >> >> > On Tue, Jan 31, 2017 at 09:01:07AM +0900, Inki Dae wrote: > >> >> > > > >> >> > > > >> >> > > 2017년 01월 24일 10:50에 Hoegeun Kwon 이(가) 쓴 글: > >> >> > > > Dear Thierry, > >> >> > > > > >> >> > > > Could you please review this patch? > >> >> > > > >> >> > > Thierry, I think this patch has been reviewed enough but no comment > >> >> > > from you. Seems you are busy. I will pick up this. > >> >> > > >> >> > Sorry, but that's not how it works. This patch has gone through 8 > >> >> > revisions within 4 weeks, and I tend to ignore patches like that until > >> >> > the dust settles. > >> >> > > >> >> > >> >> Seems like the dust was pretty settled. It was posted on 1/11, pinged on 1/24, > >> >> and picked up on 1/31. I don't think it's unreasonable to take it through > >> >> another tree after that. > >> >> > >> >> I wonder if drm_panel would benefit from the -misc group maintainership model > >> >> as drm_bridge does. By spreading out the workload, the high-maintenance > >> >> patches would hopefully find someone to shepherd them through. > >> > > >> > Except that nobody except me really cares. If we let people take patches > >> > through separate trees or group-maintained trees they'll likely go in > >> > without too much thought. DRM panel is somewhat different from core DRM > >> > in this regard because its infrastructure is minimal and there's little > >> > outside the panel-simple driver. So we're still at a stage where we need > >> > to fine-tune what drivers should look like and how we can improve. > >> > >> I would love to care and participate in review, but with the structure > >> of your tree you're the only one whose review counts, so I don't > >> participate. > > > > Really? What exactly do you think is special about the structure of my > > tree? I require patches to be on dri-devel (I pick them up from the > > patchwork instance at freedesktop.org), the tree is publicly available > > and reviewed-by tags get picked up automatically by patchwork. > > > > The panel tree works exactly like any other maintainer tree. And my > > review is *not* the only one that counts. I appreciate every Reviewed-by > > tag I see on panel patches because it means that I don't have to look as > > closely as I have to otherwise. > > > > It is true that I am responsible for those patches, that's why I get to > > have the final word on whether or not a patch gets applied. And that's > > no different from any other maintainer tree either. > > If me reviewing a patch isn't part of unblocking that patch getting in, > then I won't bother because all I could end up doing is punishing the > developer of the patch. Contributors have a hard enough time already. Maybe you should go and read my previous reply again more carefully. Perhaps then you'll realize that reviews are in fact helping in getting patches merged. Interestingly my inbox doesn't show you ever bothering to review panel patches, so maybe you should be more careful about your assumptions. Thierry
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web