Skip to content

Commit 88867e3

Browse files
sthibaulgregkh
authored andcommitted
Staging: speakup: fix read scrolled-back VT
Previously, speakup would always read the non-scrolled part of the VT, even when the VT is scrolled back with shift-page. This patch makes vt.c export screen_pos so that speakup can use it to properly access the content of the scrolled-back VT. This was tested with both vgacon and fbcon. Signed-off-by: Samuel Thibault <[email protected]> Reviewed-by: Alan Cox <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 327b882 commit 88867e3

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

drivers/staging/speakup/main.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,9 @@ static struct notifier_block vt_notifier_block = {
264264
.notifier_call = vt_notifier_call,
265265
};
266266

267-
static unsigned char get_attributes(u16 *pos)
267+
static unsigned char get_attributes(struct vc_data *vc, u16 *pos)
268268
{
269+
pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1);
269270
return (u_char) (scr_readw(pos) >> 8);
270271
}
271272

@@ -275,7 +276,7 @@ static void speakup_date(struct vc_data *vc)
275276
spk_y = spk_cy = vc->vc_y;
276277
spk_pos = spk_cp = vc->vc_pos;
277278
spk_old_attr = spk_attr;
278-
spk_attr = get_attributes((u_short *) spk_pos);
279+
spk_attr = get_attributes(vc, (u_short *)spk_pos);
279280
}
280281

281282
static void bleep(u_short val)
@@ -469,8 +470,12 @@ static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs)
469470
u16 ch = ' ';
470471

471472
if (vc && pos) {
472-
u16 w = scr_readw(pos);
473-
u16 c = w & 0xff;
473+
u16 w;
474+
u16 c;
475+
476+
pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1);
477+
w = scr_readw(pos);
478+
c = w & 0xff;
474479

475480
if (w & vc->vc_hi_font_mask)
476481
c |= 0x100;
@@ -746,7 +751,7 @@ static int get_line(struct vc_data *vc)
746751
u_char tmp2;
747752

748753
spk_old_attr = spk_attr;
749-
spk_attr = get_attributes((u_short *) spk_pos);
754+
spk_attr = get_attributes(vc, (u_short *)spk_pos);
750755
for (i = 0; i < vc->vc_cols; i++) {
751756
buf[i] = (u_char) get_char(vc, (u_short *) tmp, &tmp2);
752757
tmp += 2;
@@ -811,7 +816,7 @@ static int say_from_to(struct vc_data *vc, u_long from, u_long to,
811816
u_short saved_punc_mask = spk_punc_mask;
812817

813818
spk_old_attr = spk_attr;
814-
spk_attr = get_attributes((u_short *) from);
819+
spk_attr = get_attributes(vc, (u_short *)from);
815820
while (from < to) {
816821
buf[i++] = (char)get_char(vc, (u_short *) from, &tmp);
817822
from += 2;
@@ -886,7 +891,7 @@ static int get_sentence_buf(struct vc_data *vc, int read_punc)
886891
sentmarks[bn][0] = &sentbuf[bn][0];
887892
i = 0;
888893
spk_old_attr = spk_attr;
889-
spk_attr = get_attributes((u_short *) start);
894+
spk_attr = get_attributes(vc, (u_short *)start);
890895

891896
while (start < end) {
892897
sentbuf[bn][i] = (char)get_char(vc, (u_short *) start, &tmp);
@@ -1585,7 +1590,7 @@ static int count_highlight_color(struct vc_data *vc)
15851590
u16 *ptr;
15861591

15871592
for (ptr = start; ptr < end; ptr++) {
1588-
ch = get_attributes(ptr);
1593+
ch = get_attributes(vc, ptr);
15891594
bg = (ch & 0x70) >> 4;
15901595
speakup_console[vc_num]->ht.bgcount[bg]++;
15911596
}

drivers/tty/vt/vt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,6 +4250,7 @@ unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed)
42504250
{
42514251
return screenpos(vc, 2 * w_offset, viewed);
42524252
}
4253+
EXPORT_SYMBOL_GPL(screen_pos);
42534254

42544255
void getconsxy(struct vc_data *vc, unsigned char *p)
42554256
{

0 commit comments

Comments
 (0)