summaryrefslogtreecommitdiffstats
path: root/domx
diff options
context:
space:
mode:
authorVidhoon Viswanathan <vidhoon@ti.com>2012-09-25 08:30:48 -0700
committerGerrit Code Review <gerrit2@git.omapzoom.org>2012-10-04 05:23:50 -0500
commit0da015ad970071c1ce09154b45574b5df72336d3 (patch)
treec817e426cafb3c5fa077a45553c282c1652b94b3 /domx
parent1a1f97627b516b386b530d73ec5a1d7ac2dde7de (diff)
downloadhardware_ti_omap4-0da015ad970071c1ce09154b45574b5df72336d3.zip
hardware_ti_omap4-0da015ad970071c1ce09154b45574b5df72336d3.tar.gz
hardware_ti_omap4-0da015ad970071c1ce09154b45574b5df72336d3.tar.bz2
[PLUGINS] MemPlugins: Plugin based integration of Memory managers
This patch introduces the MemPlugin generic API interface for buffer actions. All types and definitions are contained in memplugin.h & memplugin.c ION memory manager is "plugged in" through internal methods defined in memplugin_ion.h & memplugin_ion.c. The generic APIs are linked to the specific memory manager methods internally based on the mapping table defined in memplugin_table.c. Change-Id: Ibff94732c40749f9c8cf34aa18bc0c43ddd298de Signed-off-by: Vidhoon Viswanathan <vidhoon@ti.com>
Diffstat (limited to 'domx')
-rw-r--r--domx/plugins/inc/memplugin.h231
-rw-r--r--domx/plugins/inc/memplugin_ion.h132
-rw-r--r--domx/plugins/memplugin.c248
-rw-r--r--domx/plugins/memplugin_ion.c297
-rw-r--r--domx/plugins/memplugin_table.c52
5 files changed, 960 insertions, 0 deletions
diff --git a/domx/plugins/inc/memplugin.h b/domx/plugins/inc/memplugin.h
new file mode 100644
index 0000000..6bd7d51
--- /dev/null
+++ b/domx/plugins/inc/memplugin.h
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* author: Vidhoon Viswanathan
+ * date: 28 sept 2012
+ * This file contains two portions:
+ *
+ * PART1: contains all PLUGIN related type defintions
+ * such as error types, buffer types, buffer params
+ * that are generic to all PLUGINS and expected to
+ * be reused.
+ *
+ * PART2: contains all GENERIC INTERFACE type definitions
+ * and methods that would be used to access PLUGIN
+ * implementations from common DOMX.
+ */
+
+ /* ----- system and platform files ----------------------------*/
+#ifndef MEMPLUGIN_H
+#define MEMPLUGIN_H
+#include <string.h>
+
+#include "OMX_TI_Core.h"
+/***************************************************************
+ * PART 1
+ * PLUGIN RELATED TYPE DEFINITIONS
+ *
+ *
+ * *************************************************************
+ */
+typedef enum MEMPLUGIN_ERRORTYPE
+{
+ MEMPLUGIN_ERROR_NONE = 0x00,
+ MEMPLUGIN_ERROR_BADPARAMETER,
+ MEMPLUGIN_ERROR_NORESOURCES,
+ MEMPLUGIN_ERROR_UNDEFINED,
+ MEMPLUGIN_ERROR_NOTIMPLEMENTED
+}MEMPLUGIN_ERRORTYPE;
+
+typedef enum MEMPLUGIN_BUFFERTYPE
+{
+ DEFAULT = 0x00, //NON TILER
+ TILER1D,
+ TILER2D
+}MEMPLUGIN_BUFFERTYPE;
+
+typedef enum MEMPLUGIN_TILER_FORMAT
+{
+ MEMPLUGIN_TILER_FORMAT_8BIT = 0,
+ MEMPLUGIN_TILER_FORMAT_16BIT = 1,
+ MEMPLUGIN_TILER_FORMAT_32BIT = 2,
+ MEMPLUGIN_TILER_FORMAT_PAGE = 3
+}MEMPLUGIN_TILER_FORMAT;
+/**
+ * MEMPLUGIN_BUFFER_ACCESSOR: This structure maintaines all possible accessors for an allocated buffer
+ *
+ * @param pBufferHandle: This is a pointer to buffer handle
+ * @param bufferFd: This is the context free file descriptor obtained by mapping
+ * @param pRegBufferHandle: This is the handle obtained after registration of the buffer with rpmsg
+ * @param pBufferMappedAddress: This is the mapped address of the buffer obtained after mapping
+ *
+ */
+ //TBD: if pRegBufferHandle can be part of this structure - it is kind of ION specific
+typedef struct MEMPLUGIN_BUFFER_ACCESSOR
+{
+ OMX_PTR pBufferHandle;
+ OMX_U32 bufferFd;
+ OMX_PTR pRegBufferHandle;
+ OMX_PTR pBufferMappedAddress;
+}MEMPLUGIN_BUFFER_ACCESSOR;
+
+// @struct MEMPLUGIN_BUFFER_INPARAMS - comprises of all buffer properties required as input for Plugin APIs
+typedef struct MEMPLUGIN_BUFFER_PARAMS
+{
+OMX_U32 nHeight;
+OMX_U32 nWidth;
+OMX_BOOL bMap;
+MEMPLUGIN_TILER_FORMAT eTiler_format; //expected to be passed from user for tiler1D/2D == in case of nontiler to tiler upgrade, defaulted to TILER_PIXEL_FMT_PAGE
+MEMPLUGIN_BUFFERTYPE eBuffer_type;
+}MEMPLUGIN_BUFFER_PARAMS;
+// @struct MEMPLUGIN_BUFFER_OUTPARAMS - comprises of all buffer properties required as input for Plugin APIs
+typedef struct MEMPLUGIN_BUFFER_PROPERTIES
+{
+MEMPLUGIN_BUFFER_ACCESSOR sBuffer_accessor;
+OMX_U32 nStride;
+}MEMPLUGIN_BUFFER_PROPERTIES;
+
+/***************************************************************
+ * PART 2
+ * PLUGIN INTERFACE RELATED TYPE AND METHOD DEFINITIONS
+ *
+ *
+ * *************************************************************
+ */
+
+/** @struct MEMPLUGIN_OBJECT - comprises of all plugin related data including:
+ *
+ * pPluginExtendedInfo - plugin specific extended data structure
+ * fpOpen - function pointer interface to Plugin Open()
+ * fpAlloc - function pointer interface to Plugin Allocation method
+ * fpFree - function pointer interface to Plugin Freeing method
+ * fpClose - function pointer interface to Plugin Close()
+ *
+ */
+typedef struct MEMPLUGIN_OBJECT
+{
+ OMX_PTR pPluginExtendedInfo;
+ MEMPLUGIN_ERRORTYPE (*fpConfig)(void *pMemPluginHandle,
+ void *pConfigData);
+ MEMPLUGIN_ERRORTYPE (*fpOpen)(void *pMemPluginHandle,
+ OMX_U32 *pClient);
+ MEMPLUGIN_ERRORTYPE (*fpAlloc)(void *pMemPluginHandle,
+ OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pBufferProp);
+ MEMPLUGIN_ERRORTYPE (*fpFree)(void *pMemPluginHandle,
+ OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pBufferProp);
+ MEMPLUGIN_ERRORTYPE (*fpClose)(void *pMemPluginHandle,
+ OMX_U32 nClient);
+ MEMPLUGIN_ERRORTYPE (*fpDeInit)(void *pMemPluginHandle);
+}MEMPLUGIN_OBJECT;
+
+typedef MEMPLUGIN_ERRORTYPE (*MEMPLUGIN_CONFIGTYPE)(MEMPLUGIN_OBJECT **);
+
+typedef struct MEMPLUGIN_TABLETYPE
+{
+ char cMemPluginName[50];
+ MEMPLUGIN_CONFIGTYPE pMemPluginConfig;
+}MEMPLUGIN_TABLETYPE;
+
+/******************************************************************
+ * FUNCTIONS DEFINITION
+ ******************************************************************/
+ /*MemPlugin_Init: To initialize a MemPlugin from DOMX PROXY
+ * Must be called before any other API calls.
+ * Maps the plugin handle to corresponding proxy
+ * element for further access
+ *
+ * @param cMemPluginName: string that identifies plugin
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ */
+ MEMPLUGIN_ERRORTYPE MemPlugin_Init(char *cMemPluginName,
+ void **pMemPluginHandle);
+ /*MemPlugin_Configure: To do different types of plugin specific
+ * config operations required.
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param pConfigData: data specific to configuration to be done
+ */
+ MEMPLUGIN_ERRORTYPE MemPlugin_Configure(void *pMemPluginHandle,
+ void *pConfigData);
+ /*MemPlugin_Open: To open and obtain a client for the MemPlugin
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param pClient: MemPlugin client used for operations
+ */
+ MEMPLUGIN_ERRORTYPE MemPlugin_Open(void *pMemPluginHandle,
+ OMX_U32 *pClient);
+ /*MemPlugin_Close: To close the client of MemPlugin
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param nClient: MemPlugin client used for operations
+ */
+ MEMPLUGIN_ERRORTYPE MemPlugin_Close(void *pMemPluginHandle,
+ OMX_U32 nClient);
+ /*MemPlugin_Alloc: To allocate a buffer
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param nClient: MemPlugin client used for operations
+ * @param pBufferParams: All buffer IN params required for allocation
+ * @param pBufferProp: All buffer properties obtained from allocation
+ */
+ MEMPLUGIN_ERRORTYPE MemPlugin_Alloc(void *pMemPluginHandle,
+ OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pBufferProp);
+ /*MemPlugin_Free: To free a buffer
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param nClient: MemPlugin client used for operations
+ * @param pBufferParams: All buffer IN params required for freeing
+ * @param pBufferProp: All buffer properties required for freeing
+ */
+ MEMPLUGIN_ERRORTYPE MemPlugin_Free(void *pMemPluginHandle,
+ OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pBufferProp);
+ /*MemPlugin_DeInit: To destroy a MemPlugin from DOMX PROXY
+ *
+ * @param pMemPluginHandle: handle that provides identifies the
+ * plugin to be destroyed
+ */
+ MEMPLUGIN_ERRORTYPE MemPlugin_DeInit(void *pMemPluginHandle);
+#endif
diff --git a/domx/plugins/inc/memplugin_ion.h b/domx/plugins/inc/memplugin_ion.h
new file mode 100644
index 0000000..debdc14
--- /dev/null
+++ b/domx/plugins/inc/memplugin_ion.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* author: Vidhoon Viswanathan
+ * date: 28 sept 2012
+ * This file contains all ION plugin related types
+ * and methods that will be accessed only from
+ * within or corresponding GLUE layers.
+ */
+
+#include <unistd.h>
+#include <ion/ion.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/eventfd.h>
+#include <fcntl.h>
+#include <linux/rpmsg_omx.h>
+#include <errno.h>
+
+#include "memplugin.h"
+
+/* struct MEMPLUGIN_ION_PARAMS : contains all params that are specific to
+ * ION APIs for buffer allocation.
+ * @param nAlign: alignment of buffers
+ * @param nOffset: offset needed for buffers
+ * @param alloc_flags: allocation flags depending on type of buffer needed
+ * @param map_flags: mapping flags depending on type of mapping
+ * @param prot: buffer protection flag
+ */
+typedef struct MEMPLUGIN_ION_PARAMS {
+ size_t nAlign;
+ off_t nOffset;
+ OMX_U32 alloc_flags;
+ OMX_S32 map_flags;
+ OMX_S32 prot;
+}MEMPLUGIN_ION_PARAMS;
+/******************************************************************
+ * FUNCTIONS DEFINITION
+ ******************************************************************/
+ /*MemPlugin_ION_Init: To initialize a MemPlugin from DOMX PROXY
+ * Must be called before any other API calls.
+ * Maps the plugin handle to corresponding proxy
+ * element for further access
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ */
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Init(void **pMemPluginHandle);
+ /*MemPlugin_Configure: To do different types of plugin specific
+ * config operations required.
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param pConfigData: data specific to configuration to be done
+ */
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Configure(void *pMemPluginHandle,
+ void *pConfigData);
+/*MemPlugin_Open: To open and obtain a client for the MemPlugin
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param pClient: MemPlugin client used for operations
+ */
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Open(void *pMemPluginHandle,
+ OMX_U32 *pClient);
+/*MemPlugin_Close: To close the client of MemPlugin
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param nClient: MemPlugin client used for operations
+ */
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Close(void *pMemPluginHandle,
+ OMX_U32 nClient);
+/*MemPlugin_Alloc: To allocate a buffer
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param nClient: MemPlugin client used for operations
+ * @param pBufferParams: All buffer IN params required for allocation
+ * @param pBufferProp: All buffer properties obtained from allocation
+ */
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Alloc(void *pMemPluginHandle,
+ OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pIonBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pIonBufferProp);
+/*MemPlugin_Free: To free a buffer
+ *
+ * @param pMemPluginHandle: handle that provides access for APIs
+ * corresponding to the plugin
+ * @param nClient: MemPlugin client used for operations
+ * @param pBufferParams: All buffer IN params required for freeing
+ * @param pBufferProp: All buffer properties required for freeing
+ */
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Free(void *pMemPluginHandle,
+ OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pIonBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pIonBufferProp);
+ /*MemPlugin_DeInit: To destroy a MemPlugin from DOMX PROXY
+ *
+ * @param pMemPluginHandle: handle that provides identifies the
+ * plugin to be destroyed
+ */
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_DeInit(void *pMemPluginHandle);
diff --git a/domx/plugins/memplugin.c b/domx/plugins/memplugin.c
new file mode 100644
index 0000000..b6597b4
--- /dev/null
+++ b/domx/plugins/memplugin.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* author: Vidhoon Viswanathan
+ * date: 28 sept 2012
+ * This file contains declarations and function prototypes
+ * that are expected to be reused or common across various
+ * memory PLUGIN implementations
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <timm_osal_types.h>
+#include <timm_osal_memory.h>
+#include <timm_osal_trace.h>
+
+#include "memplugin.h"
+#include "omx_rpc_utils.h"
+
+extern MEMPLUGIN_TABLETYPE MemPlugins_Map[];
+
+MEMPLUGIN_ERRORTYPE MemPlugin_Init(char *cMemPluginName, void **pMemPluginHandle)
+{
+ MEMPLUGIN_OBJECT *pMemPluginHdl;
+ OMX_BOOL bFound;
+ OMX_U16 i = 0;
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+
+ if(cMemPluginName == NULL || pMemPluginHandle == NULL)
+ {
+ eError = MEMPLUGIN_ERROR_BADPARAMETER;
+ DOMX_ERROR("%s: Invalid parameter to function",__FUNCTION__);
+ goto EXIT;
+ }
+
+ while(MemPlugins_Map[i].cMemPluginName != NULL)
+ {
+ if(strcmp(MemPlugins_Map[i].cMemPluginName,cMemPluginName) == 0)
+ {
+ bFound = OMX_TRUE;
+ break;
+ }
+ else
+ {
+ i++;
+
+ }
+ }
+ if(bFound)
+ {
+ eError = MemPlugins_Map[i].pMemPluginConfig(&pMemPluginHdl);
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ goto EXIT;
+ }
+ else
+ {
+ *pMemPluginHandle = pMemPluginHdl;
+ }
+
+ }
+ else
+ {
+ eError = MEMPLUGIN_ERROR_BADPARAMETER;
+ DOMX_ERROR("%s: Invalid parameter to function",__FUNCTION__);
+ goto EXIT;
+ }
+EXIT:
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError);
+ }
+ else
+ {
+ DOMX_EXIT("%s: executed successfully",__FUNCTION__);
+ }
+ return eError;
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_Open(void *pMemPluginHandle, OMX_U32 *pClient)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+ OMX_U32 pClientDesc;
+
+ if(pMemPluginHandle == NULL || pClient == NULL)
+ {
+ eError = MEMPLUGIN_ERROR_BADPARAMETER;
+ DOMX_ERROR("%s: Invalid parameter to function",__FUNCTION__);
+ goto EXIT;
+ }
+
+ eError = ((MEMPLUGIN_OBJECT *)pMemPluginHandle)->fpOpen(pMemPluginHandle,&pClientDesc);
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_ERROR("%s: Client Open() failed",__FUNCTION__);
+ goto EXIT;
+ }
+ else
+ {
+ *pClient = pClientDesc;
+ }
+
+EXIT:
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError);
+ }
+ else
+ {
+ DOMX_EXIT("%s: executed successfully with client desc %d",__FUNCTION__,*pClient);
+ }
+ return eError;
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_Close(void *pMemPluginHandle, OMX_U32 nClient)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+
+ if(pMemPluginHandle == NULL)
+ {
+ eError = MEMPLUGIN_ERROR_BADPARAMETER;
+ DOMX_ERROR("%s: Invalid parameter to function",__FUNCTION__);
+ goto EXIT;
+ }
+ eError = ((MEMPLUGIN_OBJECT *)pMemPluginHandle)->fpClose(pMemPluginHandle,nClient);
+EXIT:
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError);
+ }
+ else
+ {
+ DOMX_EXIT("%s: executed successfully",__FUNCTION__);
+ }
+ return eError;
+}
+MEMPLUGIN_ERRORTYPE MemPlugin_Configure(void *pMemPluginHandle, void *pConfigData)
+{
+ //implementation to be added later
+EXIT:
+ return(MEMPLUGIN_ERROR_NONE);
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_Alloc(void *pMemPluginHandle, OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pBufferProp)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+
+ if(pMemPluginHandle == NULL)
+ {
+ eError = MEMPLUGIN_ERROR_BADPARAMETER;
+ DOMX_ERROR("%s: Invalid parameter to function",__FUNCTION__);
+ goto EXIT;
+ }
+ eError = ((MEMPLUGIN_OBJECT *)pMemPluginHandle)->fpAlloc(pMemPluginHandle,nClient,pBufferParams,pBufferProp);
+EXIT:
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError);
+ }
+ else
+ {
+ DOMX_EXIT("%s: executed successfully",__FUNCTION__);
+ }
+ return eError;
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_Free(void *pMemPluginHandle, OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pBufferProp)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+
+ if(pMemPluginHandle == NULL)
+ {
+ eError = MEMPLUGIN_ERROR_BADPARAMETER;
+ DOMX_ERROR("%s: Invalid parameter to function",__FUNCTION__);
+ goto EXIT;
+ }
+ eError = ((MEMPLUGIN_OBJECT *)pMemPluginHandle)->fpFree(pMemPluginHandle,nClient,pBufferParams,pBufferProp);
+EXIT:
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError);
+ }
+ else
+ {
+ DOMX_EXIT("%s: executed successfully",__FUNCTION__);
+ }
+ return eError;
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_DeInit(void *pMemPluginHandle)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+
+ if(pMemPluginHandle == NULL)
+ {
+ eError = MEMPLUGIN_ERROR_BADPARAMETER;
+ DOMX_ERROR("%s: Invalid parameter to function",__FUNCTION__);
+ goto EXIT;
+ }
+
+ eError = ((MEMPLUGIN_OBJECT *)pMemPluginHandle)->fpDeInit(pMemPluginHandle);
+
+
+EXIT:
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError);
+ }
+ else
+ {
+ DOMX_EXIT("%s: executed successfully",__FUNCTION__);
+ }
+ return eError;
+
+}
diff --git a/domx/plugins/memplugin_ion.c b/domx/plugins/memplugin_ion.c
new file mode 100644
index 0000000..21fc460
--- /dev/null
+++ b/domx/plugins/memplugin_ion.c
@@ -0,0 +1,297 @@
+/*
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "memplugin_ion.h"
+#include <timm_osal_types.h>
+#include <timm_osal_memory.h>
+#include <timm_osal_trace.h>
+#include "omx_rpc_utils.h"
+
+
+/******************************************************************
+ * MACROS DEFINITION
+ ******************************************************************/
+#define MEMPLUGIN_ION_PARAMS_INIT(buffer_ion_params) do {\
+ buffer_ion_params.alloc_flags = 1 << ION_HEAP_TYPE_CARVEOUT;\
+ buffer_ion_params.map_flags = MAP_SHARED;\
+ buffer_ion_params.nAlign = 0x1000;\
+ buffer_ion_params.prot = PROT_READ | PROT_WRITE;\
+ buffer_ion_params.nOffset = 0;\
+}while(0)
+
+#define MEMPLUGIN_ION_PARAMS_COPY(ion_params_src, ion_params_dest) do {\
+ ion_params_dest.alloc_flags = ion_params_src->alloc_flags;\
+ ion_params_dest.map_flags = ion_params_src->map_flags;\
+ ion_params_dest.nAlign = ion_params_src->nAlign;\
+ ion_params_dest.prot = ion_params_src->prot ;\
+ ion_params_dest.nOffset = ion_params_src->nOffset ;\
+}while(0)
+
+
+
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Init(void **pMemPluginHandle)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+ MEMPLUGIN_OBJECT *pMemPluginHdl;
+
+ pMemPluginHdl = TIMM_OSAL_MallocExtn(sizeof(MEMPLUGIN_OBJECT), TIMM_OSAL_TRUE,
+ 0, TIMMOSAL_MEM_SEGMENT_EXT, NULL);
+ if(pMemPluginHdl == NULL)
+ {
+ eError = MEMPLUGIN_ERROR_NORESOURCES;
+ DOMX_ERROR("%s: allocation failed",__FUNCTION__);
+ goto EXIT;
+ }
+
+ TIMM_OSAL_Memset(pMemPluginHdl, 0, sizeof(MEMPLUGIN_OBJECT));
+
+ pMemPluginHdl->fpOpen = MemPlugin_ION_Open;
+ pMemPluginHdl->fpClose = MemPlugin_ION_Close;
+ pMemPluginHdl->fpConfig = MemPlugin_ION_Configure;
+ pMemPluginHdl->fpAlloc = MemPlugin_ION_Alloc;
+ pMemPluginHdl->fpFree = MemPlugin_ION_Free;
+ pMemPluginHdl->fpDeInit = MemPlugin_ION_DeInit;
+ *pMemPluginHandle = pMemPluginHdl;
+
+EXIT:
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError);
+ }
+ else
+ {
+ DOMX_EXIT("%s: executed successfully",__FUNCTION__);
+ }
+ return eError;
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Open(void *pMemPluginHandle,OMX_U32 *pClient)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+ OMX_U32 memClient = 0;
+ memClient = ion_open();
+ if(memClient == 0)
+ {
+ DOMX_ERROR("ion open failed");
+ eError = MEMPLUGIN_ERROR_UNDEFINED;
+ goto EXIT;
+ }
+ else
+ {
+ *pClient = memClient;
+ }
+EXIT:
+ if(eError != MEMPLUGIN_ERROR_NONE)
+ {
+ DOMX_EXIT("%s: failed with error %d",__FUNCTION__,eError);
+ }
+ else
+ {
+ DOMX_EXIT("%s: executed successfully",__FUNCTION__);
+ }
+ return eError;
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Close(void *pMemPluginHandle, OMX_U32 nClient)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+
+ ion_close(nClient);
+
+EXIT:
+ return eError;
+}
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Configure(void *pMemPluginHandle, void *pConfigData)
+{
+ //implementation to be added later
+EXIT:
+ return(MEMPLUGIN_ERROR_NONE);
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Alloc(void *pMemPluginHandle, OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pIonBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pIonBufferProp)
+{
+ OMX_S16 ret;
+ struct ion_handle *temp;
+ size_t stride;
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+ MEMPLUGIN_ION_PARAMS sIonParams;
+ MEMPLUGIN_OBJECT *pMemPluginHdl = (MEMPLUGIN_OBJECT *)pMemPluginHandle;
+
+ if(pIonBufferParams->nWidth <= 0)
+ {
+ eError = MEMPLUGIN_ERROR_BADPARAMETER;
+ DOMX_ERROR("%s: width should be positive %d", __FUNCTION__,pIonBufferParams->nWidth);
+ }
+
+ if(pMemPluginHdl->pPluginExtendedInfo == NULL)
+ {
+ MEMPLUGIN_ION_PARAMS_INIT(sIonParams);
+ }
+ else
+ {
+ MEMPLUGIN_ION_PARAMS_COPY(((MEMPLUGIN_ION_PARAMS *)pMemPluginHdl->pPluginExtendedInfo),sIonParams);
+ }
+ if(pIonBufferParams->eBuffer_type == DEFAULT)
+ {
+ ret = (OMX_S16)ion_alloc(nClient,
+ pIonBufferParams->nWidth,
+ sIonParams.nAlign,
+ sIonParams.alloc_flags,
+ &temp);
+ if(ret || (int)temp == -ENOMEM)
+ {
+ pIonBufferParams->eBuffer_type = TILER1D;
+ pIonBufferParams->eTiler_format = MEMPLUGIN_TILER_FORMAT_PAGE;
+ sIonParams.alloc_flags = OMAP_ION_HEAP_TILER_MASK;
+ sIonParams.nAlign = -1;
+ }
+ }
+ if(pIonBufferParams->eBuffer_type == TILER1D)
+ {
+ ret = (OMX_S16)ion_alloc_tiler(nClient,
+ pIonBufferParams->nWidth,
+ pIonBufferParams->nHeight,
+ pIonBufferParams->eTiler_format,
+ sIonParams.alloc_flags,
+ &temp,
+ &(pIonBufferProp->nStride));
+
+ if (ret || ((int)temp == -ENOMEM))
+ {
+ DOMX_ERROR("FAILED to allocate buffer of size=%d. ret=0x%x",pIonBufferParams->nWidth, ret);
+ eError = MEMPLUGIN_ERROR_NORESOURCES;
+ goto EXIT;
+ }
+ }
+ else if(pIonBufferParams->eBuffer_type == TILER2D)
+ {
+ DOMX_ERROR("Tiler 2D not implemented");
+ eError = MEMPLUGIN_ERROR_NOTIMPLEMENTED;
+ goto EXIT;
+ }
+ else if(!temp)
+ {
+ DOMX_ERROR("Undefined option for buffer type");
+ eError = MEMPLUGIN_ERROR_UNDEFINED;
+ goto EXIT;
+ }
+ pIonBufferProp->sBuffer_accessor.pBufferHandle = (OMX_PTR)temp;
+ pIonBufferProp->nStride = stride;
+
+ if(pIonBufferParams->bMap == OMX_TRUE)
+ {
+ ret = (OMX_S16) ion_map(nClient,
+ pIonBufferProp->sBuffer_accessor.pBufferHandle,
+ pIonBufferParams->nWidth*pIonBufferParams->nHeight,
+ sIonParams.prot,
+ sIonParams.map_flags,
+ sIonParams.nOffset,
+ (unsigned char **) &(pIonBufferProp->sBuffer_accessor.pBufferMappedAddress),
+ &(pIonBufferProp->sBuffer_accessor.bufferFd));
+
+ if(ret < 0)
+ {
+ DOMX_ERROR("userspace mapping of ION buffers returned error");
+ eError = MEMPLUGIN_ERROR_NORESOURCES;
+ goto EXIT;
+ }
+ }
+ else
+ {
+ ret = (OMX_S16) ion_share(nClient,
+ pIonBufferProp->sBuffer_accessor.pBufferHandle,
+ &(pIonBufferProp->sBuffer_accessor.bufferFd));
+ if(ret < 0)
+ {
+ DOMX_ERROR("ION share returned error");
+ eError = MEMPLUGIN_ERROR_NORESOURCES;
+ goto EXIT;
+ }
+ }
+EXIT:
+ if (eError != MEMPLUGIN_ERROR_NONE) {
+ DOMX_EXIT("%s exited with error 0x%x",__FUNCTION__,eError);
+ return eError;
+ }
+ else {
+ DOMX_EXIT("%s executed successfully",__FUNCTION__);
+ return MEMPLUGIN_ERROR_NONE;
+ }
+}
+
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_Free(void *pMemPluginHandle,OMX_U32 nClient,
+ MEMPLUGIN_BUFFER_PARAMS *pIonBufferParams,
+ MEMPLUGIN_BUFFER_PROPERTIES *pIonBufferProp)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+ DOMX_ENTER("%s: called with arguments ion fd %d buffer-params 0x%x buffer-prop 0x%x",__FUNCTION__,nClient,pIonBufferParams,pIonBufferProp);
+
+ //unmap
+ if(pIonBufferParams->bMap == OMX_TRUE)
+ {
+ munmap(pIonBufferProp->sBuffer_accessor.pBufferMappedAddress, pIonBufferParams->nHeight * pIonBufferParams->nWidth);
+ }
+ //close
+ close(pIonBufferProp->sBuffer_accessor.bufferFd);
+ //free
+ ion_free(nClient, (struct ion_handle*)pIonBufferProp->sBuffer_accessor.pBufferHandle);
+
+EXIT:
+ if (eError != MEMPLUGIN_ERROR_NONE) {
+ DOMX_EXIT("%s exited with error 0x%x",__FUNCTION__,eError);
+ return eError;
+ }
+ else {
+ DOMX_EXIT("%s executed successfully",__FUNCTION__);
+ return MEMPLUGIN_ERROR_NONE;
+ }
+}
+MEMPLUGIN_ERRORTYPE MemPlugin_ION_DeInit(void *pMemPluginHandle)
+{
+ MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
+ MEMPLUGIN_OBJECT *pMemPluginHdl = (MEMPLUGIN_OBJECT *)pMemPluginHandle;
+
+ if(pMemPluginHdl->pPluginExtendedInfo != NULL)
+ {
+ TIMM_OSAL_Free(((MEMPLUGIN_ION_PARAMS *)pMemPluginHdl->pPluginExtendedInfo));
+ }
+ TIMM_OSAL_Free((MEMPLUGIN_OBJECT *)pMemPluginHandle);
+ pMemPluginHandle = NULL;
+EXIT:
+ return (eError);
+}
diff --git a/domx/plugins/memplugin_table.c b/domx/plugins/memplugin_table.c
new file mode 100644
index 0000000..a5b30c4
--- /dev/null
+++ b/domx/plugins/memplugin_table.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** author: Vidhoon Viswanathan
+ * date: 28 sept 2012
+ * This file contains the table that
+ * maps a specific Plugin name to the
+ * specific plugin init method.
+ */
+#include <stdio.h>
+#include "memplugin.h"
+
+extern MEMPLUGIN_ERRORTYPE MemPlugin_ION_Init(MEMPLUGIN_OBJECT * *pMemPluginHandle);
+
+//extern MEMPLUGIN_ERRORTYPE MemPlugin_DRM_Configure(MEMPLUGIN_OBJECT * *pMemPluginHandle);
+
+
+MEMPLUGIN_TABLETYPE MemPlugins_Map[] =
+{
+ { "MEMPLUGIN_ION", &MemPlugin_ION_Init },
+ // {"MEMPLUGIN_DRM" , &MemPlugin_DRM_Configure},
+ { NULL, NULL }
+};