kmsvnc/kmsvnc.h

148 lines
3.1 KiB
C
Raw Permalink Normal View History

2023-04-27 19:35:18 +08:00
#pragma once
#include <rfb/rfb.h>
#include <xkbcommon/xkbcommon.h>
#include <xf86drm.h>
#include <i915_drm.h>
#include <amdgpu_drm.h>
#include <xf86drmMode.h>
#include <linux/dma-buf.h>
2023-04-29 02:05:13 +08:00
#include <va/va.h>
2023-04-27 19:35:18 +08:00
#define BYTES_PER_PIXEL 4
2023-07-16 01:34:58 +08:00
#define CURSOR_FRAMESKIP 15
2023-04-27 19:35:18 +08:00
struct vnc_opt
{
int port;
struct in_addr *bind;
char *bind6;
char disable_ipv6;
int sleep_ns;
2023-04-28 14:13:46 +08:00
char always_shared;
char disable_cmpfb;
2023-04-27 19:35:18 +08:00
char *desktop_name;
};
struct kmsvnc_data
{
2023-04-28 14:13:46 +08:00
char *debug_capture_fb;
2023-04-27 19:35:18 +08:00
char *card;
char *force_driver;
struct vnc_opt *vnc_opt;
char input_wakeup;
2023-04-27 19:35:18 +08:00
char disable_input;
2023-04-29 15:17:06 +08:00
int va_derive_enabled;
2023-07-16 01:34:58 +08:00
char debug_enabled;
2023-04-28 14:13:46 +08:00
int source_plane;
int source_crtc;
2023-07-15 10:38:48 +08:00
int input_width;
int input_height;
int input_offx;
int input_offy;
2023-08-11 00:25:26 +08:00
char screen_blank;
char screen_blank_restore;
2023-04-27 19:35:18 +08:00
struct kmsvnc_drm_data *drm;
struct kmsvnc_input_data *input;
struct kmsvnc_keymap_data *keymap;
2023-04-29 02:05:13 +08:00
struct kmsvnc_va_data *va;
2023-04-27 19:35:18 +08:00
rfbScreenInfoPtr server;
char shutdown;
2023-07-16 01:34:58 +08:00
char capture_cursor;
char *cursor_bitmap;
int cursor_bitmap_len;
2023-04-27 19:35:18 +08:00
char *buf;
char *buf1;
};
struct key_iter_search
{
xkb_keysym_t keysym;
xkb_keycode_t keycode;
xkb_level_index_t level;
};
struct kmsvnc_keymap_data
{
struct xkb_context *ctx;
struct xkb_keymap *map;
};
struct kmsvnc_input_data {
int uinput_fd;
char *keystate;
};
struct kmsvnc_drm_funcs
{
void (*sync_start)(int);
void (*sync_end)(int);
void (*convert)(const char *, int, int, char *);
};
2023-08-11 00:25:26 +08:00
struct kmsvnc_drm_gamma_data
{
uint32_t size;
uint16_t *red;
uint16_t *green;
uint16_t *blue;
};
2023-04-27 19:35:18 +08:00
struct kmsvnc_drm_data
{
int drm_fd;
2023-08-11 00:25:26 +08:00
int drm_master_fd;
2023-04-27 19:35:18 +08:00
drmVersionPtr drm_ver;
int prime_fd;
drmModePlane *plane;
2023-07-16 01:34:58 +08:00
drmModePlane *cursor_plane;
2023-04-27 19:35:18 +08:00
drmModePlaneRes *plane_res;
2023-04-27 23:42:41 +08:00
drmModeFB2 *mfb;
2023-07-16 01:34:58 +08:00
drmModeFB2 *cursor_mfb;
2023-08-11 00:25:26 +08:00
uint32_t plane_id;
2023-04-27 19:35:18 +08:00
int mmap_fd;
size_t mmap_size;
off_t mmap_offset;
char *mapped;
2023-07-16 01:34:58 +08:00
char *cursor_mapped;
size_t cursor_mmap_size;
2023-04-29 15:17:06 +08:00
char skip_map;
2023-04-27 19:35:18 +08:00
struct kmsvnc_drm_funcs *funcs;
2023-04-29 02:05:13 +08:00
char *pixfmt_name;
char *mod_vendor;
char *mod_name;
2023-07-16 01:34:58 +08:00
char *kms_convert_buf;
size_t kms_convert_buf_len;
char *kms_cpy_tmp_buf;
size_t kms_cpy_tmp_buf_len;
char *kms_cursor_buf;
size_t kms_cursor_buf_len;
2023-08-11 00:25:26 +08:00
struct kmsvnc_drm_gamma_data *gamma;
2023-04-27 19:35:18 +08:00
};
2023-04-29 02:05:13 +08:00
struct kmsvnc_va_data
{
VADisplay dpy;
int render_node_fd;
VASurfaceID surface_id;
VAImage *image;
char *imgbuf;
2023-04-29 15:17:06 +08:00
char derive_enabled;
2023-05-07 17:57:53 +08:00
VAImageFormat* img_fmts;
int img_fmt_count;
2023-04-29 02:05:13 +08:00
};
#define KMSVNC_FATAL(...) do{ fprintf(stderr, __VA_ARGS__); return 1; } while(0)
#define KMSVNC_ARRAY_ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#define KMSVNC_FOURCC_TO_INT(a,b,c,d) (((a) << 0) + ((b) << 8) + ((c) << 16) + ((d) << 24))
2023-05-07 00:57:26 +08:00
#define KMSVNC_WRITE_MAY(fd,buf,count) do { ssize_t e = write((fd), (buf), (count)); if (e != (count)) fprintf(stderr, "should write %ld bytes, actually wrote %ld, on line %d\n", (count), e, __LINE__); } while (0)
2023-07-16 01:34:58 +08:00
#define KMSVNC_DEBUG(...) do{ if (kmsvnc->debug_enabled) fprintf(stdout, __VA_ARGS__); } while(0)