xref: /openbsd-src/sys/dev/fdt/rkdrm.h (revision 99fd087599a8791921855f21bd7e36130f39aadc)
1 /* $OpenBSD: rkdrm.h,v 1.1 2020/02/21 15:44:54 patrick Exp $ */
2 /* $NetBSD: rk_drm.h,v 1.1 2019/11/09 23:30:14 jmcneill Exp $ */
3 /*-
4  * Copyright (c) 2019 Jared D. McNeill <jmcneill@invisible.ca>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef _ARM_RK_DRM_H
30 #define _ARM_RK_DRM_H
31 
32 #include <dev/wscons/wsconsio.h>
33 #include <dev/wscons/wsdisplayvar.h>
34 #include <dev/rasops/rasops.h>
35 
36 #include <drm/drm_fb_helper.h>
37 #include <drm/drm_gem_cma_helper.h>
38 
39 #define DRIVER_AUTHOR		"Jared McNeill"
40 
41 #define DRIVER_NAME		"rk"
42 #define DRIVER_DESC		"Rockchip Display Subsystem"
43 #define DRIVER_DATE		"20191109"
44 
45 #define DRIVER_MAJOR		1
46 #define DRIVER_MINOR		0
47 #define DRIVER_PATCHLEVEL	0
48 
49 struct rk_framebuffer;
50 
51 #define	RK_DRM_MAX_CRTC	2
52 
53 struct rkdrm_vblank {
54 	void			*priv;
55 	void			(*enable_vblank)(void *);
56 	void			(*disable_vblank)(void *);
57 	uint32_t		(*get_vblank_counter)(void *);
58 };
59 
60 struct rkdrm_softc {
61 	struct device		sc_dev;
62 	struct drm_device	sc_ddev;
63 
64 	bus_space_tag_t		sc_iot;
65 	bus_dma_tag_t		sc_dmat;
66 
67 	int			sc_node;
68 
69 	struct rkdrm_vblank	sc_vbl[RK_DRM_MAX_CRTC];
70 
71 	void			(*switchcb)(void *, int, int);
72 	void			*switchcbarg;
73 	void			*switchcookie;
74 	struct task		switchtask;
75 	struct rasops_info	ro;
76 	int			console;
77 	int			primary;
78 
79 	struct drm_fb_helper	helper;
80 };
81 
82 struct rkdrm_framebuffer {
83 	struct drm_framebuffer	base;
84 	struct drm_gem_cma_object *obj;
85 };
86 
87 struct rkdrm_ports {
88 	int			phandle;
89 	struct drm_device	*ddev;
90 	TAILQ_ENTRY(rkdrm_ports) entries;
91 };
92 
93 struct rkdrm_fbdev {
94 	struct drm_fb_helper	helper;
95 };
96 
97 struct rkdrmfb_attach_args {
98 	struct drm_device	*sfa_drm_dev;
99 	struct drm_fb_helper	*sfa_fb_helper;
100 	struct drm_fb_helper_surface_size sfa_fb_sizes;
101 	bus_space_tag_t		sfa_fb_iot;
102 	bus_dma_tag_t		sfa_fb_dmat;
103 	uint32_t		sfa_fb_linebytes;
104 };
105 
106 #define rkdrm_private(ddev)		(ddev)->dev_private
107 #define to_rkdrm_framebuffer(x)	container_of(x, struct rkdrm_framebuffer, base)
108 
109 #endif /* _ARM_RK_DRM_H */
110