Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the
      6  * "Software"), to deal in the Software without restriction, including
      7  * without limitation the rights to use, copy, modify, merge, publish,
      8  * distribute, sub license, and/or sell copies of the Software, and to
      9  * permit persons to whom the Software is furnished to do so, subject to
     10  * the following conditions:
     11  *
     12  * The above copyright notice and this permission notice (including the
     13  * next paragraph) shall be included in all copies or substantial portions
     14  * of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
     19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
     20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     23  *
     24  * Authors:
     25  *    Binglin Chen <binglin.chen (at) intel.com>
     26  *
     27  */
     28 
     29 #ifndef _VSP_CMDBUF_H_
     30 #define _VSP_CMDBUF_H_
     31 
     32 #include <wsbm/wsbm_manager.h>
     33 
     34 #include "psb_drv_video.h"
     35 #include "psb_buffer.h"
     36 
     37 struct vsp_cmdbuf_s {
     38 	struct psb_buffer_s buf;
     39 	unsigned int size;
     40 
     41 	/* Relocation records */
     42 	unsigned char *reloc_base;
     43 	struct drm_psb_reloc *reloc_idx;
     44 
     45 	/* CMD stream data */
     46 	int cmd_count;
     47 	unsigned char *cmd_base;
     48 	unsigned char *cmd_start;
     49 	unsigned int *cmd_idx;
     50 
     51 	int param_mem_loc;
     52 
     53 	/* Referenced buffers */
     54 	psb_buffer_p *buffer_refs;
     55 	int buffer_refs_count;
     56 	int buffer_refs_allocated;
     57 
     58 	struct psb_buffer_s param_mem;
     59 	unsigned char *param_mem_p;
     60 	unsigned char *pic_param_p;
     61 	unsigned char *seq_param_p;
     62 	unsigned char *end_param_p;
     63 	unsigned char *pipeline_param_p;
     64 	unsigned char *denoise_param_p;
     65 	unsigned char *enhancer_param_p;
     66 	unsigned char *sharpen_param_p;
     67 	unsigned char *frc_param_p;
     68 	unsigned char *ref_param_p;
     69 	unsigned char *compose_param_p;
     70 };
     71 
     72 typedef struct vsp_cmdbuf_s *vsp_cmdbuf_p;
     73 
     74 #define VSP_RELOC_CMDBUF(dest, offset, buf) vsp_cmdbuf_add_relocation(cmdbuf, (uint32_t*)(dest), buf, offset, 0XFFFFFFFF, 0, 0, 0, (uint32_t *)cmdbuf->cmd_start)
     75 
     76 /**
     77  * VSP command:
     78  * context
     79  * type
     80  * buffer
     81  * size
     82  * buffer_id
     83  * irq
     84  * reserved6
     85  * reserved7
     86  */
     87 /* operation number is inserted by DRM */
     88 #define vsp_cmdbuf_insert_command(cmdbuf,context_id, ref_buf,type,offset,size)	\
     89 	do { *cmdbuf->cmd_idx++ = context_id; *cmdbuf->cmd_idx++ = type;\
     90 	     VSP_RELOC_CMDBUF(cmdbuf->cmd_idx++, offset, ref_buf);\
     91 	     *cmdbuf->cmd_idx++ = size; *cmdbuf->cmd_idx++ = 0;\
     92 	     *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = 0; \
     93 	     *cmdbuf->cmd_idx++ = wsbmKBufHandle(wsbmKBuf((ref_buf)->drm_buf));} while(0)
     94 
     95 
     96 #define vsp_cmdbuf_reloc_pic_param(pic_param_dest,offset,ref_buf, dst_buf_loc, pic_param_buf_start)	\
     97 	do { vsp_cmdbuf_add_relocation(cmdbuf, (uint32_t*)(pic_param_dest), ref_buf, offset, 0XFFFFFFFF, 0, 0, dst_buf_loc,(uint32_t *)pic_param_buf_start); } while(0)
     98 #define vsp_cmdbuf_fence_pic_param(cmdbuf, pic_param_handler) \
     99 	do { *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = VspFencePictureParamCommand; *cmdbuf->cmd_idx++ = pic_param_handler; *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = 0;} while(0)
    100 
    101 #define vsp_cmdbuf_vpp_context(cmdbuf, type, buffer, size) \
    102 	do { *cmdbuf->cmd_idx++ = VSP_API_GENERIC_CONTEXT_ID; \
    103 	     *cmdbuf->cmd_idx++ = type; \
    104 	     *cmdbuf->cmd_idx++ = buffer; \
    105 	     *cmdbuf->cmd_idx++ = size; \
    106 	     *cmdbuf->cmd_idx++ = 0; \
    107 	     *cmdbuf->cmd_idx++ = 0; \
    108 	     *cmdbuf->cmd_idx++ = 0; *cmdbuf->cmd_idx++ = 0;} while(0)
    109 
    110 #define vsp_cmdbuf_fence_compose_param(cmdbuf, pic_param_handler) \
    111 	do { \
    112 		*cmdbuf->cmd_idx++ = 0; \
    113 		*cmdbuf->cmd_idx++ = VspFenceComposeCommand; \
    114 		*cmdbuf->cmd_idx++ = pic_param_handler; \
    115 		*cmdbuf->cmd_idx++ = 0; \
    116 		*cmdbuf->cmd_idx++ = 0; \
    117 		*cmdbuf->cmd_idx++ = 0; \
    118 		*cmdbuf->cmd_idx++ = 0; \
    119 		*cmdbuf->cmd_idx++ = 0; \
    120 	} while(0)
    121 
    122 #define vsp_cmdbuf_compose_end(cmdbuf) \
    123 	do { *cmdbuf->cmd_idx++ = 0; \
    124 	     *cmdbuf->cmd_idx++ = VssWiDi_ComposeEndOfSequenceCommand; \
    125 	     *cmdbuf->cmd_idx++ = 0; \
    126 	     *cmdbuf->cmd_idx++ = 0; \
    127 	     *cmdbuf->cmd_idx++ = 0; \
    128 	     *cmdbuf->cmd_idx++ = 0; \
    129 	     *cmdbuf->cmd_idx++ = 0; \
    130 	     *cmdbuf->cmd_idx++ = 0;} while(0)
    131 
    132 /*
    133  * Create command buffer
    134  */
    135 VAStatus vsp_cmdbuf_create(object_context_p obj_context,
    136                            psb_driver_data_p driver_data,
    137                            vsp_cmdbuf_p cmdbuf
    138 	);
    139 
    140 /*
    141  * Destroy buffer
    142  */
    143 void vsp_cmdbuf_destroy(vsp_cmdbuf_p cmdbuf);
    144 
    145 /*
    146  * Reset buffer & map
    147  *
    148  * Returns 0 on success
    149  */
    150 int vsp_cmdbuf_reset(vsp_cmdbuf_p cmdbuf);
    151 
    152 /*
    153  * Unmap buffer
    154  *
    155  * Returns 0 on success
    156  */
    157 int vsp_cmdbuf_unmap(vsp_cmdbuf_p cmdbuf);
    158 
    159 /*
    160  * Advances "obj_context" to the next cmdbuf
    161  *
    162  * Returns 0 on success
    163  */
    164 int vsp_context_get_next_cmdbuf(object_context_p obj_context);
    165 
    166 /*
    167  * Submits the current cmdbuf
    168  *
    169  * Returns 0 on success
    170  */
    171 int vsp_context_submit_cmdbuf(object_context_p obj_context);
    172 
    173 /*
    174  * Flushes the pending cmdbuf
    175  *
    176  * Return 0 on success
    177  */
    178 int vsp_context_flush_cmdbuf(object_context_p obj_context);
    179 
    180 void vsp_cmdbuf_add_relocation(vsp_cmdbuf_p cmdbuf,
    181                                uint32_t *addr_in_dst_buffer,
    182                                psb_buffer_p ref_buffer,
    183                                uint32_t buf_offset,
    184                                uint32_t mask,
    185                                uint32_t background,
    186                                uint32_t align_shift,
    187                                uint32_t dst_buffer,
    188                                uint32_t *start_of_dst_buffer);
    189 int vsp_cmdbuf_buffer_ref(vsp_cmdbuf_p cmdbuf, psb_buffer_p buf);
    190 
    191 #endif /* _VSP_CMDBUF_H_ */
    192