Subject: Re: X weirdness (TGA2, AS600, -current)
To: Jarkko Teppo <jarkko.teppo@er-grp.com>
From: Roland Dowdeswell <elric@imrryr.org>
List: port-alpha
Date: 04/12/2002 16:56:21
------- =_baaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"; charset="us-ascii"
Content-ID: <8201.1018644953.1@imrryr.org>

On 1018643008 seconds since the Beginning of the UNIX epoch
Roland Dowdeswell wrote:
>

>#forw [forwarded message] +/u/elric/usr/mail/NetBSD/port-alpha 4926

Well, I guess that I forgot to run that through mhbuild.

 == Roland Dowdeswell                      http://www.Imrryr.ORG/~elric/  ==
 == The Unofficial NetBSD Web Pages        http://www.Imrryr.ORG/NetBSD/  ==
 == The NetBSD Project                            http://www.NetBSD.ORG/  ==

------- =_baaaaaaaaa0
Content-Type: message/rfc822
Content-ID: <8201.1018644953.2@imrryr.org>
Content-Description: forwarded message

From port-alpha-owner-elric=imrryr.org@netbsd.org  Tue Aug 22 00:59:10 2000
	by mabelode.imrryr.org (Postfix) with SMTP id 1E1E2DE2
	for <elric@imrryr.org>; Tue, 22 Aug 2000 00:59:10 -0700 (PDT)
  by mail.netbsd.org with SMTP; 22 Aug 2000 07:59:04 -0000
	by mabelode.imrryr.org (Postfix) with ESMTP
	id CFFCFDE0; Tue, 22 Aug 2000 00:59:03 -0700 (PDT)
To: "Christian Groessler" <cpg@aladdin.de>
Cc: port-alpha@NetBSD.ORG
Subject: Re: TGA console problem 
In-reply-to: Your message of "Sun, 20 Aug 2000 19:55:43 BST."
             <41256941.006D8B45.00@saturn.aladdin.de> 
Organization: The Fall of Imrryr
Reply-To: "R. C. Dowdeswell" <elric@imrryr.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
Content-ID: <16311.966931111.0@mabelode.imrryr.org>
Date: Tue, 22 Aug 2000 00:59:03 -0700
From: "R. C. Dowdeswell" <elric@mabelode.imrryr.org>
Message-Id: <20000822075903.CFFCFDE0@mabelode.imrryr.org>
Sender: port-alpha-owner@netbsd.org

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <16311.966931111.1@mabelode.imrryr.org>

On 966797743 seconds since the Beginning of the UNIX epoch
"Christian Groessler" wrote:
>
>Hi,
>
>since the TGA console code was changed (somewhere in the
>1.4<letter somewhere in the 2nd half of the alphabet> line)
>I have 2 annoying problems:
>
>First, and more important:
>I use bash as shell. If on the new console I type some chars
>then use ctrl-a to go back to the start of the line and try to
>insert some chars, _the_whole_line_ (i,e. also chars to the
>left of the cursor) is moved one character position to the right.
>It's also not done 100% correctly, so after a few inserted
>chars the complete line is more or less unreadable...

How large is your display?  Mine is at 1280x1024 and I can't
seem to reproduce this one.

>Second,
>if I enter and leave X, the screen is set to black chars
>on white bg, and I don't know how to change it back.

Okay, I see this one too.  I have looked a bit and it would
be pretty trivial to hack the Xserver to put the cmap back into
a sane state, but I've been thinking that perhaps the kernel
should do this one when the Xserver exits so that we don't have
to rely on the Xserver playing nice (or not getting -9ed.)
Opinions?

Anyway, attached please find a tiny program that I just wrote
which works:

cmap [-f tty] [-x] idx rval:gval:bval

and it opens tty and sets the colourmap entry idx to rval:gval:bval.
If you set:

cmap 0 0:0:0
cmap 1 255:255:255

You should get back to something useful.  If that doesn't quite work,
try:

cmap 0 0:0:0
for i in $(jot 255); do
   cmap $i 255:255:255
done

Remember that there is a point in there where you'll have white on
white.  You can avoid that by experimenting with 255:0:0 to get things
right.

 == Roland Dowdeswell                      http://www.Imrryr.ORG/~elric/  ==
 == The Unofficial NetBSD Web Pages        http://www.Imrryr.ORG/NetBSD/  ==
 == The NetBSD Project                            http://www.NetBSD.ORG/  ==

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <16311.966931111.2@mabelode.imrryr.org>

/* */

/*-
 * Copyright (c) 2000 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Roland C. Dowdeswell.
 *
 * 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. 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. 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 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 <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <sys/ioctl.h>
#include <sys/types.h>
#include <dev/wscons/wsconsio.h>

int	setcmap(int, u_char, u_char, u_char, u_char);
void	usage();

char *prognam = NULL;

int
main(int argc, char **argv)
{
	extern	int optind;
	extern	char *optarg;
	int	ch;
	int	fd;
	int	xflag = 0;
	int	ret;
	char	*filename = NULL;
	char	*tmp1;
	char	*tmp2;
	u_char	idx, rval, gval, bval;

	prognam = strdup(*argv);

	while ((ch = getopt(argc, argv, "f:x")) != -1)
		switch (ch) {
		case 'f':
			filename = strdup(optarg);
			break;
		case 'x':
			xflag = 1;
			break;
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (filename == NULL)
		filename = strdup("/dev/ttyE0");

	if (argc != 2)
		usage();

	idx = strtol(argv[0], NULL, xflag?16:0);

	tmp1 = argv[1];
	rval = (u_char)strtol(tmp1, &tmp2, xflag?16:0);
	if (!tmp2 || *tmp2 != ':')
		usage();

	tmp1 = tmp2 + 1;
	gval = strtol(tmp1, &tmp2, xflag?16:0);
	if (!tmp2 || *tmp2 != ':')
		usage();

	tmp1 = tmp2 + 1;
	bval = strtol(tmp1, &tmp2, xflag?16:0);

	fd = open(filename, O_RDWR, 0);
	if (fd == -1) {
		perror("open");
		fprintf(stderr, "fbopen(\"%s\") failed\n", filename);
		exit(-1);
	}

	ret = setcmap(fd, idx, rval, gval, bval);
	if (ret && !xflag) {
		fprintf(stderr, "setcmap(%d, %d, %d, %d, %d) failed\n",
		    fd, idx, rval, gval, bval);
		exit(-1);
	} else if (ret) {
		fprintf(stderr, "setcmap(%d, 0x%x, 0x%x, 0x%x, 0x%x) failed\n",
		    fd, idx, rval, gval, bval);
		exit(-1);
	}
	return 0;
}

int
setcmap(int fd, u_char idx, u_char rval, u_char gval, u_char bval)
{
	struct	wsdisplay_cmap cmap;
	int	ret;

	cmap.index = idx;
	cmap.count = 1;
	cmap.red = &rval;
	cmap.green = &gval;
	cmap.blue = &bval;

	ret = ioctl(fd, WSDISPLAYIO_PUTCMAP, &cmap);
	if (ret == -1) {
		perror("ioctl");
		return -1;
	}
}

void
usage()
{
	fprintf(stderr, "usage:\n%s [-x] entry rval:gval:bval\n", prognam);
	exit(-1);
}

------- =_aaaaaaaaaa0--


------- =_baaaaaaaaa0--