From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796223385; b=rsSzs4Q7zlObdWk+OuGJspIh5tvzc0I2lXnTuK7VaGpV4Gw2/Ixp+omdyT426Mixz8xO jbm+T2+Fm3ThWiXGR9roFSWWlCLxt3sgL789fn7AfToMfvoufzLxE/dDlNZchmJVbnX3O Gj5QxnbUt8b8goJtXnee8WvlFX8NqAgjcfGcYyCEjPGyFNidGMRQ9wYRASFN+iIqDDdRX 7qI1jkv8lr5c2LM5P9o6gz0kqblYiWC7lqgO5j0XB/+q5zhEIp5vkueAjHL9wYnSO9MVx WiUa4gHw18+PPE2o6NmpgBDi0X/g3cXc4IT71t/2Uy6XZDG42I3Qaja1DcI+gxhsTBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796223385; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=bVTD+T8SpgsAmfE9FN1khh7oFaHbJF70Gj+FVNO7QNc=; b=h41NSrvqId4t+t5y4reDVReOhyWC+Dy56w5t85RPot9WGZJCjF9ZB7Mt70DbcTRyI2N1 lAXcfKrCXeFVxplrDJwGJ0XRoNbCBhQCuLnJoDBjy4rhe+zIguBbjj0rnnzWZF1SuRPMI YRHbyECj6mYtJ3GCpnG9B5L2dx2Y33Pq0bKTlANAa3Lt2H7fZFzBc0caaUUHJS5L+v7BV mtcQo/a0BfiRL8jOk8oSljYUauyeCWXZmmSCHujcxJoJsFMDLpe76XoMj0kIP3zD5xhfn uIQ761vHKhb0gmUP2kVQ2cRQE8dihZvUp14W7QI18pQUFJJPy3dpLzIOIHLBNyv5d2g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=bkgkTZNF; arc=none smtp.remote-ip=209.85.216.49 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAA52606A323 for ; Wed, 2 Dec 2026 14:56:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AAA52606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=bkgkTZNF Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-3b501791bb5so3673875a91.1 for ; Wed, 02 Dec 2026 06:56:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796223384; x=1796828184; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=bVTD+T8SpgsAmfE9FN1khh7oFaHbJF70Gj+FVNO7QNc=; b=bkgkTZNFSX+uIdZc2IsPZ+BhTDKMyTPk0UOP8A6zK+sVGiGOBIje+thtEvwYDL4K/s D4T9PDIo96GQhMBPqv0C/e9LM4iNJV0PYXtLKXIpSxZYuPXOcaTrOSE2PQ0B47Qzu0za rc/CDb2ZFYnUHItOeCasK/E3rq+7b6jdRExk6Ezue0JYJjGFTValQIqp1kHL/xUxeaKy wmWRtch2xGolPq0f/2QpTBjUrMq//0I13hwpO3W47JAuMLftR07bsAAJLaM5EFPl7TA+ 5HdOl8yMPPLS9Zn+hW93MXuS6f2rrQa7L39YaNT4/qv5O2H2Lb5APfZ4YP7EfW5/YEeD tw3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796223384; x=1796828184; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bVTD+T8SpgsAmfE9FN1khh7oFaHbJF70Gj+FVNO7QNc=; b=bBhoVNqdxTXpWvQeTPrpDjbalhr/2B/Xt8fHymgdB/m80VM/ydF53Ds0WSicBkmiWK dnBBdO6nTi6b6TUAP48qahg3uHwOiaRjGo6GsffcBBBjmpn6i5yRNfD2Ab4njEKvEjCw Dk45GvJCKC7SPKsVdSZRnA4daG9ZiqvU//gzM4xEXrqhn8IXc9USDewHQeaVmWK1awzo oOoOKf7/mTuhST3CzcwHKAruXvIWTriFZTsInwwNUvRrm06CZwRGuOc26WZlTyLS9njq i7UFIV8hnQ14Iepuz2JlP37ePK2Ww1kXU3qpQIccoHnN932MyMLRz7Snxm823TXIRlUO yC8Q== X-Forwarded-Encrypted: i=1; AL+hErGO0KGzyfE+QYc2/xdXMxZTg8YhKjClp9eFYKIGYyz2orOntmdQaqoJyH1jBdrpPJ+EI2yvOO6juwqUarc=@vger.kernel.org X-Gm-Message-State: APuU4Z+a2QwM79fypmYtz9XtUY55EKmLyc3P6kR2WVyCNhSRiKI0CYud 5lKBCq7FlRY8/IVbnU+dPhbz+REDk2BzkA3kJWSzTEhoXfxuoLZhmp4n X-Gm-Gg: AZFdTZfLjnFTXwSIdkCWuZlj2y1xgzwRXyAd/xFTLlUOG+k/Fn10Pplnm8xzWVcD8qo 2JUXwglfWntFXOCB6GZc4LctTCK31SglnIVYej5OLngGGUM1H7B6+GGe42L4EnKpgQiPTtzfMPt nEwC9ujFSUVIDbqDuwG88Ra/e0K2ztn7+SgCH2DFDC8l8w6QD1xOP3C5Tiji8lLHDBSOLMgT4BD goaSF+cztnc3F3twprZU4WG9GT2oRfGc5g1lGc2DTFDcylh+dkX12uO+PcFQKiSwi28YQpYz6Sm 0pgwbYwRouXTMPSh2sIcMsRnZPm0dIt33al2uHBenBo2jdMUMbVZPCz4Dk+a1dC2VG6lj/M/F+L i1QjU1wV4w2fI7G3FhW1dc7praePDdGmeAX6Vo636dViMUo5aBttVK23q3Br5in8aqINkd1ICmh gy9MFjIixnZ96hCKtPlUdtqIjLuf0deGICJ5u0V4VFZLt42WLv2k9gyDJ9QABtvBYmKm7SJCXsi c4O7zykAaCH0fFOWwt9tHrBH+MD2vhcWDTaUasuUC6SXU3WaYLfEF6eSFBJOznb8klpRLYPq5kG 2PAn2YDcvWzpOU9+js2dP+1LanAgfF5NzevEk4x1UzIMIJZhXpUaUQ== X-Received: by 2002:a17:90b:498c:b0:3b3:8b61:c44a with SMTP id 98e67ed59e1d1-3b41c7d5c1cmr34303085a91.4.1796223383712; Wed, 02 Dec 2026 06:56:23 -0800 (PST) Received: from localhost.localdomain ([106.213.82.148]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b4dfbe54a2sm44813958a91.17.2026.12.02.06.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 06:56:23 -0800 (PST) From: himanshu bakshi 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 Message-ID: <20261202145543.121935-1-himanshu.bakshi478@gmail.com> X-Mailer: git-send-email 2.56.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Himanshu Bakshi 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 --- 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