[PATCH -resend 1/6] mdacon: align code in mda_detect properly

Subsystems: console subsystem, framebuffer layer, the rest

STALE3598d

6 messages, 2 authors, 2016-10-04 · open the first message on its own page

[PATCH -resend 1/6] mdacon: align code in mda_detect properly

From: Jiri Slaby <hidden>
Date: 2016-10-03 09:07:56

This is just a whitespace cleanup. The code was a mess having multiple
commands on one line like:
scr_writew(0xAA55, p); if (scr_readw(p) = 0xAA55) count++;

Indent that properly and make it nicer for reading.

Signed-off-by: Jiri Slaby <redacted>
Cc: Tomi Valkeinen <redacted>
Cc: <redacted>
---
 drivers/video/console/mdacon.c | 60 ++++++++++++++++++++++++------------------
 1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index bacbb044d77c..64c2c5e8d00b 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -208,10 +208,17 @@ static int mda_detect(void)
 	p = (u16 *) mda_vram_base;
 	q = (u16 *) (mda_vram_base + 0x01000);
 
-	p_save = scr_readw(p); q_save = scr_readw(q);
+	p_save = scr_readw(p);
+	q_save = scr_readw(q);
+
+	scr_writew(0xAA55, p);
+	if (scr_readw(p) = 0xAA55)
+		count++;
+
+	scr_writew(0x55AA, p);
+	if (scr_readw(p) = 0x55AA)
+		count++;
 
-	scr_writew(0xAA55, p); if (scr_readw(p) = 0xAA55) count++;
-	scr_writew(0x55AA, p); if (scr_readw(p) = 0x55AA) count++;
 	scr_writew(p_save, p);
 
 	if (count != 2) {
@@ -220,13 +227,18 @@ static int mda_detect(void)
 
 	/* check if we have 4K or 8K */
 
-	scr_writew(0xA55A, q); scr_writew(0x0000, p);
-	if (scr_readw(q) = 0xA55A) count++;
+	scr_writew(0xA55A, q);
+	scr_writew(0x0000, p);
+	if (scr_readw(q) = 0xA55A)
+		count++;
 	
-	scr_writew(0x5AA5, q); scr_writew(0x0000, p);
-	if (scr_readw(q) = 0x5AA5) count++;
+	scr_writew(0x5AA5, q);
+	scr_writew(0x0000, p);
+	if (scr_readw(q) = 0x5AA5)
+		count++;
 
-	scr_writew(p_save, p); scr_writew(q_save, q);
+	scr_writew(p_save, p);
+	scr_writew(q_save, q);
 	
 	if (count = 4) {
 		mda_vram_len = 0x02000;
@@ -240,14 +252,12 @@ static int mda_detect(void)
 	/* Edward: These two mess `tests' mess up my cursor on bootup */
 
 	/* cursor low register */
-	if (! test_mda_b(0x66, 0x0f)) {
+	if (!test_mda_b(0x66, 0x0f))
 		return 0;
-	}
 
 	/* cursor low register */
-	if (! test_mda_b(0x99, 0x0f)) {
+	if (!test_mda_b(0x99, 0x0f))
 		return 0;
-	}
 #endif
 
 	/* See if the card is a Hercules, by checking whether the vsync
@@ -257,25 +267,25 @@ static int mda_detect(void)
 	
 	p_save = q_save = inb_p(mda_status_port) & MDA_STATUS_VSYNC;
 
-	for (count=0; count < 50000 && p_save = q_save; count++) {
+	for (count = 0; count < 50000 && p_save = q_save; count++) {
 		q_save = inb(mda_status_port) & MDA_STATUS_VSYNC;
 		udelay(2);
 	}
 
 	if (p_save != q_save) {
 		switch (inb_p(mda_status_port) & 0x70) {
-			case 0x10:
-				mda_type = TYPE_HERCPLUS;
-				mda_type_name = "HerculesPlus";
-				break;
-			case 0x50:
-				mda_type = TYPE_HERCCOLOR;
-				mda_type_name = "HerculesColor";
-				break;
-			default:
-				mda_type = TYPE_HERC;
-				mda_type_name = "Hercules";
-				break;
+		case 0x10:
+			mda_type = TYPE_HERCPLUS;
+			mda_type_name = "HerculesPlus";
+			break;
+		case 0x50:
+			mda_type = TYPE_HERCCOLOR;
+			mda_type_name = "HerculesColor";
+			break;
+		default:
+			mda_type = TYPE_HERC;
+			mda_type_name = "Hercules";
+			break;
 		}
 	}
 
-- 
2.10.0

[PATCH -resend 2/6] mdacon: make mda_vram_base u16 *

From: Jiri Slaby <hidden>
Date: 2016-10-03 09:07:46

Given every user of mda_vram_base expects a pointer, let
mda_vram_base be a pointer to u16.

The offset calculation in mda_detect had to be adjusted by / 2 (due to
different pointer arithmetic now).

We introduce a cast to a value returned from VGA_MAP_MEM. But I will
change VGA_MAP_MEM to return a pointer later too. But vgacon needs a
similar change first.

Signed-off-by: Jiri Slaby <redacted>
Cc: Tomi Valkeinen <redacted>
Cc: <redacted>
---
 drivers/video/console/mdacon.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index 64c2c5e8d00b..814606bd26d1 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -48,7 +48,7 @@ static DEFINE_SPINLOCK(mda_lock);
 
 /* description of the hardware layout */
 
-static unsigned long	mda_vram_base;		/* Base of video memory */
+static u16		*mda_vram_base;		/* Base of video memory */
 static unsigned long	mda_vram_len;		/* Size of video memory */
 static unsigned int	mda_num_columns;	/* Number of text columns */
 static unsigned int	mda_num_lines;		/* Number of text lines */
@@ -205,8 +205,8 @@ static int mda_detect(void)
 
 	/* do a memory check */
 
-	p = (u16 *) mda_vram_base;
-	q = (u16 *) (mda_vram_base + 0x01000);
+	p = mda_vram_base;
+	q = mda_vram_base + 0x01000 / 2;
 
 	p_save = scr_readw(p);
 	q_save = scr_readw(q);
@@ -323,7 +323,7 @@ static const char *mdacon_startup(void)
 	mda_num_lines   = 25;
 
 	mda_vram_len  = 0x01000;
-	mda_vram_base = VGA_MAP_MEM(0xb0000, mda_vram_len);
+	mda_vram_base = (u16 *)VGA_MAP_MEM(0xb0000, mda_vram_len);
 
 	mda_index_port  = 0x3b4;
 	mda_value_port  = 0x3b5;
@@ -420,7 +420,7 @@ static void mdacon_invert_region(struct vc_data *c, u16 *p, int count)
 	}
 }
 
-#define MDA_ADDR(x,y)  ((u16 *) mda_vram_base + (y)*mda_num_columns + (x))
+#define MDA_ADDR(x, y)  (mda_vram_base + (y)*mda_num_columns + (x))
 
 static void mdacon_putc(struct vc_data *c, int ch, int y, int x)
 {
@@ -463,7 +463,7 @@ static int mdacon_blank(struct vc_data *c, int blank, int mode_switch)
 {
 	if (mda_type = TYPE_MDA) {
 		if (blank) 
-			scr_memsetw((void *)mda_vram_base, 
+			scr_memsetw(mda_vram_base,
 				mda_convert_attr(c->vc_video_erase_char),
 				c->vc_screenbuf_size);
 		/* Tell console.c that it has to restore the screen itself */
-- 
2.10.0

[PATCH -resend 3/6] mdacon: replace MDA_ADDR macro by inline function

From: Jiri Slaby <hidden>
Date: 2016-10-03 09:08:07

MDA_ADDR is one of those macros which could be an inline function. So
convert MDA_ADDR to mda_addr.

Note that we take x and y as unsigned now. But they are absolute
coordinates, so this is no problem.

Signed-off-by: Jiri Slaby <redacted>
Cc: Tomi Valkeinen <redacted>
Cc: <redacted>
---
 drivers/video/console/mdacon.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index 814606bd26d1..24fe55134eb5 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -420,17 +420,20 @@ static void mdacon_invert_region(struct vc_data *c, u16 *p, int count)
 	}
 }
 
-#define MDA_ADDR(x, y)  (mda_vram_base + (y)*mda_num_columns + (x))
+static inline u16 *mda_addr(unsigned int x, unsigned int y)
+{
+	return mda_vram_base + y * mda_num_columns + x;
+}
 
 static void mdacon_putc(struct vc_data *c, int ch, int y, int x)
 {
-	scr_writew(mda_convert_attr(ch), MDA_ADDR(x, y));
+	scr_writew(mda_convert_attr(ch), mda_addr(x, y));
 }
 
 static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
 		         int count, int y, int x)
 {
-	u16 *dest = MDA_ADDR(x, y);
+	u16 *dest = mda_addr(x, y);
 
 	for (; count > 0; count--) {
 		scr_writew(mda_convert_attr(scr_readw(s++)), dest++);
@@ -440,7 +443,7 @@ static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
 static void mdacon_clear(struct vc_data *c, int y, int x, 
 			  int height, int width)
 {
-	u16 *dest = MDA_ADDR(x, y);
+	u16 *dest = mda_addr(x, y);
 	u16 eattr = mda_convert_attr(c->vc_video_erase_char);
 
 	if (width <= 0 || height <= 0)
@@ -511,16 +514,16 @@ static int mdacon_scroll(struct vc_data *c, int t, int b, int dir, int lines)
 	switch (dir) {
 
 	case SM_UP:
-		scr_memmovew(MDA_ADDR(0,t), MDA_ADDR(0,t+lines),
+		scr_memmovew(mda_addr(0, t), mda_addr(0, t + lines),
 				(b-t-lines)*mda_num_columns*2);
-		scr_memsetw(MDA_ADDR(0,b-lines), eattr,
+		scr_memsetw(mda_addr(0, b - lines), eattr,
 				lines*mda_num_columns*2);
 		break;
 
 	case SM_DOWN:
-		scr_memmovew(MDA_ADDR(0,t+lines), MDA_ADDR(0,t),
+		scr_memmovew(mda_addr(0, t + lines), mda_addr(0, t),
 				(b-t-lines)*mda_num_columns*2);
-		scr_memsetw(MDA_ADDR(0,t), eattr, lines*mda_num_columns*2);
+		scr_memsetw(mda_addr(0, t), eattr, lines*mda_num_columns*2);
 		break;
 	}
 
-- 
2.10.0

[PATCH -resend 4/6] mdacon: enable COMPILE_TEST build

From: Jiri Slaby <hidden>
Date: 2016-10-03 09:08:18

It can be built even on systems without ISA. So enable compile testing
by specifying ISA || COMPILE_TEST.

Signed-off-by: Jiri Slaby <redacted>
Cc: Tomi Valkeinen <redacted>
Cc: <redacted>
---
 drivers/video/console/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 38da6e299149..7e9e8be24134 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -48,7 +48,7 @@ config VGACON_SOFT_SCROLLBACK_SIZE
 	 screenfuls of scrollback buffer
 
 config MDA_CONSOLE
-	depends on !M68K && !PARISC && ISA
+	depends on !M68K && !PARISC && (ISA || COMPILE_TEST)
 	tristate "MDA text console (dual-headed)"
 	---help---
 	  Say Y here if you have an old MDA or monochrome Hercules graphics
-- 
2.10.0

Re: [PATCH -resend 4/6] mdacon: enable COMPILE_TEST build

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2016-10-03 09:35:34

On Mon, Oct 3, 2016 at 11:07 AM, Jiri Slaby [off-list ref] wrote:
quoted hunk
It can be built even on systems without ISA. So enable compile testing
by specifying ISA || COMPILE_TEST.

Signed-off-by: Jiri Slaby <redacted>
Cc: Tomi Valkeinen <redacted>
Cc: <redacted>
---
 drivers/video/console/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 38da6e299149..7e9e8be24134 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -48,7 +48,7 @@ config VGACON_SOFT_SCROLLBACK_SIZE
         screenfuls of scrollback buffer

 config MDA_CONSOLE
-       depends on !M68K && !PARISC && ISA
+       depends on !M68K && !PARISC && (ISA || COMPILE_TEST)
My first thought was

    depends on (!M68K && !PARISC && ISA) || COMPILE_TEST

but arch/m68k/include/asm/vga.h doesn't define VGA_MAP_MEM().
Adding #include <asm-generic/vga.h> at the end of arch/m68k/include/asm/vga.h
fixes that.

Do we want that?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Re: [PATCH -resend 4/6] mdacon: enable COMPILE_TEST build

From: Jiri Slaby <hidden>
Date: 2016-10-04 07:09:09

On 10/03/2016, 11:35 AM, Geert Uytterhoeven wrote:
quoted
-       depends on !M68K && !PARISC && ISA
+       depends on !M68K && !PARISC && (ISA || COMPILE_TEST)
My first thought was

    depends on (!M68K && !PARISC && ISA) || COMPILE_TEST

but arch/m68k/include/asm/vga.h doesn't define VGA_MAP_MEM().
Adding #include <asm-generic/vga.h> at the end of arch/m68k/include/asm/vga.h
fixes that.

Do we want that?
The driver is not used much nowadays, so compile-testing on other
architectures is not worth it IMHO.

thanks,
-- 
js
suse labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help