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