Initial revision
[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_ioctl.h"
29 //#include "nouveau_state.h"
30 #include "nouveau_driver.h"
31 #include "swrast/swrast.h"
32
33 #include "context.h"
34 #include "framebuffer.h"
35
36 #include "utils.h"
37
38
39 /* Return the width and height of the current color buffer */
40 static void nouveauGetBufferSize( GLframebuffer *buffer,
41 GLuint *width, GLuint *height )
42 {
43 GET_CURRENT_CONTEXT(ctx);
44 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
45
46 LOCK_HARDWARE( nmesa );
47 *width = nmesa->driDrawable->w;
48 *height = nmesa->driDrawable->h;
49 UNLOCK_HARDWARE( nmesa );
50 }
51
52 /* glGetString */
53 static const GLubyte *nouveauGetString( GLcontext *ctx, GLenum name )
54 {
55 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
56 static char buffer[128];
57 const char * card_name = "Unknown";
58 GLuint agp_mode = 0;
59
60 switch ( name ) {
61 case GL_VENDOR:
62 return (GLubyte *)DRIVER_AUTHOR;
63
64 case GL_RENDERER:
65 switch(nmesa->screen->card_type)
66 {
67 case NV_03:
68 card_name="Riva 128";
69 break;
70 case NV_04:
71 card_name="TNT";
72 break;
73 case NV_05:
74 card_name="TNT2";
75 break;
76 case NV_10:
77 card_name="GeForce 1/2/4Mx";
78 break;
79 case NV_20:
80 card_name="GeForce 3/4Ti";
81 break;
82 case NV_30:
83 card_name="GeForce FX 5x00";
84 break;
85 case NV_40:
86 card_name="GeForce FX 6x00";
87 break;
88 case G_70:
89 card_name="GeForce FX 7x00";
90 break;
91 default:
92 break;
93 }
94
95 switch(nmesa->screen->bus_type)
96 {
97 case NV_PCI:
98 case NV_PCIE:
99 default:
100 agp_mode=0;
101 break;
102 case NV_AGP:
103 nmesa->screen->agp_mode;
104 break;
105 }
106 driGetRendererString( buffer, card_name, DRIVER_DATE,
107 agp_mode );
108 return (GLubyte *)buffer;
109 default:
110 return NULL;
111 }
112 }
113
114 /* glFlush */
115 static void nouveauFlush( GLcontext *ctx )
116 {
117 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
118 FIRE_RING( nmesa );
119 }
120
121 /* glFinish */
122 static void nouveauFinish( GLcontext *ctx )
123 {
124 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
125 nouveauFlush( ctx );
126 nouveauWaitForIdle( nmesa );
127 }
128
129 /* glClear */
130 static void nouveauClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
131 GLint cx, GLint cy, GLint cw, GLint ch )
132 {
133 // XXX we really should do something here...
134 }
135
136 void nouveauDriverInitFunctions( struct dd_function_table *functions )
137 {
138 functions->GetBufferSize = nouveauGetBufferSize;
139 functions->ResizeBuffers = _mesa_resize_framebuffer;
140 functions->GetString = nouveauGetString;
141 functions->Flush = nouveauFlush;
142 functions->Finish = nouveauFinish;
143 functions->Clear = nouveauClear;
144 }
145