1/************************************************************************** 2 * 3 * Copyright 2013 Advanced Micro Devices, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28#include <tizplatform.h> 29#include <tizkernel.h> 30#include <tizscheduler.h> 31#include <tizport.h> 32#include <tizport_decls.h> 33#include <tizvideoport.h> 34#include <tizvideoport_decls.h> 35 36#include "vid_dec_h264_common.h" 37#include "entrypoint.h" 38#include "h264d.h" 39#include "h264dprc.h" 40#include "h264dinport.h" 41#include "h264e.h" 42#include "h264eprc.h" 43#include "h264einport.h" 44#include "h264eoutport.h" 45#include "names.h" 46 47#include "util/u_debug.h" 48 49DEBUG_GET_ONCE_BOOL_OPTION(mesa_enable_omx_eglimage, 50 "MESA_ENABLE_OMX_EGLIMAGE", 51 false) 52 53static OMX_BOOL egl_image_validation_hook(const OMX_HANDLETYPE ap_hdl, 54 OMX_U32 pid, OMX_PTR ap_eglimage, 55 void *ap_args) 56{ 57 const void * p_krn = NULL; 58 const tiz_port_t * p_port = NULL; 59 60 assert(ap_hdl); 61 assert(ap_eglimage); 62 assert(!ap_args); 63 64 if (!debug_get_option_mesa_enable_omx_eglimage()) { 65 return OMX_FALSE; 66 } 67 68 p_krn = tiz_get_krn(ap_hdl); 69 p_port = tiz_krn_get_port(p_krn, pid); 70 71 const OMX_VIDEO_PORTDEFINITIONTYPE * p_video_portdef 72 = &(p_port->portdef_.format.video); 73 74 if (!p_video_portdef->pNativeWindow) { 75 return OMX_FALSE; 76 } 77 78 return OMX_TRUE; 79} 80 81OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE ap_hdl) 82{ 83 tiz_role_factory_t h264d_role; 84 tiz_role_factory_t h264e_role; 85 const tiz_role_factory_t * rf_list[] = {&h264d_role, &h264e_role}; 86 tiz_type_factory_t h264dprc_type; 87 tiz_type_factory_t h264d_inport_type; 88 tiz_type_factory_t h264eprc_type; 89 tiz_type_factory_t h264e_inport_type; 90 tiz_type_factory_t h264e_outport_type; 91 const tiz_type_factory_t * tf_list[] = {&h264dprc_type, 92 &h264d_inport_type, 93 &h264eprc_type, 94 &h264e_inport_type, 95 &h264e_outport_type}; 96 const tiz_eglimage_hook_t egl_validation_hook = { 97 OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX, 98 egl_image_validation_hook, 99 NULL 100 }; 101 102 /* Settings for roles */ 103 strcpy ((OMX_STRING) h264d_role.role, OMX_VID_DEC_AVC_ROLE); 104 h264d_role.pf_cport = instantiate_h264d_config_port; 105 h264d_role.pf_port[0] = instantiate_h264d_input_port; 106 h264d_role.pf_port[1] = instantiate_h264d_output_port; 107 h264d_role.nports = 2; 108 h264d_role.pf_proc = instantiate_h264d_processor; 109 110 strcpy ((OMX_STRING) h264e_role.role, OMX_VID_ENC_AVC_ROLE); 111 h264e_role.pf_cport = instantiate_h264e_config_port; 112 h264e_role.pf_port[0] = instantiate_h264e_input_port; 113 h264e_role.pf_port[1] = instantiate_h264e_output_port; 114 h264e_role.nports = 2; 115 h264e_role.pf_proc = instantiate_h264e_processor; 116 117 /* Settings for classes */ 118 strcpy ((OMX_STRING) h264dprc_type.class_name, "h264dprc_class"); 119 h264dprc_type.pf_class_init = h264d_prc_class_init; 120 strcpy ((OMX_STRING) h264dprc_type.object_name, "h264dprc"); 121 h264dprc_type.pf_object_init = h264d_prc_init; 122 123 strcpy ((OMX_STRING) h264d_inport_type.class_name, "h264dinport_class"); 124 h264d_inport_type.pf_class_init = h264d_inport_class_init; 125 strcpy ((OMX_STRING) h264d_inport_type.object_name, "h264dinport"); 126 h264d_inport_type.pf_object_init = h264d_inport_init; 127 128 strcpy ((OMX_STRING) h264eprc_type.class_name, "h264eprc_class"); 129 h264eprc_type.pf_class_init = h264e_prc_class_init; 130 strcpy ((OMX_STRING) h264eprc_type.object_name, "h264eprc"); 131 h264eprc_type.pf_object_init = h264e_prc_init; 132 133 strcpy ((OMX_STRING) h264e_inport_type.class_name, "h264einport_class"); 134 h264e_inport_type.pf_class_init = h264e_inport_class_init; 135 strcpy ((OMX_STRING) h264e_inport_type.object_name, "h264einport"); 136 h264e_inport_type.pf_object_init = h264e_inport_init; 137 138 strcpy ((OMX_STRING) h264e_outport_type.class_name, "h264eoutport_class"); 139 h264e_outport_type.pf_class_init = h264e_outport_class_init; 140 strcpy ((OMX_STRING) h264e_outport_type.object_name, "h264eoutport"); 141 h264e_outport_type.pf_object_init = h264e_outport_init; 142 143 /* Initialize the component infrastructure */ 144 tiz_comp_init (ap_hdl, OMX_VID_COMP_NAME); 145 146 /* Classes need to be registered first */ 147 tiz_comp_register_types (ap_hdl, tf_list, 5); 148 149 /* Register the component roles */ 150 tiz_comp_register_roles (ap_hdl, rf_list, 2); 151 152 /* Register egl image validation hook for the decoder */ 153 tiz_check_omx (tiz_comp_register_role_eglimage_hook 154 (ap_hdl, (const OMX_U8 *) OMX_VID_DEC_AVC_ROLE, 155 &egl_validation_hook)); 156 157 return OMX_ErrorNone; 158} 159