Skip to content

Commit

Permalink
Removing code not meant to be run on target arch at compile-time to s…
Browse files Browse the repository at this point in the history
…ave space
  • Loading branch information
wberube committed Jun 6, 2024
1 parent aff6ff3 commit 95acf6d
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 41 deletions.
2 changes: 2 additions & 0 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ char *errstr(int error) {
int module = (error >> 16) & 0xFF;

switch (plat) {
#ifdef __arm__
case HAL_PLATFORM_I6:
level = (error >> 12) & 0xF;
error = error & 0xFF000FFF | (level > 0 ? (4 << 13) : 0);
Expand Down Expand Up @@ -97,6 +98,7 @@ char *errstr(int error) {
error |= (module << 16); break;
}
break;
#endif
}

switch (error) {
Expand Down
2 changes: 2 additions & 0 deletions src/hal/hisi/v3_hal.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __arm__
#include "v3_hal.h"

v3_isp_alg v3_ae_lib = { .id = 0, .libName = "ae_lib" };
Expand Down Expand Up @@ -840,3 +841,4 @@ int v3_system_init(char *snrConfig)

return EXIT_SUCCESS;
}
#endif
2 changes: 2 additions & 0 deletions src/hal/hisi/v4_hal.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __arm__
#include "v4_hal.h"

v4_isp_alg v4_ae_lib = { .id = 0, .libName = "ae_lib" };
Expand Down Expand Up @@ -895,3 +896,4 @@ int v4_system_init(char *snrConfig)

return EXIT_SUCCESS;
}
#endif
6 changes: 5 additions & 1 deletion src/hal/hisi/v4_quirks.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef __arm__

int (*fnISP_AlgRegisterDehaze)(int);
int (*fnISP_AlgRegisterDrc)(int);
int (*fnISP_AlgRegisterLdci)(int);
Expand All @@ -14,4 +16,6 @@ int ISP_AlgRegisterLdci(int pipeId) {
}
int MPI_ISP_IrAutoRunOnce(int pipeId, void *irAttr) {
return fnMPI_ISP_IrAutoRunOnce(pipeId, irAttr);
}
}

#endif
2 changes: 2 additions & 0 deletions src/hal/inge/t31_hal.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __mips__
#include "t31_hal.h"

t31_aud_impl t31_aud;
Expand Down Expand Up @@ -638,3 +639,4 @@ int t31_system_init(void)

return EXIT_SUCCESS;
}
#endif
4 changes: 3 additions & 1 deletion src/hal/sstar/i6_hal.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __arm__
#include "i6_hal.h"

i6_aud_impl i6_aud;
Expand Down Expand Up @@ -827,4 +828,5 @@ int i6_system_init(void)
return ret;

return EXIT_SUCCESS;
}
}
#endif
4 changes: 3 additions & 1 deletion src/hal/sstar/i6c_hal.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __arm__
#include "i6c_hal.h"

i6c_aud_impl i6c_aud;
Expand Down Expand Up @@ -945,4 +946,5 @@ int i6c_system_init(void)
return ret;

return EXIT_SUCCESS;
}
}
#endif
4 changes: 3 additions & 1 deletion src/hal/sstar/i6f_hal.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef __arm__
#include "i6f_hal.h"

i6f_aud_impl i6f_aud;
Expand Down Expand Up @@ -904,4 +905,5 @@ int i6f_system_init(void)
return ret;

return EXIT_SUCCESS;
}
}
#endif
11 changes: 10 additions & 1 deletion src/hal/support.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void hal_identify(void) {
char *endMark;
char line[200] = {0};

#ifdef __arm__
if (!access("/proc/mi_modules", 0) &&
hal_registry(0x1F003C00, &val, OP_READ))
switch (val) {
Expand Down Expand Up @@ -88,7 +89,10 @@ void hal_identify(void) {
venc_thread = i6f_video_thread;
return;
}
else if (!access("/proc/jz", 0) &&
#endif

#ifdef __mips__
if (!access("/proc/jz", 0) &&
hal_registry(0x1300002C, &val, OP_READ)) {
unsigned int type;
hal_registry(0x13540238, &type, OP_READ);
Expand All @@ -114,6 +118,10 @@ void hal_identify(void) {
}
}

return;
#endif

#ifdef __arm__
if (file = fopen("/proc/iomem", "r"))
while (fgets(line, 200, file))
if (strstr(line, "uart")) {
Expand Down Expand Up @@ -169,4 +177,5 @@ void hal_identify(void) {
chnState = (hal_chnstate*)v4_state;
isp_thread = v4_image_thread;
venc_thread = v4_video_thread;
#endif
}
13 changes: 9 additions & 4 deletions src/hal/support.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include "types.h"
#if defined(__arm__)
#include "hisi/v3_hal.h"
#include "hisi/v4_hal.h"
#include "inge/t31_hal.h"
#include "sstar/i6_hal.h"
#include "sstar/i6c_hal.h"
#include "sstar/i6f_hal.h"
#elif defined(__mips__)
#include "inge/t31_hal.h"
#endif

#include <errno.h>
#include <fcntl.h>
Expand All @@ -19,15 +22,13 @@ extern hal_chnstate *chnState;
extern hal_platform plat;
extern char series[16];

#if defined(__arm__)
extern void *v3_video_thread(void);
extern hal_chnstate v3_state[V4_VENC_CHN_NUM];

extern void *v4_video_thread(void);
extern hal_chnstate v4_state[V4_VENC_CHN_NUM];

extern void *t31_video_thread(void);
extern hal_chnstate t31_state[T31_VENC_CHN_NUM];

extern void *i6_video_thread(void);
extern hal_chnstate i6_state[I6_VENC_CHN_NUM];

Expand All @@ -36,6 +37,10 @@ extern hal_chnstate i6c_state[I6C_VENC_CHN_NUM];

extern void *i6f_video_thread(void);
extern hal_chnstate i6f_state[I6F_VENC_CHN_NUM];
#elif defined(__mips__)
extern void *t31_video_thread(void);
extern hal_chnstate t31_state[T31_VENC_CHN_NUM];
#endif

bool hal_registry(unsigned int addr, unsigned int *data, hal_register_op op);
void hal_identify(void);
Expand Down
30 changes: 23 additions & 7 deletions src/jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ int jpeg_init() {

pthread_mutex_lock(&jpeg_mutex);

if (app_config.mjpeg_enable) goto mjpeg_active;
switch (plat) {
#ifdef __mips__
case HAL_PLATFORM_T31:
if (app_config.mjpeg_enable) goto mjpeg_active;
break;
#endif
}

jpeg_index = take_next_free_channel(false);

Expand All @@ -47,12 +53,15 @@ int jpeg_init() {
config.minQual = config.maxQual = app_config.jpeg_qfactor;

switch (plat) {
#if defined(__arm__)
case HAL_PLATFORM_I6: ret = i6_video_create(jpeg_index, &config); break;
case HAL_PLATFORM_I6C: ret = i6c_video_create(jpeg_index, &config); break;
case HAL_PLATFORM_I6F: ret = i6f_video_create(jpeg_index, &config); break;
case HAL_PLATFORM_T31: ret = t31_video_create(jpeg_index, &config); break;
case HAL_PLATFORM_V3: ret = v3_video_create(jpeg_index, &config); break;
case HAL_PLATFORM_V4: ret = v4_video_create(jpeg_index, &config); break;
#elif defined(__mips__)
case HAL_PLATFORM_T31: ret = t31_video_create(jpeg_index, &config); break;
#endif
default:
pthread_mutex_unlock(&jpeg_mutex);
return EXIT_FAILURE;
Expand All @@ -78,15 +87,19 @@ int jpeg_init() {
void jpeg_deinit() {
pthread_mutex_lock(&jpeg_mutex);

if (app_config.mjpeg_enable) goto mjpeg_active;

switch (plat) {
#if defined(__arm__)
case HAL_PLATFORM_I6: i6_video_destroy(jpeg_index); break;
case HAL_PLATFORM_I6C: i6c_video_destroy(jpeg_index, 1); break;
case HAL_PLATFORM_I6F: i6f_video_destroy(jpeg_index, 1); break;
case HAL_PLATFORM_T31: t31_video_destroy(jpeg_index); break;
case HAL_PLATFORM_V3: v3_video_destroy(jpeg_index); break;
case HAL_PLATFORM_V4: v4_video_destroy(jpeg_index); break;
#elif defined(__mips__)
case HAL_PLATFORM_T31:
if (app_config.mjpeg_enable) goto mjpeg_active;
t31_video_destroy(jpeg_index);
break;
#endif
default:
pthread_mutex_unlock(&jpeg_mutex);
return;
Expand All @@ -109,16 +122,19 @@ int jpeg_get(short width, short height, char quality, char grayscale,
int ret;

switch (plat) {
#if defined(__arm__)
case HAL_PLATFORM_I6: ret = i6_video_snapshot_grab(jpeg_index, quality,
grayscale, jpeg); break;
case HAL_PLATFORM_I6C: ret = i6c_video_snapshot_grab(jpeg_index, quality,
grayscale, jpeg); break;
case HAL_PLATFORM_I6F: ret = i6f_video_snapshot_grab(jpeg_index, quality,
grayscale, jpeg); break;
case HAL_PLATFORM_T31: ret = t31_video_snapshot_grab(app_config.mjpeg_enable ?
-1 : jpeg_index, jpeg); break;
case HAL_PLATFORM_V3: ret = v3_video_snapshot_grab(jpeg_index, jpeg); break;
case HAL_PLATFORM_V4: ret = v4_video_snapshot_grab(jpeg_index, jpeg); break;
#elif defined(__mips__)
case HAL_PLATFORM_T31: ret = t31_video_snapshot_grab(app_config.mjpeg_enable ?
-1 : jpeg_index, jpeg); break;
#endif
}
if (ret) {
if (jpeg->data)
Expand Down
7 changes: 5 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ rtsp_handle rtspHandle;
int main(int argc, char *argv[]) {
hal_identify();
switch (plat) {
#if defined(__arm__)
case HAL_PLATFORM_I6:
fprintf(stderr, "Divinus for infinity6(b0/e)\n"); break;
case HAL_PLATFORM_I6C:
fprintf(stderr, "Divinus for infinity6c\n"); break;
case HAL_PLATFORM_I6F:
fprintf(stderr, "Divinus for infinity6f\n"); break;
case HAL_PLATFORM_T31:
fprintf(stderr, "Divinus for ingenic t31\n"); break;
case HAL_PLATFORM_V3:
fprintf(stderr, "Divinus for hisi-gen3\n"); break;
case HAL_PLATFORM_V4:
fprintf(stderr, "Divinus for hisi-gen4\n"); break;
#elif defined(__mips__)
case HAL_PLATFORM_T31:
fprintf(stderr, "Divinus for ingenic t31\n"); break;
#endif
default:
fprintf(stderr, "Unsupported chip family! Quitting...\n");
return EXIT_FAILURE;
Expand Down
20 changes: 15 additions & 5 deletions src/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ void region_fill_formatted(char* str)

void *region_thread(void)
{
#ifdef __arm__
switch (plat) {
case HAL_PLATFORM_I6: i6_region_init(); break;
case HAL_PLATFORM_I6C: i6c_region_init(); break;
case HAL_PLATFORM_I6F: i6f_region_init(); break;
}
#endif

for (char id = 0; id < MAX_OSD; id++)
{
Expand Down Expand Up @@ -138,6 +140,7 @@ void *region_thread(void)
hal_rect rect = { .height = bitmap.dim.height, .width = bitmap.dim.width,
.x = osds[id].posx, .y = osds[id].posy };
switch (plat) {
#if defined(__arm__)
case HAL_PLATFORM_I6:
i6_region_create(id, rect, osds[id].opal);
i6_region_setbitmap(id, &bitmap);
Expand All @@ -150,10 +153,6 @@ void *region_thread(void)
i6f_region_create(id, rect, osds[id].opal);
i6f_region_setbitmap(id, &bitmap);
break;
case HAL_PLATFORM_T31:
t31_region_create(&osds[id].hand, rect, osds[id].opal);
t31_region_setbitmap(&osds[id].hand, &bitmap);
break;
case HAL_PLATFORM_V3:
v3_region_create(id, rect, osds[id].opal);
v3_region_setbitmap(id, &bitmap);
Expand All @@ -162,6 +161,12 @@ void *region_thread(void)
v4_region_create(id, rect, osds[id].opal);
v4_region_setbitmap(id, &bitmap);
break;
#elif defined(__mips__)
case HAL_PLATFORM_T31:
t31_region_create(&osds[id].hand, rect, osds[id].opal);
t31_region_setbitmap(&osds[id].hand, &bitmap);
break;
#endif
}
free(bitmap.data);
}
Expand All @@ -170,12 +175,15 @@ void *region_thread(void)
else if (empty(osds[id].text) && osds[id].updt)
{
switch (plat) {
#if defined(__arm__)
case HAL_PLATFORM_I6: 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_T31: t31_region_destroy(&osds[id].hand); break;
case HAL_PLATFORM_V3: v3_region_destroy(id); break;
case HAL_PLATFORM_V4: v4_region_destroy(id); break;
#elif defined(__mips__)
case HAL_PLATFORM_T31: t31_region_destroy(&osds[id].hand); break;
#endif
}
}
osds[id].updt = 0;
Expand All @@ -184,9 +192,11 @@ void *region_thread(void)
}

switch (plat) {
#ifdef __arm__
case HAL_PLATFORM_I6: i6_region_deinit(); break;
case HAL_PLATFORM_I6C: i6c_region_deinit(); break;
case HAL_PLATFORM_I6F: i6f_region_deinit(); break;
#endif
}
}

Expand Down
Loading

0 comments on commit 95acf6d

Please sign in to comment.