xref: /titanic_44/usr/src/uts/common/io/drm/drm_sunmod.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * Common misc module interfaces of DRM under Solaris
31  */
32 
33 /*
34  * I915 DRM Driver for Solaris
35  *
36  * This driver provides the hardware 3D acceleration support for Intel
37  * integrated video devices (e.g. i8xx/i915/i945 series chipsets), under the
38  * DRI (Direct Rendering Infrastructure). DRM (Direct Rendering Manager) here
39  * means the kernel device driver in DRI.
40  *
41  * I915 driver is a device dependent driver only, it depends on a misc module
42  * named drm for generic DRM operations.
43  *
44  * This driver also calls into gfx and agpmaster misc modules respectively for
45  * generic graphics operations and AGP master device support.
46  */
47 
48 #ifndef	_SYS_DRM_SUNMOD_H_
49 #define	_SYS_DRM_SUNMOD_H_
50 
51 #ifdef	__cplusplus
52 extern "C" {
53 #endif
54 
55 #include <sys/types.h>
56 #include <sys/errno.h>
57 #include <sys/conf.h>
58 #include <sys/kmem.h>
59 #include <sys/visual_io.h>
60 #include <sys/font.h>
61 #include <sys/fbio.h>
62 #include <sys/ddi.h>
63 #include <sys/sunddi.h>
64 #include <sys/stat.h>
65 #include <sys/file.h>
66 #include <sys/open.h>
67 #include <sys/modctl.h>
68 #include <sys/vgareg.h>
69 #include <sys/vgasubr.h>
70 #include <sys/pci.h>
71 #include <sys/kd.h>
72 #include <sys/ddi_impldefs.h>
73 #include <sys/sunldi.h>
74 #include <sys/mkdev.h>
75 #include <gfx_private.h>
76 #include <sys/agpgart.h>
77 #include <sys/agp/agpdefs.h>
78 #include <sys/agp/agpmaster_io.h>
79 #include "drmP.h"
80 #include <sys/modctl.h>
81 
82 /*
83  * dev_t of this driver looks consists of:
84  *
85  * major number with NBITSMAJOR bits
86  * instance node number with NBITSINST bits
87  * minor node number with NBITSMINOR - NBITSINST bits
88  *
89  * Each instance has at most 2^(NBITSMINOR - NBITSINST) minor nodes, the first
90  * three are:
91  * 0: gfx<instance number>, graphics common node
92  * 1: agpmaster<instance number>, agpmaster node
93  * 2: drm<instance number>, drm node
94  */
95 #define	GFX_MINOR		0
96 #define	AGPMASTER_MINOR		1
97 #define	DRM_MINOR		2
98 #define	DRM_MIN_CLONEMINOR	3
99 
100 /*
101  * Number of bits occupied by instance number in dev_t, currently maximum 8
102  * instances are supported.
103  */
104 #define	NBITSINST		3
105 
106 /* Number of bits occupied in dev_t by minor node */
107 #define	NBITSMNODE		(18 - NBITSINST)
108 
109 /*
110  * DRM use a "cloning" minor node mechanism to release lock on every close(2),
111  * thus there will be a minor node for every open(2) operation. Here we give
112  * the maximum DRM cloning minor node number.
113  */
114 #define	MAX_CLONE_MINOR		(1 << (NBITSMNODE) - 1)
115 #define	DEV2MINOR(dev)		(getminor(dev) & ((1 << (NBITSMNODE)) - 1))
116 #define	DEV2INST(dev)		(getminor(dev) >> NBITSMNODE)
117 #define	INST2NODE0(inst)	((inst) << NBITSMNODE)
118 #define	INST2NODE1(inst)	(((inst) << NBITSMNODE) + AGPMASTER_MINOR)
119 #define	INST2NODE2(inst)	(((inst) << NBITSMNODE) + DRM_MINOR)
120 
121 /* graphics name for the common graphics minor node */
122 #define	GFX_NAME		"gfx"
123 
124 
125 /*
126  * softstate for DRM module
127  */
128 typedef struct drm_instance_state {
129 	kmutex_t		mis_lock;
130 	kmutex_t		dis_ctxlock;
131 	major_t			mis_major;
132 	dev_info_t		*mis_dip;
133 	drm_device_t	*mis_devp;
134 	ddi_acc_handle_t	mis_cfg_hdl;
135 	agp_master_softc_t	*mis_agpm;	/* agpmaster softstate ptr */
136 	gfxp_vgatext_softc_ptr_t	mis_gfxp;	/* gfx softstate */
137 } drm_inst_state_t;
138 
139 
140 struct drm_inst_state_list {
141 	drm_inst_state_t	disl_state;
142 	struct drm_inst_state_list *disl_next;
143 
144 };
145 typedef struct drm_inst_state_list drm_inst_list_t;
146 
147 
148 /* Identifier of this driver */
149 static struct vis_identifier text_ident = { "SUNWdrm" };
150 static int drm_sun_open(dev_t *, int, int, cred_t *);
151 static int drm_sun_close(dev_t, int, int, cred_t *);
152 static int drm_sun_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
153 static int drm_sun_devmap(dev_t, devmap_cookie_t,
154 	offset_t, size_t, size_t *, uint_t);
155 
156 #ifdef	__cplusplus
157 }
158 #endif
159 
160 #endif	/* _SYS_DRM_SUNMOD_H_ */
161