$OpenBSD: patch-xwindow_fb_x_display_wscons_c,v 1.1 2014/01/11 21:15:26 dcoppa Exp $

Add support for OpenBSD/luna88k 8bpp framebuffer
https://bitbucket.org/arakiken/mlterm/commits/2b4b80e883a654bc1b5ad7756843e28750ee6f37

--- xwindow/fb/x_display_wscons.c.orig	Sat Dec 21 18:11:37 2013
+++ xwindow/fb/x_display_wscons.c	Sat Jan 11 20:39:17 2014
@@ -376,28 +376,37 @@ open_display(
 
 	_display.width = _disp.width = vinfo.width ;
 	_display.height = _disp.height = vinfo.height ;
+	_disp.depth = vinfo.depth ;
 
-	if( ( _disp.depth = vinfo.depth) < 8)
+#ifdef  WSDISPLAY_TYPE_LUNA
+	if( wstype == WSDISPLAY_TYPE_LUNA)
 	{
-	#ifdef  ENABLE_2_4_PPB
-		_display.pixels_per_byte = 8 / _disp.depth ;
-	#else
-	#ifdef  WSDISPLAY_TYPE_LUNA
-		if( wstype == WSDISPLAY_TYPE_LUNA)
+		/* always 8 or less bpp */
+
+		if( _disp.depth > 8)
 		{
-			if( ( depth == 1 || depth == 4))
-			{
-				_disp.depth = depth ;
-			}
+			goto  error ;
 		}
-		else
-	#endif
+		else if( depth == 1 || depth == 4 || depth == 8)
 		{
-			/* XXX Forcibly set 1 bpp */
-			_disp.depth = 1 ;
+			_disp.depth = depth ;
 		}
-	#endif
+
 		_display.pixels_per_byte = 8 ;
+		_display.shift_0 = 7 ;
+		_display.mask = 1 ;
+	}
+	else
+#endif
+	if( _disp.depth < 8)
+	{
+	#ifdef  ENABLE_2_4_PPB
+		_display.pixels_per_byte = 8 / _disp.depth ;
+	#else
+		/* XXX Forcibly set 1 bpp */
+		_disp.depth = 1 ;
+		_display.pixels_per_byte = 8 ;
+	#endif
 
 		_display.shift_0 = FB_SHIFT_0(_display.pixels_per_byte,_disp.depth) ;
 		_display.mask = FB_MASK(_display.pixels_per_byte) ;
@@ -431,9 +440,9 @@ open_display(
 	}
 
 #ifdef  WSDISPLAY_TYPE_LUNA
-	if( wstype == WSDISPLAY_TYPE_LUNA && _disp.depth == 4)
+	if( wstype == WSDISPLAY_TYPE_LUNA && (_disp.depth == 4 || _disp.depth == 8))
 	{
-		_display.smem_len = 0x40000 * 4 ;
+		_display.smem_len = 0x40000 * _disp.depth ;
 		_display.plane_len = 0x40000 ;
 	}
 	else
