Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 1 | /* Copyright (c) 2002,2007-2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | #ifndef __ADRENO_DRAWCTXT_H |
| 14 | #define __ADRENO_DRAWCTXT_H |
| 15 | |
| 16 | #include "a200_reg.h" |
| 17 | #include "a220_reg.h" |
| 18 | |
| 19 | /* Flags */ |
| 20 | |
| 21 | #define CTXT_FLAGS_NOT_IN_USE 0x00000000 |
| 22 | #define CTXT_FLAGS_IN_USE 0x00000001 |
| 23 | |
| 24 | /* state shadow memory allocated */ |
| 25 | #define CTXT_FLAGS_STATE_SHADOW 0x00000010 |
| 26 | |
| 27 | /* gmem shadow memory allocated */ |
| 28 | #define CTXT_FLAGS_GMEM_SHADOW 0x00000100 |
| 29 | /* gmem must be copied to shadow */ |
| 30 | #define CTXT_FLAGS_GMEM_SAVE 0x00000200 |
| 31 | /* gmem can be restored from shadow */ |
| 32 | #define CTXT_FLAGS_GMEM_RESTORE 0x00000400 |
| 33 | /* shader must be copied to shadow */ |
| 34 | #define CTXT_FLAGS_SHADER_SAVE 0x00002000 |
| 35 | /* shader can be restored from shadow */ |
| 36 | #define CTXT_FLAGS_SHADER_RESTORE 0x00004000 |
| 37 | /* Context has caused a GPU hang */ |
| 38 | #define CTXT_FLAGS_GPU_HANG 0x00008000 |
| 39 | |
| 40 | struct kgsl_device; |
| 41 | struct adreno_device; |
| 42 | struct kgsl_device_private; |
| 43 | struct kgsl_context; |
| 44 | |
| 45 | /* draw context */ |
| 46 | struct gmem_shadow_t { |
| 47 | struct kgsl_memdesc gmemshadow; /* Shadow buffer address */ |
| 48 | |
| 49 | /* 256 KB GMEM surface = 4 bytes-per-pixel x 256 pixels/row x |
| 50 | * 256 rows. */ |
| 51 | /* width & height must be a multiples of 32, in case tiled textures |
| 52 | * are used. */ |
| 53 | enum COLORFORMATX format; |
| 54 | unsigned int size; /* Size of surface used to store GMEM */ |
| 55 | unsigned int width; /* Width of surface used to store GMEM */ |
| 56 | unsigned int height; /* Height of surface used to store GMEM */ |
| 57 | unsigned int pitch; /* Pitch of surface used to store GMEM */ |
| 58 | unsigned int gmem_pitch; /* Pitch value used for GMEM */ |
| 59 | unsigned int *gmem_save_commands; |
| 60 | unsigned int *gmem_restore_commands; |
| 61 | unsigned int gmem_save[3]; |
| 62 | unsigned int gmem_restore[3]; |
| 63 | struct kgsl_memdesc quad_vertices; |
| 64 | struct kgsl_memdesc quad_texcoords; |
| 65 | }; |
| 66 | |
| 67 | struct adreno_context { |
| 68 | uint32_t flags; |
| 69 | struct kgsl_pagetable *pagetable; |
| 70 | struct kgsl_memdesc gpustate; |
| 71 | unsigned int reg_save[3]; |
| 72 | unsigned int reg_restore[3]; |
| 73 | unsigned int shader_save[3]; |
| 74 | unsigned int shader_fixup[3]; |
| 75 | unsigned int shader_restore[3]; |
| 76 | unsigned int chicken_restore[3]; |
| 77 | unsigned int bin_base_offset; |
| 78 | /* Information of the GMEM shadow that is created in context create */ |
| 79 | struct gmem_shadow_t context_gmem_shadow; |
| 80 | }; |
| 81 | |
| 82 | int adreno_drawctxt_create(struct kgsl_device *device, |
| 83 | struct kgsl_pagetable *pagetable, |
| 84 | struct kgsl_context *context, |
| 85 | uint32_t flags); |
| 86 | |
| 87 | void adreno_drawctxt_destroy(struct kgsl_device *device, |
| 88 | struct kgsl_context *context); |
| 89 | |
| 90 | void adreno_drawctxt_switch(struct adreno_device *adreno_dev, |
| 91 | struct adreno_context *drawctxt, |
| 92 | unsigned int flags); |
| 93 | void adreno_drawctxt_set_bin_base_offset(struct kgsl_device *device, |
| 94 | struct kgsl_context *context, |
| 95 | unsigned int offset); |
| 96 | |
| 97 | #endif /* __ADRENO_DRAWCTXT_H */ |