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 99 /* 100 * Number of bits occupied by instance number in dev_t, currently maximum 8 101 * instances are supported. 102 */ 103 #define NBITSINST 3 104 105 /* Number of bits occupied in dev_t by minor node */ 106 #define NBITSMNODE (18 - NBITSINST) 107 108 /* 109 * DRM use a "cloning" minor node mechanism to release lock on every close(2), 110 * thus there will be a minor node for every open(2) operation. Here we give 111 * the maximum DRM cloning minor node number. 112 */ 113 #define MAX_CLONE_MINOR (1 << (NBITSMNODE) - 1) 114 #define DEV2MINOR(dev) (getminor(dev) & ((1 << (NBITSMNODE)) - 1)) 115 #define DEV2INST(dev) (getminor(dev) >> NBITSMNODE) 116 #define INST2NODE0(inst) ((inst) << NBITSMNODE) 117 #define INST2NODE1(inst) (((inst) << NBITSMNODE) + AGPMASTER_MINOR) 118 #define INST2NODE2(inst) (((inst) << NBITSMNODE) + DRM_MINOR) 119 120 /* graphics name for the common graphics minor node */ 121 #define GFX_NAME "gfx" 122 123 124 /* 125 * softstate for DRM module 126 */ 127 typedef struct drm_instance_state { 128 kmutex_t mis_lock; 129 kmutex_t dis_ctxlock; 130 major_t mis_major; 131 dev_info_t *mis_dip; 132 drm_device_t *mis_devp; 133 ddi_acc_handle_t mis_cfg_hdl; 134 agp_master_softc_t *mis_agpm; /* agpmaster softstate ptr */ 135 gfxp_vgatext_softc_ptr_t mis_gfxp; /* gfx softstate */ 136 } drm_inst_state_t; 137 138 139 struct drm_inst_state_list { 140 drm_inst_state_t disl_state; 141 struct drm_inst_state_list *disl_next; 142 143 }; 144 typedef struct drm_inst_state_list drm_inst_list_t; 145 146 147 /* Identifier of this driver */ 148 static struct vis_identifier text_ident = { "SUNWdrm" }; 149 static int drm_sun_open(dev_t *, int, int, cred_t *); 150 static int drm_sun_close(dev_t, int, int, cred_t *); 151 static int drm_sun_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); 152 static int drm_sun_devmap(dev_t, devmap_cookie_t, 153 offset_t, size_t, size_t *, uint_t); 154 155 #ifdef __cplusplus 156 } 157 #endif 158 159 #endif /* _SYS_DRM_SUNMOD_H_ */ 160