tizen 2.4 release accepted/tizen_2.4_mobile accepted/tizen/2.4/mobile/20151029.034524 submit/tizen_2.4/20151028.063646 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:25:54 +0000 (16:25 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:25:54 +0000 (16:25 +0900)
CMakeLists.txt
doc/radio_doc.h
include/radio.h
include/radio_private.h
packaging/capi-media-radio.spec
src/radio.c
test/radio_test.c
test/radio_test_type.h

index 6118bf2..93ad9ed 100755 (executable)
@@ -69,10 +69,10 @@ IF(UNIX)
 
 ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
 ADD_CUSTOM_COMMAND(
-        DEPENDS clean 
+        DEPENDS clean
         COMMENT "distribution clean"
         COMMAND find
-        ARGS    . 
+        ARGS    .
         -not -name config.cmake -and \(
         -name tester.c -or
         -name Testing -or
index 7034036..032e451 100644 (file)
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
  *
  *
  */
index 6d354e1..0855ad9 100644 (file)
@@ -44,8 +44,7 @@ typedef struct radio_s *radio_h;
  * @brief Enumeration of radio state.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
-typedef enum
-{
+typedef enum {
        RADIO_STATE_READY,                      /**< Ready to play or scan */
        RADIO_STATE_PLAYING,            /**< Playing the audio from the tuner */
        RADIO_STATE_SCANNING,           /**< Scanning/Searching for the next station signal that starts from a given starting frequency */
@@ -55,33 +54,32 @@ typedef enum
  * @brief Enumeration of error codes for the radio.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
-typedef enum
-{
-       RADIO_ERROR_NONE                        = TIZEN_ERROR_NONE,                                                             /**< Successful */
-       RADIO_ERROR_OUT_OF_MEMORY           = TIZEN_ERROR_OUT_OF_MEMORY,                                /**< Out of memory */
-       RADIO_ERROR_INVALID_PARAMETER  = TIZEN_ERROR_INVALID_PARAMETER,                 /**< Invalid parameter */
+typedef enum {
+       RADIO_ERROR_NONE                                        = TIZEN_ERROR_NONE,                                             /**< Successful */
+       RADIO_ERROR_OUT_OF_MEMORY               = TIZEN_ERROR_OUT_OF_MEMORY,                    /**< Out of memory */
+       RADIO_ERROR_INVALID_PARAMETER   = TIZEN_ERROR_INVALID_PARAMETER,                        /**< Invalid parameter */
        RADIO_ERROR_INVALID_OPERATION   = TIZEN_ERROR_INVALID_OPERATION,                        /**< Invalid operation */
-       RADIO_ERROR_INVALID_STATE           = TIZEN_ERROR_RADIO | 0x01  ,                                       /**< Invalid state */
-       RADIO_ERROR_SOUND_POLICY            = TIZEN_ERROR_RADIO | 0x02  ,                                       /**< Sound policy error */
-       RADIO_ERROR_PERMISSION_DENIED   = TIZEN_ERROR_PERMISSION_DENIED,                        /**< Permission denied */
-       RADIO_ERROR_NOT_SUPPORTED   = TIZEN_ERROR_NOT_SUPPORTED,                                        /**< Not supported */
+       RADIO_ERROR_INVALID_STATE                       = TIZEN_ERROR_RADIO | 0x01      ,                               /**< Invalid state */
+       RADIO_ERROR_SOUND_POLICY                        = TIZEN_ERROR_RADIO | 0x02      ,                               /**< Sound policy error */
+       RADIO_ERROR_NO_ANTENNA                  = TIZEN_ERROR_RADIO | 0x03 ,                             /**< No Antenna error (Since 2.4) */
+       RADIO_ERROR_PERMISSION_DENIED   = TIZEN_ERROR_PERMISSION_DENIED,                        /**< Permission denied */
+       RADIO_ERROR_NOT_SUPPORTED               = TIZEN_ERROR_NOT_SUPPORTED,                    /**< Not supported */
 } radio_error_e;
 
 /**
  * @brief Enumeration of radio interrupted type.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
-typedef enum
-{
-       RADIO_INTERRUPTED_COMPLETED = 0,                                        /**< Interrupt completed */
-       RADIO_INTERRUPTED_BY_MEDIA,                                             /**< Interrupted by a non-resumable media application */
-       RADIO_INTERRUPTED_BY_CALL,                                              /**< Interrupted by an incoming call */
-       RADIO_INTERRUPTED_BY_EARJACK_UNPLUG,                    /**< Interrupted by unplugging headphones */
-       RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT,         /**< Interrupted by a resource conflict */
-       RADIO_INTERRUPTED_BY_ALARM,                                             /**< Interrupted by an alarm */
-       RADIO_INTERRUPTED_BY_EMERGENCY,                         /**< Interrupted by an emergency */
-       RADIO_INTERRUPTED_BY_RESUMABLE_MEDIA,                   /**< Interrupted by a resumable media application */
-       RADIO_INTERRUPTED_BY_NOTIFICATION,                              /**< Interrupted by a notification */
+typedef enum {
+       RADIO_INTERRUPTED_COMPLETED = 0,                                        /**< Interrupt completed */
+       RADIO_INTERRUPTED_BY_MEDIA,                                             /**< Interrupted by a non-resumable media application */
+       RADIO_INTERRUPTED_BY_CALL,                                              /**< Interrupted by an incoming call */
+       RADIO_INTERRUPTED_BY_EARJACK_UNPLUG,                    /**< Interrupted by unplugging headphones */
+       RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT,         /**< Interrupted by a resource conflict */
+       RADIO_INTERRUPTED_BY_ALARM,                                             /**< Interrupted by an alarm */
+       RADIO_INTERRUPTED_BY_EMERGENCY,                         /**< Interrupted by an emergency */
+       RADIO_INTERRUPTED_BY_RESUMABLE_MEDIA,                   /**< Interrupted by a resumable media application */
+       RADIO_INTERRUPTED_BY_NOTIFICATION,                              /**< Interrupted by a notification */
 } radio_interrupted_code_e;
 
 /**
@@ -189,6 +187,7 @@ int  radio_get_state(radio_h radio, radio_state_e *state);
  * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
  * @retval #RADIO_ERROR_SOUND_POLICY Sound policy error
  * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
+ * @retval #RADIO_ERROR_NO_ANTENNA No Antenna error
  * @pre The radio state must be set to #RADIO_STATE_READY by calling radio_create().
  * @post The radio state will be #RADIO_STATE_PLAYING.
  * @see radio_stop()
@@ -229,7 +228,7 @@ int radio_stop(radio_h radio);
  * @post It invokes radio_seek_completed_cb() when the seek completes.
  * @see radio_seek_down()
  */
-int radio_seek_up(radio_h radio,radio_seek_completed_cb callback, void *user_data );
+int radio_seek_up(radio_h radio, radio_seek_completed_cb callback, void *user_data);
 
 /**
  * @brief Seeks down the effective frequency of the radio, asynchronously.
@@ -248,7 +247,7 @@ int radio_seek_up(radio_h radio,radio_seek_completed_cb callback, void *user_dat
  * @post It invokes radio_seek_completed_cb() when the seek completes.
  * @see radio_seek_up()
  */
-int radio_seek_down(radio_h radio,radio_seek_completed_cb callback, void *user_data );
+int radio_seek_down(radio_h radio, radio_seek_completed_cb callback, void *user_data);
 
 /**
  * @brief Sets the radio frequency.
@@ -435,6 +434,36 @@ int radio_set_interrupted_cb(radio_h radio, radio_interrupted_cb callback, void
 int radio_unset_interrupted_cb(radio_h radio);
 
 /**
+ * @brief Gets the min, max frequency of the region.
+ * @since_tizen 2.4
+ * @param[in]   radio The handle to radio
+ * @param[out]  min_freq The min frequency [87500 ~ 108000] (kHz)
+ * @param[out]  max_freq The max frequency [87500 ~ 108000] (kHz)
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
+ */
+int radio_get_frequency_range(radio_h radio, int *min_freq, int *max_freq);
+
+/**
+ * @brief Gets channel spacing.
+ * @since_tizen 2.4
+ * @param[in]   radio The handle to radio
+ * @param[out]  channel_spacing The channel spacing value
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported
+ */
+int radio_get_channel_spacing(radio_h radio, int *channel_spacing);
+
+
+/**
  * @}
  */
 
index b128372..886800f 100644 (file)
@@ -11,7 +11,7 @@
 * 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. 
+* limitations under the License.
 */
 
 #ifndef __TIZEN_MEDIA_RADIO_PRIVATE_H__
@@ -30,12 +30,13 @@ typedef enum {
        _RADIO_EVENT_TYPE_SEEK_FINISH,
        _RADIO_EVENT_TYPE_INTERRUPT,
        _RADIO_EVENT_TYPE_NUM
-}_radio_event_e;
+}
+_radio_event_e;
 
-typedef struct _radio_s{
+typedef struct _radio_s {
        MMHandleType mm_handle;
-       const voiduser_cb[_RADIO_EVENT_TYPE_NUM];
-       voiduser_data[_RADIO_EVENT_TYPE_NUM];
+       const void *user_cb[_RADIO_EVENT_TYPE_NUM];
+       void *user_data[_RADIO_EVENT_TYPE_NUM];
        radio_state_e state;
        bool mute;
 } radio_s;
@@ -44,4 +45,4 @@ typedef struct _radio_s{
 }
 #endif
 
-#endif //__TIZEN_MEDIA_RADIO_PRIVATE_H__
+#endif /*__TIZEN_MEDIA_RADIO_PRIVATE_H__ */
index d2856f1..9413ffb 100644 (file)
@@ -1,19 +1,16 @@
 #sbs-git:slp/api/radio capi-media-radio 0.1.0 59dddd8ea3de373c44c66ce2a298ca81240305a8
 Name:       capi-media-radio
 Summary:    A Radio library in Tizen Native API
-Version:    0.1.1
-Release:    12
+Version:    0.1.2
+Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
-BuildRequires:  pkgconfig(dbus-glib-1)
 BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(mm-radio)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  cmake
-BuildRequires:  gettext-devel
 
 %description
 A Radio library in Tizen Native API.
@@ -41,9 +38,9 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 mkdir -p %{buildroot}/usr/share/license
-mkdir -p %{buildroot}/opt/usr/devel
+mkdir -p %{buildroot}/usr/bin
 cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
-cp test/radio_test %{buildroot}/opt/usr/devel
+cp test/radio_test %{buildroot}/usr/bin
 
 %post
 
@@ -55,7 +52,7 @@ cp test/radio_test %{buildroot}/opt/usr/devel
 %defattr(-,root,root,-)
 /usr/lib/libcapi-media-radio.so.*
 /usr/share/license/%{name}
-/opt/usr/devel/*
+/usr/bin/*
 
 %files devel
 %defattr(-,root,root,-)
index 72aa388..eba7788 100644 (file)
 /*
 * Internal Macros
 */
-#define RADIO_CHECK_CONDITION(condition,error,msg)     \
-               if(condition) {} else \
-               { LOGE("[%s] %s(0x%08x)",(char*)__FUNCTION__, msg,error); return error;}; \
+#define RADIO_CHECK_CONDITION(condition, error, msg)   \
+       if (condition) { } else \
+               { LOGE("[%s] %s(0x%08x)", (char *)__FUNCTION__, msg, error); return error; }; \
 
 #define RADIO_INSTANCE_CHECK(radio)    \
-       RADIO_CHECK_CONDITION(radio != NULL, RADIO_ERROR_INVALID_PARAMETER,"RADIO_ERROR_INVALID_PARAMETER")
+       RADIO_CHECK_CONDITION(radio != NULL, RADIO_ERROR_INVALID_PARAMETER, "RADIO_ERROR_INVALID_PARAMETER")
 
-#define RADIO_STATE_CHECK(radio,expected_state)        \
-       RADIO_CHECK_CONDITION(radio->state == expected_state,RADIO_ERROR_INVALID_STATE,"RADIO_ERROR_INVALID_STATE")
+#define RADIO_STATE_CHECK(radio, expected_state)       \
+       RADIO_CHECK_CONDITION(radio->state == expected_state, RADIO_ERROR_INVALID_STATE, "RADIO_ERROR_INVALID_STATE")
 
 #define RADIO_NULL_ARG_CHECK(arg)      \
-       RADIO_CHECK_CONDITION(arg != NULL,RADIO_ERROR_INVALID_PARAMETER,"RADIO_ERROR_INVALID_PARAMETER")
+       RADIO_CHECK_CONDITION(arg != NULL, RADIO_ERROR_INVALID_PARAMETER, "RADIO_ERROR_INVALID_PARAMETER")
 
 #define RADIO_SUPPORT_CHECK(arg)       \
-       RADIO_CHECK_CONDITION(arg != false, RADIO_ERROR_NOT_SUPPORTED,"RADIO_ERROR_NOT_SUPPORTED")
+       RADIO_CHECK_CONDITION(arg != false, RADIO_ERROR_NOT_SUPPORTED, "RADIO_ERROR_NOT_SUPPORTED")
 
 /*
 * Internal Implementation
 */
-static int __convert_error_code(int code, char *func_name)
+int __convert_error_code(int code, char *func_name)
 {
        int ret = RADIO_ERROR_NONE;
-       char* msg="RADIO_ERROR_NONE";
+       char *msg = "RADIO_ERROR_NONE";
        LOGI("[%s] Enter code :%x", __func__, code);
-       switch(code)
-       {
+       switch (code) {
                case MM_ERROR_NONE:
                        ret = RADIO_ERROR_NONE;
                        msg = "RADIO_ERROR_NONE";
@@ -73,6 +72,7 @@ static int __convert_error_code(int code, char *func_name)
                        msg = "RADIO_ERROR_INVALID_STATE";
                        break;
                case MM_ERROR_COMMON_INVALID_ARGUMENT:
+               case MM_ERROR_INVALID_ARGUMENT:
                        ret = RADIO_ERROR_INVALID_PARAMETER;
                        msg = "RADIO_ERROR_INVALID_PARAMETER";
                        break;
@@ -85,19 +85,23 @@ static int __convert_error_code(int code, char *func_name)
                        break;
                case  MM_ERROR_RADIO_INTERNAL:
                case  MM_ERROR_RADIO_RESPONSE_TIMEOUT:
-                       ret= RADIO_ERROR_INVALID_OPERATION;
+                       ret = RADIO_ERROR_INVALID_OPERATION;
                        msg = "RADIO_ERROR_INVALID_OPERATION";
                        break;
                case  MM_ERROR_RADIO_DEVICE_NOT_FOUND:
                        ret = RADIO_ERROR_NOT_SUPPORTED;
                        msg = "RADIO_ERROR_NOT_SUPPORTED";
                        break;
+               case MM_ERROR_RADIO_NO_ANTENNA:
+                       ret = RADIO_ERROR_NO_ANTENNA;
+                       msg = "RADIO_ERROR_NO_ANTENNA";
+                       break;
                case  MM_ERROR_RADIO_DEVICE_NOT_OPENED:
-               default :
-                       ret= RADIO_ERROR_PERMISSION_DENIED;
+               default:
+                       ret = RADIO_ERROR_PERMISSION_DENIED;
                        msg = "RADIO_ERROR_PERMISSION_DENIED";
        }
-       LOGE("[%s] %s(0x%08x) : core fw error(0x%x)",func_name,msg, ret, code);
+       LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
        return ret;
 }
 
@@ -105,8 +109,7 @@ static radio_state_e __convert_radio_state(MMRadioStateType state)
 {
        int converted_state = RADIO_STATE_READY;
        LOGI("[%s] Enter state: %d", __func__, state);
-       switch(state)
-       {
+       switch (state) {
 
                case MM_RADIO_STATE_PLAYING:
                        converted_state = RADIO_STATE_PLAYING;
@@ -117,8 +120,8 @@ static radio_state_e __convert_radio_state(MMRadioStateType state)
                case MM_RADIO_STATE_NULL:
                case MM_RADIO_STATE_READY:
                default:
-                        converted_state = RADIO_STATE_READY;
-                        break;
+                       converted_state = RADIO_STATE_READY;
+                       break;
        }
        LOGI("[%s] Leave converted_state: %d", __func__, converted_state);
        return converted_state;
@@ -129,8 +132,7 @@ static radio_interrupted_code_e __convert_interrupted_code(int code)
 {
        LOGI("[%s] Enter code: %d", __func__, code);
        radio_interrupted_code_e ret = RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT;
-       switch(code)
-       {
+       switch (code) {
                case MM_MSG_CODE_INTERRUPTED_BY_CALL_END:
                case MM_MSG_CODE_INTERRUPTED_BY_ALARM_END:
                case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_END:
@@ -156,91 +158,81 @@ static radio_interrupted_code_e __convert_interrupted_code(int code)
                case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_START:
                        ret = RADIO_INTERRUPTED_BY_EMERGENCY;
                        break;
-               case MM_MSG_CODE_INTERRUPTED_BY_RESUMABLE_MEDIA:
-                       ret = RADIO_INTERRUPTED_BY_RESUMABLE_MEDIA;
-                       break;
                case MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT:
-               default :
+               default:
                        ret = RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT;
                        break;
        }
-       LOGE("[%s] interrupted code(%d) => ret(%d)",__FUNCTION__,code, ret);
+       LOGE("[%s] interrupted code(%d) => ret(%d)", __FUNCTION__, code, ret);
        return ret;
 }
 
-static int __set_callback(_radio_event_e type, radio_h radio, voidcallback, void *user_data)
+static int __set_callback(_radio_event_e type, radio_h radio, void *callback, void *user_data)
 {
        RADIO_INSTANCE_CHECK(radio);
        RADIO_NULL_ARG_CHECK(callback);
-       radio_s * handle = (radio_s *) radio;
+       radio_s *handle = (radio_s *) radio;
        handle->user_cb[type] = callback;
        handle->user_data[type] = user_data;
-       LOGI("[%s] Event type : %d ",__FUNCTION__, type);
+       LOGI("[%s] Event type : %d ", __FUNCTION__, type);
        return RADIO_ERROR_NONE;
 }
 
 static int __unset_callback(_radio_event_e type, radio_h radio)
 {
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
+       radio_s *handle = (radio_s *) radio;
        handle->user_cb[type] = NULL;
        handle->user_data[type] = NULL;
-       LOGI("[%s] Event type : %d ",__FUNCTION__, type);
+       LOGI("[%s] Event type : %d ", __FUNCTION__, type);
        return RADIO_ERROR_NONE;
 }
 
 static int __msg_callback(int message, void *param, void *user_data)
 {
-       radio_s * handle = (radio_s*)user_data;
-       MMMessageParamType *msg = (MMMessageParamType*)param;
-       LOGI("[%s] Got message type : 0x%x" ,__FUNCTION__, message);
-       switch(message)
-       {
+       radio_s *handle = (radio_s *)user_data;
+       MMMessageParamType *msg = (MMMessageParamType *)param;
+       LOGI("[%s] Got message type : 0x%x" , __FUNCTION__, message);
+       switch (message) {
                case MM_MESSAGE_RADIO_SCAN_INFO:
-                       if( handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO] )
-                       {
-                               ((radio_scan_updated_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO])(msg->radio_scan.frequency,handle->user_data[_RADIO_EVENT_TYPE_SCAN_INFO]);
+                       if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO]) {
+                               ((radio_scan_updated_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO])(msg->radio_scan.frequency, handle->user_data[_RADIO_EVENT_TYPE_SCAN_INFO]);
                        }
                        break;
                case MM_MESSAGE_RADIO_SCAN_STOP:
-                       if( handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP] )
-                       {
+                       if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP]) {
                                ((radio_scan_stopped_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_STOP]);
                        }
                        break;
                case MM_MESSAGE_RADIO_SCAN_FINISH:
-                       if( handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH] )
-                       {
+                       if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH]) {
                                ((radio_scan_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_FINISH]);
                        }
                        break;
                case MM_MESSAGE_RADIO_SEEK_FINISH:
-                       if( handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH] )
-                       {
+                       if (handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH]) {
                                ((radio_seek_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH])(msg->radio_scan.frequency, handle->user_data[_RADIO_EVENT_TYPE_SEEK_FINISH]);
                        }
                        break;
                case MM_MESSAGE_STATE_INTERRUPTED:
-                       if( handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT] )
-                       {
-                               ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(__convert_interrupted_code(msg->code),handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]);
+                       if (handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT]) {
+                               ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(__convert_interrupted_code(msg->code), handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]);
                        }
                        break;
                case MM_MESSAGE_READY_TO_RESUME:
-                       if( handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT] )
-                       {
-                               ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(RADIO_INTERRUPTED_COMPLETED,handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]);
+                       if (handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT]) {
+                               ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(RADIO_INTERRUPTED_COMPLETED, handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]);
                        }
                        break;
                case  MM_MESSAGE_ERROR:
-                               __convert_error_code(msg->code,(char*)__FUNCTION__);
+                       __convert_error_code(msg->code, (char *)__FUNCTION__);
                        break;
                case MM_MESSAGE_RADIO_SCAN_START:
                        LOGI("[%s] Scan Started");
                        break;
                case  MM_MESSAGE_STATE_CHANGED:
                        handle->state = __convert_radio_state(msg->state.current);
-                       LOGI("[%s] State Changed --- from : %d , to : %d" ,__FUNCTION__,  __convert_radio_state(msg->state.previous), handle->state);
+                       LOGI("[%s] State Changed --- from : %d , to : %d" , __FUNCTION__,  __convert_radio_state(msg->state.previous), handle->state);
                        break;
                case MM_MESSAGE_RADIO_SEEK_START:
                        LOGI("[%s] Seek Started", __FUNCTION__);
@@ -258,18 +250,14 @@ static int __radio_check_system_info_feature_supported()
 
        nRetVal = system_info_get_platform_bool("http://tizen.org/feature/fmradio", &bValue);
 
-       if ( nRetVal != SYSTEM_INFO_ERROR_NONE )
-       {
+       if (nRetVal != SYSTEM_INFO_ERROR_NONE) {
                LOGE("[%s] SYSTEM_INFO_ERROR : ", __FUNCTION__);
                return false;
        }
 
-       if ( false == bValue )
-       {
+       if (false == bValue) {
                LOGI("system_info_get_platform_bool returned Unsupported feature capability\n");
-       }
-       else
-       {
+       } else {
                LOGI("system_info_get_platform_bool returned Supported status feature\n");
        }
 
@@ -284,36 +272,30 @@ int radio_create(radio_h *radio)
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle;
+       radio_s *handle;
 
-       handle = (radio_s*)malloc( sizeof(radio_s));
+       handle = (radio_s *)malloc(sizeof(radio_s));
        if (handle != NULL)
                memset(handle, 0 , sizeof(radio_s));
-       else
-       {
-               LOGE("[%s] RADIO_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__,RADIO_ERROR_OUT_OF_MEMORY);
+       else {
+               LOGE("[%s] RADIO_ERROR_OUT_OF_MEMORY(0x%08x)" , __FUNCTION__, RADIO_ERROR_OUT_OF_MEMORY);
                return RADIO_ERROR_OUT_OF_MEMORY;
        }
        int ret = mm_radio_create(&handle->mm_handle);
-       if( ret != MM_ERROR_NONE)
-       {
+       if (ret != MM_ERROR_NONE) {
                free(handle);
-               handle=NULL;
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+               handle = NULL;
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                *radio = (radio_h)handle;
 
-               ret = mm_radio_set_message_callback(handle->mm_handle, __msg_callback, (void*)handle);
-               if(ret != MM_ERROR_NONE)
-               {
-                       LOGW("[%s] Failed to set message callback function (0x%x)" ,__FUNCTION__, ret);
+               ret = mm_radio_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle);
+               if (ret != MM_ERROR_NONE) {
+                       LOGW("[%s] Failed to set message callback function (0x%x)" , __FUNCTION__, ret);
                }
                ret = mm_radio_realize(handle->mm_handle);
-               if(ret != MM_ERROR_NONE)
-               {
-                       return __convert_error_code(ret,(char*)__FUNCTION__);
+               if (ret != MM_ERROR_NONE) {
+                       return __convert_error_code(ret, (char *)__FUNCTION__);
                }
                handle->state = RADIO_STATE_READY;
                handle->mute = FALSE;
@@ -326,24 +308,20 @@ int radio_destroy(radio_h radio)
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
+       radio_s *handle = (radio_s *) radio;
 
        int ret;
        ret = mm_radio_unrealize(handle->mm_handle);
-       if ( ret!= MM_ERROR_NONE)
-       {
-               LOGW("[%s] Failed to unrealize (0x%x)" ,__FUNCTION__, ret);
+       if (ret != MM_ERROR_NONE) {
+               LOGW("[%s] Failed to unrealize (0x%x)" , __FUNCTION__, ret);
        }
 
        ret = mm_radio_destroy(handle->mm_handle);
-       if (ret!= MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                free(handle);
-               handle= NULL;
+               handle = NULL;
                return RADIO_ERROR_NONE;
        }
 }
@@ -354,16 +332,13 @@ int  radio_get_state(radio_h radio, radio_state_e *state)
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
        RADIO_NULL_ARG_CHECK(state);
-       radio_s * handle = (radio_s *) radio;
+       radio_s *handle = (radio_s *) radio;
        MMRadioStateType currentStat = MM_RADIO_STATE_NULL;
        int ret = mm_radio_get_state(handle->mm_handle, &currentStat);
-       if(ret != MM_ERROR_NONE)
-       {
+       if (ret != MM_ERROR_NONE) {
                *state = handle->state;
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                handle->state  = __convert_radio_state(currentStat);
                *state = handle->state;
                return RADIO_ERROR_NONE;
@@ -375,16 +350,13 @@ int radio_start(radio_h radio)
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
-       RADIO_STATE_CHECK(handle,RADIO_STATE_READY);
+       radio_s *handle = (radio_s *) radio;
+       RADIO_STATE_CHECK(handle, RADIO_STATE_READY);
 
        int ret = mm_radio_start(handle->mm_handle);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                handle->state = RADIO_STATE_PLAYING;
                return RADIO_ERROR_NONE;
        }
@@ -395,73 +367,58 @@ int radio_stop(radio_h radio)
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
-       RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING);
+       radio_s *handle = (radio_s *) radio;
+       RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
 
        int ret = mm_radio_stop(handle->mm_handle);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                handle->state = RADIO_STATE_READY;
                return RADIO_ERROR_NONE;
        }
 }
 
-int radio_seek_up(radio_h radio,radio_seek_completed_cb callback, void *user_data )
+int radio_seek_up(radio_h radio, radio_seek_completed_cb callback, void *user_data)
 {
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
-       RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING);
+       radio_s *handle = (radio_s *) radio;
+       RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
 
-       if(callback!=NULL)
-       {
-               __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio,callback,user_data);
-       }
-       else
-       {
-               __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio);
+       if (callback != NULL) {
+               __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data);
+       } else {
+               __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio);
        }
 
        int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_UP);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                return RADIO_ERROR_NONE;
        }
 }
 
-int radio_seek_down(radio_h radio,radio_seek_completed_cb callback, void *user_data )
+int radio_seek_down(radio_h radio, radio_seek_completed_cb callback, void *user_data)
 {
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
-       RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING);
+       radio_s *handle = (radio_s *) radio;
+       RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
 
-       if(callback!=NULL)
-       {
-               __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio,callback,user_data);
-       }
-       else
-       {
-               __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio);
+       if (callback != NULL) {
+               __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data);
+       } else {
+               __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio);
        }
 
        int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_DOWN);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                return RADIO_ERROR_NONE;
        }
 }
@@ -471,20 +428,16 @@ int radio_set_frequency(radio_h radio, int frequency)
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       if(frequency < 87500 || frequency > 108000)
-       {
-               LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (87500 ~ 108000)" ,__FUNCTION__,RADIO_ERROR_INVALID_PARAMETER);
+       if (frequency < 87500 || frequency > 108000) {
+               LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (87500 ~ 108000)" , __FUNCTION__, RADIO_ERROR_INVALID_PARAMETER);
                return RADIO_ERROR_INVALID_PARAMETER;
        }
-       int freq= frequency;
-       radio_s * handle = (radio_s *) radio;
+       int freq = frequency;
+       radio_s *handle = (radio_s *) radio;
        int ret = mm_radio_set_frequency(handle->mm_handle, freq);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                return RADIO_ERROR_NONE;
        }
 }
@@ -495,16 +448,13 @@ int radio_get_frequency(radio_h radio, int *frequency)
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
        RADIO_NULL_ARG_CHECK(frequency);
-       radio_s * handle = (radio_s *) radio;
+       radio_s *handle = (radio_s *) radio;
 
        int freq;
        int ret = mm_radio_get_frequency(handle->mm_handle, &freq);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                *frequency = freq;
                return RADIO_ERROR_NONE;
        }
@@ -516,16 +466,13 @@ int radio_get_signal_strength(radio_h radio, int *strength)
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
        RADIO_NULL_ARG_CHECK(strength);
-       radio_s * handle = (radio_s *) radio;
+       radio_s *handle = (radio_s *) radio;
 
        int _strength;
        int ret = mm_radio_get_signal_strength(handle->mm_handle, &_strength);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                *strength = _strength;
                return RADIO_ERROR_NONE;
        }
@@ -536,25 +483,19 @@ int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_d
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
-       RADIO_STATE_CHECK(handle,RADIO_STATE_READY);
+       radio_s *handle = (radio_s *) radio;
+       RADIO_STATE_CHECK(handle, RADIO_STATE_READY);
 
-       if(callback!=NULL)
-       {
-               __set_callback(_RADIO_EVENT_TYPE_SCAN_INFO,radio,callback,user_data);
-       }
-       else
-       {
-               __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO,radio);
+       if (callback != NULL) {
+               __set_callback(_RADIO_EVENT_TYPE_SCAN_INFO, radio, callback, user_data);
+       } else {
+               __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO, radio);
        }
 
        int ret = mm_radio_scan_start(handle->mm_handle);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                handle->state = RADIO_STATE_SCANNING;
                return RADIO_ERROR_NONE;
        }
@@ -565,25 +506,19 @@ int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_da
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
-       RADIO_STATE_CHECK(handle,RADIO_STATE_SCANNING);
+       radio_s *handle = (radio_s *) radio;
+       RADIO_STATE_CHECK(handle, RADIO_STATE_SCANNING);
 
-       if(callback!=NULL)
-       {
-               __set_callback(_RADIO_EVENT_TYPE_SCAN_STOP,radio,callback,user_data);
-       }
-       else
-       {
-               __unset_callback(_RADIO_EVENT_TYPE_SCAN_STOP,radio);
+       if (callback != NULL) {
+               __set_callback(_RADIO_EVENT_TYPE_SCAN_STOP, radio, callback, user_data);
+       } else {
+               __unset_callback(_RADIO_EVENT_TYPE_SCAN_STOP, radio);
        }
 
        int ret = mm_radio_scan_stop(handle->mm_handle);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                handle->state = RADIO_STATE_READY;
                return RADIO_ERROR_NONE;
        }
@@ -595,15 +530,12 @@ int radio_set_mute(radio_h radio, bool muted)
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
-       radio_s * handle = (radio_s *) radio;
+       radio_s *handle = (radio_s *) radio;
 
        int ret = mm_radio_set_mute(handle->mm_handle, muted);
-       if(ret != MM_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       else
-       {
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
                handle->mute = muted;
                return RADIO_ERROR_NONE;
        }
@@ -615,7 +547,7 @@ int radio_is_muted(radio_h radio, bool *muted)
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
        RADIO_INSTANCE_CHECK(radio);
        RADIO_NULL_ARG_CHECK(muted);
-       radio_s * handle = (radio_s *) radio;
+       radio_s *handle = (radio_s *) radio;
        *muted = handle->mute;
        return RADIO_ERROR_NONE;
 }
@@ -624,26 +556,69 @@ int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback,
 {
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
-       return __set_callback(_RADIO_EVENT_TYPE_SCAN_FINISH,radio,callback,user_data);
+       return __set_callback(_RADIO_EVENT_TYPE_SCAN_FINISH, radio, callback, user_data);
 }
 
 int radio_unset_scan_completed_cb(radio_h radio)
 {
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
-       return __unset_callback(_RADIO_EVENT_TYPE_SCAN_FINISH,radio);
+       return __unset_callback(_RADIO_EVENT_TYPE_SCAN_FINISH, radio);
 }
 
 int radio_set_interrupted_cb(radio_h radio, radio_interrupted_cb callback, void *user_data)
 {
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
-       return __set_callback(_RADIO_EVENT_TYPE_INTERRUPT,radio,callback,user_data);
+       return __set_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio, callback, user_data);
 }
 
 int radio_unset_interrupted_cb(radio_h radio)
 {
        LOGI("[%s] Enter", __func__);
        RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
-       return __unset_callback(_RADIO_EVENT_TYPE_INTERRUPT,radio);
+       return __unset_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio);
 }
+
+
+int radio_get_frequency_range(radio_h radio, int *min_freq, int *max_freq)
+{
+       LOGI("[%s] Enter", __func__);
+       RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
+       RADIO_INSTANCE_CHECK(radio);
+       RADIO_NULL_ARG_CHECK(min_freq);
+       RADIO_NULL_ARG_CHECK(max_freq);
+       radio_s *handle = (radio_s *) radio;
+
+       unsigned int min = 0;
+       unsigned int max = 0;
+
+       int ret = mm_radio_get_region_frequency_range(handle->mm_handle, &min, &max);
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
+               *min_freq = min;
+               *max_freq = max;
+               return RADIO_ERROR_NONE;
+       }
+}
+
+int radio_get_channel_spacing(radio_h radio, int *channel_spacing)
+{
+       LOGI("[%s] Enter", __func__);
+       RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
+       RADIO_INSTANCE_CHECK(radio);
+
+       radio_s *handle = (radio_s *) radio;
+
+       int ret = mm_radio_get_channel_spacing(handle->mm_handle, channel_spacing);
+
+       if (ret != MM_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       } else {
+               return RADIO_ERROR_NONE;
+       }
+}
+
+
+
index 8886db6..2e4931d 100644 (file)
@@ -28,7 +28,7 @@
 #include <unistd.h>
 
 #define DEFAULT_TEST_FREQ      107700
-#define MENU_ITEM_MAX  19
+#define MENU_ITEM_MAX  20
 #define _MAX_INPUT_STRING_ 100
 
 
@@ -49,7 +49,7 @@ static void __run_test(int key);
 
 int radio_rt_api_test(void);
 static int __menu(void);
-static void __call_api( int choosen );
+static void __call_api(int choosen);
 void __radio_seek_completed_cb(int frequency, void *user_data);
 void __radio_scan_updated_cb(int freq, void *user_data);
 void __radio_scan_stop_cb(void *user_data);
@@ -59,8 +59,7 @@ void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param)
 
 
 /* list of tests*/
-test_item_t g_tests[100] =
-{
+test_item_t g_tests[100] = {
        /* menu string : short string to be displayed to menu
             description : detailed description
             test function :  a pointer to a actual test function
@@ -70,49 +69,49 @@ test_item_t g_tests[100] =
                "init test",
                "check radio init function",
                __test_radio_init,
-       0
+               0
        },
 
        {
                "listening gorealra",
                "let's listen to the gorealra!",
                __test_radio_listen_gorealra,
-       0
+               0
        },
 
        {
                "repeat_init_release",
                "repeat init and release and check if it working and memory usage increment",
                __test_repeat_init_release,
-       0
+               0
        },
 
        {
                "repeat_start_stop",
                "repeat start and stop and check if it working and memory usage increment",
                __test_repeat_start_stop,
-       0
+               0
        },
 
        {
                "repeat_seek",
                "repeat seek and check if it working and memory usage increment",
                __test_repeat_seek,
-       0
+               0
        },
 
        {
                "repeat_whole",
                "repeat whole radio sequence and check if it working and memory usage increment",
                __test_repeat_whole,
-       0
+               0
        },
 
        {
                "manual api calling test",
                "mapping each api to each test manu. just like other testsuite. try to reproduce the bugs with it.",
                __test_manual_api_calling,
-       0
+               0
        },
 
        /* add tests here*/
@@ -134,14 +133,13 @@ int main(int argc, char **argv)
                do {
                        key = getchar();
 
-                       if ( key >= '0' && key <= '9')
-                       {
-                               __run_test( key - '0' );
+                       if (key >= '0' && key <= '9') {
+                               __run_test(key - '0');
                        }
-               }while ( key == '\n' );
-               if(key == 'Q' || key == 'q')
+               } while (key == '\n');
+               if (key == 'Q' || key == 'q')
                        break;
-       }while(1);
+       } while (1);
 
        printf("radio test client finished\n");
 
@@ -155,9 +153,8 @@ void __print_menu(void)
        printf("\n\nFMRadio testing menu\n");
        printf("------------------------------------------\n");
 
-       for ( i = 0; g_tests[i].func; i++ )
-       {
-               printf( "[%d] %s\n", i, g_tests[i].menu_string );
+       for (i = 0; g_tests[i].func; i++) {
+               printf("[%d] %s\n", i, g_tests[i].menu_string);
        }
        printf("[q] quit\n");
 
@@ -172,28 +169,24 @@ void __run_test(int key)
 
        /* check index */
        printf("#tests : %d    key : %d\n", g_num_of_tests, key);
-       if ( key >= g_num_of_tests || key < 0 )
-       {
+       if (key >= g_num_of_tests || key < 0) {
                printf("unassigned key has pressed : %d\n", key);
                return;
        }
 
        /* display description*/
-       printf( "excuting test : %s\n", g_tests[key].menu_string );
-       printf( "description : %s\n", g_tests[key].description );
+       printf("excuting test : %s\n", g_tests[key].menu_string);
+       printf("description : %s\n", g_tests[key].description);
 
        /* calling test function*/
        ret = g_tests[key].func();
 
        g_tests[key].result =  ret;
 
-       if ( ret )
-       {
-               printf( "TEST FAILED. ret code : %d\n", g_tests[key].result);
-       }
-       else
-       {
-               printf( "TEST SUCCEDED. ret code : %d\n", g_tests[key].result);
+       if (ret) {
+               printf("TEST FAILED. ret code : %d\n", g_tests[key].result);
+       } else {
+               printf("TEST SUCCEDED. ret code : %d\n", g_tests[key].result);
        }
 }
 
@@ -206,8 +199,8 @@ int __test_radio_init(void)
        int ret = RADIO_ERROR_NONE;
        radio_h radio;
 
-       RADIO_TEST__( radio_create(&radio); )
-       RADIO_TEST__( radio_destroy(radio); )
+       RADIO_TEST__(radio_create(&radio);)
+       RADIO_TEST__(radio_destroy(radio);)
        return ret;
 }
 
@@ -218,12 +211,12 @@ int __test_radio_listen_gorealra(void)
        int ret = RADIO_ERROR_NONE;
        radio_h radio;
 
-       RADIO_TEST__( radio_create(&radio); )
-       RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); )
-       RADIO_TEST__( radio_start(radio); )
+       RADIO_TEST__(radio_create(&radio);)
+       RADIO_TEST__(radio_set_frequency(radio, DEFAULT_TEST_FREQ);)
+       RADIO_TEST__(radio_start(radio);)
        usleep(5000 * 1000);
-       RADIO_TEST__( radio_stop(radio); )
-       RADIO_TEST__( radio_destroy(radio); )
+       RADIO_TEST__(radio_stop(radio);)
+       RADIO_TEST__(radio_destroy(radio);)
        return ret;
 }
 
@@ -235,10 +228,9 @@ int __test_repeat_init_release(void)
        int cnt = 0;
        radio_h radio;
 
-       while ( cnt < 1000 )
-       {
-               RADIO_TEST__( radio_create(&radio); )
-               RADIO_TEST__( radio_destroy(radio); )
+       while (cnt < 1000) {
+               RADIO_TEST__(radio_create(&radio);)
+               RADIO_TEST__(radio_destroy(radio);)
 
                cnt++;
 
@@ -255,14 +247,13 @@ int __test_repeat_start_stop(void)
        int cnt = 0;
        radio_h radio;
 
-       RADIO_TEST__( radio_create(&radio); )
-       RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); )
+       RADIO_TEST__(radio_create(&radio);)
+       RADIO_TEST__(radio_set_frequency(radio, DEFAULT_TEST_FREQ);)
 
-       while(cnt < 10)
-       {
-               RADIO_TEST__( radio_start(radio); )
+       while (cnt < 10) {
+               RADIO_TEST__(radio_start(radio);)
                usleep(2000 * 1000);
-               RADIO_TEST__( radio_stop(radio); )
+               RADIO_TEST__(radio_stop(radio);)
 
                cnt++;
 
@@ -295,19 +286,18 @@ int __test_manual_api_calling(void)
 
 int radio_rt_api_test(void)
 {
-       while(1)
-       {
+       while (1) {
                int choosen = 0;
 
                choosen = __menu();
 
-               if ( choosen == -1)
+               if (choosen == -1)
                        continue;
 
-               if ( choosen == 0 )
+               if (choosen == 0)
                        break;
 
-               __call_api( choosen );
+               __call_api(choosen);
        }
 
        printf("radio test client finished\n");
@@ -340,163 +330,159 @@ int __menu(void)
        printf("[16] radio_unset_scan_completed_cb\n");
        printf("[17] radio_set_interrupted_cb\n");
        printf("[18] radio_unset_interrupted_cb\n");
+       printf("[19] radio_get_frequency_range\n");
+       printf("[20] radio_get_channel_spacing\n");
 
        printf("[0] quit\n");
        printf("---------------------------------------------------------\n");
        printf("choose one : ");
 
-       if ( scanf("%d", &menu_item) == 0)
-       {
+       if (scanf("%d", &menu_item) == 0) {
                char temp[_MAX_INPUT_STRING_];
-               if (scanf("%s", temp) ==0)
-               {
+               if (scanf("%s", temp) == 0) {
                        printf("Error while flushing the input buffer - but lets continue\n");
                }
                return -1;
        }
 
 
-       if ( menu_item > MENU_ITEM_MAX )
+       if (menu_item > MENU_ITEM_MAX)
                menu_item = -1;
 
        return menu_item;
 }
 
-void __call_api( int choosen )
+void __call_api(int choosen)
 {
        int ret = RADIO_ERROR_NONE;
 
-       switch( choosen )
-       {
-               case 1:
-               {
-                       RADIO_TEST__( radio_create( &g_my_radio ); )
-               }
-               break;
+       switch (choosen) {
+               case 1: {
+                               RADIO_TEST__(radio_create(&g_my_radio);)
+                       }
+                       break;
 
-               case 2:
-               {
-                       RADIO_TEST__( radio_destroy( g_my_radio ); )
-                       g_my_radio = 0;
-               }
-               break;
+               case 2: {
+                               RADIO_TEST__(radio_destroy(g_my_radio);)
+                               g_my_radio = 0;
+                       }
+                       break;
 
-               case 3:
-               {
-                       radio_state_e state;
-                       RADIO_TEST__( radio_get_state(g_my_radio, &state); )
+               case 3: {
+                               radio_state_e state;
+                               RADIO_TEST__(radio_get_state(g_my_radio, &state);)
 
-                       printf("state : %d\n", state);
-               }
-               break;
+                               printf("state : %d\n", state);
+                       }
+                       break;
 
-               case 4:
-               {
-                       RADIO_TEST__( radio_start(g_my_radio); )
-               }
-               break;
+               case 4: {
+                               RADIO_TEST__(radio_start(g_my_radio);)
+                       }
+                       break;
 
-               case 5:
-               {
-                       RADIO_TEST__( radio_stop(g_my_radio); )
-               }
-               break;
+               case 5: {
+                               RADIO_TEST__(radio_stop(g_my_radio);)
+                       }
+                       break;
 
-               case 6:
-               {
-                       RADIO_TEST__( radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL); )
+               case 6: {
+                               RADIO_TEST__(radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL);)
 
-               }
-               break;
+                       }
+                       break;
 
-               case 7:
-               {
-                       RADIO_TEST__( radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL); )
-               }
-               break;
+               case 7: {
+                               RADIO_TEST__(radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL);)
+                       }
+                       break;
 
-               case 8:
-               {
-                       int freq = 0;
-                       printf("input freq : ");
-                       if (scanf("%d", &freq) == 0)
-                               return;
+               case 8: {
+                               int freq = 0;
+                               printf("input freq : ");
+                               if (scanf("%d", &freq) == 0)
+                                       return;
 
-                       RADIO_TEST__( radio_set_frequency(g_my_radio, freq); )
-               }
-               break;
+                               RADIO_TEST__(radio_set_frequency(g_my_radio, freq);)
+                       }
+                       break;
 
-               case 9:
-               {
-                       int freq = 0;
-                       RADIO_TEST__( radio_get_frequency(g_my_radio, &freq ); )
+               case 9: {
+                               int freq = 0;
+                               RADIO_TEST__(radio_get_frequency(g_my_radio, &freq);)
 
-                       printf("freq : %d\n", freq);
-               }
-               break;
+                               printf("freq : %d\n", freq);
+                       }
+                       break;
 
-               case 10:
-               {
-                       int signal_strength = 0;
-                       RADIO_TEST__( radio_get_signal_strength(g_my_radio, &signal_strength); )
-                       printf("signal strength is : %d \n", signal_strength);
-               }
-               break;
+               case 10: {
+                               int signal_strength = 0;
+                               RADIO_TEST__(radio_get_signal_strength(g_my_radio, &signal_strength);)
+                               printf("signal strength is : %d \n", signal_strength);
+                       }
+                       break;
 
-               case 11:
-               {
-                       RADIO_TEST__( radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL); )
-               }
-               break;
+               case 11: {
+                               RADIO_TEST__(radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL);)
+                       }
+                       break;
 
-               case 12:
-               {
-                       RADIO_TEST__( radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL); )
-               }
-               break;
-
-               case 13:
-               {
-                       int muted = 0;
-                       printf("select one(0:UNMUTE/1:MUTE) : ");
-                       if ( scanf("%d", &muted) == 0)
-                               return;
-                       RADIO_TEST__( radio_set_mute(g_my_radio, muted); )
-               }
-               break;
+               case 12: {
+                               RADIO_TEST__(radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL);)
+                       }
+                       break;
 
-               case 14:
-               {
-                       bool muted = 0;
-                       RADIO_TEST__( radio_is_muted(g_my_radio, &muted); )
-                       printf("muted : %d \n", muted);
-               }
-               break;
+               case 13: {
+                               int muted = 0;
+                               printf("select one(0:UNMUTE/1:MUTE) : ");
+                               if (scanf("%d", &muted) == 0)
+                                       return;
+                               RADIO_TEST__(radio_set_mute(g_my_radio, muted);)
+                       }
+                       break;
 
+               case 14: {
+                               bool muted = 0;
+                               RADIO_TEST__(radio_is_muted(g_my_radio, &muted);)
+                               printf("muted : %d \n", muted);
+                       }
+                       break;
 
-               case 15:
-               {
-                       RADIO_TEST__( radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL); )
-               }
-               break;
 
-               case 16:
-               {
-                       RADIO_TEST__( radio_unset_scan_completed_cb(g_my_radio); )
-               }
-               break;
+               case 15: {
+                               RADIO_TEST__(radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL);)
+                       }
+                       break;
 
-               case 17:
-               {
-                       RADIO_TEST__( radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL ); )
-               }
-               break;
+               case 16: {
+                               RADIO_TEST__(radio_unset_scan_completed_cb(g_my_radio);)
+                       }
+                       break;
 
-               case 18:
-               {
-                       RADIO_TEST__( radio_unset_interrupted_cb(g_my_radio); )
-               }
-               break;
+               case 17: {
+                               RADIO_TEST__(radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL);)
+                       }
+                       break;
+
+               case 18: {
+                               RADIO_TEST__(radio_unset_interrupted_cb(g_my_radio);)
+                       }
+                       break;
+
+               case 19: {
+                               int min = 0;
+                               int max = 0;
+                               RADIO_TEST__(radio_get_frequency_range(g_my_radio, &min, &max);)
+                               printf("min : %d max: %d \n", min, max);
+                       }
+                       break;
+
+               case 20: {
+                               int channel_spacing = 0;
+                               RADIO_TEST__(radio_get_channel_spacing(g_my_radio, &channel_spacing);)
+                               printf("channel_spacing : %d \n", channel_spacing);
+                       }
+                       break;
 
                default:
                        break;
index 5363cdd..bfa7df9 100644 (file)
 #include <stdio.h>
 #include <assert.h>
 
-typedef int (*test_function) (void);
+typedef int (*test_function)(void);
 
-typedef struct __test_item
-{
+typedef struct __test_item {
        char menu_string[80];
        char description[128];
        test_function func;
@@ -36,14 +35,14 @@ typedef struct __test_item
 } test_item_t;
 
 #define RADIO_TEST__(x_test)   \
-               ret = x_test    \
-               if ( ! ret )    \
-               {       \
-                       printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__);    \
-               }       \
-               else    \
-               {       \
-                       printf("FAIL : %s ERR-CODE : 0x%x -- %s:%d\n", #x_test, ret, __FILE__, __LINE__);       \
-               }
+       ret = x_test    \
+             if ( ! ret )      \
+       {       \
+               printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__);    \
+       }       \
+       else    \
+       {       \
+               printf("FAIL : %s ERR-CODE : 0x%x -- %s:%d\n", #x_test, ret, __FILE__, __LINE__);       \
+       }
 
 #endif /* MM_RADIO_TEST_TYPE_H_ */