66#include <string.h>
77#include <unistd.h>
88
9+ #include "chipid.h"
910#include "hal/common.h"
1011#include "tools.h"
1112
@@ -14,11 +15,13 @@ static unsigned char ssens_addrs[] = {0x60, 0};
1415static unsigned char omni_addrs [] = {0x6c , 0 };
1516static unsigned char onsemi_addrs [] = {0x20 , 0 };
1617static unsigned char gc_addrs [] = {0x6e , 0 };
18+ static unsigned char imagedesign_addrs [] = {0x60 , 0 };
1719
1820static sensor_addr_t rockchip_possible_i2c_addrs [] = {
1921 {SENSOR_SONY , sony_addrs }, {SENSOR_SMARTSENS , ssens_addrs },
2022 {SENSOR_ONSEMI , onsemi_addrs }, {SENSOR_OMNIVISION , omni_addrs },
21- {SENSOR_GALAXYCORE , gc_addrs }, {0 , NULL }};
23+ {SENSOR_GALAXYCORE , gc_addrs }, {SENSOR_IMAGEDESIGN , imagedesign_addrs },
24+ {0 , NULL }};
2225
2326bool rockchip_detect_cpu (char * chip_name ) {
2427 char buf [256 ];
@@ -27,6 +30,10 @@ bool rockchip_detect_cpu(char *chip_name) {
2730 "rockchip,(r[kv][0-9]+)" , buf , sizeof (buf )))
2831 return false;
2932 strcpy (chip_name , buf );
33+
34+ if (!strcmp (chip_name , "rv1103" ) || !strcmp (chip_name , "rv1106" ))
35+ chip_generation = 0x1106 ;
36+
3037 return true;
3138}
3239
@@ -81,16 +88,23 @@ float rockchip_get_temp() {
8188 return (float )ret / 1000 ;
8289}
8390
84- static int i2c1_open_sensor_fd () {
85- return universal_open_sensor_fd ("/dev/i2c-1" );
91+ static int rockchip_open_i2c_fd () {
92+ i2c_adapter_nr = 1 ;
93+ if (chip_generation == 0x1106 )
94+ i2c_adapter_nr = 4 ;
95+ char adapter_name [FILENAME_MAX ];
96+
97+ snprintf (adapter_name , sizeof (adapter_name ), "/dev/i2c-%d" , i2c_adapter_nr );
98+
99+ return universal_open_sensor_fd (adapter_name );
86100}
87101
88102void rockchip_setup_hal () {
89103 possible_i2c_addrs = rockchip_possible_i2c_addrs ;
90- open_i2c_sensor_fd = i2c1_open_sensor_fd ;
104+ open_i2c_sensor_fd = rockchip_open_i2c_fd ;
91105 if (!access ("/sys/class/thermal/thermal_zone0/temp" , R_OK ))
92106 hal_temperature = rockchip_get_temp ;
93107#ifndef STANDALONE_LIBRARY
94108 hal_totalmem = rockchip_totalmem ;
95109#endif
96- }
110+ }
0 commit comments