Skip to content

Commit

Permalink
Concentrate on T31 series since their encoder is fundamentally different
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jun 1, 2024
1 parent e7f2393 commit 4cec2d9
Show file tree
Hide file tree
Showing 23 changed files with 1,405 additions and 1,408 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ In spite of these design choices, Divinus boasts numerous features that cater to
| infinity6e[^6] || ✔️ | ✔️ || ✔️ |
| infinity6c[^7] || ✔️ | ✔️ || ✔️ |
| infinity6f[^8] || ✔️ | ✔️ || ✔️ |
| T2X series ||||||
| T3X series ||||||
| T31 series ||||||

_✔️ - supported, ↻ - in development, ✗ - unsupported, ⁿ/ₐ - not supported by hardware_

Expand Down
2 changes: 1 addition & 1 deletion src/app_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum ConfigError parse_app_config(void) {
enum ConfigError err;
find_sections(&ini);

if (plat != HAL_PLATFORM_TX) {
if (plat != HAL_PLATFORM_T31) {
err = parse_param_value(
&ini, "system", "sensor_config", app_config.sensor_config);
if (err != CONFIG_OK)
Expand Down
64 changes: 32 additions & 32 deletions src/hal/inge/tx_aud.h → src/hal/inge/t31_aud.h
Original file line number Diff line number Diff line change
@@ -1,119 +1,119 @@
#pragma once

#include "tx_common.h"
#include "t31_common.h"

#define TX_AUD_CHN_NUM 2
#define T31_AUD_CHN_NUM 2

typedef enum {
TX_AUD_BIT_16
} tx_aud_bit;
T31_AUD_BIT_16
} t31_aud_bit;

typedef enum {
TX_AUD_SND_MONO = 1,
TX_AUD_SND_STEREO = 2
} tx_aud_snd;
T31_AUD_SND_MONO = 1,
T31_AUD_SND_STEREO = 2
} t31_aud_snd;

typedef struct {
// Accept industry standards from 8000 to 96000Hz
int rate;
tx_aud_bit bit;
tx_aud_snd mode;
t31_aud_bit bit;
t31_aud_snd mode;
unsigned int frmNum;
unsigned int packNumPerFrm;
unsigned int chnNum;
} tx_aud_cnf;
} t31_aud_cnf;

typedef struct {
tx_aud_bit bit;
tx_aud_snd mode;
t31_aud_bit bit;
t31_aud_snd mode;
unsigned int addr;
unsigned int phy;
unsigned long long timestamp;
unsigned int sequence;
unsigned int length;
} tx_aud_frm;
} t31_aud_frm;

typedef struct {
void *handle;

int (*fnDisableDevice)(int device);
int (*fnEnableDevice)(int device);
int (*fnSetDeviceConfig)(int device, tx_aud_cnf *config);
int (*fnSetDeviceConfig)(int device, t31_aud_cnf *config);

int (*fnDisableChannel)(int device, int channel);
int (*fnEnableChannel)(int device, int channel);

int (*fnSetMute)(int device, int channel, int active);
int (*fnSetVolume)(int device, int channel, int *dbLevel);

int (*fnFreeFrame)(int device, int channel, tx_aud_frm *frame);
int (*fnGetFrame)(int device, int channel, tx_aud_frm *frame, int notBlocking);
} tx_aud_impl;
int (*fnFreeFrame)(int device, int channel, t31_aud_frm *frame);
int (*fnGetFrame)(int device, int channel, t31_aud_frm *frame, int notBlocking);
} t31_aud_impl;

static int tx_aud_load(tx_aud_impl *aud_lib) {
static int t31_aud_load(t31_aud_impl *aud_lib) {
if (!(aud_lib->handle = dlopen("libimp.so", RTLD_LAZY | RTLD_GLOBAL))) {
fprintf(stderr, "[tx_aud] Failed to load library!\nError: %s\n", dlerror());
fprintf(stderr, "[t31_aud] Failed to load library!\nError: %s\n", dlerror());
return EXIT_FAILURE;
}

if (!(aud_lib->fnDisableDevice = (int(*)(int device))
dlsym(aud_lib->handle, "IMP_AI_Disable"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_Disable!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_Disable!\n");
return EXIT_FAILURE;
}

if (!(aud_lib->fnEnableDevice = (int(*)(int device))
dlsym(aud_lib->handle, "IMP_AI_Enable"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_Enable!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_Enable!\n");
return EXIT_FAILURE;
}

if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, tx_aud_cnf *config))
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, t31_aud_cnf *config))
dlsym(aud_lib->handle, "IMP_AI_SetPubAttr"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetPubAttr!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_SetPubAttr!\n");
return EXIT_FAILURE;
}

if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "IMP_AI_DisableChn"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_DisableChn!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_DisableChn!\n");
return EXIT_FAILURE;
}

if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "IMP_AI_EnableChn"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_EnableChn!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_EnableChn!\n");
return EXIT_FAILURE;
}

if (!(aud_lib->fnSetMute = (int(*)(int device, int channel, int active))
dlsym(aud_lib->handle, "IMP_AI_SetVolMute"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetVolMute!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_SetVolMute!\n");
return EXIT_FAILURE;
}

if (!(aud_lib->fnSetVolume = (int(*)(int device, int channel, int *dbLevel))
dlsym(aud_lib->handle, "IMP_AI_SetVol"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_SetVol!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_SetVol!\n");
return EXIT_FAILURE;
}

if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, tx_aud_frm *frame))
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, t31_aud_frm *frame))
dlsym(aud_lib->handle, "IMP_AI_ReleaseFrame"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_ReleaseFrame!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_ReleaseFrame!\n");
return EXIT_FAILURE;
}

if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, tx_aud_frm *frame, int notBlocking))
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, t31_aud_frm *frame, int notBlocking))
dlsym(aud_lib->handle, "IMP_AI_GetFrame"))) {
fprintf(stderr, "[tx_aud] Failed to acquire symbol IMP_AI_GetFrame!\n");
fprintf(stderr, "[t31_aud] Failed to acquire symbol IMP_AI_GetFrame!\n");
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}

static void tx_aud_unload(tx_aud_impl *aud_lib) {
static void t31_aud_unload(t31_aud_impl *aud_lib) {
if (aud_lib->handle) dlclose(aud_lib->handle);
aud_lib->handle = NULL;
memset(aud_lib, 0, sizeof(*aud_lib));
Expand Down
74 changes: 74 additions & 0 deletions src/hal/inge/t31_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#pragma once

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>

#include "../types.h"

#define T31_ERROR(x, ...) \
do { \
fprintf(stderr, "[t31_hal] \033[31m"); \
fprintf(stderr, (x), ##__VA_ARGS__); \
fprintf(stderr, "\033[0m"); \
return EXIT_FAILURE; \
} while (0)

typedef enum {
T31_PIXFMT_YUV420P,
T31_PIXFMT_YUV422_YUYV,
T31_PIXFMT_YUV422_UYVY,
T31_PIXFMT_YUV422P,
T31_PIXFMT_YUV444P,
T31_PIXFMT_YUV410P,
T31_PIXFMT_YUV411P,
T31_PIXFMT_GRAY8,
T31_PIXFMT_MONOWHITE,
T31_PIXFMT_MONOBLACK,
T31_PIXFMT_NV12,
T31_PIXFMT_NV24,
T31_PIXFMT_RGB888,
T31_PIXFMT_BGR888,
T31_PIXFMT_ARGB8888,
T31_PIXFMT_RGBA8888,
T31_PIXFMT_ABGR8888,
T31_PIXFMT_BGRA8888,
T31_PIXFMT_RGB565BE,
T31_PIXFMT_RGB565LE,
// Following twos have their MSB set to 1
T31_PIXFMT_RGB555BE,
T31_PIXFMT_RGB555LE,
T31_PIXFMT_BGR565BE,
T31_PIXFMT_BGR565LE,
// Following twos have their MSB set to 1
T31_PIXFMT_BGR555BE,
T31_PIXFMT_BGR555LE,
T31_PIXFMT_0RGB8888,
T31_PIXFMT_RGB08888,
T31_PIXFMT_0BGR8888,
T31_PIXFMT_BGR08888,
T31_PIXFMT_BAYER_BGGR8,
T31_PIXFMT_BAYER_RGGB8,
T31_PIXFMT_BAYER_GBRG8,
T31_PIXFMT_BAYER_GRBG8,
T31_PIXFMT_RAW,
T31_PIXFMT_HSV888,
T31_PIXFMT_END
} t31_common_pixfmt;

typedef struct {
int width;
int height;
} t31_common_dim;

typedef struct {
int x;
int y;
} t31_common_pnt;

typedef struct {
t31_common_pnt p0;
t31_common_pnt p1;
} t31_common_rect;
56 changes: 28 additions & 28 deletions src/hal/inge/tx_fs.h → src/hal/inge/t31_fs.h
Original file line number Diff line number Diff line change
@@ -1,114 +1,114 @@
#pragma once

#include "tx_common.h"
#include "t31_common.h"

typedef struct {
int enable;
int left;
int top;
int width;
int height;
} tx_fs_crop;
} t31_fs_crop;

typedef struct {
int enable;
int width;
int height;
} tx_fs_scale;
} t31_fs_scale;

typedef struct {
tx_common_dim dest;
tx_common_pixfmt pixFmt;
tx_fs_crop crop;
tx_fs_scale scale;
t31_common_dim dest;
t31_common_pixfmt pixFmt;
t31_fs_crop crop;
t31_fs_scale scale;
int fpsNum;
int fpsDen;
int bufCount;
int phyOrExtChn;
tx_fs_crop frame;
} tx_fs_chn;
t31_fs_crop frame;
} t31_fs_chn;

typedef struct {
int index;
int poolId;
unsigned int width;
unsigned int height;
tx_common_pixfmt pixFmt;
t31_common_pixfmt pixFmt;
unsigned int size;
unsigned int phyAddr;
unsigned int virtAddr;
long long timestamp;
int rotateFlag;
unsigned int priv[0];
} tx_fs_frame;
} t31_fs_frame;

typedef struct {
void *handle;

int (*fnCreateChannel)(int channel, tx_fs_chn *config);
int (*fnCreateChannel)(int channel, t31_fs_chn *config);
int (*fnDestroyChannel)(int channel);
int (*fnDisableChannel)(int channel);
int (*fnEnableChannel)(int channel);
int (*fnSetChannelRotate)(int channel, char rotateMode, int width, int height);
int (*fnSetChannelSource)(int channel, int source);

int (*fnSnapshot)(int channel, tx_common_pixfmt pixFmt, int width, int height,
void *data, tx_fs_frame *info);
} tx_fs_impl;
int (*fnSnapshot)(int channel, t31_common_pixfmt pixFmt, int width, int height,
void *data, t31_fs_frame *info);
} t31_fs_impl;

static int tx_fs_load(tx_fs_impl *fs_lib) {
static int t31_fs_load(t31_fs_impl *fs_lib) {
if (!(fs_lib->handle = dlopen("libimp.so", RTLD_LAZY | RTLD_GLOBAL))) {
fprintf(stderr, "[tx_fs] Failed to load library!\nError: %s\n", dlerror());
fprintf(stderr, "[t31_fs] Failed to load library!\nError: %s\n", dlerror());
return EXIT_FAILURE;
}

if (!(fs_lib->fnCreateChannel = (int(*)(int channel, tx_fs_chn *config))
if (!(fs_lib->fnCreateChannel = (int(*)(int channel, t31_fs_chn *config))
dlsym(fs_lib->handle, "IMP_FrameSource_CreateChn"))) {
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_CreateChn!\n");
fprintf(stderr, "[t31_fs] Failed to acquire symbol IMP_FrameSource_CreateChn!\n");
return EXIT_FAILURE;
}

if (!(fs_lib->fnDestroyChannel = (int(*)(int channel))
dlsym(fs_lib->handle, "IMP_FrameSource_DestroyChn"))) {
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_DestroyChn!\n");
fprintf(stderr, "[t31_fs] Failed to acquire symbol IMP_FrameSource_DestroyChn!\n");
return EXIT_FAILURE;
}

if (!(fs_lib->fnDisableChannel = (int(*)(int channel))
dlsym(fs_lib->handle, "IMP_FrameSource_DisableChn"))) {
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_DisableChn!\n");
fprintf(stderr, "[t31_fs] Failed to acquire symbol IMP_FrameSource_DisableChn!\n");
return EXIT_FAILURE;
}

if (!(fs_lib->fnEnableChannel = (int(*)(int channel))
dlsym(fs_lib->handle, "IMP_FrameSource_EnableChn"))) {
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_EnableChn!\n");
fprintf(stderr, "[t31_fs] Failed to acquire symbol IMP_FrameSource_EnableChn!\n");
return EXIT_FAILURE;
}

if (!(fs_lib->fnSetChannelRotate = (int(*)(int channel, char rotateMode, int width, int height))
dlsym(fs_lib->handle, "IMP_FrameSource_SetChnRotate"))) {
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SetChnRotate!\n");
fprintf(stderr, "[t31_fs] Failed to acquire symbol IMP_FrameSource_SetChnRotate!\n");
return EXIT_FAILURE;
}

if (!(fs_lib->fnSetChannelSource = (int(*)(int channel, int source))
dlsym(fs_lib->handle, "IMP_FrameSource_SetSource"))) {
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SetSource!\n");
fprintf(stderr, "[t31_fs] Failed to acquire symbol IMP_FrameSource_SetSource!\n");
return EXIT_FAILURE;
}

if (!(fs_lib->fnSnapshot = (int(*)(int channel, tx_common_pixfmt pixFmt, int width, int height,
void *data, tx_fs_frame *info))
if (!(fs_lib->fnSnapshot = (int(*)(int channel, t31_common_pixfmt pixFmt, int width, int height,
void *data, t31_fs_frame *info))
dlsym(fs_lib->handle, "IMP_FrameSource_SnapFrame"))) {
fprintf(stderr, "[tx_fs] Failed to acquire symbol IMP_FrameSource_SnapFrame!\n");
fprintf(stderr, "[t31_fs] Failed to acquire symbol IMP_FrameSource_SnapFrame!\n");
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}

static void tx_fs_unload(tx_fs_impl *fs_lib) {
static void t31_fs_unload(t31_fs_impl *fs_lib) {
if (fs_lib->handle) dlclose(fs_lib->handle);
fs_lib->handle = NULL;
memset(fs_lib, 0, sizeof(*fs_lib));
Expand Down
Loading

0 comments on commit 4cec2d9

Please sign in to comment.