Re: [PATCH 3/5] drm: panel: add Xingbangda XBD599 panel

2020-03-15 Thread Icenowy Zheng


于 2020年3月14日 GMT+08:00 下午4:00:00, Sam Ravnborg  写到:
>Hi Icenowy
>
>A few details in the following.
>
>   Sam
>
>On Thu, Mar 12, 2020 at 12:33:27AM +0800, Icenowy Zheng wrote:
>> Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI IPS LCD panel made by
>> Xingbangda, which is used on PinePhone final assembled phones.
>> 
>> Add support for it.
>> 
>> Signed-off-by: Icenowy Zheng 
>> ---
>>  drivers/gpu/drm/panel/Kconfig |   9 +
>>  drivers/gpu/drm/panel/Makefile|   1 +
>>  .../gpu/drm/panel/panel-xingbangda-xbd599.c   | 367
>++
>>  3 files changed, 377 insertions(+)
>>  create mode 100644 drivers/gpu/drm/panel/panel-xingbangda-xbd599.c
>> 
>> +++ b/drivers/gpu/drm/panel/panel-xingbangda-xbd599.c
>> @@ -0,0 +1,367 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Xingbangda XBD599 MIPI-DSI panel driver
>> + *
>> + * Copyright (C) 2019 Icenowy Zheng 
>2020?

The work started at Mid 2019.

Is 2019-2020 okay?

>
>> + *
>> + * Based on panel-rocktech-jh057n00900.c, which is:
>> + *   Copyright (C) Purism SPC 2019
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>Sort alphabetically.
>
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define DRV_NAME "panel-xingbangda-xbd599"
>No reason for this indirection, it is only used once
>
>> +
>> +/* Manufacturer specific Commands send via DSI */
>> +#define ST7703_CMD_ALL_PIXEL_OFF 0x22
>> +#define ST7703_CMD_ALL_PIXEL_ON  0x23
>> +#define ST7703_CMD_SETDISP   0xB2
>> +#define ST7703_CMD_SETRGBIF  0xB3
>> +#define ST7703_CMD_SETCYC0xB4
>> +#define ST7703_CMD_SETBGP0xB5
>> +#define ST7703_CMD_SETVCOM   0xB6
>> +#define ST7703_CMD_SETOTP0xB7
>> +#define ST7703_CMD_SETPOWER_EXT  0xB8
>> +#define ST7703_CMD_SETEXTC   0xB9
>> +#define ST7703_CMD_SETMIPI   0xBA
>> +#define ST7703_CMD_SETVDC0xBC
>> +#define ST7703_CMD_SETSCR0xC0
>> +#define ST7703_CMD_SETPOWER  0xC1
>> +#define ST7703_CMD_UNK_C60xC6
>> +#define ST7703_CMD_SETPANEL  0xCC
>> +#define ST7703_CMD_SETGAMMA  0xE0
>> +#define ST7703_CMD_SETEQ 0xE3
>> +#define ST7703_CMD_SETGIP1   0xE9
>> +#define ST7703_CMD_SETGIP2   0xEA
>> +
>> +static const char * const regulator_names[] = {
>> +"iovcc",
>> +"vcc",
>> +};
>> +
>> +struct xbd599 {
>> +struct device *dev;
>> +struct drm_panel panel;
>> +struct gpio_desc *reset_gpio;
>> +struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];
>> +bool prepared;
>> +};
>> +
>> +static inline struct xbd599 *panel_to_xbd599(struct drm_panel
>*panel)
>> +{
>> +return container_of(panel, struct xbd599, panel);
>> +}
>> +
>> +#define dsi_dcs_write_seq(dsi, cmd, seq...) do {\
>> +static const u8 d[] = { seq };  \
>> +int ret;\
>> +ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
>> +if (ret < 0)\
>> +return ret; \
>> +} while (0)
>> +
>> +static int xbd599_init_sequence(struct xbd599 *ctx)
>> +{
>> +struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>> +struct device *dev = ctx->dev;
>> +int ret;
>> +
>> +/*
>> + * Init sequence was supplied by the panel vendor.
>> + */
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETEXTC,
>> +  0xF1, 0x12, 0x83);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETMIPI,
>> +  0x33, 0x81, 0x05, 0xF9, 0x0E, 0x0E, 0x20, 0x00,
>> +  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x25,
>> +  0x00, 0x91, 0x0a, 0x00, 0x00, 0x02, 0x4F, 0x11,
>> +  0x00, 0x00, 0x37);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER_EXT,
>> +  0x25, 0x22, 0x20, 0x03);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETRGBIF,
>> +  0x10, 0x10, 0x05, 0x05, 0x03, 0xFF, 0x00, 0x00,
>> +  0x00, 0x00);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETSCR,
>> +  0x73, 0x73, 0x50, 0x50, 0x00, 0xC0, 0x08, 0x70,
>> +  0x00);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETVDC, 0x4E);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETPANEL, 0x0B);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETCYC, 0x80);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETDISP, 0xF0, 0x12, 0xF0);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETEQ,
>> +  0x00, 0x00, 0x0B, 0x0B, 0x10, 0x10, 0x00, 0x00,
>> +  0x00, 0x00, 0xFF, 0x00, 0xC0, 0x10);
>> +dsi_dcs_write_seq(dsi, 0xC6, 0x01, 0x00, 0xFF, 0xFF, 0x00);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER,
>> +  0x74, 0x00, 0x32, 0x32, 0x77, 0xF1, 0xFF, 0xFF,
>> +  0xCC, 0xCC, 0x77, 0x77);
>> +dsi_dcs_write_seq(dsi, ST7703_CMD_SETBGP, 

Re: [PATCH 3/5] drm: panel: add Xingbangda XBD599 panel

2020-03-14 Thread Sam Ravnborg
Hi Icenowy

> >> +++ b/drivers/gpu/drm/panel/panel-xingbangda-xbd599.c
> >> @@ -0,0 +1,367 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/*
> >> + * Xingbangda XBD599 MIPI-DSI panel driver
> >> + *
> >> + * Copyright (C) 2019 Icenowy Zheng 
> >2020?
> 
> The work started at Mid 2019.
> 
> Is 2019-2020 okay?

We see this in other places so I guess it is. The point
here is that the driver contains work from 2020 so you should at least
specify 2020.

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/5] drm: panel: add Xingbangda XBD599 panel

2020-03-14 Thread Sam Ravnborg
Hi Icenowy

A few details in the following.

Sam

On Thu, Mar 12, 2020 at 12:33:27AM +0800, Icenowy Zheng wrote:
> Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI IPS LCD panel made by
> Xingbangda, which is used on PinePhone final assembled phones.
> 
> Add support for it.
> 
> Signed-off-by: Icenowy Zheng 
> ---
>  drivers/gpu/drm/panel/Kconfig |   9 +
>  drivers/gpu/drm/panel/Makefile|   1 +
>  .../gpu/drm/panel/panel-xingbangda-xbd599.c   | 367 ++
>  3 files changed, 377 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-xingbangda-xbd599.c
> 
> +++ b/drivers/gpu/drm/panel/panel-xingbangda-xbd599.c
> @@ -0,0 +1,367 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Xingbangda XBD599 MIPI-DSI panel driver
> + *
> + * Copyright (C) 2019 Icenowy Zheng 
2020?

> + *
> + * Based on panel-rocktech-jh057n00900.c, which is:
> + *   Copyright (C) Purism SPC 2019
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
Sort alphabetically.

> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRV_NAME "panel-xingbangda-xbd599"
No reason for this indirection, it is only used once

> +
> +/* Manufacturer specific Commands send via DSI */
> +#define ST7703_CMD_ALL_PIXEL_OFF 0x22
> +#define ST7703_CMD_ALL_PIXEL_ON   0x23
> +#define ST7703_CMD_SETDISP0xB2
> +#define ST7703_CMD_SETRGBIF   0xB3
> +#define ST7703_CMD_SETCYC 0xB4
> +#define ST7703_CMD_SETBGP 0xB5
> +#define ST7703_CMD_SETVCOM0xB6
> +#define ST7703_CMD_SETOTP 0xB7
> +#define ST7703_CMD_SETPOWER_EXT   0xB8
> +#define ST7703_CMD_SETEXTC0xB9
> +#define ST7703_CMD_SETMIPI0xBA
> +#define ST7703_CMD_SETVDC 0xBC
> +#define ST7703_CMD_SETSCR 0xC0
> +#define ST7703_CMD_SETPOWER   0xC1
> +#define ST7703_CMD_UNK_C6 0xC6
> +#define ST7703_CMD_SETPANEL   0xCC
> +#define ST7703_CMD_SETGAMMA   0xE0
> +#define ST7703_CMD_SETEQ  0xE3
> +#define ST7703_CMD_SETGIP10xE9
> +#define ST7703_CMD_SETGIP20xEA
> +
> +static const char * const regulator_names[] = {
> + "iovcc",
> + "vcc",
> +};
> +
> +struct xbd599 {
> + struct device *dev;
> + struct drm_panel panel;
> + struct gpio_desc *reset_gpio;
> + struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];
> + bool prepared;
> +};
> +
> +static inline struct xbd599 *panel_to_xbd599(struct drm_panel *panel)
> +{
> + return container_of(panel, struct xbd599, panel);
> +}
> +
> +#define dsi_dcs_write_seq(dsi, cmd, seq...) do { \
> + static const u8 d[] = { seq };  \
> + int ret;\
> + ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
> + if (ret < 0)\
> + return ret; \
> + } while (0)
> +
> +static int xbd599_init_sequence(struct xbd599 *ctx)
> +{
> + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
> + struct device *dev = ctx->dev;
> + int ret;
> +
> + /*
> +  * Init sequence was supplied by the panel vendor.
> +  */
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETEXTC,
> +   0xF1, 0x12, 0x83);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETMIPI,
> +   0x33, 0x81, 0x05, 0xF9, 0x0E, 0x0E, 0x20, 0x00,
> +   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x25,
> +   0x00, 0x91, 0x0a, 0x00, 0x00, 0x02, 0x4F, 0x11,
> +   0x00, 0x00, 0x37);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER_EXT,
> +   0x25, 0x22, 0x20, 0x03);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETRGBIF,
> +   0x10, 0x10, 0x05, 0x05, 0x03, 0xFF, 0x00, 0x00,
> +   0x00, 0x00);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETSCR,
> +   0x73, 0x73, 0x50, 0x50, 0x00, 0xC0, 0x08, 0x70,
> +   0x00);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETVDC, 0x4E);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETPANEL, 0x0B);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETCYC, 0x80);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETDISP, 0xF0, 0x12, 0xF0);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETEQ,
> +   0x00, 0x00, 0x0B, 0x0B, 0x10, 0x10, 0x00, 0x00,
> +   0x00, 0x00, 0xFF, 0x00, 0xC0, 0x10);
> + dsi_dcs_write_seq(dsi, 0xC6, 0x01, 0x00, 0xFF, 0xFF, 0x00);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER,
> +   0x74, 0x00, 0x32, 0x32, 0x77, 0xF1, 0xFF, 0xFF,
> +   0xCC, 0xCC, 0x77, 0x77);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETBGP, 0x07, 0x07);
> + dsi_dcs_write_seq(dsi, ST7703_CMD_SETVCOM, 0x2C, 0x2C);
> + dsi_dcs_write_seq(dsi, 0xBF, 0x02, 0x11, 0x00);
> +
> + dsi_dcs_write_seq(dsi, 

[PATCH 3/5] drm: panel: add Xingbangda XBD599 panel

2020-03-12 Thread Icenowy Zheng
Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI IPS LCD panel made by
Xingbangda, which is used on PinePhone final assembled phones.

Add support for it.

Signed-off-by: Icenowy Zheng 
---
 drivers/gpu/drm/panel/Kconfig |   9 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-xingbangda-xbd599.c   | 367 ++
 3 files changed, 377 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-xingbangda-xbd599.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index da3b84602cdd..d648f40469c7 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -413,6 +413,15 @@ config DRM_PANEL_TRULY_NT35597_WQXGA
  Say Y here if you want to enable support for Truly NT35597 WQXGA Dual 
DSI
  Video Mode panel
 
+config DRM_PANEL_XINGBANGDA_XBD599
+   tristate "Xingbangda XBD599 panel"
+   depends on OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ Say Y here if you want to enable support for the Xingbangda XBD599
+ MIPI DSI Video Mode panel.
+
 config DRM_PANEL_XINPENG_XPP055C272
tristate "Xinpeng XPP055C272 panel driver"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index af1e2a3cc5fc..d9645f079e59 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -44,4 +44,5 @@ obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += 
panel-tpo-td028ttec1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
 obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o
+obj-$(CONFIG_DRM_PANEL_XINGBANGDA_XBD599) += panel-xingbangda-xbd599.o
 obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o
diff --git a/drivers/gpu/drm/panel/panel-xingbangda-xbd599.c 
b/drivers/gpu/drm/panel/panel-xingbangda-xbd599.c
new file mode 100644
index ..68a5d8bb7f26
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-xingbangda-xbd599.c
@@ -0,0 +1,367 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Xingbangda XBD599 MIPI-DSI panel driver
+ *
+ * Copyright (C) 2019 Icenowy Zheng 
+ *
+ * Based on panel-rocktech-jh057n00900.c, which is:
+ *   Copyright (C) Purism SPC 2019
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define DRV_NAME "panel-xingbangda-xbd599"
+
+/* Manufacturer specific Commands send via DSI */
+#define ST7703_CMD_ALL_PIXEL_OFF 0x22
+#define ST7703_CMD_ALL_PIXEL_ON 0x23
+#define ST7703_CMD_SETDISP  0xB2
+#define ST7703_CMD_SETRGBIF 0xB3
+#define ST7703_CMD_SETCYC   0xB4
+#define ST7703_CMD_SETBGP   0xB5
+#define ST7703_CMD_SETVCOM  0xB6
+#define ST7703_CMD_SETOTP   0xB7
+#define ST7703_CMD_SETPOWER_EXT 0xB8
+#define ST7703_CMD_SETEXTC  0xB9
+#define ST7703_CMD_SETMIPI  0xBA
+#define ST7703_CMD_SETVDC   0xBC
+#define ST7703_CMD_SETSCR   0xC0
+#define ST7703_CMD_SETPOWER 0xC1
+#define ST7703_CMD_UNK_C6   0xC6
+#define ST7703_CMD_SETPANEL 0xCC
+#define ST7703_CMD_SETGAMMA 0xE0
+#define ST7703_CMD_SETEQ0xE3
+#define ST7703_CMD_SETGIP1  0xE9
+#define ST7703_CMD_SETGIP2  0xEA
+
+static const char * const regulator_names[] = {
+   "iovcc",
+   "vcc",
+};
+
+struct xbd599 {
+   struct device *dev;
+   struct drm_panel panel;
+   struct gpio_desc *reset_gpio;
+   struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];
+   bool prepared;
+};
+
+static inline struct xbd599 *panel_to_xbd599(struct drm_panel *panel)
+{
+   return container_of(panel, struct xbd599, panel);
+}
+
+#define dsi_dcs_write_seq(dsi, cmd, seq...) do {   \
+   static const u8 d[] = { seq };  \
+   int ret;\
+   ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
+   if (ret < 0)\
+   return ret; \
+   } while (0)
+
+static int xbd599_init_sequence(struct xbd599 *ctx)
+{
+   struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+   struct device *dev = ctx->dev;
+   int ret;
+
+   /*
+* Init sequence was supplied by the panel vendor.
+*/
+   dsi_dcs_write_seq(dsi, ST7703_CMD_SETEXTC,
+ 0xF1, 0x12, 0x83);
+   dsi_dcs_write_seq(dsi, ST7703_CMD_SETMIPI,
+ 0x33, 0x81, 0x05, 0xF9, 0x0E, 0x0E, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x25,
+ 0x00, 0x91, 0x0a, 0x00, 0x00, 0x02, 0x4F, 0x11,
+ 0x00, 0x00, 0x37);
+   dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER_EXT,
+