From 32166efdadccf6d2082e729e5fd172eaa2170aa0 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 9 Feb 2024 16:42:42 +0100 Subject: [PATCH] xfree86: common: move non-public defs out of xf86platformBus.h public server module API headers shouldn't be clobbered with non-exported definitions, so move them out to private header file. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/common/xf86Events.c | 2 +- hw/xfree86/common/xf86Option.c | 2 +- hw/xfree86/common/xf86pciBus.c | 1 + hw/xfree86/common/xf86pciBus.h | 1 + hw/xfree86/common/xf86platformBus.c | 2 +- hw/xfree86/common/xf86platformBus.h | 96 ----------------- hw/xfree86/common/xf86platformBus_priv.h | 103 +++++++++++++++++++ hw/xfree86/drivers/modesetting/driver.c | 1 + hw/xfree86/os-support/linux/systemd-logind.c | 2 +- hw/xfree86/os-support/shared/drm_platform.c | 2 +- 10 files changed, 111 insertions(+), 101 deletions(-) create mode 100644 hw/xfree86/common/xf86platformBus_priv.h diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 2be494394..03b2325fa 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -90,7 +90,7 @@ #include "dpmsproc.h" #endif -#include "xf86platformBus.h" +#include "xf86platformBus_priv.h" #include "../os-support/linux/systemd-logind.h" diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index b8bab3617..dc5cae698 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -44,7 +44,7 @@ #include "xf86Xinput.h" #include "xf86Optrec.h" #include "xf86Parser.h" -#include "xf86platformBus.h" /* For OutputClass functions */ +#include "xf86platformBus_priv.h" #include "optionstr.h" static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 952810bac..50e5b20cc 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -48,6 +48,7 @@ /* Bus-specific headers */ #include "xf86Bus.h" +#include "xf86sbusBus_priv.h" #include "xf86_OSproc.h" diff --git a/hw/xfree86/common/xf86pciBus.h b/hw/xfree86/common/xf86pciBus.h index 14ae9760e..286c34acd 100644 --- a/hw/xfree86/common/xf86pciBus.h +++ b/hw/xfree86/common/xf86pciBus.h @@ -34,6 +34,7 @@ #define _XF86_PCI_BUS_H #include "xf86MatchDrivers.h" +#include "xf86platformBus_priv.h" void xf86PciProbe(void); Bool xf86PciAddMatchingDev(DriverPtr drvp); diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index 075143498..54f307a18 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -51,7 +51,7 @@ #include "xf86str.h" #include "xf86Bus.h" #include "Pci.h" -#include "xf86platformBus.h" +#include "xf86platformBus_priv.h" #include "xf86Config.h" #include "xf86Crtc.h" diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h index b9933f405..de39d6fc0 100644 --- a/hw/xfree86/common/xf86platformBus.h +++ b/hw/xfree86/common/xf86platformBus.h @@ -33,112 +33,16 @@ struct xf86_platform_device { int flags; }; -/* xf86_platform_device flags */ -#define XF86_PDEV_UNOWNED 0x01 -#define XF86_PDEV_SERVER_FD 0x02 -#define XF86_PDEV_PAUSED 0x04 - -#ifdef XSERVER_PLATFORM_BUS -int xf86platformProbe(void); -int xf86platformProbeDev(DriverPtr drvp); -int xf86platformAddGPUDevices(DriverPtr drvp); -void xf86MergeOutputClassOptions(int entityIndex, void **options); -void xf86PlatformScanPciDev(void); -const char *xf86PlatformFindHotplugDriver(int dev_index); - -extern int xf86_num_platform_devices; -extern struct xf86_platform_device *xf86_platform_devices; - -extern int -xf86_add_platform_device(struct OdevAttributes *attribs, Bool unowned); -extern int -xf86_remove_platform_device(int dev_index); -extern Bool -xf86_get_platform_device_unowned(int index); - -extern int -xf86platformAddDevice(const char *driver_name, int index); -extern void -xf86platformRemoveDevice(int index); - -static inline struct OdevAttributes * -xf86_platform_device_odev_attributes(struct xf86_platform_device *device) -{ - return device->attribs; -} - -static inline struct OdevAttributes * -xf86_platform_odev_attributes(int index) -{ - struct xf86_platform_device *device = &xf86_platform_devices[index]; - - return device->attribs; -} - -/* - * Define the legacy API only for external builds - */ - -/* path to kernel device node - Linux e.g. /dev/dri/card0 */ -#define ODEV_ATTRIB_PATH 1 -/* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ -#define ODEV_ATTRIB_SYSPATH 2 -/* DRI-style bus id */ -#define ODEV_ATTRIB_BUSID 3 -/* Server managed FD */ -#define ODEV_ATTRIB_FD 4 -/* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ -#define ODEV_ATTRIB_MAJOR 5 -/* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ -#define ODEV_ATTRIB_MINOR 6 -/* kernel driver name */ -#define ODEV_ATTRIB_DRIVER 7 - _X_EXPORT char * _xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]); _X_EXPORT int _xf86_get_platform_device_int_attrib(struct xf86_platform_device *device, int attrib, int (*fake)[0]); -#ifndef _XORG_CONFIG_H_ - -/* Protect against a mismatch attribute type by generating a compiler - * error using a negative array size when an incorrect attribute is - * passed - */ - -#define _ODEV_ATTRIB_IS_STRING(x) ((x) == ODEV_ATTRIB_PATH || \ - (x) == ODEV_ATTRIB_SYSPATH || \ - (x) == ODEV_ATTRIB_BUSID || \ - (x) == ODEV_ATTRIB_DRIVER) - -#define _ODEV_ATTRIB_STRING_CHECK(x) ((int (*)[_ODEV_ATTRIB_IS_STRING(x)-1]) 0) - -#define xf86_get_platform_device_attrib(device, attrib) _xf86_get_platform_device_attrib(device,attrib,_ODEV_ATTRIB_STRING_CHECK(attrib)) - -#define _ODEV_ATTRIB_IS_INT(x) ((x) == ODEV_ATTRIB_FD || (x) == ODEV_ATTRIB_MAJOR || (x) == ODEV_ATTRIB_MINOR) -#define _ODEV_ATTRIB_INT_DEFAULT(x) ((x) == ODEV_ATTRIB_FD ? -1 : 0) -#define _ODEV_ATTRIB_DEFAULT_CHECK(x,def) (_ODEV_ATTRIB_INT_DEFAULT(x) == (def)) -#define _ODEV_ATTRIB_INT_CHECK(x,def) ((int (*)[_ODEV_ATTRIB_IS_INT(x)*_ODEV_ATTRIB_DEFAULT_CHECK(x,def)-1]) 0) - -#define xf86_get_platform_device_int_attrib(device, attrib, def) _xf86_get_platform_device_int_attrib(device,attrib,_ODEV_ATTRIB_INT_CHECK(attrib,def)) - -#endif - extern _X_EXPORT Bool xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *busid); extern _X_EXPORT void xf86PlatformMatchDriver(XF86MatchedDrivers *); -extern void xf86platformVTProbe(void); -extern void xf86platformPrimary(void); - -#else - -static inline int xf86platformAddGPUDevices(DriverPtr drvp) { return FALSE; } -static inline void xf86MergeOutputClassOptions(int index, void **options) {} - -#endif - #endif diff --git a/hw/xfree86/common/xf86platformBus_priv.h b/hw/xfree86/common/xf86platformBus_priv.h new file mode 100644 index 000000000..0be91977a --- /dev/null +++ b/hw/xfree86/common/xf86platformBus_priv.h @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: MIT OR X11 + * + * Copyright © 2024 Enrico Weigelt, metux IT consult + * Copyright © 2012 Red Hat. + */ +#ifndef _XSERVER_XF86_PLATFORM_BUS_PRIV_H_ +#define _XSERVER_XF86_PLATFORM_BUS_PRIV_H_ + +#include + +#include "xf86platformBus.h" + +/* xf86_platform_device flags */ +#define XF86_PDEV_UNOWNED 0x01 +#define XF86_PDEV_SERVER_FD 0x02 +#define XF86_PDEV_PAUSED 0x04 + +#ifdef XSERVER_PLATFORM_BUS +int xf86platformProbe(void); +int xf86platformProbeDev(DriverPtr drvp); +int xf86platformAddGPUDevices(DriverPtr drvp); +void xf86MergeOutputClassOptions(int entityIndex, void **options); +void xf86PlatformScanPciDev(void); +const char *xf86PlatformFindHotplugDriver(int dev_index); + +extern int xf86_num_platform_devices; +extern struct xf86_platform_device *xf86_platform_devices; + +int xf86_add_platform_device(struct OdevAttributes *attribs, Bool unowned); +int xf86_remove_platform_device(int dev_index); +Bool xf86_get_platform_device_unowned(int index); + +int xf86platformAddDevice(const char *driver_name, int index); +void xf86platformRemoveDevice(int index); + +static inline struct OdevAttributes * +xf86_platform_device_odev_attributes(struct xf86_platform_device *device) +{ + return device->attribs; +} + +static inline struct OdevAttributes * +xf86_platform_odev_attributes(int index) +{ + struct xf86_platform_device *device = &xf86_platform_devices[index]; + + return device->attribs; +} + +#ifndef _XORG_CONFIG_H_ +/* + * Define the legacy API only for external builds + */ + +/* path to kernel device node - Linux e.g. /dev/dri/card0 */ +#define ODEV_ATTRIB_PATH 1 +/* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ +#define ODEV_ATTRIB_SYSPATH 2 +/* DRI-style bus id */ +#define ODEV_ATTRIB_BUSID 3 +/* Server managed FD */ +#define ODEV_ATTRIB_FD 4 +/* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ +#define ODEV_ATTRIB_MAJOR 5 +/* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ +#define ODEV_ATTRIB_MINOR 6 +/* kernel driver name */ +#define ODEV_ATTRIB_DRIVER 7 + +/* Protect against a mismatch attribute type by generating a compiler + * error using a negative array size when an incorrect attribute is + * passed + */ + +#define _ODEV_ATTRIB_IS_STRING(x) ((x) == ODEV_ATTRIB_PATH || \ + (x) == ODEV_ATTRIB_SYSPATH || \ + (x) == ODEV_ATTRIB_BUSID || \ + (x) == ODEV_ATTRIB_DRIVER) + +#define _ODEV_ATTRIB_STRING_CHECK(x) ((int (*)[_ODEV_ATTRIB_IS_STRING(x)-1]) 0) + +#define xf86_get_platform_device_attrib(device, attrib) _xf86_get_platform_device_attrib(device,attrib,_ODEV_ATTRIB_STRING_CHECK(attrib)) + +#define _ODEV_ATTRIB_IS_INT(x) ((x) == ODEV_ATTRIB_FD || (x) == ODEV_ATTRIB_MAJOR || (x) == ODEV_ATTRIB_MINOR) +#define _ODEV_ATTRIB_INT_DEFAULT(x) ((x) == ODEV_ATTRIB_FD ? -1 : 0) +#define _ODEV_ATTRIB_DEFAULT_CHECK(x,def) (_ODEV_ATTRIB_INT_DEFAULT(x) == (def)) +#define _ODEV_ATTRIB_INT_CHECK(x,def) ((int (*)[_ODEV_ATTRIB_IS_INT(x)*_ODEV_ATTRIB_DEFAULT_CHECK(x,def)-1]) 0) + +#define xf86_get_platform_device_int_attrib(device, attrib, def) _xf86_get_platform_device_int_attrib(device,attrib,_ODEV_ATTRIB_INT_CHECK(attrib,def)) + +#endif /* _XORG_CONFIG_H_ */ + +extern void xf86platformVTProbe(void); +extern void xf86platformPrimary(void); + +#else /* XSERVER_PLATFORM_BUS */ + +static inline int xf86platformAddGPUDevices(DriverPtr drvp) { return FALSE; } +static inline void xf86MergeOutputClassOptions(int index, void **options) {} + +#endif /* XSERVER_PLATFORM_BUS */ + +#endif /* _XSERVER_XF86_PLATFORM_BUS_PRIV_H_ */ diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index d8c8e81c6..45a7adc29 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -66,6 +66,7 @@ #include #endif #include "driver.h" +#include "xf86platformBus_priv.h" static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y); static Bool CloseScreen(ScreenPtr pScreen); diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index efe710b3c..0421a4b76 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -38,7 +38,7 @@ #include "os.h" #include "linux.h" #include "xf86.h" -#include "xf86platformBus.h" +#include "xf86platformBus_priv.h" #include "xf86Xinput_priv.h" #include "xf86Priv.h" #include "globals.h" diff --git a/hw/xfree86/os-support/shared/drm_platform.c b/hw/xfree86/os-support/shared/drm_platform.c index 2cbe53422..9bddb3822 100644 --- a/hw/xfree86/os-support/shared/drm_platform.c +++ b/hw/xfree86/os-support/shared/drm_platform.c @@ -17,7 +17,7 @@ #include "xf86.h" #include "xf86_os_support.h" -#include "xf86platformBus.h" +#include "xf86platformBus_priv.h" #include "xf86Bus.h" #include "../linux/systemd-logind.h"