diff --git a/drivers/lcd/lcd_dev.c b/drivers/lcd/lcd_dev.c index 93f7d53a1f..93ac9f1cfc 100644 --- a/drivers/lcd/lcd_dev.c +++ b/drivers/lcd/lcd_dev.c @@ -118,8 +118,11 @@ static int lcddev_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR struct lcddev_area_s *lcd_area = (FAR struct lcddev_area_s *)arg; size_t cols = lcd_area->col_end - lcd_area->col_start + 1; - size_t row_size = cols * (priv->planeinfo.bpp > 1 ? - priv->planeinfo.bpp >> 3 : 1); + size_t pixel_size = priv->planeinfo.bpp > 1 ? + priv->planeinfo.bpp >> 3 : 1; + size_t row_size = lcd_area->stride > 0 ? + lcd_area->stride * pixel_size : + cols * pixel_size; if (priv->planeinfo.getarea) { @@ -158,8 +161,11 @@ static int lcddev_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR const struct lcddev_area_s *lcd_area = (FAR const struct lcddev_area_s *)arg; size_t cols = lcd_area->col_end - lcd_area->col_start + 1; - size_t row_size = cols * (priv->planeinfo.bpp > 1 ? - priv->planeinfo.bpp >> 3 : 1); + size_t pixel_size = priv->planeinfo.bpp > 1 ? + priv->planeinfo.bpp >> 3 : 1; + size_t row_size = lcd_area->stride > 0 ? + lcd_area->stride * pixel_size : + cols * pixel_size; if (priv->planeinfo.putarea) { diff --git a/include/nuttx/lcd/lcd_dev.h b/include/nuttx/lcd/lcd_dev.h index 9b8a0e0610..b3b2c40f24 100644 --- a/include/nuttx/lcd/lcd_dev.h +++ b/include/nuttx/lcd/lcd_dev.h @@ -87,6 +87,7 @@ struct lcddev_area_s { fb_coord_t row_start, row_end; fb_coord_t col_start, col_end; + fb_coord_t stride; FAR uint8_t *data; };