reverse color support.

This commit is contained in:
uch 2000-10-22 10:33:01 +00:00
parent a9869a4ed5
commit c3ceefe48c
4 changed files with 134 additions and 126 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: plumvideo.c,v 1.14 2000/10/04 13:53:55 uch Exp $ */
/* $NetBSD: plumvideo.c,v 1.15 2000/10/22 10:33:01 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#define PLUMVIDEODEBUG
#undef PLUMVIDEODEBUG
#include "opt_tx39_debug.h"
#include "plumohci.h" /* Plum2 OHCI shared memory allocated on V-RAM */
@ -85,6 +85,7 @@ struct plumvideo_softc {
plum_chipset_tag_t sc_pc;
void *sc_powerhook; /* power management hook */
int sc_console;
/* control register */
bus_space_tag_t sc_regt;
@ -154,6 +155,7 @@ plumvideo_attach(struct device *parent, struct device *self, void *aux)
struct hpcfb_attach_args ha;
int console, reverse_flag;
sc->sc_console = console = cn_tab ? 0 : 1;
sc->sc_pc = pa->pa_pc;
sc->sc_regt = pa->pa_regt;
sc->sc_fbiot = sc->sc_clutiot = sc->sc_bitbltt = pa->pa_iot;
@ -168,12 +170,8 @@ plumvideo_attach(struct device *parent, struct device *self, void *aux)
}
/* power control */
#ifndef PLUMVIDEODEBUG
if (bootinfo->bi_cnuse & BI_CNUSE_SERIAL)
plumvideo_power(sc, 0, 0, (void *)PWR_SUSPEND);
else
#endif
plumvideo_power(sc, 0, 0, (void *)PWR_RESUME);
plumvideo_power(sc, 0, 0,
(void *)(console ? PWR_RESUME : PWR_SUSPEND));
/* Add a hard power hook to power saving */
sc->sc_powerhook = config_hook(CONFIG_HOOK_PMEVENT,
CONFIG_HOOK_PMEVENT_HARDPOWER,
@ -197,14 +195,13 @@ plumvideo_attach(struct device *parent, struct device *self, void *aux)
plumvideo_hpcfbinit(sc, reverse_flag);
#ifdef PLUMVIDEODEBUG
if (plumvideo_debug > 1)
if (plumvideo_debug > 0)
plumvideo_dump(sc);
/* attach debug draw routine (debugging use) */
video_attach_drawfunc(&sc->sc_chip);
tx_conf_register_video(sc->sc_pc->pc_tc, &sc->sc_chip);
#endif /* PLUMVIDEODEBUG */
console = cn_tab ? 0 : 1;
if(console && hpcfb_cnattach(&sc->sc_fbconf) != 0) {
panic("plumvideo_attach: can't init fb console");
}
@ -296,23 +293,14 @@ plumvideo_hpcfbinit(struct plumvideo_softc *sc, int reverse_flag)
int
plumvideo_init(struct plumvideo_softc *sc, int *reverse)
{
struct {
int reverse, normal;
} ctype[] = {
{ BIFB_D2_M2L_3, BIFB_D2_M2L_0 },
{ BIFB_D2_M2L_3x2, BIFB_D2_M2L_0x2 },
{ BIFB_D8_FF, BIFB_D8_00 },
{ BIFB_D16_FFFF, BIFB_D16_0000, },
{ -1, -1 } /* terminator */
}, *ctypep;
struct video_chip *chip = &sc->sc_chip;
bus_space_tag_t regt = sc->sc_regt;
bus_space_handle_t regh = sc->sc_regh;
plumreg_t reg;
size_t vram_size;
int bpp, width, height, vram_pitch;
u_int16_t fbtype;
*reverse = video_reverse_color();
chip->vc_v = sc->sc_pc->pc_tc;
#if notyet
/* map BitBlt area */
@ -326,24 +314,9 @@ plumvideo_init(struct plumvideo_softc *sc, int *reverse)
#endif
reg = plum_conf_read(regt, regh, PLUM_VIDEO_PLGMD_REG);
/* check reverse color */
fbtype = bootinfo->fb_type;
for (ctypep = ctype; ctypep->normal != -1 ; ctypep++) {
if (fbtype == ctypep->normal) {
*reverse = 0;
goto fbtype_found;
} else if (fbtype == ctypep->reverse) {
*reverse = 1;
goto fbtype_found;
}
}
printf(": unknown frame buffer type 0x%04x. attach failed.\n", fbtype);
return (1);
fbtype_found:
switch (reg & PLUM_VIDEO_PLGMD_GMODE_MASK) {
case PLUM_VIDEO_PLGMD_16BPP:
#if NPLUMOHCI > 0 /* reserve V-RAM for USB OHCI */
#if NPLUMOHCI > 0 /* reserve V-RAM area for USB OHCI */
/* FALLTHROUGH */
#else
bpp = 16;
@ -729,6 +702,9 @@ plumvideo_power(void *ctx, int type, long id, void *msg)
switch (why) {
case PWR_RESUME:
if (!sc->sc_console)
return 0; /* serial console */
DPRINTF(("%s: ON\n", sc->sc_dev.dv_xname));
/* power on */
/* LCD power on and display on */

View File

@ -1,7 +1,11 @@
/* $NetBSD: video_subr.c,v 1.2 2000/05/22 17:17:44 uch Exp $ */
/* $NetBSD: video_subr.c,v 1.3 2000/10/22 10:33:01 uch Exp $ */
/*-
* Copyright (c) 2000 UCHIYAMA Yasushi. All rights reserved.
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -11,25 +15,33 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <machine/bootinfo.h>
#include <arch/hpcmips/dev/video_subr.h>
#define BPP2 ({ \
@ -104,7 +116,7 @@
})
#define LINEFUNC(b) \
static void linebpp##b __P((struct video_chip *, int, int, int, int)); \
static void linebpp##b (struct video_chip *, int, int, int, int); \
static void \
linebpp##b##(vc, x0, y0, x1, y1) \
struct video_chip *vc; \
@ -124,7 +136,7 @@ linebpp##b##(vc, x0, y0, x1, y1) \
}
#define DOTFUNC(b) \
static void dotbpp##b __P((struct video_chip *, int, int)); \
static void dotbpp##b (struct video_chip *, int, int); \
static void \
dotbpp##b##(vc, x, y) \
struct video_chip *vc; \
@ -142,14 +154,12 @@ LINEFUNC(8)
DOTFUNC(2)
DOTFUNC(4)
DOTFUNC(8)
static void linebpp_unimpl __P((struct video_chip *, int, int, int, int));
static void dotbpp_unimpl __P((struct video_chip *, int, int));
static void linebpp_unimpl(struct video_chip *, int, int, int, int);
static void dotbpp_unimpl(struct video_chip *, int, int);
int
cmap_work_alloc(r, g, b, rgb, cnt)
u_int8_t **r, **g, **b;
u_int32_t **rgb;
int cnt;
cmap_work_alloc(u_int8_t **r, u_int8_t **g, u_int8_t **b, u_int32_t **rgb,
int cnt)
{
KASSERT(r && g && b && rgb && LEGAL_CLUT_INDEX(cnt - 1));
@ -162,9 +172,7 @@ cmap_work_alloc(r, g, b, rgb, cnt)
}
void
cmap_work_free(r, g, b, rgb)
u_int8_t *r, *g, *b;
u_int32_t *rgb;
cmap_work_free(u_int8_t *r, u_int8_t *g, u_int8_t *b, u_int32_t *rgb)
{
if (r)
free(r, M_DEVBUF);
@ -177,10 +185,7 @@ cmap_work_free(r, g, b, rgb)
}
void
rgb24_compose(rgb24, r, g, b, cnt)
u_int32_t *rgb24;
u_int8_t *r, *g, *b;
int cnt;
rgb24_compose(u_int32_t *rgb24, u_int8_t *r, u_int8_t *g, u_int8_t *b, int cnt)
{
int i;
KASSERT(rgb24 && r && g && b && LEGAL_CLUT_INDEX(cnt - 1));
@ -191,10 +196,8 @@ rgb24_compose(rgb24, r, g, b, cnt)
}
void
rgb24_decompose(rgb24, r, g, b, cnt)
u_int32_t *rgb24;
u_int8_t *r, *g, *b;
int cnt;
rgb24_decompose(u_int32_t *rgb24, u_int8_t *r, u_int8_t *g, u_int8_t *b,
int cnt)
{
int i;
KASSERT(rgb24 && r && g && b && LEGAL_CLUT_INDEX(cnt - 1));
@ -211,8 +214,7 @@ rgb24_decompose(rgb24, r, g, b, cnt)
* Debug routines.
*/
void
video_calibration_pattern(vc)
struct video_chip *vc;
video_calibration_pattern(struct video_chip *vc)
{
int x, y;
@ -227,24 +229,19 @@ video_calibration_pattern(vc)
}
static void
linebpp_unimpl(vc, x0, y0, x1, y1)
struct video_chip *vc;
int x0, y0, x1, y1;
linebpp_unimpl(struct video_chip *vc, int x0, int y0, int x1, int y1)
{
return;
}
static void
dotbpp_unimpl(vc, x, y)
struct video_chip *vc;
int x, y;
dotbpp_unimpl(struct video_chip *vc, int x, int y)
{
return;
}
void
video_attach_drawfunc(vc)
struct video_chip *vc;
video_attach_drawfunc(struct video_chip *vc)
{
switch (vc->vc_fbdepth) {
default:
@ -267,19 +264,42 @@ video_attach_drawfunc(vc)
}
void
video_line(vc, x0, y0, x1, y1)
struct video_chip *vc;
int x0, y0, x1, y1;
video_line(struct video_chip *vc, int x0, int y0, int x1, int y1)
{
if (vc->vc_drawline)
vc->vc_drawline(vc, x0, y0, x1, y1);
}
void
video_dot(vc, x, y)
struct video_chip *vc;
int x, y;
video_dot(struct video_chip *vc, int x, int y)
{
if (vc->vc_drawdot)
vc->vc_drawdot(vc, x, y);
}
int
video_reverse_color()
{
struct {
int reverse, normal;
} ctype[] = {
{ BIFB_D2_M2L_3, BIFB_D2_M2L_0 },
{ BIFB_D2_M2L_3x2, BIFB_D2_M2L_0x2 },
{ BIFB_D8_FF, BIFB_D8_00 },
{ BIFB_D16_FFFF, BIFB_D16_0000, },
{ -1, -1 } /* terminator */
}, *ctypep;
u_int16_t fbtype;
/* check reverse color */
fbtype = bootinfo->fb_type;
for (ctypep = ctype; ctypep->normal != -1 ; ctypep++) {
if (fbtype == ctypep->normal) {
return (0);
} else if (fbtype == ctypep->reverse) {
return (1);
}
}
printf(": WARNING unknown frame buffer type 0x%04x.\n", fbtype);
return (0);
}

View File

@ -1,7 +1,11 @@
/* $NetBSD: video_subr.h,v 1.3 2000/05/22 17:17:44 uch Exp $ */
/* $NetBSD: video_subr.h,v 1.4 2000/10/22 10:33:01 uch Exp $ */
/*-
* Copyright (c) 2000 UCHIYAMA Yasushi. All rights reserved.
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -11,19 +15,25 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#define LEGAL_CLUT_INDEX(x) ((x) >= 0 && (x) <= 255)
@ -31,12 +41,10 @@
(((g) << 8) & 0x0000ff00) | \
(((b)) & 0x000000ff))
int cmap_work_alloc __P((u_int8_t **, u_int8_t **, u_int8_t **, u_int32_t **,
int));
void cmap_work_free __P((u_int8_t *, u_int8_t *, u_int8_t *, u_int32_t *));
void rgb24_compose __P((u_int32_t *, u_int8_t *, u_int8_t *, u_int8_t *, int));
void rgb24_decompose __P((u_int32_t *, u_int8_t *, u_int8_t *, u_int8_t *,
int));
int cmap_work_alloc(u_int8_t **, u_int8_t **, u_int8_t **, u_int32_t **, int);
void cmap_work_free(u_int8_t *, u_int8_t *, u_int8_t *, u_int32_t *);
void rgb24_compose(u_int32_t *, u_int8_t *, u_int8_t *, u_int8_t *, int);
void rgb24_decompose(u_int32_t *, u_int8_t *, u_int8_t *, u_int8_t *, int);
/* debug function for TX. VR will need `line bytes' */
struct video_chip;
@ -50,11 +58,12 @@ struct video_chip {
int vc_fbwidth;
int vc_fbheight;
void (*vc_drawline) __P((struct video_chip *, int, int, int, int));
void (*vc_drawdot) __P((struct video_chip *, int, int));
void (*vc_drawline)(struct video_chip *, int, int, int, int);
void (*vc_drawdot)(struct video_chip *, int, int);
};
void video_attach_drawfunc __P((struct video_chip *));
void video_line __P((struct video_chip *, int, int, int, int));
void video_dot __P((struct video_chip *, int, int));
void video_calibration_pattern __P((struct video_chip *));
void video_attach_drawfunc(struct video_chip *);
void video_line(struct video_chip *, int, int, int, int);
void video_dot(struct video_chip *, int, int);
void video_calibration_pattern(struct video_chip *);
int video_reverse_color(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx3912video.c,v 1.18 2000/10/04 13:53:55 uch Exp $ */
/* $NetBSD: tx3912video.c,v 1.19 2000/10/22 10:33:02 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -51,6 +51,8 @@
#include <uvm/uvm_extern.h>
#include <dev/cons.h> /* consdev */
#include <machine/bus.h>
#include <machine/bootinfo.h>
#include <machine/config_hook.h>
@ -80,6 +82,7 @@ int tx3912video_debug = 1;
struct tx3912video_softc {
struct device sc_dev;
void *sc_powerhook; /* power management hook */
int sc_console;
struct hpcfb_fbconf sc_fbconf;
struct hpcfb_dspconf sc_dspconf;
struct video_chip *sc_chip;
@ -121,7 +124,7 @@ struct hpcfb_accessops tx3912video_ha = {
int
tx3912video_match(struct device *parent, struct cfdata *cf, void *aux)
{
return (1);
return ATTACH_NORMAL;
}
void
@ -138,8 +141,9 @@ tx3912video_attach(struct device *parent, struct device *self, void *aux)
struct hpcfb_attach_args ha;
tx_chipset_tag_t tc;
txreg_t val;
int console = (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) ? 0 : 1;
int console;
sc->sc_console = console = cn_tab ? 0 : 1;
sc->sc_chip = chip = &tx3912video_chip;
/* print video module information */
@ -158,13 +162,9 @@ tx3912video_attach(struct device *parent, struct device *self, void *aux)
tx3912video_clut_init(sc);
/* if serial console, power off video module */
#ifndef TX3912VIDEO_DEBUG
if (!console)
tx3912video_power(sc, 0, 0, (void *)PWR_SUSPEND);
else
#endif /* TX3912VIDEO_DEBUG */
tx3912video_power(sc, 0, 0, (void *)PWR_RESUME);
tx3912video_power(sc, 0, 0, (void *)
(console ? PWR_RESUME : PWR_SUSPEND));
/* Add a hard power hook to power saving */
sc->sc_powerhook = config_hook(CONFIG_HOOK_PMEVENT,
CONFIG_HOOK_PMEVENT_HARDPOWER,
@ -210,6 +210,9 @@ tx3912video_power(void *ctx, int type, long id, void *msg)
switch (why) {
case PWR_RESUME:
if (!sc->sc_console)
return 0; /* serial console */
DPRINTF(("%s: ON\n", sc->sc_dev.dv_xname));
val = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
val |= (TX3912_VIDEOCTRL1_DISPON | TX3912_VIDEOCTRL1_ENVID);
@ -291,9 +294,9 @@ tx3912video_init(paddr_t fb_start, paddr_t *fb_end)
struct video_chip *chip = &tx3912video_chip;
tx_chipset_tag_t tc;
txreg_t reg;
int fbdepth;
int error;
int fbdepth, reverse, error;
reverse = video_reverse_color();
chip->vc_v = tc = tx_conf_get_tag();
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
@ -301,12 +304,12 @@ tx3912video_init(paddr_t fb_start, paddr_t *fb_end)
switch (fbdepth) {
case 2:
bootinfo->fb_type = BIFB_D2_M2L_0;
bootinfo->fb_type = reverse ? BIFB_D2_M2L_3 : BIFB_D2_M2L_0;
break;
case 4:
/* XXX should implement rasops4.c */
fbdepth = 2;
bootinfo->fb_type = BIFB_D2_M2L_0;
bootinfo->fb_type = reverse ? BIFB_D2_M2L_3 : BIFB_D2_M2L_0;
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
TX3912_VIDEOCTRL1_BITSEL_CLR(reg);
reg = TX3912_VIDEOCTRL1_BITSEL_SET(
@ -314,7 +317,7 @@ tx3912video_init(paddr_t fb_start, paddr_t *fb_end)
tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, reg);
break;
case 8:
bootinfo->fb_type = BIFB_D8_FF;
bootinfo->fb_type = reverse ? BIFB_D8_FF : BIFB_D8_00;
break;
}