aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/emgd/include/igd_render.h
blob: 0323d6df49219488c1dbee430f6f61733d492734 (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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
/* -*- pse-c -*-
 *-----------------------------------------------------------------------------
 * Filename: igd_render.h
 * $Revision: 1.10 $
 *-----------------------------------------------------------------------------
 * 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 is a header file for the Intel GFX commands.
 *  This includes commands specific to Intel hardware and structures specific
 *  to Intel hardware.  All other commands and structures are available
 *  through GFX.
 *-----------------------------------------------------------------------------
 */

#ifndef _IGD_RENDER_H
#define _IGD_RENDER_H

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

/*
 * Flags passed to 2d and 3d render functions.
 * Note: These flags MUST not conflict the the blend flags in igd_blend.h
 */
#define IGD_RENDER_BLOCK       0x00000000
#define IGD_RENDER_NONBLOCK    0x00000001
/* Render to Framebuffer: Causes a flush afterward */
#define IGD_RENDER_FRAMEBUFFER 0x00000002
/* Should this be an immediate blit? */
#define IGD_RENDER_IMMEDIATE   0x00000004
/* Render should prevent on-screen tearing */
#define IGD_RENDER_NOTEAR      0x00000008

/*
 * Command priority for use with 2d and 3d render functions.
 */
#define IGD_PRIORITY_NORMAL    0x0
#define IGD_PRIORITY_INTERRUPT 0x1
#define IGD_PRIORITY_POWER     0x2
#define IGD_PRIORITY_BIN       0x3
#define IGD_PRIORITY_BB        0x4


typedef struct _igd_palette_info {
	unsigned long *palette;
	int palette_id;
	int palette_type;
	int size;
} igd_palette_info_t, *pigd_palette_info_t;

/*
 *
 * 2D blit => igd_coord + igd_surface => igd_rect + igd_surface
 * 3D blend => (igd_rect + igd_surface + igd_rect)*n => igd_rect + igd_surface
 *   Blend: N source surfaces with a source rect.
 *          N destination rects.
 *          1 Destination surface.
 *          1 Destination clip rect.
 */

typedef struct _igd_coord {
	unsigned int x;
	unsigned int y;
} igd_coord_t, *pigd_coord_t;

typedef struct _igd_rect {
	unsigned int x1;
	unsigned int y1;
	unsigned int x2;
	unsigned int y2;
} igd_rect_t, *pigd_rect_t;

typedef struct _igd_surface {
	unsigned long offset;
	unsigned int pitch;
	unsigned int width;
	unsigned int height;
	unsigned long u_offset;     /* Needed for YUV Planar modes. */
	unsigned int u_pitch;      /* Needed for YUV Planar modes. */
	unsigned long v_offset;     /* Needed for YUV Planar modes. */
	unsigned int v_pitch;      /* Needed for YUV Planar modes. */
	unsigned long pixel_format;
	igd_palette_info_t *palette_info;
	unsigned long flags;        /* GMM Alignment flags (igd_gmm.h) */
	unsigned int logic_ops;
	unsigned int render_ops;
	unsigned int alpha;        /* Global Alpha:
								*  Surface is modulated by alpha prior
								*  to blend. Used with IGD_RENDER_OP_ALPHA.
								*  Used exclusive of diffuse which contains
								*  a full ARGB value.
								*/
	unsigned int diffuse;      /* Diffuse Color:
								*   Use with IGD_RENDER_OP_DIFFUSE.
								*  Used with alpha-only surfaces or
								*  constants color surfaces.
								*/
	unsigned long chroma_high; /* Drop pixels between low and high */
	unsigned long chroma_low;
	unsigned char *virt_addr;   /* Virtual memory address to be used for
								 * either Sys Mem to Vid Mem BLT operations
								 * or for per surface virtual memory.
								 */
	void *pvr2d_mem_info;    /* memory information, intended to be used only 
								* by kernel, that allows access to surface memory
								* from variety of device memory perpectives.
								*/

	void *pvr2d_context_h;   /* TODO: This needs to be moved to the appcontext and needs to be 
								accessible by blend */

	unsigned long FlipChainID;
	void * hPVR2DFlipChain;

	/* TODO: remove floating point use from code used by kernel.  who needs this??? */
	/* We do!! This is how these parameters are passed in to blend. 
	   They are not processed on kernel side. */
	float proc_amp_const[6];     /* Video ProcAmpControl parameter */
} igd_surface_t, *pigd_surface_t;

typedef struct _igd_surface_list {
    unsigned long offset;
    unsigned long size;
} igd_surface_list_t, *pigd_surface_list_t;

/*!
 * @name Surface Render Ops
 * @anchor render_ops
 *
 * These flags apply to a surface and indicate features of the surface
 * that should be considered during render operations such as
 * _igd_dispatch::blend()
 *
 * - IGD_RENDER_OP_BLEND: This surface should be blended with other
 *  surfaces during rendering. In calls to _igd_dispatch::blend() this
 *  surface will blend with those below it in the stack or the destination
 *  surface (when the surface is the bottom-most in the stack).
 *   Note: xRGB surfaces used with this render op will convert to ARGB
 *   surfaces with an alpha of 1.0. Without this render op xRGB surfaces
 *   will preserve the x value from the source.
 *
 * - IGD_RENDER_OP_PREMULT: The surface contains a pre-multipled alpha
 *  value. This indicates that the per-pixel color values have already been
 *  multipled by the per-pixel alpha value. Without this bit set it is
 *  necessary to perform this multiplication as part of a blend operation.
 *
 * - IGD_RENDER_OP_ALPHA: The surface contains a global alpha. All pixel
 *  values are multiplied against the global alpha as part of any blend
 *  operation. Global alpha is used exclusive of Diffuse color.
 *
 * - IGD_RENDER_OP_DIFFUSE: The surface contains a single diffuse color.
 *  This flag is used with alpha-only surfaces or surfaces of constant
 *  color. Diffuse is used exclusively of Global Alpha.
 *
 * - IGD_RENDER_OP_CHROMA: THe surface contains a chroma-key. Pixel
 *  values between  chroma_high and chroma_low will be filtered out.
 *
 * - IGD_RENDER_OP_COLORKEY: The surface contains a colorkey. This is used
 *  on mask surfaces to indicate the location of pixels that may be drawn
 *  on the destination. Only pixels with values between chroma_high and
 *  chroma_low should "pass through" the mask to the destination. Other pixels
 *  will be filered out.
 *
 * @{
 */

#define IGD_RENDER_OP_BLEND      0x1
#define IGD_RENDER_OP_PREMULT    0x2
#define IGD_RENDER_OP_ALPHA      0x4
#define IGD_RENDER_OP_DIFFUSE    0x8
#define IGD_RENDER_OP_CHROMA     0x20
#define IGD_RENDER_OP_COLORKEY   0x40

/*
 * Make sure rotate and flip flags are not moved. Blend uses them as
 * array indexes
 */
#define IGD_RENDER_OP_ROT_MASK   0x000300
#define IGD_RENDER_OP_ROT_0      0x000000
#define IGD_RENDER_OP_ROT_90     0x000100
#define IGD_RENDER_OP_ROT_180    0x000200
#define IGD_RENDER_OP_ROT_270    0x000300
#define IGD_RENDER_OP_FLIP       0x000400
#define IGD_RENDER_OP_SKIP_ROT	 0x000800

/*
 * flags for post process - Deinterlacing and ProcAmpControl.
 */
#define IGD_RENDER_OP_INTERLACED 0x00001000
#define IGD_RENDER_OP_BOB_EVEN   0x00002000
#define IGD_RENDER_OP_BOB_ODD    0x00004000
#define IGD_RENDER_OP_PROCAMP    0x00010000

/*
 * Region structure. Holds information about non-surface memory
 * allocations.
 */

#define IGD_REGION_UNFINISHED 0x00000000
#define IGD_REGION_READY      0x00000001
#define IGD_REGION_QUEUED     0x00000002
#define IGD_REGION_ABANDONED  0x00000004

typedef struct _igd_region {
	unsigned long offset;
	char *virt;
	unsigned long size;
	unsigned long type;
	unsigned long flags;
} igd_region_t;
/* @} */

typedef struct _igd_dma {
	unsigned long offset;
	char *virt;
	unsigned long size;
	unsigned long head;
	unsigned long flags;
	/* unsigned long phys;
		- currently not used - maybe needed in future */
} igd_dma_t;

/*
 * Functions for setting/getting the surface information for the
 * Display, Color, Depth, and Aux buffers for a display.
 */
typedef enum _igd_buffertype {
	IGD_BUFFER_DISPLAY = 0,
	IGD_BUFFER_COLOR,
	IGD_BUFFER_DEPTH
} igd_buffertype_t;

/*----------------------------------------------------------------------
 * Typedef: _igd_get_suface_fn_t
 *
 * Description:
 *  This function, available from the top-level igd_dispatch_t as
 *  get_surface(), allows the client to query the parameters for
 *  the display, color, depth, and aux buffers for a given display.
 *
 * Parameters:
 *  display_handle - Handle for the requested display.
 *
 *  type - One of the igd_buffertype_t enums.
 *
 *  surface - An igd_surface_t to return the information in.
 *
 * Returns:
 *  0: Success
 *  < 0: Error
 *----------------------------------------------------------------------
 */
typedef int (*_igd_get_surface_fn_t)(
	igd_display_h display_handle,
	igd_buffertype_t type,
	igd_surface_t *surface,
	igd_appcontext_h appcontext);

/*----------------------------------------------------------------------
 * Typedef: _igd_set_suface_fn_t
 *
 * Description:
 *  This function, available from the top-level igd_dispatch_t as
 *  set_surface(), allows the client to set the parameters for
 *  the display, color, and depth buffers for a given display.
 *
 *  This command will happen asynchronously when possible. It will
 *  be placed in the command stream and will happen at some point
 *  after the command is parsed (The next vblank if it is the display
 *  buffer)
 *
 *  When setting the depth buffer the setting will not take place
 *  until the next color buffer set. Therefore when changing the
 *  color buffer the depth buffer should always be changed first.
 *
 *  If set_surface has been used to change the displayed surface, the
 *  original framebuffer should be replaced before changing modes.
 *
 * Parameters:
 *  display_handle - Handle for the requested display.
 *
 *  priority - The priority for the command.
 *
 *  type - One of the igd_buffertype_t enums.
 *
 *  flags - Additional bitfield of options for buffer.
 *
 *  surface - An igd_surface_t that contains the parameters to apply.
 *
 * Returns:
 *  0: Success
 *  < 0: Error
 *----------------------------------------------------------------------
 */
#define IGD_BUFFER_ZERO_BIAS 0x1
#define IGD_BUFFER_FIXED_Z   0x2
#define IGD_BUFFER_ASYNC     0x4
/* Issue a Wait for last flip only, do not flip again */
#define IGD_BUFFER_WAIT      0x8

/* ------ WARNING!!!! Read Before Changing ------ */
/*    Command should always be 32 Bit on all platforms including 64 bit */
/*    Int is assumed to be 32 bit on all the supported platforms */
typedef unsigned int igd_command_t;

typedef int (*_igd_set_surface_fn_t)(
	igd_display_h display_handle,
	int priority,
	igd_buffertype_t type,
	igd_surface_t *surface,
	igd_appcontext_h appcontext,
	unsigned long flags);

typedef enum _igd_event {
	IGD_EVENT_FLIP_PENDING = 1
} igd_event_t;

typedef int (*_igd_query_event_fn_t)(
	igd_display_h display_handle,
	igd_event_t event,
	unsigned long *status);

/*----------------------------------------------------------------------
 * Typedef: _igd_alloc_ring_fn_t
 *
 * Description:
 *
 * Parameters:
 *  display_handle - Handle for the requested display.
 *
 *  flags - IGD_ALLOC_PRIORITY_*
 *
 * Returns:
 *  0: Success
 *  < 0: Error
 *----------------------------------------------------------------------
 */
typedef int (*_igd_alloc_ring_fn_t)(
	igd_display_h display_handle,
	unsigned long flags);


/*----------------------------------------------------------------------
 * Typedef: _igd_exec_buffer_fn_t
 *
 * Description:
 *  This function allows a privelidged IAL to place instructions directly
 * into the HAL's command queue. Under normal circumstances an IAL does not
 * have the knowledge necessary to do this; however, some IALs (D3D, OGL, MC)
 * will have this knowledge. The contents referenced by the data parameter
 * are device dependent and may be a data structure or other structured
 * information.
 *
 * Parameters:
 *  display_handle - Handle for the requested display.
 *
 *  priority - The priority for the command.
 *
 *  data - Pointer to the device dependent command data or data strucutre.
 *
 *  size - Size in Dwords (4bytes).
 *
 * Returns:
 *  0: Success
 *  < 0: Error
 *----------------------------------------------------------------------
 */
typedef int (*_igd_exec_buffer_fn_t)(
	igd_display_h display_handle,
	int priority,
	igd_appcontext_h appcontext,
	const void *data,
	unsigned long size);

/*----------------------------------------------------------------------
 * Typedef: _igd_query_buffer_fn_t
 *
 * Description:
 * This function allows a privelidged IAL to query Topaz/MSVDX. 
 * Under normal circumstances an IAL does not have the knowledge 
 * necessary to do this; however, some IALs (D3D, OGL, MC)
 * will have this knowledge. The contents referenced by the data parameter
 * are device dependent and may be a data structure or other structured
 * information.
 *
 * Parameters:
 *  in_size - in parameter size.
 *
 *  in_buffer - input buffer.
 *
 *  out_size - out parameter size.
 *
 *  out_buffer - output buffer.
 *
 *  command - query command.
 *
 * Returns:
 *  0: Success
 *  < 0: Error
 *----------------------------------------------------------------------
 */
typedef int (*_igd_query_buffer_fn_t) (
	igd_display_h display_handle,
	void *in_buffer, 
	void *out_buffer,
	unsigned long command);

/*
 * Flags passed to (exclusive) igd_rb_reserve
 * and igd_rb_update functions.
 */
#define IGD_RB_RESERVE_BLOCK     0x00000000
#define IGD_RB_RESERVE_NONBLOCK  0x00000001
#define IGD_RB_CACHELINE_PAD     0x00000002

/*----------------------------------------------------------------------
 * Typedef: _igd_rb_reserve_fn_t
 *
 * Description:
 *  This function allows a privelidged IAL to aquire space directly on
 * the HAL's ring buffer. Under normal circumstances an IAL does not have
 * the knowledge necessary to do this; however, some IALs (D3D, OGL, MC)
 * will have this knowledge.
 *  Any IAL making use of this interface must have full knowledge of all
 * hardware interactions, padding etc that are needed to safely access
 * the ring directly.
 *
 * Parameters:
 *  display_handle - Handle for the requested display.
 *
 *  priority - The priority for the command.
 *
 *  size - Size in Dwords (4bytes).
 *    Setting size to 0 will re-initialize the ring.
 *
 *  block - Blocking or not 1 or 0
 *
 *  addr - Virtual address returned from the call. Caller should begin
 *   writing commands at this address.
 *
 *  avail - The amount (in dwords) of space that is available in the
 *   ring. This is just a hint in case it is helpful to the IAL.
 *
 * Returns:
 *  0: Success
 *  < 0: Error
 *----------------------------------------------------------------------
 */
typedef int (*_igd_rb_reserve_fn_t)(
	igd_display_h display_handle,
	int priority,
	unsigned long size,
	unsigned long flags,
	igd_command_t **addr,
	unsigned long *avail);

/*----------------------------------------------------------------------
 * Typedef: _igd_rb_update_fn_t
 *
 * Description:
 *  This function updates the ring pointer after a call to rb_reserve,
 * and after the command data has been placed in the ring.
 *
 * Parameters:
 *  display_handle - Handle for the requested display. Must be the same
 *   display used with rb_reserve.
 *
 *  priority - The priority for the command. Must be the same priority
 *   used with rb_reserve.
 *
 *  addr - Virtual address after placing the commands into the ring. This
 *   should be equal to the returned addr + size from rb_reserve.
 *
 * Returns:
 *  0: Success
 *  < 0: Error
 *----------------------------------------------------------------------
 */
typedef int (*_igd_rb_update_fn_t)(
	igd_display_h display_handle,
	int priority,
	igd_command_t *addr,
	unsigned long flags);


#endif /* _IGD_RENDER_H */

/*----------------------------------------------------------------------------
 * File Revision History
 * $Id: igd_render.h,v 1.10 2010/07/23 16:54:51 bpaauwe Exp $
 * $Source: /nfs/fm/proj/eia/cvsroot/koheo/linux/egd_drm/include/igd_render.h,v $
 *----------------------------------------------------------------------------
 */