aboutsummaryrefslogtreecommitdiff
path: root/nuttx/drivers/lcd/ssd1289.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/drivers/lcd/ssd1289.c')
-rw-r--r--nuttx/drivers/lcd/ssd1289.c123
1 files changed, 111 insertions, 12 deletions
diff --git a/nuttx/drivers/lcd/ssd1289.c b/nuttx/drivers/lcd/ssd1289.c
index 3d5ba96d3..e42b5bded 100644
--- a/nuttx/drivers/lcd/ssd1289.c
+++ b/nuttx/drivers/lcd/ssd1289.c
@@ -229,8 +229,8 @@
/* Debug ******************************************************************************/
#ifdef CONFIG_DEBUG_LCD
-# define lcddbg dbg
-# define lcdvdbg vdbg
+# define lcddbg dbg
+# define lcdvdbg vdbg
#else
# define lcddbg(x...)
# define lcdvdbg(x...)
@@ -253,6 +253,16 @@ struct ssd1289_dev_s
FAR struct ssd1289_lcd_s *lcd; /* The contained platform-specific, LCD interface */
uint8_t power; /* Current power setting */
+ /* These fields simplify and reduce debug output */
+
+#ifdef CONFIG_DEBUG_LCD
+ bool put; /* Last raster operation was a putrun */
+ fb_coord_t firstrow; /* First row of the run */
+ fb_coord_t lastrow; /* Last row of the run */
+ fb_coord_t col; /* Column of the run */
+ size_t npixels; /* Length of the run */
+#endif
+
/* This is working memory allocated by the LCD driver for each LCD device
* and for each color plane. This memory will hold one raster line of data.
* The size of the allocated run buffer must therefore be at least
@@ -287,6 +297,19 @@ static void ssd1289_setcursor(FAR struct ssd1289_lcd_s *lcd, uint16_t column,
/* LCD Data Transfer Methods */
+#if 0 /* Sometimes useful */
+static void ssd1289_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels);
+#else
+# define ssd1289_dumprun(m,r,n)
+#endif
+
+#ifdef CONFIG_DEBUG_LCD
+static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row,
+ fb_coord_t col, size_t npixels, bool put);
+#else
+# define ssd1289_showrun(p,r,c,n,b)
+#endif
+
static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
size_t npixels);
static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
@@ -489,6 +512,64 @@ static void ssd1289_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixe
#endif
/**************************************************************************************
+ * Name: ssd1289_showrun
+ *
+ * Description:
+ * When LCD debug is enabled, try to reduce then amount of ouptut data generated by
+ * ssd1289_putrun and ssd1289_getrun
+ *
+ **************************************************************************************/
+
+#ifdef CONFIG_DEBUG_LCD
+static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row,
+ fb_coord_t col, size_t npixels, bool put)
+{
+ fb_coord_t nextrow = priv->lastrow + 1;
+
+ /* Has anything changed (other than the row is the next row in the sequence)? */
+
+ if (put == priv->put && row == nextrow && col == priv->col &&
+ npixels == priv->npixels)
+ {
+ /* No, just update the last row */
+
+ priv->lastrow = nextrow;
+ }
+ else
+ {
+ /* Yes... then this is the end of the preceding sequence. Output the last run
+ * (if there were more than one run in the sequence).
+ */
+
+ if (priv->firstrow != priv->lastrow)
+ {
+ lcddbg("...\n");
+ lcddbg("%s row: %d col: %d npixels: %d\n",
+ priv->put ? "PUT" : "GET",
+ priv->lastrow, priv->col, priv->npixels);
+ }
+
+ /* And we are starting a new sequence. Output the first run of the
+ * new sequence
+ */
+
+ lcddbg("%s row: %d col: %d npixels: %d\n",
+ put ? "PUT" : "GET", row, col, npixels);
+
+ /* And save information about the run so that we can detect continuations
+ * of the sequence.
+ */
+
+ priv->put = put;
+ priv->firstrow = row;
+ priv->lastrow = row;
+ priv->col = col;
+ priv->npixels = npixels;
+ }
+}
+#endif
+
+/**************************************************************************************
* Name: ssd1289_putrun
*
* Description:
@@ -512,7 +593,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
/* Buffer must be provided and aligned to a 16-bit address boundary */
- lcdvdbg("row: %d col: %d npixels: %d\n", row, col, npixels);
+ ssd1289_showrun(priv, row, col, npixels, true);
DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0);
/* Select the LCD */
@@ -536,7 +617,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
ssd1289_gramselect(lcd);
ssd1289_gramwrite(lcd, *src);
- /* Increment to next column */
+ /* Increment to the next column */
src++;
col++;
@@ -581,7 +662,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
ssd1289_gramselect(lcd);
ssd1289_gramwrite(lcd, *src);
- /* Increment to next column */
+ /* Increment to the next column */
src++;
col--;
@@ -604,7 +685,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
ssd1289_gramselect(lcd);
ssd1289_gramwrite(lcd, *src);
- /* Decrement to next column */
+ /* Decrement to the next column */
src++;
col++;
@@ -632,7 +713,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
**************************************************************************************/
static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
- size_t npixels)
+ size_t npixels)
{
#ifndef CONFIG_LCD_NOGETRUN
FAR struct ssd1289_dev_s *priv = &g_lcddev;
@@ -643,7 +724,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
/* Buffer must be provided and aligned to a 16-bit address boundary */
- lcdvdbg("row: %d col: %d npixels: %d\n", row, col, npixels);
+ ssd1289_showrun(priv, row, col, npixels, false);
DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0);
/* Select the LCD */
@@ -666,7 +747,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
ssd1289_readsetup(lcd, &accum);
*dest++ = ssd1289_gramread(lcd, &accum);
- /* Increment to next column */
+ /* Increment to the next column */
col++;
}
@@ -715,7 +796,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
ssd1289_readsetup(lcd, &accum);
*dest++ = ssd1289_gramread(lcd, &accum);
- /* Increment to next column */
+ /* Increment to the next column */
col--;
}
@@ -738,7 +819,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
ssd1289_readsetup(lcd, &accum);
*dest++ = ssd1289_gramread(lcd, &accum);
- /* Decrement to next column */
+ /* Decrement to the next column */
col++;
}
@@ -931,9 +1012,27 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv)
lcd->select(lcd);
+ /* Read the device ID. Skip verification of the device ID is the LCD is
+ * write-only. What choice do we have?
+ */
+
#ifndef CONFIG_LCD_NOGETRUN
id = ssd1289_readreg(lcd, SSD1289_DEVCODE);
- lcddbg("LCD ID: %04x\n", id);
+ if (id != 0)
+ {
+ lcddbg("LCD ID: %04x\n", id);
+ }
+
+ /* If we could not get the ID, then let's just assume that this is an SSD1289.
+ * Perhaps we have some early register access issues. This seems to happen.
+ * But then perhaps we should not even bother to read the device ID at all?
+ */
+
+ else
+ {
+ lcddbg("No LCD ID, assuming SSD1289\n");
+ id = SSD1289_DEVCODE_VALUE;
+ }
/* Check if the ID is for the SSD1289 */