You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/11/03 16:20:51 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2208: lcd: add optional putarea() operation

xiaoxiang781216 commented on a change in pull request #2208:
URL: https://github.com/apache/incubator-nuttx/pull/2208#discussion_r516785518



##########
File path: arch/sim/src/sim/up_lcd.c
##########
@@ -242,6 +246,63 @@ static int sim_putrun(fb_coord_t row, fb_coord_t col,
   return OK;
 }
 
+/****************************************************************************
+ * Name:  sim_putarea
+ *
+ * Description:
+ *   This method can be used to write a partial raster line to the LCD:
+ *
+ *   row_start - Starting row to write to (range: 0 <= row < yres)
+ *   row_end   - Ending row to write to (range: row_start <= row < yres)
+ *   col_start - Starting column to write to (range: 0 <= col <= xres)
+ *   col_end   - Ending column to write to
+ *               (range: col_start <= col_end < xres)
+ *   buffer    - The buffer containing the area to be written to the LCD
+ *
+ ****************************************************************************/
+
+static int sim_putarea(fb_coord_t row_start, fb_coord_t row_end,
+                       fb_coord_t col_start, fb_coord_t col_end,
+                       FAR const uint8_t *buffer)
+{
+  fb_coord_t row;
+  size_t rows;
+  size_t cols;
+  size_t row_size;
+
+  lcdinfo("row_start: %d row_end: %d col_start: %d col_end: %d\n", row_start
+          row_end, col_start, col_end);
+
+  cols = col_end - col_start + 1;
+  rows = row_end - row_start + 1;
+  row_size = (col_end - col_start + 1) * (g_planeinfo.bpp >> 3);

Review comment:
       (col_end - col_start + 1) to cols

##########
File path: include/nuttx/lcd/lcd_dev.h
##########
@@ -76,6 +77,14 @@ struct lcddev_run_s
   size_t npixels;
 };
 
+struct lcddev_area_s
+{
+  fb_coord_t row_start, row_end;
+  fb_coord_t col_start, col_end;
+  size_t stride;

Review comment:
       remove, it has to be same as lcd driver's report

##########
File path: arch/sim/src/sim/up_lcd.c
##########
@@ -242,6 +246,63 @@ static int sim_putrun(fb_coord_t row, fb_coord_t col,
   return OK;
 }
 
+/****************************************************************************
+ * Name:  sim_putarea
+ *
+ * Description:
+ *   This method can be used to write a partial raster line to the LCD:
+ *
+ *   row_start - Starting row to write to (range: 0 <= row < yres)
+ *   row_end   - Ending row to write to (range: row_start <= row < yres)
+ *   col_start - Starting column to write to (range: 0 <= col <= xres)
+ *   col_end   - Ending column to write to
+ *               (range: col_start <= col_end < xres)
+ *   buffer    - The buffer containing the area to be written to the LCD
+ *
+ ****************************************************************************/
+
+static int sim_putarea(fb_coord_t row_start, fb_coord_t row_end,
+                       fb_coord_t col_start, fb_coord_t col_end,
+                       FAR const uint8_t *buffer)
+{
+  fb_coord_t row;
+  size_t rows;
+  size_t cols;
+  size_t row_size;
+
+  lcdinfo("row_start: %d row_end: %d col_start: %d col_end: %d\n", row_start

Review comment:
       move row_start to next line

##########
File path: drivers/lcd/lcd_dev.c
##########
@@ -123,20 +123,56 @@ static int lcddev_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
     {
     case LCDDEVIO_GETRUN:
       {
-        FAR struct lcddev_run_s *lcd_putrun =
+        FAR struct lcddev_run_s *lcd_run =
             (FAR struct lcddev_run_s *)arg;
 
-        ret = priv->planeinfo.getrun(lcd_putrun->row, lcd_putrun->col,
-                                     lcd_putrun->data, lcd_putrun->npixels);
+        ret = priv->planeinfo.getrun(lcd_run->row, lcd_run->col,
+                                     lcd_run->data, lcd_run->npixels);
       }
       break;
     case LCDDEVIO_PUTRUN:
       {
-        const FAR struct lcddev_run_s *lcd_putrun =
+        const FAR struct lcddev_run_s *lcd_run =
             (const FAR struct lcddev_run_s *)arg;
 
-        ret = priv->planeinfo.putrun(lcd_putrun->row, lcd_putrun->col,
-                                     lcd_putrun->data, lcd_putrun->npixels);
+        ret = priv->planeinfo.putrun(lcd_run->row, lcd_run->col,
+                                     lcd_run->data, lcd_run->npixels);
+      }
+      break;
+    case LCDDEVIO_PUTAREA:
+      {
+        const FAR struct lcddev_area_s *lcd_area =
+            (const FAR struct lcddev_area_s *)arg;
+
+        if (priv->planeinfo.putarea)
+          {
+            ret = priv->planeinfo.putarea(lcd_area->row_start,
+                                          lcd_area->row_end,
+                                          lcd_area->col_start,
+                                          lcd_area->col_end,
+                                          lcd_area->data);
+          }
+        else
+          {
+            /* Emulate putarea() using putrun() */
+
+            uint8_t *buf = lcd_area->data;
+            size_t npixels = (lcd_area->col_end - lcd_area->col_start + 1);
+            int row;
+
+            for (row = lcd_area->row_start; row <= lcd_area->row_end; row++)
+              {
+                ret = priv->planeinfo.putrun(row, lcd_area->col_start, buf,
+                                             npixels);
+
+                buf += npixels * (priv->planeinfo.bpp >> 3);
+
+                if (ret < 0)

Review comment:
       move before line 168

##########
File path: include/nuttx/lcd/lcd_dev.h
##########
@@ -37,15 +37,16 @@
  * Type Definitions
  ****************************************************************************/
 
-#define LCDDEVIO_PUTRUN       _LCDIOC(0)  /* Arg: const struct lcddev_putrun_s* */
-#define LCDDEVIO_GETRUN       _LCDIOC(1)  /* Arg: struct lcddev_putrun_s* */
-#define LCDDEVIO_GETPOWER     _LCDIOC(2)  /* Arg: int* */
-#define LCDDEVIO_SETPOWER     _LCDIOC(3)  /* Arg: int */
-#define LCDDEVIO_GETCONTRAST  _LCDIOC(4)  /* Arg: int* */
-#define LCDDEVIO_SETCONTRAST  _LCDIOC(5)  /* Arg: unsigned int */
-#define LCDDEVIO_GETPLANEINFO _LCDIOC(6)  /* Arg: struct lcd_planeinfo_s* */
-#define LCDDEVIO_GETVIDEOINFO _LCDIOC(7)  /* Arg: struct fb_videoinfo_s* */
-#define LCDDEVIO_SETPLANENO   _LCDIOC(8)  /* Arg: int */
+#define LCDDEVIO_PUTRUN       _LCDIOC(0)  /* Arg: const struct lcddev_run_s* */
+#define LCDDEVIO_PUTAREA      _LCDIOC(1)  /* Arg: const struct lcddev_area_s* */
+#define LCDDEVIO_GETRUN       _LCDIOC(2)  /* Arg: struct lcddev_run_s* */

Review comment:
       should we add LCDDEVIO_GETAREA

##########
File path: drivers/lcd/lcd_dev.c
##########
@@ -123,20 +123,56 @@ static int lcddev_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
     {
     case LCDDEVIO_GETRUN:
       {
-        FAR struct lcddev_run_s *lcd_putrun =
+        FAR struct lcddev_run_s *lcd_run =
             (FAR struct lcddev_run_s *)arg;
 
-        ret = priv->planeinfo.getrun(lcd_putrun->row, lcd_putrun->col,
-                                     lcd_putrun->data, lcd_putrun->npixels);
+        ret = priv->planeinfo.getrun(lcd_run->row, lcd_run->col,
+                                     lcd_run->data, lcd_run->npixels);
       }
       break;
     case LCDDEVIO_PUTRUN:
       {
-        const FAR struct lcddev_run_s *lcd_putrun =
+        const FAR struct lcddev_run_s *lcd_run =
             (const FAR struct lcddev_run_s *)arg;
 
-        ret = priv->planeinfo.putrun(lcd_putrun->row, lcd_putrun->col,
-                                     lcd_putrun->data, lcd_putrun->npixels);
+        ret = priv->planeinfo.putrun(lcd_run->row, lcd_run->col,
+                                     lcd_run->data, lcd_run->npixels);
+      }
+      break;
+    case LCDDEVIO_PUTAREA:
+      {
+        const FAR struct lcddev_area_s *lcd_area =
+            (const FAR struct lcddev_area_s *)arg;
+
+        if (priv->planeinfo.putarea)
+          {
+            ret = priv->planeinfo.putarea(lcd_area->row_start,

Review comment:
       need optimize lcd_framebuffer.c too, maybe we can write a common function lcd_putarea(...) shared by lcd_dev.c and lcd_framebuffer.c




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org