示例#1
0
int main(int argc, string argv[])
{
  real rrange[2], rmax;
  int np;
  double lgrs;
  gsprof *gsp;
  stream ostr;

  initparam(argv, defv);
  setrange(rrange, getparam("rrange"));
  np = getiparam("npoint");
  rmax = pow(2.0, floor(log2(32.0 / getdparam("alpha"))));
  if (rmax < rrange[1] && getbparam("smartrange")) {
    lgrs = log2(rrange[1] / rrange[0]) / (np - 1);
    np = 1 + log2(rmax / rrange[0]) / lgrs;
    eprintf("[%s: warning: npoint = %d -> %d  rrange[1] = %f -> %f]\n",
	    getprog(), getiparam("npoint"), np, rrange[1], rmax);
    rrange[1] = rmax;
  }
  gsp = gsp_expd(getdparam("mtot"), getdparam("alpha"), getdparam("zdisk"),
		 np, rrange[0], rrange[1]);
  ostr = stropen(getparam("out"), "w");
  put_history(ostr);
  gsp_write(ostr, gsp);
  fflush(NULL);
  return 0;
}
int
ul_putcmap (struct grf_softc *gp, struct grf_colormap *cmap, dev_t dev)
{
	struct grf_ul_softc *gup;
	volatile struct gspregs *ba;
	u_int16_t cmd[8];
	int x, mxidx, error;
	u_int8_t *mymap;

	gup = (struct grf_ul_softc *)gp;

	if (minor(dev) & GRFIMDEV) {
		mxidx = 256;
		mymap = gup->gus_imcmap;
	} else {
		mxidx = 4;
		mymap = gup->gus_ovcmap;
	}

	if (cmap->count == 0 || cmap->index >= mxidx)
		return 0;

	if (cmap->count > mxidx - cmap->index)
		cmap->count = mxidx - cmap->index;

	/* first copyin to our shadow color map */

	if ((error = copyin(cmap->red, mymap + cmap->index, cmap->count))

	    || (error = copyin(cmap->green, mymap + cmap->index + mxidx,
		cmap->count))

	    || (error = copyin(cmap->blue,  mymap + cmap->index + mxidx*2,
		cmap->count)))

		return error;


	/* then write from there to the hardware */
	ba = (volatile struct gspregs *)gp->g_regkva;
	/*
	 * XXX This is a bad thing to do.
	 * We should always use the gsp call, or have a means to arbitrate
	 * the usage of the BT458 index register. Else there might be a
	 * race condition (when writing both colormaps at nearly the same
	 * time), where one CPU changes the index register when the other
	 * one has not finished using it.
	 */
	if (mxidx > 4) {
		/* image color map: we can write, with a hack, directly */
		ba->ctrl = LBL;
		ba->hstadrh = 0xfe80;
		ba->hstadrl = 0x0000;
		ba->ctrl |= INCW;
		ba->data = cmap->index;
		ba->ctrl &= ~INCW;

		for (x=cmap->index; x < cmap->index + cmap->count; ++x) {
			ba->data = (u_int16_t) mymap[x];
			ba->data = (u_int16_t) mymap[x + mxidx];
			ba->data = (u_int16_t) mymap[x + mxidx * 2];
		}
	} else {

		/* overlay planes color map: have to call tms to do it */
		cmd[0] = GCMD_CMAP;
		cmd[1] = 1;
		for (x=cmap->index; x < cmap->index + cmap->count; ++x) {
			cmd[2] = x;
			cmd[3] = mymap[x];
			cmd[4] = mymap[x + mxidx];
			cmd[5] = mymap[x + mxidx * 2];
			gsp_write(ba, cmd, 6);
		}
	}
	return 0;
}
static int
ul_load_mon(struct grf_softc *gp, struct grfvideo_mode *md)
{
	struct grfinfo *gi;
	volatile struct gspregs *ba;
	u_int16_t buf[8];

	gi = &gp->g_display;
	ba = (volatile struct gspregs *)gp->g_regkva;

	gi->gd_dyn.gdi_fbx	= 0;
	gi->gd_dyn.gdi_fby	= 0;
	gi->gd_dyn.gdi_dwidth	= md->disp_width;
	gi->gd_dyn.gdi_dheight	= md->disp_height;
	gi->gd_dyn.gdi_dx	= 0;
	gi->gd_dyn.gdi_dy	= 0;

	ba->ctrl = (ba->ctrl & ~INCR) | (LBL | INCW); /* XXX */

	ba->hstadrh = 0xC000;
	ba->hstadrl = 0x0000;

	ba->data = (md->hsync_stop - md->hsync_start)/16;
	ba->data = (md->htotal - md->hsync_start)/16 - 1;
	ba->data = (md->hblank_start + md->htotal - md->hsync_start)/16 - 1;
	ba->data = md->htotal/16 - 1;

	ba->data = md->vsync_stop - md->vsync_start;
	ba->data = md->vtotal - md->vsync_start - 1;
	ba->data = md->vblank_start + md->vtotal - md->vsync_start - 1;
	ba->data = md->vtotal - 1;

	ba->ctrl &= ~INCW;
	ba->hstadrh = 0xFE90;
	ba->hstadrl = 0x0000;

	if (abs(md->pixel_clock - ulowell_clock[0]) >
	    abs(md->pixel_clock - ulowell_clock[1])) {

		ba->data = (ba->data & 0xFC) | 2 | 1;
		md->pixel_clock = ulowell_clock[1];

	} else {
		ba->data = (ba->data & 0xFC) | 2 | 0;
		md->pixel_clock = ulowell_clock[0];
	}

	ba->ctrl |= LBL | INCW;
	ba->hstadrh = 0xC000;
	ba->hstadrl = 0x0080;
	ba->data = md->disp_flags & GRF_FLAGS_LACE ? 0xb020 : 0xf020;

	/* I guess this should be in the yet unimplemented mode select ioctl */
	/* Hm.. maybe not. We always put the console on overlay plane no 0. */
	/* Anyway, this _IS_ called in the mode select ioctl. */

	/* ite support code parameters: */
	buf[0] = GCMD_MCHG;
	buf[1] = md->disp_width;	/* display width */
	buf[2] = md->disp_height;	/* display height */
	buf[3] = 0;			/* LSW of frame buffer origin */
	buf[4] = 0xFF80;		/* MSW of frame buffer origin */
	buf[5] = gi->gd_fbwidth * 1;	/* frame buffer pitch */
	buf[6] = 1;			/* frame buffer depth */
	gsp_write(ba, buf, 7);

	return(1);
}