interfaces that are needed for the upcoming apple kms driver.
ok jsg@
-/* $OpenBSD: drm_linux.c,v 1.104 2023/10/20 03:38:58 jsg Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.105 2023/12/23 14:18:27 kettenis Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
#endif
+SLIST_HEAD(,backlight_device) backlight_device_list =
+ SLIST_HEAD_INITIALIZER(backlight_device_list);
+
void
backlight_do_update_status(void *arg)
{
struct backlight_device *
backlight_device_register(const char *name, void *kdev, void *data,
- const struct backlight_ops *ops, struct backlight_properties *props)
+ const struct backlight_ops *ops, const struct backlight_properties *props)
{
struct backlight_device *bd;
bd->data = data;
task_set(&bd->task, backlight_do_update_status, bd);
+
+ SLIST_INSERT_HEAD(&backlight_device_list, bd, next);
+ bd->name = name;
return bd;
}
void
backlight_device_unregister(struct backlight_device *bd)
{
+ SLIST_REMOVE(&backlight_device_list, bd, backlight_device, next);
free(bd, M_DRM, sizeof(*bd));
}
-struct backlight_device *
-devm_backlight_device_register(void *dev, const char *name, void *parent,
- void *data, const struct backlight_ops *bo,
- const struct backlight_properties *bp)
-{
- STUB();
- return NULL;
-}
-
void
backlight_schedule_update_status(struct backlight_device *bd)
{
task_add(systq, &bd->task);
}
-inline int
+int
backlight_enable(struct backlight_device *bd)
{
if (bd == NULL)
return bd->ops->update_status(bd);
}
-inline int
+int
backlight_disable(struct backlight_device *bd)
{
if (bd == NULL)
return bd->ops->update_status(bd);
}
+struct backlight_device *
+backlight_device_get_by_name(const char *name)
+{
+ struct backlight_device *bd;
+
+ SLIST_FOREACH(bd, &backlight_device_list, next) {
+ if (strcmp(name, bd->name) == 0)
+ return bd;
+ }
+
+ return NULL;
+}
+
+struct drvdata {
+ struct device *dev;
+ void *data;
+ SLIST_ENTRY(drvdata) next;
+};
+
+SLIST_HEAD(,drvdata) drvdata_list = SLIST_HEAD_INITIALIZER(drvdata_list);
+
+void
+dev_set_drvdata(struct device *dev, void *data)
+{
+ struct drvdata *drvdata;
+
+ SLIST_FOREACH(drvdata, &drvdata_list, next) {
+ if (drvdata->dev == dev) {
+ drvdata->data = data;
+ return;
+ }
+ }
+
+ if (data == NULL)
+ return;
+
+ drvdata = malloc(sizeof(*drvdata), M_DRM, M_WAITOK);
+ drvdata->dev = dev;
+ drvdata->data = data;
+
+ SLIST_INSERT_HEAD(&drvdata_list, drvdata, next);
+}
+
+void *
+dev_get_drvdata(struct device *dev)
+{
+ struct drvdata *drvdata;
+
+ SLIST_FOREACH(drvdata, &drvdata_list, next) {
+ if (drvdata->dev == dev)
+ return drvdata->data;
+ }
+
+ return NULL;
+}
+
void
drm_sysfs_hotplug_event(struct drm_device *dev)
{
/* private: */
int index; /* Minor device number */
int type; /* Control or render */
-#ifdef __linux__
struct device *kdev; /* Linux device */
-#endif
struct drm_device *dev;
struct dentry *debugfs_root;
struct backlight_properties {
int type;
+#define BACKLIGHT_RAW 0
+#define BACKLIGHT_FIRMWARE 1
+#define BACKLIGHT_PLATFORM 2
int max_brightness;
int brightness;
int power;
+ int scale;
+#define BACKLIGHT_SCALE_LINEAR 0
+ int state;
+#define BL_CORE_SUSPENDED 0x00000001
};
struct backlight_ops {
int options;
+#define BL_CORE_SUSPENDRESUME 0x00000001
int (*update_status)(struct backlight_device *);
int (*get_brightness)(struct backlight_device *);
};
-#define BL_CORE_SUSPENDRESUME 1
-
struct backlight_device {
const struct backlight_ops *ops;
struct backlight_properties props;
struct task task;
void *data;
+ SLIST_ENTRY(backlight_device) next;
+ const char *name;
};
static inline void *
return bd->data;
}
-#define BACKLIGHT_RAW 0
-#define BACKLIGHT_FIRMWARE 1
+static inline int
+backlight_get_brightness(struct backlight_device *bd)
+{
+ return bd->props.brightness;
+}
#define BACKLIGHT_UPDATE_HOTKEY 0
struct backlight_device *backlight_device_register(const char *, void *,
- void *, const struct backlight_ops *, struct backlight_properties *);
+ void *, const struct backlight_ops *, const struct backlight_properties *);
void backlight_device_unregister(struct backlight_device *);
-struct backlight_device *devm_backlight_device_register(void *, const char *,
- void *, void *, const struct backlight_ops *,
- const struct backlight_properties *);
+static inline struct backlight_device *
+devm_backlight_device_register(void *dev, const char *name, void *parent,
+ void *data, const struct backlight_ops *bo,
+ const struct backlight_properties *bp)
+{
+ return backlight_device_register(name, dev, data, bo, bp);
+}
static inline void
backlight_update_status(struct backlight_device *bd)
return NULL;
}
-static inline struct backlight_device *
-backlight_device_get_by_name(const char *name)
-{
- return NULL;
-}
+struct backlight_device *backlight_device_get_by_name(const char *);
#endif
struct device_node;
+struct bus_type {
+};
+
struct device_driver {
struct device *dev;
};
#define device_create_file(a, b) 0
#define device_remove_file(a, b)
-#define dev_get_drvdata(x) NULL
-#define dev_set_drvdata(x, y)
+void *dev_get_drvdata(struct device *);
+void dev_set_drvdata(struct device *, void *);
#define dev_pm_set_driver_flags(x, y)
#define devm_kzalloc(x, y, z) kzalloc(y, z)
+#define devm_kfree(x, y) kfree(y)
#define dev_warn(dev, fmt, arg...) \
printf("drm:pid%d:%s *WARNING* " fmt, curproc->p_p->ps_pid, \
#define dev_err_once(dev, fmt, arg...) \
printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid, \
__func__ , ## arg)
+
+#define dev_err_probe(dev, err, fmt, arg...) \
+ printf("drm:pid%d:%s *ERROR* " fmt, curproc->p_p->ps_pid, \
+ __func__ , ## arg), err
#ifdef DRMDEBUG
#define dev_info(dev, fmt, arg...) \
#define readq(p) ioread64(p)
#define writeq(v, p) iowrite64(v, p)
+#define readl_relaxed(p) readl(p)
+#define writel_relaxed(v, p) writel(v, p)
+
int drm_mtrr_add(unsigned long, size_t, int);
int drm_mtrr_del(int, unsigned long, size_t, int);
#include <linux/types.h>
+#define IORESOURCE_MEM 0x0001
+
struct resource {
u_long start;
u_long end;
#define usecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000000)
#define nsecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000000000)
#define nsecs_to_jiffies64(x) (((uint64_t)(x)) * hz / 1000000000)
-#define get_jiffies_64() jiffies
+
+static inline uint64_t
+get_jiffies_64(void)
+{
+ return jiffies;
+}
static inline int
time_after(const unsigned long a, const unsigned long b)
return((long)(b - a) <= 0);
}
+static inline int
+time_after_eq64(const unsigned long long a, const unsigned long long b)
+{
+ return((long long)(b - a) <= 0);
+}
+
#define time_after32(a,b) ((int32_t)((uint32_t)(b) - (uint32_t)(a)) < 0)
#endif
#define STUB() do { printf("%s: stub\n", __func__); } while(0)
+#define CONCATENATE(x, y) __CONCAT(x, y)
+
#endif
-/* $OpenBSD: pci.h,v 1.14 2023/09/13 12:31:49 jsg Exp $ */
+/* $OpenBSD: pci.h,v 1.15 2023/12/23 14:18:27 kettenis Exp $ */
/*
* Copyright (c) 2015 Mark Kettenis
*
return 0;
}
+struct pci_driver;
+
+static inline int
+pci_register_driver(struct pci_driver *pci_drv)
+{
+ return 0;
+}
+
static inline void
pci_unregister_driver(void *d)
{