cg149915 | d0538f6 | 2008-01-09 19:45:15 -0800 | [diff] [blame] | 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 | |
cg149915 | d0538f6 | 2008-01-09 19:45:15 -0800 | [diff] [blame] | 27 | /* |
| 28 | * Common misc module interfaces of DRM under Solaris |
| 29 | */ |
| 30 | |
| 31 | /* |
| 32 | * I915 DRM Driver for Solaris |
| 33 | * |
| 34 | * This driver provides the hardware 3D acceleration support for Intel |
| 35 | * integrated video devices (e.g. i8xx/i915/i945 series chipsets), under the |
| 36 | * DRI (Direct Rendering Infrastructure). DRM (Direct Rendering Manager) here |
| 37 | * means the kernel device driver in DRI. |
| 38 | * |
| 39 | * I915 driver is a device dependent driver only, it depends on a misc module |
| 40 | * named drm for generic DRM operations. |
| 41 | * |
| 42 | * This driver also calls into gfx and agpmaster misc modules respectively for |
| 43 | * generic graphics operations and AGP master device support. |
| 44 | */ |
| 45 | |
| 46 | #ifndef _SYS_DRM_SUNMOD_H_ |
| 47 | #define _SYS_DRM_SUNMOD_H_ |
| 48 | |
| 49 | #ifdef __cplusplus |
| 50 | extern "C" { |
| 51 | #endif |
| 52 | |
| 53 | #include <sys/types.h> |
| 54 | #include <sys/errno.h> |
| 55 | #include <sys/conf.h> |
| 56 | #include <sys/kmem.h> |
| 57 | #include <sys/visual_io.h> |
cg149915 | d0538f6 | 2008-01-09 19:45:15 -0800 | [diff] [blame] | 58 | #include <sys/fbio.h> |
| 59 | #include <sys/ddi.h> |
| 60 | #include <sys/sunddi.h> |
| 61 | #include <sys/stat.h> |
| 62 | #include <sys/file.h> |
| 63 | #include <sys/open.h> |
| 64 | #include <sys/modctl.h> |
| 65 | #include <sys/vgareg.h> |
| 66 | #include <sys/vgasubr.h> |
| 67 | #include <sys/pci.h> |
| 68 | #include <sys/kd.h> |
| 69 | #include <sys/ddi_impldefs.h> |
| 70 | #include <sys/sunldi.h> |
| 71 | #include <sys/mkdev.h> |
Gordon Ross | dc1b269 | 2016-10-09 11:32:43 -0400 | [diff] [blame] | 72 | #include <sys/gfx_private.h> |
cg149915 | d0538f6 | 2008-01-09 19:45:15 -0800 | [diff] [blame] | 73 | #include <sys/agpgart.h> |
| 74 | #include <sys/agp/agpdefs.h> |
| 75 | #include <sys/agp/agpmaster_io.h> |
| 76 | #include "drmP.h" |
| 77 | #include <sys/modctl.h> |
| 78 | |
| 79 | /* |
| 80 | * dev_t of this driver looks consists of: |
| 81 | * |
| 82 | * major number with NBITSMAJOR bits |
| 83 | * instance node number with NBITSINST bits |
| 84 | * minor node number with NBITSMINOR - NBITSINST bits |
| 85 | * |
| 86 | * Each instance has at most 2^(NBITSMINOR - NBITSINST) minor nodes, the first |
| 87 | * three are: |
| 88 | * 0: gfx<instance number>, graphics common node |
| 89 | * 1: agpmaster<instance number>, agpmaster node |
| 90 | * 2: drm<instance number>, drm node |
| 91 | */ |
| 92 | #define GFX_MINOR 0 |
| 93 | #define AGPMASTER_MINOR 1 |
| 94 | #define DRM_MINOR 2 |
cg149915 | fca314a | 2008-02-28 20:09:48 -0800 | [diff] [blame] | 95 | #define DRM_MIN_CLONEMINOR 3 |
cg149915 | d0538f6 | 2008-01-09 19:45:15 -0800 | [diff] [blame] | 96 | |
| 97 | /* |
| 98 | * Number of bits occupied by instance number in dev_t, currently maximum 8 |
| 99 | * instances are supported. |
| 100 | */ |
| 101 | #define NBITSINST 3 |
| 102 | |
| 103 | /* Number of bits occupied in dev_t by minor node */ |
| 104 | #define NBITSMNODE (18 - NBITSINST) |
| 105 | |
| 106 | /* |
| 107 | * DRM use a "cloning" minor node mechanism to release lock on every close(2), |
| 108 | * thus there will be a minor node for every open(2) operation. Here we give |
| 109 | * the maximum DRM cloning minor node number. |
| 110 | */ |
| 111 | #define MAX_CLONE_MINOR (1 << (NBITSMNODE) - 1) |
| 112 | #define DEV2MINOR(dev) (getminor(dev) & ((1 << (NBITSMNODE)) - 1)) |
| 113 | #define DEV2INST(dev) (getminor(dev) >> NBITSMNODE) |
| 114 | #define INST2NODE0(inst) ((inst) << NBITSMNODE) |
| 115 | #define INST2NODE1(inst) (((inst) << NBITSMNODE) + AGPMASTER_MINOR) |
| 116 | #define INST2NODE2(inst) (((inst) << NBITSMNODE) + DRM_MINOR) |
| 117 | |
| 118 | /* graphics name for the common graphics minor node */ |
| 119 | #define GFX_NAME "gfx" |
| 120 | |
| 121 | |
| 122 | /* |
| 123 | * softstate for DRM module |
| 124 | */ |
| 125 | typedef struct drm_instance_state { |
| 126 | kmutex_t mis_lock; |
| 127 | kmutex_t dis_ctxlock; |
| 128 | major_t mis_major; |
| 129 | dev_info_t *mis_dip; |
| 130 | drm_device_t *mis_devp; |
| 131 | ddi_acc_handle_t mis_cfg_hdl; |
| 132 | agp_master_softc_t *mis_agpm; /* agpmaster softstate ptr */ |
| 133 | gfxp_vgatext_softc_ptr_t mis_gfxp; /* gfx softstate */ |
| 134 | } drm_inst_state_t; |
| 135 | |
| 136 | |
| 137 | struct drm_inst_state_list { |
| 138 | drm_inst_state_t disl_state; |
| 139 | struct drm_inst_state_list *disl_next; |
| 140 | |
| 141 | }; |
| 142 | typedef struct drm_inst_state_list drm_inst_list_t; |
| 143 | |
| 144 | |
| 145 | /* Identifier of this driver */ |
| 146 | static struct vis_identifier text_ident = { "SUNWdrm" }; |
| 147 | static int drm_sun_open(dev_t *, int, int, cred_t *); |
| 148 | static int drm_sun_close(dev_t, int, int, cred_t *); |
| 149 | static int drm_sun_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); |
| 150 | static int drm_sun_devmap(dev_t, devmap_cookie_t, |
| 151 | offset_t, size_t, size_t *, uint_t); |
| 152 | |
| 153 | #ifdef __cplusplus |
| 154 | } |
| 155 | #endif |
| 156 | |
| 157 | #endif /* _SYS_DRM_SUNMOD_H_ */ |