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