Compare commits

..

2 commits

Author SHA1 Message Date
JerryXiao 1847cd5f02
resolve github #8 2024-01-23 10:40:41 +08:00
JerryXiao a5a2ba0d82
mesa quirk finally fixed 2024-01-23 10:40:35 +08:00
7 changed files with 34 additions and 75 deletions

21
.drone.yml Normal file
View file

@ -0,0 +1,21 @@
kind: pipeline
type: docker
name: default
steps:
- name: build
image: archlinux:latest
commands:
- pacman -Syu --noconfirm --needed base-devel libvncserver libxkbcommon libdrm libva git cmake clang
- export CFLAGS="-pipe -fno-plt -fexceptions -fstack-clash-protection -fcf-protection -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security"
- CC=gcc cmake -B gcc-out
- cmake --build gcc-out
- CC=clang cmake -B clang-out
- cmake --build clang-out
trigger:
branch:
- dev
event:
exclude:
- pull_request

View file

@ -1,27 +0,0 @@
name: Build with gcc + clang
on:
push:
branches: [dev]
jobs:
build:
if: "github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]')"
runs-on: docker
container:
image: archlinux:latest
env:
CFLAGS: "-pipe -fno-plt -fexceptions -fstack-clash-protection -fcf-protection -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security"
steps:
- name: Prepare dependencies
run: |
pacman -Syu --noconfirm --needed nodejs git \
base-devel libvncserver libxkbcommon libdrm libva cmake clang
- name: Check out repository code
uses: actions/checkout@v4
- name: Build with gcc
run: |
CC=gcc cmake -B gcc-out
cmake --build gcc-out
- name: Build with clang
run: |
CC=clang cmake -B clang-out
cmake --build clang-out

View file

@ -23,22 +23,12 @@ IF(NOT HAVE_LINUX_API_HEADERS)
ENDIF()
include(CheckSymbolExists)
check_symbol_exists(SYS_pidfd_getfd "sys/syscall.h" HAVE_LIBC_SYS_pidfd_getfd)
IF(NOT HAVE_LIBC_SYS_pidfd_getfd)
check_symbol_exists(SYS_pidfd_getfd "sys/syscall.h" HAVE_PIDFD_GETFD_SYSCALL)
IF(NOT HAVE_PIDFD_GETFD_SYSCALL)
message(WARNING "pidfd_getfd syscall not found, the --screen-blank options will be disabled")
target_compile_options(kmsvnc PUBLIC -DDISABLE_KMSVNC_SCREEN_BLANK)
list(REMOVE_ITEM kmsvnc_SOURCES drm_master.c)
ENDIF()
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES ${LIBDRM_INCLUDEDIR}/libdrm) # can't do anything about that
set(CMAKE_REQUIRED_LIBRARIES ${LIBDRM_LIBRARIES})
check_symbol_exists(drmGetFormatName "xf86drm.h" HAVE_LIBDRM_drmGetFormatName)
cmake_pop_check_state()
IF(NOT HAVE_LIBDRM_drmGetFormatName)
message(WARNING "drmGetFormatName not found, format name printing will be disabled")
target_compile_options(kmsvnc PUBLIC -DDISABLE_KMSVNC_drmGetFormatName)
ENDIF()
target_sources(kmsvnc PUBLIC
@ -46,12 +36,18 @@ target_sources(kmsvnc PUBLIC
)
target_include_directories(kmsvnc PUBLIC
${LIBDRM_INCLUDEDIR}
${LIBDRM_INCLUDEDIR}/libdrm
${LIBVNCSERVER_INCLUDEDIR}
${XKBCOMMON_INCLUDEDIR}
${LIBVA_INCLUDEDIR}
${LIBVA_DRM_INCLUDEDIR}
)
target_compile_options(kmsvnc PUBLIC
${LIBDRM_CFLAGS}
${LIBVNCSERVER_CFLAGS}
${XKBCOMMON_CFLAGS}
${LIBVA_CFLAGS}
${LIBVA_DRM_CFLAGS}
)
target_link_libraries(kmsvnc PUBLIC
m
${LIBDRM_LIBRARIES}

10
drm.c
View file

@ -19,16 +19,6 @@
#define fourcc_mod_is_vendor(modifier, vendor) \
(fourcc_mod_get_vendor(modifier) == DRM_FORMAT_MOD_VENDOR_## vendor)
#endif
#ifdef DISABLE_KMSVNC_drmGetFormatName
static char* drmGetFormatName(uint32_t data) {
char *name = "missing drmGetFormatName";
char *out = malloc(strlen(name)+1);
if (out) {
memcpy(out, name, strlen(name)+1);
}
return out;
}
#endif
extern struct kmsvnc_data *kmsvnc;

View file

@ -6,7 +6,6 @@
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <argp.h>
#include <arpa/inet.h>
@ -223,7 +222,7 @@ void signal_handler(int signum){
}
static struct argp_option kmsvnc_main_options[] = {
{"device", 'd', "/dev/dri/cardX", 0, "DRM device"},
{"device", 'd', "/dev/dri/card0", 0, "DRM device"},
{"source-plane", 0xfefc, "0", 0, "Use specific plane"},
{"source-crtc", 0xfefd, "0", 0, "Use specific crtc (to list all crtcs and planes, set this to -1)"},
{"force-driver", 0xfefe, "i915", 0, "force a certain driver (for debugging)"},
@ -246,7 +245,6 @@ static struct argp_option kmsvnc_main_options[] = {
{"screen-blank", 0xff0a, 0, OPTION_ARG_OPTIONAL, "Blank screen with gamma set on crtc"},
{"screen-blank-restore-linear", 0xff0b, 0, OPTION_ARG_OPTIONAL, "Restore linear values on exit in case of messed up gamma"},
#endif
{"va-byteorder-swap", 0xff0c, 0, OPTION_ARG_OPTIONAL, "Force swap vaapi image rgb byteorder"},
{"wakeup", 'w', 0, OPTION_ARG_OPTIONAL, "Move mouse to wake the system up before start"},
{"disable-input", 'i', 0, OPTION_ARG_OPTIONAL, "Disable uinput"},
{"desktop-name", 'n', "kmsvnc", 0, "Specify vnc desktop name"},
@ -364,9 +362,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case 0xff0b:
kmsvnc->screen_blank_restore = 1;
break;
case 0xff0c:
kmsvnc->va_byteorder_swap = 1;
break;
case 'w':
kmsvnc->input_wakeup = 1;
break;
@ -399,10 +394,7 @@ int main(int argc, char **argv)
kmsvnc->vnc_opt = vncopt;
#define DEVICE_EXAMPLE_MAX_SIZE 15
#define DEVICE_EXAMPLE_FALLBACK "/dev/dri/card0"
static char device_example[DEVICE_EXAMPLE_MAX_SIZE] = DEVICE_EXAMPLE_FALLBACK;
kmsvnc->card = device_example;
kmsvnc->card = "/dev/dri/card0";
kmsvnc->va_derive_enabled = -1;
kmsvnc->vnc_opt->bind = &(struct in_addr){0};
kmsvnc->vnc_opt->always_shared = 1;
@ -416,18 +408,6 @@ int main(int argc, char **argv)
struct argp argp = {kmsvnc_main_options, parse_opt, args_doc, doc};
argp_parse(&argp, argc, argv, 0, 0, NULL);
if (kmsvnc->card == device_example) {
for (int i = 0; i < 10; i++) {
snprintf(kmsvnc->card, DEVICE_EXAMPLE_MAX_SIZE, "/dev/dri/card%d", i);
if (!access(kmsvnc->card, F_OK)) {
break;
}
else {
snprintf(kmsvnc->card, DEVICE_EXAMPLE_MAX_SIZE, DEVICE_EXAMPLE_FALLBACK);
}
}
}
if (!kmsvnc->disable_input) {
const char* XKB_DEFAULT_LAYOUT = getenv("XKB_DEFAULT_LAYOUT");
if (!XKB_DEFAULT_LAYOUT || strcmp(XKB_DEFAULT_LAYOUT, "") == 0) {

View file

@ -45,7 +45,6 @@ struct kmsvnc_data
int input_offy;
char screen_blank;
char screen_blank_restore;
char va_byteorder_swap;
struct kmsvnc_drm_data *drm;
struct kmsvnc_input_data *input;
struct kmsvnc_keymap_data *keymap;

4
va.c
View file

@ -89,8 +89,8 @@ struct va_fmt_data {
static VAImageFormat* vaImgFmt_apply_quirks(struct va_fmt_data* data) {
static VAImageFormat ret = {0};
memcpy(&ret, data->fmt, sizeof(VAImageFormat));
if ((kmsvnc->va_byteorder_swap ^ !strncmp(kmsvnc->va->vendor_string, "Mesa", 4)) && data->depth != 30) {
printf("applying rgb mask byte order swap\n");
if (!strncmp(kmsvnc->va->vendor_string, "Mesa", 4) && data->depth != 30) {
printf("applying mesa quirk\n");
ret.blue_mask = __builtin_bswap32(data->fmt->blue_mask);
ret.green_mask = __builtin_bswap32(data->fmt->green_mask);
ret.red_mask = __builtin_bswap32(data->fmt->red_mask);