From nobody@FreeBSD.org  Mon Jun 23 08:11:10 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DBA381065674
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 08:11:10 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id CB9AB8FC1D
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 08:11:10 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m5N8BAPO054723
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 23 Jun 2008 08:11:10 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m5N8BAV2054722;
	Mon, 23 Jun 2008 08:11:10 GMT
	(envelope-from nobody)
Message-Id: <200806230811.m5N8BAV2054722@www.freebsd.org>
Date: Mon, 23 Jun 2008 08:11:10 GMT
From: paradox <ddkprog@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: patch to fix VESA modes and allow 8bit depth modes
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         124902
>Category:       i386
>Synopsis:       [i386] [patch] patch to fix VESA modes and allow 8bit depth modes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    delphij
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 23 08:20:01 UTC 2008
>Closed-Date:    Mon May 03 22:11:36 UTC 2010
>Last-Modified:  Mon May 03 22:11:36 UTC 2010
>Originator:     paradox
>Release:        RELENG_7
>Organization:
>Environment:
FreeBSD 7.0-STABLE #3: Sun Jun 22 09:33:03 EEST 2008
    root@hack.org.ua:/usr/obj/work/cvsup/freebsd/7.0S/src/sys/KIR
>Description:
on FreeBSD console VESA modes not work

i'am recompile kernel with options
options VESA
options SC_PIXEL_MODE

#reboot
..
as example on my notebook
#vidcontrol -i mode
...
...
273 (0x111) 0x0000000f G 640x480x16 1    8x16  0xa0000 64k 64k 0xe8000000 15168k
274 (0x112) 0x0000000f G 640x480x32 1    8x16  0xa0000 64k 64k 0xe8000000 15168k
276 (0x114) 0x0000000f G 800x600x16 1    8x8   0xa0000 64k 64k 0xe8000000 15168k
277 (0x115) 0x0000000f G 800x600x32 1    8x8   0xa0000 64k 64k 0xe8000000 15168k
279 (0x117) 0x0000000f G 1024x768x16 1   8x16  0xa0000 64k 64k 0xe8000000 15168k
280 (0x118) 0x0000000f G 1024x768x32 1   8x16  0xa0000 64k 64k 0xe8000000 15168k
282 (0x11a) 0x0000000f G 1280x1024x16 1  8x16  0xa0000 64k 64k 0xe8000000 15168k
...
any of this mode not work!
fail or broken screen

>How-To-Repeat:
recompile kernel with options
options VESA
options SC_PIXEL_MODE


vidcontrol -i mode
to lists all support vesa video mode
try to use all graphics mode
>Fix:



Patch attached with submission follows:

--- src/sys/i386/isa/vesa.c.orig	2005-12-05 13:58:33.000000000 +0200
+++ src/sys/i386/isa/vesa.c	2008-06-22 00:52:26.000000000 +0300
@@ -1074,6 +1074,11 @@
 		(info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
 	vesa_adp->va_crtc_addr =
 		(vesa_adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
+
+	vesa_adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
+	vesa_adp->va_window_size = info.vi_window_size;
+	vesa_adp->va_window_gran = info.vi_window_gran;
+
 	if (info.vi_flags & V_INFO_LINEAR) {
 #if VESA_DEBUG > 1
 		printf("VESA: setting up LFB\n");
@@ -1083,33 +1088,31 @@
 					vesa_adp_info->v_memsize*64*1024);
 		vesa_adp->va_buffer_size = info.vi_buffer_size;
 		vesa_adp->va_window = vesa_adp->va_buffer;
-		vesa_adp->va_window_size = info.vi_buffer_size/info.vi_planes;
-		vesa_adp->va_window_gran = info.vi_buffer_size/info.vi_planes;
 	} else {
 		vesa_adp->va_buffer = 0;
-		vesa_adp->va_buffer_size = info.vi_buffer_size;
-		vesa_adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
-		vesa_adp->va_window_size = info.vi_window_size;
-		vesa_adp->va_window_gran = info.vi_window_gran;
+		vesa_adp->va_buffer_size = 0;
 	}
+#if VESA_DEBUG > 1
+	printf("VESA: buffer %x, buffer_size %d, window %x, window_size %d\n",
+			vesa_adp->va_buffer,
+			vesa_adp->va_buffer_size,
+			vesa_adp->va_window,
+			vesa_adp->va_window_size);
+#endif
 	vesa_adp->va_window_orig = 0;
 	len = vesa_bios_get_line_length();
-	if (len > 0) {
-		vesa_adp->va_line_width = len;
-	} else if (info.vi_flags & V_INFO_GRAPHICS) {
-		switch (info.vi_depth/info.vi_planes) {
-		case 1:
-			vesa_adp->va_line_width = info.vi_width/8;
-			break;
-		case 2:
-			vesa_adp->va_line_width = info.vi_width/4;
-			break;
+	if (info.vi_flags & V_INFO_GRAPHICS) {
+		switch (info.vi_depth) {
 		case 4:
-			vesa_adp->va_line_width = info.vi_width/2;
+			vesa_adp->va_line_width = info.vi_width;
 			break;
 		case 8:
-		default: /* shouldn't happen */
-			vesa_adp->va_line_width = info.vi_width;
+		case 15:
+		case 16:
+		case 24:
+		case 32:
+		default:
+			vesa_adp->va_line_width = info.vi_width * (info.vi_depth / 8);
 			break;
 		}
 	} else {
@@ -1118,8 +1121,8 @@
 	vesa_adp->va_disp_start.x = 0;
 	vesa_adp->va_disp_start.y = 0;
 #if VESA_DEBUG > 0
-	printf("vesa_set_mode(): vi_width:%d, len:%d, line_width:%d\n",
-	       info.vi_width, len, vesa_adp->va_line_width);
+	printf("vesa_set_mode(): vi_width:%d, len:%d, line_width:%d vi_mem_model:%d\n",
+	       info.vi_width, len, vesa_adp->va_line_width, info.vi_mem_model);
 #endif
 	bcopy(&info, &vesa_adp->va_info, sizeof(vesa_adp->va_info));

--- src/sys/dev/syscons/scvgarndr.c.orig	2008-03-03 02:56:08.000000000 +0200
+++ src/sys/dev/syscons/scvgarndr.c	2008-06-22 01:33:00.000000000 +0300
@@ -193,6 +193,8 @@
 		case 15:						\
 			writew(pos, vga_palette15[color]);		\
 			break;						\
+		case 8:							\
+			writeb(pos, (uint8_t)color);			\
 		}
 	
 static uint32_t vga_palette32[16] = {
@@ -215,6 +217,7 @@
 #ifndef SC_NO_CUTPASTE
 static uint32_t mouse_buf32[256];
 static uint16_t mouse_buf16[256];
+static uint8_t  mouse_buf8[256];
 #endif
 #endif
 
@@ -503,7 +506,9 @@
 		scp->rndr->draw_cursor = vga_pxlcursor_planar;
 		scp->rndr->blink_cursor = vga_pxlblink_planar;
 		scp->rndr->draw_mouse = vga_pxlmouse_planar;
-	} else if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT) {
+	} else
+	if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT ||
+	    scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_PACKED) {
 		scp->rndr->clear = vga_pxlclear_direct;
 		scp->rndr->draw_border = vga_pxlborder_direct;
 		scp->rndr->draw = vga_vgadraw_direct;
@@ -1153,6 +1158,7 @@
 	int i, j;
 	uint32_t *u32;
 	uint16_t *u16;
+	uint8_t  *u8;
 	int bpp;
 
 	if (!on)
@@ -1184,6 +1190,10 @@
 				u16 = (uint16_t*)(p + j * pixel_size);
 				writew(u16, mouse_buf16[i * 16 + j]);
 				break;
+			case 8:
+				u8 = (uint8_t*)(p + j * pixel_size);
+				writeb(u8, mouse_buf8[i * 16 + j]);
+				break;
 			}
 		}
 
@@ -1219,6 +1229,14 @@
 				else if (mouse_and_mask[i] & (1 << (15 - j)))
 					writew(u16, 0);
 				break;
+			case 8:
+				u8 = (uint8_t*)(p + j * pixel_size);
+				mouse_buf8[i * 16 + j] = *u8;
+				if (mouse_or_mask[i] & (1 << (15 - j)))
+					writeb(u8, 15);
+				else if (mouse_and_mask[i] & (1 << (15 - j)))
+					writeb(u8, 0);
+				break;
 			}
 		}
 

--- src/sys/dev/syscons/scvidctl.c.orig	2008-03-03 02:56:09.000000000 +0200
+++ src/sys/dev/syscons/scvidctl.c	2008-06-22 01:27:10.000000000 +0300
@@ -397,6 +397,10 @@
 	    (info.vi_depth != 15) && (info.vi_depth != 16) &&
 	    (info.vi_depth != 24) && (info.vi_depth != 32))
 	    return ENODEV;
+    } else if (info.vi_mem_model == V_INFO_MM_PACKED) {
+	if (!(info.vi_flags & V_INFO_LINEAR) &&
+	    (info.vi_depth != 8))
+	    return ENODEV;
     } else
 	return ENODEV;
 


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-i386 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Jun 24 08:12:31 UTC 2008 
Responsible-Changed-Why:  
Affects the i386 source tree only. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124902 
State-Changed-From-To: open->patched 
State-Changed-By: delphij 
State-Changed-When: Mon Aug 24 22:36:15 UTC 2009 
State-Changed-Why:  
Patch applied against -HEAD. 


Responsible-Changed-From-To: freebsd-i386->delphij 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Mon Aug 24 22:36:15 UTC 2009 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124902 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: i386/124902: commit references a PR
Date: Mon, 24 Aug 2009 22:37:01 +0000 (UTC)

 Author: delphij
 Date: Mon Aug 24 22:35:53 2009
 New Revision: 196524
 URL: http://svn.freebsd.org/changeset/base/196524
 
 Log:
   Fix VESA modes and allow 8bit depth modes.
   
   PR:		i386/124902
   Submitted by:	paradox <ddkprog yahoo com>
   MFC after:	2 months
 
 Modified:
   head/sys/dev/syscons/scvgarndr.c
   head/sys/dev/syscons/scvidctl.c
   head/sys/i386/isa/vesa.c
 
 Modified: head/sys/dev/syscons/scvgarndr.c
 ==============================================================================
 --- head/sys/dev/syscons/scvgarndr.c	Mon Aug 24 22:05:08 2009	(r196523)
 +++ head/sys/dev/syscons/scvgarndr.c	Mon Aug 24 22:35:53 2009	(r196524)
 @@ -193,6 +193,8 @@ static u_short mouse_or_mask[16] = {
  		case 15:						\
  			writew(pos, vga_palette15[color]);		\
  			break;						\
 +		case 8:							\
 +			writeb(pos, (uint8_t)color);			\
  		}
  	
  static uint32_t vga_palette32[16] = {
 @@ -215,6 +217,7 @@ static uint16_t vga_palette15[16] = {
  #ifndef SC_NO_CUTPASTE
  static uint32_t mouse_buf32[256];
  static uint16_t mouse_buf16[256];
 +static uint8_t  mouse_buf8[256];
  #endif
  #endif
  
 @@ -498,7 +501,9 @@ vga_rndrinit(scr_stat *scp)
  		scp->rndr->draw_cursor = vga_pxlcursor_planar;
  		scp->rndr->blink_cursor = vga_pxlblink_planar;
  		scp->rndr->draw_mouse = vga_pxlmouse_planar;
 -	} else if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT) {
 +	} else
 +	if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT ||
 +	    scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_PACKED) {
  		scp->rndr->clear = vga_pxlclear_direct;
  		scp->rndr->draw_border = vga_pxlborder_direct;
  		scp->rndr->draw = vga_vgadraw_direct;
 @@ -1148,6 +1153,7 @@ vga_pxlmouse_direct(scr_stat *scp, int x
  	int i, j;
  	uint32_t *u32;
  	uint16_t *u16;
 +	uint8_t  *u8;
  	int bpp;
  
  	if (!on)
 @@ -1179,6 +1185,10 @@ vga_pxlmouse_direct(scr_stat *scp, int x
  				u16 = (uint16_t*)(p + j * pixel_size);
  				writew(u16, mouse_buf16[i * 16 + j]);
  				break;
 +			case 8:
 +				u8 = (uint8_t*)(p + j * pixel_size);
 +				writeb(u8, mouse_buf8[i * 16 + j]);
 +				break;
  			}
  		}
  
 @@ -1214,6 +1224,14 @@ vga_pxlmouse_direct(scr_stat *scp, int x
  				else if (mouse_and_mask[i] & (1 << (15 - j)))
  					writew(u16, 0);
  				break;
 +			case 8:
 +				u8 = (uint8_t*)(p + j * pixel_size);
 +				mouse_buf8[i * 16 + j] = *u8;
 +				if (mouse_or_mask[i] & (1 << (15 - j)))
 +					writeb(u8, 15);
 +				else if (mouse_and_mask[i] & (1 << (15 - j)))
 +					writeb(u8, 0);
 +				break;
  			}
  		}
  
 
 Modified: head/sys/dev/syscons/scvidctl.c
 ==============================================================================
 --- head/sys/dev/syscons/scvidctl.c	Mon Aug 24 22:05:08 2009	(r196523)
 +++ head/sys/dev/syscons/scvidctl.c	Mon Aug 24 22:35:53 2009	(r196524)
 @@ -391,6 +391,10 @@ sc_set_pixel_mode(scr_stat *scp, struct 
  	    (info.vi_depth != 15) && (info.vi_depth != 16) &&
  	    (info.vi_depth != 24) && (info.vi_depth != 32))
  	    return ENODEV;
 +    } else if (info.vi_mem_model == V_INFO_MM_PACKED) {
 +	if (!(info.vi_flags & V_INFO_LINEAR) &&
 +	    (info.vi_depth != 8))
 +	    return ENODEV;
      } else
  	return ENODEV;
  
 
 Modified: head/sys/i386/isa/vesa.c
 ==============================================================================
 --- head/sys/i386/isa/vesa.c	Mon Aug 24 22:05:08 2009	(r196523)
 +++ head/sys/i386/isa/vesa.c	Mon Aug 24 22:35:53 2009	(r196524)
 @@ -1074,6 +1074,11 @@ vesa_set_mode(video_adapter_t *adp, int 
  		(info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
  	vesa_adp->va_crtc_addr =
  		(vesa_adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
 +
 +	vesa_adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
 +	vesa_adp->va_window_size = info.vi_window_size;
 +	vesa_adp->va_window_gran = info.vi_window_gran;
 +
  	if (info.vi_flags & V_INFO_LINEAR) {
  #if VESA_DEBUG > 1
  		printf("VESA: setting up LFB\n");
 @@ -1083,33 +1088,31 @@ vesa_set_mode(video_adapter_t *adp, int 
  					vesa_adp_info->v_memsize*64*1024);
  		vesa_adp->va_buffer_size = info.vi_buffer_size;
  		vesa_adp->va_window = vesa_adp->va_buffer;
 -		vesa_adp->va_window_size = info.vi_buffer_size/info.vi_planes;
 -		vesa_adp->va_window_gran = info.vi_buffer_size/info.vi_planes;
  	} else {
  		vesa_adp->va_buffer = 0;
 -		vesa_adp->va_buffer_size = info.vi_buffer_size;
 -		vesa_adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
 -		vesa_adp->va_window_size = info.vi_window_size;
 -		vesa_adp->va_window_gran = info.vi_window_gran;
 +		vesa_adp->va_buffer_size = 0;
  	}
 +#if VESA_DEBUG > 1
 +	printf("VESA: buffer %x, buffer_size %d, window %x, window_size %d\n",
 +			vesa_adp->va_buffer,
 +			vesa_adp->va_buffer_size,
 +			vesa_adp->va_window,
 +			vesa_adp->va_window_size);
 +#endif
  	vesa_adp->va_window_orig = 0;
  	len = vesa_bios_get_line_length();
 -	if (len > 0) {
 -		vesa_adp->va_line_width = len;
 -	} else if (info.vi_flags & V_INFO_GRAPHICS) {
 -		switch (info.vi_depth/info.vi_planes) {
 -		case 1:
 -			vesa_adp->va_line_width = info.vi_width/8;
 -			break;
 -		case 2:
 -			vesa_adp->va_line_width = info.vi_width/4;
 -			break;
 +	if (info.vi_flags & V_INFO_GRAPHICS) {
 +		switch (info.vi_depth) {
  		case 4:
 -			vesa_adp->va_line_width = info.vi_width/2;
 +			vesa_adp->va_line_width = info.vi_width;
  			break;
  		case 8:
 -		default: /* shouldn't happen */
 -			vesa_adp->va_line_width = info.vi_width;
 +		case 15:
 +		case 16:
 +		case 24:
 +		case 32:
 +		default:
 +			vesa_adp->va_line_width = info.vi_width * (info.vi_depth / 8);
  			break;
  		case 15:
  		case 16:
 @@ -1126,8 +1129,8 @@ vesa_set_mode(video_adapter_t *adp, int 
  	vesa_adp->va_disp_start.x = 0;
  	vesa_adp->va_disp_start.y = 0;
  #if VESA_DEBUG > 0
 -	printf("vesa_set_mode(): vi_width:%d, len:%d, line_width:%d\n",
 -	       info.vi_width, len, vesa_adp->va_line_width);
 +	printf("vesa_set_mode(): vi_width:%d, len:%d, line_width:%d vi_mem_model:%d\n",
 +	       info.vi_width, len, vesa_adp->va_line_width, info.vi_mem_model);
  #endif
  	bcopy(&info, &vesa_adp->va_info, sizeof(vesa_adp->va_info));
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: delphij 
State-Changed-When: Mon May 3 22:11:13 UTC 2010 
State-Changed-Why:  
The associated code has been MFC'ed to 8-STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124902 
>Unformatted:
