2 * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file drm_intf_tapps.cpp
19 * @brief This file includes definitions of the drm TAPPS intf APIs.
22 #include "drm_intf_tapps.h"
24 /* String Operations */
25 #ifdef _TAPPS_DEBUG_ENABLE_
26 unsigned int TAPPS_gstrlcat(char* s1,const char* s2,unsigned int destsize,const char* funName, unsigned int lineno)
28 unsigned int ret_g_strlcat = (unsigned int)g_strlcat(s1, s2, destsize);
30 if(ret_g_strlcat >= (unsigned int)destsize)
32 DRM_TAPPS_EXCEPTION("Truncation occured during concatenation at [%s:%u] s1=%s s2=%s destsize=%u ret_g_strlcpy=%u \n",funName,lineno,s1,s2,destsize,ret_g_strlcat);
36 DRM_TAPPS_FRQ_LOG("Concatenation Successful at [%s:%u] s1=%s s2=%s destsize=%u ret_g_strlcpy=%u \n",funName,lineno,s1,s2,destsize,ret_g_strlcat);
42 unsigned int TAPPS_gstrlcpy(char* s1,const char* s2,unsigned int destsize,const char* funName, unsigned int lineno)
44 unsigned int ret_g_strlcpy = (unsigned int)g_strlcpy(s1, s2, destsize);
46 if(ret_g_strlcpy >= (unsigned int)destsize)
48 DRM_TAPPS_EXCEPTION("Truncation occured during copying at [%s:%u] s1=%s s2=%s destsize=%u ret_g_strlcpy=%u \n",funName,lineno,s1,s2,destsize,ret_g_strlcpy);
52 DRM_TAPPS_FRQ_LOG("Copy Successful at [%s:%u] s1=%s s2=%s destsize=%u ret_g_strlcpy=%u \n",funName,lineno,s1,s2,destsize,ret_g_strlcpy);
58 unsigned int TAPPS_strlen(const char* s,const char* funName, unsigned int lineno)
60 DRM_TAPPS_FRQ_LOG("Function = %s, Line number = %u",funName,lineno);
66 int TAPPS_strnicmp(const char * s1, const char * s2, unsigned int sz)
74 if ( ((tmp1 = (unsigned char)(*(s1++))) >= 'A') && (tmp1 <= 'Z') )
77 if ( ((tmp2 = (unsigned char)(*(s2++))) >= 'A') && (tmp2 <= 'Z') )
81 } while ( tmp1 && (tmp1== tmp2) && idx < sz);
89 int dtapps_mutex_lock (dtappslockarg dtapps_mutex)
93 DRM_TAPPS_FRQ_LOG( "%s MUT-LK-ULK Thread [%d] trying to lock the Mutex=0x%x \n",__func__,drmgettid(),dtapps_mutex);
95 retval = pthread_mutex_lock(dtapps_mutex);
101 DRM_TAPPS_FRQ_LOG("Mutex is already locked by the same thread \n");
105 DRM_TAPPS_EXCEPTION( "Error locking mutex %d \n", retval);
106 perror("\n drm_mutex_lock:Error:");
112 DRM_TAPPS_FRQ_LOG( "Mutex lock is successful \n");
114 DRM_TAPPS_FRQ_LOG( "%s retval=%d \n",__func__,retval);
120 int dtapps_mutex_unlock (dtappslockarg dtapps_mutex)
124 DRM_TAPPS_FRQ_LOG( "%s MUT-LK-ULK Thread [%d] trying to unlock the Mutex=0x%x \n",__func__,drmgettid(),dtapps_mutex);
126 status = pthread_mutex_unlock(dtapps_mutex);
130 DRM_TAPPS_EXCEPTION( "Error unlocking mutex:return value=[%d] \n", status);
131 perror("\n drm_mutex_unlock:Error:");
136 DRM_TAPPS_FRQ_LOG( "Mutex unlocked is successful :return value=[%d] \n",status);
139 DRM_TAPPS_FRQ_LOG( "%s status=%d \n",__func__,status);
144 void dtapps_sleep(unsigned int TimeInSec,unsigned int TimeInMicroSec)
148 tv.tv_sec = TimeInSec;
149 tv.tv_usec = TimeInMicroSec;
151 DRM_TAPPS_FRQ_LOG("%s TimeInSec =%u TimeInMicroSec=%u \n",__func__,tv.tv_sec,tv.tv_usec);
153 retval = select(0, NULL, NULL, NULL, &tv);
155 DRM_TAPPS_FRQ_LOG("%s select retval=%d \n",__func__,retval);