summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-02-21 15:46:16 +0000
committerpatrick <patrick@openbsd.org>2020-02-21 15:46:16 +0000
commitf11bbe7268da3bc9e5caaeff7a4e192a12798415 (patch)
treec8f26fb7f0c365643a69e8083d68948e28bd1d69
parentAdd rkdrm(4), a driver which combines all the separate components (diff)
downloadwireguard-openbsd-f11bbe7268da3bc9e5caaeff7a4e192a12798415.tar.xz
wireguard-openbsd-f11bbe7268da3bc9e5caaeff7a4e192a12798415.zip
Implement a rather simple video interface support for OFW. This is
good enough to make the Pinebook Pro work, but probably needs a lot more thinking. ok kettenis@
-rw-r--r--sys/dev/ofw/ofw_misc.c57
-rw-r--r--sys/dev/ofw/ofw_misc.h22
2 files changed, 77 insertions, 2 deletions
diff --git a/sys/dev/ofw/ofw_misc.c b/sys/dev/ofw/ofw_misc.c
index e6672eb4fa9..3af8a002d8b 100644
--- a/sys/dev/ofw/ofw_misc.c
+++ b/sys/dev/ofw/ofw_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_misc.c,v 1.12 2020/01/23 02:57:10 kettenis Exp $ */
+/* $OpenBSD: ofw_misc.c,v 1.13 2020/02/21 15:46:16 patrick Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis
*
@@ -439,3 +439,58 @@ nvmem_read_cell(int node, const char *name, void *data, bus_size_t size)
nd = nc->nc_nd;
return nd->nd_read(nd->nd_cookie, nc->nc_addr, data, size);
}
+
+/* Video interface support */
+
+LIST_HEAD(, video_device) video_devices =
+ LIST_HEAD_INITIALIZER(video_devices);
+
+void
+video_register(struct video_device *vd)
+{
+ vd->vd_phandle = OF_getpropint(vd->vd_node, "phandle", 0);
+ if (vd->vd_phandle == 0)
+ return;
+ LIST_INSERT_HEAD(&video_devices, vd, vd_list);
+}
+
+int
+video_port_activate(uint32_t phandle, struct drm_device *ddev)
+{
+ uint32_t ep, rep;
+ int node, error;
+
+ node = OF_getnodebyphandle(phandle);
+ if (node == 0)
+ return ENXIO;
+
+ for (node = OF_child(node); node; node = OF_peer(node)) {
+ ep = OF_getpropint(node, "phandle", 0);
+ rep = OF_getpropint(node, "remote-endpoint", 0);
+ if (ep == 0 || rep == 0)
+ continue;
+ error = video_endpoint_activate(ep, ddev);
+ if (error)
+ return error;
+ error = video_endpoint_activate(rep, ddev);
+ if (error)
+ return error;
+ }
+
+ return 0;
+}
+
+int
+video_endpoint_activate(uint32_t phandle, struct drm_device *ddev)
+{
+ struct video_device *vd;
+
+ LIST_FOREACH(vd, &video_devices, vd_list) {
+ if (vd->vd_phandle == phandle)
+ break;
+ }
+ if (vd == NULL)
+ return ENXIO;
+
+ return vd->vd_ep_activate(vd->vd_cookie, ddev);
+}
diff --git a/sys/dev/ofw/ofw_misc.h b/sys/dev/ofw/ofw_misc.h
index 53b3617851d..35a9b15c1a0 100644
--- a/sys/dev/ofw/ofw_misc.h
+++ b/sys/dev/ofw/ofw_misc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_misc.h,v 1.9 2020/01/23 02:57:10 kettenis Exp $ */
+/* $OpenBSD: ofw_misc.h,v 1.10 2020/02/21 15:46:16 patrick Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis
*
@@ -129,4 +129,24 @@ void nvmem_register(struct nvmem_device *);
int nvmem_read(uint32_t, bus_addr_t, void *, bus_size_t);
int nvmem_read_cell(int, const char *name, void *, bus_size_t);
+/* Video interface support */
+
+struct drm_device;
+struct video_device {
+ int vd_node;
+ void *vd_cookie;
+ int (*vd_read)(void *, bus_addr_t, void *, bus_size_t);
+
+ int (*vd_ep_activate)(void *, struct drm_device *);
+ void * (*vd_ep_get_data)(void *);
+
+ LIST_ENTRY(video_device) vd_list;
+ uint32_t vd_phandle;
+};
+
+void video_register(struct video_device *);
+int video_port_activate(uint32_t, struct drm_device *);
+int video_endpoint_activate(uint32_t, struct drm_device *);
+void * video_endpoint_get_data(uint32_t);
+
#endif /* _DEV_OFW_MISC_H_ */