From patchwork Sun Feb 2 12:46:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Kajt=C3=A1r_Zsolt?= X-Patchwork-Id: 13956512 Received: from c64.rulez.org (c64.rulez.org [79.139.58.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D11D1D6DB6 for ; Sun, 2 Feb 2025 12:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.139.58.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738500416; cv=none; b=jwai5Spf4S5G88sqyamKf4YVfMorPnX3ANGGc4As5z7jjNWFClpn3qyF8wpYdSVoJqdYqrJMZl6kAyZOfCCmpwxcukA8/jU9CWMfdL9G7/xvHZyverorGylRt4NBoTAuXqB4kBe8fAbJwD8WXiB+tTjCsNo3bkmKHRAyrOM1NFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738500416; c=relaxed/simple; bh=UySuaKMdF+qDuWLBJcChIir92Q/vfWkpJw9YlW6ziNY=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=qaPV0e00hFEut5oKZPcV69JbO3i5rsSecycgn6OZlI3jZMHIX9lOYIKsEiqqUCcrFtDiQHgxTwvIa2nXYrLla3FJww8i7dUbxwgWXxeSP71+AEQgPF7UQG7cp0HRBYrDy7sdCJQthQ5vfjtkcKOYczHU9MUa2KWE3Oin0E4LlLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org; spf=pass smtp.mailfrom=c64.rulez.org; arc=none smtp.client-ip=79.139.58.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c64.rulez.org Received: from [192.168.0.59] (unknown [89.134.12.53]) by c64.rulez.org (Postfix) with ESMTPSA id AA605100F6 for ; Sun, 2 Feb 2025 13:46:52 +0100 (CET) Message-ID: <8ed1d74c-0757-6c6c-d619-9d9b4fea00c0@c64.rulez.org> Date: Sun, 2 Feb 2025 13:46:52 +0100 Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: [RFC PATCH 10/12] fbdev: core: Make fb_imageblit generic Content-Language: en-GB From: =?utf-8?q?Kajt=C3=A1r_Zsolt?= To: linux-fbdev@vger.kernel.org References: <0e2eba19-bc83-fd23-c9ff-59299a738bcf@c64.rulez.org> <50c335f3-d3c9-3f1d-dd3b-e78818425662@c64.rulez.org> <65535c64-6f8e-95b4-e171-528176969983@c64.rulez.org> <15ae6780-b3a9-abad-047b-a650d193aba3@c64.rulez.org> <7f2cf3dc-ae1e-7b6c-9c71-717b6f4453ea@c64.rulez.org> <6c0e4997-8215-a249-20ed-d353ca476cd4@c64.rulez.org> In-Reply-To: <6c0e4997-8215-a249-20ed-d353ca476cd4@c64.rulez.org> fbdev: core: Make fb_imageblit generic Signed-off-by: Zsolt Kajtar --- drivers/video/fbdev/core/fb_imageblit.h | 53 ++++++++++--------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/drivers/video/fbdev/core/fb_imageblit.h b/drivers/video/fbdev/core/fb_imageblit.h index 7d1d2f1a6..d0308135e 100644 --- a/drivers/video/fbdev/core/fb_imageblit.h +++ b/drivers/video/fbdev/core/fb_imageblit.h @@ -29,10 +29,6 @@ * Also need to add code to deal with cards endians that are different than * the native cpu endians. I also need to deal with MSB position in the word. */ -#include -#include -#include -#include #include "fb_draw.h" #define DEBUG @@ -69,16 +65,13 @@ static const u32 cfb_tab32[] = { 0x00000000, 0xffffffff }; -#define FB_WRITEL fb_writel -#define FB_READL fb_readl - static inline void color_imageblit(const struct fb_image *image, - struct fb_info *p, u8 __iomem *dst1, + struct fb_info *p, u8 FB_MEM *dst1, u32 start_index, u32 pitch_index) { /* Draw the penguin */ - u32 __iomem *dst, *dst2; + u32 FB_MEM *dst, *dst2; u32 color = 0, val, shift; int i, n, bpp = p->var.bits_per_pixel; u32 null_bits = 32 - bpp; @@ -86,10 +79,10 @@ static inline void color_imageblit(const struct fb_image *image, const u8 *src = image->data; u32 bswapmask = fb_compute_bswapmask(p); - dst2 = (u32 __iomem *) dst1; + dst2 = (u32 FB_MEM *) dst1; for (i = image->height; i--; ) { n = image->width; - dst = (u32 __iomem *) dst1; + dst = (u32 FB_MEM *) dst1; shift = 0; val = 0; @@ -126,7 +119,7 @@ static inline void color_imageblit(const struct fb_image *image, dst1 += p->fix.line_length; if (pitch_index) { dst2 += p->fix.line_length; - dst1 = (u8 __iomem *)((long __force)dst2 & ~(sizeof(u32) - 1)); + dst1 = (u8 FB_MEM *)((long __force)dst2 & ~(sizeof(u32) - 1)); start_index += pitch_index; start_index &= 32 - 1; @@ -135,13 +128,13 @@ static inline void color_imageblit(const struct fb_image *image, } static inline void slow_imageblit(const struct fb_image *image, struct fb_info *p, - u8 __iomem *dst1, u32 fgcolor, + u8 FB_MEM *dst1, u32 fgcolor, u32 bgcolor, u32 start_index, u32 pitch_index) { u32 shift, color = 0, bpp = p->var.bits_per_pixel; - u32 __iomem *dst, *dst2; + u32 FB_MEM *dst, *dst2; u32 val, pitch = p->fix.line_length; u32 null_bits = 32 - bpp; u32 spitch = (image->width+7)/8; @@ -149,7 +142,7 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info * u32 i, j, l; u32 bswapmask = fb_compute_bswapmask(p); - dst2 = (u32 __iomem *) dst1; + dst2 = (u32 FB_MEM *) dst1; fgcolor <<= FB_LEFT_POS(p, bpp); bgcolor <<= FB_LEFT_POS(p, bpp); @@ -157,7 +150,7 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info * shift = val = 0; l = 8; j = image->width; - dst = (u32 __iomem *) dst1; + dst = (u32 FB_MEM *) dst1; s = src; /* write leading bits */ @@ -196,7 +189,7 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info * src += spitch; if (pitch_index) { dst2 += pitch; - dst1 = (u8 __iomem *)((long __force)dst2 & ~(sizeof(u32) - 1)); + dst1 = (u8 FB_MEM *)((long __force)dst2 & ~(sizeof(u32) - 1)); start_index += pitch_index; start_index &= 32 - 1; } @@ -213,14 +206,14 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info * * beginning and end of a scanline is dword aligned */ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *p, - u8 __iomem *dst1, u32 fgcolor, + u8 FB_MEM *dst1, u32 fgcolor, u32 bgcolor) { u32 fgx = fgcolor, bgx = bgcolor, bpp = p->var.bits_per_pixel; u32 ppw = 32/bpp, spitch = (image->width + 7)/8; u32 bit_mask, eorx, shift; - const char *s = image->data, *src; - u32 __iomem *dst; + const u8 *s = image->data, *src; + u32 FB_MEM *dst; const u32 *tab = NULL; size_t tablen; u32 colortab[16]; @@ -258,7 +251,7 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info * colortab[i] = (tab[i] & eorx) ^ bgx; for (i = image->height; i--; ) { - dst = (u32 __iomem *)dst1; + dst = (u32 FB_MEM *)dst1; shift = 8; src = s; @@ -315,19 +308,20 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info * } } -void cfb_imageblit(struct fb_info *p, const struct fb_image *image) +void FB_IMAGEBLIT (struct fb_info *p, const struct fb_image *image) { u32 fgcolor, bgcolor, start_index, bitstart, pitch_index = 0; u32 bpl = sizeof(u32), bpp = p->var.bits_per_pixel; u32 width = image->width; u32 dx = image->dx, dy = image->dy; - u8 __iomem *dst1; + u8 FB_MEM *dst1; if (p->state != FBINFO_STATE_RUNNING) return; - if (p->flags & FBINFO_VIRTFB) - fb_warn_once(p, "Framebuffer is not in I/O address space."); + if ((p->flags & FBINFO_VIRTFB) != FB_SPACE) + fb_warn_once(p, "Framebuffer is not in " FB_SPACE_NAME + " address space."); bitstart = (dy * p->fix.line_length * 8) + (dx * bpp); start_index = bitstart & (32 - 1); @@ -335,7 +329,7 @@ void cfb_imageblit(struct fb_info *p, const struct fb_image *image) bitstart /= 8; bitstart &= ~(bpl - 1); - dst1 = p->screen_base + bitstart; + dst1 = (void __force *)FB_SCREEN_BASE(p) + bitstart; if (p->fbops->fb_sync) p->fbops->fb_sync(p); @@ -360,10 +354,3 @@ void cfb_imageblit(struct fb_info *p, const struct fb_image *image) } else color_imageblit(image, p, dst1, start_index, pitch_index); } - -EXPORT_SYMBOL(cfb_imageblit); - -MODULE_AUTHOR("James Simmons "); -MODULE_DESCRIPTION("Generic software accelerated imaging drawing"); -MODULE_LICENSE("GPL"); -