Module Name: src Committed By: tsutsui Date: Mon Oct 3 17:42:36 UTC 2022
Modified Files: src/sys/arch/luna68k/dev: lunafb.c omrasops.c omrasopsvar.h Log Message: Remove global hwplanecount and use ri_depth in struct rasops instead. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/luna68k/dev/lunafb.c cvs rdiff -u -r1.24 -r1.25 src/sys/arch/luna68k/dev/omrasops.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/luna68k/dev/omrasopsvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/luna68k/dev/lunafb.c diff -u src/sys/arch/luna68k/dev/lunafb.c:1.48 src/sys/arch/luna68k/dev/lunafb.c:1.49 --- src/sys/arch/luna68k/dev/lunafb.c:1.48 Sat Oct 1 14:02:08 2022 +++ src/sys/arch/luna68k/dev/lunafb.c Mon Oct 3 17:42:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lunafb.c,v 1.48 2022/10/01 14:02:08 tsutsui Exp $ */ +/* $NetBSD: lunafb.c,v 1.49 2022/10/03 17:42:35 tsutsui Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.48 2022/10/01 14:02:08 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.49 2022/10/03 17:42:35 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -175,8 +175,6 @@ CFATTACH_DECL_NEW(fb, sizeof(struct omfb extern int hwplanemask; /* hardware planemask; retrieved at boot */ -int hwplanecount; /* for omrasops */ - static int omfb_console; int omfb_cnattach(void); @@ -460,7 +458,7 @@ omfb_resetcmap(struct om_hwdevconfig *dc static void omfb_getdevconfig(paddr_t paddr, struct om_hwdevconfig *dc) { - int i; + int bpp, i; struct rasops_info *ri; union { struct { short h, v; } p; @@ -469,21 +467,21 @@ omfb_getdevconfig(paddr_t paddr, struct switch (hwplanemask) { case 0xff: - hwplanecount = 8; /* XXX check monochrome bit in DIPSW */ + bpp = 8; /* XXX check monochrome bit in DIPSW */ break; default: case 0x0f: - hwplanecount = 4; /* XXX check monochrome bit in DIPSW */ + bpp = 4; /* XXX check monochrome bit in DIPSW */ break; case 1: - hwplanecount = 1; + bpp = 1; break; } dc->dc_wid = 1280; dc->dc_ht = 1024; - dc->dc_depth = hwplanecount; + dc->dc_depth = bpp; dc->dc_rowbytes = 2048 / 8; - dc->dc_cmsize = (hwplanecount == 1) ? 0 : 1 << hwplanecount; + dc->dc_cmsize = (bpp == 1) ? 0 : 1 << bpp; dc->dc_videobase = paddr; omfb_resetcmap(dc); @@ -513,7 +511,7 @@ omfb_getdevconfig(paddr_t paddr, struct ri->ri_flg |= RI_NO_AUTO; ri->ri_hw = dc; - if (hwplanecount == 4 || hwplanecount == 8) + if (bpp == 4 || bpp == 8) omrasops4_init(ri, 34, 80); else omrasops1_init(ri, 34, 80); Index: src/sys/arch/luna68k/dev/omrasops.c diff -u src/sys/arch/luna68k/dev/omrasops.c:1.24 src/sys/arch/luna68k/dev/omrasops.c:1.25 --- src/sys/arch/luna68k/dev/omrasops.c:1.24 Sat Oct 1 13:51:55 2022 +++ src/sys/arch/luna68k/dev/omrasops.c Mon Oct 3 17:42:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: omrasops.c,v 1.24 2022/10/01 13:51:55 tsutsui Exp $ */ +/* $NetBSD: omrasops.c,v 1.25 2022/10/03 17:42:35 tsutsui Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.24 2022/10/01 13:51:55 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.25 2022/10/03 17:42:35 tsutsui Exp $"); /* * Designed speficically for 'm68k bitorder'; @@ -100,8 +100,8 @@ static void om_eraserows(void *, int, in static int om_allocattr(void *, int, int, int, long *); static void om_fill(int, int, uint8_t *, int, int, uint32_t, int, int); -static void om_fill_color(int, uint8_t *, int, int, int, int); -static void om_rascopy_single(uint8_t *, uint8_t *, int16_t, int16_t, +static void om_fill_color(int, int, uint8_t *, int, int, int, int); +static void om_rascopy_single(int, uint8_t *, uint8_t *, int16_t, int16_t, uint8_t[]); static void om4_rascopy_multi(uint8_t *, uint8_t *, int16_t, int16_t); static void om_unpack_attr(long, uint8_t *, uint8_t *, int *); @@ -330,8 +330,8 @@ om_fill(int planemask, int rop, uint8_t } static void -om_fill_color(int color, uint8_t *dstptr, int dstbitoffs, int dstspan, - int width, int height) +om_fill_color(int planecount, int color, uint8_t *dstptr, int dstbitoffs, + int dstspan, int width, int height) { uint32_t mask; uint32_t prev_mask; @@ -340,7 +340,7 @@ om_fill_color(int color, uint8_t *dstptr ASSUME(width > 0); ASSUME(height > 0); - ASSUME(omfb_planecount > 0); + ASSUME(planecount > 0); /* select all planes */ om_set_planemask(hwplanemask); @@ -364,7 +364,7 @@ om_fill_color(int color, uint8_t *dstptr } if (prev_mask != mask) { - for (plane = 0; plane < omfb_planecount; plane++) { + for (plane = 0; plane < planecount; plane++) { if ((color & (1U << plane)) != 0) rop = ROP_ONE; else @@ -446,6 +446,7 @@ om_putchar(void *cookie, int row, int st uint32_t mask; int width; int height; + int planecount; int x, y; int fontstride; int fontx; @@ -462,6 +463,7 @@ om_putchar(void *cookie, int row, int st width = ri->ri_font->fontwidth; height = ri->ri_font->fontheight; + planecount = ri->ri_depth; fontstride = ri->ri_font->stride; y = height * row; x = width * startcol; @@ -475,7 +477,7 @@ om_putchar(void *cookie, int row, int st last_fg = fg; last_bg = bg; /* calculate ROP */ - for (plane = 0; plane < omfb_planecount; plane++) { + for (plane = 0; plane < planecount; plane++) { int t = om_fgbg2rop(fg, bg); ropaddr[plane] = om_rop_addr(plane, t); fg >>= 1; @@ -497,9 +499,9 @@ om_putchar(void *cookie, int row, int st mask = ALL1BITS >> xl; dw = 32 - xl; - ASSUME(omfb_planecount == 1 || - omfb_planecount == 4 || - omfb_planecount == 8); + ASSUME(planecount == 1 || + planecount == 4 || + planecount == 8); do { uint8_t *d; @@ -513,7 +515,7 @@ om_putchar(void *cookie, int row, int st width = 0; } - switch (omfb_planecount) { + switch (planecount) { case 8: *(ropaddr[7]) = mask; *(ropaddr[6]) = mask; @@ -558,6 +560,7 @@ om_erasecols(void *cookie, int row, int int startx; int width; int height; + int planecount; int sh, sl; int y; int scanspan; @@ -569,6 +572,7 @@ om_erasecols(void *cookie, int row, int startx = ri->ri_font->fontwidth * startcol; width = ri->ri_font->fontwidth * ncols; height = ri->ri_font->fontheight; + planecount = ri->ri_depth; om_unpack_attr(attr, &fg, &bg, NULL); sh = startx >> 5; sl = startx & 0x1f; @@ -582,7 +586,7 @@ om_erasecols(void *cookie, int row, int om_fill(hwplanemask, ROP_ZERO, p, sl, scanspan, 0, width, height); } else { - om_fill_color(bg, p, sl, scanspan, width, height); + om_fill_color(planecount, bg, p, sl, scanspan, width, height); } /* reset mask value */ @@ -596,6 +600,7 @@ om_eraserows(void *cookie, int startrow, int startx; int width; int height; + int planecount; int sh, sl; int y; int scanspan; @@ -608,6 +613,7 @@ om_eraserows(void *cookie, int startrow, startx = 0; width = ri->ri_emuwidth; height = ri->ri_font->fontheight * nrows; + planecount = ri->ri_depth; om_unpack_attr(attr, &fg, &bg, NULL); sh = startx >> 5; sl = startx & 0x1f; @@ -622,7 +628,7 @@ om_eraserows(void *cookie, int startrow, om_fill(hwplanemask, ROP_ZERO, p, sl, scanspan, 0, width, height); } else { - om_fill_color(bg, p, sl, scanspan, width, height); + om_fill_color(planecount, bg, p, sl, scanspan, width, height); } /* reset mask value */ om_reset_planemask_and_rop(); @@ -636,13 +642,13 @@ om_eraserows(void *cookie, int startrow, * if y-backward, src < dst, point to left-bottom. * width: pixel width (must > 0) * height: pixel height (> 0 if forward, < 0 if backward) - * rop: ROP array with omfb_planecount elements. + * rop: ROP array with planecount elements. * * This function modifies(breaks) the planemask and ROPs. */ static void -om_rascopy_single(uint8_t *dst, uint8_t *src, int16_t width, int16_t height, - uint8_t rop[]) +om_rascopy_single(int planecount, uint8_t *dst, uint8_t *src, + int16_t width, int16_t height, uint8_t rop[]) { uint32_t mask; int wh; @@ -773,7 +779,7 @@ om_rascopy_single(uint8_t *dst, uint8_t * The common ROP cannot be used here. Because the hardware doesn't * allow you to set the mask while keeping the ROP states. */ - for (plane = 0; plane < omfb_planecount; plane++) { + for (plane = 0; plane < planecount; plane++) { om_set_rop(plane, rop[plane], mask); } @@ -802,7 +808,7 @@ om_rascopy_single(uint8_t *dst, uint8_t } #endif - for (plane = 0; plane < omfb_planecount; plane++) { + for (plane = 0; plane < planecount; plane++) { om_set_rop(plane, rop[plane], ALL1BITS); } } @@ -1140,6 +1146,7 @@ om4_copyrows(void *cookie, int srcrow, i struct rasops_info *ri = cookie; uint8_t *src, *dst; int width, rowheight; + int planecount; int ptrstep, rowstep; int srcplane; int i; @@ -1148,6 +1155,7 @@ om4_copyrows(void *cookie, int srcrow, i width = ri->ri_emuwidth; rowheight = ri->ri_font->fontheight; + planecount = ri->ri_depth; src = (uint8_t *)ri->ri_bits + srcrow * rowheight * ri->ri_stride; dst = (uint8_t *)ri->ri_bits + dstrow * rowheight * ri->ri_stride; @@ -1231,7 +1239,7 @@ om4_copyrows(void *cookie, int srcrow, i bg = tmp; } - for (i = 0; i < omfb_planecount; i++) { + for (i = 0; i < planecount; i++) { int t = om_fgbg2rop(fg, bg); rop[i] = t; om_set_rop(i, rop[i], ALL1BITS); @@ -1248,7 +1256,8 @@ om4_copyrows(void *cookie, int srcrow, i srcplane = (set != 0) ? (31 - __builtin_clz(set)) : 0; srcp = src + OMFB_PLANEOFFS + srcplane * OMFB_PLANEOFFS; - om_rascopy_single(dst, srcp, width, rowheight * r, rop); + om_rascopy_single(planecount, dst, srcp, + width, rowheight * r, rop); } skip: @@ -1673,8 +1682,10 @@ om_cursor(void *cookie, int on, int row, */ #endif static int -om_allocattr(void *id, int fg, int bg, int flags, long *attrp) +om_allocattr(void *cookie, int fg, int bg, int flags, long *attrp) { + struct rasops_info *ri = cookie; + int planecount = ri->ri_depth; uint32_t a; uint16_t c; @@ -1697,7 +1708,7 @@ om_allocattr(void *id, int fg, int bg, i } if ((flags & WSATTR_HILIT) != 0) { - if (omfb_planecount == 1) { + if (planecount == 1) { #if 0 a |= OMFB_ATTR_BOLD; #else @@ -1721,7 +1732,7 @@ om_allocattr(void *id, int fg, int bg, i #if 0 int i; - for (i = 0; i < omfb_planecount; i++) { + for (i = 0; i < planecount; i++) { c += c; c += ((fg & 1) << 1) | (bg & 1); fg >>= 1; Index: src/sys/arch/luna68k/dev/omrasopsvar.h diff -u src/sys/arch/luna68k/dev/omrasopsvar.h:1.7 src/sys/arch/luna68k/dev/omrasopsvar.h:1.8 --- src/sys/arch/luna68k/dev/omrasopsvar.h:1.7 Sat Oct 1 13:41:12 2022 +++ src/sys/arch/luna68k/dev/omrasopsvar.h Mon Oct 3 17:42:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: omrasopsvar.h,v 1.7 2022/10/01 13:41:12 tsutsui Exp $ */ +/* $NetBSD: omrasopsvar.h,v 1.8 2022/10/03 17:42:35 tsutsui Exp $ */ /* * Copyright (c) 2013 Kenji Aoyama * @@ -34,9 +34,7 @@ #define OMFB_STRIDE (2048/8) /* stride [byte] */ /* TODO: should be improved... */ -#define omfb_planecount hwplanecount extern int hwplanemask; -extern int hwplanecount; /* * ROP function