From: himanshu bakshi <himanshu.bakshi478@gmail.com>
To: sudip.mukherjee@gmail.com, teddy.wang@siliconmotion.com,
gregkh@linuxfoundation.org, linux-fbdev@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: himanshu.bakshi478@gmail.com
Subject: [PATCH v1] staging: sm750fb: add hardware-accelerated color imageblit support
Date: Wed, 2 Dec 2026 20:25:43 +0530 [thread overview]
Message-ID: <20261202145543.121935-1-himanshu.bakshi478@gmail.com> (raw)
From: Himanshu Bakshi <himanshu.bakshi478@gmail.com>
Add a hardware-accelerated function for color imageblit and dispatch
imageblit operations to the monochrome or color implementation based
on the source image depth.
Signed-off-by: Himanshu Bakshi <himanshu.bakshi478@gmail.com>
---
drivers/staging/sm750fb/sm750.c | 33 ++++--
drivers/staging/sm750fb/sm750.h | 9 +-
drivers/staging/sm750fb/sm750_accel.c | 153 +++++++++++++++++++++++++-
drivers/staging/sm750fb/sm750_accel.h | 8 +-
4 files changed, 180 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 21e310274330..e54ed7e474eb 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -228,12 +228,6 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
pitch = info->fix.line_length;
bpp = info->var.bits_per_pixel >> 3;
- /* TODO: Implement hardware acceleration for image->depth > 1 */
- if (image->depth != 1) {
- cfb_imageblit(info, image);
- return;
- }
-
if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
fgcol = ((u32 *)info->pseudo_palette)[image->fg_color];
@@ -243,6 +237,17 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
bgcol = image->bg_color;
}
+ switch (image->depth) {
+ case 1:
+ case 8:
+ case 16:
+ case 24:
+ case 32:
+ break;
+ default:
+ cfb_imageblit(info, image);
+ return;
+ }
/*
* If not use spin_lock, system will die if user load driver
* and immediately unload driver frequently (dual)
@@ -252,11 +257,17 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
spin_lock(&sm750_dev->slock);
sm750_dev->accel.de_imageblit(&sm750_dev->accel,
- image->data, 0,
- base, pitch, bpp,
- image->dx, image->dy,
- image->width, image->height,
- fgcol, bgcol, HW_ROP2_COPY);
+ image->data,
+ 0,
+ base, pitch,
+ image->depth == 1 ? 0 :
+ image->depth >> 3,
+ bpp,
+ image->dx, image->dy,
+ image->width, image->height,
+ fgcol, bgcol,
+ HW_ROP2_COPY);
+
spin_unlock(&sm750_dev->slock);
}
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index fd1cf9eb5797..3c97e3034ed1 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -63,10 +63,11 @@ struct lynx_accel {
u32 width, u32 height,
u32 rop2);
- int (*de_imageblit)(struct lynx_accel *accel, const char *p_srcbuf,
- u32 start_bit, u32 d_base, u32 d_pitch,
- u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
- u32 height, u32 f_color, u32 b_color, u32 rop2);
+ int (*de_imageblit)(struct lynx_accel *accel, const char *src_buf,
+ u32 start_bit, u32 dest_base, u32 dest_pitch,
+ u32 src_byte_per_pixel, u32 byte_per_pixel,
+ u32 dx, u32 dy, u32 width, u32 height,
+ u32 fg_color, u32 bg_color, u32 rop2);
};
diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c
index bac9a209899c..b0474e8bce83 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -285,7 +285,7 @@ static unsigned int de_get_transparency(struct lynx_accel *accel)
}
/**
- * sm750_hw_imageblit
+ * sm750_hw_imageblit_mono
* @accel: Acceleration device data
* @src_buf: pointer to start of source buffer in system memory
* @start_bit: Mono data can start at any bit in a byte, this value should be
@@ -301,10 +301,10 @@ static unsigned int de_get_transparency(struct lynx_accel *accel)
* @bg_color: Background color (corresponding to a 0 in the monochrome data
* @rop2: ROP value
*/
-int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf,
- u32 start_bit, u32 dest_base, u32 dest_pitch,
- u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
- u32 height, u32 fg_color, u32 bg_color, u32 rop2)
+static int sm750_hw_imageblit_mono(struct lynx_accel *accel, const char *src_buf,
+ u32 start_bit, u32 dest_base, u32 dest_pitch,
+ u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
+ u32 height, u32 fg_color, u32 bg_color, u32 rop2)
{
unsigned int bytes_per_scan;
unsigned int words_per_scan;
@@ -399,3 +399,146 @@ int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf,
return 0;
}
+/*
+ * sm750_hw_imageblit_color
+ * @accel: Acceleration device data
+ * @src_buf: pointer to start of source buffer in system memory
+ * @dest_base: Address of destination: offset in frame buffer
+ * @dest_pitch: Pitch value of destination surface in BYTE
+ * @src_byte_per_pixel: Color depth of source surface
+ * @byte_per_pixel: Color depth of destination surface
+ * @dx: Starting x coordinate of destination surface
+ * @dy: Starting y coordinate of destination surface
+ * @width: width of rectangle in pixel value
+ * @height: height of rectangle in pixel value
+ * @rop2: ROP value
+ */
+static int sm750_hw_imageblit_color(struct lynx_accel *accel, const char *src_buf,
+ u32 dest_base, u32 dest_pitch, u32 src_byte_per_pixel,
+ u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
+ u32 height, u32 rop2)
+{
+ unsigned int bytes_per_scan;
+ unsigned int words_per_scan;
+ unsigned int bytes_remain;
+ unsigned int de_ctrl;
+ unsigned char remain[4] = {};
+ int i, j;
+ int ret;
+
+ bytes_per_scan = width * src_byte_per_pixel;
+ words_per_scan = bytes_per_scan & ~3;
+ bytes_remain = bytes_per_scan & 3;
+
+ ret = accel->de_wait();
+ if (ret)
+ return ret;
+
+ /*
+ * 2D Source Base.
+ * Use 0 for HOST Blt.
+ */
+ write_dpr(accel, DE_WINDOW_SOURCE_BASE, 0);
+
+ /* 2D Destination Base.
+ * It is an address offset (128 bit aligned)
+ * from the beginning of frame buffer.
+ */
+ write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dest_base);
+
+ /*
+ * Program pitch (distance between the 1st points of two adjacent
+ * lines). Note that input pitch is BYTE value, but the 2D Pitch
+ * register uses pixel values. Need Byte to pixel conversion.
+ */
+ write_dpr(accel, DE_PITCH,
+ ((dest_pitch / byte_per_pixel << DE_PITCH_DESTINATION_SHIFT) &
+ DE_PITCH_DESTINATION_MASK) |
+ (dest_pitch / byte_per_pixel & DE_PITCH_SOURCE_MASK)); /* dpr10 */
+
+ /*
+ * Screen Window width in Pixels.
+ * 2D engine uses this value to calculate the linear address
+ * in frame buffer for a given point.
+ */
+ write_dpr(accel, DE_WINDOW_WIDTH,
+ ((dest_pitch / byte_per_pixel << DE_WINDOW_WIDTH_DST_SHIFT) &
+ DE_WINDOW_WIDTH_DST_MASK) |
+ (dest_pitch / byte_per_pixel & DE_WINDOW_WIDTH_SRC_MASK));
+
+ /*
+ * X_K1 is only relevant when
+ * the source is a packed monochrome bitmap.
+ */
+ write_dpr(accel, DE_SOURCE, 0); /* dpr00 */
+
+ write_dpr(accel, DE_DESTINATION,
+ ((dx << DE_DESTINATION_X_SHIFT) & DE_DESTINATION_X_MASK) |
+ (dy & DE_DESTINATION_Y_MASK)); /* dpr04 */
+
+ write_dpr(accel, DE_DIMENSION,
+ ((width << DE_DIMENSION_X_SHIFT) & DE_DIMENSION_X_MASK) |
+ (height & DE_DIMENSION_Y_ET_MASK)); /* dpr08 */
+
+ de_ctrl = (rop2 & DE_CONTROL_ROP_MASK) |
+ DE_CONTROL_ROP_SELECT | DE_CONTROL_COMMAND_HOST_WRITE |
+ DE_CONTROL_STATUS;
+
+ write_dpr(accel, DE_CONTROL, de_ctrl | de_get_transparency(accel));
+
+ /* Write COLOR data (line by line) to 2D Engine data port */
+ for (i = 0; i < height; i++) {
+ /* For each line, send the data in chunks of 4 bytes */
+ for (j = 0; j < (words_per_scan / 4); j++)
+ write_dp_port(accel, *(unsigned int *)(src_buf + (j * 4)));
+
+ if (bytes_remain) {
+ memcpy(remain, src_buf + words_per_scan,
+ bytes_remain);
+ write_dp_port(accel, *(unsigned int *)remain);
+ }
+
+ src_buf += bytes_per_scan;
+ }
+
+ return 0;
+}
+
+/*
+ * sm750_hw_imageblit
+ * @accel: Acceleration device data
+ * @src_buf: pointer to start of source buffer in system memory
+ * @start_bit: Mono data can start at any bit in a byte, this value should be
+ * 0 to 7
+ * @dest_base: Address of destination: offset in frame buffer
+ * @dest_pitch: Pitch value of destination surface in BYTE
+ * @src_byte_per_pixel: Pitch value of source surface in BYTE. (0 for mono.
+ * @byte_per_pixel: Color depth of destination surface
+ * @dx: Starting x coordinate of destination surface
+ * @dy: Starting y coordinate of destination surface
+ * @width: width of rectangle in pixel value
+ * @height: height of rectangle in pixel value
+ * @fg_color: Foreground color (corresponding to a 1 in the monochrome data
+ * @bg_color: Background color (corresponding to a 0 in the monochrome data
+ * @rop2: ROP value
+ */
+int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf,
+ u32 start_bit, u32 dest_base, u32 dest_pitch,
+ u32 src_byte_per_pixel, u32 byte_per_pixel,
+ u32 dx, u32 dy, u32 width, u32 height,
+ u32 fg_color, u32 bg_color, u32 rop2)
+{
+ if (src_byte_per_pixel)
+ return sm750_hw_imageblit_color(accel, src_buf,
+ dest_base, dest_pitch,
+ src_byte_per_pixel,
+ byte_per_pixel,
+ dx, dy, width, height,
+ rop2);
+
+ return sm750_hw_imageblit_mono(accel, src_buf, start_bit,
+ dest_base, dest_pitch,
+ byte_per_pixel,
+ dx, dy, width, height,
+ fg_color, bg_color, rop2);
+}
diff --git a/drivers/staging/sm750fb/sm750_accel.h b/drivers/staging/sm750fb/sm750_accel.h
index 6db54c6526dc..bfb8ec00c9b5 100644
--- a/drivers/staging/sm750fb/sm750_accel.h
+++ b/drivers/staging/sm750fb/sm750_accel.h
@@ -223,9 +223,10 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
* @accel: Acceleration device data
* @src_buf: pointer to start of source buffer in system memory
* @start_bit: Mono data can start at any bit in a byte, this value should be
- *>----- 0 to 7
+ * 0 to 7
* @dest_base: Address of destination: offset in frame buffer
* @dest_pitch: Pitch value of destination surface in BYTE
+ * @src_byte_per_pixel: Pitch value of source surface in BYTE. (0 for mono.
* @byte_per_pixel: Color depth of destination surface
* @dx: Starting x coordinate of destination surface
* @dy: Starting y coordinate of destination surface
@@ -237,7 +238,8 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
*/
int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf,
u32 start_bit, u32 dest_base, u32 dest_pitch,
- u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
- u32 height, u32 fg_color, u32 bg_color, u32 rop2);
+ u32 src_byte_per_pixel, u32 byte_per_pixel,
+ u32 dx, u32 dy, u32 width, u32 height,
+ u32 fg_color, u32 bg_color, u32 rop2);
#endif
--
2.56.0
next reply other threads:[~2026-12-02 14:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 14:55 himanshu bakshi [this message]
2026-12-02 15:05 ` Dan Carpenter
2026-12-02 15:10 ` Himanshu Bakshi
2026-12-02 15:28 ` Dan Carpenter
2026-12-02 15:35 ` Himanshu Bakshi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202145543.121935-1-himanshu.bakshi478@gmail.com \
--to=himanshu.bakshi478@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=sudip.mukherjee@gmail.com \
--cc=teddy.wang@siliconmotion.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®