Skip to content

Commit

Permalink
Completing Ingenic regions, providing a table of supported sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed May 31, 2024
1 parent 4c2ce04 commit 21af12b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 17 deletions.
16 changes: 13 additions & 3 deletions src/hal/inge/tx_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tx_isp_snr _tx_isp_snr;
char _tx_aud_chn = 0;
char _tx_aud_dev = 0;
char _tx_fs_chn = 0;
char _tx_osd_grp = 0;

void tx_hal_deinit(void)
{
Expand Down Expand Up @@ -89,7 +90,8 @@ int tx_pipeline_create(short width, short height, char framerate)
{
tx_fs_chn channel = {
.dest = { .width = width, .height = height },
.fpsDen = framerate, .fpsNum = 1
.fpsDen = framerate, .fpsNum = 1,
.pixFmt = TX_PIXFMT_NV12
};

if (ret = tx_fs.fnCreateChannel(_tx_fs_chn, &channel))
Expand Down Expand Up @@ -117,10 +119,11 @@ int tx_region_create(int *handle, char group, hal_rect rect)
region.rect.p1.y = rect.y + rect.height - 1;
region.data.picture = NULL;

if (ret = tx_osd.fnGetRegionConfig(*handle, &regionCurr)) {
if (tx_osd.fnGetRegionConfig(*handle, &regionCurr)) {
fprintf(stderr, "[tx_osd] Creating region %d...\n", group);
if (ret = tx_osd.fnCreateRegion(&region))
if ((ret = tx_osd.fnCreateRegion(&region)) < 0)
return ret;
else *handle = ret;
} else if (regionCurr.rect.p1.y - regionCurr.rect.p0.y != rect.height ||
regionCurr.rect.p1.x - regionCurr.rect.p0.x != rect.width) {
fprintf(stderr, "[tx_osd] Parameters are different, recreating "
Expand All @@ -137,6 +140,7 @@ int tx_region_create(int *handle, char group, hal_rect rect)
attrib.alphaOn = 1;
attrib.fgAlpha = 255;

tx_osd.fnCreateGroup(group);
tx_osd.fnRegisterRegion(*handle, group, &attrib);
tx_osd.fnStartGroup(group);

Expand All @@ -147,6 +151,8 @@ void tx_region_destroy(int *handle, char group)
{
tx_osd.fnStopGroup(group);
tx_osd.fnUnregisterRegion(*handle, group);
tx_osd.fnDestroyGroup(group);
*handle = -1;
}

int tx_region_setbitmap(int *handle, hal_bitmap *bitmap)
Expand Down Expand Up @@ -192,6 +198,10 @@ int tx_system_init(void)
for (char i = 0; i < sizeof(tx_sensors) / sizeof(*tx_sensors); i++) {
if (strcmp(tx_sensors[i].name, sensor)) continue;
memcpy(&_tx_isp_snr, &tx_sensors[i], sizeof(tx_isp_snr));
if (tx_sensors[i].mode == TX_ISP_COMM_I2C)
memcpy(&_tx_isp_snr.i2c.type, &tx_sensors[i].name, strlen(tx_sensors[i].name));
else if (tx_sensors[i].mode == TX_ISP_COMM_SPI)
memcpy(&_tx_isp_snr.spi.alias, &tx_sensors[i].name, strlen(tx_sensors[i].name));
ret = 0;
break;
}
Expand Down
29 changes: 28 additions & 1 deletion src/hal/inge/tx_isp.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,34 @@ typedef struct {
} tx_isp_snr;

static tx_isp_snr tx_sensors[] = {
{ .name = "sc2335", .mode = TX_ISP_COMM_I2C, .i2c.type = "sc2335", .i2c.addr = 0x30 }
{ .name = "c23a98", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x36 },
{ .name = "c4390", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x36 },
{ .name = "gc1034", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x21 },
{ .name = "gc2053", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x37 },
{ .name = "gc4653", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x29 },
{ .name = "imx307", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x1a },
{ .name = "imx327", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x36 },
{ .name = "imx335", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x1a },
{ .name = "jxf23", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x40 },
{ .name = "jxf37", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x40 },
{ .name = "jxh62", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "jxk03", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x40 },
{ .name = "jxk05", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x40 },
{ .name = "jxq03", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "os02k10", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x36 },
{ .name = "os04b10", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x3c },
{ .name = "os05a10", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x36 },
{ .name = "ov5648", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x36 },
{ .name = "sc2232h", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc2235", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc2239", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc2310", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc2315e", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc2335", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc3235", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc3335", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc4335", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 },
{ .name = "sc5235", .mode = TX_ISP_COMM_I2C, .i2c.addr = 0x30 }
};

typedef struct {
Expand Down
33 changes: 20 additions & 13 deletions src/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void *region_thread(void)

for (char id = 0; id < MAX_OSD; id++)
{
osds[id].hand = id;
osds[id].hand = -1;
osds[id].size = DEF_SIZE;
osds[id].posx = DEF_POSX;
osds[id].posy = DEF_POSY;
Expand Down Expand Up @@ -141,20 +141,25 @@ void *region_thread(void)
case HAL_PLATFORM_I6:
case HAL_PLATFORM_I6B0:
case HAL_PLATFORM_I6E:
i6_region_create(osds[id].hand, rect);
i6_region_setbitmap(osds[id].hand, &bitmap);
i6_region_create(id, rect);
i6_region_setbitmap(id, &bitmap);
break;
case HAL_PLATFORM_I6C:
i6c_region_create(osds[id].hand, rect);
i6c_region_setbitmap(osds[id].hand, &bitmap);
i6c_region_create(id, rect);
i6c_region_setbitmap(id, &bitmap);
break;
case HAL_PLATFORM_I6F:
i6f_region_create(osds[id].hand, rect);
i6f_region_setbitmap(osds[id].hand, &bitmap);
i6f_region_create(id, rect);
i6f_region_setbitmap(id, &bitmap);
break;
case HAL_PLATFORM_T21:
case HAL_PLATFORM_T31:
tx_region_create(&osds[id].hand, id, rect);
tx_region_setbitmap(&osds[id].hand, &bitmap);
break;
case HAL_PLATFORM_V4:
v4_region_create(osds[id].hand, rect);
v4_region_setbitmap(osds[id].hand, &bitmap);
v4_region_create(id, rect);
v4_region_setbitmap(id, &bitmap);
break;
}
free(bitmap.data);
Expand All @@ -166,10 +171,12 @@ void *region_thread(void)
switch (plat) {
case HAL_PLATFORM_I6:
case HAL_PLATFORM_I6B0:
case HAL_PLATFORM_I6E: i6_region_destroy(osds[id].hand); break;
case HAL_PLATFORM_I6C: i6c_region_destroy(osds[id].hand); break;
case HAL_PLATFORM_I6F: i6f_region_destroy(osds[id].hand); break;
case HAL_PLATFORM_V4: v4_region_destroy(osds[id].hand); break;
case HAL_PLATFORM_I6E: i6_region_destroy(id); break;
case HAL_PLATFORM_I6C: i6c_region_destroy(id); break;
case HAL_PLATFORM_I6F: i6f_region_destroy(id); break;
case HAL_PLATFORM_T21:
case HAL_PLATFORM_T31: tx_region_destroy(&osds[id].hand, id); break;
case HAL_PLATFORM_V4: v4_region_destroy(id); break;
}
}
osds[id].updt = 0;
Expand Down

0 comments on commit 21af12b

Please sign in to comment.