2000-04-24 17:02:13 +04:00
|
|
|
/* $NetBSD: tx3912video.c,v 1.10 2000/04/24 13:02:13 uch Exp $ */
|
1999-11-20 22:56:31 +03:00
|
|
|
|
|
|
|
/*
|
2000-04-24 17:02:13 +04:00
|
|
|
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi
|
1999-11-20 22:56:31 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
2000-04-24 17:02:13 +04:00
|
|
|
* 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.
|
1999-11-20 22:56:31 +03:00
|
|
|
*
|
2000-04-24 17:02:13 +04:00
|
|
|
* 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.
|
1999-11-20 22:56:31 +03:00
|
|
|
*
|
|
|
|
*/
|
2000-04-24 17:02:13 +04:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
#include "opt_tx39_debug.h"
|
2000-03-13 21:49:15 +03:00
|
|
|
#include "hpcfb.h"
|
1999-11-20 22:56:31 +03:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/extent.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
2000-04-24 17:02:13 +04:00
|
|
|
#include <machine/bootinfo.h>
|
1999-11-20 22:56:31 +03:00
|
|
|
|
|
|
|
#include <hpcmips/tx/tx39var.h>
|
|
|
|
#include <hpcmips/tx/tx3912videovar.h>
|
|
|
|
#include <hpcmips/tx/tx3912videoreg.h>
|
|
|
|
|
2000-03-13 21:49:15 +03:00
|
|
|
#if NHPCFB > 0
|
2000-04-03 07:35:37 +04:00
|
|
|
#include <dev/wscons/wsconsio.h>
|
2000-03-13 21:49:15 +03:00
|
|
|
#include <arch/hpcmips/dev/hpcfbvar.h>
|
|
|
|
#include <arch/hpcmips/dev/hpcfbio.h>
|
|
|
|
#include <arch/hpcmips/dev/bivideovar.h>
|
1999-11-29 20:21:21 +03:00
|
|
|
#endif
|
2000-03-13 21:49:15 +03:00
|
|
|
#include <machine/autoconf.h> /* XXX */
|
1999-11-29 20:21:21 +03:00
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
#define TX3912VIDEO_DEBUG
|
1999-11-20 22:56:31 +03:00
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
static struct tx3912video_chip {
|
|
|
|
tx_chipset_tag_t vc_tc;
|
1999-11-20 22:56:31 +03:00
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
paddr_t vc_fbaddr;
|
|
|
|
size_t vc_fbsize;
|
|
|
|
int vc_fbdepth;
|
|
|
|
int vc_fbwidth;
|
|
|
|
int vc_fbheight;
|
2000-01-06 21:10:42 +03:00
|
|
|
|
|
|
|
void (*vc_drawline) __P((int, int, int, int));
|
|
|
|
void (*vc_drawdot) __P((int, int));
|
2000-04-24 17:02:13 +04:00
|
|
|
} tx3912video_chip;
|
2000-01-06 21:10:42 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
struct tx3912video_softc {
|
|
|
|
struct device sc_dev;
|
2000-01-06 21:10:42 +03:00
|
|
|
|
|
|
|
struct tx3912video_chip *sc_chip;
|
1999-11-20 22:56:31 +03:00
|
|
|
};
|
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
void tx3912video_framebuffer_init __P((struct tx3912video_chip *));
|
|
|
|
int tx3912video_framebuffer_alloc __P((struct tx3912video_chip *, paddr_t,
|
|
|
|
paddr_t *));
|
|
|
|
void tx3912video_reset __P((struct tx3912video_chip *));
|
|
|
|
void tx3912video_resolution_init __P((struct tx3912video_chip *));
|
|
|
|
|
|
|
|
int tx3912video_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
void tx3912video_attach __P((struct device *, struct device *, void *));
|
|
|
|
int tx3912video_print __P((void *, const char *));
|
1999-11-20 22:56:31 +03:00
|
|
|
|
|
|
|
struct cfattach tx3912video_ca = {
|
1999-12-12 20:04:55 +03:00
|
|
|
sizeof(struct tx3912video_softc), tx3912video_match,
|
|
|
|
tx3912video_attach
|
1999-11-20 22:56:31 +03:00
|
|
|
};
|
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
void __tx3912video_attach_drawfunc __P((struct tx3912video_chip*));
|
2000-01-06 21:10:42 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
int
|
|
|
|
tx3912video_match(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
2000-04-24 17:02:13 +04:00
|
|
|
return (1);
|
1999-11-20 22:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tx3912video_attach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
2000-04-24 17:02:13 +04:00
|
|
|
struct tx3912video_softc *sc = (void *)self;
|
|
|
|
struct tx3912video_chip *chip;
|
|
|
|
const char *depth_print[] = {
|
|
|
|
[TX3912_VIDEOCTRL1_BITSEL_MONOCHROME] = "monochrome",
|
|
|
|
[TX3912_VIDEOCTRL1_BITSEL_2BITGREYSCALE] = "2bit greyscale",
|
|
|
|
[TX3912_VIDEOCTRL1_BITSEL_4BITGREYSCALE] = "4bit greyscale",
|
|
|
|
[TX3912_VIDEOCTRL1_BITSEL_8BITCOLOR] = "8bit color"
|
|
|
|
};
|
|
|
|
|
|
|
|
sc->sc_chip = chip = &tx3912video_chip;
|
|
|
|
|
|
|
|
/* print video module information */
|
|
|
|
printf(": %s, frame buffer 0x%08x-0x%08x\n",
|
|
|
|
depth_print[(ffs(chip->vc_fbdepth) - 1) & 0x3],
|
|
|
|
(unsigned)chip->vc_fbaddr,
|
|
|
|
(unsigned)(chip->vc_fbaddr + chip->vc_fbsize));
|
|
|
|
|
|
|
|
/* if serial console, power off video module */
|
2000-01-06 21:10:42 +03:00
|
|
|
#ifndef TX3912VIDEO_DEBUG
|
1999-12-23 19:56:16 +03:00
|
|
|
if (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) {
|
2000-04-24 17:02:13 +04:00
|
|
|
tx_chipset_tag_t tc = ta->ta_tc;
|
|
|
|
txreg_t reg;
|
2000-01-03 21:29:03 +03:00
|
|
|
printf("%s: power off\n", sc->sc_dev.dv_xname);
|
1999-12-23 19:56:16 +03:00
|
|
|
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
|
|
|
|
reg &= ~(TX3912_VIDEOCTRL1_DISPON |
|
|
|
|
TX3912_VIDEOCTRL1_ENVID);
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, reg);
|
|
|
|
}
|
2000-01-06 21:10:42 +03:00
|
|
|
#endif /* TX3912VIDEO_DEBUG */
|
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
/* attach debug draw routine (debugging use) */
|
|
|
|
__tx3912video_attach_drawfunc(sc->sc_chip);
|
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
/* Attach frame buffer device */
|
2000-03-13 21:49:15 +03:00
|
|
|
#if NHPCFB > 0
|
1999-11-29 20:21:21 +03:00
|
|
|
if (!(bootinfo->bi_cnuse & BI_CNUSE_SERIAL)) {
|
2000-03-13 21:49:15 +03:00
|
|
|
if (hpcfb_cnattach(0, 0, 0, 0)) {
|
1999-11-29 20:21:21 +03:00
|
|
|
panic("tx3912video_attach: can't init fb console");
|
|
|
|
}
|
|
|
|
}
|
2000-04-24 17:02:13 +04:00
|
|
|
{
|
|
|
|
struct mainbus_attach_args ma; /* XXX */
|
|
|
|
ma.ma_name = "bivideo"; /* XXX */
|
|
|
|
config_found(self, &ma, tx3912video_print);
|
|
|
|
}
|
|
|
|
#endif /* NHPCFB > 0 */
|
1999-11-20 22:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
tx3912video_print(aux, pnp)
|
|
|
|
void *aux;
|
|
|
|
const char *pnp;
|
|
|
|
{
|
2000-04-24 17:02:13 +04:00
|
|
|
return (pnp ? QUIET : UNCONF);
|
1999-11-20 22:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_init(fb_start, fb_end)
|
|
|
|
paddr_t fb_start, *fb_end;
|
1999-11-20 22:56:31 +03:00
|
|
|
{
|
2000-04-24 17:02:13 +04:00
|
|
|
struct tx3912video_chip *chip = &tx3912video_chip;
|
|
|
|
tx_chipset_tag_t tc;
|
2000-01-07 18:10:50 +03:00
|
|
|
txreg_t reg;
|
2000-04-24 17:02:13 +04:00
|
|
|
int fbdepth;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
chip->vc_tc = tc = tx_conf_get_tag();
|
1999-11-20 22:56:31 +03:00
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
|
|
|
|
fbdepth = 1 << (TX3912_VIDEOCTRL1_BITSEL(reg));
|
2000-01-07 18:10:50 +03:00
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
switch (fbdepth) {
|
2000-01-07 18:10:50 +03:00
|
|
|
case 2:
|
|
|
|
bootinfo->fb_type = BIFB_D2_M2L_0;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
/* XXX should implement rasops4.c */
|
2000-04-24 17:02:13 +04:00
|
|
|
fbdepth = 2;
|
2000-01-07 18:10:50 +03:00
|
|
|
bootinfo->fb_type = BIFB_D2_M2L_0;
|
|
|
|
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
|
|
|
|
TX3912_VIDEOCTRL1_BITSEL_CLR(reg);
|
|
|
|
reg = TX3912_VIDEOCTRL1_BITSEL_SET(
|
|
|
|
reg, TX3912_VIDEOCTRL1_BITSEL_2BITGREYSCALE);
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, reg);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
bootinfo->fb_type = BIFB_D8_FF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_chip.vc_fbdepth = fbdepth;
|
|
|
|
tx3912video_chip.vc_fbwidth = bootinfo->fb_width;
|
|
|
|
tx3912video_chip.vc_fbheight= bootinfo->fb_height;
|
2000-01-07 18:10:50 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
/* Allocate framebuffer area */
|
2000-04-24 17:02:13 +04:00
|
|
|
error = tx3912video_framebuffer_alloc(chip, fb_start, fb_end);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
#if notyet
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_resolution_init(chip);
|
1999-11-20 22:56:31 +03:00
|
|
|
#else
|
|
|
|
/* Use Windows CE setting. */
|
|
|
|
#endif
|
|
|
|
/* Set DMA transfer address to VID module */
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_framebuffer_init(chip);
|
1999-11-20 22:56:31 +03:00
|
|
|
|
|
|
|
/* Syncronize framebuffer addr to frame signal */
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_reset(chip);
|
1999-11-20 22:56:31 +03:00
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
bootinfo->fb_line_bytes = (chip->vc_fbwidth * fbdepth) / NBBY;
|
|
|
|
bootinfo->fb_addr = (void *)MIPS_PHYS_TO_KSEG1(chip->vc_fbaddr);
|
|
|
|
|
|
|
|
return (0);
|
1999-11-20 22:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_framebuffer_alloc(chip, fb_start, fb_end)
|
|
|
|
struct tx3912video_chip *chip;
|
|
|
|
paddr_t fb_start, *fb_end; /* buffer allocation hint */
|
1999-11-20 22:56:31 +03:00
|
|
|
{
|
2000-04-24 17:02:13 +04:00
|
|
|
struct extent_fixed ex_fixed[10];
|
1999-11-20 22:56:31 +03:00
|
|
|
struct extent *ex;
|
|
|
|
u_long addr, size;
|
2000-04-24 17:02:13 +04:00
|
|
|
int error;
|
|
|
|
|
|
|
|
/* calcurate frame buffer size */
|
|
|
|
size = (chip->vc_fbwidth * chip->vc_fbheight * chip->vc_fbdepth) /
|
|
|
|
NBBY;
|
|
|
|
|
|
|
|
/* extent V-RAM region */
|
|
|
|
ex = extent_create("Frame buffer address", fb_start, *fb_end,
|
|
|
|
0, (caddr_t)ex_fixed, sizeof ex_fixed,
|
|
|
|
EX_NOWAIT);
|
|
|
|
if (ex == 0)
|
|
|
|
return (1);
|
1999-11-20 22:56:31 +03:00
|
|
|
|
|
|
|
/* Allocate V-RAM area */
|
2000-04-24 17:02:13 +04:00
|
|
|
error = extent_alloc_subregion(ex, fb_start, fb_start + size, size,
|
|
|
|
TX3912_FRAMEBUFFER_ALIGNMENT,
|
|
|
|
TX3912_FRAMEBUFFER_BOUNDARY,
|
|
|
|
EX_FAST|EX_NOWAIT, &addr);
|
|
|
|
extent_destroy(ex);
|
|
|
|
|
|
|
|
if (error != 0) {
|
|
|
|
return (1);
|
1999-11-20 22:56:31 +03:00
|
|
|
}
|
2000-04-24 17:02:13 +04:00
|
|
|
|
|
|
|
chip->vc_fbaddr = addr;
|
|
|
|
chip->vc_fbsize = size;
|
2000-01-06 21:10:42 +03:00
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
*fb_end = addr + size;
|
1999-11-20 22:56:31 +03:00
|
|
|
|
2000-04-24 17:02:13 +04:00
|
|
|
return (0);
|
1999-11-20 22:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_framebuffer_init(chip)
|
|
|
|
struct tx3912video_chip *chip;
|
1999-11-20 22:56:31 +03:00
|
|
|
{
|
2000-04-24 17:02:13 +04:00
|
|
|
u_int32_t fb_addr, fb_size, vaddr, bank, base;
|
|
|
|
txreg_t reg;
|
|
|
|
tx_chipset_tag_t tc = chip->vc_tc;
|
|
|
|
|
|
|
|
fb_addr = chip->vc_fbaddr;
|
|
|
|
fb_size = chip->vc_fbsize;
|
1999-11-20 22:56:31 +03:00
|
|
|
|
|
|
|
/* XXX currently I don't set DFVAL, so force DF signal toggled on
|
|
|
|
* XXX each frame. */
|
|
|
|
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
|
|
|
|
reg &= ~TX3912_VIDEOCTRL1_DFMODE;
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, reg);
|
|
|
|
|
|
|
|
/* Set DMA transfer start and end address */
|
2000-04-24 17:02:13 +04:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
bank = TX3912_VIDEOCTRL3_VIDBANK(fb_addr);
|
|
|
|
base = TX3912_VIDEOCTRL3_VIDBASEHI(fb_addr);
|
|
|
|
reg = TX3912_VIDEOCTRL3_VIDBANK_SET(0, bank);
|
|
|
|
/* Upper address counter */
|
|
|
|
reg = TX3912_VIDEOCTRL3_VIDBASEHI_SET(reg, base);
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL3_REG, reg);
|
|
|
|
|
|
|
|
/* Lower address counter */
|
|
|
|
base = TX3912_VIDEOCTRL4_VIDBASELO(fb_addr + fb_size);
|
|
|
|
reg = TX3912_VIDEOCTRL4_VIDBASELO_SET(0, base);
|
|
|
|
|
|
|
|
/* Set DF-signal rate */
|
|
|
|
reg = TX3912_VIDEOCTRL4_DFVAL_SET(reg, 0); /* XXX not yet*/
|
|
|
|
|
|
|
|
/* Set VIDDONE signal delay after FRAME signal */
|
|
|
|
/* XXX not yet*/
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL4_REG, reg);
|
|
|
|
|
|
|
|
/* Clear frame buffer */
|
|
|
|
vaddr = MIPS_PHYS_TO_KSEG1(fb_addr);
|
2000-04-24 17:02:13 +04:00
|
|
|
memset((void*)vaddr, 0, fb_size);
|
1999-11-20 22:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_resolution_init(chip)
|
|
|
|
struct tx3912video_chip *chip;
|
1999-11-20 22:56:31 +03:00
|
|
|
{
|
2000-04-24 17:02:13 +04:00
|
|
|
int h, v, split, bit8, horzval, lineval;
|
|
|
|
tx_chipset_tag_t tc = chip->vc_tc;
|
|
|
|
txreg_t reg;
|
|
|
|
u_int32_t val;
|
|
|
|
|
|
|
|
h = chip->vc_fbwidth;
|
|
|
|
v = chip->vc_fbheight;
|
1999-11-20 22:56:31 +03:00
|
|
|
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
|
|
|
|
split = reg & TX3912_VIDEOCTRL1_DISPSPLIT;
|
|
|
|
bit8 = (TX3912_VIDEOCTRL1_BITSEL(reg) ==
|
|
|
|
TX3912_VIDEOCTRL1_BITSEL_8BITCOLOR);
|
|
|
|
val = TX3912_VIDEOCTRL1_BITSEL(reg);
|
|
|
|
|
|
|
|
if ((val == TX3912_VIDEOCTRL1_BITSEL_8BITCOLOR) &&
|
|
|
|
!split) {
|
1999-12-12 20:04:55 +03:00
|
|
|
/* (LCD horizontal pixels / 8bit) * RGB - 1 */
|
|
|
|
horzval = (h / 8) * 3 - 1;
|
1999-11-20 22:56:31 +03:00
|
|
|
} else {
|
|
|
|
horzval = h / 4 - 1;
|
|
|
|
}
|
|
|
|
lineval = (split ? v / 2 : v) - 1;
|
|
|
|
|
|
|
|
/* Video rate */
|
1999-12-12 20:04:55 +03:00
|
|
|
/* XXX
|
|
|
|
* probably This value should be determined from DFINT and LCDINT
|
|
|
|
*/
|
1999-11-20 22:56:31 +03:00
|
|
|
reg = TX3912_VIDEOCTRL2_VIDRATE_SET(0, horzval + 1);
|
|
|
|
/* Horizontal size of LCD */
|
|
|
|
reg = TX3912_VIDEOCTRL2_HORZVAL_SET(reg, horzval);
|
|
|
|
/* # of lines for the LCD */
|
|
|
|
reg = TX3912_VIDEOCTRL2_LINEVAL_SET(reg, lineval);
|
|
|
|
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL2_REG, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-04-24 17:02:13 +04:00
|
|
|
tx3912video_reset(chip)
|
|
|
|
struct tx3912video_chip *chip;
|
1999-11-20 22:56:31 +03:00
|
|
|
{
|
2000-04-24 17:02:13 +04:00
|
|
|
tx_chipset_tag_t tc = chip->vc_tc;
|
|
|
|
txreg_t reg;
|
1999-11-20 22:56:31 +03:00
|
|
|
|
|
|
|
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
|
1999-12-12 20:04:55 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
/* Disable video logic at end of this frame */
|
|
|
|
reg |= TX3912_VIDEOCTRL1_ENFREEZEFRAME;
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, reg);
|
1999-12-12 20:04:55 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
/* Wait for end of frame */
|
2000-04-24 17:02:13 +04:00
|
|
|
delay(30 * 1000);
|
1999-12-12 20:04:55 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
/* Make sure to disable video logic */
|
|
|
|
reg &= ~TX3912_VIDEOCTRL1_ENVID;
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, reg);
|
1999-12-12 20:04:55 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
delay(1000);
|
1999-12-12 20:04:55 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
/* Enable video logic again */
|
|
|
|
reg &= ~TX3912_VIDEOCTRL1_ENFREEZEFRAME;
|
|
|
|
reg |= TX3912_VIDEOCTRL1_ENVID;
|
|
|
|
tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, reg);
|
1999-12-12 20:04:55 +03:00
|
|
|
|
1999-11-20 22:56:31 +03:00
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
2000-01-06 21:10:42 +03:00
|
|
|
/*
|
|
|
|
* Debug routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
tx3912video_calibration_pattern()
|
|
|
|
{
|
|
|
|
struct tx3912video_chip *vc = &tx3912video_chip;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
x = vc->vc_fbwidth - 40;
|
|
|
|
y = vc->vc_fbheight - 40;
|
|
|
|
tx3912video_line(40, 40, x , 40);
|
|
|
|
tx3912video_line(x , 40, x , y );
|
|
|
|
tx3912video_line(x , y , 40, y );
|
|
|
|
tx3912video_line(40, y , 40, 40);
|
|
|
|
tx3912video_line(40, 40, x , y );
|
|
|
|
tx3912video_line(x, 40, 40, y );
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BPP2 ({ \
|
|
|
|
u_int8_t bitmap; \
|
|
|
|
bitmap = *(volatile u_int8_t*)MIPS_PHYS_TO_KSEG1(addr); \
|
|
|
|
*(volatile u_int8_t*)MIPS_PHYS_TO_KSEG1(addr) = \
|
|
|
|
(bitmap & ~(0x3 << ((3 - (x % 4)) * 2))); \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define BPP4 ({ \
|
|
|
|
u_int8_t bitmap; \
|
|
|
|
bitmap = *(volatile u_int8_t*)MIPS_PHYS_TO_KSEG1(addr); \
|
|
|
|
*(volatile u_int8_t*)MIPS_PHYS_TO_KSEG1(addr) = \
|
|
|
|
(bitmap & ~(0xf << ((1 - (x % 2)) * 4))); \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define BPP8 ({ \
|
|
|
|
*(volatile u_int8_t*)MIPS_PHYS_TO_KSEG1(addr) = 0xff; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define BRESENHAM(a, b, c, d, func) ({ \
|
|
|
|
u_int32_t fbaddr = vc->vc_fbaddr; \
|
|
|
|
u_int32_t fbwidth = vc->vc_fbwidth; \
|
|
|
|
u_int32_t fbdepth = vc->vc_fbdepth; \
|
|
|
|
len = a, step = b -1; \
|
|
|
|
if (step == 0) \
|
|
|
|
return; \
|
|
|
|
kstep = len == 0 ? 0 : 1; \
|
|
|
|
for (i = k = 0, j = step / 2; i <= step; i++) { \
|
|
|
|
x = xbase c; \
|
|
|
|
y = ybase d; \
|
|
|
|
addr = fbaddr + (((y * fbwidth + x) * fbdepth) >> 3); \
|
|
|
|
func; \
|
|
|
|
j -= len; \
|
|
|
|
while (j < 0) { \
|
|
|
|
j += step; \
|
|
|
|
k += kstep; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define DRAWLINE(func) ({ \
|
|
|
|
if (x < 0) { \
|
|
|
|
if (y < 0) { \
|
|
|
|
if (_y < _x) { \
|
|
|
|
BRESENHAM(_y, _x, -i, -k, func); \
|
|
|
|
} else { \
|
|
|
|
BRESENHAM(_x, _y, -k, -i, func); \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if (_y < _x) { \
|
|
|
|
BRESENHAM(_y, _x, -i, +k, func); \
|
|
|
|
} else { \
|
|
|
|
BRESENHAM(_x, _y, -k, +i, func); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if (y < 0) { \
|
|
|
|
if (_y < _x) { \
|
|
|
|
BRESENHAM(_y, _x, +i, -k, func); \
|
|
|
|
} else { \
|
|
|
|
BRESENHAM(_x, _y, +k, -i, func); \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if (_y < _x) { \
|
|
|
|
BRESENHAM(_y, _x, +i, +k, func); \
|
|
|
|
} else { \
|
|
|
|
BRESENHAM(_x, _y, +k, +i, func); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define LINEFUNC(b) \
|
|
|
|
static void linebpp##b __P((int, int, int, int)); \
|
|
|
|
static void \
|
|
|
|
linebpp##b##(x0, y0, x1, y1) \
|
|
|
|
int x0, y0, x1, y1; \
|
|
|
|
{ \
|
|
|
|
struct tx3912video_chip *vc = &tx3912video_chip; \
|
|
|
|
u_int32_t addr; \
|
|
|
|
int i, j, k, len, step, kstep; \
|
|
|
|
int x, _x, y, _y; \
|
|
|
|
int xbase, ybase; \
|
|
|
|
x = x1 - x0; \
|
|
|
|
y = y1 - y0; \
|
|
|
|
_x = abs(x); \
|
|
|
|
_y = abs(y); \
|
|
|
|
xbase = x0; \
|
|
|
|
ybase = y0; \
|
|
|
|
DRAWLINE(BPP##b##); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DOTFUNC(b) \
|
|
|
|
static void dotbpp##b __P((int, int)); \
|
|
|
|
static void \
|
|
|
|
dotbpp##b##(x, y) \
|
|
|
|
int x, y; \
|
|
|
|
{ \
|
|
|
|
struct tx3912video_chip *vc = &tx3912video_chip; \
|
|
|
|
u_int32_t addr; \
|
|
|
|
addr = vc->vc_fbaddr + (((y * vc->vc_fbwidth + x) * \
|
|
|
|
vc->vc_fbdepth) >> 3); \
|
|
|
|
BPP##b; \
|
|
|
|
}
|
|
|
|
|
|
|
|
static void linebpp_unimpl __P((int, int, int, int));
|
|
|
|
static void dotbpp_unimpl __P((int, int));
|
|
|
|
static
|
|
|
|
void linebpp_unimpl(x0, y0, x1, y1)
|
|
|
|
int x0, y0, x1, y1;
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
static
|
|
|
|
void dotbpp_unimpl(x, y)
|
|
|
|
int x, y;
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LINEFUNC(2)
|
|
|
|
LINEFUNC(4)
|
|
|
|
LINEFUNC(8)
|
|
|
|
DOTFUNC(2)
|
|
|
|
DOTFUNC(4)
|
|
|
|
DOTFUNC(8)
|
|
|
|
|
|
|
|
void
|
2000-04-24 17:02:13 +04:00
|
|
|
__tx3912video_attach_drawfunc(vc)
|
2000-01-06 21:10:42 +03:00
|
|
|
struct tx3912video_chip *vc;
|
|
|
|
{
|
|
|
|
switch (vc->vc_fbdepth) {
|
|
|
|
default:
|
|
|
|
vc->vc_drawline = linebpp_unimpl;
|
|
|
|
vc->vc_drawdot = dotbpp_unimpl;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
vc->vc_drawline = linebpp8;
|
|
|
|
vc->vc_drawdot = dotbpp8;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
vc->vc_drawline = linebpp4;
|
|
|
|
vc->vc_drawdot = dotbpp4;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
vc->vc_drawline = linebpp2;
|
|
|
|
vc->vc_drawdot = dotbpp2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tx3912video_line(x0, y0, x1, y1)
|
|
|
|
int x0, y0, x1, y1;
|
|
|
|
{
|
|
|
|
struct tx3912video_chip *vc = &tx3912video_chip;
|
|
|
|
vc->vc_drawline(x0, y0, x1, y1);
|
|
|
|
}
|
1999-11-20 22:56:31 +03:00
|
|
|
|
2000-01-06 21:10:42 +03:00
|
|
|
void
|
|
|
|
tx3912video_dot(x, y)
|
|
|
|
int x, y;
|
|
|
|
{
|
|
|
|
struct tx3912video_chip *vc = &tx3912video_chip;
|
|
|
|
vc->vc_drawdot(x, y);
|
|
|
|
}
|