From patchwork Wed Jul 4 21:48:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 1157421 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 4CDF9DFF0F for ; Wed, 4 Jul 2012 21:49:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755927Ab2GDVtB (ORCPT ); Wed, 4 Jul 2012 17:49:01 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:58100 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755198Ab2GDVsv (ORCPT ); Wed, 4 Jul 2012 17:48:51 -0400 Received: by wgbdr13 with SMTP id dr13so7695650wgb.1 for ; Wed, 04 Jul 2012 14:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=PC7oBIS1LW58x0KHFQ8ygetkc4djFAY/StcxpCOvW18=; b=pyUBjikuCuU84J4K33HSAyq9e0rXQ5w2X2TMZV1x1aPytsFDb5dsqOGa6SFW3+Rq1h BKa6yG9G94y2Oxm854GUKIaxCxDiQjyBEyd8S6IBMkf9Ec1rHsgNREE6Io4wGMQEzd8C Hz6H+/3pk8Ho6Pbg1DAr5yFBnvy7rv5g8u6P24bNhzCLdj3bHZGX/P2VgfuyXD8HUPBY Px9TWgtfM/73bNbYZtfhAvtxp1LGrjuAM73j5K4aem6ahKLx+wy0bqMAgjUBufoLDABU VCKg45OHdSS/Qnxkk5rRjYd/nbE75m0sXflcdFQjA2ozwQBdqUujlSr8DPguTZZ7LjHF zI+A== Received: by 10.216.182.70 with SMTP id n48mr2336147wem.196.1341438529550; Wed, 04 Jul 2012 14:48:49 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71b29e.pool.mediaWays.net. [95.113.178.158]) by mx.google.com with ESMTPS id l5sm66953540wix.5.2012.07.04.14.48.48 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Jul 2012 14:48:49 -0700 (PDT) From: David Herrmann To: linux-serial@vger.kernel.org Cc: Florian Tobias Schandinat , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, alan@lxorguk.ukuu.org.uk, gregkh@linuxfoundation.org, David Herrmann Subject: [PATCH 1/2] fbcon: move update_attr() into separate source file Date: Wed, 4 Jul 2012 23:48:33 +0200 Message-Id: <1341438514-1786-2-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.11.1 In-Reply-To: <1341438514-1786-1-git-send-email-dh.herrmann@googlemail.com> References: <1341438514-1786-1-git-send-email-dh.herrmann@googlemail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org If we want to use update_attr() independently from fbcon, we need to split it off from bitblit.c and fbcon.h. Therefore, introduce a new header and source file (fbdraw.[ch]) which does not depende on vc_* and fbcon_* structures in any way. This does not introduce any new code nor does it make the paths deeper, it simply splits the function off. The other update_attr() functions (inside the rotation sources) seem similar but are significantly different and I haven't found a way to merge them efficiently (which is probably the reason why they are split off now). Furthermore, I do not intend to use them in the coming code so there is no need to split them off. Signed-off-by: David Herrmann --- drivers/video/console/Makefile | 3 ++- drivers/video/console/bitblit.c | 26 +++-------------------- drivers/video/console/fbcon.h | 5 +---- drivers/video/console/fbdraw.c | 46 +++++++++++++++++++++++++++++++++++++++++ drivers/video/console/fbdraw.h | 26 +++++++++++++++++++++++ 5 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 drivers/video/console/fbdraw.c create mode 100644 drivers/video/console/fbdraw.h diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile index a862e91..9a52226 100644 --- a/drivers/video/console/Makefile +++ b/drivers/video/console/Makefile @@ -25,7 +25,8 @@ obj-$(CONFIG_SGI_NEWPORT_CONSOLE) += newport_con.o font.o obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o font.o obj-$(CONFIG_VGA_CONSOLE) += vgacon.o obj-$(CONFIG_MDA_CONSOLE) += mdacon.o -obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon.o bitblit.o font.o softcursor.o +obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon.o bitblit.o font.o softcursor.o \ + fbdraw.o ifeq ($(CONFIG_FB_TILEBLITTING),y) obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += tileblit.o endif diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c index 28b1a83..6ec2905 100644 --- a/drivers/video/console/bitblit.c +++ b/drivers/video/console/bitblit.c @@ -22,26 +22,6 @@ /* * Accelerated handlers. */ -static void update_attr(u8 *dst, u8 *src, int attribute, - struct vc_data *vc) -{ - int i, offset = (vc->vc_font.height < 10) ? 1 : 2; - int width = DIV_ROUND_UP(vc->vc_font.width, 8); - unsigned int cellsize = vc->vc_font.height * width; - u8 c; - - offset = cellsize - (offset * width); - for (i = 0; i < cellsize; i++) { - c = src[i]; - if (attribute & FBCON_ATTRIBUTE_UNDERLINE && i >= offset) - c = 0xff; - if (attribute & FBCON_ATTRIBUTE_BOLD) - c |= c >> 1; - if (attribute & FBCON_ATTRIBUTE_REVERSE) - c = ~c; - dst[i] = c; - } -} static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy, int sx, int dy, int dx, int height, int width) @@ -88,7 +68,7 @@ static inline void bit_putcs_aligned(struct vc_data *vc, struct fb_info *info, charmask)*cellsize; if (attr) { - update_attr(buf, src, attr, vc); + fbdraw_update_attr(buf, src, attr, &vc->vc_font); src = buf; } @@ -123,7 +103,7 @@ static inline void bit_putcs_unaligned(struct vc_data *vc, charmask)*cellsize; if (attr) { - update_attr(buf, src, attr, vc); + fbdraw_update_attr(buf, src, attr, &vc->vc_font); src = buf; } @@ -275,7 +255,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, return; kfree(ops->cursor_data); ops->cursor_data = dst; - update_attr(dst, src, attribute, vc); + fbdraw_update_attr(dst, src, attribute, &vc->vc_font); src = dst; } diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h index 6bd2e0c..8623bac 100644 --- a/drivers/video/console/fbcon.h +++ b/drivers/video/console/fbcon.h @@ -16,6 +16,7 @@ #include #include +#include "fbdraw.h" #define FBCON_FLAGS_INIT 1 #define FBCON_FLAGS_CURSOR_TIMER 2 @@ -219,10 +220,6 @@ extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info); extern void fbcon_set_bitops(struct fbcon_ops *ops); extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor); -#define FBCON_ATTRIBUTE_UNDERLINE 1 -#define FBCON_ATTRIBUTE_REVERSE 2 -#define FBCON_ATTRIBUTE_BOLD 4 - static inline int real_y(struct display *p, int ypos) { int rows = p->vrows; diff --git a/drivers/video/console/fbdraw.c b/drivers/video/console/fbdraw.c new file mode 100644 index 0000000..65e7003 --- /dev/null +++ b/drivers/video/console/fbdraw.c @@ -0,0 +1,46 @@ +/* + * Framebuffer helpers for image draw-operations + * + * Copyright (c) 2004 Antonino Daplas + * Copyright (c) 2012 David Herrmann + * + * Originally from drivers/video/console/bitblit.c which itself originally is + * from the 'accel_*' routines in drivers/video/console/fbcon.c. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive for + * more details. + */ + +#include +#include +#include +#include +#include +#include "fbdraw.h" + +void fbdraw_update_attr(u8 *dst, const u8 *src, int attribute, + struct console_font *font) +{ + int i, offset = (font->height < 10) ? 1 : 2; + int width = DIV_ROUND_UP(font->width, 8); + unsigned int cellsize = font->height * width; + u8 c; + + offset = cellsize - (offset * width); + for (i = 0; i < cellsize; i++) { + c = src[i]; + if (attribute & FBCON_ATTRIBUTE_UNDERLINE && i >= offset) + c = 0xff; + if (attribute & FBCON_ATTRIBUTE_BOLD) + c |= c >> 1; + if (attribute & FBCON_ATTRIBUTE_REVERSE) + c = ~c; + dst[i] = c; + } +} +EXPORT_SYMBOL(fbdraw_update_attr); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("David Herrmann "); +MODULE_DESCRIPTION("Framebuffer helpers for image draw-operations"); diff --git a/drivers/video/console/fbdraw.h b/drivers/video/console/fbdraw.h new file mode 100644 index 0000000..77edd7f --- /dev/null +++ b/drivers/video/console/fbdraw.h @@ -0,0 +1,26 @@ +/* + * Framebuffer helpers for image draw-operations + * + * Copyright (c) 2012 David Herrmann + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive for + * more details. + */ + +#ifndef _VIDEO_FBDRAW_H +#define _VIDEO_FBDRAW_H + +#include +#include +#include + +/* fbcon character attributes */ +#define FBCON_ATTRIBUTE_UNDERLINE 1 +#define FBCON_ATTRIBUTE_REVERSE 2 +#define FBCON_ATTRIBUTE_BOLD 4 + +void fbdraw_update_attr(u8 *dst, const u8 *src, int attribute, + struct console_font *font); + +#endif /* _VIDEO_FBDRAW_H */