Commit f77f936a authored by Sven Schnelle's avatar Sven Schnelle Committed by Heiko Carstens

s390/raw3270: make raw3270_buffer_address() accept x/y coordinates

All callers of raw3270_buffer_address() are calculating the offset
from some x/y coordinates. Move that calculation inside of the
function, so user can pass the x/y values directly. Note that
negative values are relative to the end-of-line or end-of-screen.
Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Tested-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent b2057c87
...@@ -133,6 +133,7 @@ struct tty3270 { ...@@ -133,6 +133,7 @@ struct tty3270 {
#define TTY_UPDATE_ALL 16 /* Recreate screen. */ #define TTY_UPDATE_ALL 16 /* Recreate screen. */
#define TTY3270_INPUT_AREA_ROWS 2 #define TTY3270_INPUT_AREA_ROWS 2
static void tty3270_update(struct timer_list *); static void tty3270_update(struct timer_list *);
/* /*
* Setup timeout for a device. On timeout trigger an update. * Setup timeout for a device. On timeout trigger an update.
...@@ -153,7 +154,6 @@ static int tty3270_tty_rows(struct tty3270 *tp) ...@@ -153,7 +154,6 @@ static int tty3270_tty_rows(struct tty3270 *tp)
static void tty3270_update_prompt(struct tty3270 *tp, char *input, int count) static void tty3270_update_prompt(struct tty3270 *tp, char *input, int count)
{ {
struct string *line; struct string *line;
unsigned int off;
line = tp->prompt; line = tp->prompt;
if (count != 0) if (count != 0)
...@@ -168,8 +168,7 @@ static void tty3270_update_prompt(struct tty3270 *tp, char *input, int count) ...@@ -168,8 +168,7 @@ static void tty3270_update_prompt(struct tty3270 *tp, char *input, int count)
if (count < tp->view.cols * 2 - 11) { if (count < tp->view.cols * 2 - 11) {
line->string[7 + count] = TO_RA; line->string[7 + count] = TO_RA;
line->string[10 + count] = 0; line->string[10 + count] = 0;
off = tp->view.cols * tp->view.rows - 9; raw3270_buffer_address(tp->view.dev, line->string+count+8, -9, -1);
raw3270_buffer_address(tp->view.dev, line->string+count+8, off);
line->len = 11 + count; line->len = 11 + count;
} else } else
line->len = 7 + count; line->len = 7 + count;
...@@ -183,7 +182,6 @@ static void tty3270_create_prompt(struct tty3270 *tp) ...@@ -183,7 +182,6 @@ static void tty3270_create_prompt(struct tty3270 *tp)
/* empty input string */ /* empty input string */
TO_IC, TO_RA, 0, 0, 0 }; TO_IC, TO_RA, 0, 0, 0 };
struct string *line; struct string *line;
unsigned int offset;
line = alloc_string(&tp->freemem, line = alloc_string(&tp->freemem,
sizeof(blueprint) + tp->view.cols * 2 - 9); sizeof(blueprint) + tp->view.cols * 2 - 9);
...@@ -193,10 +191,9 @@ static void tty3270_create_prompt(struct tty3270 *tp) ...@@ -193,10 +191,9 @@ static void tty3270_create_prompt(struct tty3270 *tp)
memcpy(line->string, blueprint, sizeof(blueprint)); memcpy(line->string, blueprint, sizeof(blueprint));
line->len = sizeof(blueprint); line->len = sizeof(blueprint);
/* Set output offsets. */ /* Set output offsets. */
offset = tp->view.cols * tty3270_tty_rows(tp);
raw3270_buffer_address(tp->view.dev, line->string + 1, offset); raw3270_buffer_address(tp->view.dev, line->string + 1, 0, -2);
offset = tp->view.cols * tp->view.rows - 9; raw3270_buffer_address(tp->view.dev, line->string + 8, -9, -1);
raw3270_buffer_address(tp->view.dev, line->string + 8, offset);
/* Allocate input string for reading. */ /* Allocate input string for reading. */
tp->input = alloc_string(&tp->freemem, tp->view.cols * 2 - 9 + 6); tp->input = alloc_string(&tp->freemem, tp->view.cols * 2 - 9 + 6);
...@@ -232,7 +229,7 @@ static void tty3270_create_status(struct tty3270 *tp) ...@@ -232,7 +229,7 @@ static void tty3270_create_status(struct tty3270 *tp)
memcpy(line->string, blueprint, sizeof(blueprint)); memcpy(line->string, blueprint, sizeof(blueprint));
/* Set address to start of status string (= last 9 characters). */ /* Set address to start of status string (= last 9 characters). */
offset = tp->view.cols * tp->view.rows - 9; offset = tp->view.cols * tp->view.rows - 9;
raw3270_buffer_address(tp->view.dev, line->string + 1, offset); raw3270_buffer_address(tp->view.dev, line->string + 1, -9, -1);
} }
/* /*
...@@ -243,12 +240,10 @@ static void tty3270_update_string(struct tty3270 *tp, struct string *line, int n ...@@ -243,12 +240,10 @@ static void tty3270_update_string(struct tty3270 *tp, struct string *line, int n
{ {
unsigned char *cp; unsigned char *cp;
raw3270_buffer_address(tp->view.dev, line->string + 1, raw3270_buffer_address(tp->view.dev, line->string + 1, 0, nr);
tp->view.cols * nr);
cp = line->string + line->len - 4; cp = line->string + line->len - 4;
if (*cp == TO_RA) if (*cp == TO_RA)
raw3270_buffer_address(tp->view.dev, cp + 1, raw3270_buffer_address(tp->view.dev, cp + 1, 0, nr + 1);
tp->view.cols * (nr + 1));
} }
/* /*
......
...@@ -113,8 +113,15 @@ static inline int raw3270_state_ready(struct raw3270 *rp) ...@@ -113,8 +113,15 @@ static inline int raw3270_state_ready(struct raw3270 *rp)
return rp->state == RAW3270_STATE_READY; return rp->state == RAW3270_STATE_READY;
} }
void raw3270_buffer_address(struct raw3270 *rp, char *cp, unsigned short addr) void raw3270_buffer_address(struct raw3270 *rp, char *cp, int x, int y)
{ {
int addr;
if (x < 0)
x = max_t(int, 0, rp->view->cols + x);
if (y < 0)
y = max_t(int, 0, rp->view->rows + y);
addr = (y * rp->view->cols) + x;
if (test_bit(RAW3270_FLAGS_14BITADDR, &rp->flags)) { if (test_bit(RAW3270_FLAGS_14BITADDR, &rp->flags)) {
cp[0] = (addr >> 8) & 0x3f; cp[0] = (addr >> 8) & 0x3f;
cp[1] = addr & 0xff; cp[1] = addr & 0xff;
......
...@@ -132,7 +132,7 @@ raw3270_request_final(struct raw3270_request *rq) ...@@ -132,7 +132,7 @@ raw3270_request_final(struct raw3270_request *rq)
return list_empty(&rq->list); return list_empty(&rq->list);
} }
void raw3270_buffer_address(struct raw3270 *, char *, unsigned short); void raw3270_buffer_address(struct raw3270 *, char *, int, int);
/* /*
* Functions of a 3270 view. * Functions of a 3270 view.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment