debug frame buffer draw routines moved to video_subr.c.

plumvideo also use it.
This commit is contained in:
uch 2000-05-22 17:17:44 +00:00
parent 09e72ae7e2
commit 27a7fbff47
9 changed files with 494 additions and 426 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: plumvideo.c,v 1.10 2000/05/21 11:22:25 uch Exp $ */
/* $NetBSD: plumvideo.c,v 1.11 2000/05/22 17:17:44 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
@ -25,6 +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.
*/
#define PLUMVIDEODEBUG
#include "opt_tx39_debug.h"
@ -57,7 +58,6 @@
#include <arch/hpcmips/dev/hpcfbvar.h>
#include <arch/hpcmips/dev/hpcfbio.h>
#ifdef PLUMVIDEODEBUG
int plumvideo_debug = 1;
#define DPRINTF(arg) if (plumvideo_debug) printf arg;
@ -69,8 +69,9 @@ int plumvideo_debug = 1;
struct plumvideo_softc {
struct device sc_dev;
tx_chipset_tag_t sc_tc;
plum_chipset_tag_t sc_pc;
/* control register */
bus_space_tag_t sc_regt;
bus_space_handle_t sc_regh;
@ -84,10 +85,7 @@ struct plumvideo_softc {
bus_space_tag_t sc_bitbltt;
bus_space_handle_t sc_bitblth;
int sc_width;
int sc_height;
int sc_depth;
struct video_chip sc_chip;
struct hpcfb_fbconf sc_fbconf;
struct hpcfb_dspconf sc_dspconf;
};
@ -199,13 +197,17 @@ plumvideo_attach(parent, self, aux)
printf("\n");
#ifdef PLUMVIDEODEBUG
if (plumvideo_debug)
plumvideo_dump(sc);
#endif
/* Attach frame buffer device */
plumvideo_hpcfbinit(sc);
#ifdef PLUMVIDEODEBUG
if (plumvideo_debug > 1)
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");
@ -229,7 +231,11 @@ plumvideo_hpcfbinit(sc)
struct plumvideo_softc *sc;
{
struct hpcfb_fbconf *fb = &sc->sc_fbconf;
struct video_chip *chip = &sc->sc_chip;
vaddr_t fbvaddr = (vaddr_t)sc->sc_fbioh;
int height = chip->vc_fbheight;
int width = chip->vc_fbwidth;
int depth = chip->vc_fbdepth;
memset(fb, 0, sizeof(struct hpcfb_fbconf));
@ -239,20 +245,20 @@ plumvideo_hpcfbinit(sc)
/* frame buffer name */
strncpy(fb->hf_conf_name, "LCD", HPCFB_MAXNAMELEN);
/* configuration name */
fb->hf_height = sc->sc_height;
fb->hf_width = sc->sc_width;
fb->hf_height = height;
fb->hf_width = width;
fb->hf_baseaddr = mips_ptob(mips_btop(fbvaddr));
fb->hf_offset = (u_long)fbvaddr - fb->hf_baseaddr;
/* frame buffer start offset */
fb->hf_bytes_per_line = (sc->sc_width * sc->sc_depth) / NBBY;
fb->hf_bytes_per_line = (width * depth) / NBBY;
fb->hf_nplanes = 1;
fb->hf_bytes_per_plane = sc->sc_height * fb->hf_bytes_per_line;
fb->hf_bytes_per_plane = height * fb->hf_bytes_per_line;
fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
fb->hf_access_flags |= HPCFB_ACCESS_WORD;
fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
switch (sc->sc_depth) {
switch (depth) {
default:
panic("plumvideo_hpcfbinit: not supported color depth\n");
/* NOTREACHED */
@ -298,7 +304,10 @@ plumvideo_init(sc)
bus_space_handle_t regh = sc->sc_regh;
plumreg_t reg;
size_t vram_size;
int bpp, vram_pitch;
int bpp, width, height, vram_pitch;
struct video_chip *chip = &sc->sc_chip;
chip->vc_v = sc->sc_pc->pc_tc;
#if notyet
/* map BitBlt area */
if (bus_space_map(sc->sc_bitbltt,
@ -334,23 +343,23 @@ plumvideo_init(sc)
bpp = 8;
break;
}
sc->sc_depth = bpp;
chip->vc_fbdepth = bpp;
/*
* Get display size from WindowsCE setted.
*/
sc->sc_width = bootinfo->fb_width =
chip->vc_fbwidth = width = bootinfo->fb_width =
plum_conf_read(regt, regh, PLUM_VIDEO_PLHPX_REG) + 1;
sc->sc_height = bootinfo->fb_height =
chip->vc_fbheight = height = bootinfo->fb_height =
plum_conf_read(regt, regh, PLUM_VIDEO_PLVT_REG) -
plum_conf_read(regt, regh, PLUM_VIDEO_PLVDS_REG);
/*
* set line byte length to bootinfo and LCD controller.
*/
bootinfo->fb_line_bytes = (sc->sc_width * bpp) / NBBY;
bootinfo->fb_line_bytes = (width * bpp) / NBBY;
vram_pitch = sc->sc_width / (8 / bpp);
vram_pitch = width / (8 / bpp);
plum_conf_write(regt, regh, PLUM_VIDEO_PLPIT1_REG, vram_pitch);
plum_conf_write(regt, regh, PLUM_VIDEO_PLPIT2_REG,
vram_pitch & PLUM_VIDEO_PLPIT2_MASK);
@ -386,8 +395,9 @@ plumvideo_init(sc)
* calcurate frame buffer size.
*/
reg = plum_conf_read(regt, regh, PLUM_VIDEO_PLGMD_REG);
vram_size = (sc->sc_width * sc->sc_height * bpp) / NBBY;
vram_size = (width * height * bpp) / NBBY;
vram_size = mips_round_page(vram_size);
chip->vc_fbsize = vram_size;
/*
* map V-RAM area.
@ -399,6 +409,8 @@ plumvideo_init(sc)
}
bootinfo->fb_addr = (unsigned char *)sc->sc_fbioh;
chip->vc_fbvaddr = (vaddr_t)sc->sc_fbioh;
chip->vc_fbpaddr = PLUM_VIDEO_VRAM_IOBASE_PHYSICAL;
return (0);
}

View File

@ -1,29 +1,29 @@
/* $NetBSD: ucb1200reg.h,v 1.5 2000/03/12 15:36:11 uch Exp $ */
/* $NetBSD: ucb1200reg.h,v 1.6 2000/05/22 17:17:44 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
* All rights reserved.
/*-
* Copyright (c) 2000 UCHIYAMA Yasushi. 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.
* 2. The name of the developer may NOT be used to endorse or promote products
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* 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.
*/
/*
@ -61,11 +61,11 @@
#define UCB1200_TELECOMCTRLA_DIV_MAX 127
#define UCB1200_TELECOMCTRLA_DIV_SHIFT 0
#define UCB1200_TELECOMCTRLA_DIV_MASK 0x7f
#define UCB1200_TELECOMCTRLA_DIV(cr) \
(((cr) >> UCB1200_TELECOMCTRLA_DIV_SHIFT) & \
#define UCB1200_TELECOMCTRLA_DIV(cr) \
(((cr) >> UCB1200_TELECOMCTRLA_DIV_SHIFT) & \
UCB1200_TELECOMCTRLA_DIV_MASK)
#define UCB1200_TELECOMCTRLA_DIV_SET(cr, val) \
((cr) | (((val) << UCB1200_TELECOMCTRLA_DIV_SHIFT) & \
#define UCB1200_TELECOMCTRLA_DIV_SET(cr, val) \
((cr) | (((val) << UCB1200_TELECOMCTRLA_DIV_SHIFT) & \
(UCB1200_TELECOMCTRLA_DIV_MASK << UCB1200_TELECOMCTRLA_DIV_SHIFT)))
#define UCB1200_TELECOMCTRLA_LOOP 0x0080
@ -88,20 +88,20 @@
#define UCB1200_AUDIOCTRLA_DIV_MAX 127
#define UCB1200_AUDIOCTRLA_DIV_SHIFT 0
#define UCB1200_AUDIOCTRLA_DIV_MASK 0x7f
#define UCB1200_AUDIOCTRLA_DIV(cr) \
(((cr) >> UCB1200_AUDIOCTRLA_DIV_SHIFT) & \
#define UCB1200_AUDIOCTRLA_DIV(cr) \
(((cr) >> UCB1200_AUDIOCTRLA_DIV_SHIFT) & \
UCB1200_AUDIOCTRLA_DIV_MASK)
#define UCB1200_AUDIOCTRLA_DIV_SET(cr, val) \
((cr) | (((val) << UCB1200_AUDIOCTRLA_DIV_SHIFT) & \
#define UCB1200_AUDIOCTRLA_DIV_SET(cr, val) \
((cr) | (((val) << UCB1200_AUDIOCTRLA_DIV_SHIFT) & \
(UCB1200_AUDIOCTRLA_DIV_MASK << UCB1200_AUDIOCTRLA_DIV_SHIFT)))
#define UCB1200_AUDIOCTRLA_GAIN_SHIFT 7
#define UCB1200_AUDIOCTRLA_GAIN_MASK 0x1f
#define UCB1200_AUDIOCTRLA_GAIN(cr) \
(((cr) >> UCB1200_AUDIOCTRLA_GAIN_SHIFT) & \
#define UCB1200_AUDIOCTRLA_GAIN(cr) \
(((cr) >> UCB1200_AUDIOCTRLA_GAIN_SHIFT) & \
UCB1200_AUDIOCTRLA_GAIN_MASK)
#define UCB1200_AUDIOCTRLA_GAIN_SET(cr, val) \
((cr) | (((val) << UCB1200_AUDIOCTRLA_GAIN_SHIFT) & \
#define UCB1200_AUDIOCTRLA_GAIN_SET(cr, val) \
((cr) | (((val) << UCB1200_AUDIOCTRLA_GAIN_SHIFT) & \
(UCB1200_AUDIOCTRLA_GAIN_MASK << UCB1200_AUDIOCTRLA_GAIN_SHIFT)))
/*
@ -136,8 +136,8 @@
#define UCB1200_TSCTRL_MODE_SHIFT 8
#define UCB1200_TSCTRL_MODE_MASK 0x7f
#define UCB1200_TSCTRL_MODE(cr) \
(((cr) >> UCB1200_TSCTRL_MODE_SHIFT) & \
#define UCB1200_TSCTRL_MODE(cr) \
(((cr) >> UCB1200_TSCTRL_MODE_SHIFT) & \
UCB1200_TSCTRL_MODE_MASK)
#define UCB1200_TSCTRL_MODE_INTERRUPT 0
#define UCB1200_TSCTRL_MODE_PRESSURE (1 << UCB1200_TSCTRL_MODE_SHIFT)
@ -154,19 +154,20 @@
#define UCB1200_TSCTRL_MXPWR 0x00000001
/* touch screen modes */
#define UCB1200_TSCTRL_YPOSITION \
(UCB1200_TSCTRL_PXPWR | UCB1200_TSCTRL_MXGND | \
#define UCB1200_TSCTRL_YPOSITION \
(UCB1200_TSCTRL_PXPWR | UCB1200_TSCTRL_MXGND | \
UCB1200_TSCTRL_MODE_POSITION0 | UCB1200_TSCTRL_BIAS)
#define UCB1200_TSCTRL_XPOSITION \
(UCB1200_TSCTRL_PYPWR | UCB1200_TSCTRL_MYGND | \
#define UCB1200_TSCTRL_XPOSITION \
(UCB1200_TSCTRL_PYPWR | UCB1200_TSCTRL_MYGND | \
UCB1200_TSCTRL_MODE_POSITION0 | UCB1200_TSCTRL_BIAS)
#define UCB1200_TSCTRL_PRESSURE \
(UCB1200_TSCTRL_PXPWR | UCB1200_TSCTRL_MXPWR | \
UCB1200_TSCTRL_PYGND | UCB1200_TSCTRL_MYGND | \
#define UCB1200_TSCTRL_PRESSURE \
(UCB1200_TSCTRL_PXPWR | UCB1200_TSCTRL_MXPWR | \
UCB1200_TSCTRL_PYGND | UCB1200_TSCTRL_MYGND | \
UCB1200_TSCTRL_MODE_PRESSURE | UCB1200_TSCTRL_BIAS)
#define UCB1200_TSCTRL_INTERRUPT \
(UCB1200_TSCTRL_PXPWR | UCB1200_TSCTRL_MXPWR | \
UCB1200_TSCTRL_PYGND | UCB1200_TSCTRL_MYGND | \
#define UCB1200_TSCTRL_INTERRUPT \
(UCB1200_TSCTRL_PXPWR | UCB1200_TSCTRL_MXPWR | \
UCB1200_TSCTRL_PYGND | UCB1200_TSCTRL_MYGND | \
UCB1200_TSCTRL_MODE_INTERRUPT)
#define UCB1200_TSCTRL_PRESSURE1
@ -186,8 +187,8 @@
#define UCB1200_ADCCTRL_INPUT_SHIFT 2
#define UCB1200_ADCCTRL_INPUT_MASK 0x7
#define UCB1200_ADCCTRL_INPUT_SET(cr, val) \
((cr) | (((val) << UCB1200_ADCCTRL_INPUT_SHIFT) & \
#define UCB1200_ADCCTRL_INPUT_SET(cr, val) \
((cr) | (((val) << UCB1200_ADCCTRL_INPUT_SHIFT) & \
(UCB1200_ADCCTRL_INPUT_MASK << UCB1200_ADCCTRL_INPUT_SHIFT)))
#define UCB1200_ADCCTRL_INPUT_TSPX 0x0
#define UCB1200_ADCCTRL_INPUT_TSMX 0x1
@ -208,8 +209,8 @@
#define UCB1200_ADCDATA_SHIFT 5
#define UCB1200_ADCDATA_MASK 0x3ff
#define UCB1200_ADCDATA(cr) \
(((cr) >> UCB1200_ADCDATA_SHIFT) & \
#define UCB1200_ADCDATA(cr) \
(((cr) >> UCB1200_ADCDATA_SHIFT) & \
UCB1200_ADCDATA_MASK)
/*

View File

@ -1,29 +1,29 @@
/* $NetBSD: ucbtp.c,v 1.3 2000/03/04 19:36:34 uch Exp $ */
/* $NetBSD: ucbtp.c,v 1.4 2000/05/22 17:17:45 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
* All rights reserved.
/*-
* Copyright (c) 2000 UCHIYAMA Yasushi. 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.
* 2. The name of the developer may NOT be used to endorse or promote products
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* 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.
*/
/*
@ -53,16 +53,14 @@
#include <hpcmips/tx/tx39sibreg.h>
#include <hpcmips/tx/tx39icureg.h>
#ifdef TX391X
#include <hpcmips/tx/tx3912videovar.h> /* debug */
#endif
#include <hpcmips/dev/ucb1200var.h>
#include <hpcmips/dev/ucb1200reg.h>
#include <hpcmips/tx/txsnd.h>
#include <hpcmips/dev/video_subr.h> /* debug */
#ifdef UCBTPDEBUG
int ucbtp_debug = 1;
int ucbtp_debug = 0;
#define DPRINTF(arg) if (ucbtp_debug) printf arg;
#define DPRINTFN(n, arg) if (ucbtp_debug > (n)) printf arg;
#else
@ -106,10 +104,10 @@ enum ucbadc_state {
};
struct ucbtp_softc {
struct device sc_dev;
struct device *sc_sib; /* parent (TX39 SIB module) */
struct device *sc_ucb; /* parent (UCB1200 module) */
tx_chipset_tag_t sc_tc;
struct device sc_dev;
struct device *sc_sib; /* parent (TX39 SIB module) */
struct device *sc_ucb; /* parent (UCB1200 module) */
tx_chipset_tag_t sc_tc;
enum ucbts_stat sc_stat;
int sc_polling;
@ -122,30 +120,31 @@ struct ucbtp_softc {
/* measurement value */
int sc_x, sc_y, sc_p;
int sc_ox, sc_oy;
int sc_xy_reverse; /* some platform pin connect interchanged */
/*
* touch panel state machine
*/
void *sm_ih; /* TX39 SIB subframe 0 interrupt handler */
void *sm_ih; /* TX39 SIB subframe 0 interrupt handler */
int sm_addr; /* UCB1200 register address */
u_int32_t sm_reg; /* UCB1200 register data & TX39 SIB header */
int sm_tmpreg;
int sm_addr; /* UCB1200 register address */
u_int32_t sm_reg; /* UCB1200 register data & TX39 SIB header */
int sm_tmpreg;
#define UCBADC_RETRY_DEFAULT 200
int sm_retry; /* retry counter */
int sm_retry; /* retry counter */
enum ucbadc_state sm_state;
int sm_measurement; /* X, Y, Pressure */
#define UCBADC_MEASUREMENT_X 0
#define UCBADC_MEASUREMENT_Y 1
#define UCBADC_MEASUREMENT_PRESSURE 2
int sm_returnstate;
int sm_returnstate;
int sm_read_state, sm_write_state;
int sm_writing; /* writing state flag */
u_int32_t sm_write_val; /* temporary buffer */
int sm_read_state, sm_write_state;
int sm_writing; /* writing state flag */
u_int32_t sm_write_val; /* temporary buffer */
int sm_rw_retry; /* retry counter for r/w */
int sm_rw_retry; /* retry counter for r/w */
/* wsmouse */
struct device *sc_wsmousedev;
@ -210,6 +209,14 @@ struct calibration_sample_table {
{ 241, 115, 600, 200 },
{ 747, 101, 600, 40 }}}},
{{{PLATID_WILD, PLATID_MACH_SHARP_TELIOS_HCAJ1}}, /* uch machine */
{ 0, 0, 799, 479, 5,
{{ 850, 150, 1, 1 },
{ 850, 880, 1, 479 },
{ 850, 880, 1, 479 },
{ 85, 880, 799, 479 },
{ 85, 150, 799, 1 }}}},
{{{PLATID_UNKNOWN, PLATID_UNKNOWN}},
{ 0, 0, 639, 239, 5,
{{0, 0, 0, 0},
@ -231,11 +238,11 @@ calibration_sample_lookup()
mask = PLATID_DEREF(&tab->cst_platform);
if (platid_match(&platid, &mask)) {
return &tab->cst_sample;
return (&tab->cst_sample);
}
}
return 0;
return (0);
}
int
@ -243,14 +250,15 @@ ucbtp_calibration(sc)
struct ucbtp_softc *sc;
{
struct wsmouse_calibcoords *cs;
#ifdef TX391X
tx3912video_calibration_pattern(); /* debug */
#endif
if (sc->sc_tc->tc_videot)
video_calibration_pattern(sc->sc_tc->tc_videot); /* debug */
tpcalib_init(&sc->sc_tpcalib);
if (!(cs = calibration_sample_lookup())) {
printf("no calibration data");
return 1;
DPRINTF(("no calibration data"));
return (1);
}
sc->sc_calibrated =
@ -261,7 +269,7 @@ ucbtp_calibration(sc)
printf("not ");
printf("calibrated");
return 0;
return (0);
}
int
@ -270,7 +278,7 @@ ucbtp_match(parent, cf, aux)
struct cfdata *cf;
void *aux;
{
return 1;
return (1);
}
void
@ -295,7 +303,10 @@ ucbtp_attach(parent, self, aux)
/* attempt to calibrate touch panel */
ucbtp_calibration(sc);
#ifdef TX392X /* hack for Telios HC-VJ1C */
sc->sc_xy_reverse = 1;
#endif
printf("\n");
wsmaa.accessops = &ucbtp_accessops;
@ -315,7 +326,7 @@ ucbtp_busy(arg)
{
struct ucbtp_softc *sc = arg;
return sc->sm_state != UCBADC_IDLE;
return (sc->sm_state != UCBADC_IDLE);
}
int
@ -325,18 +336,18 @@ ucbtp_poll(arg)
struct ucbtp_softc *sc = arg;
if (!ucb1200_state_idle(sc->sc_ucb)) /* subframe0 busy */
return POLL_CONT;
return (POLL_CONT);
if (sc->sc_polling_finish) {
sc->sc_polling_finish = 0;
return POLL_END;
return (POLL_END);
}
/* execute A-D converter */
sc->sm_state = UCBADC_ADC_INIT;
ucbtp_adc_async(sc);
return POLL_CONT;
return (POLL_CONT);
}
int
@ -361,17 +372,17 @@ ucbtp_sibintr(arg)
/* don't acknoledge interrupt until polling finish */
return 0;
return (0);
}
#define REGWRITE(addr, reg, ret) ( \
sc->sm_addr = (addr), \
sc->sm_reg = (reg), \
sc->sm_returnstate = (ret),\
#define REGWRITE(addr, reg, ret) ( \
sc->sm_addr = (addr), \
sc->sm_reg = (reg), \
sc->sm_returnstate = (ret), \
sc->sm_state = UCBADC_REGWRITE)
#define REGREAD(addr, ret) ( \
sc->sm_addr = (addr), \
sc->sm_returnstate = (ret), \
#define REGREAD(addr, ret) ( \
sc->sm_addr = (addr), \
sc->sm_returnstate = (ret), \
sc->sm_state = UCBADC_REGREAD)
int
@ -575,7 +586,6 @@ ucbtp_adc_async(arg)
reg = tx_conf_read(tc, TX39_SIBSF0STAT_REG);
if ((TX39_SIBSF0_REGADDR(reg) != sc->sm_addr) &&
--sc->sm_rw_retry > 0) {
printf("retry!\n");
break;
}
@ -624,27 +634,26 @@ ucbtp_adc_async(arg)
break;
}
return 0;
return (0);
}
int
ucbtp_input(sc)
struct ucbtp_softc *sc;
{
int x, y;
int rx, ry, x, y, p;
rx = sc->sc_x;
ry = sc->sc_y;
p = sc->sc_p;
if (!sc->sc_calibrated) {
DPRINTFN(2, ("x=%d y=%d p=%d\n",
sc->sc_x, sc->sc_y, sc->sc_p));
printf("ucbtp_input: no calibration data\n");
return 0;
DPRINTFN(2, ("x=%4d y=%4d p=%4d\n", rx, ry, p));
DPRINTF(("ucbtp_input: no calibration data\n"));
}
tpcalib_trans(&sc->sc_tpcalib, sc->sc_x, sc->sc_y, &x, &y);
DPRINTFN(2, ("x: %d->%d y: %d->%d pressure=%d\n",
sc->sc_x, x, sc->sc_y, y, sc->sc_p));
if (sc->sc_p < UCBTS_PRESS_THRESHOLD) {
if (p < UCBTS_PRESS_THRESHOLD || rx == 0x3ff || ry == 0x3ff ||
rx == 0 || ry == 0) {
sc->sc_stat = UCBTS_STAT_RELEASE;
if (sc->sc_polling < UCBTS_TAP_THRESHOLD) {
DPRINTFN(2, ("TAP!\n"));
@ -662,20 +671,32 @@ ucbtp_input(sc)
}
sc->sc_polling = 0;
return 1;
return (1);
}
if (sc->sc_xy_reverse)
tpcalib_trans(&sc->sc_tpcalib, ry, rx, &x, &y);
else
tpcalib_trans(&sc->sc_tpcalib, rx, ry, &x, &y);
DPRINTFN(2, ("x: %4d->%4d y: %4d->%4d pressure=%4d\n",
rx, x, ry, y, p));
/* debug draw */
if (sc->sc_tc->tc_videot) {
if (sc->sc_polling == 1)
video_dot(sc->sc_tc->tc_videot, x, y);
else
video_line(sc->sc_tc->tc_videot, sc->sc_ox,
sc->sc_oy, x, y);
}
#ifdef TX391X /* debug */
if (sc->sc_polling == 1)
tx3912video_dot(x, y);
else
tx3912video_line(sc->sc_ox, sc->sc_oy, x, y);
sc->sc_ox = x, sc->sc_oy = y;
#endif
wsmouse_input(sc->sc_wsmousedev, 1, x, y, 0,
WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
return 0;
return (0);
}
/*
@ -687,7 +708,7 @@ ucbtp_enable(v)
void *v;
{
/* not yet */
return 0;
return (0);
}
void
@ -726,5 +747,6 @@ ucbtp_ioctl(v, cmd, data, flag, p)
default:
return (-1);
}
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: video_subr.c,v 1.1 2000/05/08 21:57:56 uch Exp $ */
/* $NetBSD: video_subr.c,v 1.2 2000/05/22 17:17:44 uch Exp $ */
/*-
* Copyright (c) 2000 UCHIYAMA Yasushi. All rights reserved.
@ -32,6 +32,119 @@
#include <arch/hpcmips/dev/video_subr.h>
#define BPP2 ({ \
u_int8_t bitmap; \
bitmap = *(volatile u_int8_t*)addr; \
*(volatile u_int8_t*)addr = \
(bitmap & ~(0x3 << ((3 - (x % 4)) * 2))); \
})
#define BPP4 ({ \
u_int8_t bitmap; \
bitmap = *(volatile u_int8_t*)addr; \
*(volatile u_int8_t*)addr = \
(bitmap & ~(0xf << ((1 - (x % 2)) * 4))); \
})
#define BPP8 ({ \
*(volatile u_int8_t*)addr = 0xff; \
})
#define BRESENHAM(a, b, c, d, func) ({ \
u_int32_t fbaddr = vc->vc_fbvaddr; \
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((struct video_chip *, int, int, int, int)); \
static void \
linebpp##b##(vc, x0, y0, x1, y1) \
struct video_chip *vc; \
int x0, y0, x1, y1; \
{ \
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((struct video_chip *, int, int)); \
static void \
dotbpp##b##(vc, x, y) \
struct video_chip *vc; \
int x, y; \
{ \
u_int32_t addr; \
addr = vc->vc_fbvaddr + (((y * vc->vc_fbwidth + x) * \
vc->vc_fbdepth) >> 3); \
BPP##b; \
}
LINEFUNC(2)
LINEFUNC(4)
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));
int
cmap_work_alloc(r, g, b, rgb, cnt)
u_int8_t **r, **g, **b;
@ -93,3 +206,80 @@ rgb24_decompose(rgb24, r, g, b, cnt)
*b++ = rgb & 0xff;
}
}
/*
* Debug routines.
*/
void
video_calibration_pattern(vc)
struct video_chip *vc;
{
int x, y;
x = vc->vc_fbwidth - 40;
y = vc->vc_fbheight - 40;
video_line(vc, 40, 40, x , 40);
video_line(vc, x , 40, x , y );
video_line(vc, x , y , 40, y );
video_line(vc, 40, y , 40, 40);
video_line(vc, 40, 40, x , y );
video_line(vc, x, 40, 40, y );
}
static void
linebpp_unimpl(vc, x0, y0, x1, y1)
struct video_chip *vc;
int x0, y0, x1, y1;
{
return;
}
static void
dotbpp_unimpl(vc, x, y)
struct video_chip *vc;
int x, y;
{
return;
}
void
video_attach_drawfunc(vc)
struct video_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
video_line(vc, x0, y0, x1, y1)
struct video_chip *vc;
int x0, y0, x1, 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;
{
if (vc->vc_drawdot)
vc->vc_drawdot(vc, x, y);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: video_subr.h,v 1.2 2000/05/13 03:12:56 uch Exp $ */
/* $NetBSD: video_subr.h,v 1.3 2000/05/22 17:17:44 uch Exp $ */
/*-
* Copyright (c) 2000 UCHIYAMA Yasushi. All rights reserved.
@ -31,11 +31,30 @@
(((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 __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));
/* debug function for TX. VR will need `line bytes' */
struct video_chip;
struct video_chip {
void *vc_v; /* CPU/chipset dependent goo */
vaddr_t vc_fbvaddr;
paddr_t vc_fbpaddr;
size_t vc_fbsize;
int vc_fbdepth;
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 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 *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39.c,v 1.17 2000/05/21 11:24:45 uch Exp $ */
/* $NetBSD: tx39.c,v 1.18 2000/05/22 17:17:44 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
@ -405,6 +405,18 @@ tx_conf_register_ioman(t, iomant)
tx_chipset.tc_iomant = iomant;
}
void
tx_conf_register_video(t, videot)
tx_chipset_tag_t t;
void *videot;
{
if (t != &tx_chipset) {
panic("bogus tx_chipset_tag");
}
tx_chipset.tc_videot = videot;
}
#ifdef TX39_PREFER_FUNCTION
tx_chipset_tag_t
tx_conf_get_tag()

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx3912video.c,v 1.14 2000/05/12 18:09:55 uch Exp $ */
/* $NetBSD: tx3912video.c,v 1.15 2000/05/22 17:17:44 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
@ -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.
*/
#undef TX3912VIDEO_DEBUG
#define TX3912VIDEO_DEBUG
#include "opt_tx39_debug.h"
#include "hpcfb.h"
@ -55,31 +55,21 @@
#include <arch/hpcmips/dev/hpcfbvar.h>
#include <arch/hpcmips/dev/hpcfbio.h>
static struct tx3912video_chip {
tx_chipset_tag_t vc_tc;
paddr_t vc_fbaddr;
size_t vc_fbsize;
int vc_fbdepth;
int vc_fbwidth;
int vc_fbheight;
void (*vc_drawline) __P((int, int, int, int)); /* for debug */
void (*vc_drawdot) __P((int, int)); /* for debug */
} tx3912video_chip;
struct tx3912video_softc {
struct device sc_dev;
struct hpcfb_fbconf sc_fbconf;
struct hpcfb_dspconf sc_dspconf;
struct tx3912video_chip *sc_chip;
struct video_chip *sc_chip;
};
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 *));
/* TX3912 built-in video chip itself */
static struct video_chip tx3912video_chip;
void tx3912video_framebuffer_init __P((struct video_chip *));
int tx3912video_framebuffer_alloc __P((struct video_chip *,
paddr_t, paddr_t *));
void tx3912video_reset __P((struct video_chip *));
void tx3912video_resolution_init __P((struct video_chip *));
int tx3912video_match __P((struct device *, struct cfdata *, void *));
void tx3912video_attach __P((struct device *, struct device *, void *));
@ -106,8 +96,6 @@ struct hpcfb_accessops tx3912video_ha = {
tx3912video_clut_install
};
void __tx3912video_attach_drawfunc __P((struct tx3912video_chip*));
int
tx3912video_match(parent, cf, aux)
struct device *parent;
@ -124,7 +112,7 @@ tx3912video_attach(parent, self, aux)
void *aux;
{
struct tx3912video_softc *sc = (void *)self;
struct tx3912video_chip *chip;
struct video_chip *chip;
const char *depth_print[] = {
[TX3912_VIDEOCTRL1_BITSEL_MONOCHROME] = "monochrome",
[TX3912_VIDEOCTRL1_BITSEL_2BITGREYSCALE] = "2bit greyscale",
@ -141,11 +129,11 @@ tx3912video_attach(parent, self, aux)
/* 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));
(unsigned)chip->vc_fbpaddr,
(unsigned)(chip->vc_fbpaddr + chip->vc_fbsize));
/* don't inverse VDAT[3:0] signal */
tc = chip->vc_tc;
tc = chip->vc_v;
val = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
val &= ~TX3912_VIDEOCTRL1_INVVID;
tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, val);
@ -166,7 +154,8 @@ tx3912video_attach(parent, self, aux)
#ifdef TX3912VIDEO_DEBUG
/* attach debug draw routine (debugging use) */
__tx3912video_attach_drawfunc(sc->sc_chip);
video_attach_drawfunc(sc->sc_chip);
tx_conf_register_video(tc, sc->sc_chip);
#endif
/* Attach frame buffer device */
@ -193,9 +182,9 @@ void
tx3912video_hpcfbinit(sc)
struct tx3912video_softc *sc;
{
struct tx3912video_chip *chip = sc->sc_chip;
struct video_chip *chip = sc->sc_chip;
struct hpcfb_fbconf *fb = &sc->sc_fbconf;
vaddr_t fbvaddr = (vaddr_t)MIPS_PHYS_TO_KSEG1(chip->vc_fbaddr);
vaddr_t fbvaddr = (vaddr_t)MIPS_PHYS_TO_KSEG1(chip->vc_fbpaddr);
memset(fb, 0, sizeof(struct hpcfb_fbconf));
@ -250,13 +239,13 @@ int
tx3912video_init(fb_start, fb_end)
paddr_t fb_start, *fb_end;
{
struct tx3912video_chip *chip = &tx3912video_chip;
struct video_chip *chip = &tx3912video_chip;
tx_chipset_tag_t tc;
txreg_t reg;
int fbdepth;
int error;
chip->vc_tc = tc = tx_conf_get_tag();
chip->vc_v = tc = tx_conf_get_tag();
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
fbdepth = 1 << (TX3912_VIDEOCTRL1_BITSEL(reg));
@ -280,9 +269,9 @@ tx3912video_init(fb_start, fb_end)
break;
}
tx3912video_chip.vc_fbdepth = fbdepth;
tx3912video_chip.vc_fbwidth = bootinfo->fb_width;
tx3912video_chip.vc_fbheight= bootinfo->fb_height;
chip->vc_fbdepth = fbdepth;
chip->vc_fbwidth = bootinfo->fb_width;
chip->vc_fbheight= bootinfo->fb_height;
/* Allocate framebuffer area */
error = tx3912video_framebuffer_alloc(chip, fb_start, fb_end);
@ -301,14 +290,14 @@ tx3912video_init(fb_start, fb_end)
tx3912video_reset(chip);
bootinfo->fb_line_bytes = (chip->vc_fbwidth * fbdepth) / NBBY;
bootinfo->fb_addr = (void *)MIPS_PHYS_TO_KSEG1(chip->vc_fbaddr);
bootinfo->fb_addr = (void *)MIPS_PHYS_TO_KSEG1(chip->vc_fbpaddr);
return (0);
}
int
tx3912video_framebuffer_alloc(chip, fb_start, fb_end)
struct tx3912video_chip *chip;
struct video_chip *chip;
paddr_t fb_start, *fb_end; /* buffer allocation hint */
{
struct extent_fixed ex_fixed[10];
@ -338,7 +327,8 @@ tx3912video_framebuffer_alloc(chip, fb_start, fb_end)
return (1);
}
chip->vc_fbaddr = addr;
chip->vc_fbpaddr = addr;
chip->vc_fbvaddr = MIPS_PHYS_TO_KSEG1(addr);
chip->vc_fbsize = size;
*fb_end = addr + size;
@ -348,13 +338,13 @@ tx3912video_framebuffer_alloc(chip, fb_start, fb_end)
void
tx3912video_framebuffer_init(chip)
struct tx3912video_chip *chip;
struct video_chip *chip;
{
u_int32_t fb_addr, fb_size, vaddr, bank, base;
txreg_t reg;
tx_chipset_tag_t tc = chip->vc_tc;
tx_chipset_tag_t tc = chip->vc_v;
fb_addr = chip->vc_fbaddr;
fb_addr = chip->vc_fbpaddr;
fb_size = chip->vc_fbsize;
/* XXX currently I don't set DFVAL, so force DF signal toggled on
@ -390,10 +380,10 @@ tx3912video_framebuffer_init(chip)
void
tx3912video_resolution_init(chip)
struct tx3912video_chip *chip;
struct video_chip *chip;
{
int h, v, split, bit8, horzval, lineval;
tx_chipset_tag_t tc = chip->vc_tc;
tx_chipset_tag_t tc = chip->vc_v;
txreg_t reg;
u_int32_t val;
@ -429,9 +419,9 @@ tx3912video_resolution_init(chip)
void
tx3912video_reset(chip)
struct tx3912video_chip *chip;
struct video_chip *chip;
{
tx_chipset_tag_t tc = chip->vc_tc;
tx_chipset_tag_t tc = chip->vc_v;
txreg_t reg;
reg = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG);
@ -581,7 +571,7 @@ tx3912video_mmap(ctx, offset, prot)
return (-1);
}
return (mips_btop(sc->sc_chip->vc_fbaddr + offset));
return (mips_btop(sc->sc_chip->vc_fbpaddr + offset));
}
/*
@ -702,7 +692,7 @@ void
tx3912video_clut_init(sc)
struct tx3912video_softc *sc;
{
tx_chipset_tag_t tc = sc->sc_chip->vc_tc;
tx_chipset_tag_t tc = sc->sc_chip->vc_v;
if (sc->sc_chip->vc_fbdepth != 8) {
return; /* XXX 2bit gray scale LUT not supported */
@ -766,190 +756,3 @@ tx3912video_clut_init(sc)
tx3912video_reset(sc->sc_chip);
}
/*
* 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
__tx3912video_attach_drawfunc(vc)
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;
if (vc->vc_drawline)
vc->vc_drawline(x0, y0, x1, y1);
}
void
tx3912video_dot(x, y)
int x, y;
{
struct tx3912video_chip *vc = &tx3912video_chip;
if (vc->vc_drawdot)
vc->vc_drawdot(x, y);
}

View File

@ -1,30 +1,31 @@
/* $NetBSD: tx39power.c,v 1.5 2000/01/16 21:47:00 uch Exp $ */
/* $NetBSD: tx39power.c,v 1.6 2000/05/22 17:17:44 uch Exp $ */
/*
* Copyright (c) 1999, 2000 by UCHIYAMA Yasushi
* All rights reserved.
/*-
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi. 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.
* 2. The name of the developer may NOT be used to endorse or promote products
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* 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.
*/
#include "opt_tx39_debug.h"
#include "opt_tx39powerdebug.h"
#include "opt_ddb.h"
@ -41,6 +42,8 @@
#include <hpcmips/tx/tx39powerreg.h>
#include <hpcmips/tx/tx39spireg.h>
#include <hpcmips/dev/video_subr.h>
#undef POWERBUTTON_IS_DEBUGGER
#define ISSET(x, v) ((x) & (v))
@ -176,7 +179,11 @@ int
tx39power_button_intr(arg)
void *arg;
{
printf("power button\n");
struct tx39power_softc *sc = arg;
if (sc->sc_tc->tc_videot)
video_calibration_pattern(sc->sc_tc->tc_videot); /* debug */
#if defined DDB && defined POWERBUTTON_IS_DEBUGGER
cpu_Debugger();
#endif

View File

@ -1,29 +1,29 @@
/* $NetBSD: tx39var.h,v 1.5 2000/01/16 21:47:01 uch Exp $ */
/* $NetBSD: tx39var.h,v 1.6 2000/05/22 17:17:44 uch Exp $ */
/*
* Copyright (c) 1999, 2000 by UCHIYAMA Yasushi
* All rights reserved.
/*-
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi. 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.
* 2. The name of the developer may NOT be used to endorse or promote products
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* 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.
*/
struct tx_chipset_tag {
@ -32,6 +32,7 @@ struct tx_chipset_tag {
void *tc_clockt; /* clock/timer tag */
void *tc_soundt; /* sound tag */
void *tc_iomant; /* io manager tag */
void *tc_videot; /* video chip tag */
};
typedef struct tx_chipset_tag* tx_chipset_tag_t;
@ -42,6 +43,7 @@ void tx_conf_register_power __P((tx_chipset_tag_t, void*));
void tx_conf_register_clock __P((tx_chipset_tag_t, void*));
void tx_conf_register_sound __P((tx_chipset_tag_t, void*));
void tx_conf_register_ioman __P((tx_chipset_tag_t, void*));
void tx_conf_register_video __P((tx_chipset_tag_t, void*));
/*
* TX39 Internal Function Register access