Subject: lcd contrast/brightness ioctl, gpe
To: None <port-hpcarm@netbsd.org>
From: Lorant Toth <LorantToth@gmx.net>
List: port-hpcarm
Date: 10/26/2004 13:32:44
This is a multi-part message in MIME format.
--------------010307090306050807060309
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
hi,
I've finally managed to put up a fairly nicely running NetBSD-based
Jornada system. I'm using matchbox and rxvts and a few other apps and it
runs well - better than fluxbox.
Well, then I decided that I'd like the screen to be a bit darker b/c its
a little too bright and that would also benefit the battery... as I
could not find settings for wsconsctl or alike (I am quite new to BSD) I
looked at the J720 sources (J720ssp.c I think) and wrote a small app to
manipulate the screen via ioctls. Eventually I also thought about
possibly getting rid of WinCE too bright "bug" after reboot (but that's
probably a different story :) )
But my problem is that
a) I've never programmed any ioctl stuff before, so I probably made
mistakes and could not find too much info on this
b) my app does not affect the display at all... I can read the values
but setting these params via ioctl does not affect either brightness or
contrast - and the read-out remains the same.
Could somebody look at the code and possibly point out my mistake or
give me a better way to adjust contrast and brightness? it is attached.
>> Ohh and then I'm also trying to put together a few simple PIM Apps
written in PyGTK, b/c that's one of the last things I miss :) I'd like
to keep to GPE looks... have not finished much yet though.
>> One more thing: I tried to "port" (more recompile) GPE
(gpe.handhelds.org) on NetBSD and it would run on my desktop i386 but
with most apps I kept getting errors that the apps could not find
dynamic lib "libX11.so" - though the calculator did run :). I've had to
make a few modifications to the makefiles to use gmake and more things.
I am a complete novice with NetBSD but even I could make GPE at least
compile within a few hrs :) So a GPE port should be feasable, though I
lack the knowledge for now...
regards,
Lorant
--------------010307090306050807060309
Content-Type: image/x-xbitmap;
name="lcdctl.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="lcdctl.c"
#define DEVICE "/dev/ttyE0"
#include <stdio.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <time.h>
#include <dev/wscons/wsconsio.h>
#include <fcntl.h>
#define TYPE WSDISPLAYIO_PARAM_BRIGHTNESS
#define NAME "brightness"
main()
{
int fd = 0; /* standard input */
struct wsdisplay_param disp;
/* Adjust BRIGHTNESS or CONTRAST */
disp.param = TYPE;
/* Read the value via ioctl */
if (ioctl(fd, WSDISPLAYIO_GETPARAM, &disp) < 0)
{
perror("ioctl");
close(fd);
exit(1);
}
else
printf("Current display %s: min: %d, cur: %d, max: %d\n", NAME, disp.min, disp.curval, disp.max);
//int min = disp.min, max = disp.max;
/* Setup the wsdisplay_param structure */
disp.curval = i;
disp.param = TYPE;
disp.min = disp.curval;
disp.max = disp.curval;
// if ((fd = open(DEVICE, O_RDWR)) < 0)
// err(1, "Could not open " DEVICE);
/* Set BRIGHTNESS or CONTRAST */
printf("Setting %s to: %d\n", NAME, disp.curval);
if (ioctl(fd, WSDISPLAYIO_SETPARAM, &disp) < 0)
{
perror("ioctl");
close(fd);
exit(1);
}
if (ioctl(fd, WSDISPLAYIO_GETPARAM, &disp) < 0)
{
perror("ioctl getparam");
close(fd);
exit(1);
}
else
printf("Current display %s: min: %d, cur: %d, max: %d\n\n", NAME, disp.min, disp.curval, disp.max);
close(fd);
}
--------------010307090306050807060309--