2002-03-26 10:06:28 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2002-03-26 10:59:39 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "screenhack.h"
|
2004-09-16 14:36:08 +00:00
|
|
|
#include "config.h"
|
2002-03-26 10:59:39 +00:00
|
|
|
|
2002-03-26 10:06:28 +00:00
|
|
|
/*
|
2002-03-26 10:59:39 +00:00
|
|
|
* Specific implementations for X11, using the generic LCD API and data.
|
2002-03-26 10:06:28 +00:00
|
|
|
*/
|
|
|
|
|
2002-03-26 14:27:03 +00:00
|
|
|
#include "lcd-x11.h"
|
2002-10-28 20:08:40 +00:00
|
|
|
#include "lcd-playersim.h"
|
2002-03-26 10:59:39 +00:00
|
|
|
|
2005-07-06 22:58:02 +00:00
|
|
|
#if LCD_DEPTH == 2
|
|
|
|
#define YBLOCK 4
|
2005-07-14 10:02:04 +00:00
|
|
|
#define ANDBIT 3 /* AND with this to get the color number */
|
2005-07-06 22:58:02 +00:00
|
|
|
#else
|
|
|
|
#define YBLOCK 8
|
2005-07-14 10:02:04 +00:00
|
|
|
#define ANDBIT 1
|
2005-07-06 22:58:02 +00:00
|
|
|
#endif
|
|
|
|
|
2002-04-19 12:55:12 +00:00
|
|
|
extern void screen_resized(int width, int height);
|
2005-10-23 23:49:46 +00:00
|
|
|
extern bool lcd_display_redraw;
|
2002-03-26 10:59:39 +00:00
|
|
|
|
2002-10-28 20:08:40 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-11-14 02:11:26 +00:00
|
|
|
#if LCD_DEPTH==16
|
2005-11-17 07:17:03 +00:00
|
|
|
fb_data lcd_framebuffer_copy[LCD_HEIGHT][LCD_WIDTH*2];
|
2005-11-14 02:11:26 +00:00
|
|
|
#else
|
2005-11-17 07:17:03 +00:00
|
|
|
fb_data lcd_framebuffer_copy[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
|
2005-11-14 02:11:26 +00:00
|
|
|
#endif
|
2002-04-27 23:41:41 +00:00
|
|
|
|
2002-03-26 10:59:39 +00:00
|
|
|
void lcd_update (void)
|
|
|
|
{
|
2005-07-14 10:02:04 +00:00
|
|
|
/* update a full screen rect */
|
|
|
|
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
2002-09-10 07:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_update_rect(int x_start, int y_start,
|
|
|
|
int width, int height)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int yline=y_start;
|
|
|
|
int y;
|
|
|
|
int p=0;
|
|
|
|
int bit;
|
|
|
|
int xmax;
|
|
|
|
int ymax;
|
2005-07-14 10:02:04 +00:00
|
|
|
int colors[LCD_WIDTH * LCD_HEIGHT];
|
2002-10-28 20:08:40 +00:00
|
|
|
struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
|
2005-10-23 23:49:46 +00:00
|
|
|
unsigned force_mask = lcd_display_redraw ? 0xFF : 0;
|
2002-09-10 07:07:44 +00:00
|
|
|
|
2003-04-23 18:49:24 +00:00
|
|
|
#if 0
|
2003-02-07 09:42:57 +00:00
|
|
|
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
|
|
|
|
counter++, x_start, y_start, width, height);
|
2003-04-23 18:49:24 +00:00
|
|
|
#endif
|
2005-07-06 22:58:02 +00:00
|
|
|
/* The Y coordinates have to work on even YBLOCK pixel rows */
|
|
|
|
ymax = (yline + height)/YBLOCK;
|
|
|
|
yline /= YBLOCK;
|
2005-03-18 23:51:52 +00:00
|
|
|
|
2002-09-10 07:07:44 +00:00
|
|
|
xmax = x_start + width;
|
|
|
|
|
|
|
|
if(xmax > LCD_WIDTH)
|
|
|
|
xmax = LCD_WIDTH;
|
2005-07-06 22:58:02 +00:00
|
|
|
if(ymax >= LCD_HEIGHT/YBLOCK)
|
|
|
|
ymax = LCD_HEIGHT/YBLOCK-1;
|
2002-09-10 07:07:44 +00:00
|
|
|
|
2005-10-23 23:49:46 +00:00
|
|
|
for(; yline <= ymax; yline++) {
|
2005-07-06 22:58:02 +00:00
|
|
|
y = yline * YBLOCK;
|
2005-10-23 23:49:46 +00:00
|
|
|
for(x = x_start; x < xmax; x++) {
|
|
|
|
unsigned char diff = (lcd_framebuffer[yline][x]
|
|
|
|
^ lcd_framebuffer_copy[yline][x])
|
|
|
|
| force_mask;
|
|
|
|
if(diff) {
|
2002-04-27 23:41:41 +00:00
|
|
|
/* one or more bits/pixels are changed */
|
2005-10-23 23:49:46 +00:00
|
|
|
unsigned char mask = ANDBIT;
|
|
|
|
for(bit = 0; bit < YBLOCK; bit++) {
|
|
|
|
if(diff & mask) {
|
|
|
|
/* pixel has changed */
|
|
|
|
unsigned int col = lcd_framebuffer[yline][x] & mask;
|
2005-07-14 10:02:04 +00:00
|
|
|
#if LCD_DEPTH == 2
|
2005-10-23 23:49:46 +00:00
|
|
|
colors[p] = col >> (bit * LCD_DEPTH);
|
2005-07-14 10:02:04 +00:00
|
|
|
#else
|
2005-10-23 23:49:46 +00:00
|
|
|
colors[p] = col ? 3 : 0;
|
2005-07-14 10:02:04 +00:00
|
|
|
#endif
|
2005-10-23 23:49:46 +00:00
|
|
|
points[p].x = x + MARGIN_X;
|
|
|
|
points[p].y = y + bit + MARGIN_Y;
|
|
|
|
p++; /* increase the point counter */
|
|
|
|
}
|
|
|
|
mask <<= LCD_DEPTH;
|
2002-04-27 23:41:41 +00:00
|
|
|
}
|
2002-09-10 07:07:44 +00:00
|
|
|
|
|
|
|
/* update the copy */
|
2003-12-23 23:41:45 +00:00
|
|
|
lcd_framebuffer_copy[yline][x] = lcd_framebuffer[yline][x];
|
2002-04-27 23:41:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-14 10:02:04 +00:00
|
|
|
dots(colors, &points[0], p);
|
2005-03-18 23:51:52 +00:00
|
|
|
/* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
|
|
|
|
XtAppLock(app);
|
2002-04-19 12:55:12 +00:00
|
|
|
XSync(dpy,False);
|
2005-03-18 23:51:52 +00:00
|
|
|
XtAppUnlock(app);
|
2005-10-23 23:49:46 +00:00
|
|
|
lcd_display_redraw=false;
|
2002-03-26 10:59:39 +00:00
|
|
|
}
|
2005-05-23 16:23:25 +00:00
|
|
|
|
|
|
|
#ifdef LCD_REMOTE_HEIGHT
|
|
|
|
extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
|
|
|
|
unsigned char lcd_remote_framebuffer_copy[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
|
|
|
|
|
2005-10-23 13:06:25 +00:00
|
|
|
#define REMOTE_START_Y (LCD_HEIGHT + 2*MARGIN_Y)
|
2005-05-23 16:23:25 +00:00
|
|
|
|
|
|
|
void lcd_remote_update (void)
|
|
|
|
{
|
2005-07-14 10:02:04 +00:00
|
|
|
lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
|
2005-05-23 16:23:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_remote_update_rect(int x_start, int y_start,
|
|
|
|
int width, int height)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int yline=y_start;
|
|
|
|
int y;
|
|
|
|
int p=0;
|
|
|
|
int bit;
|
|
|
|
int xmax;
|
|
|
|
int ymax;
|
2005-10-23 23:49:46 +00:00
|
|
|
struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
|
|
|
|
int colors[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
|
|
|
|
unsigned force_mask = lcd_display_redraw ? 0xFF : 0;
|
2005-05-23 16:23:25 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
|
|
|
|
counter++, x_start, y_start, width, height);
|
|
|
|
#endif
|
|
|
|
/* The Y coordinates have to work on even 8 pixel rows */
|
|
|
|
ymax = (yline + height)/8;
|
|
|
|
yline /= 8;
|
|
|
|
|
|
|
|
xmax = x_start + width;
|
|
|
|
|
|
|
|
if(xmax > LCD_REMOTE_WIDTH)
|
|
|
|
xmax = LCD_REMOTE_WIDTH;
|
|
|
|
if(ymax >= LCD_REMOTE_HEIGHT/8)
|
|
|
|
ymax = LCD_REMOTE_HEIGHT/8-1;
|
|
|
|
|
2005-10-23 23:49:46 +00:00
|
|
|
for(; yline <= ymax; yline++) {
|
2005-05-23 16:23:25 +00:00
|
|
|
y = yline * 8;
|
2005-10-23 23:49:46 +00:00
|
|
|
for(x = x_start; x < xmax; x++) {
|
|
|
|
unsigned char diff = (lcd_remote_framebuffer[yline][x]
|
|
|
|
^ lcd_remote_framebuffer_copy[yline][x])
|
|
|
|
| force_mask;
|
|
|
|
if(diff) {
|
|
|
|
unsigned char mask = 1;
|
|
|
|
for(bit = 0; bit < 8; bit++) {
|
|
|
|
if(diff & mask) {
|
|
|
|
unsigned int col = lcd_remote_framebuffer[yline][x] & mask;
|
|
|
|
colors[p] = col ? 3 : 0;
|
2005-10-23 13:06:25 +00:00
|
|
|
points[p].x = x + MARGIN_X;
|
2005-10-23 23:49:46 +00:00
|
|
|
points[p].y = y + bit + (REMOTE_START_Y + MARGIN_Y);
|
2005-07-14 10:02:04 +00:00
|
|
|
p++; /* increase the point counter */
|
2005-05-23 16:23:25 +00:00
|
|
|
}
|
2005-10-23 23:49:46 +00:00
|
|
|
mask <<= 1;
|
2005-05-23 16:23:25 +00:00
|
|
|
}
|
2005-07-14 10:02:04 +00:00
|
|
|
|
2005-05-23 16:23:25 +00:00
|
|
|
/* update the copy */
|
|
|
|
lcd_remote_framebuffer_copy[yline][x] =
|
|
|
|
lcd_remote_framebuffer[yline][x];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-14 10:02:04 +00:00
|
|
|
dots(colors, &points[0], p);
|
2005-05-23 16:23:25 +00:00
|
|
|
/* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
|
|
|
|
XtAppLock(app);
|
|
|
|
XSync(dpy,False);
|
|
|
|
XtAppUnlock(app);
|
2005-10-23 23:49:46 +00:00
|
|
|
lcd_display_redraw=false;
|
2005-05-23 16:23:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-10-28 20:08:40 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
|
|
|
/* Defined in lcd-playersim.c */
|
|
|
|
extern void lcd_print_char(int x, int y);
|
|
|
|
extern unsigned char lcd_buffer[2][11];
|
|
|
|
extern void drawrect(int color, int x1, int y1, int x2, int y2);
|
|
|
|
|
2003-01-10 10:03:07 +00:00
|
|
|
extern unsigned char hardware_buffer_lcd[11][2];
|
|
|
|
static unsigned char lcd_buffer_copy[11][2];
|
2002-10-28 20:08:40 +00:00
|
|
|
|
|
|
|
void lcd_update (void)
|
|
|
|
{
|
2005-03-18 00:03:22 +00:00
|
|
|
bool changed=false;
|
|
|
|
int x, y;
|
|
|
|
for (y=0; y<2; y++) {
|
|
|
|
for (x=0; x<11; x++) {
|
|
|
|
if (lcd_display_redraw ||
|
|
|
|
lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y]) {
|
|
|
|
lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
|
|
|
|
lcd_print_char(x, y);
|
|
|
|
changed=true;
|
|
|
|
}
|
|
|
|
}
|
2002-10-28 20:08:40 +00:00
|
|
|
}
|
2005-03-18 00:03:22 +00:00
|
|
|
if (changed)
|
2005-03-18 23:51:52 +00:00
|
|
|
{
|
|
|
|
XtAppLock(app);
|
2005-03-18 00:03:22 +00:00
|
|
|
XSync(dpy,False);
|
2005-03-18 23:51:52 +00:00
|
|
|
XtAppUnlock(app);
|
|
|
|
}
|
2005-03-18 00:03:22 +00:00
|
|
|
lcd_display_redraw=false;
|
2002-10-28 20:08:40 +00:00
|
|
|
}
|
2002-09-10 07:07:44 +00:00
|
|
|
|
2002-10-28 20:08:40 +00:00
|
|
|
#endif
|