psb_surface.h revision 09998e330bbcbf835798128768e590772f5a5737
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 * Waldo Bastian <waldo.bastian@intel.com> 27 */ 28 29#ifndef _PSB_SURFACE_H_ 30#define _PSB_SURFACE_H_ 31 32#include <va/va.h> 33#include "psb_buffer.h" 34//#include "xf86mm.h" 35 36/* MSVDX specific */ 37typedef enum { 38 STRIDE_352 = 0, 39 STRIDE_720 = 1, 40 STRIDE_1280 = 2, 41 STRIDE_1920 = 3, 42 STRIDE_512 = 4, 43 STRIDE_1024 = 5, 44 STRIDE_2048 = 6, 45 STRIDE_4096 = 7, 46 STRIDE_NA, 47 STRIDE_UNDEFINED, 48} psb_surface_stride_t; 49 50typedef struct psb_surface_s *psb_surface_p; 51 52struct psb_surface_s { 53 struct psb_buffer_s buf; 54 struct psb_buffer_s *in_loop_buf; 55 struct psb_buffer_s *ref_buf; 56 psb_surface_stride_t stride_mode; 57 int stride; 58 unsigned int luma_offset; 59 unsigned int chroma_offset; 60 /* Used to store driver private data, e.g. decoder specific intermediate status data 61 * extra_info[0-3]: used for decode 62 * extra_info[4]: surface fourcc 63 * extra_info[5]: surface skippeded or not for encode, rotate info for decode 64 * extra_info[6]: mfld protected surface 65 */ 66 int extra_info[8]; 67 int size; 68 unsigned int bc_buffer; 69}; 70 71/* 72 * Create surface 73 */ 74VAStatus psb_surface_create(psb_driver_data_p driver_data, 75 int width, int height, int fourcc, int protected, 76 psb_surface_p psb_surface /* out */ 77 ); 78 79VAStatus psb_surface_create_for_userptr( 80 psb_driver_data_p driver_data, 81 int width, int height, 82 unsigned size, /* total buffer size need to be allocated */ 83 unsigned int fourcc, /* expected fourcc */ 84 unsigned int luma_stride, /* luma stride, could be width aligned with a special value */ 85 unsigned int chroma_u_stride, /* chroma stride */ 86 unsigned int chroma_v_stride, 87 unsigned int luma_offset, /* could be 0 */ 88 unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */ 89 unsigned int chroma_v_offset, 90 psb_surface_p psb_surface /* out */ 91); 92 93VAStatus psb_surface_create_from_kbuf( 94 psb_driver_data_p driver_data, 95 int width, int height, 96 unsigned size, /* total buffer size need to be allocated */ 97 unsigned int fourcc, /* expected fourcc */ 98 int kbuf_handle, /*kernel handle */ 99 unsigned int luma_stride, /* luma stride, could be width aligned with a special value */ 100 unsigned int chroma_u_stride, /* chroma stride */ 101 unsigned int chroma_v_stride, 102 unsigned int luma_offset, /* could be 0 */ 103 unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */ 104 unsigned int chroma_v_offset, 105 psb_surface_p psb_surface /* out */ 106); 107 108 109VAStatus psb_surface_create_camera(psb_driver_data_p driver_data, 110 int width, int height, int stride, int size, 111 psb_surface_p psb_surface, /* out */ 112 int is_v4l2, 113 unsigned int id_or_ofs 114 ); 115 116/* id_or_ofs: it is frame ID or frame offset in camear device memory 117 * for CI frame: it it always frame offset currently 118 * for v4l2 buf: it is offset used in V4L2 buffer mmap 119 * user_ptr: virtual address of user buffer. 120 */ 121VAStatus psb_surface_create_camera_from_ub(psb_driver_data_p driver_data, 122 int width, int height, int stride, int size, 123 psb_surface_p psb_surface, /* out */ 124 int is_v4l2, 125 unsigned int id_or_ofs, 126 const unsigned long *user_ptr); 127 128/* 129 * Temporarily map surface and set all chroma values of surface to 'chroma' 130 */ 131VAStatus psb_surface_set_chroma(psb_surface_p psb_surface, int chroma); 132 133/* 134 * Destroy surface 135 */ 136void psb_surface_destroy(psb_surface_p psb_surface); 137 138/* 139 * Wait for surface to become idle 140 */ 141VAStatus psb_surface_sync(psb_surface_p psb_surface); 142 143/* 144 * Return surface status 145 */ 146VAStatus psb_surface_query_status(psb_surface_p psb_surface, VASurfaceStatus *status); 147 148/* 149 * Set current displaying surface info to kernel 150 */ 151int psb_surface_set_displaying(psb_driver_data_p driver_data, 152 int width, int height, 153 psb_surface_p psb_surface); 154 155#endif /* _PSB_SURFACE_H_ */ 156