17ec681f3Smrg/************************************************************************** 27ec681f3Smrg * 37ec681f3Smrg * Copyright 2013 Advanced Micro Devices, Inc. 47ec681f3Smrg * All Rights Reserved. 57ec681f3Smrg * 67ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 77ec681f3Smrg * copy of this software and associated documentation files (the 87ec681f3Smrg * "Software"), to deal in the Software without restriction, including 97ec681f3Smrg * without limitation the rights to use, copy, modify, merge, publish, 107ec681f3Smrg * distribute, sub license, and/or sell copies of the Software, and to 117ec681f3Smrg * permit persons to whom the Software is furnished to do so, subject to 127ec681f3Smrg * the following conditions: 137ec681f3Smrg * 147ec681f3Smrg * The above copyright notice and this permission notice (including the 157ec681f3Smrg * next paragraph) shall be included in all copies or substantial portions 167ec681f3Smrg * of the Software. 177ec681f3Smrg * 187ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 197ec681f3Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 207ec681f3Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 217ec681f3Smrg * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR 227ec681f3Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 237ec681f3Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 247ec681f3Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 257ec681f3Smrg * 267ec681f3Smrg **************************************************************************/ 277ec681f3Smrg 287ec681f3Smrg#include <tizplatform.h> 297ec681f3Smrg#include <tizkernel.h> 307ec681f3Smrg#include <tizscheduler.h> 317ec681f3Smrg#include <tizport.h> 327ec681f3Smrg#include <tizport_decls.h> 337ec681f3Smrg#include <tizvideoport.h> 347ec681f3Smrg#include <tizvideoport_decls.h> 357ec681f3Smrg 367ec681f3Smrg#include "vid_dec_h264_common.h" 377ec681f3Smrg#include "entrypoint.h" 387ec681f3Smrg#include "h264d.h" 397ec681f3Smrg#include "h264dprc.h" 407ec681f3Smrg#include "h264dinport.h" 417ec681f3Smrg#include "h264e.h" 427ec681f3Smrg#include "h264eprc.h" 437ec681f3Smrg#include "h264einport.h" 447ec681f3Smrg#include "h264eoutport.h" 457ec681f3Smrg#include "names.h" 467ec681f3Smrg 477ec681f3Smrg#include "util/u_debug.h" 487ec681f3Smrg 497ec681f3SmrgDEBUG_GET_ONCE_BOOL_OPTION(mesa_enable_omx_eglimage, 507ec681f3Smrg "MESA_ENABLE_OMX_EGLIMAGE", 517ec681f3Smrg false) 527ec681f3Smrg 537ec681f3Smrgstatic OMX_BOOL egl_image_validation_hook(const OMX_HANDLETYPE ap_hdl, 547ec681f3Smrg OMX_U32 pid, OMX_PTR ap_eglimage, 557ec681f3Smrg void *ap_args) 567ec681f3Smrg{ 577ec681f3Smrg const void * p_krn = NULL; 587ec681f3Smrg const tiz_port_t * p_port = NULL; 597ec681f3Smrg 607ec681f3Smrg assert(ap_hdl); 617ec681f3Smrg assert(ap_eglimage); 627ec681f3Smrg assert(!ap_args); 637ec681f3Smrg 647ec681f3Smrg if (!debug_get_option_mesa_enable_omx_eglimage()) { 657ec681f3Smrg return OMX_FALSE; 667ec681f3Smrg } 677ec681f3Smrg 687ec681f3Smrg p_krn = tiz_get_krn(ap_hdl); 697ec681f3Smrg p_port = tiz_krn_get_port(p_krn, pid); 707ec681f3Smrg 717ec681f3Smrg const OMX_VIDEO_PORTDEFINITIONTYPE * p_video_portdef 727ec681f3Smrg = &(p_port->portdef_.format.video); 737ec681f3Smrg 747ec681f3Smrg if (!p_video_portdef->pNativeWindow) { 757ec681f3Smrg return OMX_FALSE; 767ec681f3Smrg } 777ec681f3Smrg 787ec681f3Smrg return OMX_TRUE; 797ec681f3Smrg} 807ec681f3Smrg 817ec681f3SmrgOMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE ap_hdl) 827ec681f3Smrg{ 837ec681f3Smrg tiz_role_factory_t h264d_role; 847ec681f3Smrg tiz_role_factory_t h264e_role; 857ec681f3Smrg const tiz_role_factory_t * rf_list[] = {&h264d_role, &h264e_role}; 867ec681f3Smrg tiz_type_factory_t h264dprc_type; 877ec681f3Smrg tiz_type_factory_t h264d_inport_type; 887ec681f3Smrg tiz_type_factory_t h264eprc_type; 897ec681f3Smrg tiz_type_factory_t h264e_inport_type; 907ec681f3Smrg tiz_type_factory_t h264e_outport_type; 917ec681f3Smrg const tiz_type_factory_t * tf_list[] = {&h264dprc_type, 927ec681f3Smrg &h264d_inport_type, 937ec681f3Smrg &h264eprc_type, 947ec681f3Smrg &h264e_inport_type, 957ec681f3Smrg &h264e_outport_type}; 967ec681f3Smrg const tiz_eglimage_hook_t egl_validation_hook = { 977ec681f3Smrg OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX, 987ec681f3Smrg egl_image_validation_hook, 997ec681f3Smrg NULL 1007ec681f3Smrg }; 1017ec681f3Smrg 1027ec681f3Smrg /* Settings for roles */ 1037ec681f3Smrg strcpy ((OMX_STRING) h264d_role.role, OMX_VID_DEC_AVC_ROLE); 1047ec681f3Smrg h264d_role.pf_cport = instantiate_h264d_config_port; 1057ec681f3Smrg h264d_role.pf_port[0] = instantiate_h264d_input_port; 1067ec681f3Smrg h264d_role.pf_port[1] = instantiate_h264d_output_port; 1077ec681f3Smrg h264d_role.nports = 2; 1087ec681f3Smrg h264d_role.pf_proc = instantiate_h264d_processor; 1097ec681f3Smrg 1107ec681f3Smrg strcpy ((OMX_STRING) h264e_role.role, OMX_VID_ENC_AVC_ROLE); 1117ec681f3Smrg h264e_role.pf_cport = instantiate_h264e_config_port; 1127ec681f3Smrg h264e_role.pf_port[0] = instantiate_h264e_input_port; 1137ec681f3Smrg h264e_role.pf_port[1] = instantiate_h264e_output_port; 1147ec681f3Smrg h264e_role.nports = 2; 1157ec681f3Smrg h264e_role.pf_proc = instantiate_h264e_processor; 1167ec681f3Smrg 1177ec681f3Smrg /* Settings for classes */ 1187ec681f3Smrg strcpy ((OMX_STRING) h264dprc_type.class_name, "h264dprc_class"); 1197ec681f3Smrg h264dprc_type.pf_class_init = h264d_prc_class_init; 1207ec681f3Smrg strcpy ((OMX_STRING) h264dprc_type.object_name, "h264dprc"); 1217ec681f3Smrg h264dprc_type.pf_object_init = h264d_prc_init; 1227ec681f3Smrg 1237ec681f3Smrg strcpy ((OMX_STRING) h264d_inport_type.class_name, "h264dinport_class"); 1247ec681f3Smrg h264d_inport_type.pf_class_init = h264d_inport_class_init; 1257ec681f3Smrg strcpy ((OMX_STRING) h264d_inport_type.object_name, "h264dinport"); 1267ec681f3Smrg h264d_inport_type.pf_object_init = h264d_inport_init; 1277ec681f3Smrg 1287ec681f3Smrg strcpy ((OMX_STRING) h264eprc_type.class_name, "h264eprc_class"); 1297ec681f3Smrg h264eprc_type.pf_class_init = h264e_prc_class_init; 1307ec681f3Smrg strcpy ((OMX_STRING) h264eprc_type.object_name, "h264eprc"); 1317ec681f3Smrg h264eprc_type.pf_object_init = h264e_prc_init; 1327ec681f3Smrg 1337ec681f3Smrg strcpy ((OMX_STRING) h264e_inport_type.class_name, "h264einport_class"); 1347ec681f3Smrg h264e_inport_type.pf_class_init = h264e_inport_class_init; 1357ec681f3Smrg strcpy ((OMX_STRING) h264e_inport_type.object_name, "h264einport"); 1367ec681f3Smrg h264e_inport_type.pf_object_init = h264e_inport_init; 1377ec681f3Smrg 1387ec681f3Smrg strcpy ((OMX_STRING) h264e_outport_type.class_name, "h264eoutport_class"); 1397ec681f3Smrg h264e_outport_type.pf_class_init = h264e_outport_class_init; 1407ec681f3Smrg strcpy ((OMX_STRING) h264e_outport_type.object_name, "h264eoutport"); 1417ec681f3Smrg h264e_outport_type.pf_object_init = h264e_outport_init; 1427ec681f3Smrg 1437ec681f3Smrg /* Initialize the component infrastructure */ 1447ec681f3Smrg tiz_comp_init (ap_hdl, OMX_VID_COMP_NAME); 1457ec681f3Smrg 1467ec681f3Smrg /* Classes need to be registered first */ 1477ec681f3Smrg tiz_comp_register_types (ap_hdl, tf_list, 5); 1487ec681f3Smrg 1497ec681f3Smrg /* Register the component roles */ 1507ec681f3Smrg tiz_comp_register_roles (ap_hdl, rf_list, 2); 1517ec681f3Smrg 1527ec681f3Smrg /* Register egl image validation hook for the decoder */ 1537ec681f3Smrg tiz_check_omx (tiz_comp_register_role_eglimage_hook 1547ec681f3Smrg (ap_hdl, (const OMX_U8 *) OMX_VID_DEC_AVC_ROLE, 1557ec681f3Smrg &egl_validation_hook)); 1567ec681f3Smrg 1577ec681f3Smrg return OMX_ErrorNone; 1587ec681f3Smrg} 159