2008-01-04 23:42:38 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* New greyscale framework
|
|
|
|
*
|
|
|
|
* This is a generic framework to display 129 shades of grey on low-depth
|
|
|
|
* bitmap LCDs (Archos b&w, Iriver & Ipod 4-grey) within plugins.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Jens Arnold
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* 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.
|
2008-01-04 23:42:38 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GREY_H__
|
|
|
|
#define __GREY_H__
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
2020-07-17 14:31:31 +00:00
|
|
|
#if (LCD_DEPTH < 4)
|
2008-01-04 23:42:38 +00:00
|
|
|
|
2008-03-02 23:31:09 +00:00
|
|
|
/* The greyscale lib uses 8 bit brightness values natively on input. */
|
2008-01-04 23:42:38 +00:00
|
|
|
#define GREY_BRIGHTNESS(y) (y)
|
|
|
|
|
2008-03-02 23:31:09 +00:00
|
|
|
/* Some predefined levels for convenience: */
|
2008-01-04 23:42:38 +00:00
|
|
|
#define GREY_BLACK GREY_BRIGHTNESS(0)
|
|
|
|
#define GREY_DARKGRAY GREY_BRIGHTNESS(85)
|
|
|
|
#define GREY_LIGHTGRAY GREY_BRIGHTNESS(170)
|
|
|
|
#define GREY_WHITE GREY_BRIGHTNESS(255)
|
|
|
|
|
2008-01-13 00:11:43 +00:00
|
|
|
/* Greyscale library management structure declaration. You need one of these
|
|
|
|
* in every plugin using the library, depending on whether the structure should
|
|
|
|
* use IRAM or not. */
|
2008-04-06 13:59:31 +00:00
|
|
|
#define GREY_INFO_STRUCT struct _grey_info _grey_info SHAREDBSS_ATTR;
|
2008-01-13 00:11:43 +00:00
|
|
|
#define GREY_INFO_STRUCT_IRAM struct _grey_info _grey_info IBSS_ATTR;
|
|
|
|
|
2008-03-02 23:31:09 +00:00
|
|
|
/* Features you can request on library init (ORed together): */
|
2008-04-04 22:13:53 +00:00
|
|
|
#define GREY_BUFFERED 0x0001 /* Use a chunky buffer */
|
|
|
|
#define GREY_RAWMAPPED 0x0002 /* No gamma & LCD linearisation */
|
|
|
|
#define GREY_ON_COP 0x0004 /* Run ISR on COP (PP targets) */
|
2008-03-02 23:31:09 +00:00
|
|
|
|
2008-01-04 23:42:38 +00:00
|
|
|
/* Library initialisation and release */
|
2009-01-16 10:34:40 +00:00
|
|
|
bool grey_init(unsigned char *gbuf, long gbuf_size,
|
2008-03-02 23:31:09 +00:00
|
|
|
unsigned features, int width, int height, long *buf_taken);
|
2008-01-04 23:42:38 +00:00
|
|
|
void grey_release(void);
|
|
|
|
|
|
|
|
/* Special functions */
|
|
|
|
void grey_show(bool enable);
|
|
|
|
void grey_deferred_lcd_update(void);
|
|
|
|
|
2012-12-07 06:50:52 +00:00
|
|
|
/* Viewports and framebuffers */
|
|
|
|
void grey_clear_viewport(void);
|
2020-10-07 06:01:35 +00:00
|
|
|
struct viewport *grey_set_viewport(struct viewport *vp);
|
2012-12-07 06:50:52 +00:00
|
|
|
void grey_viewport_set_fullscreen(struct viewport *vp,
|
|
|
|
const enum screen_type screen);
|
|
|
|
void grey_viewport_set_pos(struct viewport *vp,
|
|
|
|
int x, int y, int width, int height);
|
|
|
|
void grey_set_framebuffer(unsigned char *buffer);
|
|
|
|
void grey_framebuffer_set_pos(int x, int y, int width, int height);
|
|
|
|
|
2008-01-04 23:42:38 +00:00
|
|
|
/* Update functions */
|
|
|
|
void grey_update(void);
|
|
|
|
void grey_update_rect(int x, int y, int width, int height);
|
|
|
|
|
|
|
|
/* Parameter handling */
|
|
|
|
void grey_set_position(int x, int y);
|
|
|
|
void grey_set_drawmode(int mode);
|
|
|
|
int grey_get_drawmode(void);
|
|
|
|
void grey_set_foreground(unsigned brightness);
|
|
|
|
unsigned grey_get_foreground(void);
|
|
|
|
void grey_set_background(unsigned brightness);
|
|
|
|
unsigned grey_get_background(void);
|
|
|
|
void grey_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness);
|
|
|
|
void grey_setfont(int newfont);
|
|
|
|
int grey_getstringsize(const unsigned char *str, int *w, int *h);
|
|
|
|
|
|
|
|
/* Whole display */
|
|
|
|
void grey_clear_display(void);
|
|
|
|
void grey_ub_clear_display(void);
|
|
|
|
|
|
|
|
/* Pixel */
|
|
|
|
void grey_drawpixel(int x, int y);
|
|
|
|
|
|
|
|
/* Lines */
|
|
|
|
void grey_drawline(int x1, int y1, int x2, int y2);
|
|
|
|
void grey_hline(int x1, int x2, int y);
|
|
|
|
void grey_vline(int x, int y1, int y2);
|
|
|
|
void grey_drawrect(int x, int y, int nx, int ny);
|
|
|
|
|
|
|
|
/* Filled primitives */
|
|
|
|
void grey_fillrect(int x, int y, int nx, int ny);
|
|
|
|
void grey_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3);
|
|
|
|
|
|
|
|
/* Bitmaps */
|
|
|
|
void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|
|
|
int stride, int x, int y, int width, int height);
|
|
|
|
void grey_mono_bitmap(const unsigned char *src, int x, int y, int width,
|
|
|
|
int height);
|
|
|
|
void grey_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|
|
|
int stride, int x, int y, int width, int height);
|
|
|
|
void grey_gray_bitmap(const unsigned char *src, int x, int y, int width,
|
|
|
|
int height);
|
|
|
|
void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|
|
|
int stride, int x, int y, int width, int height);
|
|
|
|
void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width,
|
|
|
|
int height);
|
2008-12-26 07:05:13 +00:00
|
|
|
extern const struct custom_format format_grey;
|
2008-01-04 23:42:38 +00:00
|
|
|
|
|
|
|
/* Text */
|
|
|
|
void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str);
|
|
|
|
void grey_putsxy(int x, int y, const unsigned char *str);
|
|
|
|
|
|
|
|
/* Scrolling */
|
|
|
|
void grey_scroll_left(int count);
|
|
|
|
void grey_scroll_right(int count);
|
|
|
|
void grey_scroll_up(int count);
|
|
|
|
void grey_scroll_down(int count);
|
|
|
|
void grey_ub_scroll_left(int count);
|
|
|
|
void grey_ub_scroll_right(int count);
|
|
|
|
void grey_ub_scroll_up(int count);
|
|
|
|
void grey_ub_scroll_down(int count);
|
|
|
|
|
|
|
|
/*** Internal stuff ***/
|
|
|
|
|
2008-04-02 22:16:14 +00:00
|
|
|
/* standard gamma (s23p8) */
|
|
|
|
#ifdef SIMULATOR /* Standard PC gamma */
|
|
|
|
#define _GREY_GAMMA ((200<<8)/100)
|
|
|
|
#else /* Target LCDs have a smaller contrast range */
|
|
|
|
#define _GREY_GAMMA ((180<<8)/100)
|
|
|
|
#endif
|
|
|
|
|
2008-01-04 23:42:38 +00:00
|
|
|
/* flag definitions */
|
2008-04-02 22:16:14 +00:00
|
|
|
#define _GREY_RUNNING 0x8000 /* greyscale overlay is running */
|
|
|
|
#define _GREY_DEFERRED_UPDATE 0x4000 /* lcd_update() requested */
|
2008-04-04 19:14:19 +00:00
|
|
|
#define _GREY_BACKLIGHT_ON 0x2000 /* backlight is active - only used on 1st+2nd Gen */
|
2008-01-04 23:42:38 +00:00
|
|
|
|
|
|
|
/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit,
|
|
|
|
* whichever is faster for the architecture) */
|
|
|
|
#ifdef CPU_ARM
|
|
|
|
#define _GREY_MULUQ(a, b) ((uint32_t) (((uint32_t) (a)) * ((uint32_t) (b))))
|
|
|
|
#else
|
|
|
|
#define _GREY_MULUQ(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b))))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
2008-01-10 22:51:33 +00:00
|
|
|
#define _GREY_BSHIFT 0
|
2008-03-25 23:21:36 +00:00
|
|
|
#else /* vertical packing or vertical interleaved */
|
|
|
|
#if (LCD_DEPTH == 1) || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
2008-01-10 22:51:33 +00:00
|
|
|
#define _GREY_BSHIFT 3
|
2008-01-04 23:42:38 +00:00
|
|
|
#elif LCD_DEPTH == 2
|
2008-01-10 22:51:33 +00:00
|
|
|
#define _GREY_BSHIFT 2
|
2008-01-04 23:42:38 +00:00
|
|
|
#endif
|
|
|
|
#endif /* LCD_PIXELFORMAT */
|
|
|
|
|
2008-01-10 22:51:33 +00:00
|
|
|
#define _GREY_BSIZE (1<<_GREY_BSHIFT)
|
|
|
|
#define _GREY_BMASK (_GREY_BSIZE-1)
|
|
|
|
|
2008-01-04 23:42:38 +00:00
|
|
|
/* The greyscale buffer management structure */
|
|
|
|
struct _grey_info
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
|
|
|
int bx; /* 8-pixel units */
|
|
|
|
int bwidth; /* 8-pixel units */
|
2008-03-25 23:21:36 +00:00
|
|
|
#else /* vertical packing or vertical interleaved */
|
2008-01-04 23:42:38 +00:00
|
|
|
int by; /* 4-pixel or 8-pixel units */
|
|
|
|
int bheight; /* 4-pixel or 8-pixel units */
|
|
|
|
#endif
|
2008-05-13 09:57:56 +00:00
|
|
|
unsigned long flags; /* various flags, see #defines */
|
|
|
|
unsigned char *values; /* start of greyscale pixel values */
|
|
|
|
unsigned char *phases; /* start of greyscale pixel phases */
|
|
|
|
unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */
|
2012-12-07 06:50:52 +00:00
|
|
|
unsigned char *curbuffer; /* start of current framebuffer (for buffered mode) */
|
|
|
|
int cb_x; /* horizontal position of current framebuffer (for buffered mode) */
|
|
|
|
int cb_y; /* vertical position of current framebuffer (for buffered mode) */
|
|
|
|
int cb_width; /* width of current framebuffer (for buffered mode) */
|
|
|
|
int cb_height; /* height of current framebuffer (for buffered mode) */
|
|
|
|
int clip_l;
|
|
|
|
int clip_t;
|
|
|
|
int clip_r;
|
|
|
|
int clip_b;
|
2008-05-13 09:57:56 +00:00
|
|
|
unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */
|
2012-12-07 06:50:52 +00:00
|
|
|
struct viewport *vp; /* current viewport in use */
|
2008-01-04 23:42:38 +00:00
|
|
|
};
|
|
|
|
|
2008-01-13 00:11:43 +00:00
|
|
|
/* Global variable, defined in the plugin */
|
2008-01-04 23:42:38 +00:00
|
|
|
extern struct _grey_info _grey_info;
|
|
|
|
|
2020-07-17 14:31:31 +00:00
|
|
|
#endif /* (LCD_DEPTH < 4) */
|
2008-01-04 23:42:38 +00:00
|
|
|
#endif /* __GREY_H__ */
|