1 /**************************************************************************
3 Copyright 2006 Stephane Marchesin
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:
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
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.
25 **************************************************************************/
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"
35 #include "framebuffer.h"
39 /* Wrapper for DRM_NOUVEAU_GETPARAM ioctl */
40 GLboolean
nouveauDRMGetParam(nouveauContextPtr nmesa
,
44 struct drm_nouveau_getparam getp
;
47 if (!value
|| drmCommandWriteRead(nmesa
->driFd
, DRM_NOUVEAU_GETPARAM
,
54 /* Wrapper for DRM_NOUVEAU_GETPARAM ioctl */
55 GLboolean
nouveauDRMSetParam(nouveauContextPtr nmesa
,
59 struct drm_nouveau_setparam setp
;
63 if (drmCommandWrite(nmesa
->driFd
, DRM_NOUVEAU_SETPARAM
, &setp
,
69 /* Return the width and height of the current color buffer */
70 static void nouveauGetBufferSize( GLframebuffer
*buffer
,
71 GLuint
*width
, GLuint
*height
)
73 GET_CURRENT_CONTEXT(ctx
);
74 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
76 LOCK_HARDWARE( nmesa
);
77 *width
= nmesa
->driDrawable
->w
;
78 *height
= nmesa
->driDrawable
->h
;
79 UNLOCK_HARDWARE( nmesa
);
83 static const GLubyte
*nouveauGetString( GLcontext
*ctx
, GLenum name
)
85 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
86 static char buffer
[128];
87 const char * card_name
= "Unknown";
92 return (GLubyte
*)DRIVER_AUTHOR
;
95 card_name
=nmesa
->screen
->card
->name
;
97 switch(nmesa
->screen
->bus_type
)
105 agp_mode
=nmesa
->screen
->agp_mode
;
108 driGetRendererString( buffer
, card_name
, DRIVER_DATE
,
110 return (GLubyte
*)buffer
;
117 static void nouveauFlush( GLcontext
*ctx
)
119 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
124 static void nouveauFinish( GLcontext
*ctx
)
126 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
128 nouveauWaitForIdle( nmesa
);
132 static void nouveauClear( GLcontext
*ctx
, GLbitfield mask
)
134 // XXX we really should do something here...
137 void nouveauDriverInitFunctions( struct dd_function_table
*functions
)
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
;