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
+35 -57
View File
@@ -293,24 +293,23 @@ stv5730_init (Driver *drvthis)
/* End of config file parsing */ /* End of config file parsing */
if (timing_init() == -1) { 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; return -1;
} }
// Initialize the Port and the stv5730 // 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, report(RPT_ERR,
"Couldn't get IO-permission for 0x%X ! Are we running as root ?\n ", "%s: cannot get IO-permission for 0x%03X! Are we running as root?",
stv5730_lptport); drvthis->name, stv5730_lptport);
return -1; return -1;
}; }
if (stv5730_detect ()) if (stv5730_detect()) {
{ report(RPT_ERR, "%s: no STV5730 hardware found at 0x%03X ",
report(RPT_ERR, "No STV5730 hardware found at 0x%X !\n ", stv5730_lptport); drvthis->name, stv5730_lptport);
return -1; return -1;
}; }
port_out(stv5730_lptport, 0); port_out(stv5730_lptport, 0);
@@ -327,12 +326,11 @@ stv5730_init (Driver *drvthis)
stv5730_write16bit(STV5730_REG_CONTROL); stv5730_write16bit(STV5730_REG_CONTROL);
stv5730_write16bit(0x1FF4); stv5730_write16bit(0x1FF4);
report(RPT_INFO, "Detecting Video Signal: "); report(RPT_INFO, "%s: detecting video signal: ", drvthis->name);
usleep (50000); usleep (50000);
if (stv5730_is_mute ()) if (stv5730_is_mute()) {
{ report(RPT_INFO, "%s: no video signal found; using full page mode", drvthis->name);
report(RPT_INFO, "No Video Signal found, using full page mode.\n");
// Setup Mode + Control for full page mode // Setup Mode + Control for full page mode
stv5730_charattrib = STV5730_ATTRIB; stv5730_charattrib = STV5730_ATTRIB;
stv5730_write16bit(STV5730_REG_MODE); stv5730_write16bit(STV5730_REG_MODE);
@@ -347,9 +345,8 @@ stv5730_init (Driver *drvthis)
#endif #endif
} }
else else {
{ report(RPT_INFO, "%s: video signal found, using mixed mode (B&W)", drvthis->name);
report(RPT_INFO, "Video Signal found, using mixed mode (B&W).\n");
// Setup Mode + Control for mixed mode, disable color // Setup Mode + Control for mixed mode, disable color
stv5730_charattrib = 0; stv5730_charattrib = 0;
stv5730_write16bit(STV5730_REG_MODE); stv5730_write16bit(STV5730_REG_MODE);
@@ -378,23 +375,24 @@ stv5730_init (Driver *drvthis)
stv5730_write16bit(0x1000 + 4); stv5730_write16bit(0x1000 + 4);
// Set the Row Attributes // Set the Row Attributes
for (i = 0; i <= 10; i++) for (i = 0; i <= 10; i++) {
{
stv5730_write16bit(0x00C0 + i); stv5730_write16bit(0x00C0 + i);
stv5730_write16bit(0x10C0); stv5730_write16bit(0x10C0);
} }
// Allocate our own framebuffer // Allocate our own framebuffer
stv5730_framebuf = malloc(STV5730_WID * STV5730_HGT); stv5730_framebuf = malloc(STV5730_WID * STV5730_HGT);
if (!stv5730_framebuf) if (stv5730_framebuf == NULL) {
{ report(RPT_ERR, "%s: unable to allocate framebuffer", drvthis->name);
stv5730_close(drvthis); stv5730_close(drvthis);
return -4; return -1;
} }
// clear screen // 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; return 0;
} }
@@ -469,23 +467,21 @@ stv5730_flush (Driver *drvthis)
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) if (i == 0)
atr = (STV5730_COL_FLINE << 8); atr = (STV5730_COL_FLINE << 8);
else else
atr = (STV5730_COL_TEXT << 8); atr = (STV5730_COL_TEXT << 8);
stv5730_write16bit (0x1000 + atr + stv5730_framebuf[i * STV5730_WID] + stv5730_write16bit (0x1000 + atr + stv5730_framebuf[i * STV5730_WID] +
stv5730_charattrib); stv5730_charattrib);
for (j = 1; j < STV5730_WID; j++) for (j = 1; j < STV5730_WID; j++) {
{
if (stv5730_framebuf[j + (i * STV5730_WID) - 1] != if (stv5730_framebuf[j + (i * STV5730_WID) - 1] !=
stv5730_framebuf[j + (i * STV5730_WID)]) stv5730_framebuf[j + (i * STV5730_WID)])
stv5730_write8bit (stv5730_framebuf[j + (i * STV5730_WID)]); stv5730_write8bit (stv5730_framebuf[j + (i * STV5730_WID)]);
else else
stv5730_write0bit(); stv5730_write0bit();
}; }
} }
} }
@@ -497,11 +493,11 @@ MODULE_EXPORT void
stv5730_string (Driver *drvthis, int x, int y, char string[]) stv5730_string (Driver *drvthis, int x, int y, char string[])
{ {
int i; int i;
x--; // Convert 1-based coords to 0-based... x--; // Convert 1-based coords to 0-based...
y--; y--;
for (i = 0; string[i]; i++) for (i = 0; string[i] != '\0'; i++) {
{
stv5730_drawchar2fb(x + i, y, string[i]); stv5730_drawchar2fb(x + i, y, string[i]);
} }
} }
@@ -525,7 +521,6 @@ stv5730_chr (Driver *drvthis, int x, int y, char c)
MODULE_EXPORT void MODULE_EXPORT void
stv5730_num (Driver *drvthis, int x, int num) stv5730_num (Driver *drvthis, int x, int num)
{ {
int i, j; int i, j;
x--; x--;
@@ -536,19 +531,15 @@ stv5730_num (Driver *drvthis, int x, int num)
if (num == 10 && (x < 0 || x > 19)) if (num == 10 && (x < 0 || x > 19))
return; return;
for (j = 1; j < 10; j++) for (j = 1; j < 10; j++) {
{ if (num != 10) {
if (num != 10)
{
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
stv5730_drawchar2fb (x + i, j, '0' + num); stv5730_drawchar2fb (x + i, j, '0' + num);
} }
else else {
{
stv5730_drawchar2fb (x, j, ':'); stv5730_drawchar2fb (x, j, ':');
} }
} }
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@@ -558,27 +549,21 @@ stv5730_num (Driver *drvthis, int x, int num)
MODULE_EXPORT void MODULE_EXPORT void
stv5730_old_vbar (Driver *drvthis, int x, int len) stv5730_old_vbar (Driver *drvthis, int x, int len)
{ {
int i; int i;
x--; x--;
if (x < 0 || len < 0 || (len / 6) >= STV5730_WID) if (x < 0 || len < 0 || (len / 6) >= STV5730_WID)
return; return;
for (i = 0; i <= len; i += 6) for (i = 0; i <= len; i += 6) {
{ if (len >= (i + 6)) {
if (len >= (i + 6))
{
stv5730_framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x77; stv5730_framebuf[((10 - (i / 6)) * STV5730_WID) + x] = 0x77;
} }
else else {
{
stv5730_framebuf[((10 - (i / 6)) * STV5730_WID) + x] = stv5730_framebuf[((10 - (i / 6)) * STV5730_WID) + x] =
0x72 + (len % 6); 0x72 + (len % 6);
} }
} }
} }
@@ -598,15 +583,11 @@ stv5730_old_hbar (Driver *drvthis, int x, int y, int len)
|| (x + (len / 5)) >= STV5730_WID) || (x + (len / 5)) >= STV5730_WID)
return; return;
for (i = 0; i <= len; i += 5) for (i = 0; i <= len; i += 5) {
{ if (len >= (i + 4)) {
if (len >= (i + 4))
{
stv5730_framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x64; stv5730_framebuf[(y * STV5730_WID) + x + (i / 5)] = 0x64;
} }
else else {
{
stv5730_framebuf[(y * STV5730_WID) + x + (i / 5)] = stv5730_framebuf[(y * STV5730_WID) + x + (i / 5)] =
0x65 + (len % 5); 0x65 + (len % 5);
} }
@@ -622,8 +603,7 @@ stv5730_old_hbar (Driver *drvthis, int x, int y, int len)
MODULE_EXPORT void MODULE_EXPORT void
stv5730_old_icon (Driver *drvthis, int which, char dest) stv5730_old_icon (Driver *drvthis, int which, char dest)
{ {
switch (which) switch (which) {
{
case 0: // 0:empty Heart case 0: // 0:empty Heart
stv5730_to_ascii[(int) dest] = 0x71; stv5730_to_ascii[(int) dest] = 0x71;
break; break;
@@ -636,7 +616,5 @@ stv5730_old_icon (Driver *drvthis, int which, char dest)
default: default:
stv5730_to_ascii[(int) dest] = 0x0B; stv5730_to_ascii[(int) dest] = 0x0B;
break; break;
} }
} }
+17 -13
View File
@@ -261,7 +261,8 @@ svgalib_drv_init (Driver *drvthis)
if ((sscanf(size, "%dx%d", &w, &h) != 2) || if ((sscanf(size, "%dx%d", &w, &h) != 2) ||
(w <= 0) || (w > LCD_MAX_WIDTH) || (w <= 0) || (w > LCD_MAX_WIDTH) ||
(h <= 0) || (h > LCD_MAX_HEIGHT)) { (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); sscanf(DEFAULT_SIZE, "%dx%d", &w, &h);
} }
p->width = w; p->width = w;
@@ -277,14 +278,14 @@ svgalib_drv_init (Driver *drvthis)
p->height = LCD_DEFAULT_HEIGHT; 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 */ /* Which backlight brightness */
tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS); tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_BRIGHTNESS);
debug(RPT_INFO, "%s: Brightness (in config) is '%d'", __FUNCTION__, tmp); debug(RPT_INFO, "%s: Brightness (in config) is '%d'", __FUNCTION__, tmp);
if ((tmp < 0) || (tmp > 1000)) { if ((tmp < 0) || (tmp > 1000)) {
report (RPT_WARNING, "%s: Brightness must be between 0 and 1000. Using default %d.\n", report(RPT_WARNING, "%s: Brightness must be between 0 and 1000; using default %d",
__FUNCTION__, DEFAULT_BRIGHTNESS); drvthis->name, DEFAULT_BRIGHTNESS);
tmp = DEFAULT_BRIGHTNESS; tmp = DEFAULT_BRIGHTNESS;
} }
p->brightness = tmp; p->brightness = tmp;
@@ -293,8 +294,8 @@ svgalib_drv_init (Driver *drvthis)
tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS); tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFFBRIGHTNESS);
debug(RPT_INFO, "%s: OffBrightness (in config) is '%d'", __FUNCTION__, tmp); debug(RPT_INFO, "%s: OffBrightness (in config) is '%d'", __FUNCTION__, tmp);
if ((tmp < 0) || (tmp > 1000)) { if ((tmp < 0) || (tmp > 1000)) {
report (RPT_WARNING, "%s: OffBrightness must be between 0 and 1000. Using default %d.\n", report(RPT_WARNING, "%s: OffBrightness must be between 0 and 1000. Using default %d",
__FUNCTION__, DEFAULT_OFFBRIGHTNESS); drvthis->name, DEFAULT_OFFBRIGHTNESS);
tmp = DEFAULT_OFFBRIGHTNESS; tmp = DEFAULT_OFFBRIGHTNESS;
} }
p->offbrightness = tmp; p->offbrightness = tmp;
@@ -307,21 +308,21 @@ svgalib_drv_init (Driver *drvthis)
/* initialize svgalib library */ /* initialize svgalib library */
if (vga_init() != 0) { if (vga_init() != 0) {
report(RPT_ERR, "svga: vga_init() failed."); report(RPT_ERR, "%s: vga_init() failed", drvthis->name);
return -1; return -1;
} }
/* check for legal VGA mode */ /* check for legal VGA mode */
tmp = vga_getmodenumber(modestr); tmp = vga_getmodenumber(modestr);
if (tmp <= 0) { 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; return -1;
} }
p->mode = tmp; p->mode = tmp;
/* switch to selected VGA mode if it is available */ /* switch to selected VGA mode if it is available */
if (!vga_hasmode (p->mode)) { 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; return -1;
} }
@@ -338,7 +339,7 @@ svgalib_drv_init (Driver *drvthis)
p->yoffs = p->cellheight + (modeinfo->height - p->height * p->cellheight) / 2; p->yoffs = p->cellheight + (modeinfo->height - p->height * p->cellheight) / 2;
if (vga_setmode (p->mode) < 0) { 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; return -1;
} }
gl_setcontextvga(p->mode); /* Physical screen context. */ gl_setcontextvga(p->mode); /* Physical screen context. */
@@ -347,7 +348,7 @@ svgalib_drv_init (Driver *drvthis)
/* allocate space, expand and install the font */ /* 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) { 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; return -1;
} }
@@ -359,6 +360,8 @@ svgalib_drv_init (Driver *drvthis)
gl_clearscreen(gl_rgbcolor (0, 0, 0)); gl_clearscreen(gl_rgbcolor (0, 0, 0));
report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 0; return 0;
} }
@@ -471,6 +474,7 @@ svgalib_drv_string (Driver *drvthis, int x, int y, char string[])
for (i = 0; string[i] != '\0'; i++) { for (i = 0; string[i] != '\0'; i++) {
unsigned char *c = &string[i]; unsigned char *c = &string[i];
switch (*c) { switch (*c) {
case '\0': case '\0':
*c = icon_char; *c = icon_char;
@@ -641,7 +645,7 @@ svgalib_drv_set_contrast (Driver *drvthis, int promille)
int contrast; int contrast;
/* Check it */ /* Check it */
if (promille < 0 || promille > 1000) if ((promille < 0) || (promille > 1000))
return; return;
/* store the software value since there is not get */ /* 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; PrivateData *p = drvthis->private_data;
/* Check it */ /* Check it */
if (promille < 0 || promille > 1000) if ((promille < 0) || (promille > 1000))
return; return;
/* store the software value since there is no get */ /* store the software value since there is no get */