1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright (C) 2009 Francisco Jerez.
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved.
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * a copy of this software and associated documentation files (the
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sublicense, and/or sell copies of the Software, and to
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * portions of the Software.
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef __NOUVEAU_DRIVER_H__
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define __NOUVEAU_DRIVER_H__
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/imports.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/mtypes.h"
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/macros.h"
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/formats.h"
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/state.h"
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "utils.h"
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "dri_util.h"
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#undef NDEBUG
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include <assert.h>
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include <libdrm/nouveau.h>
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nouveau_screen.h"
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nouveau_state.h"
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nouveau_surface.h"
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "nouveau_local.h"
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define DRIVER_AUTHOR	"Nouveau"
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct nouveau_driver {
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	struct gl_context *(*context_create)(struct nouveau_screen *screen,
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				     const struct gl_config *visual,
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org				     struct gl_context *share_ctx);
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	void (*context_destroy)(struct gl_context *ctx);
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	void (*surface_copy)(struct gl_context *ctx,
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     struct nouveau_surface *dst,
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     struct nouveau_surface *src,
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     int dx, int dy, int sx, int sy, int w, int h);
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	void (*surface_fill)(struct gl_context *ctx,
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     struct nouveau_surface *dst,
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     unsigned mask, unsigned value,
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     int dx, int dy, int w, int h);
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	nouveau_state_func *emit;
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	int num_emit;
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define nouveau_error(format, ...) \
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org	fprintf(stderr, "%s: " format, __func__, ## __VA_ARGS__)
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_clear(struct gl_context *ctx, GLbitfield buffers);
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_span_functions_init(struct gl_context *ctx);
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_driver_functions_init(struct dd_function_table *functions);
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnouveau_texture_functions_init(struct dd_function_table *functions);
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
84