2008-03-26 09:33:24 frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53053 Hi all, i use an ext-bf5xx-Video with a cm-bf537e from bluetechnix, and i would like to capture frames from a camera. I saw there where no driver for the 7183b so can I use the PPI camera frame capture driver and what have I to modify.
Regards
Bastien
TranslateQuoteReplyEditDelete
2008-03-26 12:27:42 Re: frame capture with adv7183b
Robin Getz (UNITED STATES)
Message: 53064 Bastien:
The frame format for the 7183B (which I believe is YCrCb 4:2:2) is much different than the camera chips we have been using, (which are normally RGB 4:4:4).
Although the data transfer will be the same, the rest of the driver will be wrong.
-Robin
QuoteReplyEditDelete
2008-03-26 16:29:15 Re: frame capture with adv7183b
Jean-Christian de Rivaz (SWITZERLAND)
Message: 53076 Hi Bastien,
As long as you only wants to capture just a frame (not a stream) you don't need a new driver at all, the current frame capture driver work fine with the 7183b. It have the capability to be adusted via a few ioctl() call to it. You need to configure the 7183b via the I2C bus. The most easy way is probably to use the I2C device driver that let your userspace application configure the 7183b.
Your userspace application have to handle to video format. But YCrCb 4:2:2 is just fine if you wants to do a JPEG compression for example...
Regrads,
--
Jean-Christian
QuoteReplyEditDelete
2008-03-27 06:54:14 Re: frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53124 I have a look at the ppifcd_test program and i see that to use the i2c driver a client adress was needed i2c_read_register(I2C_DEVICE, DEVID, 0x11), in the example #define DEVID 0x5D for the micron mt9m001. I have a look at the micron datasheet but the slave address don't seems to be the same, and i try with the slave adress for the adv7183 (0x40) but it don't works. can somebody explain me how to configure the i2c and what the DEVID correspond to.
TranslateQuoteReplyEditDelete
2008-03-27 08:29:55 Re: frame capture with adv7183b
Mike Frysinger (UNITED STATES)
Message: 53133 the DEVID corresponds to the I2C address of the device you're trying to use. this is documented in the part's datasheet.
QuoteReplyEditDelete
2008-03-27 08:58:03 Re: frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53138 I try with 0x40 which is the I2C Slave Address for the ADV7183B and it doesn't work. What I don't understand is why in the example program DEVID is 0x5D whereas in the MT9M001 datasheet we can see :
"The 8-bit address of a two-wire serial interface device consists of seven bits of address
and 1 bit of direction. A “0” (0xBA) in the LSB (least significant bit) of the address indi-
cates the write mode, and a “1” (0xBB) indicates read mode."
TranslateQuoteReplyEditDelete
2008-03-27 09:34:20 Re: frame capture with adv7183b
Jean-Christian de Rivaz (SWITZERLAND)
Message: 53141 If I remember correctly, the Linux definition of the I2C is without the R/W bit at the LSB, so the address must be right shifted 1 bit: eg. 0x40 -> 0x20.
QuoteReplyEditDelete
2008-03-27 12:46:52 Re: frame capture with adv7183b
Mike Frysinger (UNITED STATES)
Message: 53156 correct. datasheets will often incorrectly say "8-bit" because it wrongly includes the R/W bit. you'll need to use the right 7-bit I2C address (without the R/W bit).
QuoteReplyEditDelete
2008-03-28 05:09:57 Re: frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53243 I try to read the identification register 0x11 (which value should be 0x13) with 0x20 devid but it always return 0. I also try to modify i2c.c to put the i2c_devid to 0x20 but it always return 0 when reading the register. the i2c.c function i2c_read_register should print an error on the stderr if the slave adr was not correct, but nothing and i get 0 returned instead of -1 if there were an error.
TranslateQuoteReplyEditDelete
2008-03-28 10:28:14 Re: frame capture with adv7183b
Mike Frysinger (UNITED STATES)
Message: 53251 why are you trying those devids ? the documentation you posted from the datasheet reads:
"The 8-bit address of a two-wire serial interface device consists of seven bits of address
and 1 bit of direction. A “0” (0xBA) in the LSB (least significant bit) of the address indi-
cates the write mode, and a “1” (0xBB) indicates read mode."
that means if you take "0xBA" or "0xBB" and shift off the 1 bit of direction, you get "0x5D". you dont get "0x20".
QuoteReplyEditDelete
2008-03-28 11:11:07 Re: frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53255 I'm not using a micron, i just try to understand comparing the program to the datasheet because the ppifcd program was configured for the micron. I use an adv7183b so if I well understand 0x40 in the datasheet became 0x20 or 0x40>>1 but even with this adress it does not work
TranslateQuoteReplyEditDelete
2008-03-28 17:13:03 Re: frame capture with adv7183b
Jean-Christian de Rivaz (SWITZERLAND)
Message: 53267 Hi Bastien,
I have verified from a working user space application that the ADV7183B can be reached using the ioctl(i2cfd, I2C_SLAVE, 0x20). It's maybe the time to connect some probes on your physical I2C buses...
Regards,
QuoteReplyEditDelete
2008-03-31 03:43:43 Re: frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53350 Do you have some example program to reach the device ? It would be very helpfull,
Regards
Bastien
TranslateQuoteReplyEditDelete
2008-03-31 05:59:11 Re: frame capture with adv7183b
Jean-Christian de Rivaz (SWITZERLAND)
Message: 53358 To get an idea of the picture (untested):
------------------------------------------------------------------------------------
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <linux/i2c.h>
int main(int argc, char *argv[])
{
int i2cfd = open("/dev/i2c-0", O_RDWR);
if (i2cfd == -1) {
fprintf(stderr, "open error: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
if (ioctl(i2cfd, I2C_SLAVE, 0x20) != 0) {
fprintf(stderr, "ioctl error\n");
exit(EXIT_FAILURE);
}
unsigned char buffer[2] = { [0] = 0x00, [1] = 0x80 };
int ret = write(i2cfd, &buffer[0], sizeof(buffer));
if (ret != sizeof(buffer)) {
fprintf(stderr, "write error %d: %s\n", ret, strerror(errno));
exit(EXIT_FAILURE);
}
}
---------------------------------------------------------------------------------------
Regards,
QuoteReplyEditDelete
2008-03-31 11:26:11 Re: frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53373 It seems to to ok with this program, I try to read a register using "read(i2cfd, 0x11)" but I get -1. Is the call to the read function ok?
TranslateQuoteReplyEditDelete
2008-03-31 14:21:05 Re: frame capture with adv7183b
Jean-Christian de Rivaz (SWITZERLAND)
Message: 53378 Yes, read() is supported but not the way you do it. Please read the kernel/Documentation/i2c/dev-interface file as well as the manual page of the read() call (man 2 read).
QuoteReplyEditDelete
2008-04-01 08:32:13 Re: frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53448 I use read as describe in kernel/Documentation/i2c/dev-interface
char buf[10];
buf[0] = 0x11;
//buf[1] = 0x43;
//buf[2] = 0x65;
int ret=read(i2cfd,buf,1);
if (ret != 1) {
// ERROR HANDLING: i2c transaction failed
fprintf(stderr, "error reading: ret %d\n",ret);
} else {
// buf[0] contains the read byte
}
I get 0 returned by read and 0 in buf[0], as explain in read(2) manual 0 is returned if it's eof, i try with differents register wich are the ident and status of the 7183, so I don't understand why there is no return value
TranslateQuoteReplyEditDelete
2008-04-01 09:52:47 Re: frame capture with adv7183b
Jean-Christian de Rivaz (SWITZERLAND)
Message: 53452 You need to write the address of the register before you read it. Please read the I2C section of the ADV7183B.
Note 1: You actually don't need to read any ADV7183B register to capture a frame.
Note 2: The ADV7181B and probably the ADV7183B are not fully I2C protocol compliant. There only allow a read after a restart condition, not after a stop and start conditions. If you really wants to read a register you need to find a way to use the i2c-dev in a way to not have a stop between the write and the read.
QuoteReplyEditDelete
2008-04-02 08:29:12 Re: frame capture with adv7183b
Bastien Briec (FRANCE)
Message: 53538 I try to read the 20 first register :
char buf[20];
buf[0] = 0x00;
int ret2=read(i2cfd,buf,1);
,just after "ioctl(i2cfd, I2C_SLAVE, slave_addr" suposing the start adress is 0, but i can't read any register and i can't find any way to do it.
TranslateQuoteReplyEditDelete
2008-04-02 08:44:16 Re: frame capture with adv7183b
Jean-Christian de Rivaz (SWITZERLAND)
Message: 53539 Your code can't read 20 registers as you specify only 1 byte size to the read call. You better have to use sizeof(buf) for this parameter.
I am really not confident with you suposition. The ioctl probably configure only some structure into the kernel space, not the internal register pointer of the ADV7183B.