~gma500/emgd/trunk

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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/* -*- pse-c -*-
 *-----------------------------------------------------------------------------
 * Filename: igd_interrupt.h
 * $Revision: 1.2 $
 *-----------------------------------------------------------------------------
 * INTEL CONFIDENTIAL
 * Copyright (2002-2008) Intel Corporation All Rights Reserved.
 * The source code contained or described herein and all documents related to
 * the source code ("Material") are owned by Intel Corporation or its suppliers
 * or licensors. Title to the Material remains with Intel Corporation or its
 * suppliers and licensors. The Material contains trade secrets and proprietary
 * and confidential information of Intel or its suppliers and licensors. The
 * Material is protected by worldwide copyright and trade secret laws and
 * treaty provisions. No part of the Material may be used, copied, reproduced,
 * modified, published, uploaded, posted, transmitted, distributed, or
 * disclosed in any way without Intel's prior express written permission.
 * 
 * No license under any patent, copyright, trade secret or other intellectual
 * property right is granted to or conferred upon you by disclosure or
 * delivery of the Materials, either expressly, by implication, inducement,
 * estoppel or otherwise. Any license under such intellectual property rights
 * must be express and approved by Intel in writing.
 * 
 * 
 *-----------------------------------------------------------------------------
 * Description:
 *  The is the IGD exported interrupt access functions. It should be included
 *  by client drivers making use of interrupt functionality of IGD.
 *  This file Should NOT be included by any IGD modules because in some
 *  IGD environments the interrupt module will not be available.
 *-----------------------------------------------------------------------------
 * Authors:
 *  Matt Sottek <matthew.j.sottek@intel.com>
 *-----------------------------------------------------------------------------
 */

#ifndef _IGD_INTERRUPT_H
#define _IGD_INTERRUPT_H

#include <igd_mode.h>

typedef struct _oal_callbacks {

	void (*spin_lock_irqsave)(void *lock);
	void (*spin_unlock_irqrestore)(void *lock);
	void (*spin_lock_isr)(void *lock);
	void (*spin_unlock_isr)(void *lock);
	void (*spin_lock)(void *lock);
	void (*spin_unlock)(void *lock);
} oal_callbacks_t;

#define CB_FUNC(a, b, c) if(a && a->b) { a->b(c); }

/* Responses returned to the client from drm */
#define INT_INVALID  -1
#define INT_NOOP      0
#define INT_CLEARED   1
#define INT_HANDLED   2
#define INT_READ      3
#define INT_STORED    4
#define INT_TIMEOUT   5

/* Response from the ISR helper to the ISR routine */
#define ISR_NEED_DPC  0
#define ISR_HANDLED   1
#define ISR_NOT_OURS  2

typedef struct _interrupt_data {

	void *irqmask_lock;

	unsigned char *msvdx_reg;
	unsigned long sgx_irq_mask;
	unsigned long sgx_irq_mask2;
	unsigned long vdc_irq_mask;
	unsigned long msvdx_irq_mask;
	int irq_enabled;

	/* condition to wake up on */
	unsigned int event_present;

	/* interrupts that have already occured */
	unsigned int out_vdc;

	unsigned int out_sgx;
	unsigned int out_sgx2;

	unsigned int out_mtx;
} interrupt_data_t;


/*----------------------------------------------------------------------
 * Typedef: igd_interrupt_handler_t
 *
 * Description:
 *  This function type is used for OS independent interrupt handlers
 *  that will be called by the hal to handle a requested interrupt.
 *
 * Members:
 *
 *----------------------------------------------------------------------
 */
typedef void (igd_interrupt_handler_t)(unsigned long type,
	void *call_data,
	void *user_data);


/*----------------------------------------------------------------------
 * Typedef: igd_interrupt_t
 *
 * Description:
 *  An opaque handle to identify an interrupt to be handled
 *
 * Members:
 *
 *----------------------------------------------------------------------
 */
typedef void * igd_interrupt_t;

#define IGD_INTERRUPT_VBLANK 0x1
#define IGD_INTERRUPT_SYNC   0x2

/*----------------------------------------------------------------------
 * Function:
 *  isr_helper
 *
 * Description:
 *  This function helps the OAL/DRM module in doing all chipset specific
 *  functionality like register sets when an ISR is fired
 * Parameters:
 *	void
 * Returns:
 *  int - 0 on the interrupt was handled and we need to queue a DPC for it
 *      - 1 on the interrupt was handled but wasn't one to do further
 *          processing on
 *      - 2 on failure
 *----------------------------------------------------------------------
 */
int isr_helper(void);

/*----------------------------------------------------------------------
 * Function:
 *  unmask_int_helper
 *
 * Description:
 *  This function helps the OAL/DRM module in unmasking the Interrupt
 *  registers for a particular chipset so that the Interrupts can start
 *  firing
 * Parameters:
 *	void
 * Returns:
 *  int - 0 on SUCCESS
 *      - 1 on FAILURE
 *----------------------------------------------------------------------
 */
int unmask_int_helper(void);

/*----------------------------------------------------------------------
 * Function:
 *  mask_int_helper
 *
 * Description:
 *  This function helps the OAL/DRM module in masking the Interrupt
 *  registers for a particular chipset so that the Interrupts can stop
 *  firing
 * Parameters:
 *	void
 * Returns:
 *  int - 0 on SUCCESS
 *      - 1 on FAILURE
 *----------------------------------------------------------------------
 */
int mask_int_helper(void);

/*----------------------------------------------------------------------
 * Function:
 *  request_int_info_helper
 *
 * Description:
 *  This function helps the OAL module to request interrupt information 
 *  and status
 * Parameters:
 *	void *int_info_data 
 * Returns:
 *  int -  1 on Interrupt events supported and previous events occured
 *      -  0 on Interrupt events supported but no previous events occured
 *      - -1 on FAILURE or Interrupt events type not supported
 *----------------------------------------------------------------------
 */
int request_int_info_helper(void *int_info_data);

/*----------------------------------------------------------------------
 * Function:
 *  clear_occured_int_helper
 *
 * Description:
 *  This function helps the OAL module to request interrupt information 
 *  and status
 * Parameters:
 *	void *int_info_data 
 * Returns:
 *  void
 *----------------------------------------------------------------------
 */
void clear_occured_int_helper(void *int_info_data);

/*----------------------------------------------------------------------
 * Function:
 *  mask_int_helper
 *
 * Description:
 *  This function helps the OAL/DRM module in clearing the cached copy
 *  of Interrupt data
 * Parameters:
 *	void
 * Returns:
 *	void
 *----------------------------------------------------------------------
 */
void clear_interrupt_cache(void);

/*----------------------------------------------------------------------
 * Function:
 *  dpc_helper
 *
 * Description:
 *  This function helps the OAL/DRM module in doing all chipset specific
 *  functionality like register sets when an DPC is fired
 * Parameters:
 *  interrupt_data_t **int_data
 * Returns:
 *  int - 0 on SUCCESS
 *      - 1 on FAILURE
 *----------------------------------------------------------------------
 */
int dpc_helper(interrupt_data_t **int_data);


/*----------------------------------------------------------------------
 * Function:
 *  interrupt_init
 *
 * Description:
 *  This function initializees the interrupt helper module
 * Parameters:
 *  unsigned short did - Device ID for main video device
 *  oal_callbacks_t *oal_callbacks_table - Callback for
 *              spin lock related functions
 * Returns:
 *  int - 0 on SUCCESS
 *      - 1 on FAILURE
 *----------------------------------------------------------------------
 */
int interrupt_init(unsigned short did,
	oal_callbacks_t *oal_callbacks_table);

/*----------------------------------------------------------------------
 * Function:
 *  pre_init_interrupt
 *
 * Description:
 *  This function helps the OAL/DRM module in doing all chipset specific
 *  functionality like register sets before an ISR is initialized
 * Parameters:
 *  unsigned char *virt_mmadr - The MMIO base address
 * Returns:
 *  void
 *----------------------------------------------------------------------
 */
void pre_init_interrupt(unsigned char *virt_mmadr);

/*----------------------------------------------------------------------
 * Function:
 *  post_init_interrupt
 *
 * Description:
 *  This function helps the OAL/DRM module in doing all chipset specific
 *  functionality like register sets after an ISR is initialized
 * Parameters:
 *  unsigned char *virt_mmadr - The MMIO base address
 * Returns:
 *  void
 *----------------------------------------------------------------------
 */
void post_init_interrupt(unsigned char *virt_mmadr);

/*----------------------------------------------------------------------
 * Function:
 *  uninstall_interrupt
 *
 * Description:
 *  This function helps the OAL/DRM module in doing all chipset specific
 *  functionality like register sets for removing Interrupt support
 * Parameters:
 *  unsigned char *virt_mmadr - The MMIO base address
 * Returns:
 *  void
 *----------------------------------------------------------------------
 */
void uninstall_interrupt(void);

#endif