diff options
-rw-r--r-- | drivers/media/radio/CG2900/cg2900_fm_api.c | 16 | ||||
-rw-r--r-- | drivers/media/radio/CG2900/cg2900_fm_driver.c | 47 | ||||
-rw-r--r-- | drivers/media/radio/CG2900/cg2900_fm_driver.h | 30 |
3 files changed, 93 insertions, 0 deletions
diff --git a/drivers/media/radio/CG2900/cg2900_fm_api.c b/drivers/media/radio/CG2900/cg2900_fm_api.c index b7f5f9867d6..c636f2fe8a9 100644 --- a/drivers/media/radio/CG2900/cg2900_fm_api.c +++ b/drivers/media/radio/CG2900/cg2900_fm_api.c @@ -26,6 +26,8 @@ #define FW_FILE_PARAM_LEN 3 /* RDS Tx PTY set to Other music */ #define OTHER_MUSIC 15 +#define DEFAULT_AUDIO_DEVIATION 0x1AA9 +#define DEFAULT_NOTIFICATION_HOLD_OFF_TIME 0x000A static bool fm_rds_status; static bool fm_prev_rds_status; @@ -1262,6 +1264,20 @@ int cg2900_fm_set_tx_default_settings( goto error; } + /* Sets the Limiter Values */ + FM_DEBUG_REPORT("cg2900_fm_set_tx_default_settings: " + "Sending fmd_limiter_setcontrol"); + result = fmd_limiter_setcontrol( + DEFAULT_AUDIO_DEVIATION, + DEFAULT_NOTIFICATION_HOLD_OFF_TIME); + if (0 != result) { + FM_ERR_REPORT("cg2900_fm_set_tx_default_settings: " + "fmd_limiter_setcontrol failed %x", + (unsigned int)result); + result = -EINVAL; + goto error; + } + /* Set the Grid */ FM_DEBUG_REPORT("cg2900_fm_set_tx_default_settings: " "Sending fmd_tx_set_grid "); diff --git a/drivers/media/radio/CG2900/cg2900_fm_driver.c b/drivers/media/radio/CG2900/cg2900_fm_driver.c index 9959790cbe8..4120eaa4d50 100644 --- a/drivers/media/radio/CG2900/cg2900_fm_driver.c +++ b/drivers/media/radio/CG2900/cg2900_fm_driver.c @@ -4833,6 +4833,53 @@ error: return err; } +int fmd_limiter_setcontrol( + u16 audio_deviation, + u16 notification_hold_off_time + ) +{ + int err; + int io_result; + u16 parameters[CMD_FMT_RP_LIMITER_SETCONTROL_PARAM_LEN]; + + if (fmd_go_cmd_busy()) { + err = -EBUSY; + goto error; + } + + if (!fmd_state_info.fmd_initialized) { + err = -ENOEXEC; + goto error; + } + + if (audio_deviation < MIN_AUDIO_DEVIATION || + audio_deviation > MAX_AUDIO_DEVIATION || + notification_hold_off_time > 0x7FFF) { + err = -EINVAL; + goto error; + } + + parameters[0] = audio_deviation; + parameters[1] = notification_hold_off_time; + + io_result = fmd_send_cmd_and_read_resp( + CMD_FMT_RP_LIMITER_SETCONTROL, + CMD_FMT_RP_LIMITER_SETCONTROL_PARAM_LEN, + parameters, + NULL, + NULL); + + if (io_result != 0) { + err = io_result; + goto error; + } + + err = 0; + +error: + return err; +} + MODULE_AUTHOR("Hemant Gupta"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/radio/CG2900/cg2900_fm_driver.h b/drivers/media/radio/CG2900/cg2900_fm_driver.h index fc20476c64a..aa908a5f14d 100644 --- a/drivers/media/radio/CG2900/cg2900_fm_driver.h +++ b/drivers/media/radio/CG2900/cg2900_fm_driver.h @@ -144,6 +144,16 @@ enum fmd_debug_levels { * This is just a hexadecimal number with no units. */ #define DEFAULT_AVERAGE_NOISE_MAX_VALUE 0x0030 +/* + * Minimum Audio Deviation Level, as per CG2900 FM User Manual. + * This is units of 10 Hz. + */ +#define MIN_AUDIO_DEVIATION 0x157C +/* + * Maximum Audio Deviation Level, as per CG2900 FM UserManual. + * This is units of 10 Hz. + */ +#define MAX_AUDIO_DEVIATION 0x3840 #define FREQUENCY_CONVERTOR_KHZ_HZ 1000 #define CHANNEL_FREQ_CONVERTER_MHZ 50 /* Interrupt(s) for CG2900 */ @@ -220,6 +230,7 @@ enum fmd_debug_levels { #define CMD_TST_TONE_ENABLE 0x0027 #define CMD_TST_TONE_CONNECT 0x0047 #define CMD_TST_TONE_SET_PARAMS 0x0067 +#define CMD_FMT_RP_LIMITER_SETCONTROL 0x01C4 /* FM Command Id Parameter Length */ #define CMD_GET_VERSION_PARAM_LEN 0 @@ -278,6 +289,7 @@ enum fmd_debug_levels { #define CMD_TST_TONE_ENABLE_PARAM_LEN 1 #define CMD_TST_TONE_CONNECT_PARAM_LEN 2 #define CMD_TST_TONE_SET_PARAMS_PARAM_LEN 6 +#define CMD_FMT_RP_LIMITER_SETCONTROL_PARAM_LEN 2 /* FM HCI Command and event specific */ #define FM_WRITE 0x00 @@ -1761,4 +1773,22 @@ int fmd_test_tone_set_params( int fmd_rx_set_deemphasis( u8 deemphasis ); + +/** + * fmd_limiter_setcontrol()- Sets the Limiter Controls. + * + * This function sets the limiter control. + * @audio_deviation: Limiting level of Audio Deviation. + * @notification_hold_off_time: Minimum time between + * two limiting interrupts. + * + * Returns: + * 0, if operation completed successfully. + * -EINVAL, otherwise. + */ +int fmd_limiter_setcontrol( + u16 audio_deviation, + u16 notification_hold_off_time + ); + #endif /* _FMDRIVER_H_ */ |