2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <radio_private.h>
24 #include <system_info.h>
29 #define LOG_TAG "TIZEN_N_RADIO"
34 #define RADIO_CHECK_CONDITION(condition, error, msg) \
38 LOGE("[%s] %s(0x%08x)", (char *)__FUNCTION__, msg, error); \
43 #define RADIO_INSTANCE_CHECK(radio) \
44 RADIO_CHECK_CONDITION(radio != NULL, RADIO_ERROR_INVALID_PARAMETER, "RADIO_ERROR_INVALID_PARAMETER")
46 #define RADIO_STATE_CHECK(radio, expected_state) \
47 RADIO_CHECK_CONDITION(radio->state == expected_state, RADIO_ERROR_INVALID_STATE, "RADIO_ERROR_INVALID_STATE")
49 #define RADIO_NULL_ARG_CHECK(arg) \
50 RADIO_CHECK_CONDITION(arg != NULL, RADIO_ERROR_INVALID_PARAMETER, "RADIO_ERROR_INVALID_PARAMETER")
52 #define RADIO_SUPPORT_CHECK(arg) \
53 RADIO_CHECK_CONDITION(arg != false, RADIO_ERROR_NOT_SUPPORTED, "RADIO_ERROR_NOT_SUPPORTED")
56 * Internal Implementation
58 static int __convert_error_code(int code, char *func_name)
60 int ret = RADIO_ERROR_NONE;
61 char *msg = "RADIO_ERROR_NONE";
62 LOGI("[%s] Enter code :%x", __func__, code);
65 ret = RADIO_ERROR_NONE;
66 msg = "RADIO_ERROR_NONE";
69 case MM_ERROR_RADIO_NO_FREE_SPACE:
70 ret = RADIO_ERROR_OUT_OF_MEMORY;
71 msg = "RADIO_ERROR_OUT_OF_MEMORY";
73 case MM_ERROR_RADIO_NOT_INITIALIZED:
74 case MM_ERROR_RADIO_NO_OP:
75 case MM_ERROR_RADIO_INVALID_STATE:
76 ret = RADIO_ERROR_INVALID_STATE;
77 msg = "RADIO_ERROR_INVALID_STATE";
79 case MM_ERROR_COMMON_INVALID_ARGUMENT:
80 case MM_ERROR_INVALID_ARGUMENT:
81 ret = RADIO_ERROR_INVALID_PARAMETER;
82 msg = "RADIO_ERROR_INVALID_PARAMETER";
84 case MM_ERROR_POLICY_BLOCKED:
85 case MM_ERROR_POLICY_INTERRUPTED:
86 case MM_ERROR_POLICY_INTERNAL:
87 case MM_ERROR_POLICY_DUPLICATED:
88 ret = RADIO_ERROR_SOUND_POLICY;
89 msg = "RADIO_ERROR_SOUND_POLICY";
91 case MM_ERROR_RADIO_INTERNAL:
92 case MM_ERROR_RADIO_RESPONSE_TIMEOUT:
93 ret = RADIO_ERROR_INVALID_OPERATION;
94 msg = "RADIO_ERROR_INVALID_OPERATION";
96 case MM_ERROR_RADIO_DEVICE_NOT_FOUND:
97 ret = RADIO_ERROR_NOT_SUPPORTED;
98 msg = "RADIO_ERROR_NOT_SUPPORTED";
100 case MM_ERROR_RADIO_NO_ANTENNA:
101 ret = RADIO_ERROR_NO_ANTENNA;
102 msg = "RADIO_ERROR_NO_ANTENNA";
104 case MM_ERROR_RADIO_DEVICE_NOT_OPENED:
106 ret = RADIO_ERROR_PERMISSION_DENIED;
107 msg = "RADIO_ERROR_PERMISSION_DENIED";
109 LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
113 static radio_state_e __convert_radio_state(MMRadioStateType state)
115 int converted_state = RADIO_STATE_READY;
116 LOGI("[%s] Enter state: %d", __func__, state);
119 case MM_RADIO_STATE_PLAYING:
120 converted_state = RADIO_STATE_PLAYING;
122 case MM_RADIO_STATE_SCANNING:
123 converted_state = RADIO_STATE_SCANNING;
125 case MM_RADIO_STATE_NULL:
126 case MM_RADIO_STATE_READY:
128 converted_state = RADIO_STATE_READY;
131 LOGI("[%s] Leave converted_state: %d", __func__, converted_state);
132 return converted_state;
135 static radio_interrupted_code_e __convert_interrupted_code(int code)
137 LOGI("[%s] Enter code: %d", __func__, code);
138 radio_interrupted_code_e ret = RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT;
140 case MM_MSG_CODE_INTERRUPTED_BY_CALL_END:
141 case MM_MSG_CODE_INTERRUPTED_BY_ALARM_END:
142 case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_END:
143 case MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_END:
144 ret = RADIO_INTERRUPTED_COMPLETED;
146 case MM_MSG_CODE_INTERRUPTED_BY_MEDIA:
147 case MM_MSG_CODE_INTERRUPTED_BY_OTHER_PLAYER_APP:
148 ret = RADIO_INTERRUPTED_BY_MEDIA;
150 case MM_MSG_CODE_INTERRUPTED_BY_CALL_START:
151 ret = RADIO_INTERRUPTED_BY_CALL;
153 case MM_MSG_CODE_INTERRUPTED_BY_EARJACK_UNPLUG:
154 ret = RADIO_INTERRUPTED_BY_EARJACK_UNPLUG;
156 case MM_MSG_CODE_INTERRUPTED_BY_ALARM_START:
157 ret = RADIO_INTERRUPTED_BY_ALARM;
159 case MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_START:
160 ret = RADIO_INTERRUPTED_BY_NOTIFICATION;
162 case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_START:
163 ret = RADIO_INTERRUPTED_BY_EMERGENCY;
165 case MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT:
167 ret = RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT;
170 LOGE("[%s] interrupted code(%d) => ret(%d)", __FUNCTION__, code, ret);
174 static int __set_callback(_radio_event_e type, radio_h radio, void *callback, void *user_data)
176 RADIO_INSTANCE_CHECK(radio);
177 RADIO_NULL_ARG_CHECK(callback);
178 radio_s *handle = (radio_s *)radio;
179 handle->user_cb[type] = callback;
180 handle->user_data[type] = user_data;
181 LOGI("[%s] Event type : %d ", __FUNCTION__, type);
182 return RADIO_ERROR_NONE;
185 static int __unset_callback(_radio_event_e type, radio_h radio)
187 RADIO_INSTANCE_CHECK(radio);
188 radio_s *handle = (radio_s *)radio;
189 handle->user_cb[type] = NULL;
190 handle->user_data[type] = NULL;
191 LOGI("[%s] Event type : %d ", __FUNCTION__, type);
192 return RADIO_ERROR_NONE;
195 static int __msg_callback(int message, void *param, void *user_data)
197 radio_s *handle = (radio_s *)user_data;
198 MMMessageParamType *msg = (MMMessageParamType *)param;
199 LOGI("[%s] Got message type : 0x%x", __FUNCTION__, message);
201 case MM_MESSAGE_RADIO_SCAN_INFO:
202 if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO])
203 ((radio_scan_updated_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO])(msg->radio_scan.frequency, handle->user_data[_RADIO_EVENT_TYPE_SCAN_INFO]);
205 case MM_MESSAGE_RADIO_SCAN_STOP:
206 if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP])
207 ((radio_scan_stopped_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_STOP]);
209 case MM_MESSAGE_RADIO_SCAN_FINISH:
210 if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH])
211 ((radio_scan_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_FINISH]);
213 case MM_MESSAGE_RADIO_SEEK_FINISH:
214 if (handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH])
215 ((radio_seek_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH])(msg->radio_scan.frequency, handle->user_data[_RADIO_EVENT_TYPE_SEEK_FINISH]);
217 case MM_MESSAGE_STATE_INTERRUPTED:
218 if (handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])
219 ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(__convert_interrupted_code(msg->code), handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]);
221 case MM_MESSAGE_READY_TO_RESUME:
222 if (handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])
223 ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(RADIO_INTERRUPTED_COMPLETED, handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]);
225 case MM_MESSAGE_ERROR:
226 __convert_error_code(msg->code, (char *)__FUNCTION__);
228 case MM_MESSAGE_RADIO_SCAN_START:
229 LOGI("[%s] Scan Started");
231 case MM_MESSAGE_STATE_CHANGED:
232 handle->state = __convert_radio_state(msg->state.current);
233 LOGI("[%s] State Changed --- from : %d , to : %d", __FUNCTION__, __convert_radio_state(msg->state.previous), handle->state);
235 case MM_MESSAGE_RADIO_SEEK_START:
236 LOGI("[%s] Seek Started", __FUNCTION__);
244 static int __radio_check_system_info_feature_supported()
249 nRetVal = system_info_get_platform_bool("http://tizen.org/feature/fmradio", &bValue);
251 if (nRetVal != SYSTEM_INFO_ERROR_NONE) {
252 LOGE("[%s] SYSTEM_INFO_ERROR : ", __FUNCTION__);
257 LOGI("system_info_get_platform_bool returned Unsupported feature capability\n");
259 LOGI("system_info_get_platform_bool returned Supported status feature\n");
265 * Public Implementation
267 int radio_create(radio_h *radio)
269 LOGI("[%s] Enter", __func__);
270 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
271 RADIO_INSTANCE_CHECK(radio);
274 handle = (radio_s *)malloc(sizeof(radio_s));
275 if (handle != NULL) {
276 memset(handle, 0, sizeof(radio_s));
278 LOGE("[%s] RADIO_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, RADIO_ERROR_OUT_OF_MEMORY);
279 return RADIO_ERROR_OUT_OF_MEMORY;
281 int ret = mm_radio_create(&handle->mm_handle);
282 if (ret != MM_ERROR_NONE) {
285 return __convert_error_code(ret, (char *)__FUNCTION__);
287 *radio = (radio_h)handle;
289 ret = mm_radio_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle);
290 if (ret != MM_ERROR_NONE)
291 LOGW("[%s] Failed to set message callback function (0x%x)", __FUNCTION__, ret);
293 ret = mm_radio_realize(handle->mm_handle);
294 if (ret != MM_ERROR_NONE)
295 return __convert_error_code(ret, (char *)__FUNCTION__);
297 handle->state = RADIO_STATE_READY;
298 handle->mute = FALSE;
299 return RADIO_ERROR_NONE;
303 int radio_destroy(radio_h radio)
305 LOGI("[%s] Enter", __func__);
306 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
307 RADIO_INSTANCE_CHECK(radio);
308 radio_s *handle = (radio_s *)radio;
311 ret = mm_radio_unrealize(handle->mm_handle);
312 if (ret != MM_ERROR_NONE)
313 LOGW("[%s] Failed to unrealize (0x%x)", __FUNCTION__, ret);
315 ret = mm_radio_destroy(handle->mm_handle);
316 if (ret != MM_ERROR_NONE) {
317 return __convert_error_code(ret, (char *)__FUNCTION__);
321 return RADIO_ERROR_NONE;
325 int radio_get_state(radio_h radio, radio_state_e *state)
327 LOGI("[%s] Enter", __func__);
328 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
329 RADIO_INSTANCE_CHECK(radio);
330 RADIO_NULL_ARG_CHECK(state);
331 radio_s *handle = (radio_s *)radio;
332 MMRadioStateType currentStat = MM_RADIO_STATE_NULL;
333 int ret = mm_radio_get_state(handle->mm_handle, ¤tStat);
334 if (ret != MM_ERROR_NONE) {
335 *state = handle->state;
336 return __convert_error_code(ret, (char *)__FUNCTION__);
338 handle->state = __convert_radio_state(currentStat);
339 *state = handle->state;
340 return RADIO_ERROR_NONE;
344 int radio_start(radio_h radio)
346 LOGI("[%s] Enter", __func__);
347 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
348 RADIO_INSTANCE_CHECK(radio);
349 radio_s *handle = (radio_s *)radio;
350 RADIO_STATE_CHECK(handle, RADIO_STATE_READY);
352 int ret = mm_radio_start(handle->mm_handle);
353 if (ret != MM_ERROR_NONE) {
354 return __convert_error_code(ret, (char *)__FUNCTION__);
356 handle->state = RADIO_STATE_PLAYING;
357 return RADIO_ERROR_NONE;
361 int radio_stop(radio_h radio)
363 LOGI("[%s] Enter", __func__);
364 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
365 RADIO_INSTANCE_CHECK(radio);
366 radio_s *handle = (radio_s *)radio;
367 RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
369 int ret = mm_radio_stop(handle->mm_handle);
370 if (ret != MM_ERROR_NONE) {
371 return __convert_error_code(ret, (char *)__FUNCTION__);
373 handle->state = RADIO_STATE_READY;
374 return RADIO_ERROR_NONE;
378 int radio_seek_up(radio_h radio, radio_seek_completed_cb callback, void *user_data)
380 LOGI("[%s] Enter", __func__);
381 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
382 RADIO_INSTANCE_CHECK(radio);
383 radio_s *handle = (radio_s *)radio;
384 RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
386 if (callback != NULL)
387 __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data);
389 __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio);
391 int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_UP);
392 if (ret != MM_ERROR_NONE)
393 return __convert_error_code(ret, (char *)__FUNCTION__);
395 return RADIO_ERROR_NONE;
398 int radio_seek_down(radio_h radio, radio_seek_completed_cb callback, void *user_data)
400 LOGI("[%s] Enter", __func__);
401 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
402 RADIO_INSTANCE_CHECK(radio);
403 radio_s *handle = (radio_s *)radio;
404 RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
406 if (callback != NULL)
407 __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data);
409 __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio);
411 int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_DOWN);
412 if (ret != MM_ERROR_NONE)
413 return __convert_error_code(ret, (char *)__FUNCTION__);
415 return RADIO_ERROR_NONE;
418 int radio_set_frequency(radio_h radio, int frequency)
420 LOGI("[%s] Enter", __func__);
421 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
422 RADIO_INSTANCE_CHECK(radio);
423 if (frequency < 87500 || frequency > 108000) {
424 LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (87500 ~ 108000)", __FUNCTION__, RADIO_ERROR_INVALID_PARAMETER);
425 return RADIO_ERROR_INVALID_PARAMETER;
427 int freq = frequency;
428 radio_s *handle = (radio_s *)radio;
429 int ret = mm_radio_set_frequency(handle->mm_handle, freq);
430 if (ret != MM_ERROR_NONE)
431 return __convert_error_code(ret, (char *)__FUNCTION__);
433 return RADIO_ERROR_NONE;
436 int radio_get_frequency(radio_h radio, int *frequency)
438 LOGI("[%s] Enter", __func__);
439 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
440 RADIO_INSTANCE_CHECK(radio);
441 RADIO_NULL_ARG_CHECK(frequency);
442 radio_s *handle = (radio_s *)radio;
445 int ret = mm_radio_get_frequency(handle->mm_handle, &freq);
446 if (ret != MM_ERROR_NONE) {
447 return __convert_error_code(ret, (char *)__FUNCTION__);
450 return RADIO_ERROR_NONE;
454 int radio_get_signal_strength(radio_h radio, int *strength)
456 LOGI("[%s] Enter", __func__);
457 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
458 RADIO_INSTANCE_CHECK(radio);
459 RADIO_NULL_ARG_CHECK(strength);
460 radio_s *handle = (radio_s *)radio;
463 int ret = mm_radio_get_signal_strength(handle->mm_handle, &_strength);
464 if (ret != MM_ERROR_NONE) {
465 return __convert_error_code(ret, (char *)__FUNCTION__);
467 *strength = _strength;
468 return RADIO_ERROR_NONE;
472 int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_data)
474 LOGI("[%s] Enter", __func__);
475 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
476 RADIO_INSTANCE_CHECK(radio);
477 radio_s *handle = (radio_s *)radio;
479 if (callback != NULL)
480 __set_callback(_RADIO_EVENT_TYPE_SCAN_INFO, radio, callback, user_data);
482 __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO, radio);
484 int ret = mm_radio_scan_start(handle->mm_handle);
485 if (ret != MM_ERROR_NONE) {
486 return __convert_error_code(ret, (char *)__FUNCTION__);
488 handle->state = RADIO_STATE_SCANNING;
489 return RADIO_ERROR_NONE;
493 int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_data)
495 LOGI("[%s] Enter", __func__);
496 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
497 RADIO_INSTANCE_CHECK(radio);
498 radio_s *handle = (radio_s *)radio;
499 RADIO_STATE_CHECK(handle, RADIO_STATE_SCANNING);
501 if (callback != NULL)
502 __set_callback(_RADIO_EVENT_TYPE_SCAN_STOP, radio, callback, user_data);
504 __unset_callback(_RADIO_EVENT_TYPE_SCAN_STOP, radio);
506 int ret = mm_radio_scan_stop(handle->mm_handle);
507 if (ret != MM_ERROR_NONE)
508 return __convert_error_code(ret, (char *)__FUNCTION__);
510 return RADIO_ERROR_NONE;
513 int radio_set_mute(radio_h radio, bool muted)
515 LOGI("[%s] Enter", __func__);
516 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
517 RADIO_INSTANCE_CHECK(radio);
518 radio_s *handle = (radio_s *)radio;
520 int ret = mm_radio_set_mute(handle->mm_handle, muted);
521 if (ret != MM_ERROR_NONE) {
522 return __convert_error_code(ret, (char *)__FUNCTION__);
524 handle->mute = muted;
525 return RADIO_ERROR_NONE;
529 int radio_is_muted(radio_h radio, bool *muted)
531 LOGI("[%s] Enter", __func__);
532 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
533 RADIO_INSTANCE_CHECK(radio);
534 RADIO_NULL_ARG_CHECK(muted);
535 radio_s *handle = (radio_s *)radio;
536 *muted = handle->mute;
537 return RADIO_ERROR_NONE;
540 int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback, void *user_data)
542 LOGI("[%s] Enter", __func__);
543 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
544 return __set_callback(_RADIO_EVENT_TYPE_SCAN_FINISH, radio, callback, user_data);
547 int radio_unset_scan_completed_cb(radio_h radio)
549 LOGI("[%s] Enter", __func__);
550 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
551 return __unset_callback(_RADIO_EVENT_TYPE_SCAN_FINISH, radio);
554 int radio_set_interrupted_cb(radio_h radio, radio_interrupted_cb callback, void *user_data)
556 LOGI("[%s] Enter", __func__);
557 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
558 return __set_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio, callback, user_data);
561 int radio_unset_interrupted_cb(radio_h radio)
563 LOGI("[%s] Enter", __func__);
564 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
565 return __unset_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio);
568 int radio_get_frequency_range(radio_h radio, int *min_freq, int *max_freq)
570 LOGI("[%s] Enter", __func__);
571 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
572 RADIO_INSTANCE_CHECK(radio);
573 RADIO_NULL_ARG_CHECK(min_freq);
574 RADIO_NULL_ARG_CHECK(max_freq);
575 radio_s *handle = (radio_s *)radio;
577 unsigned int min = 0;
578 unsigned int max = 0;
580 int ret = mm_radio_get_region_frequency_range(handle->mm_handle, &min, &max);
581 if (ret != MM_ERROR_NONE) {
582 return __convert_error_code(ret, (char *)__FUNCTION__);
586 return RADIO_ERROR_NONE;
590 int radio_get_channel_spacing(radio_h radio, int *channel_spacing)
592 LOGI("[%s] Enter", __func__);
593 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
594 RADIO_INSTANCE_CHECK(radio);
596 radio_s *handle = (radio_s *)radio;
598 int ret = mm_radio_get_channel_spacing(handle->mm_handle, channel_spacing);
600 if (ret != MM_ERROR_NONE)
601 return __convert_error_code(ret, (char *)__FUNCTION__);
603 return RADIO_ERROR_NONE;
606 int radio_set_volume(radio_h radio, float volume)
608 LOGI("[%s] Enter", __func__);
609 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
610 RADIO_INSTANCE_CHECK(radio);
611 if (volume < 0.0 || volume > 1.0) {
612 LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (0.0 ~ 1.0)", __FUNCTION__, RADIO_ERROR_INVALID_PARAMETER);
613 return RADIO_ERROR_INVALID_PARAMETER;
616 radio_s *handle = (radio_s *)radio;
617 int ret = mm_radio_set_volume(handle->mm_handle, vol);
618 if (ret != MM_ERROR_NONE)
619 return __convert_error_code(ret, (char *)__FUNCTION__);
621 return RADIO_ERROR_NONE;
624 int radio_get_volume(radio_h radio, float *volume)
626 LOGI("[%s] Enter", __func__);
627 RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
628 RADIO_INSTANCE_CHECK(radio);
629 RADIO_NULL_ARG_CHECK(volume);
630 radio_s *handle = (radio_s *)radio;
633 int ret = mm_radio_get_volume(handle->mm_handle, &vol);
634 if (ret != MM_ERROR_NONE) {
635 return __convert_error_code(ret, (char *)__FUNCTION__);
638 return RADIO_ERROR_NONE;