xref: /openbsd-src/sys/dev/fdt/rkdrm.h (revision be691f3bb6417f04a68938fadbcaee2d5795e764)
1 /* $OpenBSD: rkdrm.h,v 1.2 2020/06/08 04:47:58 jsg 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_fourcc.h>
38 #include <drm/drm_gem_cma_helper.h>
39 
40 #define DRIVER_AUTHOR		"Jared McNeill"
41 
42 #define DRIVER_NAME		"rk"
43 #define DRIVER_DESC		"Rockchip Display Subsystem"
44 #define DRIVER_DATE		"20191109"
45 
46 #define DRIVER_MAJOR		1
47 #define DRIVER_MINOR		0
48 #define DRIVER_PATCHLEVEL	0
49 
50 struct rk_framebuffer;
51 
52 #define	RK_DRM_MAX_CRTC	2
53 
54 struct rkdrm_vblank {
55 	void			*priv;
56 	void			(*enable_vblank)(void *);
57 	void			(*disable_vblank)(void *);
58 	uint32_t		(*get_vblank_counter)(void *);
59 };
60 
61 struct rkdrm_softc {
62 	struct device		sc_dev;
63 	struct drm_device	sc_ddev;
64 
65 	bus_space_tag_t		sc_iot;
66 	bus_dma_tag_t		sc_dmat;
67 
68 	int			sc_node;
69 
70 	struct rkdrm_vblank	sc_vbl[RK_DRM_MAX_CRTC];
71 
72 	void			(*switchcb)(void *, int, int);
73 	void			*switchcbarg;
74 	void			*switchcookie;
75 	struct task		switchtask;
76 	struct rasops_info	ro;
77 	int			console;
78 	int			primary;
79 
80 	struct drm_fb_helper	helper;
81 };
82 
83 struct rkdrm_framebuffer {
84 	struct drm_framebuffer	base;
85 	struct drm_gem_cma_object *obj;
86 };
87 
88 struct rkdrm_ports {
89 	int			phandle;
90 	struct drm_device	*ddev;
91 	TAILQ_ENTRY(rkdrm_ports) entries;
92 };
93 
94 struct rkdrm_fbdev {
95 	struct drm_fb_helper	helper;
96 };
97 
98 struct rkdrmfb_attach_args {
99 	struct drm_device	*sfa_drm_dev;
100 	struct drm_fb_helper	*sfa_fb_helper;
101 	struct drm_fb_helper_surface_size sfa_fb_sizes;
102 	bus_space_tag_t		sfa_fb_iot;
103 	bus_dma_tag_t		sfa_fb_dmat;
104 	uint32_t		sfa_fb_linebytes;
105 };
106 
107 #define rkdrm_private(ddev)		(ddev)->dev_private
108 #define to_rkdrm_framebuffer(x)	container_of(x, struct rkdrm_framebuffer, base)
109 
110 #endif /* _ARM_RK_DRM_H */
111