Skip to content

Commit cea5134

Browse files
committed
Add RV1106
1 parent b328d02 commit cea5134

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/chipid.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ const char *getchipfamily() {
204204
return "t40";
205205
case T41:
206206
return "t41";
207+
case RV1106:
208+
return "rv1106";
207209
default:
208210
return chip_name;
209211
}

src/hal/rockchip.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
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};
1415
static unsigned char omni_addrs[] = {0x6c, 0};
1516
static unsigned char onsemi_addrs[] = {0x20, 0};
1617
static unsigned char gc_addrs[] = {0x6e, 0};
18+
static unsigned char imagedesign_addrs[] = {0x60, 0};
1719

1820
static 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

2326
bool 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

88102
void 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+
}

src/hal/rockchip.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
#include <stdbool.h>
55

6-
bool rockchip_detect_cpu();
6+
#define RV1106 0x1106
7+
#define RV1109 0x1109
8+
#define RV1126 0x1126
9+
10+
bool rockchip_detect_cpu(char *chip_name);
711
unsigned long rockchip_totalmem(unsigned long *media_mem);
812
void rockchip_setup_hal();
913

0 commit comments

Comments
 (0)