aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/emgd/emgd/state/appcontext/cmn/igd_appcontext.c
blob: 40e5103244acc78bce26f4a7d9749e76335f211f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* -*- pse-c -*-
 *-----------------------------------------------------------------------------
 * Filename: igd_appcontext.c
 * $Revision: 1.6 $
 *-----------------------------------------------------------------------------
 * Copyright © 2002-2010, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *-----------------------------------------------------------------------------
 * Description:
 *  This file inplements the IGD interface for the context module. This
 *  includes functions that handle hardware context swapping and state
 *  variable management.
 *-----------------------------------------------------------------------------
 */

#define MODULE_NAME hal.state

#include <config.h>

#include <igd_appcontext.h>
#include <igd_gmm.h>
#include <igd_mode.h>
#include <igd_errno.h>

#include <intelpci.h>
#include <context.h>
#include <mode.h>
#include <dispatch.h>

#include <io.h>

#include "appcontext_dispatch.h"

/*!
 * @addtogroup state_group
 * @{
 */

static dispatch_table_t appcontext_dispatch_list[] = {
#ifdef CONFIG_PLB
	{PCI_DEVICE_ID_VGA_PLB, &appcontext_dispatch_plb},
#endif
#ifdef CONFIG_TNC
	{PCI_DEVICE_ID_VGA_TNC, &appcontext_dispatch_plb},
#endif
	{0, NULL}
};

/* Not static: cores may need it */
appcontext_dispatch_t *appcontext_dispatch = NULL;

/*!
 *
 * @param display_handle
 * @param priority
 * @param flags
 *
 * @return appcontext_h
 */
igd_appcontext_h igd_appcontext_alloc(
	igd_display_h display_handle,
	int priority,
	unsigned int flags)
{

	return appcontext_dispatch->appcontext_alloc(
		display_handle, priority, flags);
}

/*!
 *
 * @param display_handle
 * @param priority
 * @param appcontext_handle
 *
 * @return void
 */
void igd_appcontext_free(
	igd_display_h display_handle,
	int priority,
	igd_appcontext_h appcontext_handle)
{
	appcontext_dispatch->appcontext_free(
		display_handle, priority, appcontext_handle);
}

/*!
 *
 * @param context
 *
 * @return void
 */
void appcontext_shutdown(igd_context_t *context)
{

	EMGD_DEBUG("appcontext_shutdown Entry");

	if (appcontext_dispatch != NULL)
	{
		appcontext_dispatch->appcontext_shutdown(context);
	}
}

/*!
 *
 * @param context
 *
 * @return void
 */
int appcontext_init(igd_context_t *context)
{

	EMGD_DEBUG("appcontext_init Entry");

	appcontext_dispatch = (appcontext_dispatch_t *)dispatch_acquire(context,
		appcontext_dispatch_list);
	if(!appcontext_dispatch) {
		return -IGD_ERROR_NODEV;
	}

	/* Hook up top level dispatch table */
	context->dispatch.appcontext_alloc = appcontext_dispatch->appcontext_alloc;
	context->dispatch.appcontext_free = appcontext_dispatch->appcontext_free;

	/* Hook up optional inter-module functions */
	context->mod_dispatch.appcontext_shutdown = appcontext_shutdown;

	return 0;
}

/*----------------------------------------------------------------------------
 * File Revision History
 * $Id: igd_appcontext.c,v 1.6 2010/07/23 16:54:50 bpaauwe Exp $
 * $Source: /nfs/fm/proj/eia/cvsroot/koheo/linux/egd_drm/emgd/state/appcontext/cmn/igd_appcontext.c,v $
 *----------------------------------------------------------------------------
 */