[BRLTTY] Only question mark characters when running brltty in ppc ubuntu and ppc debian etch
Samuel Thibault
samuel.thibault at ens-lyon.org
Mon Dec 10 06:09:32 EST 2007
Hi,
Samuel Thibault, le Sun 09 Dec 2007 23:45:44 +0100, a écrit :
> Dave, we should hence probably fix the linux screen driver into reading
> short ints instead of reading bytes.
Here is a patch, completely unstested, though.
Samuel
-------------- next part --------------
Index: ScreenDrivers/Linux/screen.c
===================================================================
--- ScreenDrivers/Linux/screen.c (révision 3406)
+++ ScreenDrivers/Linux/screen.c (copie de travail)
@@ -445,19 +445,19 @@
return 1;
}
-static unsigned char highFontBit;
-static unsigned char fontAttributesMask;
-static unsigned char unshiftedAttributesMask;
-static unsigned char shiftedAttributesMask;
+static unsigned short highFontBit;
+static unsigned short fontAttributesMask;
+static unsigned short unshiftedAttributesMask;
+static unsigned short shiftedAttributesMask;
static void
setAttributesMasks (unsigned char bit) {
fontAttributesMask = bit;
- unshiftedAttributesMask = (((bit & 0XF0) - 0X10) & 0XF0) |
- (((bit & 0X0F) - 0X01) & 0X0F);
- shiftedAttributesMask = ((~((bit & 0XF0) - 0X10) << 1) & 0XE0) |
- ((~((bit & 0X0F) - 0X01) << 1) & 0X0E);
- LogPrint(LOG_DEBUG, "attributes masks: font=%02X unshifted=%02X shifted=%02X",
+ unshiftedAttributesMask = (((bit & 0XF000) - 0X1000) & 0XF000) |
+ (((bit & 0X0F00) - 0X0100) & 0X0F00);
+ shiftedAttributesMask = ((~((bit & 0XF000) - 0X1000) << 1) & 0XE000) |
+ ((~((bit & 0X0F00) - 0X0100) << 1) & 0X0E00);
+ LogPrint(LOG_DEBUG, "attributes masks: font=%04X unshifted=%04X shifted=%04X",
fontAttributesMask, unshiftedAttributesMask, shiftedAttributesMask);
}
@@ -476,10 +476,8 @@
unsigned short mask;
if (controlConsole(VT_GETHIFONTMASK, &mask) == -1) {
if (errno != EINVAL) LogError("ioctl[VT_GETHIFONTMASK]");
- } else if (mask & 0XFF) {
- LogPrint(LOG_ERR, "high font mask has bit set in low-order byte: %04X", mask);
} else {
- setAttributesMasks(mask >> 8);
+ setAttributesMasks(mask);
return 1;
}
}
@@ -489,17 +487,16 @@
if (read(screenDescriptor, attributes, sizeof(attributes)) != -1) {
const size_t count = attributes[0] * attributes[1];
- const size_t size = count * 2;
- unsigned char buffer[size];
+ unsigned short buffer[count];
if (read(screenDescriptor, buffer, sizeof(buffer)) != -1) {
int counts[0X10];
int index;
memset(counts, 0, sizeof(counts));
- for (index=1; index<size; index+=2) ++counts[buffer[index] & 0X0F];
+ for (index=0; index<count; index++) ++counts[(buffer[index] & 0X0F00) >> 8];
- setAttributesMasks((counts[0XE] > counts[0X7])? 0X01: 0X08);
+ setAttributesMasks((counts[0XE] > counts[0X7])? 0X0100: 0X0800);
return 1;
} else {
LogError("read");
@@ -538,7 +535,7 @@
} else if (!validateChoice(&choice, parameters[PARM_HFB], choices)) {
LogPrint(LOG_WARNING, "%s: %s", "invalid high font bit", parameters[PARM_HFB]);
} else if (choice) {
- static const unsigned char bits[] = {0X08, 0X01};
+ static const unsigned short bits[] = {0X0800, 0X0100};
highFontBit = bits[choice-1];
}
}
@@ -919,13 +916,13 @@
off_t start = 4 + (box.top * description.cols + box.left) * 2;
if (lseek(screenDescriptor, start, SEEK_SET) != -1) {
int length = box.width * 2;
- unsigned char line[length];
+ unsigned short line[box.width];
unsigned char *target = buffer;
off_t increment = description.cols * 2 - length;
int row;
for (row=0; row<box.height; ++row) {
int count;
- unsigned char *source;
+ unsigned short *source;
if (row) {
if (lseek(screenDescriptor, increment, SEEK_CUR) == -1) {
@@ -951,11 +948,11 @@
unsigned char *trg = target;
int column;
for (column=0; column<box.width; ++column) {
- int position = *source;
- if (source[1] & fontAttributesMask) position |= 0X100;
- src[column] = *source;
+ int position = *source & 0xFF;
+ if (*source & fontAttributesMask) position |= 0X100;
+ src[column] = *source & 0xFF;
*target++ = translationTable[position];
- source += 2;
+ source++;
}
if (debugScreenTextTranslation) {
char desc[0X20];
@@ -966,11 +963,10 @@
}
} else {
int column;
- source++;
for (column=0; column<box.width; ++column) {
*target++ = (*source & unshiftedAttributesMask) |
((*source & shiftedAttributesMask) >> 1);
- source += 2;
+ source++;
}
}
}
More information about the BRLTTY
mailing list