Home | History | Annotate | Download | only in inc
      1 
      2 /*
      3  * Copyright (C) Texas Instruments - http://www.ti.com/
      4  *
      5  * This library is free software; you can redistribute it and/or
      6  * modify it under the terms of the GNU Lesser General Public
      7  * License as published by the Free Software Foundation; either
      8  * version 2.1 of the License, or (at your option) any later version.
      9  *
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  *
     17  * You should have received a copy of the GNU Lesser General Public
     18  * License along with this library; if not, write to the Free Software
     19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     20  */
     21 /* ====================================================================
     22 *             Texas Instruments OMAP(TM) Platform Software
     23 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
     24 *
     25 * Use of this software is controlled by the terms and conditions found
     26 * in the license agreement under which this software has been supplied.
     27 * ==================================================================== */
     28 
     29 /** LCML_dspcodec.h
     30  *  The LCML header file contains the definitions used by both the
     31  *  application and the component to access common items.
     32  */
     33 
     34 
     35 #ifndef __LCML_DSPCODEC_H__
     36 #define __LCML_DSPCODEC_H__
     37 
     38 #define MAX_OBJS                10
     39 #define MAX_STREAMS             10
     40 
     41 /* 720p implementation */
     42 #define MAX_DMM_BUFFERS 20
     43 
     44 /*DSP specific*/
     45 #define DSP_DOF_IMAGE           "baseimage.dof"
     46 #define TI_PROCESSOR_DSP        0
     47 #define LCML_MAX_NUM_OF_DLLs    10
     48 #define END_OF_CR_PHASE_ARGS    0xFC25
     49 #define LCML_DATA_SIZE          42
     50 #define DMM_PAGE_SIZE           4096
     51 #define QUEUE_SIZE              20
     52 #define ROUND_TO_PAGESIZE(n)    ((((n)+4095)/DMM_PAGE_SIZE)*DMM_PAGE_SIZE)
     53 
     54 #define __ERROR_PROPAGATION__
     55 
     56 
     57 /*switch on/off here */
     58 #ifndef UNDER_CE
     59 #ifdef ANDROID
     60     #include <utils/Log.h>
     61 #endif
     62 #else
     63     #include <oaf_osal.h>
     64     #include <oaf_debug.h>
     65 #endif
     66 
     67 
     68 #ifdef __PERF_INSTRUMENTATION__
     69 #include "perf.h"
     70 #endif
     71 
     72 #include <LCML_Types.h>
     73 #include <LCML_CodecInterface.h>
     74 #include <pthread.h>
     75 
     76 /*DSP specific*/
     77 
     78 #define DSP_ERROR_EXIT(err, msg, label)                \
     79     if (DSP_FAILED (err)) {                        \
     80         printf("\n****************LCML ERROR : DSP ************************\n");\
     81         printf("Error: %s : Err Num = %lx", msg, err);  \
     82         eError = OMX_ErrorHardware;                \
     83         printf("\n****************LCML ERROR : DSP ************************\n");\
     84         goto label;                               \
     85     }                                              /**/
     86 
     87 /* ======================================================================= */
     88 /**
     89  * This enum is mean to abtract the enumerations of messages that are
     90  * sent to dsp processor.
     91  */
     92 /*  ====================================================================== */
     93 typedef enum {
     94     DSPMSG_AUDIO_UID = 1,
     95     DSPMSG_AUDIO_PARAMETERS,
     96     DSPMSG_PLAY,
     97     DSPMSG_PAUSE,
     98     DSPMSG_STOP,
     99     DSPMSG_MODE,
    100     DSPMSG_PLAYCOMPLETED
    101 } DSP_Messages;
    102 
    103 /**
    104  * USN structure
    105  */
    106 typedef struct
    107 {
    108     OMX_U32 iBufferPtr; /* storing buffer pointer MAPPED */
    109     OMX_U32 iBufferSize; /*buffer size */
    110     OMX_U32 iParamPtr;/*storing param pointer MAPPED */
    111     OMX_U32 iParamSize;/*param size */
    112     OMX_U32 iBufSizeUsed; /* Modified as USN chnages*/
    113     OMX_U32 iEOSFlag;
    114     OMX_U32 tBufState;
    115     OMX_U32 bBufActive;
    116     OMX_U32 unBufID;
    117     OMX_U32 ulReserved;
    118     OMX_U32 iArmArg;/* storing dsp mapped address of structure*/
    119     OMX_U32 iArmbufferArg;/* ARM side buffer pointer*/
    120     OMX_U32 iArmParamArg;/*ARM side Param pointer*/
    121     OMX_U32 Bufoutindex;/* buffer index*/
    122     OMX_U32 BufInindex;/*buffer i/p index*/
    123     OMX_U32 iUsrArg;/*Usr argument*/
    124     OMX_U32 iStreamID;
    125 } TArmDspCommunicationStruct;
    126 
    127 
    128 
    129 /*API needs to be exposed to application*/
    130 
    131 /** ========================================================================
    132 *  Initialise the OMX Component specific handle to LCML. The memory is
    133 *  allocated and the dsp node is created. Add notification object to listener
    134 *  thread.
    135 *
    136 *  @param  hInterface - Handle to LCML which is allocated and filled
    137 *  @param  codecName - not used
    138 *  @param  toCodecInitParams - not used yet
    139 *  @param  fromCodecInfoStruct - not used yet
    140 *  @param  pCallbacks - List of callback that uses to call OMX
    141 * ==========================================================================*/
    142 #define LCML_InitMMCodec(                                  \
    143         hInterface,                                        \
    144         codecName,                                         \
    145         toCodecInitParams,                                 \
    146         fromCodecInfoStruct ,                              \
    147         pCallbacks                                         \
    148         )                                                  \
    149     ((LCML_CODEC_INTERFACE*)hInterface)->InitMMCodec(      \
    150         hInterface,                                        \
    151         codecName,                                         \
    152         toCodecInitParams,                                 \
    153         fromCodecInfoStruct ,                              \
    154         pCallbacks                                         \
    155         )                          /* Macro End */
    156 
    157 
    158 #define LCML_InitMMCodecEx(                                \
    159         hInterface,                                        \
    160         codecName,                                         \
    161         toCodecInitParams,                                 \
    162         fromCodecInfoStruct ,                              \
    163         pCallbacks,                                        \
    164         Args)                                              \
    165     ((LCML_CODEC_INTERFACE*)hInterface)->InitMMCodecEx(    \
    166         hInterface,                                        \
    167         codecName,                                         \
    168         toCodecInitParams,                                 \
    169         fromCodecInfoStruct ,                              \
    170         pCallbacks,                                        \
    171         Args)                          /* Macro End */
    172 
    173 /** ========================================================================
    174 *  The LCML_WaitForEvent Wait for a event sychronously
    175 *  @param  hInterface -  Handle of the component to be accessed.  This is the
    176 *      component handle returned by the call to the GetHandle function.
    177 *  @param  event - Event occured
    178 *  @param  args - Array of "void *" that contains the associated arguments for
    179 *             occured event
    180 *
    181 *  @return OMX_ERRORTYPE
    182 *      If the command successfully executes, the return code will be
    183 *      OMX_NoError.  Otherwise the appropriate OMX error will be returned.
    184 ** ==========================================================================*/
    185 #define LCML_WaitForEvent(                                 \
    186         hInterface,                                        \
    187         event,                                             \
    188         args)                                              \
    189     ((LCML_CODEC_INTERFACE*)hInterface)->ControlCodec(     \
    190         hInterface,                                        \
    191         event,                                             \
    192         args)                          /* Macro End */
    193 
    194 
    195 /** ========================================================================
    196 *  The LCML_QueueBuffer send data to DSP convert it into USN format and send
    197 *  it to DSP via setbuff
    198 *  @param [in] hInterface -  Handle of the component to be accessed.  This is
    199 *      the component handle returned by the call to the GetHandle function.
    200 *  @param  bufType - type of buffer
    201 *  @param  buffer - pointer to buffer
    202 *  @param  bufferLen - length of  buffer
    203 *  @param  bufferSizeUsed - length of used buffer
    204 *  @param  auxInfo - pointer to parameter
    205 *  @param  auxInfoLen - length of  parameter
    206 *  @param  usrArg - not used
    207 *  @return OMX_ERRORTYPE
    208 *      If the command successfully executes, the return code will be
    209 *      OMX_NoError.  Otherwise the appropriate OMX error will be returned.
    210 * ==========================================================================*/
    211 #define LCML_QueueBuffer(                                  \
    212         hInterface,                                        \
    213         bufType,                                           \
    214         buffer,                                            \
    215         bufferLen,                                         \
    216         bufferSizeUsed,                                    \
    217         auxInfo,                                           \
    218         auxInfoLen,                                        \
    219         usrArg)                                            \
    220     ((LCML_CODEC_INTERFACE*)hInterface)->QueueBuffer(      \
    221         hInterface,                                        \
    222         bufType,                                           \
    223         buffer,                                            \
    224         bufferLen,                                         \
    225         bufferSizeUsed,                                    \
    226         auxInfo,                                           \
    227         auxInfoLen,                                        \
    228         usrArg)
    229 
    230 /** ========================================================================
    231 *  The LCML_ControlCodec send command to DSP convert it into USN format and
    232 *  send it to DSP
    233 *  @param  hInterface -  Handle of the component to be accessed.  This is the
    234 *      component handle returned by the call to the GetHandle function.
    235 *  @param  bufType - type of buffer
    236 *  @param  iCodecCmd -  command refer TControlCmd
    237 *  @param  args - pointer to send some specific command to DSP
    238 *
    239 *  @return OMX_ERRORTYPE
    240 *      If the command successfully executes, the return code will be
    241 *      OMX_NoError.  Otherwise the appropriate OMX error will be returned.
    242 ** ==========================================================================*/
    243 #define LCML_ControlCodec(                                 \
    244         hInterface,                                        \
    245         iCodecCmd,                                         \
    246         args)                                              \
    247     ((LCML_CODEC_INTERFACE*)hInterface)->ControlCodec(     \
    248         hInterface,                                        \
    249         iCodecCmd,                                         \
    250         args)                          /* Macro End */
    251 
    252 
    253 
    254 
    255 /**
    256 * First function needs to be called by application
    257 */
    258 OMX_ERRORTYPE GetHandle (OMX_HANDLETYPE* hInterface );
    259 
    260 /**
    261 * Struct derives codec interface which have interface to implement for using
    262 * generic codec and also have pointer to DSP specific data and have queues for
    263 * storing input and output data
    264 */
    265 typedef struct LCML_DSP_INTERFACE
    266 {
    267     OMX_HANDLETYPE pCodecinterfacehandle;  /* handle to interface struct LCML_CODEC_INTERFACE *dspcodecinterface */
    268     struct LCML_DSP *dspCodec;
    269     OMX_PTR pComponentPrivate;
    270     void * iUsrArg;
    271     /*queue to store USN structure*/
    272     TArmDspCommunicationStruct* Armoutputstorage[QUEUE_SIZE];
    273     TArmDspCommunicationStruct* Arminputstorage[QUEUE_SIZE];
    274     TArmDspCommunicationStruct * commStruct;
    275     OMX_U32 iBufinputcount;
    276     OMX_U32 iBufoutputcount;
    277     OMX_U32 pshutdownFlag;
    278 #ifdef __ERROR_PROPAGATION__
    279     struct DSP_NOTIFICATION * g_aNotificationObjects[3];
    280 #else
    281     struct DSP_NOTIFICATION * g_aNotificationObjects[1];
    282 #endif
    283     pthread_t g_tidMessageThread;
    284     OMX_U32 algcntlmapped[QUEUE_SIZE];
    285     DMM_BUFFER_OBJ *pAlgcntlDmmBuf[QUEUE_SIZE];
    286     OMX_U32 strmcntlmapped[QUEUE_SIZE];
    287     DMM_BUFFER_OBJ *pStrmcntlDmmBuf[QUEUE_SIZE];
    288     pthread_mutex_t mutex;
    289     OMX_U32 flush_pending[4];
    290     OMX_BOOL bUsnEos;
    291 
    292 #ifdef __PERF_INSTRUMENTATION__
    293     PERF_OBJHANDLE pPERF, pPERFcomp;
    294 #endif
    295     DMM_BUFFER_OBJ mapped_dmm_buffers[MAX_DMM_BUFFERS];
    296     OMX_U32 mapped_buffer_count;
    297     OMX_BOOL ReUseMap;
    298     pthread_mutex_t m_isStopped_mutex;
    299 
    300 }LCML_DSP_INTERFACE;
    301 
    302 #endif /* __MMDSPCODEC_H__ */
    303 
    304 
    305