From 07e982df8a0e3a72a357839ec0a6ff7d462bd173 Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Thu, 8 Jan 2009 02:49:23 +0000 Subject: cleanup for core-file-in-pluginlib compilation: wrapper C files in pluginlib renamed to the same name as the core files they wrap pluginlib-only init functions for resize and bmp moved into the wrapper files, and declared in the associated header files API() macro removed entirely, in favor of a core-only header file that redefines core function names to use a plugin_api pointer some unnecessary uses of PLUGIN in apps/recorder/bmp.c removed git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19712 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/lib/SOURCES | 5 +--- apps/plugins/lib/bmp.c | 15 +++++++++++ apps/plugins/lib/bmp.h | 5 ++++ apps/plugins/lib/core_bmp.c | 24 ----------------- apps/plugins/lib/core_resize.c | 24 ----------------- apps/plugins/lib/resize.c | 34 ++++++++++++++++++++++++ apps/plugins/lib/resize.h | 31 ++++++++++++++++++++++ apps/plugins/lib/wrappers.h | 44 ++++++++++++++++++++++++++++++++ apps/plugins/test_greylib_bitmap_scale.c | 2 ++ apps/recorder/bmp.c | 34 +++++++----------------- apps/recorder/bmp.h | 7 +---- apps/recorder/resize.c | 31 +++++++--------------- apps/recorder/resize.h | 5 ---- 13 files changed, 151 insertions(+), 110 deletions(-) delete mode 100644 apps/plugins/lib/core_bmp.c delete mode 100644 apps/plugins/lib/core_resize.c create mode 100644 apps/plugins/lib/resize.c create mode 100644 apps/plugins/lib/resize.h create mode 100644 apps/plugins/lib/wrappers.h diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index c8c1553dc8..b28878cffc 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES @@ -5,8 +5,7 @@ playback_control.c rgb_hsv.c #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) #if LCD_DEPTH == 1 -core_bmp.c -core_resize.c +resize.c #endif grey_core.c grey_draw.c @@ -34,9 +33,7 @@ picture.c xlcd_core.c xlcd_draw.c xlcd_scroll.c -#if LCD_DEPTH>1 bmp.c -#endif #ifdef HAVE_LCD_COLOR bmp_smooth_scale.c #endif diff --git a/apps/plugins/lib/bmp.c b/apps/plugins/lib/bmp.c index a8ebbffc27..b3e0e2b948 100644 --- a/apps/plugins/lib/bmp.c +++ b/apps/plugins/lib/bmp.c @@ -8,6 +8,7 @@ * $Id$ * * Copyright (C) 2006 by Antoine Cellerier + * Copyright (C) 2009 by Andrew Mahone * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,6 +27,7 @@ #include "lcd.h" #include "system.h" +#if LCD_DEPTH > 1 #ifdef HAVE_LCD_COLOR #define LE16(x) (htole16(x))&0xff, ((htole16(x))>>8)&0xff #define LE32(x) (htole32(x))&0xff, ((htole32(x))>>8)&0xff, ((htole32(x))>>16)&0xff, ((htole32(x))>>24)&0xff @@ -119,3 +121,16 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) yr += yrstep; } } + +#else +#include "wrappers.h" + +static const struct plugin_api *rb; + +#include "../../recorder/bmp.c" + +void bmp_init(const struct plugin_api *api) +{ + rb = api; +} +#endif diff --git a/apps/plugins/lib/bmp.h b/apps/plugins/lib/bmp.h index 12894f7551..379a889994 100644 --- a/apps/plugins/lib/bmp.h +++ b/apps/plugins/lib/bmp.h @@ -24,6 +24,7 @@ #include "lcd.h" #include "plugin.h" +#if LCD_DEPTH > 1 #ifdef HAVE_LCD_COLOR /** * Save bitmap to file @@ -43,4 +44,8 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst); */ void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst); +#else +void bmp_init(const struct plugin_api *api); +#endif + #endif diff --git a/apps/plugins/lib/core_bmp.c b/apps/plugins/lib/core_bmp.c deleted file mode 100644 index 28d70b1bb8..0000000000 --- a/apps/plugins/lib/core_bmp.c +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** -* __________ __ ___. -* Open \______ \ ____ ____ | | _\_ |__ _______ ___ -* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -* \/ \/ \/ \/ \/ -* $Id$ -* -* This is a wrapper for the core bmp.c -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY -* KIND, either express or implied. -* -****************************************************************************/ - -#include -#include "../../recorder/bmp.c" - diff --git a/apps/plugins/lib/core_resize.c b/apps/plugins/lib/core_resize.c deleted file mode 100644 index 099d4079ed..0000000000 --- a/apps/plugins/lib/core_resize.c +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** -* __________ __ ___. -* Open \______ \ ____ ____ | | _\_ |__ _______ ___ -* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -* \/ \/ \/ \/ \/ -* $Id$ -* -* This is a wrapper for the core bmp.c -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY -* KIND, either express or implied. -* -****************************************************************************/ - -#include -#include "../../recorder/resize.c" - diff --git a/apps/plugins/lib/resize.c b/apps/plugins/lib/resize.c new file mode 100644 index 0000000000..28446e75a7 --- /dev/null +++ b/apps/plugins/lib/resize.c @@ -0,0 +1,34 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2009 by Andrew Mahone +* +* This is a wrapper for the core resize.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ + +#include +#include "wrappers.h" + +static const struct plugin_api *rb; + +#include "../../recorder/resize.c" + +void resize_init(const struct plugin_api *api) +{ + rb = api; +} diff --git a/apps/plugins/lib/resize.h b/apps/plugins/lib/resize.h new file mode 100644 index 0000000000..3674e140c3 --- /dev/null +++ b/apps/plugins/lib/resize.h @@ -0,0 +1,31 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2009 by Andrew Mahone +* +* This is a header for the pluginlib extensions to the core resize.c file +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ + +#ifndef _LIB_RESIZE_H_ +#define _LIB_RESIZE_H_ + +#if LCD_DEPTH == 1 +void resize_init(const struct plugin_api *api); +#endif + +#endif diff --git a/apps/plugins/lib/wrappers.h b/apps/plugins/lib/wrappers.h new file mode 100644 index 0000000000..2eb4ea025e --- /dev/null +++ b/apps/plugins/lib/wrappers.h @@ -0,0 +1,44 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2009 by Andrew Mahone +* +* This header redefines some core functions as calls via the plugin_api, to +* allow easy compilation of core source files in the pluginlib with different +* features from the version built for the core, or when a core object file is +* not built for a particular target. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ + +#ifndef _LIB_WRAPPERS_H_ +#define _LIB_WRAPPERS_H_ + +#define open rb->open +#define close rb->close +#define read rb->read +#define lseek rb->lseek +#define memset rb->memset +#ifdef HAVE_ADJUSTABLE_CPU_FREQ +#define cpu_boost rb->cpu_boost +#endif +#define yield rb->yield +#if CONFIG_CODEC == SWCODEC +#define align_buffer rb->align_buffer +#endif + +#endif + diff --git a/apps/plugins/test_greylib_bitmap_scale.c b/apps/plugins/test_greylib_bitmap_scale.c index 3d6f81f91e..a3de006e05 100644 --- a/apps/plugins/test_greylib_bitmap_scale.c +++ b/apps/plugins/test_greylib_bitmap_scale.c @@ -21,6 +21,8 @@ #include "plugin.h" #include "lib/grey.h" +#include "lib/resize.h" +#include "lib/bmp.h" #if LCD_DEPTH == 1 #define BMP_LOAD read_bmp_file diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index 01b57d2116..d6d836a6c5 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c @@ -72,19 +72,6 @@ #pragma pack (push, 2) #endif -#ifndef PLUGIN -#define API(x) x -#else -#define API(x) rb->x - -static const struct plugin_api *rb; - -void bmp_init(const struct plugin_api * api) -{ - rb = api; -} -#endif - /* BMP header structure */ struct bmp_header { uint16_t type; /* signature - 'BM' */ @@ -137,15 +124,13 @@ static const struct uint8_rgb bitfields[3][3] = { }, }; -#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) || \ - defined(PLUGIN) +#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) /* the full 16x16 Bayer dither matrix may be calculated quickly with this table */ const unsigned char dither_table[16] = { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }; #endif -#ifndef PLUGIN #if ((LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)) \ || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH == 2) \ && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED)) @@ -153,7 +138,6 @@ const unsigned short vi_pattern[4] = { 0x0101, 0x0100, 0x0001, 0x0000 }; #endif -#endif /****************************************************************************** * read_bmp_file() @@ -168,7 +152,7 @@ int read_bmp_file(const char* filename, const struct custom_format *cformat) { int fd, ret; - fd = API(open)(filename, O_RDONLY); + fd = open(filename, O_RDONLY); /* Exit if file opening failed */ if (fd < 0) { @@ -180,7 +164,7 @@ int read_bmp_file(const char* filename, filename, !!(format & FORMAT_REMOTE), !!(format & FORMAT_RESIZE), !!(format & FORMAT_KEEP_ASPECT)); ret = read_bmp_fd(fd, bm, maxsize, format, cformat); - API(close)(fd); + close(fd); return ret; } @@ -237,7 +221,7 @@ static unsigned int read_part_line(struct bmp_args *ba) #endif ibuf = ((unsigned char *)buf) + (BM_MAX_WIDTH << 2) - len; BDEBUGF("read_part_line: cols=%d len=%d\n",cols,len); - ret = API(read)(fd, ibuf, len); + ret = read(fd, ibuf, len); if (ret != len) { DEBUGF("read_part_line: error reading image, read returned %d " @@ -324,7 +308,7 @@ static unsigned int read_part_line(struct bmp_args *ba) if (pad > 0) { BDEBUGF("seeking %d bytes to next line\n",pad); - API(lseek)(fd, pad, SEEK_CUR); + lseek(fd, pad, SEEK_CUR); } #if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ defined(PLUGIN) @@ -422,7 +406,7 @@ int read_bmp_fd(int fd, #endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/ /* read fileheader */ - ret = API(read)(fd, &bmph, sizeof(struct bmp_header)); + ret = read(fd, &bmph, sizeof(struct bmp_header)); if (ret < 0) { return ret * 10 - 2; } @@ -531,7 +515,7 @@ int read_bmp_fd(int fd, int i; union rgb_union pal; for (i = 0; i < numcolors; i++) { - if (API(read)(fd, &pal, sizeof(pal)) != (int)sizeof(pal)) + if (read(fd, &pal, sizeof(pal)) != (int)sizeof(pal)) { DEBUGF("read_bmp_fd: Can't read color palette\n"); return -7; @@ -589,9 +573,9 @@ int read_bmp_fd(int fd, } /* Search to the beginning of the image data */ - API(lseek)(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET); + lseek(fd, (off_t)letoh32(bmph.off_bits), SEEK_SET); - API(memset)(bitmap, 0, totalsize); + memset(bitmap, 0, totalsize); struct bmp_args ba = { .fd = fd, .padded_width = padded_width, .read_width = read_width, diff --git a/apps/recorder/bmp.h b/apps/recorder/bmp.h index 946bc6f8b8..c570a3d6bd 100644 --- a/apps/recorder/bmp.h +++ b/apps/recorder/bmp.h @@ -52,8 +52,7 @@ struct rowset { short rowstop; }; -#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) || \ - defined(PLUGIN) +#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) extern const unsigned char dither_table[16]; #define DITHERY(y) (dither_table[(y) & 15] & 0xAA) #define DITHERX(x) (dither_table[(x) & 15]) @@ -212,9 +211,5 @@ int read_bmp_fd(int fd, int maxsize, int format, const struct custom_format *cformat); -#ifdef PLUGIN -struct plugin_api; -void bmp_init(const struct plugin_api * api); -#endif #endif diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c index 6e5e9c4efb..99ccc84d55 100644 --- a/apps/recorder/resize.c +++ b/apps/recorder/resize.c @@ -59,19 +59,6 @@ #define DEBUGF(...) #endif -#ifndef PLUGIN -#define API(x) x -#else -#define API(x) rb->x - -static const struct plugin_api *rb; - -void resize_init(const struct plugin_api *api) -{ - rb = api; -} -#endif - /* calculate the maximum dimensions which will preserve the aspect ration of src while fitting in the constraints passed in dst, and store result in dst, returning 0 if rounding and 1 if not rounding. @@ -154,7 +141,7 @@ static bool scale_h_area(void *out_line_ptr, oxe = 0; mul = 0; /* give other tasks a chance to run */ - API(yield)(); + yield(); for (ix = 0; ix < (unsigned int)ctx->src->width; ix++) { oxe += ctx->bm->width; @@ -257,11 +244,11 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx) #ifdef HAVE_LCD_COLOR uint32_t *rowacc = (uint32_t *) ctx->buf, *rowtmp = rowacc + 3 * ctx->bm->width; - API(memset)((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(struct uint32_rgb)); + memset((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(struct uint32_rgb)); #else uint32_t *rowacc = (uint32_t *) ctx->buf, *rowtmp = rowacc + ctx->bm->width; - API(memset)((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(uint32_t)); + memset((void *)ctx->buf, 0, ctx->bm->width * 2 * sizeof(uint32_t)); #endif SDEBUGF("scale_v_area\n"); /* zero the accumulator and temp rows */ @@ -298,9 +285,9 @@ static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx) ctx->output_row(oy, (void*)rowacc, ctx); /* clear accumulator row, store partial coverage for next row */ #ifdef HAVE_LCD_COLOR - API(memset)((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t) * 3); + memset((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t) * 3); #else - API(memset)((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t)); + memset((void *)rowacc, 0, ctx->bm->width * sizeof(uint32_t)); #endif mul = oye; oy += rset->rowstep; @@ -346,7 +333,7 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, /* The error is set so that values are initialized on the first pass. */ ixe = ctx->bm->width - 1; /* give other tasks a chance to run */ - API(yield)(); + yield(); for (ox = 0; ox < (uint32_t)ctx->bm->width; ox++) { #ifdef HAVE_LCD_COLOR @@ -630,7 +617,7 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, 0 : needed]; #endif #if CONFIG_CODEC == SWCODEC - len = (unsigned int)API(align_buffer)(PUN_PTR(void**, &buf), len, + len = (unsigned int)align_buffer(PUN_PTR(void**, &buf), len, sizeof(uint32_t)); #endif if (needed > len) @@ -659,7 +646,7 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, struct scaler_context ctx; #ifdef HAVE_ADJUSTABLE_CPU_FREQ - API(cpu_boost)(true); + cpu_boost(true); #endif ctx.store_part = store_part; ctx.args = args; @@ -698,7 +685,7 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, ret = scale_v_linear(rset, &ctx); #endif #ifdef HAVE_ADJUSTABLE_CPU_FREQ - API(cpu_boost)(false); + cpu_boost(false); #endif if (!ret) return 0; diff --git a/apps/recorder/resize.h b/apps/recorder/resize.h index 9b52a7aa65..f8328e3f3d 100644 --- a/apps/recorder/resize.h +++ b/apps/recorder/resize.h @@ -95,9 +95,4 @@ int resize_on_load(struct bitmap *bm, bool dither, struct img_part* (*store_part)(void *args), void *args); -#ifdef PLUGIN -struct plugin_api; -void resize_init(const struct plugin_api *api); -#endif - #endif /* _RESIZE_H_ */ -- cgit v1.2.3