diff --git a/config/config.c b/config/config.c index 270631af8..d75f1f453 100644 --- a/config/config.c +++ b/config/config.c @@ -26,9 +26,11 @@ #include #include + +#include "config/hotplug_priv.h" + #include "os.h" #include "inputstr.h" -#include "hotplug.h" #include "config-backends.h" #include "systemd-logind.h" diff --git a/config/hotplug_priv.h b/config/hotplug_priv.h new file mode 100644 index 000000000..9a9dca645 --- /dev/null +++ b/config/hotplug_priv.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult + * Copyright © 2006-2007 Daniel Stone + */ +#ifndef _XSERVER_HOTPLUG_PRIV_H +#define _XSERVER_HOTPLUG_PRIV_H + +#include + +#include "hotplug.h" +#include "list.h" + +/* Bump this each time you add something to the struct + * so that drivers can easily tell what is available + */ +#define ODEV_ATTRIBUTES_VERSION 1 + +struct OdevAttributes { + /* path to kernel device node - Linux e.g. /dev/dri/card0 */ + char *path; + + /* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ + char *syspath; + + /* DRI-style bus id */ + char *busid; + + /* Server managed FD */ + int fd; + + /* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ + int major; + + /* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ + int minor; + + /* kernel driver name */ + char *driver; +}; + +/* Note starting with xserver 1.16 this function never fails */ +struct OdevAttributes * +config_odev_allocate_attributes(void); + +void +config_odev_free_attributes(struct OdevAttributes *attribs); + +typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs); +void config_odev_probe(config_odev_probe_proc_ptr probe_callback); + +#ifdef CONFIG_UDEV_KMS +void NewGPUDeviceRequest(struct OdevAttributes *attribs); +void DeleteGPUDeviceRequest(struct OdevAttributes *attribs); +#endif + +#define ServerIsNotSeat0() (SeatId && strcmp(SeatId, "seat0")) + +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor); + +#endif /* _XSERVER_HOTPLUG_PRIV_H */ diff --git a/config/udev.c b/config/udev.c index 19f887c7a..83226638d 100644 --- a/config/udev.c +++ b/config/udev.c @@ -29,9 +29,10 @@ #include #include +#include "config/hotplug_priv.h" + #include "input.h" #include "inputstr.h" -#include "hotplug.h" #include "config-backends.h" #include "os.h" #include "globals.h" diff --git a/dix/main.c b/dix/main.c index 5ed0411e0..0448cbabc 100644 --- a/dix/main.c +++ b/dix/main.c @@ -84,6 +84,7 @@ Equipment Corporation. #include #include +#include "config/hotplug_priv.h" #include "dix/callback_priv.h" #include "dix/cursor_priv.h" #include "dix/dix_priv.h" @@ -110,7 +111,6 @@ Equipment Corporation. #include "colormapst.h" #include "cursorstr.h" #include "servermd.h" -#include "hotplug.h" #include "dixfont.h" #include "extnsionst.h" #include "privates.h" diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 9144091a4..e2eb847d7 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -22,6 +22,7 @@ #include +#include "config/hotplug_priv.h" #include "dix/screenint_priv.h" #include "os/cmdline.h" #include "os/ddx_priv.h" @@ -50,10 +51,6 @@ #include #endif -#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) -#include -#endif - /* This stub can be safely removed once we can * split input and GPU parts in hotplug.h et al. */ #include diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 0248b8f12..22cc9a1cd 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -37,7 +37,9 @@ #include #include +#include "config/hotplug_priv.h" #include "dix/input_priv.h" +#include "os/cmdline.h" #include "xkbsrv.h" #include "XIstubs.h" /* even though we don't use stubs. cute, no? */ @@ -48,12 +50,6 @@ #include "inpututils.h" #include "optionstr.h" -#include "os/cmdline.h" - -#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) -#include -#endif - #define AtomFromName(x) MakeAtom(x, strlen(x), 1) struct KdConfigDevice { diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index ee8ce6364..5c4b01cb4 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -37,6 +37,9 @@ #include #include #include + +#include "config/hotplug_priv.h" + #include "os.h" #include "xf86.h" #include "xf86Priv.h" diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 2fceef001..b13c9a9d0 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -48,8 +48,11 @@ #include #include #include +#include +#include #include "config/dbus-core.h" +#include "config/hotplug_priv.h" #include "dix/input_priv.h" #include "dix/screenint_priv.h" #include "os/cmdline.h" @@ -72,8 +75,6 @@ #include "xf86cmap.h" #include "xorgVersion.h" #include "mipointer.h" -#include -#include #include "xf86Extensions.h" #include "xf86DDC.h" #include "xf86Xinput.h" @@ -97,7 +98,6 @@ #include #include #endif -#include void (*xf86OSPMClose) (void) = NULL; static Bool xorgHWOpenConsole = FALSE; diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index 1a4465cd3..2962c8b21 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -37,10 +37,10 @@ #include #include +#include "config/hotplug_priv.h" #include "dix/screenint_priv.h" #include "os.h" -#include "hotplug.h" #include "systemd-logind.h" #include "loaderProcs.h" diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h index 0e512d586..b9933f405 100644 --- a/hw/xfree86/common/xf86platformBus.h +++ b/hw/xfree86/common/xf86platformBus.h @@ -24,7 +24,6 @@ #ifndef XF86_PLATFORM_BUS_H #define XF86_PLATFORM_BUS_H -#include "hotplug.h" #include "xf86MatchDrivers.h" struct xf86_platform_device { diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index 1f5783362..d8c8e81c6 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -40,6 +40,7 @@ #include #include +#include "config/hotplug_priv.h" #include "dix/dix_priv.h" #include "xf86.h" diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index 5352edcd0..efe710b3c 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -33,6 +33,7 @@ #include #include "config/dbus-core.h" +#include "config/hotplug_priv.h" #include "os.h" #include "linux.h" diff --git a/hw/xfree86/os-support/shared/drm_platform.c b/hw/xfree86/os-support/shared/drm_platform.c index a404aadcc..f6291e44d 100644 --- a/hw/xfree86/os-support/shared/drm_platform.c +++ b/hw/xfree86/os-support/shared/drm_platform.c @@ -10,6 +10,8 @@ #include #include +#include "config/hotplug_priv.h" + /* Linux platform device support */ #include "xf86_OSproc.h" @@ -18,7 +20,6 @@ #include "xf86platformBus.h" #include "xf86Bus.h" -#include "hotplug.h" #include "systemd-logind.h" static Bool diff --git a/hw/xfree86/os-support/xf86_os_support.h b/hw/xfree86/os-support/xf86_os_support.h index a2fc99912..b9aebb0a2 100644 --- a/hw/xfree86/os-support/xf86_os_support.h +++ b/hw/xfree86/os-support/xf86_os_support.h @@ -53,6 +53,9 @@ void xf86OSInitVidMem(VidMemInfoPtr); #ifdef XSERVER_PLATFORM_BUS #include "hotplug.h" + +struct OdevAttributes; + void xf86PlatformDeviceProbe(struct OdevAttributes *attribs); diff --git a/include/hotplug.h b/include/hotplug.h index 6fe76c806..359bac959 100644 --- a/include/hotplug.h +++ b/include/hotplug.h @@ -26,58 +26,10 @@ #ifndef HOTPLUG_H #define HOTPLUG_H -#include "list.h" +#include extern _X_EXPORT void config_pre_init(void); extern _X_EXPORT void config_init(void); extern _X_EXPORT void config_fini(void); -/* Bump this each time you add something to the struct - * so that drivers can easily tell what is available - */ -#define ODEV_ATTRIBUTES_VERSION 1 - -struct OdevAttributes { - /* path to kernel device node - Linux e.g. /dev/dri/card0 */ - char *path; - - /* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ - char *syspath; - - /* DRI-style bus id */ - char *busid; - - /* Server managed FD */ - int fd; - - /* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ - int major; - - /* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ - int minor; - - /* kernel driver name */ - char *driver; -}; - -/* Note starting with xserver 1.16 this function never fails */ -struct OdevAttributes * -config_odev_allocate_attributes(void); - -void -config_odev_free_attributes(struct OdevAttributes *attribs); - -typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs); -void config_odev_probe(config_odev_probe_proc_ptr probe_callback); - -#ifdef CONFIG_UDEV_KMS -void NewGPUDeviceRequest(struct OdevAttributes *attribs); -void DeleteGPUDeviceRequest(struct OdevAttributes *attribs); -#endif - -#define ServerIsNotSeat0() (SeatId && strcmp(SeatId, "seat0")) - -struct xf86_platform_device * -xf86_find_platform_device_by_devnum(int major, int minor); - #endif /* HOTPLUG_H */