/* $Id$ * $URL$ * * generic driver helper for graphic displays * * Copyright (C) 1999, 2000 Michael Reinelt * Copyright (C) 2004 The LCD4Linux Team * * This file is part of LCD4Linux. * * LCD4Linux 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, or (at your option) * any later version. * * LCD4Linux 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * * exported functions: * * int drv_generic_graphic_init (char *section, char *driver); * initializes the generic graphic driver * * int drv_generic_graphic_draw (WIDGET *W); * renders Text widget into framebuffer * calls drv_generic_graphic_real_blit() * * int drv_generic_graphic_icon_draw (WIDGET *W); * renders Icon widget into framebuffer * calls drv_generic_graphic_real_blit() * * int drv_generic_graphic_bar_draw (WIDGET *W); * renders Bar widget into framebuffer * calls drv_generic_graphic_real_blit() * * int drv_generic_graphic_quit (void); * closes generic graphic driver * */ #include "config.h" #include #include #include #include #include #include #include #include "debug.h" #include "cfg.h" #include "plugin.h" #include "layout.h" #include "widget.h" #include "property.h" #include "widget_text.h" #include "widget_icon.h" #include "widget_bar.h" #include "widget_image.h" #include "rgb.h" #include "drv.h" #include "drv_generic.h" #include "drv_generic_graphic.h" #include "font_6x8.h" #include "font_6x8_bold.h" #ifdef WITH_DMALLOC #include #endif /* pixel colors */ RGBA FG_COL = {.R = 0x00,.G = 0x00,.B = 0x00,.A = 0xff }; RGBA BG_COL = {.R = 0xff,.G = 0xff,.B = 0xff,.A = 0xff }; RGBA BL_COL = {.R = 0xff,.G = 0xff,.B = 0xff,.A = 0x00 }; RGBA NO_COL = {.R = 0x00,.G = 0x00,.B = 0x00,.A = 0x00 }; static char *Section = NULL; static char *Driver = NULL; /* framebuffer */ static RGBA *drv_generic_graphic_FB[LAYERS] = { NULL, }; /* inverted colors */ static int INVERTED = 0; /* must be implemented by the real driver */ void (*drv_generic_graphic_real_blit) () = NULL; /****************************************/ /*** generic Framebuffer stuff ***/ /****************************************/ static void drv_generic_graphic_resizeFB(int rows, int cols) { RGBA *newFB; int i, l, row, col; /* Layout FB is large enough */ if (rows <= LROWS && cols <= LCOLS) return; /* get maximum values */ if (rows < LROWS) rows = LROWS; if (cols < LCOLS) cols = LCOLS; for (l = 0; l < LAYERS; l++) { /* allocate and initialize new Layout FB */ newFB = malloc(cols * rows * sizeof(*newFB)); for (i = 0; i < rows * cols; i++) newFB[i] = (l == 0) ? BG_COL : NO_COL; /* transfer contents */ if (drv_generic_graphic_FB[l] != NULL) { for (row = 0; row < LROWS; row++) { for (col = 0; col < LCOLS; col++) { newFB[row * cols + col] = drv_generic_graphic_FB[l][row * LCOLS + col]; } } free(drv_generic_graphic_FB[l]); } drv_generic_graphic_FB[l] = newFB; } LCOLS = cols; LROWS = rows; } static void drv_generic_graphic_window(int pos, int size, int max, int *wpos, int *wsize) { int p1 = pos; int p2 = pos + size; *wpos = 0; *wsize = 0; if (p1 > max || p2 < 0 || size < 1) return; if (p1 < 0) p1 = 0; if (p2 > max) p2 = max; *wpos = p1; *wsize = p2 - p1; } static void drv_generic_graphic_blit(const int row, const int col, const int height, const int width) { if (drv_generic_graphic_real_blit) { int r, c, h, w; drv_generic_graphic_window(row, height, DROWS, &r, &h); drv_generic_graphic_window(col, width, DCOLS, &c, &w); if (h > 0 && w > 0) { drv_generic_graphic_real_blit(r, c, h, w); } } } static RGBA drv_generic_graphic_blend(const int row, const int col) { int l; RGBA p; RGBA ret; ret.R = BL_COL.R; ret.G = BL_COL.G; ret.B = BL_COL.B; ret.A = 0xff; fo
# DVB-T frequencies & modulation for the Gold Coast, Australia (Mt Tamborine)
# See http://www.dba.org.au/index.asp?sectionID=22&recLocation=Gold+Coast
# and http://www.dba.org.au/index.asp?sectionID=120
#
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
# ABC (UHF 62)
T 767500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# SBS (UHF 36)
T 585500000 7MHz 2/3 NONE QAM64 8k 1/8 NONE
# Seven (UHF 53)
T 704500000 7MHz 3/4 NONE QAM64 8k 1/8 NONE
# NBN (UHF 68)
T 809500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# Prime (UHF 65)
T 788500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# Southern Cross Ten (UHF 43)
T 634500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# Nine (UHF 59)
T 746500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
# Ten (UHF 56)
T 725500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE
ric_graphic_FB[layer][(row + y) * LCOLS + col + x] = rev ? bg : bcol; else drv_generic_graphic_FB[layer][(row + y) * LCOLS + col + x] = rev ? bcol : bg; if (style) { drv_generic_graphic_FB[layer][(row) * LCOLS + col + x] = fg; drv_generic_graphic_FB[layer][(row + YRES - 1) * LCOLS + col + x] = fg; } } if (style) { drv_generic_graphic_FB[layer][(row + y) * LCOLS + col] = fg; drv_generic_graphic_FB[layer][(row + y) * LCOLS + col + max - 1] = fg; } } break; case DIR_NORTH: val1 = max - val1; val2 = max - val2; rev = 1; case DIR_SOUTH: for (x = 0; x < XRES; x++) { int val = x < XRES / 2 ? val1 : val2; for (y = 0; y < max; y++) { if (y < val) drv_generic_graphic_FB[layer][(row + y) * LCOLS + col + x] = rev ? bg : fg; else drv_generic_graphic_FB[layer][(row + y) * LCOLS + col + x] = rev ? fg : bg; } } break; } /* flush area */ if (dir & (DIR_EAST | DIR_WEST)) { drv_generic_graphic_blit(row, col, YRES, XRES * len); } else { drv_generic_graphic_blit(row, col, YRES * len, XRES); } return 0; } /****************************************/ /*** generic image handling ***/ /****************************************/ int drv_generic_graphic_image_draw(WIDGET * W) { WIDGET_IMAGE *Image = W->data; int layer, row, col, width, height; int x, y; int visible; layer = W->layer; row = W->row; col = W->col; width = Image->width; height = Image->height; /* sanity check */ if (layer < 0 || layer >= LAYERS) { error("%s: layer %d out of bounds (0..%d)", Driver, layer, LAYERS - 1); return -1; } /* if no size or no image at all, do nothing */ if (width <= 0 || height <= 0 || Image->bitmap == NULL) { return 0; } /* maybe grow layout framebuffer */ drv_generic_graphic_resizeFB(row + height, col + width); /* render image */ visible = P2N(&Image->visible); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { int i = (row + y) * LCOLS + col + x; if (visible) { drv_generic_graphic_FB[layer][i] = Image->bitmap[y * width + x]; } else { drv_generic_graphic_FB[layer][i] = BG_COL; } } } /* flush area */ drv_generic_graphic_blit(row, col, height, width); return 0; } /****************************************/ /*** generic init/quit ***/ /****************************************/ int drv_generic_graphic_init(const char *section, const char *driver) { int l; char *color; WIDGET_CLASS wc; Section = (char *) section; Driver = (char *) driver; /* init layout framebuffer */ LROWS = 0; LCOLS = 0; for (l = 0; l < LAYERS; l++) drv_generic_graphic_FB[l] = NULL; drv_generic_graphic_resizeFB(DROWS, DCOLS); /* sanity check */ for (l = 0; l < LAYERS; l++) { if (drv_generic_graphic_FB[l] == NULL) { error("%s: framebuffer could not be allocated: malloc() failed", Driver); return -1; } } /* init generic driver & register plugins */ drv_generic_init(); /* set default colors */ color = cfg_get(Section, "foreground", "000000ff"); if (color2RGBA(color, &FG_COL) < 0) { error("%s: ignoring illegal color '%s'", Driver, color); } if (color) free(color); color = cfg_get(Section, "background", "ffffff00"); if (color2RGBA(color, &BG_COL) < 0) { error("%s: ignoring illegal color '%s'", Driver, color); } if (color) free(color); color = cfg_get(Section, "basecolor", "ffffff"); if (color2RGBA(color, &BL_COL) < 0) { error("%s: ignoring illegal color '%s'", Driver, color); } if (color) free(color); /* inverted display? */ cfg_number(section, "inverted", 0, 0, 1, &INVERTED); /* register text widget */ wc = Widget_Text; wc.draw = drv_generic_graphic_draw; widget_register(&wc); /* register icon widget */ wc = Widget_Icon; wc.draw = drv_generic_graphic_icon_draw; widget_register(&wc); /* register bar widget */ wc = Widget_Bar; wc.draw = drv_generic_graphic_bar_draw; widget_register(&wc); /* register image widget */ #ifdef WITH_IMAGE wc = Widget_Image; wc.draw = drv_generic_graphic_image_draw; widget_register(&wc); #endif /* clear framebuffer */ drv_generic_graphic_clear(); return 0; } int drv_generic_graphic_clear(void) { int i, l; for (l = 0; l < LAYERS; l++) for (i = 0; i < LCOLS * LROWS; i++) drv_generic_graphic_FB[l][i] = NO_COL; drv_generic_graphic_blit(0, 0, LROWS, LCOLS); return 0; } RGBA drv_generic_graphic_rgb(const int row, const int col) { return drv_generic_graphic_blend(row, col); } unsigned char drv_generic_graphic_gray(const int row, const int col) { RGBA p = drv_generic_graphic_blend(row, col); return (77 * p.R + 150 * p.G + 28 * p.B) / 255; } unsigned char drv_generic_graphic_black(const int row, const int col) { return drv_generic_graphic_gray(row, col) < 127; } int drv_generic_graphic_quit(void) { int l; for (l = 0; l < LAYERS; l++) { if (drv_generic_graphic_FB[l]) { free(drv_generic_graphic_FB[l]); drv_generic_graphic_FB[l] = NULL; } } widget_unregister(); return (0); }