winex11.drv: Use gdi driver types for display device handler.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-11-30 13:26:29 +01:00 committed by Alexandre Julliard
parent 8278bdcbec
commit b502a3e3c6
5 changed files with 62 additions and 102 deletions

View File

@ -204,10 +204,10 @@ static void query_desktop_work_area( RECT *rc_work )
TRACE( "found tray %p %s work area %s\n", hwnd, wine_dbgstr_rect( &rect ), wine_dbgstr_rect( rc_work ) );
}
static BOOL X11DRV_desktop_get_gpus( struct x11drv_gpu **new_gpus, int *count )
static BOOL X11DRV_desktop_get_gpus( struct gdi_gpu **new_gpus, int *count )
{
static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0};
struct x11drv_gpu *gpu;
struct gdi_gpu *gpu;
gpu = heap_calloc( 1, sizeof(*gpu) );
if (!gpu) return FALSE;
@ -223,15 +223,15 @@ static BOOL X11DRV_desktop_get_gpus( struct x11drv_gpu **new_gpus, int *count )
return TRUE;
}
static void X11DRV_desktop_free_gpus( struct x11drv_gpu *gpus )
static void X11DRV_desktop_free_gpus( struct gdi_gpu *gpus )
{
heap_free( gpus );
}
/* TODO: Support multi-head virtual desktop */
static BOOL X11DRV_desktop_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new_adapters, int *count )
static BOOL X11DRV_desktop_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_adapters, int *count )
{
struct x11drv_adapter *adapter;
struct gdi_adapter *adapter;
adapter = heap_calloc( 1, sizeof(*adapter) );
if (!adapter) return FALSE;
@ -245,17 +245,17 @@ static BOOL X11DRV_desktop_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter
return TRUE;
}
static void X11DRV_desktop_free_adapters( struct x11drv_adapter *adapters )
static void X11DRV_desktop_free_adapters( struct gdi_adapter *adapters )
{
heap_free( adapters );
}
static BOOL X11DRV_desktop_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor **new_monitors, int *count )
static BOOL X11DRV_desktop_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **new_monitors, int *count )
{
static const WCHAR generic_nonpnp_monitorW[] = {
'G','e','n','e','r','i','c',' ',
'N','o','n','-','P','n','P',' ','M','o','n','i','t','o','r',0};
struct x11drv_monitor *monitor;
struct gdi_monitor *monitor;
monitor = heap_calloc( 1, sizeof(*monitor) );
if (!monitor) return FALSE;
@ -275,7 +275,7 @@ static BOOL X11DRV_desktop_get_monitors( ULONG_PTR adapter_id, struct x11drv_mon
return TRUE;
}
static void X11DRV_desktop_free_monitors( struct x11drv_monitor *monitors, int count )
static void X11DRV_desktop_free_monitors( struct gdi_monitor *monitors, int count )
{
heap_free( monitors );
}

View File

@ -247,9 +247,9 @@ RECT get_primary_monitor_rect(void)
RECT get_host_primary_monitor_rect(void)
{
INT gpu_count, adapter_count, monitor_count;
struct x11drv_gpu *gpus = NULL;
struct x11drv_adapter *adapters = NULL;
struct x11drv_monitor *monitors = NULL;
struct gdi_gpu *gpus = NULL;
struct gdi_adapter *adapters = NULL;
struct gdi_monitor *monitors = NULL;
RECT rect = {0};
/* The first monitor is always primary */
@ -264,9 +264,9 @@ RECT get_host_primary_monitor_rect(void)
return rect;
}
BOOL get_host_primary_gpu(struct x11drv_gpu *gpu)
BOOL get_host_primary_gpu(struct gdi_gpu *gpu)
{
struct x11drv_gpu *gpus;
struct gdi_gpu *gpus;
INT gpu_count;
if (host_handler.get_gpus(&gpus, &gpu_count) && gpu_count)
@ -459,7 +459,7 @@ static BOOL link_device(const WCHAR *instance, const GUID *guid)
/* Initialize a GPU instance.
* Return its GUID string in guid_string, driver value in driver parameter and LUID in gpu_luid */
static BOOL X11DRV_InitGpu(HDEVINFO devinfo, const struct x11drv_gpu *gpu, INT gpu_index, WCHAR *guid_string,
static BOOL X11DRV_InitGpu(HDEVINFO devinfo, const struct gdi_gpu *gpu, INT gpu_index, WCHAR *guid_string,
WCHAR *driver, LUID *gpu_luid)
{
static const WCHAR adapter_stringW[] = {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.','A','d','a','p','t','e','r','S','t','r','i','n','g',0};
@ -598,8 +598,8 @@ done:
}
static BOOL X11DRV_InitAdapter(HKEY video_hkey, INT video_index, INT gpu_index, INT adapter_index, INT monitor_count,
const struct x11drv_gpu *gpu, const WCHAR *guid_string,
const WCHAR *gpu_driver, const struct x11drv_adapter *adapter)
const struct gdi_gpu *gpu, const WCHAR *guid_string,
const WCHAR *gpu_driver, const struct gdi_adapter *adapter)
{
WCHAR adapter_keyW[MAX_PATH];
WCHAR key_nameW[MAX_PATH];
@ -664,7 +664,7 @@ done:
return ret;
}
static BOOL X11DRV_InitMonitor(HDEVINFO devinfo, const struct x11drv_monitor *monitor, int monitor_index,
static BOOL X11DRV_InitMonitor(HDEVINFO devinfo, const struct gdi_monitor *monitor, int monitor_index,
int video_index, const LUID *gpu_luid, UINT output_id)
{
SP_DEVINFO_DATA device_data = {sizeof(SP_DEVINFO_DATA)};
@ -798,9 +798,9 @@ void X11DRV_DisplayDevices_Init(BOOL force)
{
HANDLE mutex;
struct x11drv_display_device_handler *handler = is_virtual_desktop() ? &desktop_handler : &host_handler;
struct x11drv_gpu *gpus = NULL;
struct x11drv_adapter *adapters = NULL;
struct x11drv_monitor *monitors = NULL;
struct gdi_gpu *gpus = NULL;
struct gdi_adapter *adapters = NULL;
struct gdi_monitor *monitors = NULL;
INT gpu_count, adapter_count, monitor_count;
INT gpu, adapter, monitor;
HDEVINFO gpu_devinfo = NULL, monitor_devinfo = NULL;

View File

@ -770,47 +770,6 @@ void init_user_driver(void) DECLSPEC_HIDDEN;
/* X11 display device handler. Used to initialize display device registry data */
/* Represent a physical GPU in the PCI slots */
struct x11drv_gpu
{
/* ID to uniquely identify a GPU in handler */
ULONG_PTR id;
/* Name */
WCHAR name[128];
/* PCI ID */
UINT vendor_id;
UINT device_id;
UINT subsys_id;
UINT revision_id;
/* Vulkan device UUID */
GUID vulkan_uuid;
};
/* Represent an adapter in EnumDisplayDevices context */
struct x11drv_adapter
{
/* ID to uniquely identify an adapter in handler */
ULONG_PTR id;
/* as StateFlags in DISPLAY_DEVICE struct */
DWORD state_flags;
};
/* Represent a monitor in EnumDisplayDevices context */
struct x11drv_monitor
{
/* Name */
WCHAR name[128];
/* RcMonitor in MONITORINFO struct */
RECT rc_monitor;
/* RcWork in MONITORINFO struct */
RECT rc_work;
/* StateFlags in DISPLAY_DEVICE struct */
DWORD state_flags;
/* Extended Device Identification Data */
unsigned long edid_len;
unsigned char *edid;
};
/* Required functions for display device registry initialization */
struct x11drv_display_device_handler
{
@ -823,28 +782,28 @@ struct x11drv_display_device_handler
/* get_gpus will be called to get a list of GPUs. First GPU has to be where the primary adapter is.
*
* Return FALSE on failure with parameters unchanged */
BOOL (*get_gpus)(struct x11drv_gpu **gpus, int *count);
BOOL (*get_gpus)(struct gdi_gpu **gpus, int *count);
/* get_adapters will be called to get a list of adapters in EnumDisplayDevices context under a GPU.
* The first adapter has to be primary if GPU is primary.
*
* Return FALSE on failure with parameters unchanged */
BOOL (*get_adapters)(ULONG_PTR gpu_id, struct x11drv_adapter **adapters, int *count);
BOOL (*get_adapters)(ULONG_PTR gpu_id, struct gdi_adapter **adapters, int *count);
/* get_monitors will be called to get a list of monitors in EnumDisplayDevices context under an adapter.
* The first monitor has to be primary if adapter is primary.
*
* Return FALSE on failure with parameters unchanged */
BOOL (*get_monitors)(ULONG_PTR adapter_id, struct x11drv_monitor **monitors, int *count);
BOOL (*get_monitors)(ULONG_PTR adapter_id, struct gdi_monitor **monitors, int *count);
/* free_gpus will be called to free a GPU list from get_gpus */
void (*free_gpus)(struct x11drv_gpu *gpus);
void (*free_gpus)(struct gdi_gpu *gpus);
/* free_adapters will be called to free an adapter list from get_adapters */
void (*free_adapters)(struct x11drv_adapter *adapters);
void (*free_adapters)(struct gdi_adapter *adapters);
/* free_monitors will be called to free a monitor list from get_monitors */
void (*free_monitors)(struct x11drv_monitor *monitors, int count);
void (*free_monitors)(struct gdi_monitor *monitors, int count);
/* register_event_handlers will be called to register event handlers.
* This function pointer is optional and can be NULL when driver doesn't support it */
@ -852,7 +811,7 @@ struct x11drv_display_device_handler
};
extern HANDLE get_display_device_init_mutex(void) DECLSPEC_HIDDEN;
extern BOOL get_host_primary_gpu(struct x11drv_gpu *gpu) DECLSPEC_HIDDEN;
extern BOOL get_host_primary_gpu(struct gdi_gpu *gpu) DECLSPEC_HIDDEN;
extern void release_display_device_init_mutex(HANDLE) DECLSPEC_HIDDEN;
extern void X11DRV_DisplayDevices_SetHandler(const struct x11drv_display_device_handler *handler) DECLSPEC_HIDDEN;
extern void X11DRV_DisplayDevices_Init(BOOL force) DECLSPEC_HIDDEN;

View File

@ -120,10 +120,10 @@ static inline int query_screens(void)
#endif /* SONAME_LIBXINERAMA */
static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count )
static BOOL xinerama_get_gpus( struct gdi_gpu **new_gpus, int *count )
{
static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0};
struct x11drv_gpu *gpus;
struct gdi_gpu *gpus;
/* Xinerama has no support for GPU, faking one */
gpus = heap_calloc( 1, sizeof(*gpus) );
@ -138,14 +138,14 @@ static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count )
return TRUE;
}
static void xinerama_free_gpus( struct x11drv_gpu *gpus )
static void xinerama_free_gpus( struct gdi_gpu *gpus )
{
heap_free( gpus );
}
static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new_adapters, int *count )
static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_adapters, int *count )
{
struct x11drv_adapter *adapters = NULL;
struct gdi_adapter *adapters = NULL;
INT index = 0;
INT i, j;
INT primary_index;
@ -194,7 +194,7 @@ static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new
/* Primary adapter has to be first */
if (primary_index)
{
struct x11drv_adapter tmp;
struct gdi_adapter tmp;
tmp = adapters[primary_index];
adapters[primary_index] = adapters[0];
adapters[0] = tmp;
@ -205,17 +205,17 @@ static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new
return TRUE;
}
static void xinerama_free_adapters( struct x11drv_adapter *adapters )
static void xinerama_free_adapters( struct gdi_adapter *adapters )
{
heap_free( adapters );
}
static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor **new_monitors, int *count )
static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **new_monitors, int *count )
{
static const WCHAR generic_nonpnp_monitorW[] = {
'G','e','n','e','r','i','c',' ',
'N','o','n','-','P','n','P',' ','M','o','n','i','t','o','r',0};
struct x11drv_monitor *monitor;
struct gdi_monitor *monitor;
INT first = (INT)adapter_id;
INT monitor_count = 0;
INT index = 0;
@ -258,7 +258,7 @@ static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor *
return TRUE;
}
static void xinerama_free_monitors( struct x11drv_monitor *monitors, int count )
static void xinerama_free_monitors( struct gdi_monitor *monitors, int count )
{
heap_free( monitors );
}

View File

@ -468,22 +468,23 @@ static void get_screen_size( XRRScreenResources *resources, unsigned int *width,
}
}
static void get_edid( RROutput output, unsigned char **prop, unsigned long *len )
static unsigned int get_edid( RROutput output, unsigned char **prop )
{
int result, actual_format;
unsigned long bytes_after;
unsigned long bytes_after, len;
Atom actual_type;
result = pXRRGetOutputProperty( gdi_display, output, x11drv_atom(EDID), 0, 128, FALSE, FALSE,
AnyPropertyType, &actual_type, &actual_format, len,
AnyPropertyType, &actual_type, &actual_format, &len,
&bytes_after, prop );
if (result != Success)
{
WARN("Could not retrieve EDID property for output %#lx.\n", output);
*prop = NULL;
*len = 0;
return 0;
}
return len;
}
static void set_screen_size( int width, int height )
@ -637,7 +638,7 @@ static BOOL is_crtc_primary( RECT primary, const XRRCrtcInfo *crtc )
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR)
static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRProviderInfo *provider_info )
static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProviderInfo *provider_info )
{
static const char *extensions[] =
{
@ -745,10 +746,10 @@ done:
/* Get a list of GPUs reported by XRandR 1.4. Set get_properties to FALSE if GPU properties are
* not needed to avoid unnecessary querying */
static BOOL xrandr14_get_gpus2( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties )
static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_properties )
{
static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0};
struct x11drv_gpu *gpus = NULL;
struct gdi_gpu *gpus = NULL;
XRRScreenResources *screen_resources = NULL;
XRRProviderResources *provider_resources = NULL;
XRRProviderInfo *provider_info = NULL;
@ -819,7 +820,7 @@ static BOOL xrandr14_get_gpus2( struct x11drv_gpu **new_gpus, int *count, BOOL g
/* Make primary GPU the first */
if (primary_provider > 0)
{
struct x11drv_gpu tmp = gpus[0];
struct gdi_gpu tmp = gpus[0];
gpus[0] = gpus[primary_provider];
gpus[primary_provider] = tmp;
}
@ -840,19 +841,19 @@ done:
return ret;
}
static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count )
static BOOL xrandr14_get_gpus( struct gdi_gpu **new_gpus, int *count )
{
return xrandr14_get_gpus2( new_gpus, count, TRUE );
}
static void xrandr14_free_gpus( struct x11drv_gpu *gpus )
static void xrandr14_free_gpus( struct gdi_gpu *gpus )
{
heap_free( gpus );
}
static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new_adapters, int *count )
static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_adapters, int *count )
{
struct x11drv_adapter *adapters = NULL;
struct gdi_adapter *adapters = NULL;
XRRScreenResources *screen_resources = NULL;
XRRProviderInfo *provider_info = NULL;
XRRCrtcInfo *enum_crtc_info, *crtc_info = NULL;
@ -986,7 +987,7 @@ static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new
/* Make primary adapter the first */
if (primary_adapter)
{
struct x11drv_adapter tmp = adapters[0];
struct gdi_adapter tmp = adapters[0];
adapters[0] = adapters[primary_adapter];
adapters[primary_adapter] = tmp;
}
@ -1011,17 +1012,17 @@ done:
return ret;
}
static void xrandr14_free_adapters( struct x11drv_adapter *adapters )
static void xrandr14_free_adapters( struct gdi_adapter *adapters )
{
heap_free( adapters );
}
static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor **new_monitors, int *count )
static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **new_monitors, int *count )
{
static const WCHAR generic_nonpnp_monitorW[] = {
'G','e','n','e','r','i','c',' ',
'N','o','n','-','P','n','P',' ','M','o','n','i','t','o','r',0};
struct x11drv_monitor *realloc_monitors, *monitors = NULL;
struct gdi_monitor *realloc_monitors, *monitors = NULL;
XRRScreenResources *screen_resources = NULL;
XRROutputInfo *output_info = NULL, *enum_output_info = NULL;
XRRCrtcInfo *crtc_info = NULL, *enum_crtc_info;
@ -1056,7 +1057,7 @@ static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor *
{
lstrcpyW( monitors[monitor_count].name, generic_nonpnp_monitorW );
monitors[monitor_count].state_flags = DISPLAY_DEVICE_ATTACHED;
get_edid( adapter_id, &monitors[monitor_count].edid, &monitors[monitor_count].edid_len );
monitors[monitor_count].edid_len = get_edid( adapter_id, &monitors[monitor_count].edid );
monitor_count = 1;
}
/* Active monitors, need to find other monitors with the same coordinates as mirrored */
@ -1113,8 +1114,8 @@ static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor *
if (is_crtc_primary( primary_rect, crtc_info ))
primary_index = monitor_count;
get_edid( screen_resources->outputs[i], &monitors[monitor_count].edid,
&monitors[monitor_count].edid_len );
monitors[monitor_count].edid_len = get_edid( screen_resources->outputs[i],
&monitors[monitor_count].edid );
monitor_count++;
}
@ -1128,7 +1129,7 @@ static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor *
/* Make sure the first monitor is the primary */
if (primary_index)
{
struct x11drv_monitor tmp = monitors[0];
struct gdi_monitor tmp = monitors[0];
monitors[0] = monitors[primary_index];
monitors[primary_index] = tmp;
}
@ -1166,7 +1167,7 @@ done:
return ret;
}
static void xrandr14_free_monitors( struct x11drv_monitor *monitors, int count )
static void xrandr14_free_monitors( struct gdi_monitor *monitors, int count )
{
int i;
@ -1217,8 +1218,8 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, ULONG_PTR *id )
struct current_mode *tmp_modes, *new_current_modes = NULL;
INT gpu_count, adapter_count, new_current_mode_count = 0;
INT gpu_idx, adapter_idx, display_idx;
struct x11drv_adapter *adapters;
struct x11drv_gpu *gpus;
struct gdi_adapter *adapters;
struct gdi_gpu *gpus;
WCHAR *end;
/* Parse \\.\DISPLAY%d */