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-unsubscr...@freebsd.org"

Reply via email to