harmonize coding style and messages; little fixes
This commit is contained in:
+52
-50
@@ -84,25 +84,26 @@ t6963_init (Driver *drvthis)
|
||||
|
||||
/* -------------------------- Which size --------------------------------------*/
|
||||
strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
|
||||
size[sizeof(size)-1]=0;
|
||||
if( sscanf(size, "%dx%d", &w, &h ) != 2
|
||||
size[sizeof(size)-1] = '\0';
|
||||
if ((sscanf(size, "%dx%d", &w, &h) != 2)
|
||||
|| (w <= 0) || (w > LCD_MAX_WIDTH)
|
||||
|| (h <= 0) || (h > LCD_MAX_HEIGHT)) {
|
||||
report (RPT_WARNING, "T6963_init: Cannot read size: %s, Using default value.\n", size);
|
||||
report(RPT_WARNING, "%s: cannot read Size: %s, Using default %s",
|
||||
drvthis->name, size, DEFAULT_SIZE);
|
||||
sscanf(DEFAULT_SIZE, "%dx%d", &w, &h);
|
||||
} else {
|
||||
}
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
/* --------------------------- Which port --------------------------------------*/
|
||||
p = drvthis->config_get_int(drvthis->name, "Port", 0, DEFAULT_PORT);
|
||||
if(0x200 <= p && p <= 0x400) {
|
||||
t6963_out_port = p;
|
||||
} else {
|
||||
t6963_out_port = DEFAULT_PORT;
|
||||
report (RPT_WARNING, "T6963_init: Port value must be between 0x200 and 0x400. Using default value.\n");
|
||||
if ((p < 0x200) || (p > 0x400)) {
|
||||
p = DEFAULT_PORT;
|
||||
report(RPT_WARNING, "%s: Port value must be between 0x200 and 0x400. Using default 0x%03X",
|
||||
drvthis->name, DEFAULT_PORT);
|
||||
}
|
||||
t6963_out_port = p;
|
||||
|
||||
/* ---------------------------- Is ECP mode on ----------------------------------*/
|
||||
bidirectLPT = drvthis->config_get_bool(drvthis->name, "ECPlpt", 0, 1);
|
||||
/* ---------------------------- Use graphic -------------------------------------*/
|
||||
@@ -110,33 +111,31 @@ t6963_init (Driver *drvthis)
|
||||
|
||||
|
||||
/* -- Get permission to parallel port --------------------------------------------*/
|
||||
|
||||
debug(RPT_DEBUG, "T6963: Getting permission to parallel port %d...", t6963_out_port);
|
||||
|
||||
if (port_access_multiple(t6963_out_port, 3)) { //ioperm(t6963_out_port, 3, 1)) {
|
||||
report (RPT_ERR, "T6963_init: no permission to port %d: (%s)\n", t6963_out_port, strerror (errno));
|
||||
report(RPT_ERR, "%s: no permission to port %d: (%s)",
|
||||
drvthis->name, t6963_out_port, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (port_access(0x80)) { //ioperm(0x80, 1, 1)) {
|
||||
report (RPT_ERR, "T6963_init: no permission to port 0x80: (%s)\n", strerror (errno));
|
||||
report(RPT_ERR, "%s: no permission to port 0x80: (%s)",
|
||||
drvthis->name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
debug(RPT_DEBUG, "T6963: cool, got 'em!");
|
||||
|
||||
|
||||
/* -- Set charakter size --*/
|
||||
|
||||
cellwidth = 6;
|
||||
cellheight = 8;
|
||||
|
||||
/* -- Allocate framebuffer --*/
|
||||
|
||||
debug(RPT_DEBUG, "T6963: Allocate framebuffer...");
|
||||
framebuf = malloc(width * height);
|
||||
|
||||
if (!framebuf) {
|
||||
report (RPT_ERR, "T6963_init: No memory for framebuffer!");
|
||||
if (framebuf == NULL) {
|
||||
report(RPT_ERR, "%s: No memory for framebuffer", drvthis->name);
|
||||
t6963_close(drvthis);
|
||||
return -1;
|
||||
}
|
||||
@@ -148,16 +147,15 @@ t6963_init (Driver *drvthis)
|
||||
debug(RPT_DEBUG, "T6963: Allocating double buffering...");
|
||||
t6963_display_buffer1 = malloc(width * height);
|
||||
t6963_display_buffer2 = malloc(width * height);
|
||||
/* - Clear front and back buffer -*/
|
||||
if(t6963_display_buffer1 && t6963_display_buffer2) {
|
||||
memset(t6963_display_buffer1, ' ', width * height);
|
||||
memset(t6963_display_buffer1, ' ', width * height);
|
||||
debug (RPT_DEBUG, "T6963: done!");
|
||||
} else {
|
||||
report (RPT_ERR, "T6963: No memory for double buffering!");
|
||||
if ((t6963_display_buffer1 == NULL) || (t6963_display_buffer2 == NULL)) {
|
||||
report(RPT_ERR, "%s: No memory for double buffering", drvthis->name);
|
||||
t6963_close(drvthis);
|
||||
return -1;
|
||||
}
|
||||
/* - Clear front and back buffer -*/
|
||||
memset(t6963_display_buffer1, ' ', width * height);
|
||||
memset(t6963_display_buffer2, ' ', width * height);
|
||||
debug(RPT_DEBUG, "T6963: done!");
|
||||
|
||||
/* ------------------- I N I T I A L I Z A T I O N ----------------------- */
|
||||
debug(RPT_DEBUG, "T6963: Sending init to display...");
|
||||
@@ -184,7 +182,8 @@ t6963_init (Driver *drvthis)
|
||||
debug(RPT_WARNING, "T6963: ECP mode not working!\n -> is now disabled (STA0: %i, STA1: %i\n", ecp_input & 1, ecp_input & 2);
|
||||
bidirectLPT = 0;
|
||||
}
|
||||
else debug(RPT_WARNING, "T6963: working!");
|
||||
else
|
||||
debug(RPT_WARNING, "T6963: working!");
|
||||
}
|
||||
|
||||
debug(RPT_DEBUG, "T6963: set graphic/text home adress and area");
|
||||
@@ -202,8 +201,10 @@ t6963_init (Driver *drvthis)
|
||||
t6963_set_nchar(drvthis, 0, fontdata_6x8, 256);
|
||||
|
||||
t6963_low_enable_mode(TEXT_ON);
|
||||
if (graphicON == 0) t6963_low_disable_mode (GRAPHIC_ON);
|
||||
else t6963_low_enable_mode (GRAPHIC_ON);
|
||||
if (graphicON == 0)
|
||||
t6963_low_disable_mode(GRAPHIC_ON);
|
||||
else
|
||||
t6963_low_enable_mode(GRAPHIC_ON);
|
||||
t6963_low_disable_mode(CURSOR_ON);
|
||||
t6963_low_disable_mode(BLINK_ON);
|
||||
|
||||
@@ -211,9 +212,9 @@ t6963_init (Driver *drvthis)
|
||||
t6963_graphic_clear(drvthis, 0, 0, width, cellheight * height);
|
||||
t6963_flush(drvthis);
|
||||
|
||||
debug (RPT_DEBUG, "T6963: Initialization done!");
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 0; // 200 is arbitrary. (must be 1 or more)
|
||||
return 1; // return success
|
||||
}
|
||||
|
||||
// Below here, you may use either lcd.framebuf or driver->framebuf..
|
||||
@@ -223,18 +224,21 @@ t6963_init (Driver *drvthis)
|
||||
MODULE_EXPORT void
|
||||
t6963_close (Driver *drvthis)
|
||||
{
|
||||
debug (RPT_INFO, "Shutting down!\n");
|
||||
debug(RPT_INFO, "Shutting down!");
|
||||
t6963_low_disable_mode(BLINK_ON);
|
||||
|
||||
port_deny_multiple(t6963_out_port,3);
|
||||
|
||||
if (framebuf != NULL)
|
||||
free(framebuf);
|
||||
if (t6963_display_buffer1 != NULL) free (t6963_display_buffer1);
|
||||
if (t6963_display_buffer2 != NULL) free (t6963_display_buffer2);
|
||||
|
||||
framebuf = NULL;
|
||||
|
||||
if (t6963_display_buffer1 != NULL)
|
||||
free(t6963_display_buffer1);
|
||||
t6963_display_buffer1 = NULL;
|
||||
|
||||
if (t6963_display_buffer2 != NULL)
|
||||
free(t6963_display_buffer2);
|
||||
t6963_display_buffer2 = NULL;
|
||||
}
|
||||
|
||||
@@ -262,18 +266,18 @@ t6963_height (Driver *drvthis)
|
||||
MODULE_EXPORT void
|
||||
t6963_clear (Driver *drvthis)
|
||||
{
|
||||
debug (RPT_DEBUG, "Clearing Display of size %i x %i\n", width, height);
|
||||
debug(RPT_DEBUG, "Clearing Display of size %d x %d", width, height);
|
||||
memset(t6963_display_buffer1, ' ', width * height);
|
||||
debug (RPT_DEBUG, "Done\n");
|
||||
debug(RPT_DEBUG, "Done");
|
||||
}
|
||||
|
||||
void
|
||||
t6963_graphic_clear(Driver *drvthis, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int x;
|
||||
debug (RPT_DEBUG, "Clearing Graphic %i bytes\n", (x2-x1)*(y2-y1));
|
||||
for (;y1 < y2; y1++)
|
||||
{
|
||||
|
||||
debug(RPT_DEBUG, "Clearing Graphic %d bytes", (x2-x1)*(y2-y1));
|
||||
for ( ; y1 < y2; y1++) {
|
||||
t6963_low_command_word(SET_ADDRESS_POINTER, ATTRIB_BASE + y1 * width + x1);
|
||||
for (x = x1; x < x2; x++)
|
||||
t6963_low_command_byte(DATA_WRITE_INC, 0);
|
||||
@@ -287,18 +291,16 @@ MODULE_EXPORT void
|
||||
t6963_flush (Driver *drvthis)
|
||||
{
|
||||
int i;
|
||||
debug (RPT_DEBUG, "Flushing %i x %i\n", width, height);
|
||||
debug(RPT_DEBUG, "Flushing %d x %d", width, height);
|
||||
|
||||
for (i = 0; i < (width * height); i++)
|
||||
{
|
||||
for (i = 0; i < (width * height); i++) {
|
||||
// debug(RPT_DEBUG, "%i%i|", t6963_display_buffer1[i], t6963_display_buffer2[i]);
|
||||
if (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 (RPT_DEBUG, "Done\n");
|
||||
debug(RPT_DEBUG, "Done");
|
||||
t6963_swap_buffers();
|
||||
t6963_clear(drvthis);
|
||||
}
|
||||
@@ -310,12 +312,12 @@ t6963_flush (Driver *drvthis)
|
||||
MODULE_EXPORT void
|
||||
t6963_string (Driver *drvthis, int x, int y, char string[])
|
||||
{
|
||||
debug (RPT_DEBUG, "String out\n");
|
||||
debug(RPT_DEBUG, "String out");
|
||||
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
|
||||
if(y * width + x + strlen(string) <= width * height);
|
||||
if ((y * width + x + strlen(string)) <= (width * height));
|
||||
memcpy(&t6963_display_buffer1[y * width + x], string, strlen(string));
|
||||
|
||||
}
|
||||
@@ -327,7 +329,7 @@ t6963_string (Driver *drvthis, int x, int y, char string[])
|
||||
MODULE_EXPORT void
|
||||
t6963_chr (Driver *drvthis, int x, int y, char c)
|
||||
{
|
||||
debug (RPT_DEBUG, "Char out\n");
|
||||
debug(RPT_DEBUG, "Char out");
|
||||
y--;
|
||||
x--;
|
||||
if ((y * width) + x <= (width * height))
|
||||
@@ -352,9 +354,9 @@ t6963_set_nchar (Driver *drvthis, int n, char *dat, int num)
|
||||
int row, col;
|
||||
char letter;
|
||||
|
||||
debug (RPT_DEBUG, "Setting char %i", n);
|
||||
debug(RPT_DEBUG, "Setting char %d", n);
|
||||
|
||||
if (!dat || n+num > 256)
|
||||
if ((!dat) || (n + num > 256))
|
||||
return;
|
||||
|
||||
t6963_low_command_word(SET_ADDRESS_POINTER, CHARGEN_BASE + n*8);
|
||||
|
||||
Reference in New Issue
Block a user