>From 68c45e7de6f69b5af3a1918ebfe7dbd80bfffecf Mon Sep 17 00:00:00 2001 From: kui zheng <kui.zh...@arm.com> Date: Wed, 16 Nov 2011 15:18:29 +0800 Subject: [PATCH] generic: Add NEON version of Sop_rgb16_to_Dacc.
Signed-off-by: kui zheng <kui.zh...@arm.com> --- src/gfx/generic/Makefile.am | 1 + src/gfx/generic/generic.c | 6 ++- src/gfx/generic/generic_neon.h | 109 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 1 deletions(-) create mode 100644 src/gfx/generic/generic_neon.h diff --git a/src/gfx/generic/Makefile.am b/src/gfx/generic/Makefile.am index 227718c..51b96fb 100644 --- a/src/gfx/generic/Makefile.am +++ b/src/gfx/generic/Makefile.am @@ -29,6 +29,7 @@ libdirectfb_generic_la_SOURCES = \ $(GENERIC_C) \ generic.h \ generic_mmx.h \ + generic_neon.h \ generic_64.h \ generic_fill_rectangle.c \ generic_draw_line.c \ diff --git a/src/gfx/generic/generic.c b/src/gfx/generic/generic.c index 1a4f73d..4938d56 100644 --- a/src/gfx/generic/generic.c +++ b/src/gfx/generic/generic.c @@ -67,6 +67,9 @@ #include "generic.h" #include "duffs_device.h" +#ifdef USE_NEON +#include "generic_neon.h" +#endif /* lookup tables for 2/3bit to 8bit color conversion */ static const u8 lookup3to8[] = { 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff}; @@ -9650,7 +9653,8 @@ static void gInit_MMX( void ) static void gInit_NEON( void ) { use_neon = 1; - /* to be added */ +/********************************* Sop_PFI_to_Dacc ****************************/ + Sop_PFI_to_Dacc[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)] = Sop_rgb16_to_Dacc_NEON; } #endif diff --git a/src/gfx/generic/generic_neon.h b/src/gfx/generic/generic_neon.h new file mode 100644 index 0000000..83b2a35 --- /dev/null +++ b/src/gfx/generic/generic_neon.h @@ -0,0 +1,109 @@ +/* + Copyright (c) 2011 ARM Ltd. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Author: Kui Zheng <kui.zh...@arm.com> + +*/ + +#include <gfx/convert.h> + +#define RGB32_TO_RGB16(pixel) ( (((pixel) & 0xF80000) >> 8) | \ + (((pixel) & 0x00FC00) >> 5) | \ + (((pixel) & 0x0000F8) >> 3) ) + +#define RGB16_EXPAND_5to8(v) (((v) << 3) | ((v) >> 2)) +#define RGB16_EXPAND_6to8(v) (((v) << 2) | ((v) >> 4)) + +#define RGB16_EXPAND_Ato8( a ) 0xFF +#define RGB16_EXPAND_Rto8( r ) RGB16_EXPAND_5to8( r ) +#define RGB16_EXPAND_Gto8( g ) RGB16_EXPAND_6to8( g ) +#define RGB16_EXPAND_Bto8( b ) RGB16_EXPAND_5to8( b ) +#define RGB16_A_SHIFT 0 +#define RGB16_R_SHIFT 11 +#define RGB16_G_SHIFT 5 +#define RGB16_B_SHIFT 0 +#define RGB16_A_MASK 0 +#define RGB16_R_MASK 0xf800 +#define RGB16_G_MASK 0x07e0 +#define RGB16_B_MASK 0x001f + +#define RGB16_EXPAND( d, s ) do { \ + (d).RGB.a = RGB16_EXPAND_Ato8( (s & RGB16_A_MASK) >> RGB16_A_SHIFT ); \ + (d).RGB.r = RGB16_EXPAND_Rto8( (s & RGB16_R_MASK) >> RGB16_R_SHIFT ); \ + (d).RGB.g = RGB16_EXPAND_Gto8( (s & RGB16_G_MASK) >> RGB16_G_SHIFT ); \ + (d).RGB.b = RGB16_EXPAND_Bto8( (s & RGB16_B_MASK) >> RGB16_B_SHIFT ); \ +} while (0) + +/* + * NEON verion of Sop_rgb16_to_Dacc. + */ +static void Sop_rgb16_to_Dacc_NEON( GenefxState *gfxs ) +{ + int l = gfxs->length; + u16 *S = gfxs->Sop[0]; + GenefxAccumulator *D = gfxs->Dacc; + int Ostep = gfxs->Ostep; + unsigned int loop = l >> 3; + unsigned int single = l & 0x7; + u16 s; + + if (Ostep != 1) { + while (l--) { + s = *S; + RGB16_EXPAND( *D, s ); + S += Ostep; + D++; + } + return; + } + while (single) { + s = *S; + RGB16_EXPAND( *D, s ); + S++; + D++; + single--; + } + if (loop) { + __asm__ __volatile__ ( + "1: \n\t" + "pld [%[S], #0xC0] \n\t" + "vld1.16 {q0}, [%[S]]! \n\t" + "vmov.i16 q4, #0x00FF \n\t" + "vshr.u16 q3, q0, #8 \n\t" + "vsri.u8 q3, q3, #5 \n\t" + + "vshl.u16 q2, q0, #5 \n\t" + "vshl.u16 q1, q0, #11 \n\t" + "vshr.u16 q2, q2, #8 \n\t" + "vshr.u16 q1, q1, #8 \n\t" + "vsri.u8 q2, q2, #6 \n\t" + "vsri.u8 q1, q1, #5 \n\t" + + "vst4.16 {d2, d4, d6, d8}, [%[D]]! \n\t" + "vst4.16 {d3, d5, d7, d9}, [%[D]]! \n\t" + "subs %[loop], %[loop], #1 \n\t" + "bne 1b " + : + : [S] "r" (S), [D] "r" (D), [loop] "r" (loop) + : "memory", "d0", "d1", "d2", "d3", "d4", + "d5", "d6", "d7", "d8", "d9" + ); + } + +} + -- 1.7.1 -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
0002-generic-Add-NEON-version-of-Sop_rgb16_to_Dacc.patch
Description: 0002-generic-Add-NEON-version-of-Sop_rgb16_to_Dacc.patch
_______________________________________________ directfb-dev mailing list directfb-dev@directfb.org http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev