Path: blob/21.2-virgl/src/gallium/frontends/omx/tizonia/entrypoint.c
4561 views
/**************************************************************************1*2* Copyright 2013 Advanced Micro Devices, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include <tizplatform.h>28#include <tizkernel.h>29#include <tizscheduler.h>30#include <tizport.h>31#include <tizport_decls.h>32#include <tizvideoport.h>33#include <tizvideoport_decls.h>3435#include "vid_dec_h264_common.h"36#include "entrypoint.h"37#include "h264d.h"38#include "h264dprc.h"39#include "h264dinport.h"40#include "h264e.h"41#include "h264eprc.h"42#include "h264einport.h"43#include "h264eoutport.h"44#include "names.h"4546#include "util/u_debug.h"4748DEBUG_GET_ONCE_BOOL_OPTION(mesa_enable_omx_eglimage,49"MESA_ENABLE_OMX_EGLIMAGE",50false)5152static OMX_BOOL egl_image_validation_hook(const OMX_HANDLETYPE ap_hdl,53OMX_U32 pid, OMX_PTR ap_eglimage,54void *ap_args)55{56const void * p_krn = NULL;57const tiz_port_t * p_port = NULL;5859assert(ap_hdl);60assert(ap_eglimage);61assert(!ap_args);6263if (!debug_get_option_mesa_enable_omx_eglimage()) {64return OMX_FALSE;65}6667p_krn = tiz_get_krn(ap_hdl);68p_port = tiz_krn_get_port(p_krn, pid);6970const OMX_VIDEO_PORTDEFINITIONTYPE * p_video_portdef71= &(p_port->portdef_.format.video);7273if (!p_video_portdef->pNativeWindow) {74return OMX_FALSE;75}7677return OMX_TRUE;78}7980OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE ap_hdl)81{82tiz_role_factory_t h264d_role;83tiz_role_factory_t h264e_role;84const tiz_role_factory_t * rf_list[] = {&h264d_role, &h264e_role};85tiz_type_factory_t h264dprc_type;86tiz_type_factory_t h264d_inport_type;87tiz_type_factory_t h264eprc_type;88tiz_type_factory_t h264e_inport_type;89tiz_type_factory_t h264e_outport_type;90const tiz_type_factory_t * tf_list[] = {&h264dprc_type,91&h264d_inport_type,92&h264eprc_type,93&h264e_inport_type,94&h264e_outport_type};95const tiz_eglimage_hook_t egl_validation_hook = {96OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX,97egl_image_validation_hook,98NULL99};100101/* Settings for roles */102strcpy ((OMX_STRING) h264d_role.role, OMX_VID_DEC_AVC_ROLE);103h264d_role.pf_cport = instantiate_h264d_config_port;104h264d_role.pf_port[0] = instantiate_h264d_input_port;105h264d_role.pf_port[1] = instantiate_h264d_output_port;106h264d_role.nports = 2;107h264d_role.pf_proc = instantiate_h264d_processor;108109strcpy ((OMX_STRING) h264e_role.role, OMX_VID_ENC_AVC_ROLE);110h264e_role.pf_cport = instantiate_h264e_config_port;111h264e_role.pf_port[0] = instantiate_h264e_input_port;112h264e_role.pf_port[1] = instantiate_h264e_output_port;113h264e_role.nports = 2;114h264e_role.pf_proc = instantiate_h264e_processor;115116/* Settings for classes */117strcpy ((OMX_STRING) h264dprc_type.class_name, "h264dprc_class");118h264dprc_type.pf_class_init = h264d_prc_class_init;119strcpy ((OMX_STRING) h264dprc_type.object_name, "h264dprc");120h264dprc_type.pf_object_init = h264d_prc_init;121122strcpy ((OMX_STRING) h264d_inport_type.class_name, "h264dinport_class");123h264d_inport_type.pf_class_init = h264d_inport_class_init;124strcpy ((OMX_STRING) h264d_inport_type.object_name, "h264dinport");125h264d_inport_type.pf_object_init = h264d_inport_init;126127strcpy ((OMX_STRING) h264eprc_type.class_name, "h264eprc_class");128h264eprc_type.pf_class_init = h264e_prc_class_init;129strcpy ((OMX_STRING) h264eprc_type.object_name, "h264eprc");130h264eprc_type.pf_object_init = h264e_prc_init;131132strcpy ((OMX_STRING) h264e_inport_type.class_name, "h264einport_class");133h264e_inport_type.pf_class_init = h264e_inport_class_init;134strcpy ((OMX_STRING) h264e_inport_type.object_name, "h264einport");135h264e_inport_type.pf_object_init = h264e_inport_init;136137strcpy ((OMX_STRING) h264e_outport_type.class_name, "h264eoutport_class");138h264e_outport_type.pf_class_init = h264e_outport_class_init;139strcpy ((OMX_STRING) h264e_outport_type.object_name, "h264eoutport");140h264e_outport_type.pf_object_init = h264e_outport_init;141142/* Initialize the component infrastructure */143tiz_comp_init (ap_hdl, OMX_VID_COMP_NAME);144145/* Classes need to be registered first */146tiz_comp_register_types (ap_hdl, tf_list, 5);147148/* Register the component roles */149tiz_comp_register_roles (ap_hdl, rf_list, 2);150151/* Register egl image validation hook for the decoder */152tiz_check_omx (tiz_comp_register_role_eglimage_hook153(ap_hdl, (const OMX_U8 *) OMX_VID_DEC_AVC_ROLE,154&egl_validation_hook));155156return OMX_ErrorNone;157}158159160