1 /* 2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved. 3 * Copyright (c) Imagination Technologies Limited, UK 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the 14 * next paragraph) shall be included in all copies or substantial portions 15 * of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 20 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 * 25 * Authors: 26 * Binglin Chen <binglin.chen@intel.com> 27 * Zhaohan Ren <zhaohan.ren@intel.com> 28 * Shengquan Yuan <shengquan.yuan@intel.com> 29 * 30 */ 31 32 #ifndef PSB_TEXTURE_H_ 33 # define PSB_TEXTURE_H_ 34 35 #include "mrst/pvr2d.h" 36 #include <img_types.h> 37 38 #define DRI2_BACK_BUFFER_EXPORT_TYPE_BUFFERS 1 39 #define DRI2_BACK_BUFFER_EXPORT_TYPE_SWAPCHAIN 2 40 41 #define DRI2_FLIP_BUFFERS_NUM 2 42 #define DRI2_BLIT_BUFFERS_NUM 2 43 #define DRI2_MAX_BUFFERS_NUM MAX( DRI2_FLIP_BUFFERS_NUM, DRI2_BLIT_BUFFERS_NUM ) 44 #define VIDEO_BUFFER_NUM 20 45 46 47 typedef struct _psb_coeffs_ { 48 signed char rY; 49 signed char rU; 50 signed char rV; 51 signed char gY; 52 signed char gU; 53 signed char gV; 54 signed char bY; 55 signed char bU; 56 signed char bV; 57 unsigned char rShift; 58 unsigned char gShift; 59 unsigned char bShift; 60 signed short rConst; 61 signed short gConst; 62 signed short bConst; 63 } psb_coeffs_s, *psb_coeffs_p; 64 65 typedef struct _sgx_psb_fixed32 { 66 union { 67 struct { 68 unsigned short Fraction; 69 short Value; 70 }; 71 long ll; 72 }; 73 } sgx_psb_fixed32; 74 75 typedef struct _PVRDRI2BackBuffersExport_ { 76 IMG_UINT32 ui32Type; 77 //pixmap handles 78 PVR2D_HANDLE hBuffers[3]; 79 80 IMG_UINT32 ui32BuffersCount; 81 IMG_UINT32 ui32SwapChainID; 82 } PVRDRI2BackBuffersExport; 83 84 struct psb_texture_s { 85 struct _WsbmBufferObject *vaSrf; 86 87 unsigned int video_transfermatrix; 88 unsigned int src_nominalrange; 89 unsigned int dst_nominalrange; 90 91 uint32_t gamma0; 92 uint32_t gamma1; 93 uint32_t gamma2; 94 uint32_t gamma3; 95 uint32_t gamma4; 96 uint32_t gamma5; 97 98 sgx_psb_fixed32 brightness; 99 sgx_psb_fixed32 contrast; 100 sgx_psb_fixed32 saturation; 101 sgx_psb_fixed32 hue; 102 103 psb_coeffs_s coeffs; 104 105 uint32_t update_coeffs; 106 PVRDRI2BackBuffersExport dri2_bb_export; 107 PVRDRI2BackBuffersExport extend_dri2_bb_export; 108 109 /* struct dri_drawable *extend_dri_drawable; */ 110 /* struct dri_drawable *dri_drawable; */ 111 unsigned char *extend_dri_drawable; 112 unsigned char *dri_drawable; 113 114 uint32_t dri_init_flag; 115 uint32_t extend_dri_init_flag; 116 uint32_t adjust_window_flag; 117 uint32_t current_blt_buffer; 118 119 uint32_t extend_current_blt_buffer; 120 uint32_t destw_save; 121 uint32_t desth_save; 122 uint32_t drawable_update_flag; /* drawable resize or switch between window <==> pixmap */ 123 uint32_t local_rotation_save; 124 uint32_t extend_rotation_save; 125 126 PVR2DMEMINFO *pal_meminfo[6]; 127 PVR2DMEMINFO *blt_meminfo_pixmap; 128 PVR2DMEMINFO *blt_meminfo[DRI2_BLIT_BUFFERS_NUM]; 129 PVR2DMEMINFO *flip_meminfo[DRI2_FLIP_BUFFERS_NUM]; 130 PVR2DMEMINFO *extend_blt_meminfo[DRI2_BLIT_BUFFERS_NUM]; 131 }; 132 133 int psb_ctexture_init(VADriverContextP ctx); 134 135 void psb_ctexture_deinit(VADriverContextP ctx); 136 137 void blit_texture_to_buf(VADriverContextP ctx, unsigned char * data, int src_x, int src_y, int src_w, 138 int src_h, int dst_x, int dst_y, int dst_w, int dst_h, 139 int width, int height, int src_pitch, struct _WsbmBufferObject * src_buf, 140 unsigned int placement); 141 142 void psb_putsurface_textureblit( 143 VADriverContextP ctx, unsigned char *dst, VASurfaceID surface, int src_x, int src_y, int src_w, 144 int src_h, int dst_x, int dst_y, int dst_w, int dst_h, unsigned int subtitle, 145 int width, int height, 146 int src_pitch, struct _WsbmBufferObject * src_buf, 147 unsigned int placement, int wrap_dst); 148 149 #endif /* !PSB_TEXTURE_H_ */ 150