Skip to content

Commit

Permalink
Preliminary support code for Ingenic (needs to be reworked since fork…
Browse files Browse the repository at this point in the history
…ing causes issues with libimp), added independent builds for infinity6b0, fixed regions for hardware that have less granularity over their dimensions
  • Loading branch information
wberube committed May 11, 2024
1 parent 87680ca commit 980c1f2
Show file tree
Hide file tree
Showing 31 changed files with 10,095 additions and 105 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
run: |
bash build.sh osd-goke
bash build.sh osd-hisi
bash build.sh osd-star
bash build.sh osd-star6b0
bash build.sh osd-star6e
- name: Upload files
uses: softprops/action-gh-release@v2
Expand All @@ -28,4 +29,5 @@ jobs:
files: |
osd/osd-goke
osd/osd-hisi
osd/osd-star
osd/osd-star6b0
osd/osd-star6e
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/firmware
/toolchain
/osd/osd*
/osd/osd-*
17 changes: 14 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/bash
DL="https://github.com/openipc/firmware/releases/download/latest"

if [ "$1" = "osd-star" ]; then
if [ "$1" = "osd-inge" ]; then
CC=mips_xburst-gcc13-musl-3_10
elif [[ "$1" == *"-star6b0" ]]; then
CC=cortex_a7_thumb2_hf-gcc13-musl-4_9
elif [[ "$1" == *"-star6e" ]]; then
CC=cortex_a7_thumb2_hf-gcc13-glibc-4_9
else
CC=cortex_a7_thumb2-gcc13-musl-4_9
Expand All @@ -26,10 +30,17 @@ if [ "$1" = "osd-goke" ]; then
elif [ "$1" = "osd-hisi" ]; then
DRV=$PWD/firmware/general/package/hisilicon-osdrv-hi3516ev200/files/lib
make -C osd -B CC=$GCC DRV=$DRV $1
elif [ "$1" = "osd-star" ]; then
elif [ "$1" = "osd-inge" ]; then
DRV=$PWD/firmware/general/package/ingenic-osdrv-t31/files/lib
GCC=$PWD/toolchain/$CC/bin/mipsel-linux-gcc
make -C osd -B CC=$GCC DRV=$DRV $1
elif [ "$1" = "osd-star6b0" ]; then
DRV=$PWD/firmware/general/package/sigmastar-osdrv-infinity6b0/files/lib
make -C osd -B CC=$GCC DRV=$DRV $1
elif [ "$1" = "osd-star6e" ]; then
DRV=$PWD/firmware/general/package/sigmastar-osdrv-infinity6e/files/lib
make -C osd -B CC=$GCC DRV=$DRV $1
else
echo "Usage: $0 [osd-goke|osd-hisi|osd-star]"
echo "Usage: $0 [osd-goke|osd-hisi|osd-inge|osd-star6b0|osd-star6e]"
exit 1
fi
18 changes: 14 additions & 4 deletions osd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ BUILD = $(CC) $(SRCS) -I $(SDK)/include -L $(DRV) $(LIB) -Os -s -o $(or $(TARGET

osd-goke:
$(eval SDK = ../sdk/gk7205v300)
$(eval LIB = -lhi_mpi -lgk_api -ldnvqe -lupvqe -lvoice_engine -lsecurec)
$(eval LIB = -ldnvqe -lgk_api -lhi_mpi -lsecurec -lupvqe -lvoice_engine)
$(BUILD)

osd-hisi:
$(eval SDK = ../sdk/hi3516ev300)
$(eval LIB = -lmpi -ldnvqe -lupvqe -lVoiceEngine -lsecurec)
$(eval LIB = -ldnvqe -lmpi -lsecurec -lupvqe -lVoiceEngine)
$(BUILD)

osd-star:
osd-inge:
$(eval SDK = ../sdk/ingenic)
$(eval LIB = -D__INGENIC__ -lalog -limp)
$(BUILD)

osd-star6b0:
$(eval SDK = ../sdk/infinity6)
$(eval LIB = -D__SIGMASTAR__ -lcam_os_wrapper -lm -lmi_rgn -lmi_sys)
$(eval LIB = -D__SIGMASTAR__ -D__INFINITY6__ -D__INFINITY6B0__ -lcam_os_wrapper -lm -lmi_rgn -lmi_sys)
$(BUILD)

osd-star6e:
$(eval SDK = ../sdk/infinity6)
$(eval LIB = -D__SIGMASTAR__ -D__INFINITY6__ -D__INFINITY6E__ -lcam_os_wrapper -lm -lmi_rgn -lmi_sys)
$(BUILD)
11 changes: 11 additions & 0 deletions osd/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <unistd.h> // getopt, optarg, opterr
#include <ctype.h> // isdigit
#include <time.h> // clock_(get|set)time, timespec
#include <math.h> // ceil

#include <arpa/inet.h>
#include <fcntl.h>
Expand Down Expand Up @@ -38,6 +39,15 @@ extern "C"
#define PIXEL_FORMAT_1555 E_MI_RGN_PIXEL_FORMAT_ARGB1555
#define PIXEL_FORMAT_2BPP E_MI_RGN_PIXEL_FORMAT_I2
#define PIXEL_FORMAT_8888 E_MI_RGN_PIXEL_FORMAT_ARGB8888
#elif defined(__INGENIC__)
#include "imp_system.h"
#include "imp_osd.h"
#include "imp_isp.h"

#define PIXEL_FORMAT_4444 0
#define PIXEL_FORMAT_1555 PIX_FMT_RGB555LE
#define PIXEL_FORMAT_2BPP PIX_FMT_0RGB
#define PIXEL_FORMAT_8888 PIX_FMT_ARGB
#else
#include "hi_common.h"
#include "hi_math.h"
Expand Down Expand Up @@ -72,6 +82,7 @@ extern "C"
typedef struct osd
{
double size;
int hand;
short posx, posy;
char updt;
char font[32];
Expand Down
22 changes: 20 additions & 2 deletions osd/compat.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
#include <stdio.h>

int __ctype_b;
#ifdef __INGENIC__
#include <sys/syscall.h>
#include <unistd.h>
#endif

void __ctype_b(void) {}

int __fgetc_unlocked(FILE *stream) {
return fgetc(stream);
}

size_t _stdlib_mb_cur_max(void) {
return 0;
}
}

#ifdef __INGENIC__
void __assert(void) {}
void __ctype_tolower(void) {}
void __pthread_register_cancel(void) {}
void __pthread_unregister_cancel(void) {}

void *mmap(void *start, size_t len, int prot, int flags, int fd, unsigned int off) {
return (void *)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
}
#elif defined(__SIGMASTAR__) && defined(__INFINITY6B0__)
void __stdin(void) {}
#endif
48 changes: 33 additions & 15 deletions osd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static void fill(char* str)
strcat(out, s);
opos += strlen(s);
}
#ifndef __INGENIC__
else if (str[ipos + 1] == 'T')
{
ipos++;
Expand All @@ -104,6 +105,7 @@ static void fill(char* str)
strcat(out, t);
opos += strlen(t);
}
#endif
else if (str[ipos + 1] == '$') {
ipos++;
strcat(out, "$");
Expand Down Expand Up @@ -131,18 +133,18 @@ void overlays()
}

if (osds[id].updt) {
RECT rect = measure_text(osds[id].font, osds[id].size, out);
create_region(id, osds[id].posx, osds[id].posy, rect.width, rect.height);

BITMAP bitmap = raster_text(osds[id].font, osds[id].size, out);
#ifdef __SIGMASTAR__
int s32Ret = MI_RGN_SetBitMap(id, (MI_RGN_Bitmap_t *)(&bitmap));
#else
int s32Ret = HI_MPI_RGN_SetBitMap(id, (BITMAP_S *)(&bitmap));
#endif
if (s32Ret)
fprintf(stderr, "[%s:%d]RGN_SetBitMap failed with %#x %d!\n", __func__, __LINE__, s32Ret, id);
free(bitmap.pData);
char *font;
asprintf(&font, "/usr/share/fonts/truetype/%s.ttf", osds[id].font);
if (!access(font, F_OK)) {
RECT rect = measure_text(font, osds[id].size, out);
create_region(
&osds[id].hand,
osds[id].posx, osds[id].posy,
rect.width, rect.height);
BITMAP bitmap = raster_text(font, osds[id].size, out);
set_bitmap(osds[id].hand, &bitmap);
free(bitmap.pData);
}
}
}
else if (empty(osds[id].text) && osds[id].updt)
Expand All @@ -154,13 +156,13 @@ void overlays()
BITMAP bitmap;
if (!(prepare_bitmap(img, &bitmap, 0, 0, PIXEL_FORMAT_1555)))
{
create_region(id, osds[id].posx, osds[id].posy, bitmap.u32Width, bitmap.u32Height);
set_bitmap(id, &bitmap);
create_region(&osds[id].hand, osds[id].posx, osds[id].posy, bitmap.u32Width, bitmap.u32Height);
set_bitmap(osds[id].hand, &bitmap);
free(bitmap.pData);
}
}
else
unload_region(id);
unload_region(&osds[id].hand);
osds[id].updt = 0;
}
}
Expand Down Expand Up @@ -294,10 +296,20 @@ void route()
);
}

#ifdef __INGENIC__
extern int IMP_OSD_SetPoolSize(int size);
#endif

int main(int argc, char *argv[])
{
#ifndef __INGENIC__
int fd_mem = open("/dev/mem", O_RDWR);
io_map = mmap(NULL, IO_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd_mem, IO_BASE);
#else
fprintf(stderr, "IMP_System_Init ret:%d\n", IMP_System_Init());
fprintf(stderr, "IMP_OSD_SetPoolSize ret:%d\n", IMP_OSD_SetPoolSize(512 * 1024));
fprintf(stderr, "IMP_OSD_CreateGroup ret:%d\n", IMP_OSD_CreateGroup(0));
#endif

#ifdef __SIGMASTAR__
static MI_RGN_PaletteTable_t g_stPaletteTable = {{{0, 0, 0, 0}}};
Expand All @@ -310,6 +322,7 @@ int main(int argc, char *argv[])
PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
for (int id = 0; id < MAX_OSD; id++)
{
osds[id].hand = -1;
osds[id].size = DEF_SIZE;
osds[id].posx = DEF_POSX;
osds[id].posy = DEF_POSY;
Expand All @@ -331,8 +344,13 @@ int main(int argc, char *argv[])
printf("[%s:%d]RGN_DeInit failed with %#x!\n", __func__, __LINE__, s32Ret);
#endif

#ifndef __INGENIC__
munmap(io_map, IO_SIZE);
close(fd_mem);
#else
IMP_OSD_DestroyGroup(0);
fprintf(stderr, "IMP_System_Exit ret:%d\n", IMP_System_Exit());
#endif

return 0;
}
Loading

0 comments on commit 980c1f2

Please sign in to comment.