#include <rm_type.h>
#include "mm_radio_utils.h"
-typedef enum {
- MM_RADIO_RES_TYPE_RADIO, /**< ID of radio resource type */
- MM_RADIO_RES_TYPE_MAX, /**< Used to iterate on resource types only */
-} MMRadioResourceTypes;
-
typedef struct _radio_resource_s {
int rm_h;
- rm_device_return_s returned_devices[MM_RADIO_RES_TYPE_MAX];
+ rm_device_return_s returned_devices;
rm_consumer_info rci;
- gboolean need_to_acquire[MM_RADIO_RES_TYPE_MAX];
GMutex rm_callback_lock;
GMutex rm_control_lock;
} radio_resource_s;
int mm_radio_rm_register(MMHandleType hradio);
-int mm_radio_rm_acquire(MMHandleType hradio, MMRadioResourceTypes type);
-int mm_radio_rm_release(MMHandleType hradio, MMRadioResourceTypes type);
+int mm_radio_rm_acquire(MMHandleType hradio);
+int mm_radio_rm_release(MMHandleType hradio);
int mm_radio_rm_unregister(MMHandleType hradio);
MMRADIO_SLOG_DEBUG("now tune to frequency : %d", radio->freq);
radio->interrupted_by_resource_conflict = FALSE;
- ret = mm_radio_rm_acquire((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+ ret = mm_radio_rm_acquire((MMHandleType)radio);
if (ret != MM_ERROR_NONE) {
MMRADIO_LOG_ERROR("resource manager acquire fail");
return MM_ERROR_RADIO_INTERNAL;
/* return MM_ERROR_RADIO_NOT_INITIALIZED; */
if (!radio->interrupted_by_resource_conflict) {
- ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+ ret = mm_radio_rm_release((MMHandleType)radio);
if (ret != MM_ERROR_NONE)
MMRADIO_LOG_ERROR("resource manager release fail");
}
hal_radio_unprepare(radio->hal_radio);
if (!radio->interrupted_by_resource_conflict) {
- ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+ ret = mm_radio_rm_release((MMHandleType)radio);
if (ret != MM_ERROR_NONE)
MMRADIO_LOG_ERROR("resource manager release fail");
}
}
if (!radio->interrupted_by_resource_conflict) {
- ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+ ret = mm_radio_rm_release((MMHandleType)radio);
if (ret != MM_ERROR_NONE)
MMRADIO_LOG_ERROR("resource manager release fail");
}
}
radio->interrupted_by_resource_conflict = FALSE;
- ret = mm_radio_rm_acquire((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+ ret = mm_radio_rm_acquire((MMHandleType)radio);
if (ret != MM_ERROR_NONE) {
MMRADIO_LOG_ERROR("failed to acquire resource manager");
return ret;
error2:
hal_radio_unprepare(radio->hal_radio);
- ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+ ret = mm_radio_rm_release((MMHandleType)radio);
if (ret != MM_ERROR_NONE)
MMRADIO_LOG_ERROR("resource manager release fail");
if (ret)
__convert_error_code(ret, (char *)__FUNCTION__);
- ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+ ret = mm_radio_rm_release((MMHandleType)radio);
if (ret != MM_ERROR_NONE)
MMRADIO_LOG_ERROR("resource manager release fail");
*/
#include "mm_radio_rm.h"
+#ifdef TIZEN_FEATURE_RADIO_HAL
#include "mm_radio_priv_hal.h"
+#else
+#include "mm_radio_priv_emul.h"
+#endif
#include <mm_error.h>
#include <sys/types.h>
#include <unistd.h>
}
-int mm_radio_rm_acquire(MMHandleType hradio, MMRadioResourceTypes type)
+int mm_radio_rm_acquire(MMHandleType hradio)
{
int ret = RM_OK;
int idx = 0;
int category_option = 0;
- rm_rsc_category_e category_id = RM_CATEGORY_NONE;
- rm_requests_resource_state_e state;
rm_category_request_s request_resources;
- rm_device_return_s *returned_device;
+ rm_device_return_s *returned_device = NULL;
g_autoptr(GMutexLocker) locker = NULL;
mm_radio_t *radio = (mm_radio_t *)hradio;
locker = g_mutex_locker_new(&radio->resource.rm_control_lock);
- MMRADIO_LOG_INFO("app id : %s type %d", radio->resource.rci.app_id, type);
+ MMRADIO_LOG_INFO("app id : %s", radio->resource.rci.app_id);
memset(&request_resources, 0x0, sizeof(rm_category_request_s));
- returned_device = &radio->resource.returned_devices[type];
+ returned_device = &radio->resource.returned_devices;
memset(returned_device, 0x0, sizeof(rm_device_return_s));
- switch (type) {
- case MM_RADIO_RES_TYPE_RADIO:
- state = RM_STATE_EXCLUSIVE;
- category_id = RM_CATEGORY_RADIO;
- break;
- default:
- MMRADIO_LOG_ERROR("category id can't set");
- return MM_ERROR_RADIO_INTERNAL;
- }
-
- category_option = rc_get_capable_category_id(radio->resource.rm_h, radio->resource.rci.app_id, category_id);
+ category_option = rc_get_capable_category_id(radio->resource.rm_h, radio->resource.rci.app_id, RM_CATEGORY_RADIO);
request_resources.request_num = 1;
- request_resources.state[0] = state;
- request_resources.category_id[0] = category_id;
+ request_resources.state[0] = RM_STATE_EXCLUSIVE;
+ request_resources.category_id[0] = RM_CATEGORY_RADIO;
request_resources.category_option[0] = category_option;
- MMRADIO_LOG_INFO("state %d category id 0x%x category option %d", state, category_id, category_option);
+ MMRADIO_LOG_INFO("state %d category id 0x%x category option %d", request_resources.state[0],
+ request_resources.category_id[0], request_resources.category_option[0]);
ret = rm_allocate_resources(radio->resource.rm_h, &request_resources, returned_device);
if (ret != RM_OK) {
return MM_ERROR_NONE;
}
-int mm_radio_rm_release(MMHandleType hradio, MMRadioResourceTypes type)
+int mm_radio_rm_release(MMHandleType hradio)
{
int rm_ret = RM_OK;
int idx = 0;
locker = g_mutex_locker_new(&radio->resource.rm_control_lock);
- r_devices = &radio->resource.returned_devices[type];
+ r_devices = &radio->resource.returned_devices;
- MMRADIO_LOG_INFO("[%p] #%d (type %d) alloc num %d", r_devices, idx, type, r_devices->allocated_num);
+ MMRADIO_LOG_INFO("[%p] #%d alloc num %d", r_devices, idx, r_devices->allocated_num);
if (r_devices->allocated_num > 0) {
memset(&requested, 0x0, sizeof(rm_device_request_s));