s390/tty3270: move ASCII->EBCDIC conversion to convert_line()
authorSven Schnelle <svens@linux.ibm.com>
Sat, 26 Nov 2022 22:39:16 +0000 (23:39 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 9 Jan 2023 13:34:00 +0000 (14:34 +0100)
Instead of always converting the character set, only convert them
when the line is really displayed.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/s390/char/con3270.c

index 3c4e9f8a50d0d93f56f4f6aadabcde2bf6183d32..488d280a844d1ff51e9d4f3b11962f03ad56929d 100644 (file)
@@ -430,8 +430,38 @@ static char *tty3270_add_reset_attributes(struct tty3270 *tp, struct tty3270_lin
        return cp;
 }
 
-static char *tty3270_add_attributes(struct tty3270_line *line, struct tty3270_attribute *attr,
-                                   char *cp)
+static char tty3270_graphics_translate(struct tty3270 *tp, char ch)
+{
+       switch (ch) {
+       case 'q': /* - */
+               return 0xa2;
+       case 'x': /* '|' */
+               return 0x85;
+       case 'l': /* |- */
+               return 0xc5;
+       case 't': /* |_ */
+               return 0xc6;
+       case 'u': /* _| */
+               return 0xd6;
+       case 'k': /* -| */
+               return 0xd5;
+       case 'j':
+               return 0xd4;
+       case 'm':
+               return 0xc4;
+       case 'n': /* + */
+               return 0xd3;
+       case 'v':
+               return 0xc7;
+       case 'w':
+               return 0xd7;
+       default:
+               return ch;
+       }
+}
+
+static char *tty3270_add_attributes(struct tty3270 *tp, struct tty3270_line *line,
+                                   struct tty3270_attribute *attr, char *cp)
 {
        struct tty3270_cell *cell;
        int i;
@@ -459,9 +489,12 @@ static char *tty3270_add_attributes(struct tty3270_line *line, struct tty3270_at
                        *cp++ = cell->attributes.b_color;
                        attr->b_color = cell->attributes.b_color;
                }
-               if (cell->attributes.alternate_charset)
+               if (cell->attributes.alternate_charset) {
                        *cp++ = TO_GE;
-               *cp++ = cell->character;
+                       *cp++ = tty3270_graphics_translate(tp, cell->character);
+               } else {
+                       *cp++ = tp->view.ascebc[(int)cell->character];
+               }
        }
        return cp;
 }
@@ -511,7 +544,7 @@ static void tty3270_convert_line(struct tty3270 *tp, int line_nr)
 
        /* Write 3270 data fragment. */
        tty3270_reset_attributes(&attr);
-       cp = tty3270_add_attributes(line, &attr, s->string);
+       cp = tty3270_add_attributes(tp, line, &attr, s->string);
        cp = tty3270_add_reset_attributes(tp, line, cp, &attr);
        if (tp->nr_up + line_nr < tty3270_tty_rows(tp)) {
                /* Line is currently visible on screen. */
@@ -1241,36 +1274,6 @@ static unsigned int tty3270_write_room(struct tty_struct *tty)
        return INT_MAX;
 }
 
-static char tty3270_graphics_translate(struct tty3270 *tp, char ch)
-{
-       switch (ch) {
-       case 'q': /* - */
-               return 0xa2;
-       case 'x': /* '|' */
-               return 0x85;
-       case 'l': /* |- */
-               return 0xc5;
-       case 't': /* |_ */
-               return 0xc6;
-       case 'u': /* _| */
-               return 0xd6;
-       case 'k': /* -| */
-               return 0xd5;
-       case 'j':
-               return 0xd4;
-       case 'm':
-               return 0xc4;
-       case 'n': /* + */
-               return 0xd3;
-       case 'v':
-               return 0xc7;
-       case 'w':
-               return 0xd7;
-       default:
-               return ch;
-       }
-}
-
 /*
  * Insert character into the screen at the current position with the
  * current color and highlight. This function does NOT do cursor movement.
@@ -1284,17 +1287,14 @@ static void tty3270_put_character(struct tty3270 *tp, char ch)
        if (line->len <= tp->cx) {
                while (line->len < tp->cx) {
                        cell = line->cells + line->len;
-                       cell->character = tp->view.ascebc[' '];
+                       cell->character = ' ';
                        cell->attributes = tp->attributes;
                        line->len++;
                }
                line->len++;
        }
        cell = line->cells + tp->cx;
-       if (tp->attributes.alternate_charset)
-               cell->character = tty3270_graphics_translate(tp, ch);
-       else
-               cell->character = tp->view.ascebc[(unsigned int)ch];
+       cell->character = ch;
        cell->attributes = tp->attributes;
 }
 
@@ -1339,7 +1339,7 @@ static void tty3270_ri(struct tty3270 *tp)
 
 static void tty3270_reset_cell(struct tty3270 *tp, struct tty3270_cell *cell)
 {
-       cell->character = tp->view.ascebc[' '];
+       cell->character = ' ';
        tty3270_reset_attributes(&cell->attributes);
 }
 
@@ -1363,7 +1363,7 @@ static void tty3270_insert_characters(struct tty3270 *tp, int n)
        if (line->len > tp->view.cols)
                line->len = tp->view.cols;
        while (n-- > 0) {
-               line->cells[tp->cx + n].character = tp->view.ascebc[' '];
+               line->cells[tp->cx + n].character = ' ';
                line->cells[tp->cx + n].attributes = tp->attributes;
        }
 }