[linux-dvb] [PATCH] make the registers of the stv0297 visible for other applications (e.g. i2cdump)

Johannes Stezenbach js at linuxtv.org
Sun May 20 23:18:50 CEST 2007


On Sun, May 20, 2007, e9hack wrote:
> 
> With the attached patch, it works for the stv0297 functions. It
> doesn't solve the problem, why I've wrote the initial patch. I need a
> dump from the registers of the stv0297. I've attach a second patch.
> stv0297_attach() inserts a wrapper between i2ctransfer() and the
> transfer function of the saa7146. The add/del functions for the
> wrapper are a little bit
> dirty. I didn't find a clean way for the add/del function.

Hm, I was trying to tell you that the problem is in i2cdump,
not in saa7146 or stv0297.

i2cdump is simply limited to simple SMBUS-like transfers,
but I think it wouldn't be difficult to extend it or
write a new utility which uses the I2C_RDWR ioctl to
perform the transfer as required by stv0297.

http://lm-sensors.org/svn/lm-sensors/trunk/prog/dump/i2cdump.c
http://lm-sensors.org/svn/lm-sensors/trunk/kernel/include/i2c-dev.h

Something like that would do it (except for the race which I2C_M_STOP
should fix):

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>

#include "i2c-dev.h"

int main()
{
	unsigned char reg = 0x00;
	unsigned char val;
	struct i2c_msg msgs[] = {
		{ .addr = 0x08, .flags = I2C_M_WR, .buf = &reg, .len = 1 },
		{ .addr = 0x08, .flags = I2C_M_RD, .buf = &val, .len = 1 }
	};
	struct i2c_rdwr_ioctl_data i2c_rdwr = {
		.msgs = msgs,
		.nmsgs = 2
	};
	int fd;

	fd = open("/dev/i2c-1", O_RDWR);
	if (fd < 0)
		perror("open");
	if (ioctl(fd, I2C_RDWR, &i2c_rdwr) == -1)
		perror("ioctl I2C_RDWR");
	close(fd);
	printf("%02x\n", val);
	return 0;
}


HTH,
Johannes



More information about the linux-dvb mailing list