From 6e178cdc6ab3f3819c579264358363fca6c24d00 Mon Sep 17 00:00:00 2001 From: themythos Date: Fri, 21 Dec 2001 15:01:43 +0000 Subject: [PATCH] v1.2 now graphics disabled, because of strange pixel faults --- server/drivers/t6963.c | 215 ++++++++++++++++-------------------- server/drivers/t6963.h | 26 ++--- server/drivers/t6963_font.h | 16 +-- 3 files changed, 117 insertions(+), 140 deletions(-) diff --git a/server/drivers/t6963.c b/server/drivers/t6963.c index b9c4c55..89d27a5 100644 --- a/server/drivers/t6963.c +++ b/server/drivers/t6963.c @@ -1,5 +1,5 @@ /* - * Base driver module for Toshiba T6963 based LCD displays. ver 1.0 + * Base driver module for Toshiba T6963 based LCD displays. ver 1.2 * * Parts of this file are based on the kernel driver by Alexander Frink * @@ -8,6 +8,8 @@ * COPYING file distributed with this package. * * Copyright (c) 2001 Manuel Stahl + * + * TODO: replace current debug function with the ones of shared/report.h */ #include @@ -17,11 +19,13 @@ #include #include #include - + #include "shared/str.h" #include "shared/debug.h" #include "lcd.h" +#include "render.h" +#include "port.h" #include "t6963.h" #include "t6963_font.h" @@ -29,13 +33,16 @@ #include "config.h" #endif +#define DEBUG3 if(debug_level > 2) printf +#define DEBUG4 if(debug_level > 3) printf + +extern int debug_level; lcd_logical_driver *t6963; static u16 t6963_out_port; static u16 t6963_display_mode; static u8 *t6963_display_buffer1; static u8 *t6963_display_buffer2; -static u8 t6963_hbar_len[6]; static u8 t6963_graph_line[6]; int @@ -44,9 +51,8 @@ t6963_init (struct lcd_logical_driver *driver, char *args) char *argv[64]; int argc; int i; - int tmp; - debug ("Doing initialization\n"); + DEBUG3 ("Doing initialization\n"); t6963_out_port = 0x378; t6963_display_mode = 0; @@ -59,16 +65,9 @@ t6963_init (struct lcd_logical_driver *driver, char *args) t6963 = driver; - debug ("Reading arguments...\n"); + DEBUG3 ("Reading arguments...\n"); argc = get_args (argv, args, 64); - - /* for(i=0; iwid = 20; - driver->hgt = 6; + DEBUG3 ("done\nAllocating memory: %i x %i bytes = %i...\n", driver->wid, driver->hgt, driver->wid * driver->hgt); - debug ("done\nAllocating memory: %i x %i bytes = %i\n", driver->wid, driver->hgt, driver->wid * driver->hgt); + // Set display size + t6963->wid = 20; + t6963->hgt = 6; + t6963->cellwid = 6; + t6963->cellhgt = 8; - // You must use driver->framebuf here, but may use lcd.framebuf later. + // You must use driver->framebuf here, but may use lcd.framebuf later. if (!driver->framebuf) driver->framebuf = malloc (driver->wid * driver->hgt); @@ -113,46 +117,43 @@ t6963_init (struct lcd_logical_driver *driver, char *args) t6963_close (); return -1; } - + // Allocate memory t6963_display_buffer1 = malloc (driver->wid * 6); t6963_display_buffer2 = malloc (driver->wid * 6); -// Debugging... + // Clear front and back buffer if(t6963_display_buffer1) memset(t6963_display_buffer1, ' ', driver->wid * 6); if(t6963_display_buffer2) memset(t6963_display_buffer1, ' ', driver->wid * 6); - driver->cellwid = 6; - driver->cellhgt = 8; - t6963->cellwid = 6; - t6963->cellhgt = 8; + DEBUG3 ("done\nSetting function pointers...\n"); driver->clear = t6963_clear; driver->string = t6963_string; driver->chr = t6963_chr; driver->vbar = t6963_vbar; - //driver->init_vbar = NULL; driver->hbar = t6963_hbar; - //driver->init_hbar = NULL; driver->num = t6963_num; - driver->init_num = t6963_init_num; - driver->init = t6963_init; driver->close = t6963_close; driver->flush = t6963_flush; - //driver->flush_box = NULL; - driver->contrast = t6963_contrast; - driver->backlight = t6963_backlight; + driver->flush_box = t6963_flush_box; driver->set_char = t6963_set_char; driver->icon = t6963_icon; + driver->heartbeat = t6963_heartbeat; driver->draw_frame = t6963_draw_frame; driver->getkey = t6963_getkey; + DEBUG3 ("done\nSending init to display...\n"); + DEBUG4 (" make parallel port an output port\n"); + T6963_CEHI; // disable chip T6963_RDHI; // disable reading from LCD T6963_WRHI; // disable writing to LCD T6963_CDHI; // command/status mode T6963_DATAOUT; // make 8-bit parallel port an output port + DEBUG4(" set graphic/text home adress and area\n"); + t6963_low_command_word (SET_GRAPHIC_HOME_ADDRESS, ATTRIB_BASE); t6963_low_command_word (SET_GRAPHIC_AREA, driver->wid); t6963_low_command_word (SET_TEXT_HOME_ADDRESS, TEXT_BASE); @@ -163,19 +164,19 @@ t6963_init (struct lcd_logical_driver *driver, char *args) t6963_low_command (SET_CURSOR_PATTERN | 7); // cursor is 8 lines high t6963_low_command_2_bytes (SET_CURSOR_POINTER, 0, 0); - t6963_set_nchar (0, fontdata_6x8, 255); + t6963_set_nchar (0, fontdata_6x8, 256); t6963_low_enable_mode (TEXT_ON); - t6963_low_enable_mode (GRAPHIC_ON); + t6963_low_disable_mode (GRAPHIC_ON); t6963_low_disable_mode (CURSOR_ON); t6963_low_disable_mode (BLINK_ON); t6963_clear (); t6963_graphic_clear (0, 0, driver->wid, driver->cellhgt * 6); t6963_flush(); - debug ("Initialization done!\n"); + DEBUG3 ("Initialization done!\n"); - return 200; // 200 is arbitrary. (must be 1 or more) + return 0; // 200 is arbitrary. (must be 1 or more) } // Below here, you may use either lcd.framebuf or driver->framebuf.. @@ -185,7 +186,7 @@ t6963_init (struct lcd_logical_driver *driver, char *args) void t6963_close () { - debug ("Shutting down!\n"); + DEBUG3 ("Shutting down!\n"); t6963_low_disable_mode (BLINK_ON); ioperm(t6963_out_port, 3, 0); @@ -205,15 +206,13 @@ t6963_close () void t6963_clear () { - int i; - - debug ("Clearing Display of size %i x %i\n", t6963->wid, 6); + DEBUG4 ("Clearing Display of size %i x %i\n", t6963->wid, 6); memset (t6963_display_buffer1, ' ', t6963->wid * 6); // for (i=0; i < 6; i++) // if (t6963_hbar_len[i]==0) t6963_graphic_clear(0, i*t6963->cellhgt, t6963->wid, (i+1)*t6963->cellhgt); - debug ("Done\n"); + DEBUG4 ("Done\n"); } void @@ -221,7 +220,7 @@ t6963_graphic_clear (int x1, int y1, int x2, int y2) { int x; - debug ("Clearing Graphic %i bytes\n", (x2-x1)*(y2-y1)); + DEBUG4 ("Clearing Graphic %i bytes\n", (x2-x1)*(y2-y1)); for (;y1 < y2; y1++) { @@ -238,19 +237,18 @@ void t6963_flush () { int i; - debug ("Flushing %i x %i\n", t6963->wid, t6963->hgt); + DEBUG4 ("Flushing %i x %i\n", t6963->wid, t6963->hgt); for (i = 0; i < (t6963->wid * 6); i++) { - debug ("%c%c|", t6963_display_buffer1[i], t6963_display_buffer2[i]); + DEBUG4 ("%i%i|", t6963_display_buffer1[i], t6963_display_buffer2[i]); if (t6963_display_buffer1[i] != t6963_display_buffer2[i]) { t6963_low_command_word(SET_ADDRESS_POINTER, TEXT_BASE + i); t6963_low_command_byte(DATA_WRITE, t6963_display_buffer1[i]); } } - debug ("\n"); - //t6963->draw_frame(t6963->framebuf); + DEBUG4 ("\n"); t6963_swap_buffers(); t6963_clear(); } @@ -264,7 +262,7 @@ t6963_flush () void t6963_flush_box (int lft, int top, int rgt, int bot) { - debug ("flush_box\n"); + DEBUG4 ("flush_box\n"); t6963_flush(); //drv_base_flush(); @@ -277,9 +275,7 @@ t6963_flush_box (int lft, int top, int rgt, int bot) void t6963_string (int x, int y, char string[]) { - int i; - - debug ("String out\n"); + DEBUG4 ("String out\n"); x -= 1; // Convert 1-based coords to 0-based... y -= 1; @@ -292,56 +288,18 @@ t6963_string (int x, int y, char string[]) ///////////////////////////////////////////////////////////////// // Prints a character on the lcd display, at position (x,y). The -// upper-left is (1,1), and the lower right should be (20,4). +// upper-left is (1,1), and the lower right should be (20,6). // void t6963_chr (int x, int y, char c) { - debug ("Char out\n"); + DEBUG4 ("Char out\n"); y--; x--; if ((y * t6963->wid) + x <= (t6963->wid * 6)) t6963_display_buffer1[(y * t6963->wid) + x] = c; } -////////////////////////////////////////////////////////////////////// -// Sets the contrast of the display. Value is 0-255, where 140 is -// what I consider "just right". -// -int -t6963_contrast (int contrast) -{ -// printf("Contrast: %i\n", contrast); - return -1; -} - -////////////////////////////////////////////////////////////////////// -// Turns the lcd backlight on or off... -// -void -t6963_backlight (int on) -{ - /* - if(on) - { - printf("Backlight ON\n"); - } - else - { - printf("Backlight OFF\n"); - } - */ -} - -////////////////////////////////////////////////////////////////////// -// Tells the driver to get ready for big numbers, if possible. -// -void -t6963_init_num () -{ -// printf("Big Numbers.\n"); -} - ////////////////////////////////////////////////////////////////////// // Draws a big (4-row) number. // @@ -358,10 +316,9 @@ void t6963_set_nchar (int n, char *dat, int num) { int row, col; - char tmp; char letter; - debug ("Setting char %i", n); + DEBUG4 ("Setting char %i", n); if (!dat || n+num > 256) return; @@ -391,13 +348,14 @@ void t6963_vbar (int x, int len) { int y; - + DEBUG4 ("Drawing vertical bar..."); for (y = 0; y < len/t6963->cellhgt; y++) t6963_chr (x, 6-y, 219); if (len % t6963->cellhgt) t6963_chr (x, 6-y, 211 + (len % t6963->cellhgt)); + DEBUG4 ("Done\n"); } ///////////////////////////////////////////////////////////////// @@ -407,13 +365,14 @@ void t6963_hbar (int x, int y, int len) { int stop = x + len/t6963->cellwid; - for (; x <= stop; x++) + DEBUG4 ("Drawing horizontal bar x: %i, y: %i, len:%i, stop: %i...", x, y, len, stop); + for (; x < stop; x++) t6963_chr (x, y, 219); if (len % t6963->cellwid) t6963_chr (x, y, 225 - (len % t6963->cellwid)); - + DEBUG4 ("Done\n"); } ///////////////////////////////////////////////////////////////// @@ -423,26 +382,45 @@ void t6963_icon (int which, char dest) { // printf("Char %i set to icon %i\n", dest, which); + DEBUG4 ("Icon %i\n", which); } +///////////////////////////////////////////////////////////////// +// Does the heartbeat +// +void +t6963_heartbeat (int type) +{ + static int timer; + int whichIcon; + static int saved_type = HEARTBEAT_ON; + + if (type) + saved_type = type; + + if (type = HEARTBEAT_ON) { + // Set this to pulsate like a real heartbeat... + whichIcon = (! ((timer + 4) & 5)); + // Put character on screen... + t6963_chr (t6963->wid, 1, 3+whichIcon); + } + + timer++; + timer &= 0x0f; +} + +////////////////////////////////////////////////////////////////////// +// Gets a whole screen buffer as argument... +// + void t6963_draw_frame (char *dat) { - int x, y; + DEBUG4 ("Drawing frame..."); - if(!dat) return; + memcpy (t6963_display_buffer1, dat, t6963->wid * t6963->hgt); - for(x=1; x<=t6963->wid; x++) - { - t6963_chr (x, 1, '-'); - t6963_chr (x, 6, '-'); - } - - for(y=0; yhgt; y++) - { - for(x=0; xwid; x++) - t6963_chr(x+1, y+1, dat[x+(y*t6963->wid)]); - } + DEBUG4 ("Done"); } ////////////////////////////////////////////////////////////////////// @@ -453,6 +431,7 @@ t6963_draw_frame (char *dat) char t6963_getkey () { + DEBUG4 ("Get key"); return 0; } @@ -463,7 +442,7 @@ t6963_low_data (u8 byte) T6963_CDLO; T6963_WRLO; // activate LCD's write mode - outb_p(byte, T6963_DATA_PORT); // write value to data port + port_out(T6963_DATA_PORT, byte); // write value to data port T6963_CELO; // pulse enable LOW > 80 ns (hah!) T6963_CEHI; // return enable HIGH T6963_WRHI; // restore Write mode to inactive @@ -474,7 +453,7 @@ t6963_low_command (u8 byte) { // lcd_wait_until_ready(); - outb_p(byte, T6963_DATA_PORT); // present data to LCD on PC's port pins + port_out(T6963_DATA_PORT, byte); // present data to LCD on PC's port pins T6963_CDHI; // control/status mode T6963_RDHI; // make sure LCD read mode is off diff --git a/server/drivers/t6963.h b/server/drivers/t6963.h index ba30e2e..cc16325 100644 --- a/server/drivers/t6963.h +++ b/server/drivers/t6963.h @@ -1,5 +1,5 @@ /* - * Base driver module for Toshiba T6963 based LCD displays ver 1.0. + * Base driver module for Toshiba T6963 based LCD displays ver 1.2 * * Parts of this file are based on the kernel driver by Alexander Frink * @@ -22,29 +22,29 @@ #define CUR_NONE 1 // take PC 1 HI -#define T6963_CEHI outb_p(inb_p(T6963_CONTROL_PORT) & 0xfe, T6963_CONTROL_PORT) +#define T6963_CEHI port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) & 0xfe) // take PC 1 LO -#define T6963_CELO outb_p(inb_p(T6963_CONTROL_PORT) | 0x01, T6963_CONTROL_PORT) +#define T6963_CELO port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) | 0x01) // take PC 14 HI -#define T6963_RDHI outb_p(inb_p(T6963_CONTROL_PORT) & 0xfd, T6963_CONTROL_PORT) +#define T6963_RDHI port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) & 0xfd) // take PC 14 LO -#define T6963_RDLO outb_p(inb_p(T6963_CONTROL_PORT) | 0x02, T6963_CONTROL_PORT) +#define T6963_RDLO port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) | 0x02) // take PC 16 HI -#define T6963_WRHI outb_p(inb_p(T6963_CONTROL_PORT) | 0x04, T6963_CONTROL_PORT) +#define T6963_WRHI port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) | 0x04) // take PC 16 LO -#define T6963_WRLO outb_p(inb_p(T6963_CONTROL_PORT) & 0xfb, T6963_CONTROL_PORT) +#define T6963_WRLO port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) & 0xfb) // take PC 17 HI -#define T6963_CDHI outb_p(inb_p(T6963_CONTROL_PORT) & 0xf7, T6963_CONTROL_PORT) +#define T6963_CDHI port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) & 0xf7) // take PC 17 LO -#define T6963_CDLO outb_p(inb_p(T6963_CONTROL_PORT) | 0x08, T6963_CONTROL_PORT) +#define T6963_CDLO port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) | 0x08) // 8bit Data input -#define T6963_DATAIN outb_p(inb_p(T6963_CONTROL_PORT) | 0x20, T6963_CONTROL_PORT) +#define T6963_DATAIN port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) | 0x20) // 8bit Data output -#define T6963_DATAOUT outb_p(inb_p(T6963_CONTROL_PORT) & 0xdf, T6963_CONTROL_PORT) +#define T6963_DATAOUT port_out(T6963_CONTROL_PORT, port_in(T6963_CONTROL_PORT) & 0xdf) #define CHARGEN_BASE 0x0000 #define TEXT_BASE 0x0800 @@ -114,15 +114,13 @@ void t6963_graphic_clear (); void t6963_flush (); void t6963_string (int x, int y, char string[]); void t6963_chr (int x, int y, char c); -int t6963_contrast (int contrast); -void t6963_backlight (int on); void t6963_vbar (int x, int len); void t6963_hbar (int x, int y, int len); void t6963_num (int x, int num); -void t6963_init_num (); void t6963_set_nchar (int n, char *dat, int num); void t6963_set_char (int n, char *dat); void t6963_icon (int which, char dest); +void t6963_heartbeat (int type); void t6963_flush_box (int lft, int top, int rgt, int bot); void t6963_draw_frame (char *dat); char t6963_getkey (); diff --git a/server/drivers/t6963_font.h b/server/drivers/t6963_font.h index 8f2989b..4bedb89 100644 --- a/server/drivers/t6963_font.h +++ b/server/drivers/t6963_font.h @@ -1,5 +1,5 @@ /* - * Base driver module for Toshiba T6963 based LCD displays. ver 1.0 + * Base driver module for Toshiba T6963 based LCD displays. ver 1.2 * * Parts of this file are based on the kernel driver by Alexander Frink * @@ -2310,12 +2310,12 @@ unsigned char fontdata_6x8[FONTDATAMAX] = { 1,1,1,1,1,0, 0,0,1,1,1,1, /* num: 255 */ -0,1,1,1,1,0, -1,1,0,0,1,0, -1,1,0,0,1,0, -1,1,1,1,1,0, -0,0,1,1,1,1, -1,0,0,1,0,0, -0,1,1,0,0,0, +0,1,0,0,1,0, +1,1,1,1,1,1, +0,1,0,0,1,0, +0,1,0,0,1,0, +1,1,1,1,1,1, +0,1,0,0,1,0, +0,0,0,0,0,0, 0,0,0,0,0,0, };