Add camera resource manage into all display case 82/218682/4
authorHyuntae Kim <ht1211.kim@samsung.com>
Wed, 27 Nov 2019 02:11:24 +0000 (11:11 +0900)
committerHyuntae Kim <ht1211.kim@samsung.com>
Wed, 4 Dec 2019 01:33:30 +0000 (10:33 +0900)
[Version] 0.10.190
[Profile] TV
[Issue Type] Update

Change-Id: Id32ada6f715c0803322eefbd58c3af2ddb232042

packaging/libmm-camcorder.spec
src/Makefile.am
src/include/mm_camcorder_rm.h [new file with mode: 0644]
src/mm_camcorder_internal.c
src/mm_camcorder_rm.c [new file with mode: 0644]

index d20b3d1..a93758a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.189
+Version:    0.10.190
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index d6403cc..0fdc6db 100644 (file)
@@ -18,6 +18,9 @@ noinst_HEADERS = include/mm_camcorder_audiorec.h \
                 include/mm_camcorder_exifinfo.h \
                 include/mm_camcorder_exifdef.h \
                 include/mm_camcorder_sound.h
+if RM_SUPPORT
+noinst_HEADERS += include/mm_camcorder_rm.h
+endif
 
 libmmfcamcorder_la_SOURCES = mm_camcorder.c \
                             mm_camcorder_internal.c \
@@ -31,6 +34,9 @@ libmmfcamcorder_la_SOURCES = mm_camcorder.c \
                             mm_camcorder_util.c \
                             mm_camcorder_exifinfo.c \
                             mm_camcorder_sound.c
+if RM_SUPPORT
+libmmfcamcorder_la_SOURCES += mm_camcorder_rm.c
+endif
 
 libmmfcamcorder_la_CFLAGS = -I$(srcdir)/include \
                             $(GST_CFLAGS) \
diff --git a/src/include/mm_camcorder_rm.h b/src/include/mm_camcorder_rm.h
new file mode 100644 (file)
index 0000000..f5f83f5
--- /dev/null
@@ -0,0 +1,40 @@
+/*\r
+ * libmm-camcorder\r
+ *\r
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Hyuntae Kim <ht1211.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+#ifndef __MM_CAMCORDER_RM_H__\r
+#define __MM_CAMCORDER_RM_H__\r
+\r
+#include <mm_types.h>\r
+\r
+/*=======================================================================================\r
+| GLOBAL FUNCTION PROTOTYPES                                                           |\r
+========================================================================================*/\r
+\r
+int _mmcamcorder_rm_create(MMHandleType handle);\r
+\r
+int _mmcamcorder_rm_allocate(MMHandleType handle);\r
+\r
+\r
+int _mmcamcorder_rm_deallocate(MMHandleType handle);\r
+\r
+int _mmcamcorder_rm_release(MMHandleType handle);\r
+\r
+#endif /*__MM_CAMCORDER_RM_H__*/\r
+\r
index a48529f..200b068 100644 (file)
@@ -42,7 +42,7 @@
 #include <system_info.h>
 
 #ifdef _MMCAMCORDER_RM_SUPPORT
-#include <aul.h>
+#include "mm_camcorder_rm.h"
 #endif /* _MMCAMCORDER_RM_SUPPORT */
 
 /*---------------------------------------------------------------------------------------
@@ -85,10 +85,6 @@ static gboolean __mmcamcorder_handle_gst_warning(MMHandleType handle, GstMessage
 static int      __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
        mm_resource_manager_res_h res, void *user_data);
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
-#ifdef _MMCAMCORDER_RM_SUPPORT
-rm_cb_result    _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
-       rm_device_request_s *info, void *cb_data);
-#endif /* _MMCAMCORDER_RM_SUPPORT */
 #ifdef _MMCAMCORDER_USE_SET_ATTR_CB
 static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data);
 #endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
@@ -676,9 +672,6 @@ int _mmcamcorder_destroy(MMHandleType handle)
 {
        int ret = MM_ERROR_NONE;
        int state = MM_CAMCORDER_STATE_NONE;
-#ifdef _MMCAMCORDER_RM_SUPPORT
-       int iret = RM_OK;
-#endif /* _MMCAMCORDER_RM_SUPPORT */
        GstElement *sink_element = NULL;
        int sink_element_size = 0;
 
@@ -754,12 +747,7 @@ int _mmcamcorder_destroy(MMHandleType handle)
        _mmcamcorder_remove_message_all(handle);
 
 #ifdef _MMCAMCORDER_RM_SUPPORT
-       if (hcamcorder->rm_handle != 0) {
-               iret = rm_unregister(hcamcorder->rm_handle);
-               if (iret != RM_OK)
-                       _mmcam_dbg_err("rm_unregister() failed");
-               hcamcorder->rm_handle = 0;
-       }
+       _mmcamcorder_rm_release(handle);
 #endif /* _MMCAMCORDER_RM_SUPPORT */
 
        /* release DPM handle */
@@ -809,15 +797,6 @@ int _mmcamcorder_realize(MMHandleType handle)
        char *socket_path = NULL;
        int socket_path_len = 0;
        int conn_size = 0;
-#ifdef _MMCAMCORDER_RM_SUPPORT
-       int iret = RM_OK;
-       int preview_format = MM_PIXEL_FORMAT_NV12;
-       int qret = RM_OK;
-       int qret_avail = 0; /* 0: not available, 1: available */
-       rm_consumer_info rci;
-       int app_pid = 0;
-       int resource_count = 0;
-#endif /* _MMCAMCORDER_RM_SUPPORT */
 
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
 
@@ -1021,84 +1000,16 @@ int _mmcamcorder_realize(MMHandleType handle)
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
 #ifdef _MMCAMCORDER_RM_SUPPORT
-               if (display_surface_type != MM_DISPLAY_SURFACE_NULL) {
-                       mm_camcorder_get_attributes(handle, NULL,
-                               MMCAM_CLIENT_PID, &app_pid,
-                               NULL);
-                       rci.app_pid = app_pid;
-                       aul_app_get_appid_bypid(rci.app_pid, rci.app_id, sizeof(rci.app_id));
-
-                       /* RM register */
-                       if (hcamcorder->rm_handle == 0) {
-                               iret = rm_register((rm_resource_cb)_mmcamcorder_rm_callback, (void*)hcamcorder, &(hcamcorder->rm_handle), &rci);
-                               if (iret != RM_OK) {
-                                       _mmcam_dbg_err("rm_register fail");
-                                       ret = MM_ERROR_RESOURCE_INTERNAL;
-                                       goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-                               }
-                       }
-
-                       mm_camcorder_get_attributes(handle, NULL,
-                               MMCAM_CAMERA_FORMAT, &preview_format,
-                               NULL);
-
-                       resource_count = 0;
-                       memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
-                       memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
-
-                       if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-                               hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
-                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
-
-                               _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER);
-
-                               resource_count++;
-                       }
-
-                       if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                               hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
-                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
-
-                               _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
-
-                               resource_count++;
-                       }
-
-                       hcamcorder->request_resources.request_num = resource_count;
-
-                       if (resource_count > 0) {
-                               qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
-                               if (qret != RM_OK || qret_avail != 1) {
-                                       _mmcam_dbg_log("rm query failed. retry with sub devices");
-
-                                       resource_count = 0;
-
-                                       if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-                                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
-                                               _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER_SUB);
-                                               resource_count++;
-                                       }
-
-                                       if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                                               hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
-                                               _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
-                                               resource_count++;
-                                       }
-                               }
-                       }
-
-                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
-                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_CAMERA;
-
-                       hcamcorder->request_resources.request_num = resource_count + 1;
-                       _mmcam_dbg_log("request camera rsc - category 0x%x", RM_CATEGORY_CAMERA);
-
-                       iret = rm_allocate_resources(hcamcorder->rm_handle, &(hcamcorder->request_resources), &hcamcorder->returned_devices);
-                       if (iret != RM_OK) {
-                               _mmcam_dbg_err("Resource allocation request failed");
-                               ret = MM_ERROR_RESOURCE_INTERNAL;
-                               goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-                       }
+               ret = _mmcamcorder_rm_create(handle);
+               if (ret != MM_ERROR_NONE) {
+                       _mmcam_dbg_err("Resource create failed");
+                       goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+               }
+               ret = _mmcamcorder_rm_allocate(handle);
+               if (ret != MM_ERROR_NONE) {
+                       _mmcam_dbg_err("Resource allocation request failed");
+                       _mmcamcorder_rm_release(handle);
+                       goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
                }
 #endif /* _MMCAMCORDER_RM_SUPPORT */
        }
@@ -1158,26 +1069,8 @@ _ERR_CAMCORDER_CMD:
        _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 #ifdef _MMCAMCORDER_RM_SUPPORT
-       if (hcamcorder->rm_handle) {
-               if (hcamcorder->returned_devices.allocated_num > 0) {
-                       int idx = 0;
-                       rm_device_request_s requested;
-                       memset(&requested, 0x0, sizeof(rm_device_request_s));
-                       requested.request_num = hcamcorder->returned_devices.allocated_num;
-                       for (idx = 0; idx < requested.request_num; idx++)
-                               requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
-
-                       iret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
-                       if (iret != RM_OK)
-                               _mmcam_dbg_err("Resource deallocation request failed ");
-               }
-
-               /* unregister RM */
-               int ires = rm_unregister(hcamcorder->rm_handle);
-               if (ires != RM_OK)
-                       _mmcam_dbg_err("rm_unregister() failed");
-               hcamcorder->rm_handle = 0;
-       }
+       _mmcamcorder_rm_deallocate(handle);
+       _mmcamcorder_rm_release(handle);
 #endif /* _MMCAMCORDER_RM_SUPPORT*/
 
 _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
@@ -1284,19 +1177,7 @@ int _mmcamcorder_unrealize(MMHandleType handle)
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
 #ifdef _MMCAMCORDER_RM_SUPPORT
-       if (hcamcorder->rm_handle && (hcamcorder->returned_devices.allocated_num > 0)) {
-                       int iret = RM_OK;
-                       int idx = 0;
-                       rm_device_request_s requested;
-                       memset(&requested, 0x0, sizeof(rm_device_request_s));
-                       requested.request_num = hcamcorder->returned_devices.allocated_num;
-                       for (idx = 0; idx < requested.request_num; idx++)
-                               requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
-
-                       iret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
-                       if (iret != RM_OK)
-                               _mmcam_dbg_err("Resource deallocation request failed ");
-               }
+       _mmcamcorder_rm_deallocate(handle);
 #endif /* _MMCAMCORDER_RM_SUPPORT*/
 
        /* Deinitialize main context member */
@@ -4081,43 +3962,6 @@ static int __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
 }
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
-
-#ifdef _MMCAMCORDER_RM_SUPPORT
-rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
-       rm_device_request_s *info, void* cb_data)
-{
-       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(cb_data);
-       int current_state = MM_CAMCORDER_STATE_NONE;
-       rm_cb_result cb_res = RM_CB_RESULT_OK;
-
-       mmf_return_val_if_fail((MMHandleType)hcamcorder, RM_CB_RESULT_OK);
-
-       current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
-
-       _mmcam_dbg_warn("current state %d (handle %p)", current_state, hcamcorder);
-
-       _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
-
-       /* set RM event code for sending it to application */
-       hcamcorder->interrupt_code = event_src;
-
-       _mmcam_dbg_log("RM conflict callback : event code 0x%x", event_src);
-       switch (event_src) {
-       case RM_CALLBACK_TYPE_RESOURCE_CONFLICT:
-       case RM_CALLBACK_TYPE_RESOURCE_CONFLICT_UD:
-               __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
-               break;
-       default:
-               break;
-       }
-
-       _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
-
-       return cb_res;
-}
-#endif /* _MMCAMCORDER_RM_SUPPORT */
-
-
 int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state)
 {
        int ret = MM_ERROR_NONE;
diff --git a/src/mm_camcorder_rm.c b/src/mm_camcorder_rm.c
new file mode 100644 (file)
index 0000000..7291d54
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * libmm-camcorder
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyuntae Kim <ht1211.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+ /*=======================================================================================
+|  INCLUDE FILES                                                                       |
+========================================================================================*/
+#ifdef _MMCAMCORDER_RM_SUPPORT
+#include <aul.h>
+#include <rm_api.h>
+#include "mm_camcorder_rm.h"
+#include "mm_camcorder_internal.h"
+
+static rm_cb_result __mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
+       rm_device_request_s *info, void* cb_data)
+{
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(cb_data);
+       int current_state = MM_CAMCORDER_STATE_NONE;
+       rm_cb_result cb_res = RM_CB_RESULT_OK;
+
+       mmf_return_val_if_fail((MMHandleType)hcamcorder, RM_CB_RESULT_OK);
+
+       current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
+
+       _mmcam_dbg_warn("current state %d (handle %p)", current_state, hcamcorder);
+
+       _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
+
+       /* set RM event code for sending it to application */
+       hcamcorder->interrupt_code = event_src;
+
+       _mmcam_dbg_log("RM conflict callback : event code 0x%x", event_src);
+       switch (event_src) {
+       case RM_CALLBACK_TYPE_RESOURCE_CONFLICT:
+       case RM_CALLBACK_TYPE_RESOURCE_CONFLICT_UD:
+               __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
+               break;
+       default:
+               break;
+       }
+
+       _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
+
+       return cb_res;
+}
+
+
+
+int _mmcamcorder_rm_create(MMHandleType handle)
+{
+       int ret = RM_OK;
+       rm_consumer_info rci;
+       int app_pid = 0;
+
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+       if (!hcamcorder) {
+               _mmcam_dbg_err("Not initialized");
+               return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+       }
+
+       mm_camcorder_get_attributes(handle, NULL,
+               MMCAM_CLIENT_PID, &app_pid,
+               NULL);
+       rci.app_pid = app_pid;
+       aul_app_get_appid_bypid(rci.app_pid, rci.app_id, sizeof(rci.app_id));
+
+       /* RM register */
+       if (hcamcorder->rm_handle == 0) {
+               ret = rm_register((rm_resource_cb)__mmcamcorder_rm_callback, (void*)hcamcorder, &(hcamcorder->rm_handle), &rci);
+               if (ret != RM_OK) {
+                       _mmcam_dbg_err("rm_register fail ret = %d",ret);
+                       return MM_ERROR_RESOURCE_INTERNAL;
+               }
+       }
+       return MM_ERROR_NONE;
+}
+
+int _mmcamcorder_rm_allocate(MMHandleType handle)
+{
+       int iret = RM_OK;
+       int preview_format = MM_PIXEL_FORMAT_NV12;
+       int qret = RM_OK;
+       int qret_avail = 0; /* 0: not available, 1: available */
+       int resource_count = 0;
+       int display_surface_type = MM_DISPLAY_SURFACE_OVERLAY;
+
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+       if (!hcamcorder) {
+               _mmcam_dbg_err("Not initialized");
+               return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+       }
+
+       mm_camcorder_get_attributes(handle, NULL,
+               MMCAM_DISPLAY_SURFACE, &display_surface_type,
+               NULL);
+
+       if (display_surface_type != MM_DISPLAY_SURFACE_NULL) {
+               mm_camcorder_get_attributes(handle, NULL,
+                       MMCAM_CAMERA_FORMAT, &preview_format,
+                       NULL);
+
+               resource_count = 0;
+               memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
+               memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
+
+               if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
+
+                       _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER);
+
+                       resource_count++;
+               }
+
+               if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
+
+                       _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
+
+                       resource_count++;
+               }
+
+               hcamcorder->request_resources.request_num = resource_count;
+
+               if (resource_count > 0) {
+                       qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
+                       if (qret != RM_OK || qret_avail != 1) {
+                               _mmcam_dbg_log("rm query failed. retry with sub devices");
+
+                               resource_count = 0;
+                               memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
+                               memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
+
+                               if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+                                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
+                                       _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER_SUB);
+                                       resource_count++;
+                               }
+
+                               if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+                                       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+                                       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
+                                       _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
+                                       resource_count++;
+                               }
+                       }
+               }
+       }
+
+       hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+       hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_CAMERA;
+
+       hcamcorder->request_resources.request_num = resource_count + 1;
+       _mmcam_dbg_log("request camera rsc - category 0x%x", RM_CATEGORY_CAMERA);
+
+       iret = rm_allocate_resources(hcamcorder->rm_handle, &(hcamcorder->request_resources), &hcamcorder->returned_devices);
+       if (iret != RM_OK) {
+               _mmcam_dbg_err("Resource allocation request failed ret = %d",iret);
+               return MM_ERROR_RESOURCE_INTERNAL;
+       }
+
+       return MM_ERROR_NONE;
+}
+
+
+int _mmcamcorder_rm_deallocate(MMHandleType handle)
+{
+       int rm_ret = RM_OK;
+       int idx = 0;
+       rm_device_request_s requested;
+
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+       if (!hcamcorder->rm_handle) {
+               _mmcam_dbg_err("Resource is not initialized ");
+               return MM_ERROR_RESOURCE_NOT_INITIALIZED;
+       }
+
+       if (hcamcorder->returned_devices.allocated_num > 0) {
+               memset(&requested, 0x0, sizeof(rm_device_request_s));
+               requested.request_num = hcamcorder->returned_devices.allocated_num;
+               for (idx = 0; idx < requested.request_num; idx++)
+                       requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
+
+               rm_ret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
+               if (rm_ret != RM_OK)
+                       _mmcam_dbg_err("Resource deallocation request failed ");
+       }
+
+       return MM_ERROR_NONE;
+}
+
+int _mmcamcorder_rm_release(MMHandleType handle)
+{
+       int rm_ret = RM_OK;
+
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+       if (!hcamcorder->rm_handle) {
+               _mmcam_dbg_err("Resource is not initialized ");
+               return MM_ERROR_RESOURCE_NOT_INITIALIZED;
+       }
+
+       /* unregister RM */
+       rm_ret = rm_unregister(hcamcorder->rm_handle);
+       if (rm_ret != RM_OK)
+               _mmcam_dbg_err("rm_unregister() failed");
+       hcamcorder->rm_handle = 0;
+
+       return MM_ERROR_NONE;
+}
+
+#endif /* _MMCAMCORDER_RM_SUPPORT*/
+