harmonize coding style and messages

This commit is contained in:
marschap
2006-04-08 16:33:48 +00:00
parent e1827e078a
commit cbf92bba92
2 changed files with 144 additions and 162 deletions
+85 -107
View File
@@ -293,107 +293,105 @@ stv5730_init (Driver *drvthis)
/* End of config file parsing */
if (timing_init() == -1) {
report(RPT_ERR, "timing_init: failed (%s)\n", strerror(errno));
report(RPT_ERR, "%s: timing_init() failed (%s)", drvthis->name, strerror(errno));
return -1;
}
// Initialize the Port and the stv5730
if (port_access (stv5730_lptport) || port_access (stv5730_lptport + 1))
{
if (port_access(stv5730_lptport) || port_access(stv5730_lptport + 1)) {
report(RPT_ERR,
"Couldn't get IO-permission for 0x%X ! Are we running as root ?\n ",
stv5730_lptport);
"%s: cannot get IO-permission for 0x%03X! Are we running as root?",
drvthis->name, stv5730_lptport);
return -1;
};
}
if (stv5730_detect ())
{
report(RPT_ERR, "No STV5730 hardware found at 0x%X !\n ", stv5730_lptport);
if (stv5730_detect()) {
report(RPT_ERR, "%s: no STV5730 hardware found at 0x%03X ",
drvthis->name, stv5730_lptport);
return -1;
};
}
port_out (stv5730_lptport, 0);
port_out(stv5730_lptport, 0);
// Reset the STV5730
stv5730_write16bit (0x3000);
stv5730_write16bit (0x3000);
stv5730_write16bit (0x00db);
stv5730_write16bit (0x1000);
stv5730_write16bit(0x3000);
stv5730_write16bit(0x3000);
stv5730_write16bit(0x00db);
stv5730_write16bit(0x1000);
// Setup Mode + Control Register for video detection
stv5730_write16bit (STV5730_REG_MODE);
stv5730_write16bit (0x1576);
stv5730_write16bit(STV5730_REG_MODE);
stv5730_write16bit(0x1576);
stv5730_write16bit (STV5730_REG_CONTROL);
stv5730_write16bit (0x1FF4);
stv5730_write16bit(STV5730_REG_CONTROL);
stv5730_write16bit(0x1FF4);
report(RPT_INFO, "Detecting Video Signal: ");
report(RPT_INFO, "%s: detecting video signal: ", drvthis->name);
usleep (50000);
if (stv5730_is_mute ())
{
report(RPT_INFO, "No Video Signal found, using full page mode.\n");
if (stv5730_is_mute()) {
report(RPT_INFO, "%s: no video signal found; using full page mode", drvthis->name);
// Setup Mode + Control for full page mode
stv5730_charattrib = STV5730_ATTRIB;
stv5730_write16bit (STV5730_REG_MODE);
stv5730_write16bit (0x15A6);
stv5730_write16bit(STV5730_REG_MODE);
stv5730_write16bit(0x15A6);
stv5730_write16bit (STV5730_REG_CONTROL);
stv5730_write16bit(STV5730_REG_CONTROL);
#ifdef PAL
stv5730_write16bit (0x1FD5);
stv5730_write16bit(0x1FD5);
#endif
#ifdef NTSC
stv5730_write16bit (0x1ED4);
stv5730_write16bit(0x1ED4);
#endif
}
else
{
report(RPT_INFO, "Video Signal found, using mixed mode (B&W).\n");
}
else {
report(RPT_INFO, "%s: video signal found, using mixed mode (B&W)", drvthis->name);
// Setup Mode + Control for mixed mode, disable color
stv5730_charattrib = 0;
stv5730_write16bit (STV5730_REG_MODE);
stv5730_write16bit (0x1576);
stv5730_write16bit(STV5730_REG_MODE);
stv5730_write16bit(0x1576);
stv5730_write16bit (STV5730_REG_CONTROL);
stv5730_write16bit(STV5730_REG_CONTROL);
#ifdef PAL
stv5730_write16bit (0x1DD4);
stv5730_write16bit(0x1DD4);
#endif
#ifdef NTSC
stv5730_write16bit (0x1CF4);
stv5730_write16bit(0x1CF4);
#endif
}
// Position Register
stv5730_write16bit (STV5730_REG_POSITION);
stv5730_write16bit (0x1000 + 64 * 30 + 30);
stv5730_write16bit(STV5730_REG_POSITION);
stv5730_write16bit(0x1000 + 64 * 30 + 30);
// Color Register
stv5730_write16bit (STV5730_REG_COLOR);
stv5730_write16bit (0x1000 + (STV5730_COL_SBACK << 9) +
stv5730_write16bit(STV5730_REG_COLOR);
stv5730_write16bit(0x1000 + (STV5730_COL_SBACK << 9) +
(STV5730_COL_CBORD << 6) + STV5730_COL_CBACK);
// Zoom Register: Zoom first line
stv5730_write16bit (STV5730_REG_ZOOM);
stv5730_write16bit (0x1000 + 4);
stv5730_write16bit(STV5730_REG_ZOOM);
stv5730_write16bit(0x1000 + 4);
// Set the Row Attributes
for (i = 0; i <= 10; i++)
{
stv5730_write16bit (0x00C0 + i);
stv5730_write16bit (0x10C0);
}
for (i = 0; i <= 10; i++) {
stv5730_write16bit(0x00C0 + i);
stv5730_write16bit(0x10C0);
}
// Allocate our own framebuffer
stv5730_framebuf = malloc (STV5730_WID * STV5730_HGT);
if (!stv5730_framebuf)
{
stv5730_close (drvthis);
return -4;
}
stv5730_framebuf = malloc(STV5730_WID * STV5730_HGT);
if (stv5730_framebuf == NULL) {
report(RPT_ERR, "%s: unable to allocate framebuffer", drvthis->name);
stv5730_close(drvthis);
return -1;
}
// clear screen
memset (stv5730_framebuf, 0, STV5730_WID * STV5730_HGT);
memset(stv5730_framebuf, 0, STV5730_WID * STV5730_HGT);
report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 0;
}
@@ -405,7 +403,7 @@ MODULE_EXPORT void
stv5730_close (Driver *drvthis)
{
if (stv5730_framebuf != NULL)
free (stv5730_framebuf);
free(stv5730_framebuf);
stv5730_framebuf = NULL;
}
@@ -455,7 +453,7 @@ stv5730_cellheight (Driver *drvthis)
MODULE_EXPORT void
stv5730_clear (Driver *drvthis)
{
memset (stv5730_framebuf, 0x0B, STV5730_WID * STV5730_HGT);
memset(stv5730_framebuf, 0x0B, STV5730_WID * STV5730_HGT);
}
/////////////////////////////////////////////////////////////////
@@ -467,26 +465,24 @@ stv5730_flush (Driver *drvthis)
{
int i, j, atr;
stv5730_locate (0, 0);
stv5730_locate(0, 0);
for (i = 0; i < STV5730_HGT; i++)
{
for (i = 0; i < STV5730_HGT; i++) {
if (i == 0)
atr = (STV5730_COL_FLINE << 8);
else
atr = (STV5730_COL_TEXT << 8);
stv5730_write16bit (0x1000 + atr + stv5730_framebuf[i * STV5730_WID] +
stv5730_charattrib);
for (j = 1; j < STV5730_WID; j++)
{
for (j = 1; j < STV5730_WID; j++) {
if (stv5730_framebuf[j + (i * STV5730_WID) - 1] !=
stv5730_framebuf[j + (i * STV5730_WID)])
stv5730_write8bit (stv5730_framebuf[j + (i * STV5730_WID)]);
else
stv5730_write0bit ();
stv5730_write0bit();
};
}
}
}
}
/////////////////////////////////////////////////////////////////
@@ -497,13 +493,13 @@ MODULE_EXPORT void
stv5730_string (Driver *drvthis, int x, int y, char string[])
{
int i;
x--; // Convert 1-based coords to 0-based...
y--;
for (i = 0; string[i]; i++)
{
stv5730_drawchar2fb (x + i, y, string[i]);
}
for (i = 0; string[i] != '\0'; i++) {
stv5730_drawchar2fb(x + i, y, string[i]);
}
}
/////////////////////////////////////////////////////////////////
@@ -515,7 +511,7 @@ stv5730_chr (Driver *drvthis, int x, int y, char c)
{
y--;
x--;
stv5730_drawchar2fb (x, y, c);
stv5730_drawchar2fb(x, y, c);
}
/////////////////////////////////////////////////////////////////
@@ -525,7 +521,6 @@ stv5730_chr (Driver *drvthis, int x, int y, char c)
MODULE_EXPORT void
stv5730_num (Driver *drvthis, int x, int num)
{
int i, j;
x--;
@@ -536,19 +531,15 @@ stv5730_num (Driver *drvthis, int x, int num)
if (num == 10 && (x < 0 || x > 19))
return;
for (j = 1; j < 10; j++)
{
if (num != 10)
{
for (j = 1; j < 10; j++) {
if (num != 10) {
for (i = 0; i < 3; i++)
stv5730_drawchar2fb (x + i, j, '0' + num);
}
else
{
}
else {
stv5730_drawchar2fb (x, j, ':');
}
}
}
}
}
/////////////////////////////////////////////////////////////////
@@ -558,27 +549,21 @@ stv5730_num (Driver *drvthis, int x, int num)
MODULE_EXPORT void
stv5730_old_vbar (Driver *drvthis, int x, int len)
{
int i;
x--;
if (x < 0 || len < 0 || (len / 6) >= STV5730_WID)
return;
for (i = 0; i <= len; i += 6)
{
if (len >= (i + 6))
{
for (i = 0; i <= len; i += 6) {
if (len >= (i + 6)) {
stv5730_framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x77;
}
else
{
}
else {
stv5730_framebuf[((10 - (i / 6)) * STV5730_WID) + x] =
0x72 + (len % 6);
}
}
}
}
}
@@ -598,19 +583,15 @@ stv5730_old_hbar (Driver *drvthis, int x, int y, int len)
|| (x + (len / 5)) >= STV5730_WID)
return;
for (i = 0; i <= len; i += 5)
{
if (len >= (i + 4))
{
for (i = 0; i <= len; i += 5) {
if (len >= (i + 4)) {
stv5730_framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x64;
}
else
{
}
else {
stv5730_framebuf[(y * STV5730_WID) + x + (i / 5)] =
0x65 + (len % 5);
}
}
}
}
}
/////////////////////////////////////////////////////////////////
@@ -622,8 +603,7 @@ stv5730_old_hbar (Driver *drvthis, int x, int y, int len)
MODULE_EXPORT void
stv5730_old_icon (Driver *drvthis, int which, char dest)
{
switch (which)
{
switch (which) {
case 0: // 0:empty Heart
stv5730_to_ascii[(int) dest] = 0x71;
break;
@@ -636,7 +616,5 @@ stv5730_old_icon (Driver *drvthis, int which, char dest)
default:
stv5730_to_ascii[(int) dest] = 0x0B;
break;
}
}
+59 -55
View File
@@ -245,7 +245,7 @@ svgalib_drv_init (Driver *drvthis)
p->brightness = DEFAULT_BRIGHTNESS;
p->offbrightness = DEFAULT_OFFBRIGHTNESS;
debug (RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
debug(RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
/* Read config file */
@@ -257,11 +257,12 @@ svgalib_drv_init (Driver *drvthis)
strncpy(size, drvthis->config_get_string(drvthis->name, "Size",
0, DEFAULT_SIZE), sizeof(size));
size[sizeof(size) - 1] = '\0';
debug (RPT_INFO, "%s: Size (in config) is '%s'", __FUNCTION__, size);
debug(RPT_INFO, "%s: Size (in config) is '%s'", __FUNCTION__, size);
if ((sscanf(size, "%dx%d", &w, &h) != 2) ||
(w <= 0) || (w > LCD_MAX_WIDTH) ||
(h <= 0) || (h > LCD_MAX_HEIGHT)) {
report(RPT_WARNING, "svga: 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);
}
p->width = w;
@@ -277,24 +278,24 @@ svgalib_drv_init (Driver *drvthis)
p->height = LCD_DEFAULT_HEIGHT;
}
}
report(RPT_INFO, "%s: Using size %dx%d", __FUNCTION__, p->width, p->height);
report(RPT_INFO, "%s: using Size %dx%d", drvthis->name, p->width, p->height);
/* Which backlight brightness */
tmp = drvthis->config_get_int (drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
debug (RPT_INFO, "%s: Brightness (in config) is '%d'", __FUNCTION__, tmp);
tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
debug(RPT_INFO, "%s: Brightness (in config) is '%d'", __FUNCTION__, tmp);
if ((tmp < 0) || (tmp > 1000)) {
report (RPT_WARNING, "%s: Brightness must be between 0 and 1000. Using default %d.\n",
__FUNCTION__, DEFAULT_BRIGHTNESS);
report(RPT_WARNING, "%s: Brightness must be between 0 and 1000; using default %d",
drvthis->name, DEFAULT_BRIGHTNESS);
tmp = DEFAULT_BRIGHTNESS;
}
p->brightness = tmp;
/* Which backlight-off "brightness" */
tmp = drvthis->config_get_int (drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
debug (RPT_INFO, "%s: OffBrightness (in config) is '%d'", __FUNCTION__, tmp);
tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
debug(RPT_INFO, "%s: OffBrightness (in config) is '%d'", __FUNCTION__, tmp);
if ((tmp < 0) || (tmp > 1000)) {
report (RPT_WARNING, "%s: OffBrightness must be between 0 and 1000. Using default %d.\n",
__FUNCTION__, DEFAULT_OFFBRIGHTNESS);
report(RPT_WARNING, "%s: OffBrightness must be between 0 and 1000. Using default %d",
drvthis->name, DEFAULT_OFFBRIGHTNESS);
tmp = DEFAULT_OFFBRIGHTNESS;
}
p->offbrightness = tmp;
@@ -303,25 +304,25 @@ svgalib_drv_init (Driver *drvthis)
strncpy(modestr, drvthis->config_get_string(drvthis->name, "Mode",
0, DEFAULT_MODESTR), sizeof(modestr));
modestr[sizeof(modestr) - 1] = '\0';
debug (RPT_INFO, "%s: Mode (in config) is '%s'", __FUNCTION__, modestr);
debug(RPT_INFO, "%s: Mode (in config) is '%s'", __FUNCTION__, modestr);
/* initialize svgalib library */
if (vga_init() != 0) {
report(RPT_ERR, "svga: vga_init() failed.");
report(RPT_ERR, "%s: vga_init() failed", drvthis->name);
return -1;
}
/* check for legal VGA mode */
tmp = vga_getmodenumber(modestr);
if (tmp <= 0) {
report(RPT_ERR, "svga: illegal VGA mode %s.", modestr);
report(RPT_ERR, "%s: illegal VGA mode %s", drvthis->name, modestr);
return -1;
}
p->mode = tmp;
/* switch to selected VGA mode if it is available */
if (!vga_hasmode (p->mode)) {
report(RPT_ERR, "svga: VGA mode %s not available.", modestr);
report(RPT_ERR, "%s: VGA mode %s not available.", drvthis->name, modestr);
return -1;
}
@@ -338,26 +339,28 @@ svgalib_drv_init (Driver *drvthis)
p->yoffs = p->cellheight + (modeinfo->height - p->height * p->cellheight) / 2;
if (vga_setmode (p->mode) < 0) {
report(RPT_ERR, "svga: unable to switch to mode %s", modestr);
report(RPT_ERR, "%s: unable to switch to mode %s", drvthis->name, modestr);
return -1;
}
gl_setcontextvga (p->mode); /* Physical screen context. */
gl_setrgbpalette ();
gl_setcontextvga(p->mode); /* Physical screen context. */
gl_setrgbpalette();
/* allocate space, expand and install the font */
p->font = malloc (256 * p->cellheight * p->cellwidth * modeinfo->bytesperpixel);
p->font = malloc(256 * p->cellheight * p->cellwidth * modeinfo->bytesperpixel);
if (p->font == NULL) {
report(RPT_ERR, "svga: unable to allocate font memory");
report(RPT_ERR, "%s: unable to allocate font memory", drvthis->name);
return -1;
}
tmp = (p->brightness * 255) / 1000;
if (tmp <= 0)
tmp = 1;
ExpandGroovyFont (p->cellwidth, p->cellheight, gl_rgbcolor(tmp, tmp, tmp), simple_font6x8, p->font);
gl_setfont (p->cellwidth, p->cellheight, p->font);
ExpandGroovyFont(p->cellwidth, p->cellheight, gl_rgbcolor(tmp, tmp, tmp), simple_font6x8, p->font);
gl_setfont(p->cellwidth, p->cellheight, p->font);
gl_clearscreen (gl_rgbcolor (0, 0, 0));
gl_clearscreen(gl_rgbcolor (0, 0, 0));
report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 0;
}
@@ -371,7 +374,7 @@ svgalib_drv_close (Driver *drvthis)
{
PrivateData *p = drvthis->private_data;
debug (RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
debug(RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
if (p != NULL) {
if (p->font != NULL)
@@ -382,7 +385,7 @@ svgalib_drv_close (Driver *drvthis)
}
drvthis->store_private_ptr(drvthis, NULL);
vga_setmode (TEXT);
vga_setmode(TEXT);
}
@@ -440,10 +443,10 @@ svgalib_drv_cellheight (Driver *drvthis)
MODULE_EXPORT void
svgalib_drv_clear (Driver * drvthis)
{
debug (RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
debug(RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
//vga_waitretrace ();
gl_clearscreen (gl_rgbcolor (0, 0, 0));
gl_clearscreen(gl_rgbcolor(0, 0, 0));
}
@@ -467,20 +470,21 @@ svgalib_drv_string (Driver *drvthis, int x, int y, char string[])
PrivateData *p = drvthis->private_data;
int i;
debug (RPT_DEBUG, "%s(%p, %d, %d, \"%s\")", __FUNCTION__, drvthis, x, y, string);
debug(RPT_DEBUG, "%s(%p, %d, %d, \"%s\")", __FUNCTION__, drvthis, x, y, string);
for (i = 0; string[i] != '\0'; i++) {
unsigned char *c = &string[i];
switch (*c) {
case '\0':
*c = icon_char;
break;
case 255:
*c = '#';
break;
case '\0':
*c = icon_char;
break;
case 255:
*c = '#';
break;
}
}
gl_writen (x * p->cellwidth + p->xoffs, y * p->cellheight + p->yoffs, i, string);
gl_writen(x * p->cellwidth + p->xoffs, y * p->cellheight + p->yoffs, i, string);
}
@@ -494,19 +498,19 @@ svgalib_drv_chr (Driver *drvthis, int x, int y, char c)
PrivateData *p = drvthis->private_data;
char buffer[2];
debug (RPT_DEBUG, "%s(%p, %d, %d, \'%c\')", __FUNCTION__, drvthis, x, y, c);
debug(RPT_DEBUG, "%s(%p, %d, %d, \'%c\')", __FUNCTION__, drvthis, x, y, c);
switch ((unsigned char) c) {
case '\0':
c = icon_char;
break;
case 255:
c = '#';
break;
case '\0':
c = icon_char;
break;
case 255:
c = '#';
break;
}
buffer[0] = c;
buffer[1] = '\0';
gl_writen (x * p->cellwidth + p->xoffs, y * p->cellheight + p->yoffs, 1, buffer);
gl_writen(x * p->cellwidth + p->xoffs, y * p->cellheight + p->yoffs, 1, buffer);
}
@@ -519,13 +523,13 @@ svgalib_drv_num (Driver *drvthis, int x, int num)
char c;
int y, dx;
debug (RPT_DEBUG, "%s(%p, %d, %d)", __FUNCTION__, drvthis, x, num);
debug(RPT_DEBUG, "%s(%p, %d, %d)", __FUNCTION__, drvthis, x, num);
c = '0' + num;
for (y = 1; y < 5; y++)
for (dx = 0; dx < 3; dx++)
svgalib_drv_chr (drvthis, x + dx, y, c);
svgalib_drv_chr(drvthis, x + dx, y, c);
}
@@ -537,11 +541,11 @@ svgalib_drv_vbar (Driver *drvthis, int x, int y, int len, int promille, int patt
{
int pos;
debug (RPT_DEBUG, "%s(%p, %d, %d, %d, %d, %02x)", __FUNCTION__, drvthis, x, y, len, promille, pattern);
debug(RPT_DEBUG, "%s(%p, %d, %d, %d, %d, %02x)", __FUNCTION__, drvthis, x, y, len, promille, pattern);
for (pos = 0; pos < len; pos++) {
if (2 * pos < ((long) promille * len / 500 + 1)) {
svgalib_drv_chr (drvthis, x, y-pos, '|');
svgalib_drv_chr(drvthis, x, y-pos, '|');
} else {
; /* print nothing */
}
@@ -557,11 +561,11 @@ svgalib_drv_hbar (Driver *drvthis, int x, int y, int len, int promille, int patt
{
int pos;
debug (RPT_DEBUG, "%s(%p, %d, %d, %d, %d, %02x)", __FUNCTION__, drvthis, x, y, len, promille, pattern);
debug(RPT_DEBUG, "%s(%p, %d, %d, %d, %d, %02x)", __FUNCTION__, drvthis, x, y, len, promille, pattern);
for (pos = 0; pos < len; pos++) {
if (2 * pos < ((long) promille * len / 500 + 1)) {
svgalib_drv_chr (drvthis, x+pos, y, '-');
svgalib_drv_chr(drvthis, x+pos, y, '-');
} else {
; /* print nothing */
}
@@ -578,20 +582,20 @@ svgalib_drv_get_key (Driver *drvthis)
static char buf[2] = " ";
int key = vga_getkey ();
debug (RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
debug(RPT_DEBUG, "%s(%p)", __FUNCTION__, drvthis);
if (key <= 0) /* no key */
return NULL;
switch (key) {
case 0x1B: /* ESC may introduce special key sequence */
key = vga_getkey ();
key = vga_getkey();
if (key == 0) /* alone it is "Escape" */
return "Escape";
if (key == 0x5B) { /* 0x1B 0x5B 0x??: cursor keys */
key = vga_getkey ();
key = vga_getkey();
switch (key) {
case VGAKEY_LEFT:
return "Left";
@@ -641,7 +645,7 @@ svgalib_drv_set_contrast (Driver *drvthis, int promille)
int contrast;
/* Check it */
if (promille < 0 || promille > 1000)
if ((promille < 0) || (promille > 1000))
return;
/* store the software value since there is not get */
@@ -675,7 +679,7 @@ svgalib_drv_set_brightness(Driver *drvthis, int state, int promille)
PrivateData *p = drvthis->private_data;
/* Check it */
if (promille < 0 || promille > 1000)
if ((promille < 0) || (promille > 1000))
return;
/* store the software value since there is no get */