From e28499897bfdaf625ca01bc5b0388df81e7436c6 Mon Sep 17 00:00:00 2001 From: Sangjin Sim Date: Mon, 1 Jun 2015 11:17:33 +0900 Subject: [PATCH] Sync with latest src tizen2.4 Change-Id: I0e4556799d3127e18ee00f8781b221b9c1514780 --- include/radio.h | 88 ++++++++++++++++++++++++++++------------- packaging/capi-media-radio.spec | 9 ++--- src/radio.c | 54 +++++++++++++++++++++++++ test/CMakeLists.txt | 2 +- test/radio_test.c | 21 +++++++++- 5 files changed, 138 insertions(+), 36 deletions(-) diff --git a/include/radio.h b/include/radio.h index 01ef455..3f160be 100755 --- a/include/radio.h +++ b/include/radio.h @@ -26,7 +26,7 @@ extern "C" { /** * @file radio.h * @brief This file contains the radio API. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ /** @@ -36,13 +36,13 @@ extern "C" { /** * @brief Radio type handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct radio_s *radio_h; /** * @brief Enumeration of radio state. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -53,7 +53,7 @@ typedef enum /** * @brief Enumeration of error codes for the radio. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -63,13 +63,14 @@ typedef enum 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_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 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -86,7 +87,7 @@ typedef enum /** * @brief Called when the scan information is updated. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] frequency The tuned radio frequency [87500 ~ 108000] (kHz) * @param[in] user_data The user data passed from the callback registration function * @pre It will be invoked by radio_scan_start(). @@ -96,7 +97,7 @@ typedef void (*radio_scan_updated_cb)(int frequency, void *user_data); /** * @brief Called when the radio scan is stopped. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] user_data The user data passed from the callback registration function * @pre It will be invoked when the scan is stopped by radio_scan_stop(). * @see radio_scan_stop() @@ -105,7 +106,7 @@ typedef void (*radio_scan_stopped_cb)(void *user_data); /** * @brief Called when the radio scan is completed. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] user_data The user data passed from the callback registration function * @pre It will be invoked when the scan is completed by registering this callback using radio_set_scan_completed_cb(). * @see radio_scan_start() @@ -116,7 +117,7 @@ typedef void (*radio_scan_completed_cb)(void *user_data); /** * @brief Called when the radio seek is completed. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] frequency The current frequency [87500 ~ 108000] (kHz) * @param[in] user_data The user data passed from the callback registration function * @pre It will be invoked when the radio seek is completed by registering this callback using radio_seek_up() or radio_seek_down(). @@ -127,7 +128,7 @@ typedef void (*radio_seek_completed_cb)(int frequency, void *user_data); /** * @brief Called when the radio is interrupted. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] error_code The interrupted error code * @param[in] user_data The user data passed from the callback registration function * @see radio_set_interrupted_cb() @@ -137,7 +138,7 @@ typedef void (*radio_interrupted_cb)(radio_interrupted_code_e code, void *user_d /** * @brief Creates a radio handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks You must release @a radio using radio_destroy(). * @param[out] radio A new handle to radio * @retval #RADIO_ERROR_NONE Successful @@ -151,7 +152,7 @@ int radio_create(radio_h *radio); /** * @brief Destroys the radio handle and releases all its resources. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks To completely shutdown the radio operation, call this function with a valid radio handle. * * @param[in] radio The handle to radio to be destroyed @@ -167,7 +168,7 @@ int radio_destroy(radio_h radio); /** * @brief Gets the radio's current state. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[out] state The current state of the radio * @return @c 0 on success, @@ -180,7 +181,7 @@ int radio_get_state(radio_h radio, radio_state_e *state); /** * @brief Starts playing the radio. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @return @c 0 on success, * otherwise a negative error value @@ -189,6 +190,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() @@ -197,7 +199,7 @@ int radio_start(radio_h radio); /** * @brief Stops playing the radio. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @return @c 0 on success, * otherwise a negative error value @@ -214,7 +216,7 @@ int radio_stop(radio_h radio); /** * @brief Seeks up the effective frequency of the radio, asynchronously. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function @@ -233,7 +235,7 @@ int radio_seek_up(radio_h radio,radio_seek_completed_cb callback, void *user_dat /** * @brief Seeks down the effective frequency of the radio, asynchronously. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function @@ -252,7 +254,7 @@ int radio_seek_down(radio_h radio,radio_seek_completed_cb callback, void *user_d /** * @brief Sets the radio frequency. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[in] frequency The frequency to set [87500 ~ 108000] (kHz) * @return @c 0 on success, @@ -267,7 +269,7 @@ int radio_set_frequency(radio_h radio, int frequency); /** * @brief Gets the current frequency of the radio. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[out] frequency The current frequency [87500 ~ 108000] (kHz) * @return @c 0 on success, @@ -282,7 +284,7 @@ int radio_get_frequency(radio_h radio, int *frequency); /** * @brief Gets the current signal strength of the radio. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[out] strength The current signal strength [-128 ~ 128] (dBm) * @return @c 0 on success, @@ -296,7 +298,7 @@ int radio_get_signal_strength(radio_h radio, int *strength); /** * @brief Starts scanning radio signals, asynchronously - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function @@ -319,7 +321,7 @@ int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_d /** * @brief Stops scanning radio signals, asynchronously. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function @@ -339,7 +341,7 @@ int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_da /** * @brief Sets the radio's mute status. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @details If the mute status is @c true, no sounds will be played. If @c false, sounds will be played. Until this function is called, by default the radio is not muted. * @param[in] radio The handle to radio * @param[in] muted The new mute status: (@c true = mute, @c false = not muted) @@ -355,7 +357,7 @@ int radio_set_mute(radio_h radio, bool muted); /** * @brief Gets the radio's mute status. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @details If the mute status is @c true, no sounds are played. If @c false, sounds are played. * @param[in] radio The handle to radio * @param[out] muted The current mute status: (@c true = mute, @c false = not muted) @@ -371,7 +373,7 @@ int radio_is_muted(radio_h radio, bool *muted); /** * @brief Registers a callback function to be invoked when the scan finishes. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function @@ -389,7 +391,7 @@ int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback, /** * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @return @c 0 on success, * otherwise a negative error value @@ -403,7 +405,7 @@ int radio_unset_scan_completed_cb(radio_h radio); /** * @brief Registers a callback function to be invoked when the radio is interrupted. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function @@ -422,7 +424,7 @@ int radio_set_interrupted_cb(radio_h radio, radio_interrupted_cb callback, void /** * @brief Unregisters the callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] radio The handle to radio * @return @c 0 on success, * otherwise a negative error value @@ -435,6 +437,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); + + +/** * @} */ diff --git a/packaging/capi-media-radio.spec b/packaging/capi-media-radio.spec index 26de389..e093c26 100644 --- a/packaging/capi-media-radio.spec +++ b/packaging/capi-media-radio.spec @@ -1,25 +1,22 @@ Name: capi-media-radio Summary: A Radio library in Tizen Native API -Version: 0.1.0 +Version: 0.1.1 Release: 10 Group: API/C API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: capi-media-radio.manifest -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. -%package devel +%package devel Summary: A Radio library in Tizen Native API (Development) Group: Development/API Requires: %{name} = %{version}-%{release} @@ -50,7 +47,7 @@ make %{?jobs:-j%jobs} %defattr(-,root,root,-) %{_libdir}/libcapi-media-radio.so.* -%files devel +%files devel %manifest %{name}.manifest %defattr(-,root,root,-) /usr/include/media/radio.h diff --git a/src/radio.c b/src/radio.c index 72aa388..e17eed0 100755 --- a/src/radio.c +++ b/src/radio.c @@ -73,6 +73,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; @@ -92,6 +93,10 @@ static int __convert_error_code(int code, char *func_name) 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; @@ -647,3 +652,52 @@ int radio_unset_interrupted_cb(radio_h radio) RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); 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; + } +} + + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a4024d4..4ffcb36 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,7 +10,7 @@ FOREACH(flag ${${fw_test}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -pie") aux_source_directory(. sources) FOREACH(src ${sources}) diff --git a/test/radio_test.c b/test/radio_test.c index 8886db6..d7bfaa9 100755 --- a/test/radio_test.c +++ b/test/radio_test.c @@ -28,7 +28,7 @@ #include #define DEFAULT_TEST_FREQ 107700 -#define MENU_ITEM_MAX 19 +#define MENU_ITEM_MAX 20 #define _MAX_INPUT_STRING_ 100 @@ -340,6 +340,8 @@ 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"); @@ -498,6 +500,23 @@ void __call_api( int choosen ) } 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; } -- 2.7.4