Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rockchip #6

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ jobs:
- name: Build
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC sudo apt-get -y install git make wget gcc libevent-dev libcsfml-dev file g++ cpio unzip rsync bc bzip2
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC sudo apt-get -y install git make wget gcc libevent-dev libcsfml-dev file g++ cpio unzip rsync bc bzip2 libcairo-dev
./build.sh goke
./build.sh hisi
./build.sh star6b0
./build.sh star6e
./build.sh native
./build.sh rockchip

- name: Upload binary
uses: actions/upload-artifact@v4
Expand All @@ -35,6 +36,7 @@ jobs:
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_rockchip
msposd

- name: Versioned release
Expand All @@ -46,6 +48,7 @@ jobs:
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_rockchip
msposd

- name: Upload latest
Expand All @@ -58,4 +61,5 @@ jobs:
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_rockchip
msposd
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ majestic.yaml
/msposd
firmware/
release/
aarch64/
disk.raw
msposd_goke
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_x86
msposd_rockchip
msposd
serial_monitor.c
version.h
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ version.h:
all: version.h

clean:
rm -f *.o msposd msposd_goke msposd_hisi msposd_star6b0 msposd_star6e
rm -f *.o msposd msposd_goke msposd_hisi msposd_star6b0 msposd_star6e msposd_rockchip

goke: version.h
$(eval SDK = ./sdk/gk7205v300)
Expand Down Expand Up @@ -52,3 +52,9 @@ native: version.h
$(eval BUILD = $(CC) $(SRCS) -I $(SDK)/include -L $(DRV) $(CFLAGS) $(LIB) -levent_core -O0 -g -o $(OUTPUT))
$(BUILD)

rockchip: version.h
$(eval SDK = ./sdk/gk7205v300)
$(eval CFLAGS += -D__ROCKCHIP__)
$(eval LIB = `pkg-config --libs cairo x11` -lm -lrt)
$(eval BUILD = $(CC) $(SRCS) -I $(SDK)/include -L $(DRV) $(CFLAGS) $(LIB) -levent_core -O0 -g -o $(OUTPUT))
$(BUILD)
4 changes: 2 additions & 2 deletions bmp/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const double inv16 = 1.0 / 16.0;
int create_region(int *handle, int x, int y, int width, int height)
{
int s32Ret = -1;
#ifndef _x86
#if !defined(_x86) && !defined(__ROCKCHIP__)
#ifdef __SIGMASTAR__
MI_RGN_ChnPort_t stChn;

Expand Down Expand Up @@ -313,7 +313,7 @@ int prepare_bitmap(const char *filename, BITMAP *bitmap, int bFil, unsigned int
int set_bitmap(int handle, BITMAP *bitmap)
{
int s32Ret=0;
#ifndef _x86
#if !defined(_x86) && !defined(__ROCKCHIP__)
#ifdef __SIGMASTAR__
s32Ret = MI_RGN_SetBitMap(handle, (MI_RGN_Bitmap_t *)(bitmap));
#elif __GOKE__
Expand Down
5 changes: 3 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
GCC=$PWD/toolchain/$CC/bin/arm-linux-gcc
OUT=msposd

if [[ "$1" != *"native"* ]]; then
if [[ "$1" != *"native"* && "$1" != *"rockhip"* ]]; then
if [ ! -e toolchain/$CC ]; then
wget -c -q --show-progress $DL.$CC.tgz -P $PWD
mkdir -p toolchain/$CC
Expand All @@ -29,7 +29,6 @@ if [[ "$1" != *"native"* ]]; then
OUT=msposd_$1
fi


if [ ! -e firmware ]; then
git clone https://github.com/openipc/firmware --depth=1
fi
Expand All @@ -46,6 +45,8 @@ elif [ "$1" = "star6b0" ]; then
elif [ "$1" = "star6e" ]; then
DRV=$PWD/firmware/general/package/sigmastar-osdrv-infinity6e/files/lib
make -B CC=$GCC DRV=$DRV TOOLCHAIN=$PWD/toolchain/$CC OUTPUT=$OUT $1
elif [ "$1" = "rockchip" ]; then
./build_rockchip.sh $1
else
DRV=$PWD
make DRV=$DRV OUTPUT=$OUT $1
Expand Down
58 changes: 58 additions & 0 deletions build_rockchip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh
output=aarch64

# We run arm binary's under x86, crazy, right ;)
which qemu-arm-static 2>/dev/null > /dev/null || sudo apt-get install -y qemu-user-static

# download and unpack debian arm image
host=https://cloud.debian.org/images/cloud/bullseye
release=latest
system=debian-11-generic-arm64.tar
if [ ! -f disk.raw ]; then
wget -nv ${host}/${release}/${system}.xz
tar -xf ${system}.xz
rm ${system}.xz
fi

# loop mount the image
if [ ! -d output/tmp ]; then
mkdir -p $output
device=$(sudo losetup -P --show -f disk.raw)
sudo mount ${device}p1 $output
sudo mkdir -p $output/usr/src/msposd
sudo mount -o bind $(pwd) $output/usr/src/msposd
fi

if [ ! -f $output/tmp/prepare_chroot.done ]; then
cat > prepare_chroot.sh << EOL
#!/bin/bash
cd /home
# install radxa APT repo, see https://radxa-repo.github.io/bullseye/
keyring="/home/keyring.deb"
version="\$(curl -L https://github.com/radxa-pkg/radxa-archive-keyring/releases/latest/download/VERSION)"
curl -L --output "\$keyring" "https://github.com/radxa-pkg/radxa-archive-keyring/releases/download/\${version}/radxa-archive-keyring_\${version}_all.deb"
dpkg -i \$keyring
echo 'deb [signed-by=/usr/share/keyrings/radxa-archive-keyring.gpg] https://radxa-repo.github.io/bullseye/ bullseye main' > /etc/apt/sources.list.d/70-radxa.list
echo 'deb [signed-by=/usr/share/keyrings/radxa-archive-keyring.gpg] https://radxa-repo.github.io/bullseye rockchip-bullseye main' > /etc/apt/sources.list.d/80-rockchip.list
apt-get update
apt-get install -y git gcc make pkg-config libspdlog-dev libevent-dev libcairo-dev
apt clean
touch /tmp/prepare_chroot.done
EOL
chmod +x prepare_chroot.sh
sudo cp prepare_chroot.sh $output/home
sudo rm $output/etc/resolv.conf
echo nameserver 1.1.1.1 | sudo tee $output/etc/resolv.conf
sudo chroot $output /home/prepare_chroot.sh
rm prepare_chroot.sh
fi

if [ "$(uname -m)" = "x86_64" ]; then
sudo chroot aarch64 make OUTPUT=msposd_$1 $1 -C /usr/src/msposd
else
make OUTPUT=$OUT $1
fi
sudo umount $output/usr/src/msposd
sudo umount $output
sudo losetup -d ${device}
2 changes: 1 addition & 1 deletion compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
int __ctype_b;
int __stdin;

#ifndef _x86
#if !defined(_x86) && !defined(__ROCKCHIP__)
int __fgetc_unlocked(FILE *stream) {
return fgetc(stream);
}
Expand Down
43 changes: 24 additions & 19 deletions osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
#include "osd/msp/msp.h"
#include "osd/msp/msp_displayport.h"

#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)
// #include <cairo/cairo.h>
// #include <cairo/cairo-xlib.h>
// #include <X11/Xlib.h>
// #include <X11/Xutil.h>
// #include <X11/Xatom.h>
// #include <stdio.h>
// #include <stdbool.h>
#if defined(_x86)
#include "osd/util/Render_x86.c"
#elif defined(__ROCKCHIP__)
#include "osd/util/Render_Rockchip.c"
#endif
#else
#include "bmp/region.h"
#include "bmp/common.h"
Expand Down Expand Up @@ -92,7 +96,7 @@ typedef struct msp_cache_entry_s {

static msp_cache_entry_t *msp_message_cache[256]; // make a slot for all possible messages

static uint8_t frame_buffer[8192]; // buffer a whole frame of MSP commands until we get a draw command
static uint8_t frame_buffer[1024]; // buffer a whole frame of MSP commands until we get a draw command. needs to fit in UDP !
static uint32_t fb_cursor = 0;

static uint8_t message_buffer[256]; // only needs to be the maximum size of an MSP packet, we only care to fwd MSP
Expand Down Expand Up @@ -680,7 +684,7 @@ int y_end = 500;
}

void LineDirect(uint8_t* bmpData, uint32_t width, uint32_t height, int x0, int y0, int x1, int y1, uint8_t color, int thickness) {
#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)

drawLine_x86(x0, y0, x1, y1, getcolor(color), thickness, false);
#else
Expand All @@ -690,7 +694,7 @@ int y_end = 500;


void LineTranspose(uint8_t* bmpData, int posX0, int posY0, int posX1, int posY1, uint8_t color, int thickness) {
#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)
drawLine_x86(posX0, posY0, posX1, posY1, getcolor(color), thickness, true);
#else
drawLine( bmpData, posX0, posY0, posX1, posY1, color, thickness);
Expand Down Expand Up @@ -948,7 +952,7 @@ void LineTranspose(uint8_t* bmpData, int posX0, int posY0, int posX1, int posY1,
sprintf(buffer, "%+02d°", -last_pitch/10);

int osd_font_size=18;
#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)
uint32_t color = getcolor(COLOR_YELLOW);
if ((-50 < last_pitch) && (last_pitch <50))
color = getcolor(COLOR_WHITE);
Expand Down Expand Up @@ -1021,7 +1025,7 @@ void LineTranspose(uint8_t* bmpData, int posX0, int posY0, int posX1, int posY1,
//needed since we may have already painted the icons
}
}
#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)
Render_x86_rect(bmpBuff.pData,bmpBuff.u32Width, bmpBuff.u32Height,xR,yR,xR,yR,s_width,s_height);
#endif

Expand All @@ -1043,7 +1047,7 @@ static bool first_wfb_read=true;
void fill(char* str)
{
unsigned int rxb_l, txb_l, cpu_l[7];
char out[180] = "";
char out[280] = "";
char param = 0;
int ipos = 0, opos = 0;

Expand Down Expand Up @@ -1183,7 +1187,7 @@ static bool first_wfb_read=true;
ipos++;
char s[64];
time_t t = time(NULL);
struct tm *tm = gmtime(&t);
struct tm *tm = localtime(&t);
strftime(s, 64, timefmt, tm);
strcat(out, s);
opos += strlen(s);
Expand Down Expand Up @@ -1296,7 +1300,7 @@ void remove_carriage_returns(char *out) {
out[j] = '\0'; // Null-terminate the modified string
}

char osdmsg[80];
char osdmsg[180];

bool DrawTextOnOSDBitmap(char* msg){
char *font;
Expand All @@ -1323,7 +1327,7 @@ bool DrawTextOnOSDBitmap(char* msg){
if (msg == NULL || strlen(msg)==0){
file = fopen(FECFile, "rb");
if (file != NULL){// New file, will have to render the font
bytesRead = fread(osdmsg, 1, 79 /*max buffer*/, file); //with files
bytesRead = fread(osdmsg, 1, 179 /*max buffer*/, file); //with files
fclose(file);
remove(FECFile);
osdmsg[bytesRead]=0;//end of string
Expand Down Expand Up @@ -1491,7 +1495,7 @@ bool Convert2SmallGlyph(BITMAP *fnt , u_int16_t *s_left, u_int16_t *s_top, u_in
//Not needed, but somehow parsing DrawString in InjectChars sometimes does not work.
static bool ReplaceWidgets_Slow(int* x, int* y){

#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)
if (character_map[*x][*y]=='!' && character_map[*x+1][*y]=='R' && character_map[*x+2][*y]=='C' && character_map[*x+3][*y]=='!'){
RCWidgetX = *x *current_display_info.font_width;
RCWidgetY = current_display_info.font_height * *y;
Expand Down Expand Up @@ -1664,7 +1668,7 @@ static void draw_screenBMP(){
}

step2=get_time_ms();
#ifndef _x86
#if !defined(_x86) && !defined(__ROCKCHIP__)

if (AHI_Enabled==2)
draw_AHI();
Expand All @@ -1683,7 +1687,7 @@ static void draw_screenBMP(){

stat_screen_refresh_count++;
uint64_t step3=get_time_ms();
#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)

if (bmp_x86==NULL)//lets cache it
bmp_x86 = malloc(bmpBuff.u32Width * bmpBuff.u32Height * 4); // Allocate memory for RGBA data
Expand Down Expand Up @@ -1859,7 +1863,7 @@ unsigned char* loadPngToBMP(const char* filename, unsigned int* width, unsigned
else if (PIXEL_FORMAT_DEFAULT==PIXEL_FORMAT_8888){
// memcpy(bmpData,pngData,bmpSize);
convertRGBAToARGB( pngData, *width , *height, bmpData);
#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)
premultiplyAlpha((uint32_t*) bmpData, *width, *height);//RGBA format needs to be converted when using transparency?
#endif
}else
Expand Down Expand Up @@ -2057,8 +2061,8 @@ static void InitMSPHook(){
PIXEL_FORMAT_DEFAULT=PIXEL_FORMAT_I4;//I4 format, 4 bits per pixel
PIXEL_FORMAT_BitsPerPixel = 4;
#endif
#ifdef _x86
//enable this to simulate I4 Bitmap Processing on SigmaStar
#if defined(_x86) || defined(__ROCKCHIP__)
//enable this to test simulate preocessing on SigmaStar
//PIXEL_FORMAT_DEFAULT=PIXEL_FORMAT_I4;//I4 format, 4 bits per pixel
//PIXEL_FORMAT_BitsPerPixel = 4;

Expand All @@ -2070,10 +2074,11 @@ static void InitMSPHook(){

height = GetMajesticVideoConfig(&majestic_width);
majestic_height=height;
#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)
if (DrawOSD)
Init_x86(&OVERLAY_WIDTH, &OVERLAY_HEIGHT);
height=OVERLAY_HEIGHT;
printf("OSD is %ix%i pixels\n",OVERLAY_WIDTH,OVERLAY_HEIGHT);
#endif

//Get video resolution
Expand Down Expand Up @@ -2232,7 +2237,7 @@ On sigmastar the BMP row stride is aligned to 8 bytes, that is 16 pixels in PIXE
printf("Set Goke Font Review %d:%d\r\n", bitmap.u32Width, bitmap.u32Height);

set_bitmap(osds[FULL_OVERLAY_ID].hand, &bitmap);//bitmap must match region dimensions!
#elif _x86
#elif defined(_x86) || defined(__ROCKCHIP__)
//sfRenderWindow_clear(window, sfColor_fromRGB(255, 255, 0));

unsigned char* rgbaData = malloc(bitmap.u32Width * bitmap.u32Height * 4); // Allocate memory for RGBA data
Expand Down Expand Up @@ -2294,7 +2299,7 @@ static void CloseMSP(){
if (deinit)
printf("[%s:%d]RGN_DeInit failed with %#x!\n", __func__, __LINE__, s32Ret);
#endif
#ifdef _x86
#if defined(_x86) || defined(__ROCKCHIP__)
Close_x86();
#endif

Expand Down
Loading
Loading