nouveau: remove an unused table
[mesa.git] / src / mesa / drivers / dri / nouveau / nouveau_driver.c
1 /**************************************************************************
2
3 Copyright 2006 Stephane Marchesin
4 All Rights Reserved.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 on the rights to use, copy, modify, merge, publish, distribute, sub
10 license, and/or sell copies of the Software, and to permit persons to whom
11 the Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice (including the next
14 paragraph) shall be included in all copies or substantial portions of the
15 Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
21 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25 **************************************************************************/
26
27 #include "nouveau_context.h"
28 //#include "nouveau_state.h"
29 #include "nouveau_lock.h"
30 #include "nouveau_fifo.h"
31 #include "nouveau_driver.h"
32 #include "swrast/swrast.h"
33
34 #include "context.h"
35 #include "framebuffer.h"
36
37 #include "utils.h"
38
39 /* Wrapper for DRM_NOUVEAU_GETPARAM ioctl */
40 GLboolean nouveauDRMGetParam(nouveauContextPtr nmesa,
41 unsigned int param,
42 uint64_t* value)
43 {
44 drm_nouveau_getparam_t getp;
45
46 getp.param = param;
47 if (!value || drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_GETPARAM,
48 &getp, sizeof(getp)))
49 return GL_FALSE;
50 *value = getp.value;
51 return GL_TRUE;
52 }
53
54 /* Wrapper for DRM_NOUVEAU_GETPARAM ioctl */
55 GLboolean nouveauDRMSetParam(nouveauContextPtr nmesa,
56 unsigned int param,
57 uint64_t value)
58 {
59 drm_nouveau_setparam_t setp;
60
61 setp.param = param;
62 setp.value = value;
63 if (drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_SETPARAM, &setp,
64 sizeof(setp)))
65 return GL_FALSE;
66 return GL_TRUE;
67 }
68
69 /* Return the width and height of the current color buffer */
70 static void nouveauGetBufferSize( GLframebuffer *buffer,
71 GLuint *width, GLuint *height )
72 {
73 GET_CURRENT_CONTEXT(ctx);
74 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
75
76 LOCK_HARDWARE( nmesa );
77 *width = nmesa->driDrawable->w;
78 *height = nmesa->driDrawable->h;
79 UNLOCK_HARDWARE( nmesa );
80 }
81
82 /* glGetString */
83 static const GLubyte *nouveauGetString( GLcontext *ctx, GLenum name )
84 {
85 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
86 static char buffer[128];
87 const char * card_name = "Unknown";
88 GLuint agp_mode = 0;
89
90 switch ( name ) {
91 case GL_VENDOR:
92 return (GLubyte *)DRIVER_AUTHOR;
93
94 case GL_RENDERER:
95 card_name=nmesa->screen->card->name;
96
97 switch(nmesa->screen->bus_type)
98 {
99 case NV_PCI:
100 case NV_PCIE:
101 default:
102 agp_mode=0;
103 break;
104 case NV_AGP:
105 agp_mode=nmesa->screen->agp_mode;
106 break;
107 }
108 driGetRendererString( buffer, card_name, DRIVER_DATE,
109 agp_mode );
110 return (GLubyte *)buffer;
111 default:
112 return NULL;
113 }
114 }
115
116 /* glFlush */
117 static void nouveauFlush( GLcontext *ctx )
118 {
119 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
120 FIRE_RING();
121 }
122
123 /* glFinish */
124 static void nouveauFinish( GLcontext *ctx )
125 {
126 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
127 nouveauFlush( ctx );
128 nouveauWaitForIdle( nmesa );
129 }
130
131 /* glClear */
132 static void nouveauClear( GLcontext *ctx, GLbitfield mask )
133 {
134 // XXX we really should do something here...
135 }
136
137 void nouveauDriverInitFunctions( struct dd_function_table *functions )
138 {
139 functions->GetBufferSize = nouveauGetBufferSize;
140 functions->ResizeBuffers = _mesa_resize_framebuffer;
141 functions->GetString = nouveauGetString;
142 functions->Flush = nouveauFlush;
143 functions->Finish = nouveauFinish;
144 functions->Clear = nouveauClear;
145 }
146