From 8ffb208fa02a1b556decdd88d377a61731df75d4 Mon Sep 17 00:00:00 2001 From: KATO Takenori Date: Sat, 6 Feb 1999 09:30:19 +0000 Subject: [PATCH] Sync with syscons for i386. Submitted by: Kazutaka YOKOTA --- sys/pc98/cbus/gdc.c | 62 +++++++++++++++++++++++++++++++--------- sys/pc98/pc98/pc98gdc.c | 62 +++++++++++++++++++++++++++++++--------- sys/pc98/pc98/scvidctl.c | 4 +-- sys/pc98/pc98/syscons.c | 4 +-- 4 files changed, 100 insertions(+), 32 deletions(-) diff --git a/sys/pc98/cbus/gdc.c b/sys/pc98/cbus/gdc.c index 1bbc8d4aca91..315d101f4958 100644 --- a/sys/pc98/cbus/gdc.c +++ b/sys/pc98/cbus/gdc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pc98gdc.c,v 1.3 1999/01/18 14:55:38 kato Exp $ + * $Id: pc98gdc.c,v 1.4 1999/01/28 11:24:36 kato Exp $ */ #include "gdc.h" @@ -215,8 +215,8 @@ static video_adapter_t adapter_init_value[] = { VIDEO_BUF_BASE, VIDEO_BUF_SIZE, /* va_mem* */ TEXT_BUF_BASE, TEXT_BUF_SIZE, TEXT_BUF_SIZE, /* va_window* */ 0, 0, /* va_buffer, va_buffer_size */ - 0, M_PC98_80x25, 0, 0, /* va_*mode* */ - NULL }, + 0, M_PC98_80x25, 0, /* va_*mode* */ + }, }; static video_adapter_t biosadapter[1]; @@ -351,12 +351,31 @@ probe_adapters(void) gdc_cmd(_GDC_STOP); /* graphics OFF */ gdc_get_info(&biosadapter[0], biosadapter[0].va_initial_mode, &info); - biosadapter[0].va_mode_flags = info.vi_flags; biosadapter[0].va_window = BIOS_PADDRTOVADDR(info.vi_window); biosadapter[0].va_window_size = info.vi_window_size; biosadapter[0].va_window_gran = info.vi_window_gran; biosadapter[0].va_buffer = 0; biosadapter[0].va_buffer_size = 0; + if (info.vi_flags & V_INFO_GRAPHICS) { + switch (info.vi_depth/info.vi_planes) { + case 1: + biosadapter[0].va_line_width = info.vi_width/8; + break; + case 2: + biosadapter[0].va_line_width = info.vi_width/4; + break; + case 4: + biosadapter[0].va_line_width = info.vi_width/2; + break; + case 8: + default: /* shouldn't happen */ + biosadapter[0].va_line_width = info.vi_width; + break; + } + } else { + biosadapter[0].va_line_width = info.vi_width; + } + bcopy(&info, &biosadapter[0].va_info, sizeof(info)); return 1; } @@ -663,7 +682,6 @@ gdc_set_mode(video_adapter_t *adp, int mode) #endif adp->va_mode = mode; - adp->va_mode_flags = info.vi_flags; adp->va_flags &= ~V_ADP_COLOR; adp->va_flags |= (info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0; @@ -681,6 +699,26 @@ gdc_set_mode(video_adapter_t *adp, int mode) adp->va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer); adp->va_buffer_size = info.vi_buffer_size; } + if (info.vi_flags & V_INFO_GRAPHICS) { + switch (info.vi_depth/info.vi_planes) { + case 1: + adp->va_line_width = info.vi_width/8; + break; + case 2: + adp->va_line_width = info.vi_width/4; + break; + case 4: + adp->va_line_width = info.vi_width/2; + break; + case 8: + default: /* shouldn't happen */ + adp->va_line_width = info.vi_width; + break; + } + } else { + adp->va_line_width = info.vi_width; + } + bcopy(&info, &adp->va_info, sizeof(info)); /* move hardware cursor out of the way */ (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1); @@ -726,15 +764,13 @@ gdc_load_state(video_adapter_t *adp, void *p) static int gdc_read_hw_cursor(video_adapter_t *adp, int *col, int *row) { - video_info_t info; u_int16_t off; int s; if (!init_done) return 1; - (*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info); - if (info.vi_flags & V_INFO_GRAPHICS) + if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return 1; s = spltty(); @@ -749,8 +785,8 @@ gdc_read_hw_cursor(video_adapter_t *adp, int *col, int *row) if (off >= ROW*COL) off = 0; - *row = off / info.vi_width; - *col = off % info.vi_width; + *row = off / adp->va_info.vi_width; + *col = off % adp->va_info.vi_width; return 0; } @@ -763,7 +799,6 @@ gdc_read_hw_cursor(video_adapter_t *adp, int *col, int *row) static int gdc_set_hw_cursor(video_adapter_t *adp, int col, int row) { - video_info_t info; u_int16_t off; int s; @@ -773,10 +808,9 @@ gdc_set_hw_cursor(video_adapter_t *adp, int col, int row) if ((col == -1) && (row == -1)) { off = -1; } else { - (*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info); - if (info.vi_flags & V_INFO_GRAPHICS) + if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return 1; - off = row*info.vi_width + col; + off = row*adp->va_info.vi_width + col; } s = spltty(); diff --git a/sys/pc98/pc98/pc98gdc.c b/sys/pc98/pc98/pc98gdc.c index 1bbc8d4aca91..315d101f4958 100644 --- a/sys/pc98/pc98/pc98gdc.c +++ b/sys/pc98/pc98/pc98gdc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pc98gdc.c,v 1.3 1999/01/18 14:55:38 kato Exp $ + * $Id: pc98gdc.c,v 1.4 1999/01/28 11:24:36 kato Exp $ */ #include "gdc.h" @@ -215,8 +215,8 @@ static video_adapter_t adapter_init_value[] = { VIDEO_BUF_BASE, VIDEO_BUF_SIZE, /* va_mem* */ TEXT_BUF_BASE, TEXT_BUF_SIZE, TEXT_BUF_SIZE, /* va_window* */ 0, 0, /* va_buffer, va_buffer_size */ - 0, M_PC98_80x25, 0, 0, /* va_*mode* */ - NULL }, + 0, M_PC98_80x25, 0, /* va_*mode* */ + }, }; static video_adapter_t biosadapter[1]; @@ -351,12 +351,31 @@ probe_adapters(void) gdc_cmd(_GDC_STOP); /* graphics OFF */ gdc_get_info(&biosadapter[0], biosadapter[0].va_initial_mode, &info); - biosadapter[0].va_mode_flags = info.vi_flags; biosadapter[0].va_window = BIOS_PADDRTOVADDR(info.vi_window); biosadapter[0].va_window_size = info.vi_window_size; biosadapter[0].va_window_gran = info.vi_window_gran; biosadapter[0].va_buffer = 0; biosadapter[0].va_buffer_size = 0; + if (info.vi_flags & V_INFO_GRAPHICS) { + switch (info.vi_depth/info.vi_planes) { + case 1: + biosadapter[0].va_line_width = info.vi_width/8; + break; + case 2: + biosadapter[0].va_line_width = info.vi_width/4; + break; + case 4: + biosadapter[0].va_line_width = info.vi_width/2; + break; + case 8: + default: /* shouldn't happen */ + biosadapter[0].va_line_width = info.vi_width; + break; + } + } else { + biosadapter[0].va_line_width = info.vi_width; + } + bcopy(&info, &biosadapter[0].va_info, sizeof(info)); return 1; } @@ -663,7 +682,6 @@ gdc_set_mode(video_adapter_t *adp, int mode) #endif adp->va_mode = mode; - adp->va_mode_flags = info.vi_flags; adp->va_flags &= ~V_ADP_COLOR; adp->va_flags |= (info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0; @@ -681,6 +699,26 @@ gdc_set_mode(video_adapter_t *adp, int mode) adp->va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer); adp->va_buffer_size = info.vi_buffer_size; } + if (info.vi_flags & V_INFO_GRAPHICS) { + switch (info.vi_depth/info.vi_planes) { + case 1: + adp->va_line_width = info.vi_width/8; + break; + case 2: + adp->va_line_width = info.vi_width/4; + break; + case 4: + adp->va_line_width = info.vi_width/2; + break; + case 8: + default: /* shouldn't happen */ + adp->va_line_width = info.vi_width; + break; + } + } else { + adp->va_line_width = info.vi_width; + } + bcopy(&info, &adp->va_info, sizeof(info)); /* move hardware cursor out of the way */ (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1); @@ -726,15 +764,13 @@ gdc_load_state(video_adapter_t *adp, void *p) static int gdc_read_hw_cursor(video_adapter_t *adp, int *col, int *row) { - video_info_t info; u_int16_t off; int s; if (!init_done) return 1; - (*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info); - if (info.vi_flags & V_INFO_GRAPHICS) + if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return 1; s = spltty(); @@ -749,8 +785,8 @@ gdc_read_hw_cursor(video_adapter_t *adp, int *col, int *row) if (off >= ROW*COL) off = 0; - *row = off / info.vi_width; - *col = off % info.vi_width; + *row = off / adp->va_info.vi_width; + *col = off % adp->va_info.vi_width; return 0; } @@ -763,7 +799,6 @@ gdc_read_hw_cursor(video_adapter_t *adp, int *col, int *row) static int gdc_set_hw_cursor(video_adapter_t *adp, int col, int row) { - video_info_t info; u_int16_t off; int s; @@ -773,10 +808,9 @@ gdc_set_hw_cursor(video_adapter_t *adp, int col, int row) if ((col == -1) && (row == -1)) { off = -1; } else { - (*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info); - if (info.vi_flags & V_INFO_GRAPHICS) + if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return 1; - off = row*info.vi_width + col; + off = row*adp->va_info.vi_width + col; } s = spltty(); diff --git a/sys/pc98/pc98/scvidctl.c b/sys/pc98/pc98/scvidctl.c index 77eba9811ce8..a9e0f02949c7 100644 --- a/sys/pc98/pc98/scvidctl.c +++ b/sys/pc98/pc98/scvidctl.c @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: scvidctl.c,v 1.1 1998/12/16 14:57:37 kato Exp $ + * $Id: scvidctl.c,v 1.2 1999/01/18 08:38:08 kato Exp $ */ #include "sc.h" @@ -391,11 +391,11 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p) ((video_adapter_info_t *)data)->va_buffer_size = scp->adp->va_buffer_size; ((video_adapter_info_t *)data)->va_mode = scp->adp->va_mode; - ((video_adapter_info_t *)data)->va_mode_flags = scp->adp->va_mode_flags; ((video_adapter_info_t *)data)->va_initial_mode = scp->adp->va_initial_mode; ((video_adapter_info_t *)data)->va_initial_bios_mode = scp->adp->va_initial_bios_mode; + ((video_adapter_info_t *)data)->va_line_width = scp->adp->va_line_width; return 0; case CONS_GET: /* get current video mode */ diff --git a/sys/pc98/pc98/syscons.c b/sys/pc98/pc98/syscons.c index 402101867c6e..5856607d80d3 100644 --- a/sys/pc98/pc98/syscons.c +++ b/sys/pc98/pc98/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.111 1999/01/30 12:17:38 phk Exp $ + * $Id: syscons.c,v 1.112 1999/02/02 17:21:33 kato Exp $ */ #include "sc.h" @@ -2360,7 +2360,7 @@ set_scrn_saver_mode(scr_stat *scp, int mode, u_char *pal, int border) return 0; scp->mode = mode; if (set_mode(scp) == 0) { - if (scp->adp->va_mode_flags & V_INFO_GRAPHICS) + if (scp->adp->va_info.vi_flags & V_INFO_GRAPHICS) scp->status |= GRAPHICS_MODE; if (pal != NULL) load_palette(scp->adp, pal);