[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pbbuttonsd: Crash on Resume



Am Samstag, 8. Mai 2004 03:21 schrieb Zach Weinberg:
> I'm running pbbuttonsd on my Powerbook 3400. First of all, when i put
> the computer to sleep and wake it up later, the computer crashes, printing
>
> gatwick irq not gatwick pic
>
> repeatedly in the console. Also, pressing the volume up and volume down
> keys has no effect, but the birghtness kes work even without pbbuttonsd.

Hi,
Does your machine also crash after resume without pbbuttonsd running?

Regarding your keys problem please try the attached program that will read the 
button levels from the PMU and prints them to console. Please tell me if you 
can change the level with the brightness and volume keys.

compile with >gcc -Wall -o readpmu readpmu.c

 Best Regards
   Matthias


#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <linux/input.h>
#include <linux/adb.h>
#include <linux/pmu.h>

#define ADB_BUFSIZE		32

/* This function sends a request to the PMU via the ADB bus and reads
    the result. If successful the count of valid data bytes in the buffer will be
     returned, otherwise -1 */
int send_pmu_request(int fd, unsigned char *buffer, int params, ...)
{
	va_list list;
	int n, x;

	if (params < 0 || params > 30)
		return -1;

	buffer[0] = PMU_PACKET;
	va_start(list, params);
	for (x = 0; x < params; ++x)
		buffer[x+1] = va_arg(list, int);
	va_end(list);

	n = write(fd, buffer, x+1);
	if ((n != x+1) || (n == -1))
		return -1;
	if ((n = read(fd, buffer, ADB_BUFSIZE)) < 0)
		return -1;
	return n;
}

void get_button(int fd, int button)
{
	int count, n;
	unsigned char buffer[ADB_BUFSIZE];

	count = send_pmu_request(fd, buffer, 1, button);
	if (count == -1)
		printf ("not supported");
	else {
		for (n=1; n < count; n++)
			printf ("%d [0x%x] ", buffer[n], buffer[n]);
		printf ("count: %d", count-1);
	}
}

int main(int argc, char *argv[])
{
	struct timeval tv;
	int fd_pmu;

	if ((fd_pmu = open("/dev/adb", O_RDWR)) >= 0) {     /* open ADB device */
		printf("PMU version: ");
		get_button (fd_pmu, PMU_GET_VERSION);
		printf("\n");
		while (1) {
			tv.tv_sec = 0; tv.tv_usec = 500000;  /* 0.5s polling timeout */
			if ((select(0, NULL, NULL, NULL, &tv)) < 0) {
				break;
			} else {
				printf("volume: ");
				get_button (fd_pmu, PMU_GET_VOLBUTTON);
				printf("\t\tbrightness: ");
				get_button (fd_pmu, 0x49);
				printf("\n");
			}
		}
		close (fd_pmu);
	}
	return 0;
}

Reply to: