From 2a898cbaf135aa6660389908b42cc74b20aaf5b3 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Tue, 27 Jan 2026 05:27:14 +0200 Subject: [PATCH] kdrive: Pull ephyr/ephyr_glamor_xv.c into src/ and make generic Signed-off-by: stefan11111 --- hw/kdrive/ephyr/ephyr.c | 4 +- hw/kdrive/ephyr/hostx.c | 12 +++ hw/kdrive/ephyr/meson.build | 3 - .../ephyr_glamor_xv.c => src/kd_glamor_xv.c} | 89 ++++++++++--------- hw/kdrive/src/kxv.h | 5 ++ hw/kdrive/src/meson.build | 3 + 6 files changed, 67 insertions(+), 49 deletions(-) rename hw/kdrive/{ephyr/ephyr_glamor_xv.c => src/kd_glamor_xv.c} (59%) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 96cd57a2a..b1379500e 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -782,9 +782,7 @@ ephyrInitScreen(ScreenPtr pScreen) #ifdef XV if (!ephyrNoXV) { - if (ephyr_glamor) - ephyr_glamor_xv_init(pScreen); - else if (!ephyrInitVideo(pScreen)) { + if (!ephyr_glamor && !ephyrInitVideo(pScreen)) { EPHYR_LOG_ERROR("failed to initialize xvideo\n"); } else { diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index eace4c4b6..0c1a6213e 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -70,6 +70,11 @@ #include "glamor_glx_provider.h" #include "ephyr_glamor.h" #include "glamor/glamor_priv.h" + +#ifdef XV +#include "kxv.h" +#endif + #endif #include "ephyrlog.h" #include "ephyr.h" @@ -110,6 +115,7 @@ char *ephyrResName = NULL; int ephyrResNameFromCmd = 0; char *ephyrTitle = NULL; Bool ephyr_glamor = FALSE; +extern Bool ephyrNoXV; extern Bool ephyr_glamor_skip_present; Bool @@ -1631,6 +1637,12 @@ ephyr_glamor_init(ScreenPtr screen) GlxPushProvider(&glamor_provider); +#ifdef XV + if (!ephyrNoXV) { + kd_glamor_xv_init(screen); + } +#endif /*XV*/ + return TRUE; } diff --git a/hw/kdrive/ephyr/meson.build b/hw/kdrive/ephyr/meson.build index 42ec9dab2..d66745ae3 100644 --- a/hw/kdrive/ephyr/meson.build +++ b/hw/kdrive/ephyr/meson.build @@ -25,9 +25,6 @@ xephyr_dep = [ xephyr_glamor = [] if build_glamor srcs += 'ephyr_glamor.c' - if build_xv - srcs += 'ephyr_glamor_xv.c' - endif xephyr_glamor += glamor xephyr_dep += epoxy_dep xephyr_dep += dependency('xcb-glx') diff --git a/hw/kdrive/ephyr/ephyr_glamor_xv.c b/hw/kdrive/src/kd_glamor_xv.c similarity index 59% rename from hw/kdrive/ephyr/ephyr_glamor_xv.c rename to hw/kdrive/src/kd_glamor_xv.c index 301b05ef5..a3e1f251b 100644 --- a/hw/kdrive/ephyr/ephyr_glamor_xv.c +++ b/hw/kdrive/src/kd_glamor_xv.c @@ -25,20 +25,19 @@ #include "kdrive.h" #include "kxv.h" -#include "ephyr.h" #include "glamor_priv.h" #include #include "fourcc.h" -#define NUM_FORMATS 3 +#define NUM_FORMATS 4 static KdVideoFormatRec Formats[NUM_FORMATS] = { - {15, TrueColor}, {16, TrueColor}, {24, TrueColor} + {15, TrueColor}, {16, TrueColor}, {24, TrueColor}, {30, TrueColor} }; static void -ephyr_glamor_xv_stop_video(KdScreenInfo *screen, void *data, Bool cleanup) +kd_glamor_xv_stop_video(KdScreenInfo *screen, void *data, Bool cleanup) { if (!cleanup) return; @@ -47,53 +46,53 @@ ephyr_glamor_xv_stop_video(KdScreenInfo *screen, void *data, Bool cleanup) } static int -ephyr_glamor_xv_set_port_attribute(KdScreenInfo *screen, - Atom attribute, int value, void *data) +kd_glamor_xv_set_port_attribute(KdScreenInfo *screen, + Atom attribute, int value, void *data) { return glamor_xv_set_port_attribute(data, attribute, (INT32)value); } static int -ephyr_glamor_xv_get_port_attribute(KdScreenInfo *screen, - Atom attribute, int *value, void *data) +kd_glamor_xv_get_port_attribute(KdScreenInfo *screen, + Atom attribute, int *value, void *data) { return glamor_xv_get_port_attribute(data, attribute, (INT32 *)value); } static void -ephyr_glamor_xv_query_best_size(KdScreenInfo *screen, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, - void *data) +kd_glamor_xv_query_best_size(KdScreenInfo *screen, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + void *data) { *p_w = drw_w; *p_h = drw_h; } static int -ephyr_glamor_xv_query_image_attributes(KdScreenInfo *screen, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets) +kd_glamor_xv_query_image_attributes(KdScreenInfo *screen, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets) { return glamor_xv_query_image_attributes(id, w, h, pitches, offsets); } static int -ephyr_glamor_xv_put_image(KdScreenInfo *screen, - DrawablePtr pDrawable, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, - int id, - unsigned char *buf, - short width, - short height, - Bool sync, - RegionPtr clipBoxes, void *data) +kd_glamor_xv_put_image(KdScreenInfo *screen, + DrawablePtr pDrawable, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, + unsigned char *buf, + short width, + short height, + Bool sync, + RegionPtr clipBoxes, void *data) { return glamor_xv_put_image(data, pDrawable, src_x, src_y, @@ -104,26 +103,30 @@ ephyr_glamor_xv_put_image(KdScreenInfo *screen, } void -ephyr_glamor_xv_init(ScreenPtr screen) +kd_glamor_xv_init(ScreenPtr screen) { KdVideoAdaptorRec *adaptor; glamor_port_private *port_privates; + int i; + GLint max_size = 0; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); + if (max_size <= 0) { + /* from glamor_xf86_xv.c */ + max_size = 8192; + } + KdVideoEncodingRec encoding = { 0, "XV_IMAGE", - /* These sizes should probably be GL_MAX_TEXTURE_SIZE instead - * of 2048, but our context isn't set up yet. - */ - 2048, 2048, + max_size, max_size, {1, 1} }; - int i; glamor_xv_core_init(screen); adaptor = XNFcallocarray(1, sizeof(*adaptor)); - adaptor->name = "glamor textured video"; + adaptor->name = "GLAMOR Textured Video"; adaptor->type = XvWindowMask | XvInputMask | XvImageMask; adaptor->flags = 0; adaptor->nEncodings = 1; @@ -148,12 +151,12 @@ ephyr_glamor_xv_init(ScreenPtr screen) adaptor->pImages = glamor_xv_images; adaptor->nImages = glamor_xv_num_images; - adaptor->StopVideo = ephyr_glamor_xv_stop_video; - adaptor->SetPortAttribute = ephyr_glamor_xv_set_port_attribute; - adaptor->GetPortAttribute = ephyr_glamor_xv_get_port_attribute; - adaptor->QueryBestSize = ephyr_glamor_xv_query_best_size; - adaptor->PutImage = ephyr_glamor_xv_put_image; - adaptor->QueryImageAttributes = ephyr_glamor_xv_query_image_attributes; + adaptor->StopVideo = kd_glamor_xv_stop_video; + adaptor->SetPortAttribute = kd_glamor_xv_set_port_attribute; + adaptor->GetPortAttribute = kd_glamor_xv_get_port_attribute; + adaptor->QueryBestSize = kd_glamor_xv_query_best_size; + adaptor->PutImage = kd_glamor_xv_put_image; + adaptor->QueryImageAttributes = kd_glamor_xv_query_image_attributes; KdXVScreenInit(screen, adaptor, 1); } diff --git a/hw/kdrive/src/kxv.h b/hw/kdrive/src/kxv.h index 7f01bb16e..221bd84ad 100644 --- a/hw/kdrive/src/kxv.h +++ b/hw/kdrive/src/kxv.h @@ -192,4 +192,9 @@ typedef struct _KdXVWindowRec { struct _KdXVWindowRec *next; } KdXVWindowRec, *KdXVWindowPtr; +#ifdef GLAMOR +/* Must not be called before glamor is fully initialized */ +void kd_glamor_xv_init(ScreenPtr screen); +#endif + #endif /* _XVDIX_H_ */ diff --git a/hw/kdrive/src/meson.build b/hw/kdrive/src/meson.build index 39b406b1e..554502a5d 100644 --- a/hw/kdrive/src/meson.build +++ b/hw/kdrive/src/meson.build @@ -11,6 +11,9 @@ srcs_kdrive = [ if build_xv srcs_kdrive += 'kxv.c' + if build_glamor + srcs_kdrive += 'kd_glamor_xv.c' + endif endif kdrive_data = configuration_data()