Hi!
I failed to use C/C++ to access the image sensor OV5645's register on my system via I2C bus. Below are some information about my system:
Hardware:
Dragonboard 410c +
96Boards MIPI Adapter with Dual OV5645
(
https://www.ebay.com/itm/96Boards-MI...525BC%25252589)
OS :
Linaro Linux (Debian based) 19.01
As I can use GStreamer to control the two OV5645 to feedback captured images, the hardware connections seems to be fine. Below are some information about the I2C master and OV5645 in my system:
Code:
linaro@linaro-developer:~$ sudo i2cdetect -l
i2c-3 i2c QUP I2C adapter I2C adapter
i2c-1 i2c QUP I2C adapter I2C adapter
i2c-4 i2c Qualcomm Camera Control Interface I2C adapter
i2c-0 i2c QUP I2C adapter I2C adapter
linaro@linaro-developer:~$ dmesg | grep ov5645
[ 11.825197] ov5645 4-003b: OV5645 detected at address 0x3b
[ 12.290626] ov5645 4-003a: OV5645 detected at address 0x3a
And here is my short program:
https://gist.github.com/oliverjungen...7e7a3c0678c41e
What it does are simply:
1. Open
/dev/i2c-4
Code:
file = open(filename, O_RDWR);
2. Set I2C slave address
0x3b
Code:
errno = ioctl(file, I2C_SLAVE_FORCE, CAM_REAR_I2C_ADDR);
3. Send 16-bit register address
0x300a to this I2C slave
Code:
ret = write(file, ®, 2);
However, when it runs, I always get:
Code:
Write i2c internal address error: Input/output error
This message was printed by
perror() in this program’s Line 54, after writing the register address (
0x300a, SENSOR CHIP ID HIGH BYTE) to OV5645.
I found that, when this error occurs, the kernel module
i2c-qcom-cci reports error messages like:
Code:
linaro@linaro-developer:~$ dmesg | grep cci
[ 1280.099448] i2c-qcom-cci 1b0c000.cci: Master 0 error 0x08000000
[ 1280.099502] i2c-qcom-cci 1b0c000.cci: master 0 queue 0 error -5
[ 1280.104247] i2c-qcom-cci 1b0c000.cci: cci i2c xfer error -5
These I2C slaves (these OV5645) are actually owned by kernel modules. That's the reason why I use
I2C_SLAVE_FORCE instead of
I2C_SLAVE as the flag when I set the I2C slave address:
errno = ioctl(file, I2C_SLAVE_FORCE, CAM_REAR_I2C_ADDR);
I'm wondering whether I can't use
ioctl() to control a device owned by kernel modules?