* [PATCH 0/4] staging: fbtft: cleanup ST7789V and C-Berry28 drivers
@ 2015-10-21 21:16 Dennis Menschel
2015-10-21 21:16 ` [PATCH 1/4] staging: fbtft: use MIPI DCS for ST7789V and C-Berry28 Dennis Menschel
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Dennis Menschel @ 2015-10-21 21:16 UTC (permalink / raw)
To: Thomas Petazzoni, Noralf Trønnes
Cc: Greg Kroah-Hartman, linux-kernel, devel, Dennis Menschel
This set of patches brings some improvements for the ST7789V display
controller driver based on suggestions by Noralf Trønnes.
In addition, the settings for the concrete C-Berry28 display have been
adjusted based on feedback by its vendor admatec.
Dennis Menschel (4):
staging: fbtft: use MIPI DCS for ST7789V and C-Berry28
staging: fbtft: remove redundant set_addr_win() function
staging: fbtft: use init function instead of init sequence
staging: fbtft: fix voltage settings for C-Berry28
drivers/staging/fbtft/fb_st7789v.c | 83 +++++++++++++-----------------------
drivers/staging/fbtft/fbtft_device.c | 15 ++++---
2 files changed, 37 insertions(+), 61 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] staging: fbtft: use MIPI DCS for ST7789V and C-Berry28
2015-10-21 21:16 [PATCH 0/4] staging: fbtft: cleanup ST7789V and C-Berry28 drivers Dennis Menschel
@ 2015-10-21 21:16 ` Dennis Menschel
2015-10-21 21:16 ` [PATCH 2/4] staging: fbtft: remove redundant set_addr_win() function Dennis Menschel
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Dennis Menschel @ 2015-10-21 21:16 UTC (permalink / raw)
To: Thomas Petazzoni, Noralf Trønnes
Cc: Greg Kroah-Hartman, linux-kernel, devel, Dennis Menschel
This patch makes use of the standard MIPI Display Command Set to remove
redundant entries from the command enum of the ST7789V display controller
and also some of the magic constants found in the init sequence of the
C-Berry28 display.
Signed-off-by: Dennis Menschel <menschel-d@posteo.de>
---
drivers/staging/fbtft/fb_st7789v.c | 39 +++++++++++++-----------------------
drivers/staging/fbtft/fbtft_device.c | 7 ++++---
2 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/drivers/staging/fbtft/fb_st7789v.c b/drivers/staging/fbtft/fb_st7789v.c
index dc7d304..22a7b5b 100644
--- a/drivers/staging/fbtft/fb_st7789v.c
+++ b/drivers/staging/fbtft/fb_st7789v.c
@@ -18,6 +18,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <video/mipi_display.h>
#include "fbtft.h"
@@ -30,14 +31,6 @@
/**
* enum st7789v_command - ST7789V display controller commands
*
- * @SLPOUT: sleep out
- * @DISPOFF: display off
- * @DISPON: display on
- * @CASET: column address set
- * @RASET: row address set
- * @RAMRW: memory write
- * @MADCTL: memory data access control
- * @COLMOD: interface pixel format
* @PORCTRL: porch setting
* @GCTRL: gate control
* @VCOMS: VCOM setting
@@ -54,16 +47,10 @@
*
* Note that the ST7789V display controller offers quite a few more commands
* which have been omitted from this list as they are not used at the moment.
+ * Furthermore, commands that are compliant with the MIPI DCS have been left
+ * out as well to avoid duplicate entries.
*/
enum st7789v_command {
- SLPOUT = 0x11,
- DISPOFF = 0x28,
- DISPON = 0x29,
- CASET = 0x2A,
- RASET = 0x2B,
- RAMRW = 0x2C,
- MADCTL = 0x36,
- COLMOD = 0x3A,
PORCTRL = 0xB2,
GCTRL = 0xB7,
VCOMS = 0xBB,
@@ -93,11 +80,11 @@ enum st7789v_command {
*/
static int default_init_sequence[] = {
/* turn off sleep mode */
- -1, SLPOUT,
+ -1, MIPI_DCS_EXIT_SLEEP_MODE,
-2, 120,
/* set pixel format to RGB-565 */
- -1, COLMOD, 0x05,
+ -1, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT,
-1, PORCTRL, 0x08, 0x08, 0x00, 0x22, 0x22,
@@ -135,7 +122,7 @@ static int default_init_sequence[] = {
*/
-1, PWCTRL1, 0xA4, 0xA1,
- -1, DISPON,
+ -1, MIPI_DCS_SET_DISPLAY_ON,
-3,
};
@@ -151,9 +138,11 @@ static int default_init_sequence[] = {
*/
static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
{
- write_reg(par, CASET, xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
- write_reg(par, RASET, ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
- write_reg(par, RAMRW);
+ write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,
+ xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
+ write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,
+ ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
+ write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
}
/**
@@ -184,7 +173,7 @@ static int set_var(struct fbtft_par *par)
default:
return -EINVAL;
}
- write_reg(par, MADCTL, madctl_par);
+ write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, madctl_par);
return 0;
}
@@ -256,9 +245,9 @@ static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int blank(struct fbtft_par *par, bool on)
{
if (on)
- write_reg(par, DISPOFF);
+ write_reg(par, MIPI_DCS_SET_DISPLAY_OFF);
else
- write_reg(par, DISPON);
+ write_reg(par, MIPI_DCS_SET_DISPLAY_ON);
return 0;
}
diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c
index 0e501d0..d7475d7 100644
--- a/drivers/staging/fbtft/fbtft_device.c
+++ b/drivers/staging/fbtft/fbtft_device.c
@@ -19,6 +19,7 @@
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/spi/spi.h>
+#include <video/mipi_display.h>
#include "fbtft.h"
@@ -132,11 +133,11 @@ static void adafruit18_green_tab_set_addr_win(struct fbtft_par *par,
static int cberry28_init_sequence[] = {
/* turn off sleep mode */
- -1, 0x11,
+ -1, MIPI_DCS_EXIT_SLEEP_MODE,
-2, 120,
/* set pixel format to RGB-565 */
- -1, 0x3A, 0x05,
+ -1, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT,
-1, 0xB2, 0x0C, 0x0C, 0x00, 0x33, 0x33,
@@ -174,7 +175,7 @@ static int cberry28_init_sequence[] = {
*/
-1, 0xD0, 0xA4, 0x61,
- -1, 0x29,
+ -1, MIPI_DCS_SET_DISPLAY_ON,
-3,
};
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/4] staging: fbtft: remove redundant set_addr_win() function
2015-10-21 21:16 [PATCH 0/4] staging: fbtft: cleanup ST7789V and C-Berry28 drivers Dennis Menschel
2015-10-21 21:16 ` [PATCH 1/4] staging: fbtft: use MIPI DCS for ST7789V and C-Berry28 Dennis Menschel
@ 2015-10-21 21:16 ` Dennis Menschel
2015-10-21 21:16 ` [PATCH 3/4] staging: fbtft: use init function instead of init sequence Dennis Menschel
2015-10-21 21:16 ` [PATCH 4/4] staging: fbtft: fix voltage settings for C-Berry28 Dennis Menschel
3 siblings, 0 replies; 5+ messages in thread
From: Dennis Menschel @ 2015-10-21 21:16 UTC (permalink / raw)
To: Thomas Petazzoni, Noralf Trønnes
Cc: Greg Kroah-Hartman, linux-kernel, devel, Dennis Menschel
This patch removes the function set_addr_win() from fb_st7789v.c, as its
definition is redundant to the default implementation fbtft_set_addr_win()
which can be found in fbtft-core.c.
Signed-off-by: Dennis Menschel <menschel-d@posteo.de>
---
drivers/staging/fbtft/fb_st7789v.c | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/drivers/staging/fbtft/fb_st7789v.c b/drivers/staging/fbtft/fb_st7789v.c
index 22a7b5b..c0ecf2b 100644
--- a/drivers/staging/fbtft/fb_st7789v.c
+++ b/drivers/staging/fbtft/fb_st7789v.c
@@ -128,24 +128,6 @@ static int default_init_sequence[] = {
};
/**
- * set_addr_win() - configure display area to use
- *
- * @par: FBTFT parameter object
- * @xs: first active pixel of x-axis
- * @ys: first active pixel of y-axis
- * @xe: last active pixel of x-axis
- * @ye: last active pixel of y-axis
- */
-static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
-{
- write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,
- xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
- write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,
- ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
- write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
-}
-
-/**
* set_var() - apply LCD properties like rotation and BGR mode
*
* @par: FBTFT parameter object
@@ -260,7 +242,6 @@ static struct fbtft_display display = {
.gamma_len = 14,
.gamma = DEFAULT_GAMMA,
.fbtftops = {
- .set_addr_win = set_addr_win,
.set_var = set_var,
.set_gamma = set_gamma,
.blank = blank,
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] staging: fbtft: use init function instead of init sequence
2015-10-21 21:16 [PATCH 0/4] staging: fbtft: cleanup ST7789V and C-Berry28 drivers Dennis Menschel
2015-10-21 21:16 ` [PATCH 1/4] staging: fbtft: use MIPI DCS for ST7789V and C-Berry28 Dennis Menschel
2015-10-21 21:16 ` [PATCH 2/4] staging: fbtft: remove redundant set_addr_win() function Dennis Menschel
@ 2015-10-21 21:16 ` Dennis Menschel
2015-10-21 21:16 ` [PATCH 4/4] staging: fbtft: fix voltage settings for C-Berry28 Dennis Menschel
3 siblings, 0 replies; 5+ messages in thread
From: Dennis Menschel @ 2015-10-21 21:16 UTC (permalink / raw)
To: Thomas Petazzoni, Noralf Trønnes
Cc: Greg Kroah-Hartman, linux-kernel, devel, Dennis Menschel
This patch converts the default init sequence of the ST7789V
display controller into an init function, as init sequences
are considered deprecated by the maintainers of fbtft.
Signed-off-by: Dennis Menschel <menschel-d@posteo.de>
---
drivers/staging/fbtft/fb_st7789v.c | 43 +++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/fbtft/fb_st7789v.c b/drivers/staging/fbtft/fb_st7789v.c
index c0ecf2b..085e987 100644
--- a/drivers/staging/fbtft/fb_st7789v.c
+++ b/drivers/staging/fbtft/fb_st7789v.c
@@ -15,6 +15,7 @@
*/
#include <linux/bitops.h>
+#include <linux/delay.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -69,63 +70,67 @@ enum st7789v_command {
#define MADCTL_MY BIT(7) /* bitmask for page address order */
/**
- * default_init_sequence - default initialization sequence for ST7789V
+ * init_display() - initialize the display controller
*
- * Most of the commands in this init sequence set their parameters to the
+ * @par: FBTFT parameter object
+ *
+ * Most of the commands in this init function set their parameters to the
* same default values which are already in place after the display has been
* powered up. (The main exception to this rule is the pixel format which
* would default to 18 instead of 16 bit per pixel.)
* Nonetheless, this sequence can be used as a template for concrete
* displays which usually need some adjustments.
+ *
+ * Return: 0 on success, < 0 if error occurred.
*/
-static int default_init_sequence[] = {
+static int init_display(struct fbtft_par *par)
+{
/* turn off sleep mode */
- -1, MIPI_DCS_EXIT_SLEEP_MODE,
- -2, 120,
+ write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE);
+ mdelay(120);
/* set pixel format to RGB-565 */
- -1, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT,
+ write_reg(par, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_16BIT);
- -1, PORCTRL, 0x08, 0x08, 0x00, 0x22, 0x22,
+ write_reg(par, PORCTRL, 0x08, 0x08, 0x00, 0x22, 0x22);
/*
* VGH = 13.26V
* VGL = -10.43V
*/
- -1, GCTRL, 0x35,
+ write_reg(par, GCTRL, 0x35);
/*
* VDV and VRH register values come from command write
* (instead of NVM)
*/
- -1, VDVVRHEN, 0x01, 0xFF,
+ write_reg(par, VDVVRHEN, 0x01, 0xFF);
/*
* VAP = 4.1V + (VCOM + VCOM offset + 0.5 * VDV)
* VAN = -4.1V + (VCOM + VCOM offset + 0.5 * VDV)
*/
- -1, VRHS, 0x0B,
+ write_reg(par, VRHS, 0x0B);
/* VDV = 0V */
- -1, VDVS, 0x20,
+ write_reg(par, VDVS, 0x20);
/* VCOM = 0.9V */
- -1, VCOMS, 0x20,
+ write_reg(par, VCOMS, 0x20);
/* VCOM offset = 0V */
- -1, VCMOFSET, 0x20,
+ write_reg(par, VCMOFSET, 0x20);
/*
* AVDD = 6.8V
* AVCL = -4.8V
* VDS = 2.3V
*/
- -1, PWCTRL1, 0xA4, 0xA1,
+ write_reg(par, PWCTRL1, 0xA4, 0xA1);
- -1, MIPI_DCS_SET_DISPLAY_ON,
-
- -3,
-};
+ write_reg(par, MIPI_DCS_SET_DISPLAY_ON);
+ return 0;
+}
/**
* set_var() - apply LCD properties like rotation and BGR mode
@@ -237,11 +242,11 @@ static struct fbtft_display display = {
.regwidth = 8,
.width = 240,
.height = 320,
- .init_sequence = default_init_sequence,
.gamma_num = 2,
.gamma_len = 14,
.gamma = DEFAULT_GAMMA,
.fbtftops = {
+ .init_display = init_display,
.set_var = set_var,
.set_gamma = set_gamma,
.blank = blank,
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] staging: fbtft: fix voltage settings for C-Berry28
2015-10-21 21:16 [PATCH 0/4] staging: fbtft: cleanup ST7789V and C-Berry28 drivers Dennis Menschel
` (2 preceding siblings ...)
2015-10-21 21:16 ` [PATCH 3/4] staging: fbtft: use init function instead of init sequence Dennis Menschel
@ 2015-10-21 21:16 ` Dennis Menschel
3 siblings, 0 replies; 5+ messages in thread
From: Dennis Menschel @ 2015-10-21 21:16 UTC (permalink / raw)
To: Thomas Petazzoni, Noralf Trønnes
Cc: Greg Kroah-Hartman, linux-kernel, devel, Dennis Menschel
This patch fixes some internal voltage settings for the C-Berry28 display.
The original example source files for the C-Berry28 as provided by
its vendor admatec contained six issues where a command parameter's value
didn't match its corresponding comment.
I've informed admatec about these discrepancies on 2015-08-25. In the
meantime, I've assumed the comments to be more reliable than the code,
and thus have used these values to write the initial C-Berry28 driver.
After having received a reply from admatec on 2015-10-16 that the issues
have been fixed in their example code, it has turned out that for the
voltages VCOM and AVDD, the code was indeed correct, but the comments
were wrong. This patch is meant to fix these two pending mistakes.
Signed-off-by: Dennis Menschel <menschel-d@posteo.de>
---
drivers/staging/fbtft/fbtft_device.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c
index d7475d7..071f79b 100644
--- a/drivers/staging/fbtft/fbtft_device.c
+++ b/drivers/staging/fbtft/fbtft_device.c
@@ -162,18 +162,18 @@ static int cberry28_init_sequence[] = {
/* VDV = 0V */
-1, 0xC4, 0x20,
- /* VCOM = 0.875V */
- -1, 0xBB, 0x1F,
+ /* VCOM = 0.675V */
+ -1, 0xBB, 0x17,
/* VCOM offset = 0V */
-1, 0xC5, 0x20,
/*
- * AVDD = 6.6V
+ * AVDD = 6.8V
* AVCL = -4.8V
* VDS = 2.3V
*/
- -1, 0xD0, 0xA4, 0x61,
+ -1, 0xD0, 0xA4, 0xA1,
-1, MIPI_DCS_SET_DISPLAY_ON,
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-21 21:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-21 21:16 [PATCH 0/4] staging: fbtft: cleanup ST7789V and C-Berry28 drivers Dennis Menschel
2015-10-21 21:16 ` [PATCH 1/4] staging: fbtft: use MIPI DCS for ST7789V and C-Berry28 Dennis Menschel
2015-10-21 21:16 ` [PATCH 2/4] staging: fbtft: remove redundant set_addr_win() function Dennis Menschel
2015-10-21 21:16 ` [PATCH 3/4] staging: fbtft: use init function instead of init sequence Dennis Menschel
2015-10-21 21:16 ` [PATCH 4/4] staging: fbtft: fix voltage settings for C-Berry28 Dennis Menschel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®