Venkateshwarlu Domakonda | 54ec325 | 2013-02-18 21:25:57 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #define DRIVER_AUTHOR "Archana Ramchandran <archanar@codeaurora.org>" |
| 14 | #define DRIVER_NAME "radio-iris" |
| 15 | #define DRIVER_CARD "Qualcomm FM Radio Transceiver" |
| 16 | #define DRIVER_DESC "Driver for Qualcomm FM Radio Transceiver " |
| 17 | |
| 18 | #include <linux/version.h> |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/delay.h> |
| 21 | #include <linux/uaccess.h> |
| 22 | #include <linux/kfifo.h> |
| 23 | #include <linux/param.h> |
| 24 | #include <linux/interrupt.h> |
| 25 | #include <linux/kernel.h> |
| 26 | #include <linux/module.h> |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 27 | #include <linux/sched.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 28 | #include <linux/version.h> |
| 29 | #include <linux/videodev2.h> |
| 30 | #include <linux/mutex.h> |
| 31 | #include <linux/unistd.h> |
| 32 | #include <linux/atomic.h> |
| 33 | #include <linux/platform_device.h> |
| 34 | #include <linux/workqueue.h> |
| 35 | #include <linux/slab.h> |
| 36 | #include <media/v4l2-common.h> |
| 37 | #include <media/v4l2-ioctl.h> |
| 38 | #include <media/radio-iris.h> |
| 39 | #include <asm/unaligned.h> |
| 40 | |
| 41 | static unsigned int rds_buf = 100; |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 42 | static int oda_agt; |
| 43 | static int grp_mask; |
| 44 | static int rt_plus_carrier = -1; |
| 45 | static int ert_carrier = -1; |
| 46 | static unsigned char ert_buf[256]; |
| 47 | static unsigned char ert_len; |
| 48 | static unsigned char c_byt_pair_index; |
| 49 | static char utf_8_flag; |
| 50 | static char rt_ert_flag; |
| 51 | static char formatting_dir; |
Sheng Fang | 8ec3c6f | 2013-08-12 14:09:14 +0800 | [diff] [blame] | 52 | static unsigned char sig_blend = CTRL_ON; |
Venkateshwarlu Domakonda | 3ab02ad | 2013-02-25 14:36:39 +0530 | [diff] [blame] | 53 | static DEFINE_MUTEX(iris_fm); |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 54 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 55 | module_param(rds_buf, uint, 0); |
| 56 | MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*"); |
| 57 | |
Sheng Fang | 8ec3c6f | 2013-08-12 14:09:14 +0800 | [diff] [blame] | 58 | module_param(sig_blend, byte, S_IWUSR | S_IRUGO); |
| 59 | MODULE_PARM_DESC(sig_blend, "signal blending switch: 0:OFF 1:ON"); |
| 60 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 61 | static void radio_hci_cmd_task(unsigned long arg); |
| 62 | static void radio_hci_rx_task(unsigned long arg); |
| 63 | static struct video_device *video_get_dev(void); |
| 64 | static DEFINE_RWLOCK(hci_task_lock); |
| 65 | |
| 66 | struct iris_device { |
| 67 | struct device *dev; |
| 68 | struct kfifo data_buf[IRIS_BUF_MAX]; |
| 69 | |
| 70 | int pending_xfrs[IRIS_XFR_MAX]; |
| 71 | int xfr_bytes_left; |
| 72 | int xfr_in_progress; |
| 73 | struct completion sync_xfr_start; |
| 74 | int tune_req; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 75 | unsigned int mode; |
| 76 | |
| 77 | __u16 pi; |
| 78 | __u8 pty; |
| 79 | __u8 ps_repeatcount; |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 80 | __u8 prev_trans_rds; |
Srinivasa Rao Uppala | 1da1a24 | 2012-01-11 11:00:10 +0530 | [diff] [blame] | 81 | __u8 af_jump_bit; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 82 | struct video_device *videodev; |
| 83 | |
| 84 | struct mutex lock; |
| 85 | spinlock_t buf_lock[IRIS_BUF_MAX]; |
| 86 | wait_queue_head_t event_queue; |
| 87 | wait_queue_head_t read_queue; |
| 88 | |
| 89 | struct radio_hci_dev *fm_hdev; |
| 90 | |
| 91 | struct v4l2_capability *g_cap; |
| 92 | struct v4l2_control *g_ctl; |
| 93 | |
| 94 | struct hci_fm_mute_mode_req mute_mode; |
| 95 | struct hci_fm_stereo_mode_req stereo_mode; |
| 96 | struct hci_fm_station_rsp fm_st_rsp; |
| 97 | struct hci_fm_search_station_req srch_st; |
| 98 | struct hci_fm_search_rds_station_req srch_rds; |
| 99 | struct hci_fm_search_station_list_req srch_st_list; |
| 100 | struct hci_fm_recv_conf_req recv_conf; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 101 | struct hci_fm_trans_conf_req_struct trans_conf; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 102 | struct hci_fm_rds_grp_req rds_grp; |
| 103 | unsigned char g_search_mode; |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 104 | unsigned char power_mode; |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 105 | int search_on; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 106 | unsigned int tone_freq; |
Anantha Krishnan | f950e32 | 2012-06-06 14:25:49 +0530 | [diff] [blame] | 107 | unsigned char spur_table_size; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 108 | unsigned char g_scan_time; |
| 109 | unsigned int g_antenna; |
| 110 | unsigned int g_rds_grp_proc_ps; |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 111 | unsigned char event_mask; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 112 | enum iris_region_t region; |
| 113 | struct hci_fm_dbg_param_rsp st_dbg_param; |
| 114 | struct hci_ev_srch_list_compl srch_st_result; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 115 | struct hci_fm_riva_poke riva_data_req; |
| 116 | struct hci_fm_ssbi_req ssbi_data_accs; |
| 117 | struct hci_fm_ssbi_peek ssbi_peek_reg; |
Venkateshwarlu Domakonda | 3d1d6e4 | 2011-12-09 15:08:58 +0530 | [diff] [blame] | 118 | struct hci_fm_sig_threshold_rsp sig_th; |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 119 | struct hci_fm_ch_det_threshold ch_det_threshold; |
Venkateshwarlu Domakonda | 71731d5 | 2012-04-04 12:30:51 +0530 | [diff] [blame] | 120 | struct hci_fm_data_rd_rsp default_data; |
Anantha Krishnan | f950e32 | 2012-06-06 14:25:49 +0530 | [diff] [blame] | 121 | struct hci_fm_spur_data spur_data; |
Ayaz Ahmad | 37294ba | 2012-07-10 16:38:11 +0530 | [diff] [blame] | 122 | unsigned char is_station_valid; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | static struct video_device *priv_videodev; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 126 | static int iris_do_calibration(struct iris_device *radio); |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 127 | static void hci_buff_ert(struct iris_device *radio, |
| 128 | struct rds_grp_data *rds_buf); |
| 129 | static void hci_ev_rt_plus(struct iris_device *radio, |
| 130 | struct rds_grp_data rds_buf); |
| 131 | static void hci_ev_ert(struct iris_device *radio); |
Anantha Krishnan | f950e32 | 2012-06-06 14:25:49 +0530 | [diff] [blame] | 132 | static int update_spur_table(struct iris_device *radio); |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 133 | static int initialise_recv(struct iris_device *radio); |
| 134 | static int initialise_trans(struct iris_device *radio); |
| 135 | static int is_enable_rx_possible(struct iris_device *radio); |
| 136 | static int is_enable_tx_possible(struct iris_device *radio); |
| 137 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 138 | static struct v4l2_queryctrl iris_v4l2_queryctrl[] = { |
| 139 | { |
| 140 | .id = V4L2_CID_AUDIO_VOLUME, |
| 141 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 142 | .name = "Volume", |
| 143 | .minimum = 0, |
| 144 | .maximum = 15, |
| 145 | .step = 1, |
| 146 | .default_value = 15, |
| 147 | }, |
| 148 | { |
| 149 | .id = V4L2_CID_AUDIO_BALANCE, |
| 150 | .flags = V4L2_CTRL_FLAG_DISABLED, |
| 151 | }, |
| 152 | { |
| 153 | .id = V4L2_CID_AUDIO_BASS, |
| 154 | .flags = V4L2_CTRL_FLAG_DISABLED, |
| 155 | }, |
| 156 | { |
| 157 | .id = V4L2_CID_AUDIO_TREBLE, |
| 158 | .flags = V4L2_CTRL_FLAG_DISABLED, |
| 159 | }, |
| 160 | { |
| 161 | .id = V4L2_CID_AUDIO_MUTE, |
| 162 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 163 | .name = "Mute", |
| 164 | .minimum = 0, |
| 165 | .maximum = 1, |
| 166 | .step = 1, |
| 167 | .default_value = 1, |
| 168 | }, |
| 169 | { |
| 170 | .id = V4L2_CID_AUDIO_LOUDNESS, |
| 171 | .flags = V4L2_CTRL_FLAG_DISABLED, |
| 172 | }, |
| 173 | { |
| 174 | .id = V4L2_CID_PRIVATE_IRIS_SRCHMODE, |
| 175 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 176 | .name = "Search mode", |
| 177 | .minimum = 0, |
| 178 | .maximum = 7, |
| 179 | .step = 1, |
| 180 | .default_value = 0, |
| 181 | }, |
| 182 | { |
| 183 | .id = V4L2_CID_PRIVATE_IRIS_SCANDWELL, |
| 184 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 185 | .name = "Search dwell time", |
| 186 | .minimum = 0, |
| 187 | .maximum = 7, |
| 188 | .step = 1, |
| 189 | .default_value = 0, |
| 190 | }, |
| 191 | { |
| 192 | .id = V4L2_CID_PRIVATE_IRIS_SRCHON, |
| 193 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 194 | .name = "Search on/off", |
| 195 | .minimum = 0, |
| 196 | .maximum = 1, |
| 197 | .step = 1, |
| 198 | .default_value = 1, |
| 199 | |
| 200 | }, |
| 201 | { |
| 202 | .id = V4L2_CID_PRIVATE_IRIS_STATE, |
| 203 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 204 | .name = "radio 0ff/rx/tx/reset", |
| 205 | .minimum = 0, |
| 206 | .maximum = 3, |
| 207 | .step = 1, |
| 208 | .default_value = 1, |
| 209 | |
| 210 | }, |
| 211 | { |
| 212 | .id = V4L2_CID_PRIVATE_IRIS_REGION, |
| 213 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 214 | .name = "radio standard", |
| 215 | .minimum = 0, |
| 216 | .maximum = 2, |
| 217 | .step = 1, |
| 218 | .default_value = 0, |
| 219 | }, |
| 220 | { |
| 221 | .id = V4L2_CID_PRIVATE_IRIS_SIGNAL_TH, |
| 222 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 223 | .name = "Signal Threshold", |
| 224 | .minimum = 0x80, |
| 225 | .maximum = 0x7F, |
| 226 | .step = 1, |
| 227 | .default_value = 0, |
| 228 | }, |
| 229 | { |
| 230 | .id = V4L2_CID_PRIVATE_IRIS_SRCH_PTY, |
| 231 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 232 | .name = "Search PTY", |
| 233 | .minimum = 0, |
| 234 | .maximum = 31, |
| 235 | .default_value = 0, |
| 236 | }, |
| 237 | { |
| 238 | .id = V4L2_CID_PRIVATE_IRIS_SRCH_PI, |
| 239 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 240 | .name = "Search PI", |
| 241 | .minimum = 0, |
| 242 | .maximum = 0xFF, |
| 243 | .default_value = 0, |
| 244 | }, |
| 245 | { |
| 246 | .id = V4L2_CID_PRIVATE_IRIS_SRCH_CNT, |
| 247 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 248 | .name = "Preset num", |
| 249 | .minimum = 0, |
| 250 | .maximum = 12, |
| 251 | .default_value = 0, |
| 252 | }, |
| 253 | { |
| 254 | .id = V4L2_CID_PRIVATE_IRIS_EMPHASIS, |
| 255 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 256 | .name = "Emphasis", |
| 257 | .minimum = 0, |
| 258 | .maximum = 1, |
| 259 | .default_value = 0, |
| 260 | }, |
| 261 | { |
| 262 | .id = V4L2_CID_PRIVATE_IRIS_RDS_STD, |
| 263 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 264 | .name = "RDS standard", |
| 265 | .minimum = 0, |
| 266 | .maximum = 1, |
| 267 | .default_value = 0, |
| 268 | }, |
| 269 | { |
| 270 | .id = V4L2_CID_PRIVATE_IRIS_SPACING, |
| 271 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 272 | .name = "Channel spacing", |
| 273 | .minimum = 0, |
| 274 | .maximum = 2, |
| 275 | .default_value = 0, |
| 276 | }, |
| 277 | { |
| 278 | .id = V4L2_CID_PRIVATE_IRIS_RDSON, |
| 279 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 280 | .name = "RDS on/off", |
| 281 | .minimum = 0, |
| 282 | .maximum = 1, |
| 283 | .default_value = 0, |
| 284 | }, |
| 285 | { |
| 286 | .id = V4L2_CID_PRIVATE_IRIS_RDSGROUP_MASK, |
| 287 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 288 | .name = "RDS group mask", |
| 289 | .minimum = 0, |
| 290 | .maximum = 0xFFFFFFFF, |
| 291 | .default_value = 0, |
| 292 | }, |
| 293 | { |
| 294 | .id = V4L2_CID_PRIVATE_IRIS_RDSGROUP_PROC, |
| 295 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 296 | .name = "RDS processing", |
| 297 | .minimum = 0, |
| 298 | .maximum = 0xFF, |
| 299 | .default_value = 0, |
| 300 | }, |
| 301 | { |
| 302 | .id = V4L2_CID_PRIVATE_IRIS_RDSD_BUF, |
| 303 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 304 | .name = "RDS data groups to buffer", |
| 305 | .minimum = 1, |
| 306 | .maximum = 21, |
| 307 | .default_value = 0, |
| 308 | }, |
| 309 | { |
| 310 | .id = V4L2_CID_PRIVATE_IRIS_PSALL, |
| 311 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 312 | .name = "pass all ps strings", |
| 313 | .minimum = 0, |
| 314 | .maximum = 1, |
| 315 | .default_value = 0, |
| 316 | }, |
| 317 | { |
| 318 | .id = V4L2_CID_PRIVATE_IRIS_LP_MODE, |
| 319 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 320 | .name = "Low power mode", |
| 321 | .minimum = 0, |
| 322 | .maximum = 1, |
| 323 | .default_value = 0, |
| 324 | }, |
| 325 | { |
| 326 | .id = V4L2_CID_PRIVATE_IRIS_ANTENNA, |
| 327 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 328 | .name = "headset/internal", |
| 329 | .minimum = 0, |
| 330 | .maximum = 1, |
| 331 | .default_value = 0, |
| 332 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 333 | { |
| 334 | .id = V4L2_CID_PRIVATE_IRIS_TX_SETPSREPEATCOUNT, |
| 335 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 336 | .name = "Set PS REPEATCOUNT", |
| 337 | .minimum = 0, |
| 338 | .maximum = 15, |
| 339 | }, |
| 340 | { |
| 341 | .id = V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_PS_NAME, |
| 342 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 343 | .name = "Stop PS NAME", |
| 344 | .minimum = 0, |
| 345 | .maximum = 1, |
| 346 | }, |
| 347 | { |
| 348 | .id = V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_RT, |
| 349 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 350 | .name = "Stop RT", |
| 351 | .minimum = 0, |
| 352 | .maximum = 1, |
| 353 | }, |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 354 | { |
| 355 | .id = V4L2_CID_PRIVATE_IRIS_SOFT_MUTE, |
| 356 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 357 | .name = "Soft Mute", |
| 358 | .minimum = 0, |
| 359 | .maximum = 1, |
| 360 | }, |
| 361 | { |
| 362 | .id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR, |
| 363 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 364 | .name = "Riva addr", |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 365 | .minimum = 0x3180000, |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 366 | .maximum = 0x31E0004, |
| 367 | }, |
| 368 | { |
| 369 | .id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN, |
| 370 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 371 | .name = "Data len", |
| 372 | .minimum = 0, |
| 373 | .maximum = 0xFF, |
| 374 | }, |
| 375 | { |
| 376 | .id = V4L2_CID_PRIVATE_IRIS_RIVA_PEEK, |
| 377 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 378 | .name = "Riva peek", |
| 379 | .minimum = 0, |
| 380 | .maximum = 1, |
| 381 | }, |
| 382 | { |
| 383 | .id = V4L2_CID_PRIVATE_IRIS_RIVA_POKE, |
| 384 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 385 | .name = "Riva poke", |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 386 | .minimum = 0x3180000, |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 387 | .maximum = 0x31E0004, |
| 388 | }, |
| 389 | { |
| 390 | .id = V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR, |
| 391 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 392 | .name = "Ssbi addr", |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 393 | .minimum = 0x280, |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 394 | .maximum = 0x37F, |
| 395 | }, |
| 396 | { |
| 397 | .id = V4L2_CID_PRIVATE_IRIS_SSBI_PEEK, |
| 398 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 399 | .name = "Ssbi peek", |
| 400 | .minimum = 0, |
| 401 | .maximum = 0x37F, |
| 402 | }, |
| 403 | { |
| 404 | .id = V4L2_CID_PRIVATE_IRIS_SSBI_POKE, |
| 405 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 406 | .name = "ssbi poke", |
| 407 | .minimum = 0x01, |
| 408 | .maximum = 0xFF, |
| 409 | }, |
| 410 | { |
| 411 | .id = V4L2_CID_PRIVATE_IRIS_HLSI, |
| 412 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 413 | .name = "set hlsi", |
| 414 | .minimum = 0, |
| 415 | .maximum = 2, |
| 416 | }, |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 417 | { |
| 418 | .id = V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS, |
| 419 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 420 | .name = "RDS grp", |
| 421 | .minimum = 0, |
| 422 | .maximum = 1, |
| 423 | }, |
| 424 | { |
| 425 | .id = V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER, |
| 426 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 427 | .name = "Notch filter", |
| 428 | .minimum = 0, |
| 429 | .maximum = 2, |
| 430 | }, |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 431 | { |
| 432 | .id = V4L2_CID_PRIVATE_IRIS_READ_DEFAULT, |
| 433 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 434 | .name = "Read default", |
| 435 | }, |
| 436 | { |
| 437 | .id = V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT, |
| 438 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 439 | .name = "Write default", |
| 440 | }, |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 441 | { |
| 442 | .id = V4L2_CID_PRIVATE_IRIS_SET_CALIBRATION, |
| 443 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 444 | .name = "SET Calibration", |
| 445 | .minimum = 0, |
| 446 | .maximum = 1, |
| 447 | }, |
| 448 | { |
| 449 | .id = V4L2_CID_PRIVATE_IRIS_DO_CALIBRATION, |
| 450 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 451 | .name = "SET Calibration", |
| 452 | .minimum = 0, |
| 453 | .maximum = 1, |
| 454 | }, |
Srinivasa Rao Uppala | acdebcc | 2011-12-23 14:31:38 +0530 | [diff] [blame] | 455 | { |
| 456 | .id = V4L2_CID_PRIVATE_IRIS_GET_SINR, |
| 457 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 458 | .name = "GET SINR", |
| 459 | .minimum = -128, |
| 460 | .maximum = 127, |
| 461 | }, |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 462 | { |
| 463 | .id = V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD, |
| 464 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 465 | .name = "Intf High Threshold", |
| 466 | .minimum = 0, |
| 467 | .maximum = 0xFF, |
| 468 | .default_value = 0, |
| 469 | }, |
| 470 | { |
| 471 | .id = V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD, |
| 472 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 473 | .name = "Intf low Threshold", |
| 474 | .minimum = 0, |
| 475 | .maximum = 0xFF, |
| 476 | .default_value = 0, |
| 477 | }, |
| 478 | { |
| 479 | .id = V4L2_CID_PRIVATE_SINR_THRESHOLD, |
| 480 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 481 | .name = "SINR Threshold", |
| 482 | .minimum = -128, |
| 483 | .maximum = 127, |
| 484 | .default_value = 0, |
| 485 | }, |
| 486 | { |
| 487 | .id = V4L2_CID_PRIVATE_SINR_SAMPLES, |
| 488 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 489 | .name = "SINR samples", |
| 490 | .minimum = 1, |
| 491 | .maximum = 0xFF, |
| 492 | .default_value = 0, |
| 493 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 494 | }; |
| 495 | |
| 496 | static void iris_q_event(struct iris_device *radio, |
| 497 | enum iris_evt_t event) |
| 498 | { |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 499 | struct kfifo *data_b; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 500 | unsigned char evt = event; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 501 | |
| 502 | if (radio == NULL) { |
| 503 | FMDERR(":radio is null"); |
| 504 | return; |
| 505 | } |
| 506 | |
| 507 | data_b = &radio->data_buf[IRIS_BUF_EVENTS]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 508 | if (kfifo_in_locked(data_b, &evt, 1, &radio->buf_lock[IRIS_BUF_EVENTS])) |
| 509 | wake_up_interruptible(&radio->event_queue); |
| 510 | } |
| 511 | |
| 512 | static int hci_send_frame(struct sk_buff *skb) |
| 513 | { |
| 514 | struct radio_hci_dev *hdev = (struct radio_hci_dev *) skb->dev; |
| 515 | |
| 516 | if (!hdev) { |
| 517 | kfree_skb(skb); |
| 518 | return -ENODEV; |
| 519 | } |
| 520 | |
| 521 | __net_timestamp(skb); |
| 522 | |
| 523 | skb_orphan(skb); |
| 524 | return hdev->send(skb); |
| 525 | } |
| 526 | |
| 527 | static void radio_hci_cmd_task(unsigned long arg) |
| 528 | { |
| 529 | struct radio_hci_dev *hdev = (struct radio_hci_dev *) arg; |
| 530 | struct sk_buff *skb; |
| 531 | if (!(atomic_read(&hdev->cmd_cnt)) |
| 532 | && time_after(jiffies, hdev->cmd_last_tx + HZ)) { |
| 533 | FMDERR("%s command tx timeout", hdev->name); |
| 534 | atomic_set(&hdev->cmd_cnt, 1); |
| 535 | } |
| 536 | |
| 537 | skb = skb_dequeue(&hdev->cmd_q); |
| 538 | if (atomic_read(&hdev->cmd_cnt) && skb) { |
| 539 | kfree_skb(hdev->sent_cmd); |
| 540 | hdev->sent_cmd = skb_clone(skb, GFP_ATOMIC); |
| 541 | if (hdev->sent_cmd) { |
| 542 | atomic_dec(&hdev->cmd_cnt); |
| 543 | hci_send_frame(skb); |
| 544 | hdev->cmd_last_tx = jiffies; |
| 545 | } else { |
| 546 | skb_queue_head(&hdev->cmd_q, skb); |
| 547 | tasklet_schedule(&hdev->cmd_task); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | } |
| 552 | |
| 553 | static void radio_hci_rx_task(unsigned long arg) |
| 554 | { |
| 555 | struct radio_hci_dev *hdev = (struct radio_hci_dev *) arg; |
| 556 | struct sk_buff *skb; |
| 557 | |
| 558 | read_lock(&hci_task_lock); |
| 559 | |
| 560 | skb = skb_dequeue(&hdev->rx_q); |
| 561 | radio_hci_event_packet(hdev, skb); |
| 562 | |
| 563 | read_unlock(&hci_task_lock); |
| 564 | } |
| 565 | |
| 566 | int radio_hci_register_dev(struct radio_hci_dev *hdev) |
| 567 | { |
| 568 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 569 | if (!radio) { |
| 570 | FMDERR(":radio is null"); |
| 571 | return -EINVAL; |
| 572 | } |
| 573 | |
| 574 | if (!hdev) { |
| 575 | FMDERR("hdev is null"); |
| 576 | return -EINVAL; |
| 577 | } |
| 578 | |
| 579 | hdev->flags = 0; |
| 580 | |
| 581 | tasklet_init(&hdev->cmd_task, radio_hci_cmd_task, (unsigned long) |
| 582 | hdev); |
| 583 | tasklet_init(&hdev->rx_task, radio_hci_rx_task, (unsigned long) |
| 584 | hdev); |
| 585 | |
| 586 | init_waitqueue_head(&hdev->req_wait_q); |
| 587 | |
| 588 | skb_queue_head_init(&hdev->rx_q); |
| 589 | skb_queue_head_init(&hdev->cmd_q); |
| 590 | skb_queue_head_init(&hdev->raw_q); |
| 591 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 592 | |
| 593 | radio->fm_hdev = hdev; |
| 594 | |
| 595 | return 0; |
| 596 | } |
| 597 | EXPORT_SYMBOL(radio_hci_register_dev); |
| 598 | |
| 599 | int radio_hci_unregister_dev(struct radio_hci_dev *hdev) |
| 600 | { |
| 601 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 602 | if (!radio) { |
| 603 | FMDERR(":radio is null"); |
| 604 | return -EINVAL; |
| 605 | } |
| 606 | |
| 607 | tasklet_kill(&hdev->rx_task); |
| 608 | tasklet_kill(&hdev->cmd_task); |
| 609 | skb_queue_purge(&hdev->rx_q); |
| 610 | skb_queue_purge(&hdev->cmd_q); |
| 611 | skb_queue_purge(&hdev->raw_q); |
| 612 | kfree(radio->fm_hdev); |
| 613 | kfree(radio->videodev); |
| 614 | |
| 615 | return 0; |
| 616 | } |
| 617 | EXPORT_SYMBOL(radio_hci_unregister_dev); |
| 618 | |
| 619 | int radio_hci_recv_frame(struct sk_buff *skb) |
| 620 | { |
| 621 | struct radio_hci_dev *hdev = (struct radio_hci_dev *) skb->dev; |
| 622 | if (!hdev) { |
| 623 | FMDERR("%s hdev is null while receiving frame", hdev->name); |
| 624 | kfree_skb(skb); |
| 625 | return -ENXIO; |
| 626 | } |
| 627 | |
| 628 | __net_timestamp(skb); |
| 629 | |
| 630 | radio_hci_event_packet(hdev, skb); |
Srinivasa Rao Uppala | cf3a811 | 2011-09-22 21:02:02 +0530 | [diff] [blame] | 631 | kfree_skb(skb); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 632 | return 0; |
| 633 | } |
| 634 | EXPORT_SYMBOL(radio_hci_recv_frame); |
| 635 | |
| 636 | int radio_hci_send_cmd(struct radio_hci_dev *hdev, __u16 opcode, __u32 plen, |
| 637 | void *param) |
| 638 | { |
| 639 | int len = RADIO_HCI_COMMAND_HDR_SIZE + plen; |
| 640 | struct radio_hci_command_hdr *hdr; |
| 641 | struct sk_buff *skb; |
| 642 | int ret = 0; |
| 643 | |
| 644 | skb = alloc_skb(len, GFP_ATOMIC); |
| 645 | if (!skb) { |
| 646 | FMDERR("%s no memory for command", hdev->name); |
| 647 | return -ENOMEM; |
| 648 | } |
| 649 | |
| 650 | hdr = (struct radio_hci_command_hdr *) skb_put(skb, |
| 651 | RADIO_HCI_COMMAND_HDR_SIZE); |
| 652 | hdr->opcode = cpu_to_le16(opcode); |
| 653 | hdr->plen = plen; |
| 654 | |
| 655 | if (plen) |
| 656 | memcpy(skb_put(skb, plen), param, plen); |
| 657 | |
| 658 | skb->dev = (void *) hdev; |
| 659 | |
| 660 | ret = hci_send_frame(skb); |
| 661 | |
| 662 | return ret; |
| 663 | } |
| 664 | EXPORT_SYMBOL(radio_hci_send_cmd); |
| 665 | |
| 666 | static int hci_fm_enable_recv_req(struct radio_hci_dev *hdev, |
| 667 | unsigned long param) |
| 668 | { |
| 669 | __u16 opcode = 0; |
| 670 | |
| 671 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 672 | HCI_OCF_FM_ENABLE_RECV_REQ); |
| 673 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 674 | } |
| 675 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 676 | static int hci_fm_tone_generator(struct radio_hci_dev *hdev, |
| 677 | unsigned long param) |
| 678 | { |
| 679 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 680 | __u16 opcode = 0; |
| 681 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 682 | if (radio == NULL) { |
| 683 | FMDERR(":radio is null"); |
| 684 | return -EINVAL; |
| 685 | } |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 686 | opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, |
| 687 | HCI_FM_SET_INTERNAL_TONE_GENRATOR); |
| 688 | return radio_hci_send_cmd(hdev, opcode, |
| 689 | sizeof(radio->tone_freq), &radio->tone_freq); |
| 690 | } |
| 691 | |
| 692 | static int hci_fm_enable_trans_req(struct radio_hci_dev *hdev, |
| 693 | unsigned long param) |
| 694 | { |
| 695 | __u16 opcode = 0; |
| 696 | |
| 697 | opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, |
| 698 | HCI_OCF_FM_ENABLE_TRANS_REQ); |
| 699 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 700 | } |
| 701 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 702 | static int hci_fm_disable_recv_req(struct radio_hci_dev *hdev, |
| 703 | unsigned long param) |
| 704 | { |
| 705 | __u16 opcode = 0; |
| 706 | |
| 707 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 708 | HCI_OCF_FM_DISABLE_RECV_REQ); |
| 709 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 710 | } |
| 711 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 712 | static int hci_fm_disable_trans_req(struct radio_hci_dev *hdev, |
| 713 | unsigned long param) |
| 714 | { |
| 715 | __u16 opcode = 0; |
| 716 | |
| 717 | opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, |
| 718 | HCI_OCF_FM_DISABLE_TRANS_REQ); |
| 719 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 720 | } |
| 721 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 722 | static int hci_get_fm_recv_conf_req(struct radio_hci_dev *hdev, |
| 723 | unsigned long param) |
| 724 | { |
| 725 | __u16 opcode = 0; |
| 726 | |
| 727 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 728 | HCI_OCF_FM_GET_RECV_CONF_REQ); |
| 729 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 730 | } |
| 731 | |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 732 | static int hci_get_fm_trans_conf_req(struct radio_hci_dev *hdev, |
| 733 | unsigned long param) |
| 734 | { |
| 735 | u16 opcode = 0; |
| 736 | |
| 737 | opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, |
| 738 | HCI_OCF_FM_GET_TRANS_CONF_REQ); |
| 739 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 740 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 741 | static int hci_set_fm_recv_conf_req(struct radio_hci_dev *hdev, |
| 742 | unsigned long param) |
| 743 | { |
| 744 | __u16 opcode = 0; |
| 745 | |
| 746 | struct hci_fm_recv_conf_req *recv_conf_req = |
| 747 | (struct hci_fm_recv_conf_req *) param; |
| 748 | |
| 749 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 750 | HCI_OCF_FM_SET_RECV_CONF_REQ); |
| 751 | return radio_hci_send_cmd(hdev, opcode, sizeof((*recv_conf_req)), |
| 752 | recv_conf_req); |
| 753 | } |
| 754 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 755 | static int hci_set_fm_trans_conf_req(struct radio_hci_dev *hdev, |
| 756 | unsigned long param) |
| 757 | { |
| 758 | __u16 opcode = 0; |
| 759 | |
| 760 | struct hci_fm_trans_conf_req_struct *trans_conf_req = |
| 761 | (struct hci_fm_trans_conf_req_struct *) param; |
| 762 | |
| 763 | opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, |
| 764 | HCI_OCF_FM_SET_TRANS_CONF_REQ); |
| 765 | return radio_hci_send_cmd(hdev, opcode, sizeof((*trans_conf_req)), |
| 766 | trans_conf_req); |
| 767 | } |
| 768 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 769 | static int hci_fm_get_station_param_req(struct radio_hci_dev *hdev, |
| 770 | unsigned long param) |
| 771 | { |
| 772 | __u16 opcode = 0; |
| 773 | |
| 774 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 775 | HCI_OCF_FM_GET_STATION_PARAM_REQ); |
| 776 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 777 | } |
| 778 | |
| 779 | static int hci_set_fm_mute_mode_req(struct radio_hci_dev *hdev, |
| 780 | unsigned long param) |
| 781 | { |
| 782 | __u16 opcode = 0; |
| 783 | struct hci_fm_mute_mode_req *mute_mode_req = |
| 784 | (struct hci_fm_mute_mode_req *) param; |
| 785 | |
| 786 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 787 | HCI_OCF_FM_SET_MUTE_MODE_REQ); |
| 788 | return radio_hci_send_cmd(hdev, opcode, sizeof((*mute_mode_req)), |
| 789 | mute_mode_req); |
| 790 | } |
| 791 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 792 | |
| 793 | static int hci_trans_ps_req(struct radio_hci_dev *hdev, |
| 794 | unsigned long param) |
| 795 | { |
| 796 | __u16 opcode = 0; |
| 797 | struct hci_fm_tx_ps *tx_ps_req = |
| 798 | (struct hci_fm_tx_ps *) param; |
| 799 | |
| 800 | opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, |
| 801 | HCI_OCF_FM_RDS_PS_REQ); |
| 802 | |
| 803 | return radio_hci_send_cmd(hdev, opcode, sizeof((*tx_ps_req)), |
| 804 | tx_ps_req); |
| 805 | } |
| 806 | |
| 807 | static int hci_trans_rt_req(struct radio_hci_dev *hdev, |
| 808 | unsigned long param) |
| 809 | { |
| 810 | __u16 opcode = 0; |
| 811 | struct hci_fm_tx_rt *tx_rt_req = |
| 812 | (struct hci_fm_tx_rt *) param; |
| 813 | |
| 814 | opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, |
| 815 | HCI_OCF_FM_RDS_RT_REQ); |
| 816 | |
| 817 | return radio_hci_send_cmd(hdev, opcode, sizeof((*tx_rt_req)), |
| 818 | tx_rt_req); |
| 819 | } |
| 820 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 821 | static int hci_set_fm_stereo_mode_req(struct radio_hci_dev *hdev, |
| 822 | unsigned long param) |
| 823 | { |
| 824 | __u16 opcode = 0; |
| 825 | struct hci_fm_stereo_mode_req *stereo_mode_req = |
| 826 | (struct hci_fm_stereo_mode_req *) param; |
| 827 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 828 | HCI_OCF_FM_SET_STEREO_MODE_REQ); |
| 829 | return radio_hci_send_cmd(hdev, opcode, sizeof((*stereo_mode_req)), |
| 830 | stereo_mode_req); |
| 831 | } |
| 832 | |
| 833 | static int hci_fm_set_antenna_req(struct radio_hci_dev *hdev, |
| 834 | unsigned long param) |
| 835 | { |
| 836 | __u16 opcode = 0; |
| 837 | |
| 838 | __u8 antenna = param; |
| 839 | |
| 840 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 841 | HCI_OCF_FM_SET_ANTENNA); |
| 842 | return radio_hci_send_cmd(hdev, opcode, sizeof(antenna), &antenna); |
| 843 | } |
| 844 | |
| 845 | static int hci_fm_set_sig_threshold_req(struct radio_hci_dev *hdev, |
| 846 | unsigned long param) |
| 847 | { |
| 848 | __u16 opcode = 0; |
| 849 | |
| 850 | __u8 sig_threshold = param; |
| 851 | |
Venkateshwarlu Domakonda | 1c67b75 | 2011-10-17 13:05:48 +0530 | [diff] [blame] | 852 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 853 | HCI_OCF_FM_SET_SIGNAL_THRESHOLD); |
| 854 | return radio_hci_send_cmd(hdev, opcode, sizeof(sig_threshold), |
| 855 | &sig_threshold); |
| 856 | } |
| 857 | |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 858 | static int hci_fm_set_event_mask(struct radio_hci_dev *hdev, |
| 859 | unsigned long param) |
| 860 | { |
| 861 | u16 opcode = 0; |
| 862 | u8 event_mask = param; |
| 863 | |
| 864 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 865 | HCI_OCF_FM_SET_EVENT_MASK); |
| 866 | return radio_hci_send_cmd(hdev, opcode, sizeof(event_mask), |
| 867 | &event_mask); |
| 868 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 869 | static int hci_fm_get_sig_threshold_req(struct radio_hci_dev *hdev, |
| 870 | unsigned long param) |
| 871 | { |
| 872 | __u16 opcode = 0; |
| 873 | |
Venkateshwarlu Domakonda | 1c67b75 | 2011-10-17 13:05:48 +0530 | [diff] [blame] | 874 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 875 | HCI_OCF_FM_GET_SIGNAL_THRESHOLD); |
| 876 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 877 | } |
| 878 | |
| 879 | static int hci_fm_get_program_service_req(struct radio_hci_dev *hdev, |
| 880 | unsigned long param) |
| 881 | { |
| 882 | __u16 opcode = 0; |
| 883 | |
Venkateshwarlu Domakonda | 1c67b75 | 2011-10-17 13:05:48 +0530 | [diff] [blame] | 884 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 885 | HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ); |
| 886 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 887 | } |
| 888 | |
| 889 | static int hci_fm_get_radio_text_req(struct radio_hci_dev *hdev, |
| 890 | unsigned long param) |
| 891 | { |
| 892 | __u16 opcode = 0; |
| 893 | |
Venkateshwarlu Domakonda | 1c67b75 | 2011-10-17 13:05:48 +0530 | [diff] [blame] | 894 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 895 | HCI_OCF_FM_GET_RADIO_TEXT_REQ); |
| 896 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 897 | } |
| 898 | |
| 899 | static int hci_fm_get_af_list_req(struct radio_hci_dev *hdev, |
| 900 | unsigned long param) |
| 901 | { |
| 902 | __u16 opcode = 0; |
| 903 | |
Venkateshwarlu Domakonda | 1c67b75 | 2011-10-17 13:05:48 +0530 | [diff] [blame] | 904 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 905 | HCI_OCF_FM_GET_AF_LIST_REQ); |
| 906 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 907 | } |
| 908 | |
| 909 | static int hci_fm_search_stations_req(struct radio_hci_dev *hdev, |
| 910 | unsigned long param) |
| 911 | { |
| 912 | __u16 opcode = 0; |
| 913 | struct hci_fm_search_station_req *srch_stations = |
| 914 | (struct hci_fm_search_station_req *) param; |
| 915 | |
| 916 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 917 | HCI_OCF_FM_SEARCH_STATIONS); |
| 918 | return radio_hci_send_cmd(hdev, opcode, sizeof((*srch_stations)), |
| 919 | srch_stations); |
| 920 | } |
| 921 | |
| 922 | static int hci_fm_srch_rds_stations_req(struct radio_hci_dev *hdev, |
| 923 | unsigned long param) |
| 924 | { |
| 925 | __u16 opcode = 0; |
| 926 | struct hci_fm_search_rds_station_req *srch_stations = |
| 927 | (struct hci_fm_search_rds_station_req *) param; |
| 928 | |
| 929 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 930 | HCI_OCF_FM_SEARCH_RDS_STATIONS); |
| 931 | return radio_hci_send_cmd(hdev, opcode, sizeof((*srch_stations)), |
| 932 | srch_stations); |
| 933 | } |
| 934 | |
| 935 | static int hci_fm_srch_station_list_req(struct radio_hci_dev *hdev, |
| 936 | unsigned long param) |
| 937 | { |
| 938 | __u16 opcode = 0; |
| 939 | struct hci_fm_search_station_list_req *srch_list = |
| 940 | (struct hci_fm_search_station_list_req *) param; |
| 941 | |
| 942 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 943 | HCI_OCF_FM_SEARCH_STATIONS_LIST); |
| 944 | return radio_hci_send_cmd(hdev, opcode, sizeof((*srch_list)), |
| 945 | srch_list); |
| 946 | } |
| 947 | |
| 948 | static int hci_fm_cancel_search_req(struct radio_hci_dev *hdev, |
| 949 | unsigned long param) |
| 950 | { |
| 951 | __u16 opcode = 0; |
| 952 | |
| 953 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 954 | HCI_OCF_FM_CANCEL_SEARCH); |
| 955 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 956 | } |
| 957 | |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 958 | static int hci_fm_rds_grp_mask_req(struct radio_hci_dev *hdev, |
| 959 | unsigned long param) |
| 960 | { |
| 961 | __u16 opcode = 0; |
| 962 | |
| 963 | struct hci_fm_rds_grp_req *fm_grp_mask = |
| 964 | (struct hci_fm_rds_grp_req *)param; |
| 965 | |
| 966 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 967 | HCI_OCF_FM_RDS_GRP); |
| 968 | return radio_hci_send_cmd(hdev, opcode, sizeof(*fm_grp_mask), |
| 969 | fm_grp_mask); |
| 970 | } |
| 971 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 972 | static int hci_fm_rds_grp_process_req(struct radio_hci_dev *hdev, |
| 973 | unsigned long param) |
| 974 | { |
| 975 | __u16 opcode = 0; |
| 976 | |
| 977 | __u32 fm_grps_process = param; |
| 978 | |
| 979 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 980 | HCI_OCF_FM_RDS_GRP_PROCESS); |
| 981 | return radio_hci_send_cmd(hdev, opcode, sizeof(fm_grps_process), |
| 982 | &fm_grps_process); |
| 983 | } |
| 984 | |
| 985 | static int hci_fm_tune_station_req(struct radio_hci_dev *hdev, |
| 986 | unsigned long param) |
| 987 | { |
| 988 | __u16 opcode = 0; |
| 989 | |
| 990 | __u32 tune_freq = param; |
| 991 | |
| 992 | opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, |
| 993 | HCI_OCF_FM_TUNE_STATION_REQ); |
| 994 | return radio_hci_send_cmd(hdev, opcode, sizeof(tune_freq), &tune_freq); |
| 995 | } |
| 996 | |
| 997 | static int hci_def_data_read_req(struct radio_hci_dev *hdev, |
| 998 | unsigned long param) |
| 999 | { |
| 1000 | __u16 opcode = 0; |
| 1001 | struct hci_fm_def_data_rd_req *def_data_rd = |
| 1002 | (struct hci_fm_def_data_rd_req *) param; |
| 1003 | |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 1004 | opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1005 | HCI_OCF_FM_DEFAULT_DATA_READ); |
| 1006 | return radio_hci_send_cmd(hdev, opcode, sizeof((*def_data_rd)), |
| 1007 | def_data_rd); |
| 1008 | } |
| 1009 | |
| 1010 | static int hci_def_data_write_req(struct radio_hci_dev *hdev, |
| 1011 | unsigned long param) |
| 1012 | { |
| 1013 | __u16 opcode = 0; |
| 1014 | struct hci_fm_def_data_wr_req *def_data_wr = |
| 1015 | (struct hci_fm_def_data_wr_req *) param; |
| 1016 | |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 1017 | opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1018 | HCI_OCF_FM_DEFAULT_DATA_WRITE); |
Anantha Krishnan | 152fe5b | 2012-02-28 18:07:20 +0530 | [diff] [blame] | 1019 | |
| 1020 | return radio_hci_send_cmd(hdev, opcode, (def_data_wr->length+2), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1021 | def_data_wr); |
| 1022 | } |
| 1023 | |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1024 | static int hci_set_notch_filter_req(struct radio_hci_dev *hdev, |
| 1025 | unsigned long param) |
| 1026 | { |
| 1027 | __u16 opcode = 0; |
| 1028 | __u8 notch_filter_val = param; |
| 1029 | |
| 1030 | opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 1031 | HCI_OCF_FM_EN_NOTCH_CTRL); |
| 1032 | return radio_hci_send_cmd(hdev, opcode, sizeof(notch_filter_val), |
| 1033 | ¬ch_filter_val); |
| 1034 | } |
| 1035 | |
| 1036 | |
| 1037 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1038 | static int hci_fm_reset_req(struct radio_hci_dev *hdev, unsigned long param) |
| 1039 | { |
| 1040 | __u16 opcode = 0; |
| 1041 | |
| 1042 | opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, |
| 1043 | HCI_OCF_FM_RESET); |
| 1044 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 1045 | } |
| 1046 | |
| 1047 | static int hci_fm_get_feature_lists_req(struct radio_hci_dev *hdev, |
| 1048 | unsigned long param) |
| 1049 | { |
| 1050 | __u16 opcode = 0; |
| 1051 | |
| 1052 | opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, |
| 1053 | HCI_OCF_FM_GET_FEATURE_LIST); |
| 1054 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 1055 | } |
| 1056 | |
| 1057 | static int hci_fm_do_calibration_req(struct radio_hci_dev *hdev, |
| 1058 | unsigned long param) |
| 1059 | { |
| 1060 | __u16 opcode = 0; |
| 1061 | |
| 1062 | __u8 mode = param; |
| 1063 | |
| 1064 | opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, |
| 1065 | HCI_OCF_FM_DO_CALIBRATION); |
| 1066 | return radio_hci_send_cmd(hdev, opcode, sizeof(mode), &mode); |
| 1067 | } |
| 1068 | |
| 1069 | static int hci_read_grp_counters_req(struct radio_hci_dev *hdev, |
| 1070 | unsigned long param) |
| 1071 | { |
| 1072 | __u16 opcode = 0; |
| 1073 | |
| 1074 | __u8 reset_counters = param; |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1075 | opcode = hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1076 | HCI_OCF_FM_READ_GRP_COUNTERS); |
| 1077 | return radio_hci_send_cmd(hdev, opcode, sizeof(reset_counters), |
| 1078 | &reset_counters); |
| 1079 | } |
| 1080 | |
| 1081 | static int hci_peek_data_req(struct radio_hci_dev *hdev, unsigned long param) |
| 1082 | { |
| 1083 | __u16 opcode = 0; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1084 | struct hci_fm_riva_data *peek_data = (struct hci_fm_riva_data *)param; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1085 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1086 | opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1087 | HCI_OCF_FM_PEEK_DATA); |
| 1088 | return radio_hci_send_cmd(hdev, opcode, sizeof((*peek_data)), |
| 1089 | peek_data); |
| 1090 | } |
| 1091 | |
| 1092 | static int hci_poke_data_req(struct radio_hci_dev *hdev, unsigned long param) |
| 1093 | { |
| 1094 | __u16 opcode = 0; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1095 | struct hci_fm_riva_poke *poke_data = (struct hci_fm_riva_poke *) param; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1096 | |
Srinivasa Rao Uppala | 6cc0e32 | 2011-08-12 10:54:48 -0700 | [diff] [blame] | 1097 | opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1098 | HCI_OCF_FM_POKE_DATA); |
| 1099 | return radio_hci_send_cmd(hdev, opcode, sizeof((*poke_data)), |
| 1100 | poke_data); |
| 1101 | } |
| 1102 | |
| 1103 | static int hci_ssbi_peek_reg_req(struct radio_hci_dev *hdev, |
| 1104 | unsigned long param) |
| 1105 | { |
| 1106 | __u16 opcode = 0; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1107 | struct hci_fm_ssbi_peek *ssbi_peek = (struct hci_fm_ssbi_peek *) param; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1108 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1109 | opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1110 | HCI_OCF_FM_SSBI_PEEK_REG); |
| 1111 | return radio_hci_send_cmd(hdev, opcode, sizeof((*ssbi_peek)), |
| 1112 | ssbi_peek); |
| 1113 | } |
| 1114 | |
| 1115 | static int hci_ssbi_poke_reg_req(struct radio_hci_dev *hdev, |
| 1116 | unsigned long param) |
| 1117 | { |
| 1118 | __u16 opcode = 0; |
| 1119 | struct hci_fm_ssbi_req *ssbi_poke = (struct hci_fm_ssbi_req *) param; |
| 1120 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1121 | opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1122 | HCI_OCF_FM_SSBI_POKE_REG); |
| 1123 | return radio_hci_send_cmd(hdev, opcode, sizeof((*ssbi_poke)), |
| 1124 | ssbi_poke); |
| 1125 | } |
| 1126 | |
| 1127 | static int hci_fm_get_station_dbg_param_req(struct radio_hci_dev *hdev, |
| 1128 | unsigned long param) |
| 1129 | { |
| 1130 | __u16 opcode = 0; |
| 1131 | |
Venkateshwarlu Domakonda | 1c67b75 | 2011-10-17 13:05:48 +0530 | [diff] [blame] | 1132 | opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1133 | HCI_OCF_FM_STATION_DBG_PARAM); |
| 1134 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 1135 | } |
| 1136 | |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 1137 | static int hci_fm_set_ch_det_th(struct radio_hci_dev *hdev, |
| 1138 | unsigned long param) |
| 1139 | { |
| 1140 | struct hci_fm_ch_det_threshold *ch_det_th = |
| 1141 | (struct hci_fm_ch_det_threshold *) param; |
| 1142 | u16 opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 1143 | HCI_OCF_FM_SET_CH_DET_THRESHOLD); |
| 1144 | return radio_hci_send_cmd(hdev, opcode, sizeof((*ch_det_th)), |
| 1145 | ch_det_th); |
| 1146 | } |
| 1147 | |
| 1148 | static int hci_fm_get_ch_det_th(struct radio_hci_dev *hdev, |
| 1149 | unsigned long param) |
| 1150 | { |
| 1151 | u16 opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, |
| 1152 | HCI_OCF_FM_GET_CH_DET_THRESHOLD); |
| 1153 | return radio_hci_send_cmd(hdev, opcode, 0, NULL); |
| 1154 | } |
| 1155 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1156 | static int radio_hci_err(__u16 code) |
| 1157 | { |
| 1158 | switch (code) { |
| 1159 | case 0: |
| 1160 | return 0; |
| 1161 | case 0x01: |
| 1162 | return -EBADRQC; |
| 1163 | case 0x02: |
| 1164 | return -ENOTCONN; |
| 1165 | case 0x03: |
| 1166 | return -EIO; |
| 1167 | case 0x07: |
| 1168 | return -ENOMEM; |
| 1169 | case 0x0c: |
| 1170 | return -EBUSY; |
| 1171 | case 0x11: |
| 1172 | return -EOPNOTSUPP; |
| 1173 | case 0x12: |
| 1174 | return -EINVAL; |
| 1175 | default: |
| 1176 | return -ENOSYS; |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | static int __radio_hci_request(struct radio_hci_dev *hdev, |
| 1181 | int (*req)(struct radio_hci_dev *hdev, |
| 1182 | unsigned long param), |
| 1183 | unsigned long param, __u32 timeout) |
| 1184 | { |
| 1185 | int err = 0; |
| 1186 | |
| 1187 | DECLARE_WAITQUEUE(wait, current); |
| 1188 | |
Venkateshwarlu Domakonda | 3ab02ad | 2013-02-25 14:36:39 +0530 | [diff] [blame] | 1189 | mutex_lock(&iris_fm); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1190 | hdev->req_status = HCI_REQ_PEND; |
| 1191 | |
| 1192 | add_wait_queue(&hdev->req_wait_q, &wait); |
| 1193 | set_current_state(TASK_INTERRUPTIBLE); |
| 1194 | |
| 1195 | err = req(hdev, param); |
| 1196 | |
| 1197 | schedule_timeout(timeout); |
| 1198 | |
| 1199 | remove_wait_queue(&hdev->req_wait_q, &wait); |
| 1200 | |
Venkateshwarlu Domakonda | 3ab02ad | 2013-02-25 14:36:39 +0530 | [diff] [blame] | 1201 | if (signal_pending(current)) { |
| 1202 | mutex_unlock(&iris_fm); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1203 | return -EINTR; |
Venkateshwarlu Domakonda | 3ab02ad | 2013-02-25 14:36:39 +0530 | [diff] [blame] | 1204 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1205 | |
| 1206 | switch (hdev->req_status) { |
| 1207 | case HCI_REQ_DONE: |
| 1208 | case HCI_REQ_STATUS: |
| 1209 | err = radio_hci_err(hdev->req_result); |
| 1210 | break; |
| 1211 | |
| 1212 | case HCI_REQ_CANCELED: |
| 1213 | err = -hdev->req_result; |
| 1214 | break; |
| 1215 | |
| 1216 | default: |
| 1217 | err = -ETIMEDOUT; |
| 1218 | break; |
| 1219 | } |
| 1220 | |
| 1221 | hdev->req_status = hdev->req_result = 0; |
Venkateshwarlu Domakonda | 3ab02ad | 2013-02-25 14:36:39 +0530 | [diff] [blame] | 1222 | mutex_unlock(&iris_fm); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1223 | |
| 1224 | return err; |
| 1225 | } |
| 1226 | |
| 1227 | static inline int radio_hci_request(struct radio_hci_dev *hdev, |
| 1228 | int (*req)(struct |
| 1229 | radio_hci_dev * hdev, unsigned long param), |
| 1230 | unsigned long param, __u32 timeout) |
| 1231 | { |
| 1232 | int ret = 0; |
| 1233 | |
| 1234 | ret = __radio_hci_request(hdev, req, param, timeout); |
| 1235 | |
| 1236 | return ret; |
| 1237 | } |
| 1238 | |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 1239 | static inline int hci_conf_event_mask(__u8 *arg, |
| 1240 | struct radio_hci_dev *hdev) |
| 1241 | { |
| 1242 | u8 event_mask = *arg; |
| 1243 | return radio_hci_request(hdev, hci_fm_set_event_mask, |
| 1244 | event_mask, RADIO_HCI_TIMEOUT); |
| 1245 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1246 | static int hci_set_fm_recv_conf(struct hci_fm_recv_conf_req *arg, |
| 1247 | struct radio_hci_dev *hdev) |
| 1248 | { |
| 1249 | int ret = 0; |
| 1250 | struct hci_fm_recv_conf_req *set_recv_conf = arg; |
| 1251 | |
| 1252 | ret = radio_hci_request(hdev, hci_set_fm_recv_conf_req, (unsigned |
| 1253 | long)set_recv_conf, RADIO_HCI_TIMEOUT); |
| 1254 | |
| 1255 | return ret; |
| 1256 | } |
| 1257 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 1258 | static int hci_set_fm_trans_conf(struct hci_fm_trans_conf_req_struct *arg, |
| 1259 | struct radio_hci_dev *hdev) |
| 1260 | { |
| 1261 | int ret = 0; |
| 1262 | struct hci_fm_trans_conf_req_struct *set_trans_conf = arg; |
| 1263 | |
| 1264 | ret = radio_hci_request(hdev, hci_set_fm_trans_conf_req, (unsigned |
| 1265 | long)set_trans_conf, RADIO_HCI_TIMEOUT); |
| 1266 | |
| 1267 | return ret; |
| 1268 | } |
| 1269 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1270 | static int hci_fm_tune_station(__u32 *arg, struct radio_hci_dev *hdev) |
| 1271 | { |
| 1272 | int ret = 0; |
| 1273 | __u32 tune_freq = *arg; |
| 1274 | |
| 1275 | ret = radio_hci_request(hdev, hci_fm_tune_station_req, tune_freq, |
| 1276 | RADIO_HCI_TIMEOUT); |
| 1277 | |
| 1278 | return ret; |
| 1279 | } |
| 1280 | |
| 1281 | static int hci_set_fm_mute_mode(struct hci_fm_mute_mode_req *arg, |
| 1282 | struct radio_hci_dev *hdev) |
| 1283 | { |
| 1284 | int ret = 0; |
| 1285 | struct hci_fm_mute_mode_req *set_mute_conf = arg; |
| 1286 | |
| 1287 | ret = radio_hci_request(hdev, hci_set_fm_mute_mode_req, (unsigned |
| 1288 | long)set_mute_conf, RADIO_HCI_TIMEOUT); |
| 1289 | |
| 1290 | return ret; |
| 1291 | } |
| 1292 | |
| 1293 | static int hci_set_fm_stereo_mode(struct hci_fm_stereo_mode_req *arg, |
| 1294 | struct radio_hci_dev *hdev) |
| 1295 | { |
| 1296 | int ret = 0; |
| 1297 | struct hci_fm_stereo_mode_req *set_stereo_conf = arg; |
| 1298 | |
| 1299 | ret = radio_hci_request(hdev, hci_set_fm_stereo_mode_req, (unsigned |
| 1300 | long)set_stereo_conf, RADIO_HCI_TIMEOUT); |
| 1301 | |
| 1302 | return ret; |
| 1303 | } |
| 1304 | |
| 1305 | static int hci_fm_set_antenna(__u8 *arg, struct radio_hci_dev *hdev) |
| 1306 | { |
| 1307 | int ret = 0; |
| 1308 | __u8 antenna = *arg; |
| 1309 | |
| 1310 | ret = radio_hci_request(hdev, hci_fm_set_antenna_req, antenna, |
| 1311 | RADIO_HCI_TIMEOUT); |
| 1312 | |
| 1313 | return ret; |
| 1314 | } |
| 1315 | |
| 1316 | static int hci_fm_set_signal_threshold(__u8 *arg, |
| 1317 | struct radio_hci_dev *hdev) |
| 1318 | { |
| 1319 | int ret = 0; |
| 1320 | __u8 sig_threshold = *arg; |
| 1321 | |
| 1322 | ret = radio_hci_request(hdev, hci_fm_set_sig_threshold_req, |
| 1323 | sig_threshold, RADIO_HCI_TIMEOUT); |
| 1324 | |
| 1325 | return ret; |
| 1326 | } |
| 1327 | |
| 1328 | static int hci_fm_search_stations(struct hci_fm_search_station_req *arg, |
| 1329 | struct radio_hci_dev *hdev) |
| 1330 | { |
| 1331 | int ret = 0; |
| 1332 | struct hci_fm_search_station_req *srch_stations = arg; |
| 1333 | |
| 1334 | ret = radio_hci_request(hdev, hci_fm_search_stations_req, (unsigned |
| 1335 | long)srch_stations, RADIO_HCI_TIMEOUT); |
| 1336 | |
| 1337 | return ret; |
| 1338 | } |
| 1339 | |
| 1340 | static int hci_fm_search_rds_stations(struct hci_fm_search_rds_station_req *arg, |
| 1341 | struct radio_hci_dev *hdev) |
| 1342 | { |
| 1343 | int ret = 0; |
| 1344 | struct hci_fm_search_rds_station_req *srch_stations = arg; |
| 1345 | |
| 1346 | ret = radio_hci_request(hdev, hci_fm_srch_rds_stations_req, (unsigned |
| 1347 | long)srch_stations, RADIO_HCI_TIMEOUT); |
| 1348 | |
| 1349 | return ret; |
| 1350 | } |
| 1351 | |
| 1352 | static int hci_fm_search_station_list |
| 1353 | (struct hci_fm_search_station_list_req *arg, |
| 1354 | struct radio_hci_dev *hdev) |
| 1355 | { |
| 1356 | int ret = 0; |
| 1357 | struct hci_fm_search_station_list_req *srch_list = arg; |
| 1358 | |
| 1359 | ret = radio_hci_request(hdev, hci_fm_srch_station_list_req, (unsigned |
| 1360 | long)srch_list, RADIO_HCI_TIMEOUT); |
| 1361 | |
| 1362 | return ret; |
| 1363 | } |
| 1364 | |
| 1365 | static int hci_fm_rds_grp(struct hci_fm_rds_grp_req *arg, |
| 1366 | struct radio_hci_dev *hdev) |
| 1367 | { |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 1368 | int ret = 0; |
| 1369 | struct hci_fm_rds_grp_req *fm_grp_mask = arg; |
| 1370 | |
| 1371 | ret = radio_hci_request(hdev, hci_fm_rds_grp_mask_req, (unsigned |
| 1372 | long)fm_grp_mask, RADIO_HCI_TIMEOUT); |
| 1373 | |
| 1374 | return ret; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1375 | } |
| 1376 | |
| 1377 | static int hci_fm_rds_grps_process(__u32 *arg, struct radio_hci_dev *hdev) |
| 1378 | { |
| 1379 | int ret = 0; |
| 1380 | __u32 fm_grps_process = *arg; |
| 1381 | |
| 1382 | ret = radio_hci_request(hdev, hci_fm_rds_grp_process_req, |
| 1383 | fm_grps_process, RADIO_HCI_TIMEOUT); |
| 1384 | |
| 1385 | return ret; |
| 1386 | } |
| 1387 | |
| 1388 | int hci_def_data_read(struct hci_fm_def_data_rd_req *arg, |
| 1389 | struct radio_hci_dev *hdev) |
| 1390 | { |
| 1391 | int ret = 0; |
| 1392 | struct hci_fm_def_data_rd_req *def_data_rd = arg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1393 | ret = radio_hci_request(hdev, hci_def_data_read_req, (unsigned |
| 1394 | long)def_data_rd, RADIO_HCI_TIMEOUT); |
| 1395 | |
| 1396 | return ret; |
| 1397 | } |
| 1398 | |
| 1399 | int hci_def_data_write(struct hci_fm_def_data_wr_req *arg, |
| 1400 | struct radio_hci_dev *hdev) |
| 1401 | { |
| 1402 | int ret = 0; |
| 1403 | struct hci_fm_def_data_wr_req *def_data_wr = arg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1404 | ret = radio_hci_request(hdev, hci_def_data_write_req, (unsigned |
| 1405 | long)def_data_wr, RADIO_HCI_TIMEOUT); |
| 1406 | |
| 1407 | return ret; |
| 1408 | } |
| 1409 | |
| 1410 | int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev) |
| 1411 | { |
| 1412 | int ret = 0; |
| 1413 | __u8 mode = *arg; |
| 1414 | |
| 1415 | ret = radio_hci_request(hdev, hci_fm_do_calibration_req, mode, |
| 1416 | RADIO_HCI_TIMEOUT); |
| 1417 | |
| 1418 | return ret; |
| 1419 | } |
| 1420 | |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1421 | static int hci_read_grp_counters(__u8 *arg, struct radio_hci_dev *hdev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1422 | { |
| 1423 | int ret = 0; |
| 1424 | __u8 reset_counters = *arg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1425 | ret = radio_hci_request(hdev, hci_read_grp_counters_req, |
| 1426 | reset_counters, RADIO_HCI_TIMEOUT); |
| 1427 | |
| 1428 | return ret; |
| 1429 | } |
| 1430 | |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1431 | static int hci_set_notch_filter(__u8 *arg, struct radio_hci_dev *hdev) |
| 1432 | { |
| 1433 | int ret = 0; |
| 1434 | __u8 notch_filter = *arg; |
| 1435 | ret = radio_hci_request(hdev, hci_set_notch_filter_req, |
| 1436 | notch_filter, RADIO_HCI_TIMEOUT); |
| 1437 | |
| 1438 | return ret; |
| 1439 | } |
| 1440 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1441 | static int hci_peek_data(struct hci_fm_riva_data *arg, |
| 1442 | struct radio_hci_dev *hdev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1443 | { |
| 1444 | int ret = 0; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1445 | struct hci_fm_riva_data *peek_data = arg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1446 | |
| 1447 | ret = radio_hci_request(hdev, hci_peek_data_req, (unsigned |
| 1448 | long)peek_data, RADIO_HCI_TIMEOUT); |
| 1449 | |
| 1450 | return ret; |
| 1451 | } |
| 1452 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1453 | static int hci_poke_data(struct hci_fm_riva_poke *arg, |
| 1454 | struct radio_hci_dev *hdev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1455 | { |
| 1456 | int ret = 0; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1457 | struct hci_fm_riva_poke *poke_data = arg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1458 | |
| 1459 | ret = radio_hci_request(hdev, hci_poke_data_req, (unsigned |
| 1460 | long)poke_data, RADIO_HCI_TIMEOUT); |
| 1461 | |
| 1462 | return ret; |
| 1463 | } |
| 1464 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1465 | static int hci_ssbi_peek_reg(struct hci_fm_ssbi_peek *arg, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1466 | struct radio_hci_dev *hdev) |
| 1467 | { |
| 1468 | int ret = 0; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1469 | struct hci_fm_ssbi_peek *ssbi_peek_reg = arg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1470 | |
| 1471 | ret = radio_hci_request(hdev, hci_ssbi_peek_reg_req, (unsigned |
| 1472 | long)ssbi_peek_reg, RADIO_HCI_TIMEOUT); |
| 1473 | |
| 1474 | return ret; |
| 1475 | } |
| 1476 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1477 | static int hci_ssbi_poke_reg(struct hci_fm_ssbi_req *arg, |
| 1478 | struct radio_hci_dev *hdev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1479 | { |
| 1480 | int ret = 0; |
| 1481 | struct hci_fm_ssbi_req *ssbi_poke_reg = arg; |
| 1482 | |
| 1483 | ret = radio_hci_request(hdev, hci_ssbi_poke_reg_req, (unsigned |
| 1484 | long)ssbi_poke_reg, RADIO_HCI_TIMEOUT); |
| 1485 | |
| 1486 | return ret; |
| 1487 | } |
| 1488 | |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 1489 | static int hci_set_ch_det_thresholds_req(struct hci_fm_ch_det_threshold *arg, |
| 1490 | struct radio_hci_dev *hdev) |
| 1491 | { |
| 1492 | int ret = 0; |
| 1493 | struct hci_fm_ch_det_threshold *ch_det_threshold = arg; |
| 1494 | ret = radio_hci_request(hdev, hci_fm_set_ch_det_th, |
| 1495 | (unsigned long)ch_det_threshold, RADIO_HCI_TIMEOUT); |
| 1496 | return ret; |
| 1497 | } |
| 1498 | |
Venkateshwarlu Domakonda | 3a0b75d | 2011-11-23 17:03:27 +0530 | [diff] [blame] | 1499 | static int hci_fm_set_cal_req_proc(struct radio_hci_dev *hdev, |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 1500 | unsigned long param) |
| 1501 | { |
| 1502 | u16 opcode = 0; |
Venkateshwarlu Domakonda | 3a0b75d | 2011-11-23 17:03:27 +0530 | [diff] [blame] | 1503 | struct hci_fm_set_cal_req_proc *cal_req = |
| 1504 | (struct hci_fm_set_cal_req_proc *)param; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 1505 | |
| 1506 | opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, |
| 1507 | HCI_OCF_FM_SET_CALIBRATION); |
Venkateshwarlu Domakonda | 3a0b75d | 2011-11-23 17:03:27 +0530 | [diff] [blame] | 1508 | return radio_hci_send_cmd(hdev, opcode, sizeof(*cal_req), |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 1509 | cal_req); |
Venkateshwarlu Domakonda | 3a0b75d | 2011-11-23 17:03:27 +0530 | [diff] [blame] | 1510 | } |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 1511 | |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 1512 | static int hci_fm_do_cal_req(struct radio_hci_dev *hdev, |
| 1513 | unsigned long param) |
| 1514 | { |
| 1515 | u16 opcode = 0; |
| 1516 | u8 cal_mode = param; |
| 1517 | |
| 1518 | opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, |
| 1519 | HCI_OCF_FM_DO_CALIBRATION); |
| 1520 | return radio_hci_send_cmd(hdev, opcode, sizeof(cal_mode), |
| 1521 | &cal_mode); |
| 1522 | |
| 1523 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1524 | static int hci_cmd(unsigned int cmd, struct radio_hci_dev *hdev) |
| 1525 | { |
| 1526 | int ret = 0; |
| 1527 | unsigned long arg = 0; |
| 1528 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 1529 | if (!hdev) |
| 1530 | return -ENODEV; |
| 1531 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1532 | switch (cmd) { |
| 1533 | case HCI_FM_ENABLE_RECV_CMD: |
| 1534 | ret = radio_hci_request(hdev, hci_fm_enable_recv_req, arg, |
| 1535 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1536 | break; |
| 1537 | |
| 1538 | case HCI_FM_DISABLE_RECV_CMD: |
| 1539 | ret = radio_hci_request(hdev, hci_fm_disable_recv_req, arg, |
| 1540 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1541 | break; |
| 1542 | |
| 1543 | case HCI_FM_GET_RECV_CONF_CMD: |
| 1544 | ret = radio_hci_request(hdev, hci_get_fm_recv_conf_req, arg, |
| 1545 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1546 | break; |
| 1547 | |
| 1548 | case HCI_FM_GET_STATION_PARAM_CMD: |
| 1549 | ret = radio_hci_request(hdev, |
| 1550 | hci_fm_get_station_param_req, arg, |
| 1551 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1552 | break; |
| 1553 | |
| 1554 | case HCI_FM_GET_SIGNAL_TH_CMD: |
| 1555 | ret = radio_hci_request(hdev, |
| 1556 | hci_fm_get_sig_threshold_req, arg, |
| 1557 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1558 | break; |
| 1559 | |
| 1560 | case HCI_FM_GET_PROGRAM_SERVICE_CMD: |
| 1561 | ret = radio_hci_request(hdev, |
| 1562 | hci_fm_get_program_service_req, arg, |
| 1563 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1564 | break; |
| 1565 | |
| 1566 | case HCI_FM_GET_RADIO_TEXT_CMD: |
| 1567 | ret = radio_hci_request(hdev, hci_fm_get_radio_text_req, arg, |
| 1568 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1569 | break; |
| 1570 | |
| 1571 | case HCI_FM_GET_AF_LIST_CMD: |
| 1572 | ret = radio_hci_request(hdev, hci_fm_get_af_list_req, arg, |
| 1573 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1574 | break; |
| 1575 | |
| 1576 | case HCI_FM_CANCEL_SEARCH_CMD: |
| 1577 | ret = radio_hci_request(hdev, hci_fm_cancel_search_req, arg, |
| 1578 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1579 | break; |
| 1580 | |
| 1581 | case HCI_FM_RESET_CMD: |
| 1582 | ret = radio_hci_request(hdev, hci_fm_reset_req, arg, |
| 1583 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1584 | break; |
| 1585 | |
| 1586 | case HCI_FM_GET_FEATURES_CMD: |
| 1587 | ret = radio_hci_request(hdev, |
| 1588 | hci_fm_get_feature_lists_req, arg, |
| 1589 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1590 | break; |
| 1591 | |
| 1592 | case HCI_FM_STATION_DBG_PARAM_CMD: |
| 1593 | ret = radio_hci_request(hdev, |
| 1594 | hci_fm_get_station_dbg_param_req, arg, |
| 1595 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1596 | break; |
| 1597 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 1598 | case HCI_FM_ENABLE_TRANS_CMD: |
| 1599 | ret = radio_hci_request(hdev, hci_fm_enable_trans_req, arg, |
| 1600 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1601 | break; |
| 1602 | |
| 1603 | case HCI_FM_DISABLE_TRANS_CMD: |
| 1604 | ret = radio_hci_request(hdev, hci_fm_disable_trans_req, arg, |
| 1605 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1606 | break; |
| 1607 | |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 1608 | case HCI_FM_GET_TX_CONFIG: |
| 1609 | ret = radio_hci_request(hdev, hci_get_fm_trans_conf_req, arg, |
| 1610 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1611 | break; |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 1612 | case HCI_FM_GET_DET_CH_TH_CMD: |
| 1613 | ret = radio_hci_request(hdev, hci_fm_get_ch_det_th, arg, |
| 1614 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
| 1615 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1616 | default: |
| 1617 | ret = -EINVAL; |
| 1618 | break; |
| 1619 | } |
| 1620 | |
| 1621 | return ret; |
| 1622 | } |
| 1623 | |
| 1624 | static void radio_hci_req_complete(struct radio_hci_dev *hdev, int result) |
| 1625 | { |
| 1626 | hdev->req_result = result; |
| 1627 | hdev->req_status = HCI_REQ_DONE; |
| 1628 | wake_up_interruptible(&hdev->req_wait_q); |
| 1629 | } |
| 1630 | |
| 1631 | static void radio_hci_status_complete(struct radio_hci_dev *hdev, int result) |
| 1632 | { |
| 1633 | hdev->req_result = result; |
| 1634 | hdev->req_status = HCI_REQ_STATUS; |
| 1635 | wake_up_interruptible(&hdev->req_wait_q); |
| 1636 | } |
| 1637 | |
| 1638 | static void hci_cc_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb) |
| 1639 | { |
| 1640 | __u8 status = *((__u8 *) skb->data); |
| 1641 | |
| 1642 | if (status) |
| 1643 | return; |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 1644 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1645 | radio_hci_req_complete(hdev, status); |
| 1646 | } |
| 1647 | |
| 1648 | static void hci_cc_fm_disable_rsp(struct radio_hci_dev *hdev, |
| 1649 | struct sk_buff *skb) |
| 1650 | { |
| 1651 | __u8 status = *((__u8 *) skb->data); |
| 1652 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1653 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1654 | if (radio == NULL) { |
| 1655 | FMDERR(":radio is null"); |
| 1656 | return; |
| 1657 | } |
| 1658 | |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 1659 | if ((radio->mode == FM_TURNING_OFF) && (status == 0)) { |
Ayaz Ahmad | c1e6a95 | 2012-05-15 19:29:54 +0530 | [diff] [blame] | 1660 | iris_q_event(radio, IRIS_EVT_RADIO_DISABLED); |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 1661 | radio_hci_req_complete(hdev, status); |
| 1662 | radio->mode = FM_OFF; |
| 1663 | } else if (radio->mode == FM_CALIB) { |
| 1664 | radio_hci_req_complete(hdev, status); |
| 1665 | } else if ((radio->mode == FM_RECV) || (radio->mode == FM_TRANS)) { |
| 1666 | iris_q_event(radio, IRIS_EVT_RADIO_DISABLED); |
| 1667 | radio->mode = FM_OFF; |
| 1668 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1669 | } |
| 1670 | |
| 1671 | static void hci_cc_conf_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb) |
| 1672 | { |
| 1673 | struct hci_fm_conf_rsp *rsp = (void *)skb->data; |
| 1674 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1675 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1676 | if (radio == NULL) { |
| 1677 | FMDERR(":radio is null"); |
| 1678 | return; |
| 1679 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1680 | if (rsp->status) |
| 1681 | return; |
| 1682 | |
| 1683 | radio->recv_conf = rsp->recv_conf_rsp; |
| 1684 | radio_hci_req_complete(hdev, rsp->status); |
| 1685 | } |
| 1686 | |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 1687 | static void hci_cc_fm_trans_get_conf_rsp(struct radio_hci_dev *hdev, |
| 1688 | struct sk_buff *skb) |
| 1689 | { |
| 1690 | struct hci_fm_get_trans_conf_rsp *rsp = (void *)skb->data; |
| 1691 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1692 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1693 | if (radio == NULL) { |
| 1694 | FMDERR(":radio is null"); |
| 1695 | return; |
| 1696 | } |
| 1697 | |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 1698 | if (rsp->status) |
| 1699 | return; |
| 1700 | memcpy((void *)&radio->trans_conf, (void*)&rsp->trans_conf_rsp, |
| 1701 | sizeof(rsp->trans_conf_rsp)); |
| 1702 | radio_hci_req_complete(hdev, rsp->status); |
| 1703 | } |
| 1704 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1705 | static void hci_cc_fm_enable_rsp(struct radio_hci_dev *hdev, |
| 1706 | struct sk_buff *skb) |
| 1707 | { |
| 1708 | struct hci_fm_conf_rsp *rsp = (void *)skb->data; |
| 1709 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1710 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1711 | if (radio == NULL) { |
| 1712 | FMDERR(":radio is null"); |
| 1713 | return; |
| 1714 | } |
| 1715 | |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 1716 | if (rsp->status) { |
| 1717 | radio_hci_req_complete(hdev, rsp->status); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1718 | return; |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 1719 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1720 | |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 1721 | if (radio->mode == FM_RECV_TURNING_ON) { |
| 1722 | radio->mode = FM_RECV; |
| 1723 | iris_q_event(radio, IRIS_EVT_RADIO_READY); |
| 1724 | } else if (radio->mode == FM_TRANS_TURNING_ON) { |
| 1725 | radio->mode = FM_TRANS; |
| 1726 | iris_q_event(radio, IRIS_EVT_RADIO_READY); |
| 1727 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1728 | radio_hci_req_complete(hdev, rsp->status); |
| 1729 | } |
| 1730 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 1731 | |
| 1732 | static void hci_cc_fm_trans_set_conf_rsp(struct radio_hci_dev *hdev, |
| 1733 | struct sk_buff *skb) |
| 1734 | { |
| 1735 | struct hci_fm_conf_rsp *rsp = (void *)skb->data; |
| 1736 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1737 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1738 | if (radio == NULL) { |
| 1739 | FMDERR(":radio is null"); |
| 1740 | return; |
| 1741 | } |
| 1742 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 1743 | if (rsp->status) |
| 1744 | return; |
| 1745 | |
| 1746 | iris_q_event(radio, HCI_EV_CMD_COMPLETE); |
| 1747 | |
| 1748 | radio_hci_req_complete(hdev, rsp->status); |
| 1749 | } |
| 1750 | |
| 1751 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1752 | static void hci_cc_sig_threshold_rsp(struct radio_hci_dev *hdev, |
| 1753 | struct sk_buff *skb) |
| 1754 | { |
| 1755 | struct hci_fm_sig_threshold_rsp *rsp = (void *)skb->data; |
| 1756 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1757 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1758 | if (radio == NULL) { |
| 1759 | FMDERR(":radio is null"); |
| 1760 | return; |
| 1761 | } |
| 1762 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1763 | if (rsp->status) |
| 1764 | return; |
| 1765 | |
Venkateshwarlu Domakonda | 3d1d6e4 | 2011-12-09 15:08:58 +0530 | [diff] [blame] | 1766 | memcpy(&radio->sig_th, rsp, sizeof(struct hci_fm_sig_threshold_rsp)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1767 | radio_hci_req_complete(hdev, rsp->status); |
| 1768 | } |
| 1769 | |
| 1770 | static void hci_cc_station_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb) |
| 1771 | { |
| 1772 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1773 | struct hci_fm_station_rsp *rsp = (void *)skb->data; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1774 | |
| 1775 | if (radio == NULL) { |
| 1776 | FMDERR(":radio is null"); |
| 1777 | return; |
| 1778 | } |
| 1779 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1780 | radio->fm_st_rsp = *(rsp); |
| 1781 | |
| 1782 | /* Tune is always succesful */ |
| 1783 | radio_hci_req_complete(hdev, 0); |
| 1784 | } |
| 1785 | |
| 1786 | static void hci_cc_prg_srv_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb) |
| 1787 | { |
| 1788 | struct hci_fm_prgm_srv_rsp *rsp = (void *)skb->data; |
| 1789 | |
| 1790 | if (rsp->status) |
| 1791 | return; |
| 1792 | |
| 1793 | radio_hci_req_complete(hdev, rsp->status); |
| 1794 | } |
| 1795 | |
| 1796 | static void hci_cc_rd_txt_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb) |
| 1797 | { |
| 1798 | struct hci_fm_radio_txt_rsp *rsp = (void *)skb->data; |
| 1799 | |
| 1800 | if (rsp->status) |
| 1801 | return; |
| 1802 | |
| 1803 | radio_hci_req_complete(hdev, rsp->status); |
| 1804 | } |
| 1805 | |
| 1806 | static void hci_cc_af_list_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb) |
| 1807 | { |
| 1808 | struct hci_fm_af_list_rsp *rsp = (void *)skb->data; |
| 1809 | |
| 1810 | if (rsp->status) |
| 1811 | return; |
| 1812 | |
| 1813 | radio_hci_req_complete(hdev, rsp->status); |
| 1814 | } |
| 1815 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1816 | static void hci_cc_feature_list_rsp(struct radio_hci_dev *hdev, |
| 1817 | struct sk_buff *skb) |
| 1818 | { |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1819 | struct v4l2_capability *v4l_cap; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1820 | struct hci_fm_feature_list_rsp *rsp = (void *)skb->data; |
| 1821 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1822 | |
| 1823 | if (radio == NULL) { |
| 1824 | FMDERR(":radio is null"); |
| 1825 | return; |
| 1826 | } |
| 1827 | |
| 1828 | v4l_cap = radio->g_cap; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1829 | |
| 1830 | if (rsp->status) |
| 1831 | return; |
| 1832 | v4l_cap->capabilities = (rsp->feature_mask & 0x000002) | |
| 1833 | (rsp->feature_mask & 0x000001); |
| 1834 | |
| 1835 | radio_hci_req_complete(hdev, rsp->status); |
| 1836 | } |
| 1837 | |
| 1838 | static void hci_cc_dbg_param_rsp(struct radio_hci_dev *hdev, |
| 1839 | struct sk_buff *skb) |
| 1840 | { |
| 1841 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1842 | struct hci_fm_dbg_param_rsp *rsp = (void *)skb->data; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1843 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1844 | if (radio == NULL) { |
| 1845 | FMDERR(":radio is null"); |
| 1846 | return; |
| 1847 | } |
| 1848 | |
| 1849 | radio->st_dbg_param = *(rsp); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1850 | if (radio->st_dbg_param.status) |
| 1851 | return; |
| 1852 | |
| 1853 | radio_hci_req_complete(hdev, radio->st_dbg_param.status); |
| 1854 | } |
| 1855 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1856 | static void iris_q_evt_data(struct iris_device *radio, |
| 1857 | char *data, int len, int event) |
| 1858 | { |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1859 | struct kfifo *data_b; |
| 1860 | |
| 1861 | if (radio == NULL) { |
| 1862 | FMDERR(":radio is null"); |
| 1863 | return; |
| 1864 | } |
| 1865 | data_b = &radio->data_buf[event]; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1866 | if (kfifo_in_locked(data_b, data, len, &radio->buf_lock[event])) |
| 1867 | wake_up_interruptible(&radio->event_queue); |
| 1868 | } |
| 1869 | |
| 1870 | static void hci_cc_riva_peek_rsp(struct radio_hci_dev *hdev, |
| 1871 | struct sk_buff *skb) |
| 1872 | { |
| 1873 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1874 | __u8 status = *((__u8 *) skb->data); |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1875 | int len; |
| 1876 | char *data; |
| 1877 | |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1878 | if (status) |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1879 | return; |
| 1880 | len = skb->data[RIVA_PEEK_LEN_OFSET] + RIVA_PEEK_PARAM; |
| 1881 | data = kmalloc(len, GFP_ATOMIC); |
| 1882 | |
| 1883 | if (!data) { |
| 1884 | FMDERR("Memory allocation failed"); |
| 1885 | return; |
| 1886 | } |
| 1887 | |
| 1888 | memcpy(data, &skb->data[PEEK_DATA_OFSET], len); |
| 1889 | iris_q_evt_data(radio, data, len, IRIS_BUF_PEEK); |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1890 | radio_hci_req_complete(hdev, status); |
Priyanka Vunnam | bab6b7e | 2011-11-01 15:41:54 +0530 | [diff] [blame] | 1891 | kfree(data); |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1892 | |
| 1893 | } |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 1894 | |
| 1895 | static void hci_cc_riva_read_default_rsp(struct radio_hci_dev *hdev, |
| 1896 | struct sk_buff *skb) |
| 1897 | { |
| 1898 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1899 | __u8 status = *((__u8 *) skb->data); |
| 1900 | __u8 len; |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 1901 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1902 | if (radio == NULL) { |
| 1903 | FMDERR(":radio is null"); |
| 1904 | return; |
| 1905 | } |
| 1906 | |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 1907 | if (status) |
| 1908 | return; |
| 1909 | len = skb->data[1]; |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 1910 | |
Venkateshwarlu Domakonda | 71731d5 | 2012-04-04 12:30:51 +0530 | [diff] [blame] | 1911 | memset(&radio->default_data, 0 , sizeof(struct hci_fm_data_rd_rsp)); |
| 1912 | memcpy(&radio->default_data, &skb->data[0], len+2); |
| 1913 | iris_q_evt_data(radio, &skb->data[0], len+2, IRIS_BUF_RD_DEFAULT); |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 1914 | radio_hci_req_complete(hdev, status); |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 1915 | } |
| 1916 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1917 | static void hci_cc_ssbi_peek_rsp(struct radio_hci_dev *hdev, |
| 1918 | struct sk_buff *skb) |
| 1919 | { |
| 1920 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1921 | __u8 status = *((__u8 *) skb->data); |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1922 | char *data; |
| 1923 | |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1924 | if (status) |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1925 | return; |
| 1926 | data = kmalloc(SSBI_PEEK_LEN, GFP_ATOMIC); |
| 1927 | if (!data) { |
| 1928 | FMDERR("Memory allocation failed"); |
| 1929 | return; |
| 1930 | } |
| 1931 | |
| 1932 | data[0] = skb->data[PEEK_DATA_OFSET]; |
| 1933 | iris_q_evt_data(radio, data, SSBI_PEEK_LEN, IRIS_BUF_SSBI_PEEK); |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1934 | radio_hci_req_complete(hdev, status); |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 1935 | kfree(data); |
| 1936 | } |
| 1937 | |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 1938 | static void hci_cc_rds_grp_cntrs_rsp(struct radio_hci_dev *hdev, |
| 1939 | struct sk_buff *skb) |
| 1940 | { |
| 1941 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1942 | __u8 status = *((__u8 *) skb->data); |
| 1943 | char *data; |
| 1944 | if (status) |
| 1945 | return; |
| 1946 | data = kmalloc(RDS_GRP_CNTR_LEN, GFP_ATOMIC); |
| 1947 | if (!data) { |
| 1948 | FMDERR("memory allocation failed"); |
| 1949 | return; |
| 1950 | } |
| 1951 | memcpy(data, &skb->data[1], RDS_GRP_CNTR_LEN); |
| 1952 | iris_q_evt_data(radio, data, RDS_GRP_CNTR_LEN, IRIS_BUF_RDS_CNTRS); |
| 1953 | radio_hci_req_complete(hdev, status); |
| 1954 | kfree(data); |
| 1955 | |
| 1956 | } |
| 1957 | |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 1958 | static void hci_cc_do_calibration_rsp(struct radio_hci_dev *hdev, |
| 1959 | struct sk_buff *skb) |
| 1960 | { |
| 1961 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1962 | static struct hci_cc_do_calibration_rsp rsp ; |
| 1963 | rsp.status = skb->data[0]; |
| 1964 | rsp.mode = skb->data[CALIB_MODE_OFSET]; |
| 1965 | |
| 1966 | if (rsp.status) { |
| 1967 | FMDERR("status = %d", rsp.status); |
| 1968 | return; |
| 1969 | } |
| 1970 | if (rsp.mode == PROCS_CALIB_MODE) { |
| 1971 | memcpy(&rsp.data[0], &skb->data[CALIB_DATA_OFSET], |
| 1972 | PROCS_CALIB_SIZE); |
Venkateshwarlu Domakonda | 5e96e69 | 2011-12-05 17:36:06 +0530 | [diff] [blame] | 1973 | iris_q_evt_data(radio, rsp.data, PROCS_CALIB_SIZE, |
| 1974 | IRIS_BUF_CAL_DATA); |
| 1975 | } else { |
| 1976 | return; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 1977 | } |
Venkateshwarlu Domakonda | 5e96e69 | 2011-12-05 17:36:06 +0530 | [diff] [blame] | 1978 | |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 1979 | radio_hci_req_complete(hdev, rsp.status); |
| 1980 | } |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 1981 | |
| 1982 | static void hci_cc_get_ch_det_threshold_rsp(struct radio_hci_dev *hdev, |
| 1983 | struct sk_buff *skb) |
| 1984 | { |
| 1985 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 1986 | u8 status = skb->data[0]; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 1987 | |
| 1988 | if (radio == NULL) { |
| 1989 | FMDERR(":radio is null"); |
| 1990 | return; |
| 1991 | } |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 1992 | if (status) { |
| 1993 | FMDERR("status = %d", status); |
| 1994 | return; |
| 1995 | } |
| 1996 | memcpy(&radio->ch_det_threshold, &skb->data[1], |
| 1997 | sizeof(struct hci_fm_ch_det_threshold)); |
| 1998 | radio_hci_req_complete(hdev, status); |
| 1999 | } |
| 2000 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2001 | static inline void hci_cmd_complete_event(struct radio_hci_dev *hdev, |
| 2002 | struct sk_buff *skb) |
| 2003 | { |
| 2004 | struct hci_ev_cmd_complete *cmd_compl_ev = (void *) skb->data; |
| 2005 | __u16 opcode; |
| 2006 | |
| 2007 | skb_pull(skb, sizeof(*cmd_compl_ev)); |
| 2008 | |
| 2009 | opcode = __le16_to_cpu(cmd_compl_ev->cmd_opcode); |
| 2010 | |
| 2011 | switch (opcode) { |
| 2012 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_ENABLE_RECV_REQ): |
Ayaz Ahmad | 3dad651 | 2012-03-13 13:41:19 +0530 | [diff] [blame] | 2013 | case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_ENABLE_TRANS_REQ): |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2014 | hci_cc_fm_enable_rsp(hdev, skb); |
| 2015 | break; |
| 2016 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_RECV_CONF_REQ): |
| 2017 | hci_cc_conf_rsp(hdev, skb); |
| 2018 | break; |
| 2019 | |
| 2020 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_DISABLE_RECV_REQ): |
Ayaz Ahmad | 3dad651 | 2012-03-13 13:41:19 +0530 | [diff] [blame] | 2021 | case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_DISABLE_TRANS_REQ): |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2022 | hci_cc_fm_disable_rsp(hdev, skb); |
| 2023 | break; |
| 2024 | |
| 2025 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_RECV_CONF_REQ): |
| 2026 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_MUTE_MODE_REQ): |
| 2027 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_STEREO_MODE_REQ): |
| 2028 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_ANTENNA): |
| 2029 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_SIGNAL_THRESHOLD): |
| 2030 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_CANCEL_SEARCH): |
| 2031 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_RDS_GRP): |
| 2032 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_RDS_GRP_PROCESS): |
| 2033 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_EN_WAN_AVD_CTRL): |
| 2034 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_EN_NOTCH_CTRL): |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 2035 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_CH_DET_THRESHOLD): |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2036 | case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_RDS_RT_REQ): |
| 2037 | case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_RDS_PS_REQ): |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2038 | case hci_common_cmd_op_pack(HCI_OCF_FM_DEFAULT_DATA_WRITE): |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 2039 | hci_cc_rsp(hdev, skb); |
| 2040 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2041 | case hci_common_cmd_op_pack(HCI_OCF_FM_RESET): |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2042 | case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_SSBI_POKE_REG): |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 2043 | case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_POKE_DATA): |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2044 | case hci_diagnostic_cmd_op_pack(HCI_FM_SET_INTERNAL_TONE_GENRATOR): |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2045 | case hci_common_cmd_op_pack(HCI_OCF_FM_SET_CALIBRATION): |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 2046 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_EVENT_MASK): |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2047 | hci_cc_rsp(hdev, skb); |
| 2048 | break; |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 2049 | |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 2050 | case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_SSBI_PEEK_REG): |
| 2051 | hci_cc_ssbi_peek_rsp(hdev, skb); |
| 2052 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2053 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_SIGNAL_THRESHOLD): |
| 2054 | hci_cc_sig_threshold_rsp(hdev, skb); |
| 2055 | break; |
| 2056 | |
| 2057 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_STATION_PARAM_REQ): |
| 2058 | hci_cc_station_rsp(hdev, skb); |
| 2059 | break; |
| 2060 | |
| 2061 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ): |
| 2062 | hci_cc_prg_srv_rsp(hdev, skb); |
| 2063 | break; |
| 2064 | |
| 2065 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_RADIO_TEXT_REQ): |
| 2066 | hci_cc_rd_txt_rsp(hdev, skb); |
| 2067 | break; |
| 2068 | |
| 2069 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_AF_LIST_REQ): |
| 2070 | hci_cc_af_list_rsp(hdev, skb); |
| 2071 | break; |
| 2072 | |
| 2073 | case hci_common_cmd_op_pack(HCI_OCF_FM_DEFAULT_DATA_READ): |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 2074 | hci_cc_riva_read_default_rsp(hdev, skb); |
| 2075 | break; |
| 2076 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2077 | case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_PEEK_DATA): |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 2078 | hci_cc_riva_peek_rsp(hdev, skb); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2079 | break; |
| 2080 | |
| 2081 | case hci_common_cmd_op_pack(HCI_OCF_FM_GET_FEATURE_LIST): |
| 2082 | hci_cc_feature_list_rsp(hdev, skb); |
| 2083 | break; |
| 2084 | |
| 2085 | case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_STATION_DBG_PARAM): |
| 2086 | hci_cc_dbg_param_rsp(hdev, skb); |
| 2087 | break; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2088 | case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_SET_TRANS_CONF_REQ): |
| 2089 | hci_cc_fm_trans_set_conf_rsp(hdev, skb); |
| 2090 | break; |
| 2091 | |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 2092 | case hci_status_param_op_pack(HCI_OCF_FM_READ_GRP_COUNTERS): |
| 2093 | hci_cc_rds_grp_cntrs_rsp(hdev, skb); |
| 2094 | break; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2095 | case hci_common_cmd_op_pack(HCI_OCF_FM_DO_CALIBRATION): |
| 2096 | hci_cc_do_calibration_rsp(hdev, skb); |
| 2097 | break; |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 2098 | |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 2099 | case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_GET_TRANS_CONF_REQ): |
| 2100 | hci_cc_fm_trans_get_conf_rsp(hdev, skb); |
| 2101 | break; |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 2102 | case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_CH_DET_THRESHOLD): |
| 2103 | hci_cc_get_ch_det_threshold_rsp(hdev, skb); |
| 2104 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2105 | default: |
| 2106 | FMDERR("%s opcode 0x%x", hdev->name, opcode); |
| 2107 | break; |
| 2108 | } |
| 2109 | |
| 2110 | } |
| 2111 | |
| 2112 | static inline void hci_cmd_status_event(struct radio_hci_dev *hdev, |
| 2113 | struct sk_buff *skb) |
| 2114 | { |
| 2115 | struct hci_ev_cmd_status *ev = (void *) skb->data; |
| 2116 | radio_hci_status_complete(hdev, ev->status); |
| 2117 | } |
| 2118 | |
| 2119 | static inline void hci_ev_tune_status(struct radio_hci_dev *hdev, |
| 2120 | struct sk_buff *skb) |
| 2121 | { |
| 2122 | int i; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2123 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2124 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2125 | if (radio == NULL) { |
| 2126 | FMDERR(":radio is null"); |
| 2127 | return; |
| 2128 | } |
Venkateshwarlu Domakonda | 862492d | 2011-11-29 11:51:24 +0530 | [diff] [blame] | 2129 | memcpy(&radio->fm_st_rsp.station_rsp, &skb->data[0], |
| 2130 | sizeof(struct hci_ev_tune_status)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2131 | iris_q_event(radio, IRIS_EVT_TUNE_SUCC); |
| 2132 | |
| 2133 | for (i = 0; i < IRIS_BUF_MAX; i++) { |
| 2134 | if (i >= IRIS_BUF_RT_RDS) |
| 2135 | kfifo_reset(&radio->data_buf[i]); |
| 2136 | } |
Srinivasa Rao Uppala | acdebcc | 2011-12-23 14:31:38 +0530 | [diff] [blame] | 2137 | if (radio->fm_st_rsp.station_rsp.serv_avble) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2138 | iris_q_event(radio, IRIS_EVT_ABOVE_TH); |
| 2139 | else |
| 2140 | iris_q_event(radio, IRIS_EVT_BELOW_TH); |
| 2141 | |
| 2142 | if (radio->fm_st_rsp.station_rsp.stereo_prg) |
| 2143 | iris_q_event(radio, IRIS_EVT_STEREO); |
Ayaz Ahmad | a4b0d8e | 2013-09-02 15:18:23 +0530 | [diff] [blame] | 2144 | else if (radio->fm_st_rsp.station_rsp.stereo_prg == 0) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2145 | iris_q_event(radio, IRIS_EVT_MONO); |
| 2146 | |
| 2147 | if (radio->fm_st_rsp.station_rsp.rds_sync_status) |
| 2148 | iris_q_event(radio, IRIS_EVT_RDS_AVAIL); |
| 2149 | else |
| 2150 | iris_q_event(radio, IRIS_EVT_RDS_NOT_AVAIL); |
| 2151 | } |
| 2152 | |
| 2153 | static inline void hci_ev_search_compl(struct radio_hci_dev *hdev, |
| 2154 | struct sk_buff *skb) |
| 2155 | { |
| 2156 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2157 | iris_q_event(radio, IRIS_EVT_SEEK_COMPLETE); |
| 2158 | } |
| 2159 | |
| 2160 | static inline void hci_ev_srch_st_list_compl(struct radio_hci_dev *hdev, |
| 2161 | struct sk_buff *skb) |
| 2162 | { |
| 2163 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
Srinivasa Rao Uppala | 18fb80e | 2011-07-17 17:33:00 -0700 | [diff] [blame] | 2164 | struct hci_ev_srch_list_compl *ev ; |
| 2165 | int cnt; |
| 2166 | int stn_num; |
| 2167 | int rel_freq; |
| 2168 | int abs_freq; |
| 2169 | int len; |
| 2170 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2171 | if (radio == NULL) { |
| 2172 | FMDERR(":radio is null"); |
| 2173 | return; |
| 2174 | } |
Srinivasa Rao Uppala | 18fb80e | 2011-07-17 17:33:00 -0700 | [diff] [blame] | 2175 | ev = kmalloc(sizeof(*ev), GFP_ATOMIC); |
| 2176 | if (!ev) { |
| 2177 | FMDERR("Memory allocation failed"); |
| 2178 | return ; |
| 2179 | } |
| 2180 | |
| 2181 | ev->num_stations_found = skb->data[STN_NUM_OFFSET]; |
| 2182 | len = ev->num_stations_found * PARAMS_PER_STATION + STN_FREQ_OFFSET; |
| 2183 | |
| 2184 | for (cnt = STN_FREQ_OFFSET, stn_num = 0; |
Priyanka Vunnam | bab6b7e | 2011-11-01 15:41:54 +0530 | [diff] [blame] | 2185 | (cnt < len) && (stn_num < ev->num_stations_found) |
| 2186 | && (stn_num < ARRAY_SIZE(ev->rel_freq)); |
Srinivasa Rao Uppala | 18fb80e | 2011-07-17 17:33:00 -0700 | [diff] [blame] | 2187 | cnt += PARAMS_PER_STATION, stn_num++) { |
| 2188 | abs_freq = *((int *)&skb->data[cnt]); |
| 2189 | rel_freq = abs_freq - radio->recv_conf.band_low_limit; |
| 2190 | rel_freq = (rel_freq * 20) / KHZ_TO_MHZ; |
| 2191 | |
| 2192 | ev->rel_freq[stn_num].rel_freq_lsb = GET_LSB(rel_freq); |
| 2193 | ev->rel_freq[stn_num].rel_freq_msb = GET_MSB(rel_freq); |
| 2194 | } |
| 2195 | |
| 2196 | len = ev->num_stations_found * 2 + sizeof(ev->num_stations_found); |
| 2197 | iris_q_event(radio, IRIS_EVT_NEW_SRCH_LIST); |
| 2198 | iris_q_evt_data(radio, (char *)ev, len, IRIS_BUF_SRCH_LIST); |
| 2199 | kfree(ev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2200 | } |
| 2201 | |
| 2202 | static inline void hci_ev_search_next(struct radio_hci_dev *hdev, |
| 2203 | struct sk_buff *skb) |
| 2204 | { |
| 2205 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2206 | iris_q_event(radio, IRIS_EVT_SCAN_NEXT); |
| 2207 | } |
| 2208 | |
| 2209 | static inline void hci_ev_stereo_status(struct radio_hci_dev *hdev, |
| 2210 | struct sk_buff *skb) |
| 2211 | { |
| 2212 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2213 | __u8 st_status = *((__u8 *) skb->data); |
| 2214 | if (st_status) |
| 2215 | iris_q_event(radio, IRIS_EVT_STEREO); |
| 2216 | else |
| 2217 | iris_q_event(radio, IRIS_EVT_MONO); |
| 2218 | } |
| 2219 | |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 2220 | static void hci_ev_raw_rds_group_data(struct radio_hci_dev *hdev, |
| 2221 | struct sk_buff *skb) |
| 2222 | { |
| 2223 | struct iris_device *radio; |
| 2224 | unsigned char blocknum, index; |
| 2225 | struct rds_grp_data temp; |
| 2226 | unsigned int mask_bit; |
| 2227 | unsigned short int aid, agt, gtc; |
| 2228 | unsigned short int carrier; |
| 2229 | |
| 2230 | radio = video_get_drvdata(video_get_dev()); |
| 2231 | index = RDSGRP_DATA_OFFSET; |
| 2232 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2233 | if (radio == NULL) { |
| 2234 | FMDERR(":radio is null"); |
| 2235 | return; |
| 2236 | } |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 2237 | for (blocknum = 0; blocknum < RDS_BLOCKS_NUM; blocknum++) { |
| 2238 | temp.rdsBlk[blocknum].rdsLsb = |
| 2239 | (skb->data[index]); |
| 2240 | temp.rdsBlk[blocknum].rdsMsb = |
| 2241 | (skb->data[index+1]); |
| 2242 | index = index + 2; |
| 2243 | } |
| 2244 | |
| 2245 | aid = AID(temp.rdsBlk[3].rdsLsb, temp.rdsBlk[3].rdsMsb); |
| 2246 | gtc = GTC(temp.rdsBlk[1].rdsMsb); |
| 2247 | agt = AGT(temp.rdsBlk[1].rdsLsb); |
| 2248 | |
| 2249 | if (gtc == GRP_3A) { |
| 2250 | switch (aid) { |
| 2251 | case ERT_AID: |
| 2252 | /* calculate the grp mask for RDS grp |
| 2253 | * which will contain actual eRT text |
| 2254 | * |
| 2255 | * Bit Pos 0 1 2 3 4 5 6 7 |
| 2256 | * Grp Type 0A 0B 1A 1B 2A 2B 3A 3B |
| 2257 | * |
| 2258 | * similary for rest grps |
| 2259 | */ |
| 2260 | mask_bit = (((agt >> 1) << 1) + (agt & 1)); |
| 2261 | oda_agt = (1 << mask_bit); |
| 2262 | utf_8_flag = (temp.rdsBlk[2].rdsLsb & 1); |
| 2263 | formatting_dir = EXTRACT_BIT(temp.rdsBlk[2].rdsLsb, |
| 2264 | ERT_FORMAT_DIR_BIT); |
| 2265 | if (ert_carrier != agt) |
| 2266 | iris_q_event(radio, IRIS_EVT_NEW_ODA); |
| 2267 | ert_carrier = agt; |
| 2268 | break; |
| 2269 | case RT_PLUS_AID: |
| 2270 | /* calculate the grp mask for RDS grp |
| 2271 | * which will contain actual eRT text |
| 2272 | * |
| 2273 | * Bit Pos 0 1 2 3 4 5 6 7 |
| 2274 | * Grp Type 0A 0B 1A 1B 2A 2B 3A 3B |
| 2275 | * |
| 2276 | * similary for rest grps |
| 2277 | */ |
| 2278 | mask_bit = (((agt >> 1) << 1) + (agt & 1)); |
| 2279 | oda_agt = (1 << mask_bit); |
| 2280 | /*Extract 5th bit of MSB (b7b6b5b4b3b2b1b0)*/ |
| 2281 | rt_ert_flag = EXTRACT_BIT(temp.rdsBlk[2].rdsMsb, |
| 2282 | RT_ERT_FLAG_BIT); |
| 2283 | if (rt_plus_carrier != agt) |
| 2284 | iris_q_event(radio, IRIS_EVT_NEW_ODA); |
| 2285 | rt_plus_carrier = agt; |
| 2286 | break; |
| 2287 | default: |
| 2288 | oda_agt = 0; |
| 2289 | break; |
| 2290 | } |
| 2291 | } else { |
| 2292 | carrier = gtc; |
| 2293 | if ((carrier == rt_plus_carrier)) |
| 2294 | hci_ev_rt_plus(radio, temp); |
| 2295 | else if (carrier == ert_carrier) |
| 2296 | hci_buff_ert(radio, &temp); |
| 2297 | } |
| 2298 | } |
| 2299 | |
| 2300 | static void hci_buff_ert(struct iris_device *radio, |
| 2301 | struct rds_grp_data *rds_buf) |
| 2302 | { |
| 2303 | int i; |
| 2304 | unsigned short int info_byte = 0; |
| 2305 | unsigned short int byte_pair_index; |
| 2306 | |
| 2307 | byte_pair_index = AGT(rds_buf->rdsBlk[1].rdsLsb); |
| 2308 | if (byte_pair_index == 0) { |
| 2309 | c_byt_pair_index = 0; |
| 2310 | ert_len = 0; |
| 2311 | } |
| 2312 | if (c_byt_pair_index == byte_pair_index) { |
| 2313 | c_byt_pair_index++; |
| 2314 | for (i = 2; i <= 3; i++) { |
| 2315 | info_byte = rds_buf->rdsBlk[i].rdsLsb; |
| 2316 | info_byte |= (rds_buf->rdsBlk[i].rdsMsb << 8); |
| 2317 | ert_buf[ert_len++] = rds_buf->rdsBlk[i].rdsMsb; |
| 2318 | ert_buf[ert_len++] = rds_buf->rdsBlk[i].rdsLsb; |
| 2319 | if ((utf_8_flag == 0) |
| 2320 | && (info_byte == CARRIAGE_RETURN)) { |
| 2321 | ert_len -= 2; |
| 2322 | break; |
| 2323 | } else if ((utf_8_flag == 1) |
| 2324 | && |
| 2325 | (rds_buf->rdsBlk[i].rdsMsb |
| 2326 | == CARRIAGE_RETURN)) { |
| 2327 | info_byte = CARRIAGE_RETURN; |
| 2328 | ert_len -= 2; |
| 2329 | break; |
| 2330 | } else if ((utf_8_flag == 1) |
| 2331 | && |
| 2332 | (rds_buf->rdsBlk[i].rdsLsb |
| 2333 | == CARRIAGE_RETURN)) { |
| 2334 | info_byte = CARRIAGE_RETURN; |
| 2335 | ert_len--; |
| 2336 | break; |
| 2337 | } |
| 2338 | } |
| 2339 | if ((byte_pair_index == MAX_ERT_SEGMENT) || |
| 2340 | (info_byte == CARRIAGE_RETURN)) { |
| 2341 | hci_ev_ert(radio); |
| 2342 | c_byt_pair_index = 0; |
| 2343 | ert_len = 0; |
| 2344 | } |
| 2345 | } else { |
| 2346 | ert_len = 0; |
| 2347 | c_byt_pair_index = 0; |
| 2348 | } |
| 2349 | } |
| 2350 | static void hci_ev_ert(struct iris_device *radio) |
| 2351 | |
| 2352 | { |
| 2353 | char *data = NULL; |
| 2354 | |
| 2355 | if (ert_len <= 0) |
| 2356 | return; |
| 2357 | data = kmalloc((ert_len + 3), GFP_ATOMIC); |
| 2358 | if (data != NULL) { |
| 2359 | data[0] = ert_len; |
| 2360 | data[1] = utf_8_flag; |
| 2361 | data[2] = formatting_dir; |
| 2362 | memcpy((data + 3), ert_buf, ert_len); |
| 2363 | iris_q_evt_data(radio, data, (ert_len + 3), IRIS_BUF_ERT); |
| 2364 | iris_q_event(radio, IRIS_EVT_NEW_ERT); |
| 2365 | kfree(data); |
| 2366 | } |
| 2367 | } |
| 2368 | |
| 2369 | static void hci_ev_rt_plus(struct iris_device *radio, |
| 2370 | struct rds_grp_data rds_buf) |
| 2371 | { |
| 2372 | char tag_type1, tag_type2; |
| 2373 | char *data = NULL; |
| 2374 | int len = 0; |
| 2375 | unsigned short int agt; |
| 2376 | |
| 2377 | agt = AGT(rds_buf.rdsBlk[1].rdsLsb); |
| 2378 | /*right most 3 bits of Lsb of block 2 |
| 2379 | * and left most 3 bits of Msb of block 3 |
| 2380 | */ |
| 2381 | tag_type1 = (((agt & TAG1_MSB_MASK) << TAG1_MSB_OFFSET) | |
| 2382 | (rds_buf.rdsBlk[2].rdsMsb >> TAG1_LSB_OFFSET)); |
| 2383 | |
| 2384 | /*right most 1 bit of lsb of 3rd block |
| 2385 | * and left most 5 bits of Msb of 4th block |
| 2386 | */ |
| 2387 | tag_type2 = (((rds_buf.rdsBlk[2].rdsLsb & TAG2_MSB_MASK) |
| 2388 | << TAG2_MSB_OFFSET) | |
| 2389 | (rds_buf.rdsBlk[3].rdsMsb >> TAG2_LSB_OFFSET)); |
| 2390 | |
| 2391 | if (tag_type1 != DUMMY_CLASS) |
| 2392 | len += RT_PLUS_LEN_1_TAG; |
| 2393 | if (tag_type2 != DUMMY_CLASS) |
| 2394 | len += RT_PLUS_LEN_1_TAG; |
| 2395 | |
| 2396 | if (len != 0) { |
| 2397 | len += 2; |
| 2398 | data = kmalloc(len, GFP_ATOMIC); |
| 2399 | } else { |
| 2400 | FMDERR("Len is zero\n"); |
| 2401 | return ; |
| 2402 | } |
| 2403 | if (data != NULL) { |
| 2404 | data[0] = len; |
| 2405 | len = 1; |
| 2406 | data[len++] = rt_ert_flag; |
| 2407 | if (tag_type1 != DUMMY_CLASS) { |
| 2408 | data[len++] = tag_type1; |
| 2409 | /*start position of tag1 |
| 2410 | *right most 5 bits of msb of 3rd block |
| 2411 | *and left most bit of lsb of 3rd block |
| 2412 | */ |
| 2413 | data[len++] = (((rds_buf.rdsBlk[2].rdsMsb & |
| 2414 | TAG1_POS_MSB_MASK) |
| 2415 | << TAG1_POS_MSB_OFFSET) |
| 2416 | | |
| 2417 | (rds_buf.rdsBlk[2].rdsLsb >> |
| 2418 | TAG1_POS_LSB_OFFSET)); |
| 2419 | /*length of tag1 |
| 2420 | *left most 6 bits of lsb of 3rd block |
| 2421 | */ |
| 2422 | data[len++] = ((rds_buf.rdsBlk[2].rdsLsb |
| 2423 | >> TAG1_LEN_OFFSET) |
| 2424 | & |
| 2425 | TAG1_LEN_MASK) + 1; |
| 2426 | } |
| 2427 | if (tag_type2 != DUMMY_CLASS) { |
| 2428 | data[len++] = tag_type2; |
| 2429 | /*start position of tag2 |
| 2430 | *right most 3 bit of msb of 4th block |
| 2431 | *and left most 3 bits of lsb of 4th block |
| 2432 | */ |
| 2433 | data[len++] = (((rds_buf.rdsBlk[3].rdsMsb |
| 2434 | & TAG2_POS_MSB_MASK) |
| 2435 | << TAG2_POS_MSB_OFFSET) |
| 2436 | | |
| 2437 | (rds_buf.rdsBlk[3].rdsLsb |
| 2438 | >> TAG2_POS_LSB_OFFSET)); |
| 2439 | /*length of tag2 |
| 2440 | *right most 5 bits of lsb of 4th block |
| 2441 | */ |
| 2442 | data[len++] = (rds_buf.rdsBlk[3].rdsLsb |
| 2443 | & TAG2_LEN_MASK) + 1; |
| 2444 | } |
| 2445 | iris_q_evt_data(radio, data, len, IRIS_BUF_RT_PLUS); |
| 2446 | iris_q_event(radio, IRIS_EVT_NEW_RT_PLUS); |
| 2447 | kfree(data); |
| 2448 | } else { |
| 2449 | FMDERR("memory allocation failed\n"); |
| 2450 | } |
| 2451 | } |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2452 | |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2453 | static inline void hci_ev_program_service(struct radio_hci_dev *hdev, |
| 2454 | struct sk_buff *skb) |
| 2455 | { |
| 2456 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2457 | int len; |
| 2458 | char *data; |
| 2459 | |
| 2460 | len = (skb->data[RDS_PS_LENGTH_OFFSET] * RDS_STRING) + RDS_OFFSET; |
| 2461 | iris_q_event(radio, IRIS_EVT_NEW_PS_RDS); |
| 2462 | data = kmalloc(len, GFP_ATOMIC); |
| 2463 | if (!data) { |
| 2464 | FMDERR("Failed to allocate memory"); |
| 2465 | return; |
| 2466 | } |
| 2467 | |
| 2468 | data[0] = skb->data[RDS_PS_LENGTH_OFFSET]; |
| 2469 | data[1] = skb->data[RDS_PTYPE]; |
| 2470 | data[2] = skb->data[RDS_PID_LOWER]; |
| 2471 | data[3] = skb->data[RDS_PID_HIGHER]; |
| 2472 | data[4] = 0; |
| 2473 | |
| 2474 | memcpy(data+RDS_OFFSET, &skb->data[RDS_PS_DATA_OFFSET], len-RDS_OFFSET); |
| 2475 | |
Srinivasa Rao Uppala | 18fb80e | 2011-07-17 17:33:00 -0700 | [diff] [blame] | 2476 | iris_q_evt_data(radio, data, len, IRIS_BUF_PS_RDS); |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2477 | |
| 2478 | kfree(data); |
| 2479 | } |
| 2480 | |
| 2481 | |
| 2482 | static inline void hci_ev_radio_text(struct radio_hci_dev *hdev, |
| 2483 | struct sk_buff *skb) |
| 2484 | { |
| 2485 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2486 | int len = 0; |
| 2487 | char *data; |
| 2488 | |
| 2489 | iris_q_event(radio, IRIS_EVT_NEW_RT_RDS); |
| 2490 | |
Ayaz Ahmad | e4a0c17 | 2013-06-27 17:32:30 +0530 | [diff] [blame] | 2491 | while ((skb->data[len+RDS_OFFSET] != 0x0d) && (len < MAX_RT_LENGTH)) |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2492 | len++; |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2493 | data = kmalloc(len+RDS_OFFSET, GFP_ATOMIC); |
| 2494 | if (!data) { |
| 2495 | FMDERR("Failed to allocate memory"); |
| 2496 | return; |
| 2497 | } |
| 2498 | |
| 2499 | data[0] = len; |
| 2500 | data[1] = skb->data[RDS_PTYPE]; |
| 2501 | data[2] = skb->data[RDS_PID_LOWER]; |
| 2502 | data[3] = skb->data[RDS_PID_HIGHER]; |
Ayaz Ahmad | e4a0c17 | 2013-06-27 17:32:30 +0530 | [diff] [blame] | 2503 | data[4] = skb->data[RT_A_B_FLAG_OFFSET]; |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2504 | |
| 2505 | memcpy(data+RDS_OFFSET, &skb->data[RDS_OFFSET], len); |
| 2506 | data[len+RDS_OFFSET] = 0x00; |
| 2507 | |
Srinivasa Rao Uppala | 18fb80e | 2011-07-17 17:33:00 -0700 | [diff] [blame] | 2508 | iris_q_evt_data(radio, data, len+RDS_OFFSET, IRIS_BUF_RT_RDS); |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2509 | |
| 2510 | kfree(data); |
| 2511 | } |
| 2512 | |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2513 | static void hci_ev_af_list(struct radio_hci_dev *hdev, |
| 2514 | struct sk_buff *skb) |
| 2515 | { |
| 2516 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2517 | struct hci_ev_af_list ev; |
| 2518 | |
| 2519 | ev.tune_freq = *((int *) &skb->data[0]); |
| 2520 | ev.pi_code = *((__le16 *) &skb->data[PI_CODE_OFFSET]); |
| 2521 | ev.af_size = skb->data[AF_SIZE_OFFSET]; |
Venkateshwarlu Domakonda | e8a4187c | 2013-06-25 18:56:54 +0530 | [diff] [blame] | 2522 | if (ev.af_size > AF_LIST_MAX) { |
| 2523 | FMDERR("AF list size received more than available size"); |
| 2524 | return; |
| 2525 | } |
Venkateshwarlu Domakonda | cc705e3 | 2013-07-15 18:08:06 +0530 | [diff] [blame] | 2526 | memcpy(&ev.af_list[0], &skb->data[AF_LIST_OFFSET], |
| 2527 | ev.af_size * sizeof(int)); |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2528 | iris_q_event(radio, IRIS_EVT_NEW_AF_LIST); |
Venkateshwarlu Domakonda | cc705e3 | 2013-07-15 18:08:06 +0530 | [diff] [blame] | 2529 | iris_q_evt_data(radio, (char *)&ev, (7 + ev.af_size * sizeof(int)), |
| 2530 | IRIS_BUF_AF_LIST); |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2531 | } |
| 2532 | |
| 2533 | static void hci_ev_rds_lock_status(struct radio_hci_dev *hdev, |
| 2534 | struct sk_buff *skb) |
| 2535 | { |
| 2536 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2537 | __u8 rds_status = skb->data[0]; |
| 2538 | |
| 2539 | if (rds_status) |
| 2540 | iris_q_event(radio, IRIS_EVT_RDS_AVAIL); |
| 2541 | else |
| 2542 | iris_q_event(radio, IRIS_EVT_RDS_NOT_AVAIL); |
| 2543 | } |
| 2544 | |
| 2545 | static void hci_ev_service_available(struct radio_hci_dev *hdev, |
| 2546 | struct sk_buff *skb) |
| 2547 | { |
| 2548 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
Venkateshwarlu Domakonda | d6140eb | 2012-01-17 16:23:52 +0530 | [diff] [blame] | 2549 | u8 serv_avble = skb->data[0]; |
| 2550 | if (serv_avble) |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2551 | iris_q_event(radio, IRIS_EVT_ABOVE_TH); |
| 2552 | else |
| 2553 | iris_q_event(radio, IRIS_EVT_BELOW_TH); |
| 2554 | } |
| 2555 | |
| 2556 | static void hci_ev_rds_grp_complete(struct radio_hci_dev *hdev, |
| 2557 | struct sk_buff *skb) |
| 2558 | { |
| 2559 | struct iris_device *radio = video_get_drvdata(video_get_dev()); |
| 2560 | iris_q_event(radio, IRIS_EVT_TXRDSDONE); |
| 2561 | } |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2562 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2563 | void radio_hci_event_packet(struct radio_hci_dev *hdev, struct sk_buff *skb) |
| 2564 | { |
Priyanka Vunnam | bab6b7e | 2011-11-01 15:41:54 +0530 | [diff] [blame] | 2565 | struct radio_hci_event_hdr *hdr; |
| 2566 | u8 event; |
| 2567 | |
| 2568 | if (skb == NULL) { |
| 2569 | FMDERR("Socket buffer is NULL"); |
| 2570 | return; |
| 2571 | } |
| 2572 | |
| 2573 | hdr = (void *) skb->data; |
| 2574 | event = hdr->evt; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2575 | |
| 2576 | skb_pull(skb, RADIO_HCI_EVENT_HDR_SIZE); |
| 2577 | |
| 2578 | switch (event) { |
| 2579 | case HCI_EV_TUNE_STATUS: |
| 2580 | hci_ev_tune_status(hdev, skb); |
| 2581 | break; |
| 2582 | case HCI_EV_SEARCH_PROGRESS: |
| 2583 | case HCI_EV_SEARCH_RDS_PROGRESS: |
| 2584 | case HCI_EV_SEARCH_LIST_PROGRESS: |
| 2585 | hci_ev_search_next(hdev, skb); |
| 2586 | break; |
| 2587 | case HCI_EV_STEREO_STATUS: |
| 2588 | hci_ev_stereo_status(hdev, skb); |
| 2589 | break; |
| 2590 | case HCI_EV_RDS_LOCK_STATUS: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2591 | hci_ev_rds_lock_status(hdev, skb); |
| 2592 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2593 | case HCI_EV_SERVICE_AVAILABLE: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2594 | hci_ev_service_available(hdev, skb); |
| 2595 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2596 | case HCI_EV_RDS_RX_DATA: |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 2597 | hci_ev_raw_rds_group_data(hdev, skb); |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2598 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2599 | case HCI_EV_PROGRAM_SERVICE: |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2600 | hci_ev_program_service(hdev, skb); |
| 2601 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2602 | case HCI_EV_RADIO_TEXT: |
Ankur Nandwani | 78a782b | 2011-07-07 21:11:21 -0700 | [diff] [blame] | 2603 | hci_ev_radio_text(hdev, skb); |
| 2604 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2605 | case HCI_EV_FM_AF_LIST: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2606 | hci_ev_af_list(hdev, skb); |
| 2607 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2608 | case HCI_EV_TX_RDS_GRP_COMPL: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2609 | hci_ev_rds_grp_complete(hdev, skb); |
| 2610 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2611 | case HCI_EV_TX_RDS_CONT_GRP_COMPL: |
| 2612 | break; |
| 2613 | |
| 2614 | case HCI_EV_CMD_COMPLETE: |
| 2615 | hci_cmd_complete_event(hdev, skb); |
| 2616 | break; |
| 2617 | |
| 2618 | case HCI_EV_CMD_STATUS: |
| 2619 | hci_cmd_status_event(hdev, skb); |
| 2620 | break; |
| 2621 | |
| 2622 | case HCI_EV_SEARCH_COMPLETE: |
| 2623 | case HCI_EV_SEARCH_RDS_COMPLETE: |
| 2624 | hci_ev_search_compl(hdev, skb); |
| 2625 | break; |
| 2626 | |
| 2627 | case HCI_EV_SEARCH_LIST_COMPLETE: |
Srinivasa Rao Uppala | 18fb80e | 2011-07-17 17:33:00 -0700 | [diff] [blame] | 2628 | hci_ev_srch_st_list_compl(hdev, skb); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2629 | break; |
| 2630 | |
| 2631 | default: |
| 2632 | break; |
| 2633 | } |
| 2634 | } |
| 2635 | |
| 2636 | /* |
| 2637 | * fops/IOCTL helper functions |
| 2638 | */ |
| 2639 | |
| 2640 | static int iris_search(struct iris_device *radio, int on, int dir) |
| 2641 | { |
| 2642 | int retval = 0; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2643 | enum search_t srch; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2644 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2645 | if (radio == NULL) { |
| 2646 | FMDERR(":radio is null"); |
| 2647 | return -EINVAL; |
| 2648 | } |
| 2649 | |
| 2650 | srch = radio->g_search_mode & SRCH_MODE; |
| 2651 | radio->search_on = on; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2652 | if (on) { |
| 2653 | switch (srch) { |
| 2654 | case SCAN_FOR_STRONG: |
| 2655 | case SCAN_FOR_WEAK: |
| 2656 | radio->srch_st_list.srch_list_dir = dir; |
| 2657 | radio->srch_st_list.srch_list_mode = srch; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2658 | retval = hci_fm_search_station_list( |
| 2659 | &radio->srch_st_list, radio->fm_hdev); |
| 2660 | break; |
| 2661 | case RDS_SEEK_PTY: |
| 2662 | case RDS_SCAN_PTY: |
| 2663 | case RDS_SEEK_PI: |
Srinivasa Rao Uppala | 7bb2210 | 2011-07-14 11:27:30 -0700 | [diff] [blame] | 2664 | srch = srch - SEARCH_RDS_STNS_MODE_OFFSET; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2665 | radio->srch_rds.srch_station.srch_mode = srch; |
| 2666 | radio->srch_rds.srch_station.srch_dir = dir; |
| 2667 | radio->srch_rds.srch_station.scan_time = |
| 2668 | radio->g_scan_time; |
| 2669 | retval = hci_fm_search_rds_stations(&radio->srch_rds, |
| 2670 | radio->fm_hdev); |
| 2671 | break; |
| 2672 | default: |
| 2673 | radio->srch_st.srch_mode = srch; |
| 2674 | radio->srch_st.scan_time = radio->g_scan_time; |
| 2675 | radio->srch_st.srch_dir = dir; |
| 2676 | retval = hci_fm_search_stations( |
| 2677 | &radio->srch_st, radio->fm_hdev); |
| 2678 | break; |
| 2679 | } |
| 2680 | |
| 2681 | } else { |
| 2682 | retval = hci_cmd(HCI_FM_CANCEL_SEARCH_CMD, radio->fm_hdev); |
| 2683 | } |
| 2684 | |
| 2685 | return retval; |
| 2686 | } |
| 2687 | |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 2688 | static int set_low_power_mode(struct iris_device *radio, int power_mode) |
| 2689 | { |
| 2690 | |
| 2691 | int rds_grps_proc = 0x00; |
| 2692 | int retval = 0; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2693 | |
| 2694 | if (radio == NULL) { |
| 2695 | FMDERR(":radio is null"); |
| 2696 | return -EINVAL; |
| 2697 | } |
| 2698 | |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 2699 | if (radio->power_mode != power_mode) { |
| 2700 | |
| 2701 | if (power_mode) { |
| 2702 | radio->event_mask = 0x00; |
Srinivasa Rao Uppala | 1da1a24 | 2012-01-11 11:00:10 +0530 | [diff] [blame] | 2703 | if (radio->af_jump_bit) |
| 2704 | rds_grps_proc = 0x00 | AF_JUMP_ENABLE; |
| 2705 | else |
| 2706 | rds_grps_proc = 0x00; |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 2707 | retval = hci_fm_rds_grps_process( |
| 2708 | &rds_grps_proc, |
| 2709 | radio->fm_hdev); |
| 2710 | if (retval < 0) { |
| 2711 | FMDERR("Disable RDS failed"); |
| 2712 | return retval; |
| 2713 | } |
| 2714 | retval = hci_conf_event_mask(&radio->event_mask, |
| 2715 | radio->fm_hdev); |
| 2716 | } else { |
| 2717 | |
| 2718 | radio->event_mask = SIG_LEVEL_INTR | |
| 2719 | RDS_SYNC_INTR | AUDIO_CTRL_INTR; |
| 2720 | retval = hci_conf_event_mask(&radio->event_mask, |
| 2721 | radio->fm_hdev); |
| 2722 | if (retval < 0) { |
| 2723 | FMDERR("Enable Async events failed"); |
| 2724 | return retval; |
| 2725 | } |
| 2726 | retval = hci_fm_rds_grps_process( |
| 2727 | &radio->g_rds_grp_proc_ps, |
| 2728 | radio->fm_hdev); |
| 2729 | } |
| 2730 | radio->power_mode = power_mode; |
| 2731 | } |
| 2732 | return retval; |
| 2733 | } |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2734 | static int iris_recv_set_region(struct iris_device *radio, int req_region) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2735 | { |
| 2736 | int retval; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2737 | |
| 2738 | if (radio == NULL) { |
| 2739 | FMDERR(":radio is null"); |
| 2740 | return -EINVAL; |
| 2741 | } |
| 2742 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2743 | radio->region = req_region; |
| 2744 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2745 | retval = hci_set_fm_recv_conf( |
| 2746 | &radio->recv_conf, |
| 2747 | radio->fm_hdev); |
| 2748 | |
| 2749 | return retval; |
| 2750 | } |
| 2751 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2752 | |
| 2753 | static int iris_trans_set_region(struct iris_device *radio, int req_region) |
| 2754 | { |
| 2755 | int retval; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2756 | |
| 2757 | if (radio == NULL) { |
| 2758 | FMDERR(":radio is null"); |
| 2759 | return -EINVAL; |
| 2760 | } |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2761 | radio->region = req_region; |
| 2762 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2763 | retval = hci_set_fm_trans_conf( |
| 2764 | &radio->trans_conf, |
| 2765 | radio->fm_hdev); |
| 2766 | return retval; |
| 2767 | } |
| 2768 | |
| 2769 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2770 | static int iris_set_freq(struct iris_device *radio, unsigned int freq) |
| 2771 | { |
| 2772 | |
| 2773 | int retval; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2774 | |
| 2775 | if (radio == NULL) { |
| 2776 | FMDERR(":radio is null"); |
| 2777 | return -EINVAL; |
| 2778 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2779 | retval = hci_fm_tune_station(&freq, radio->fm_hdev); |
| 2780 | if (retval < 0) |
| 2781 | FMDERR("Error while setting the frequency : %d\n", retval); |
| 2782 | return retval; |
| 2783 | } |
| 2784 | |
| 2785 | |
| 2786 | static int iris_vidioc_queryctrl(struct file *file, void *priv, |
| 2787 | struct v4l2_queryctrl *qc) |
| 2788 | { |
| 2789 | unsigned char i; |
| 2790 | int retval = -EINVAL; |
| 2791 | |
| 2792 | for (i = 0; i < ARRAY_SIZE(iris_v4l2_queryctrl); i++) { |
| 2793 | if (qc->id && qc->id == iris_v4l2_queryctrl[i].id) { |
| 2794 | memcpy(qc, &(iris_v4l2_queryctrl[i]), sizeof(*qc)); |
| 2795 | retval = 0; |
| 2796 | break; |
| 2797 | } |
| 2798 | } |
| 2799 | |
| 2800 | return retval; |
| 2801 | } |
| 2802 | |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2803 | static int iris_do_calibration(struct iris_device *radio) |
| 2804 | { |
| 2805 | char cal_mode = 0x00; |
| 2806 | int retval = 0x00; |
| 2807 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2808 | if (radio == NULL) { |
| 2809 | FMDERR(":radio is null"); |
| 2810 | return -EINVAL; |
| 2811 | } |
| 2812 | |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2813 | cal_mode = PROCS_CALIB_MODE; |
Ayaz Ahmad | c1e6a95 | 2012-05-15 19:29:54 +0530 | [diff] [blame] | 2814 | radio->mode = FM_CALIB; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2815 | retval = hci_cmd(HCI_FM_ENABLE_RECV_CMD, |
| 2816 | radio->fm_hdev); |
| 2817 | if (retval < 0) { |
| 2818 | FMDERR("Enable failed before calibration %x", retval); |
Ayaz Ahmad | c1e6a95 | 2012-05-15 19:29:54 +0530 | [diff] [blame] | 2819 | radio->mode = FM_OFF; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2820 | return retval; |
| 2821 | } |
| 2822 | retval = radio_hci_request(radio->fm_hdev, hci_fm_do_cal_req, |
| 2823 | (unsigned long)cal_mode, RADIO_HCI_TIMEOUT); |
| 2824 | if (retval < 0) { |
| 2825 | FMDERR("Do Process calibration failed %x", retval); |
Ayaz Ahmad | c1e6a95 | 2012-05-15 19:29:54 +0530 | [diff] [blame] | 2826 | radio->mode = FM_RECV; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2827 | return retval; |
| 2828 | } |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2829 | retval = hci_cmd(HCI_FM_DISABLE_RECV_CMD, |
| 2830 | radio->fm_hdev); |
| 2831 | if (retval < 0) |
| 2832 | FMDERR("Disable Failed after calibration %d", retval); |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 2833 | else |
| 2834 | radio->mode = FM_OFF; |
| 2835 | |
Anantha Krishnan | 152fe5b | 2012-02-28 18:07:20 +0530 | [diff] [blame] | 2836 | return retval; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2837 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2838 | static int iris_vidioc_g_ctrl(struct file *file, void *priv, |
| 2839 | struct v4l2_control *ctrl) |
| 2840 | { |
| 2841 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
| 2842 | int retval = 0; |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 2843 | int cf0; |
| 2844 | struct hci_fm_def_data_rd_req rd; |
| 2845 | int lsb, msb; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2846 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 2847 | if (radio == NULL) { |
| 2848 | FMDERR(":radio is null"); |
| 2849 | return -EINVAL; |
| 2850 | } |
| 2851 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2852 | switch (ctrl->id) { |
| 2853 | case V4L2_CID_AUDIO_VOLUME: |
| 2854 | break; |
| 2855 | case V4L2_CID_AUDIO_MUTE: |
| 2856 | ctrl->value = radio->mute_mode.hard_mute; |
| 2857 | break; |
| 2858 | case V4L2_CID_PRIVATE_IRIS_SRCHMODE: |
| 2859 | ctrl->value = radio->g_search_mode; |
| 2860 | break; |
| 2861 | case V4L2_CID_PRIVATE_IRIS_SCANDWELL: |
| 2862 | ctrl->value = radio->g_scan_time; |
| 2863 | break; |
| 2864 | case V4L2_CID_PRIVATE_IRIS_SRCHON: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2865 | ctrl->value = radio->search_on; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2866 | break; |
| 2867 | case V4L2_CID_PRIVATE_IRIS_STATE: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2868 | ctrl->value = radio->mode; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2869 | break; |
| 2870 | case V4L2_CID_PRIVATE_IRIS_IOVERC: |
| 2871 | retval = hci_cmd(HCI_FM_STATION_DBG_PARAM_CMD, radio->fm_hdev); |
| 2872 | if (retval < 0) |
| 2873 | return retval; |
| 2874 | ctrl->value = radio->st_dbg_param.io_verc; |
| 2875 | break; |
| 2876 | case V4L2_CID_PRIVATE_IRIS_INTDET: |
| 2877 | retval = hci_cmd(HCI_FM_STATION_DBG_PARAM_CMD, radio->fm_hdev); |
| 2878 | if (retval < 0) |
| 2879 | return retval; |
| 2880 | ctrl->value = radio->st_dbg_param.in_det_out; |
| 2881 | break; |
| 2882 | case V4L2_CID_PRIVATE_IRIS_REGION: |
| 2883 | ctrl->value = radio->region; |
| 2884 | break; |
| 2885 | case V4L2_CID_PRIVATE_IRIS_SIGNAL_TH: |
| 2886 | retval = hci_cmd(HCI_FM_GET_SIGNAL_TH_CMD, radio->fm_hdev); |
Venkateshwarlu Domakonda | 3d1d6e4 | 2011-12-09 15:08:58 +0530 | [diff] [blame] | 2887 | if (retval < 0) { |
| 2888 | FMDERR("Error in get signal threshold %d\n", retval); |
| 2889 | return retval; |
| 2890 | } |
| 2891 | ctrl->value = radio->sig_th.sig_threshold; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2892 | break; |
| 2893 | case V4L2_CID_PRIVATE_IRIS_SRCH_PTY: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2894 | ctrl->value = radio->srch_rds.srch_pty; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2895 | break; |
| 2896 | case V4L2_CID_PRIVATE_IRIS_SRCH_PI: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2897 | ctrl->value = radio->srch_rds.srch_pi; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2898 | break; |
| 2899 | case V4L2_CID_PRIVATE_IRIS_SRCH_CNT: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 2900 | ctrl->value = radio->srch_st_result.num_stations_found; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2901 | break; |
| 2902 | case V4L2_CID_PRIVATE_IRIS_EMPHASIS: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2903 | if (radio->mode == FM_RECV) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2904 | ctrl->value = radio->recv_conf.emphasis; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2905 | } else if (radio->mode == FM_TRANS) { |
| 2906 | ctrl->value = radio->trans_conf.emphasis; |
| 2907 | } else { |
| 2908 | FMDERR("Error in radio mode" |
| 2909 | " %d\n", retval); |
| 2910 | return -EINVAL; |
| 2911 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2912 | break; |
| 2913 | case V4L2_CID_PRIVATE_IRIS_RDS_STD: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2914 | if (radio->mode == FM_RECV) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2915 | ctrl->value = radio->recv_conf.rds_std; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2916 | } else if (radio->mode == FM_TRANS) { |
| 2917 | ctrl->value = radio->trans_conf.rds_std; |
| 2918 | } else { |
| 2919 | FMDERR("Error in radio mode" |
| 2920 | " %d\n", retval); |
| 2921 | return -EINVAL; |
| 2922 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2923 | break; |
| 2924 | case V4L2_CID_PRIVATE_IRIS_SPACING: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2925 | if (radio->mode == FM_RECV) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2926 | ctrl->value = radio->recv_conf.ch_spacing; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2927 | } else { |
| 2928 | FMDERR("Error in radio mode" |
| 2929 | " %d\n", retval); |
| 2930 | return -EINVAL; |
| 2931 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2932 | break; |
| 2933 | case V4L2_CID_PRIVATE_IRIS_RDSON: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2934 | if (radio->mode == FM_RECV) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2935 | ctrl->value = radio->recv_conf.rds_std; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 2936 | } else { |
| 2937 | FMDERR("Error in radio mode" |
| 2938 | " %d\n", retval); |
| 2939 | return -EINVAL; |
| 2940 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2941 | break; |
| 2942 | case V4L2_CID_PRIVATE_IRIS_RDSGROUP_MASK: |
| 2943 | ctrl->value = radio->rds_grp.rds_grp_enable_mask; |
| 2944 | break; |
| 2945 | case V4L2_CID_PRIVATE_IRIS_RDSGROUP_PROC: |
Srinivasa Rao Uppala | 58273f8 | 2011-08-10 19:07:45 -0700 | [diff] [blame] | 2946 | case V4L2_CID_PRIVATE_IRIS_PSALL: |
| 2947 | ctrl->value = (radio->g_rds_grp_proc_ps << RDS_CONFIG_OFFSET); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2948 | break; |
| 2949 | case V4L2_CID_PRIVATE_IRIS_RDSD_BUF: |
| 2950 | ctrl->value = radio->rds_grp.rds_buf_size; |
| 2951 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2952 | case V4L2_CID_PRIVATE_IRIS_LP_MODE: |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 2953 | ctrl->value = radio->power_mode; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2954 | break; |
| 2955 | case V4L2_CID_PRIVATE_IRIS_ANTENNA: |
| 2956 | ctrl->value = radio->g_antenna; |
| 2957 | break; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 2958 | case V4L2_CID_PRIVATE_IRIS_SOFT_MUTE: |
| 2959 | ctrl->value = radio->mute_mode.soft_mute; |
| 2960 | break; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 2961 | case V4L2_CID_PRIVATE_IRIS_DO_CALIBRATION: |
| 2962 | retval = iris_do_calibration(radio); |
| 2963 | break; |
Srinivasa Rao Uppala | acdebcc | 2011-12-23 14:31:38 +0530 | [diff] [blame] | 2964 | case V4L2_CID_PRIVATE_IRIS_GET_SINR: |
| 2965 | if (radio->mode == FM_RECV) { |
| 2966 | retval = hci_cmd(HCI_FM_GET_STATION_PARAM_CMD, |
| 2967 | radio->fm_hdev); |
| 2968 | if (retval < 0) { |
| 2969 | FMDERR("Get SINR Failed"); |
| 2970 | return retval; |
| 2971 | } |
| 2972 | ctrl->value = radio->fm_st_rsp.station_rsp.sinr; |
| 2973 | |
| 2974 | } else |
| 2975 | retval = -EINVAL; |
Ayaz Ahmad | b69202b | 2012-02-23 19:24:46 +0530 | [diff] [blame] | 2976 | break; |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 2977 | case V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD: |
| 2978 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 2979 | if (retval < 0) { |
| 2980 | FMDERR("Get High det threshold failed %x", retval); |
| 2981 | return retval; |
| 2982 | } |
| 2983 | ctrl->value = radio->ch_det_threshold.high_th; |
| 2984 | break; |
| 2985 | case V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD: |
| 2986 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 2987 | if (retval < 0) { |
| 2988 | FMDERR("Get Low det threshold failed %x", retval); |
| 2989 | return retval; |
| 2990 | } |
| 2991 | ctrl->value = radio->ch_det_threshold.low_th; |
| 2992 | break; |
| 2993 | case V4L2_CID_PRIVATE_SINR_THRESHOLD: |
| 2994 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 2995 | if (retval < 0) { |
| 2996 | FMDERR("Get SINR threshold failed %x", retval); |
| 2997 | return retval; |
| 2998 | } |
| 2999 | ctrl->value = radio->ch_det_threshold.sinr; |
| 3000 | break; |
| 3001 | case V4L2_CID_PRIVATE_SINR_SAMPLES: |
| 3002 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 3003 | if (retval < 0) { |
| 3004 | FMDERR("Get SINR samples failed %x", retval); |
| 3005 | return retval; |
| 3006 | } |
| 3007 | |
| 3008 | ctrl->value = radio->ch_det_threshold.sinr_samples; |
Srinivasa Rao Uppala | acdebcc | 2011-12-23 14:31:38 +0530 | [diff] [blame] | 3009 | break; |
Ayaz Ahmad | 37294ba | 2012-07-10 16:38:11 +0530 | [diff] [blame] | 3010 | case V4L2_CID_PRIVATE_VALID_CHANNEL: |
| 3011 | ctrl->value = radio->is_station_valid; |
| 3012 | break; |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 3013 | case V4L2_CID_PRIVATE_AF_RMSSI_TH: |
| 3014 | rd.mode = FM_RDS_CNFG_MODE; |
| 3015 | rd.length = FM_RDS_CNFG_LEN; |
| 3016 | rd.param_len = 0; |
| 3017 | rd.param = 0; |
| 3018 | |
| 3019 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3020 | if (retval < 0) { |
| 3021 | FMDERR("Get AF Jump Threshold failed %x", retval); |
| 3022 | return retval; |
| 3023 | } |
| 3024 | lsb = radio->default_data.data[AF_RMSSI_TH_LSB_OFFSET]; |
| 3025 | msb = radio->default_data.data[AF_RMSSI_TH_MSB_OFFSET]; |
| 3026 | ctrl->value = ((msb << 8) | lsb); |
| 3027 | break; |
| 3028 | case V4L2_CID_PRIVATE_AF_RMSSI_SAMPLES: |
| 3029 | rd.mode = FM_RDS_CNFG_MODE; |
| 3030 | rd.length = FM_RDS_CNFG_LEN; |
| 3031 | rd.param_len = 0; |
| 3032 | rd.param = 0; |
| 3033 | |
| 3034 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3035 | if (retval < 0) { |
| 3036 | FMDERR("Get AF jump rmssi samples failed %x", retval); |
| 3037 | return retval; |
| 3038 | } |
| 3039 | ctrl->value = radio->default_data.data[AF_RMSSI_SAMPLES_OFFSET]; |
| 3040 | break; |
| 3041 | case V4L2_CID_PRIVATE_GOOD_CH_RMSSI_TH: |
| 3042 | rd.mode = FM_RX_CONFG_MODE; |
| 3043 | rd.length = FM_RX_CNFG_LEN; |
| 3044 | rd.param_len = 0; |
| 3045 | rd.param = 0; |
| 3046 | |
| 3047 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3048 | if (retval < 0) { |
| 3049 | FMDERR("get good channel rmssi th failed %x", retval); |
| 3050 | return retval; |
| 3051 | } |
| 3052 | ctrl->value = radio->default_data.data[GD_CH_RMSSI_TH_OFFSET]; |
| 3053 | if (ctrl->value > MAX_GD_CH_RMSSI_TH) |
| 3054 | ctrl->value -= 256; |
| 3055 | break; |
| 3056 | case V4L2_CID_PRIVATE_SRCHALGOTYPE: |
| 3057 | rd.mode = FM_RX_CONFG_MODE; |
| 3058 | rd.length = FM_RX_CNFG_LEN; |
| 3059 | rd.param_len = 0; |
| 3060 | rd.param = 0; |
| 3061 | |
| 3062 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3063 | if (retval < 0) { |
| 3064 | FMDERR("get search algo type failed %x", retval); |
| 3065 | return retval; |
| 3066 | } |
| 3067 | ctrl->value = radio->default_data.data[SRCH_ALGO_TYPE_OFFSET]; |
| 3068 | break; |
| 3069 | case V4L2_CID_PRIVATE_SINRFIRSTSTAGE: |
| 3070 | rd.mode = FM_RX_CONFG_MODE; |
| 3071 | rd.length = FM_RX_CNFG_LEN; |
| 3072 | rd.param_len = 0; |
| 3073 | rd.param = 0; |
| 3074 | |
| 3075 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3076 | if (retval < 0) { |
| 3077 | FMDERR("default data read failed %x", retval); |
| 3078 | return retval; |
| 3079 | } |
| 3080 | ctrl->value = radio->default_data.data[SINRFIRSTSTAGE_OFFSET]; |
| 3081 | if (ctrl->value > MAX_SINR_FIRSTSTAGE) |
| 3082 | ctrl->value -= 256; |
| 3083 | break; |
| 3084 | case V4L2_CID_PRIVATE_RMSSIFIRSTSTAGE: |
| 3085 | rd.mode = FM_RX_CONFG_MODE; |
| 3086 | rd.length = FM_RX_CNFG_LEN; |
| 3087 | rd.param_len = 0; |
| 3088 | rd.param = 0; |
| 3089 | |
| 3090 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3091 | if (retval < 0) { |
| 3092 | FMDERR("default data read failed %x", retval); |
| 3093 | return retval; |
| 3094 | } |
| 3095 | ctrl->value = radio->default_data.data[RMSSIFIRSTSTAGE_OFFSET]; |
| 3096 | if (ctrl->value > MAX_RMSSI_FIRSTSTAGE) |
| 3097 | ctrl->value -= 256; |
| 3098 | break; |
| 3099 | case V4L2_CID_PRIVATE_CF0TH12: |
| 3100 | rd.mode = FM_RX_CONFG_MODE; |
| 3101 | rd.length = FM_RX_CNFG_LEN; |
| 3102 | rd.param_len = 0; |
| 3103 | rd.param = 0; |
| 3104 | |
| 3105 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3106 | if (retval < 0) { |
| 3107 | FMDERR("default data read failed %x", retval); |
| 3108 | return retval; |
| 3109 | } |
| 3110 | ctrl->value = radio->default_data.data[CF0TH12_BYTE1_OFFSET]; |
| 3111 | cf0 = radio->default_data.data[CF0TH12_BYTE2_OFFSET]; |
| 3112 | ctrl->value |= (cf0 << 8); |
| 3113 | cf0 = radio->default_data.data[CF0TH12_BYTE3_OFFSET]; |
| 3114 | ctrl->value |= (cf0 << 16); |
| 3115 | cf0 = radio->default_data.data[CF0TH12_BYTE4_OFFSET]; |
| 3116 | if (cf0 > 127) |
| 3117 | cf0 -= 256; |
| 3118 | ctrl->value |= (cf0 << 24); |
| 3119 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3120 | default: |
| 3121 | retval = -EINVAL; |
| 3122 | } |
| 3123 | if (retval < 0) |
| 3124 | FMDERR("get control failed with %d, id: %d\n", |
| 3125 | retval, ctrl->id); |
| 3126 | return retval; |
| 3127 | } |
| 3128 | |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 3129 | static int iris_vidioc_g_ext_ctrls(struct file *file, void *priv, |
| 3130 | struct v4l2_ext_controls *ctrl) |
| 3131 | { |
| 3132 | int retval = 0; |
| 3133 | char *data = NULL; |
| 3134 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
| 3135 | struct hci_fm_def_data_rd_req default_data_rd; |
| 3136 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 3137 | if (radio == NULL) { |
| 3138 | FMDERR(":radio is null"); |
| 3139 | return -EINVAL; |
| 3140 | } |
| 3141 | |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 3142 | switch ((ctrl->controls[0]).id) { |
| 3143 | case V4L2_CID_PRIVATE_IRIS_READ_DEFAULT: |
| 3144 | data = (ctrl->controls[0]).string; |
| 3145 | memset(&default_data_rd, 0, sizeof(default_data_rd)); |
| 3146 | if (copy_from_user(&default_data_rd.mode, data, |
| 3147 | sizeof(default_data_rd))) |
| 3148 | return -EFAULT; |
| 3149 | retval = hci_def_data_read(&default_data_rd, radio->fm_hdev); |
| 3150 | break; |
| 3151 | default: |
| 3152 | retval = -EINVAL; |
| 3153 | } |
| 3154 | |
| 3155 | return retval; |
| 3156 | } |
| 3157 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3158 | static int iris_vidioc_s_ext_ctrls(struct file *file, void *priv, |
| 3159 | struct v4l2_ext_controls *ctrl) |
| 3160 | { |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3161 | int retval = 0; |
| 3162 | int bytes_to_copy; |
| 3163 | struct hci_fm_tx_ps tx_ps; |
| 3164 | struct hci_fm_tx_rt tx_rt; |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 3165 | struct hci_fm_def_data_wr_req default_data; |
Venkateshwarlu Domakonda | 3a0b75d | 2011-11-23 17:03:27 +0530 | [diff] [blame] | 3166 | struct hci_fm_set_cal_req_proc proc_cal_req; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3167 | |
| 3168 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
| 3169 | char *data = NULL; |
| 3170 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 3171 | if (radio == NULL) { |
| 3172 | FMDERR(":radio is null"); |
| 3173 | return -EINVAL; |
| 3174 | } |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3175 | switch ((ctrl->controls[0]).id) { |
| 3176 | case V4L2_CID_RDS_TX_PS_NAME: |
| 3177 | FMDBG("In V4L2_CID_RDS_TX_PS_NAME\n"); |
| 3178 | /*Pass a sample PS string */ |
| 3179 | |
| 3180 | memset(tx_ps.ps_data, 0, MAX_PS_LENGTH); |
| 3181 | bytes_to_copy = min((int)(ctrl->controls[0]).size, |
| 3182 | MAX_PS_LENGTH); |
| 3183 | data = (ctrl->controls[0]).string; |
| 3184 | |
| 3185 | if (copy_from_user(tx_ps.ps_data, |
| 3186 | data, bytes_to_copy)) |
| 3187 | return -EFAULT; |
| 3188 | tx_ps.ps_control = 0x01; |
| 3189 | tx_ps.pi = radio->pi; |
| 3190 | tx_ps.pty = radio->pty; |
| 3191 | tx_ps.ps_repeatcount = radio->ps_repeatcount; |
Ayaz Ahmad | 1c0db52 | 2012-08-27 17:52:51 +0530 | [diff] [blame] | 3192 | tx_ps.ps_num = (bytes_to_copy / PS_STRING_LEN); |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3193 | |
| 3194 | retval = radio_hci_request(radio->fm_hdev, hci_trans_ps_req, |
| 3195 | (unsigned long)&tx_ps, RADIO_HCI_TIMEOUT); |
| 3196 | break; |
| 3197 | case V4L2_CID_RDS_TX_RADIO_TEXT: |
| 3198 | bytes_to_copy = |
| 3199 | min((int)(ctrl->controls[0]).size, MAX_RT_LENGTH); |
| 3200 | data = (ctrl->controls[0]).string; |
| 3201 | |
| 3202 | memset(tx_rt.rt_data, 0, MAX_RT_LENGTH); |
| 3203 | |
| 3204 | if (copy_from_user(tx_rt.rt_data, |
| 3205 | data, bytes_to_copy)) |
| 3206 | return -EFAULT; |
| 3207 | |
| 3208 | tx_rt.rt_control = 0x01; |
| 3209 | tx_rt.pi = radio->pi; |
| 3210 | tx_rt.pty = radio->pty; |
Ayaz Ahmad | 1c0db52 | 2012-08-27 17:52:51 +0530 | [diff] [blame] | 3211 | tx_rt.rt_len = bytes_to_copy; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3212 | |
| 3213 | retval = radio_hci_request(radio->fm_hdev, hci_trans_rt_req, |
| 3214 | (unsigned long)&tx_rt, RADIO_HCI_TIMEOUT); |
| 3215 | break; |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 3216 | case V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT: |
| 3217 | data = (ctrl->controls[0]).string; |
| 3218 | memset(&default_data, 0, sizeof(default_data)); |
Anantha Krishnan | 152fe5b | 2012-02-28 18:07:20 +0530 | [diff] [blame] | 3219 | /* |
| 3220 | * Check if length of the 'FM Default Data' to be sent |
| 3221 | * is within the maximum 'FM Default Data' packet limit. |
| 3222 | * Max. 'FM Default Data' packet length is 251 bytes: |
| 3223 | * 1 byte - XFR Mode |
| 3224 | * 1 byte - length of the default data |
| 3225 | * 249 bytes - actual data to be configured |
| 3226 | */ |
| 3227 | if (ctrl->controls[0].size > (DEFAULT_DATA_SIZE + 2)) { |
| 3228 | pr_err("%s: Default data buffer overflow!\n", __func__); |
| 3229 | return -EINVAL; |
| 3230 | } |
| 3231 | |
| 3232 | /* copy only 'size' bytes of data as requested by user */ |
| 3233 | retval = copy_from_user(&default_data, data, |
| 3234 | ctrl->controls[0].size); |
| 3235 | if (retval > 0) { |
| 3236 | pr_err("%s: Failed to copy %d bytes of default data" |
| 3237 | " passed by user\n", __func__, retval); |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 3238 | return -EFAULT; |
Anantha Krishnan | 152fe5b | 2012-02-28 18:07:20 +0530 | [diff] [blame] | 3239 | } |
| 3240 | FMDBG("%s: XFR Mode\t: 0x%x\n", __func__, default_data.mode); |
| 3241 | FMDBG("%s: XFR Data Length\t: %d\n", __func__, |
| 3242 | default_data.length); |
| 3243 | /* |
| 3244 | * Check if the 'length' of the actual XFR data to be configured |
| 3245 | * is valid or not. Length of actual XFR data should be always |
| 3246 | * 2 bytes less than the total length of the 'FM Default Data'. |
| 3247 | * Length of 'FM Default Data' DEF_DATA_LEN: (1+1+XFR Data Size) |
| 3248 | * Length of 'Actual XFR Data' XFR_DATA_LEN: (DEF_DATA_LEN - 2) |
| 3249 | */ |
| 3250 | if (default_data.length != (ctrl->controls[0].size - 2)) { |
| 3251 | pr_err("%s: Invalid 'length' parameter passed for " |
| 3252 | "actual xfr data\n", __func__); |
| 3253 | return -EINVAL; |
| 3254 | } |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 3255 | retval = hci_def_data_write(&default_data, radio->fm_hdev); |
Anantha Krishnan | 152fe5b | 2012-02-28 18:07:20 +0530 | [diff] [blame] | 3256 | break; |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 3257 | case V4L2_CID_PRIVATE_IRIS_SET_CALIBRATION: |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 3258 | data = (ctrl->controls[0]).string; |
| 3259 | bytes_to_copy = (ctrl->controls[0]).size; |
Venkateshwarlu Domakonda | 5e96e69 | 2011-12-05 17:36:06 +0530 | [diff] [blame] | 3260 | if (bytes_to_copy < PROCS_CALIB_SIZE) { |
Venkateshwarlu Domakonda | 3a0b75d | 2011-11-23 17:03:27 +0530 | [diff] [blame] | 3261 | FMDERR("data is less than required size"); |
| 3262 | return -EFAULT; |
| 3263 | } |
| 3264 | memset(proc_cal_req.data, 0, PROCS_CALIB_SIZE); |
| 3265 | proc_cal_req.mode = PROCS_CALIB_MODE; |
| 3266 | if (copy_from_user(&proc_cal_req.data[0], |
| 3267 | data, sizeof(proc_cal_req.data))) |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 3268 | return -EFAULT; |
Venkateshwarlu Domakonda | 3a0b75d | 2011-11-23 17:03:27 +0530 | [diff] [blame] | 3269 | retval = radio_hci_request(radio->fm_hdev, |
| 3270 | hci_fm_set_cal_req_proc, |
| 3271 | (unsigned long)&proc_cal_req, |
| 3272 | RADIO_HCI_TIMEOUT); |
Srinivasa Rao Uppala | acdebcc | 2011-12-23 14:31:38 +0530 | [diff] [blame] | 3273 | if (retval < 0) |
Srinivasa Rao Uppala | cb48ee6 | 2011-10-25 09:57:06 +0530 | [diff] [blame] | 3274 | FMDERR("Set Process calibration failed %d", retval); |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 3275 | break; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3276 | default: |
| 3277 | FMDBG("Shouldn't reach here\n"); |
| 3278 | retval = -1; |
| 3279 | } |
| 3280 | return retval; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3281 | } |
| 3282 | |
| 3283 | static int iris_vidioc_s_ctrl(struct file *file, void *priv, |
| 3284 | struct v4l2_control *ctrl) |
| 3285 | { |
| 3286 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
| 3287 | int retval = 0; |
| 3288 | unsigned int rds_grps_proc = 0; |
| 3289 | __u8 temp_val = 0; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3290 | unsigned long arg = 0; |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 3291 | struct hci_fm_tx_ps tx_ps = {0}; |
| 3292 | struct hci_fm_tx_rt tx_rt = {0}; |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 3293 | struct hci_fm_def_data_rd_req rd; |
| 3294 | struct hci_fm_def_data_wr_req wrd; |
Ayaz Ahmad | 37294ba | 2012-07-10 16:38:11 +0530 | [diff] [blame] | 3295 | char sinr_th, sinr; |
| 3296 | __u8 intf_det_low_th, intf_det_high_th, intf_det_out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3297 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 3298 | if (radio == NULL) { |
| 3299 | FMDERR(":radio is null"); |
| 3300 | return -EINVAL; |
| 3301 | } |
| 3302 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3303 | switch (ctrl->id) { |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 3304 | case V4L2_CID_PRIVATE_IRIS_TX_TONE: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3305 | radio->tone_freq = ctrl->value; |
| 3306 | retval = radio_hci_request(radio->fm_hdev, |
| 3307 | hci_fm_tone_generator, arg, |
| 3308 | msecs_to_jiffies(RADIO_HCI_TIMEOUT)); |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 3309 | if (retval < 0) |
| 3310 | FMDERR("Error while setting the tone %d", retval); |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3311 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3312 | case V4L2_CID_AUDIO_VOLUME: |
| 3313 | break; |
| 3314 | case V4L2_CID_AUDIO_MUTE: |
| 3315 | radio->mute_mode.hard_mute = ctrl->value; |
| 3316 | radio->mute_mode.soft_mute = IOC_SFT_MUTE; |
| 3317 | retval = hci_set_fm_mute_mode( |
| 3318 | &radio->mute_mode, |
| 3319 | radio->fm_hdev); |
| 3320 | if (retval < 0) |
| 3321 | FMDERR("Error while set FM hard mute"" %d\n", |
| 3322 | retval); |
| 3323 | break; |
| 3324 | case V4L2_CID_PRIVATE_IRIS_SRCHMODE: |
| 3325 | radio->g_search_mode = ctrl->value; |
| 3326 | break; |
| 3327 | case V4L2_CID_PRIVATE_IRIS_SCANDWELL: |
| 3328 | radio->g_scan_time = ctrl->value; |
| 3329 | break; |
| 3330 | case V4L2_CID_PRIVATE_IRIS_SRCHON: |
| 3331 | iris_search(radio, ctrl->value, SRCH_DIR_UP); |
| 3332 | break; |
| 3333 | case V4L2_CID_PRIVATE_IRIS_STATE: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3334 | switch (ctrl->value) { |
| 3335 | case FM_RECV: |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3336 | if (is_enable_rx_possible(radio) != 0) |
| 3337 | return -EINVAL; |
| 3338 | radio->mode = FM_RECV_TURNING_ON; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3339 | retval = hci_cmd(HCI_FM_ENABLE_RECV_CMD, |
| 3340 | radio->fm_hdev); |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 3341 | if (retval < 0) { |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3342 | FMDERR("Error while enabling RECV FM" |
Srinivasa Rao Uppala | 0ffb5d6 | 2011-08-02 17:54:13 -0700 | [diff] [blame] | 3343 | " %d\n", retval); |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3344 | radio->mode = FM_OFF; |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 3345 | return retval; |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3346 | } else { |
| 3347 | initialise_recv(radio); |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 3348 | } |
Srinivasa Rao Uppala | 07522d9 | 2011-08-16 05:09:30 -0700 | [diff] [blame] | 3349 | break; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3350 | case FM_TRANS: |
Ayaz Ahmad | af8379e | 2013-08-20 12:54:20 +0530 | [diff] [blame] | 3351 | if (is_enable_tx_possible(radio) != 0) |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3352 | return -EINVAL; |
| 3353 | radio->mode = FM_TRANS_TURNING_ON; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3354 | retval = hci_cmd(HCI_FM_ENABLE_TRANS_CMD, |
| 3355 | radio->fm_hdev); |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 3356 | if (retval < 0) { |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3357 | FMDERR("Error while enabling TRANS FM" |
| 3358 | " %d\n", retval); |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3359 | radio->mode = FM_OFF; |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 3360 | return retval; |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3361 | } else { |
| 3362 | initialise_trans(radio); |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 3363 | } |
Srinivasa Rao Uppala | 07522d9 | 2011-08-16 05:09:30 -0700 | [diff] [blame] | 3364 | break; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3365 | case FM_OFF: |
Anantha Krishnan | f950e32 | 2012-06-06 14:25:49 +0530 | [diff] [blame] | 3366 | radio->spur_table_size = 0; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3367 | switch (radio->mode) { |
| 3368 | case FM_RECV: |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3369 | radio->mode = FM_TURNING_OFF; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3370 | retval = hci_cmd(HCI_FM_DISABLE_RECV_CMD, |
| 3371 | radio->fm_hdev); |
Ayaz Ahmad | c1e6a95 | 2012-05-15 19:29:54 +0530 | [diff] [blame] | 3372 | if (retval < 0) { |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3373 | FMDERR("Err on disable recv FM" |
| 3374 | " %d\n", retval); |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3375 | radio->mode = FM_RECV; |
Ayaz Ahmad | c1e6a95 | 2012-05-15 19:29:54 +0530 | [diff] [blame] | 3376 | return retval; |
| 3377 | } |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3378 | break; |
| 3379 | case FM_TRANS: |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3380 | radio->mode = FM_TURNING_OFF; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3381 | retval = hci_cmd(HCI_FM_DISABLE_TRANS_CMD, |
| 3382 | radio->fm_hdev); |
| 3383 | |
Ayaz Ahmad | c1e6a95 | 2012-05-15 19:29:54 +0530 | [diff] [blame] | 3384 | if (retval < 0) { |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3385 | FMDERR("Err disabling trans FM" |
Srinivasa Rao Uppala | 0ffb5d6 | 2011-08-02 17:54:13 -0700 | [diff] [blame] | 3386 | " %d\n", retval); |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 3387 | radio->mode = FM_TRANS; |
Ayaz Ahmad | c1e6a95 | 2012-05-15 19:29:54 +0530 | [diff] [blame] | 3388 | return retval; |
| 3389 | } |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3390 | break; |
| 3391 | default: |
| 3392 | retval = -EINVAL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3393 | } |
Srinivasa Rao Uppala | cc62b1c | 2011-08-22 19:15:29 +0530 | [diff] [blame] | 3394 | break; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3395 | default: |
| 3396 | retval = -EINVAL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3397 | } |
| 3398 | break; |
| 3399 | case V4L2_CID_PRIVATE_IRIS_REGION: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3400 | if (radio->mode == FM_RECV) { |
| 3401 | retval = iris_recv_set_region(radio, ctrl->value); |
| 3402 | } else { |
| 3403 | if (radio->mode == FM_TRANS) |
| 3404 | retval = iris_trans_set_region(radio, |
| 3405 | ctrl->value); |
| 3406 | else |
| 3407 | retval = -EINVAL; |
| 3408 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3409 | break; |
| 3410 | case V4L2_CID_PRIVATE_IRIS_SIGNAL_TH: |
| 3411 | temp_val = ctrl->value; |
| 3412 | retval = hci_fm_set_signal_threshold( |
| 3413 | &temp_val, |
| 3414 | radio->fm_hdev); |
| 3415 | if (retval < 0) { |
| 3416 | FMDERR("Error while setting signal threshold\n"); |
| 3417 | break; |
| 3418 | } |
| 3419 | break; |
| 3420 | case V4L2_CID_PRIVATE_IRIS_SRCH_PTY: |
| 3421 | radio->srch_rds.srch_pty = ctrl->value; |
| 3422 | radio->srch_st_list.srch_pty = ctrl->value; |
| 3423 | break; |
| 3424 | case V4L2_CID_PRIVATE_IRIS_SRCH_PI: |
| 3425 | radio->srch_rds.srch_pi = ctrl->value; |
| 3426 | break; |
| 3427 | case V4L2_CID_PRIVATE_IRIS_SRCH_CNT: |
Ayaz Ahmad | 7ba5c1c | 2012-11-20 14:55:15 +0530 | [diff] [blame] | 3428 | radio->srch_st_list.srch_list_max = ctrl->value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3429 | break; |
| 3430 | case V4L2_CID_PRIVATE_IRIS_SPACING: |
Venkateshwarlu Domakonda | 45496f1 | 2011-11-23 12:51:13 +0530 | [diff] [blame] | 3431 | if (radio->mode == FM_RECV) { |
| 3432 | radio->recv_conf.ch_spacing = ctrl->value; |
| 3433 | retval = hci_set_fm_recv_conf( |
| 3434 | &radio->recv_conf, |
| 3435 | radio->fm_hdev); |
| 3436 | if (retval < 0) |
| 3437 | FMDERR("Error in setting channel spacing"); |
| 3438 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3439 | break; |
| 3440 | case V4L2_CID_PRIVATE_IRIS_EMPHASIS: |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 3441 | switch (radio->mode) { |
| 3442 | case FM_RECV: |
| 3443 | radio->recv_conf.emphasis = ctrl->value; |
| 3444 | retval = hci_set_fm_recv_conf( |
| 3445 | &radio->recv_conf, |
| 3446 | radio->fm_hdev); |
| 3447 | if (retval < 0) |
| 3448 | FMDERR("Error in setting emphasis"); |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3449 | break; |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 3450 | case FM_TRANS: |
| 3451 | radio->trans_conf.emphasis = ctrl->value; |
| 3452 | retval = hci_set_fm_trans_conf( |
| 3453 | &radio->trans_conf, |
| 3454 | radio->fm_hdev); |
| 3455 | if (retval < 0) |
| 3456 | FMDERR("Error in setting emphasis"); |
| 3457 | break; |
| 3458 | default: |
| 3459 | retval = -EINVAL; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3460 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3461 | break; |
| 3462 | case V4L2_CID_PRIVATE_IRIS_RDS_STD: |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 3463 | switch (radio->mode) { |
| 3464 | case FM_RECV: |
| 3465 | radio->recv_conf.rds_std = ctrl->value; |
| 3466 | retval = hci_set_fm_recv_conf( |
| 3467 | &radio->recv_conf, |
| 3468 | radio->fm_hdev); |
| 3469 | if (retval < 0) |
| 3470 | FMDERR("Error in rds_std"); |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3471 | break; |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 3472 | case FM_TRANS: |
| 3473 | radio->trans_conf.rds_std = ctrl->value; |
| 3474 | retval = hci_set_fm_trans_conf( |
| 3475 | &radio->trans_conf, |
| 3476 | radio->fm_hdev); |
| 3477 | if (retval < 0) |
| 3478 | FMDERR("Error in rds_Std"); |
| 3479 | break; |
| 3480 | default: |
| 3481 | retval = -EINVAL; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3482 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3483 | break; |
| 3484 | case V4L2_CID_PRIVATE_IRIS_RDSON: |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 3485 | switch (radio->mode) { |
| 3486 | case FM_RECV: |
| 3487 | radio->recv_conf.rds_std = ctrl->value; |
| 3488 | retval = hci_set_fm_recv_conf( |
| 3489 | &radio->recv_conf, |
| 3490 | radio->fm_hdev); |
| 3491 | if (retval < 0) |
| 3492 | FMDERR("Error in rds_std"); |
| 3493 | break; |
| 3494 | case FM_TRANS: |
| 3495 | radio->trans_conf.rds_std = ctrl->value; |
| 3496 | retval = hci_set_fm_trans_conf( |
| 3497 | &radio->trans_conf, |
| 3498 | radio->fm_hdev); |
| 3499 | if (retval < 0) |
| 3500 | FMDERR("Error in rds_Std"); |
| 3501 | break; |
| 3502 | default: |
| 3503 | retval = -EINVAL; |
| 3504 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3505 | break; |
| 3506 | case V4L2_CID_PRIVATE_IRIS_RDSGROUP_MASK: |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 3507 | grp_mask = (grp_mask | oda_agt | ctrl->value); |
| 3508 | radio->rds_grp.rds_grp_enable_mask = grp_mask; |
| 3509 | radio->rds_grp.rds_buf_size = 1; |
| 3510 | radio->rds_grp.en_rds_change_filter = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3511 | retval = hci_fm_rds_grp(&radio->rds_grp, radio->fm_hdev); |
Ayaz Ahmad | 8926511 | 2012-10-05 19:39:11 +0530 | [diff] [blame] | 3512 | if (retval < 0) |
| 3513 | FMDERR("error in setting group mask\n"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3514 | break; |
| 3515 | case V4L2_CID_PRIVATE_IRIS_RDSGROUP_PROC: |
| 3516 | rds_grps_proc = radio->g_rds_grp_proc_ps | ctrl->value; |
Srinivasa Rao Uppala | 58273f8 | 2011-08-10 19:07:45 -0700 | [diff] [blame] | 3517 | radio->g_rds_grp_proc_ps = (rds_grps_proc >> RDS_CONFIG_OFFSET); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3518 | retval = hci_fm_rds_grps_process( |
Srinivasa Rao Uppala | 58273f8 | 2011-08-10 19:07:45 -0700 | [diff] [blame] | 3519 | &radio->g_rds_grp_proc_ps, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3520 | radio->fm_hdev); |
| 3521 | break; |
| 3522 | case V4L2_CID_PRIVATE_IRIS_RDSD_BUF: |
| 3523 | radio->rds_grp.rds_buf_size = ctrl->value; |
| 3524 | break; |
| 3525 | case V4L2_CID_PRIVATE_IRIS_PSALL: |
Srinivasa Rao Uppala | 58273f8 | 2011-08-10 19:07:45 -0700 | [diff] [blame] | 3526 | rds_grps_proc = (ctrl->value << RDS_CONFIG_OFFSET); |
| 3527 | radio->g_rds_grp_proc_ps |= rds_grps_proc; |
| 3528 | retval = hci_fm_rds_grps_process( |
| 3529 | &radio->g_rds_grp_proc_ps, |
| 3530 | radio->fm_hdev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3531 | break; |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 3532 | case V4L2_CID_PRIVATE_IRIS_AF_JUMP: |
Srinivasa Rao Uppala | 1da1a24 | 2012-01-11 11:00:10 +0530 | [diff] [blame] | 3533 | /*Clear the current AF jump settings*/ |
| 3534 | radio->g_rds_grp_proc_ps &= ~(1 << RDS_AF_JUMP_OFFSET); |
| 3535 | radio->af_jump_bit = ctrl->value; |
| 3536 | rds_grps_proc = 0x00; |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 3537 | rds_grps_proc = (ctrl->value << RDS_AF_JUMP_OFFSET); |
| 3538 | radio->g_rds_grp_proc_ps |= rds_grps_proc; |
| 3539 | retval = hci_fm_rds_grps_process( |
| 3540 | &radio->g_rds_grp_proc_ps, |
| 3541 | radio->fm_hdev); |
| 3542 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3543 | case V4L2_CID_PRIVATE_IRIS_LP_MODE: |
Srinivasa Rao Uppala | f856ae6 | 2011-10-17 18:43:26 +0530 | [diff] [blame] | 3544 | set_low_power_mode(radio, ctrl->value); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3545 | break; |
| 3546 | case V4L2_CID_PRIVATE_IRIS_ANTENNA: |
| 3547 | temp_val = ctrl->value; |
| 3548 | retval = hci_fm_set_antenna(&temp_val, radio->fm_hdev); |
Srinivasa Rao Uppala | 2f51a97 | 2012-01-23 20:11:13 +0530 | [diff] [blame] | 3549 | if (retval < 0) { |
| 3550 | FMDERR("Set Antenna failed retval = %x", retval); |
| 3551 | return retval; |
| 3552 | } |
| 3553 | radio->g_antenna = ctrl->value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3554 | break; |
| 3555 | case V4L2_CID_RDS_TX_PTY: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3556 | radio->pty = ctrl->value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3557 | break; |
| 3558 | case V4L2_CID_RDS_TX_PI: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3559 | radio->pi = ctrl->value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3560 | break; |
| 3561 | case V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_PS_NAME: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 3562 | tx_ps.ps_control = 0x00; |
| 3563 | retval = radio_hci_request(radio->fm_hdev, hci_trans_ps_req, |
| 3564 | (unsigned long)&tx_ps, RADIO_HCI_TIMEOUT); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3565 | break; |
| 3566 | case V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_RT: |
Srinivasa Rao Uppala | 3c7a8eb | 2011-09-18 09:10:21 +0530 | [diff] [blame] | 3567 | tx_rt.rt_control = 0x00; |
| 3568 | retval = radio_hci_request(radio->fm_hdev, hci_trans_rt_req, |
| 3569 | (unsigned long)&tx_rt, RADIO_HCI_TIMEOUT); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3570 | break; |
| 3571 | case V4L2_CID_PRIVATE_IRIS_TX_SETPSREPEATCOUNT: |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 3572 | radio->ps_repeatcount = ctrl->value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3573 | break; |
| 3574 | case V4L2_CID_TUNE_POWER_LEVEL: |
Venkateshwarlu Domakonda | 71731d5 | 2012-04-04 12:30:51 +0530 | [diff] [blame] | 3575 | if (ctrl->value > FM_TX_PWR_LVL_MAX) |
| 3576 | ctrl->value = FM_TX_PWR_LVL_MAX; |
| 3577 | if (ctrl->value < FM_TX_PWR_LVL_0) |
| 3578 | ctrl->value = FM_TX_PWR_LVL_0; |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 3579 | rd.mode = FM_TX_PHY_CFG_MODE; |
| 3580 | rd.length = FM_TX_PHY_CFG_LEN; |
| 3581 | rd.param_len = 0x00; |
| 3582 | rd.param = 0x00; |
Venkateshwarlu Domakonda | 71731d5 | 2012-04-04 12:30:51 +0530 | [diff] [blame] | 3583 | |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 3584 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
Venkateshwarlu Domakonda | 71731d5 | 2012-04-04 12:30:51 +0530 | [diff] [blame] | 3585 | if (retval < 0) { |
| 3586 | FMDERR("Default data read failed for PHY_CFG %d\n", |
| 3587 | retval); |
| 3588 | break; |
| 3589 | } |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 3590 | memset(&wrd, 0, sizeof(wrd)); |
| 3591 | wrd.mode = FM_TX_PHY_CFG_MODE; |
| 3592 | wrd.length = FM_TX_PHY_CFG_LEN; |
| 3593 | memcpy(&wrd.data, &radio->default_data.data, |
Venkateshwarlu Domakonda | 71731d5 | 2012-04-04 12:30:51 +0530 | [diff] [blame] | 3594 | radio->default_data.ret_data_len); |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 3595 | wrd.data[FM_TX_PWR_GAIN_OFFSET] = |
Venkateshwarlu Domakonda | 71731d5 | 2012-04-04 12:30:51 +0530 | [diff] [blame] | 3596 | (ctrl->value) * FM_TX_PWR_LVL_STEP_SIZE; |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 3597 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
Venkateshwarlu Domakonda | 71731d5 | 2012-04-04 12:30:51 +0530 | [diff] [blame] | 3598 | if (retval < 0) |
| 3599 | FMDERR("Default write failed for PHY_TXGAIN %d\n", |
| 3600 | retval); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3601 | break; |
Srinivasa Rao Uppala | abc8efa | 2011-08-02 14:31:30 -0700 | [diff] [blame] | 3602 | case V4L2_CID_PRIVATE_IRIS_SOFT_MUTE: |
| 3603 | radio->mute_mode.soft_mute = ctrl->value; |
| 3604 | retval = hci_set_fm_mute_mode( |
| 3605 | &radio->mute_mode, |
| 3606 | radio->fm_hdev); |
| 3607 | if (retval < 0) |
| 3608 | FMDERR("Error while setting FM soft mute"" %d\n", |
| 3609 | retval); |
| 3610 | break; |
| 3611 | case V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR: |
| 3612 | radio->riva_data_req.cmd_params.start_addr = ctrl->value; |
| 3613 | break; |
| 3614 | case V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN: |
| 3615 | radio->riva_data_req.cmd_params.length = ctrl->value; |
| 3616 | break; |
| 3617 | case V4L2_CID_PRIVATE_IRIS_RIVA_POKE: |
| 3618 | memcpy(radio->riva_data_req.data, (void *)ctrl->value, |
| 3619 | radio->riva_data_req.cmd_params.length); |
| 3620 | radio->riva_data_req.cmd_params.subopcode = RIVA_POKE_OPCODE; |
| 3621 | retval = hci_poke_data(&radio->riva_data_req , radio->fm_hdev); |
| 3622 | break; |
| 3623 | case V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR: |
| 3624 | radio->ssbi_data_accs.start_addr = ctrl->value; |
| 3625 | break; |
| 3626 | case V4L2_CID_PRIVATE_IRIS_SSBI_POKE: |
| 3627 | radio->ssbi_data_accs.data = ctrl->value; |
| 3628 | retval = hci_ssbi_poke_reg(&radio->ssbi_data_accs , |
| 3629 | radio->fm_hdev); |
| 3630 | break; |
| 3631 | case V4L2_CID_PRIVATE_IRIS_RIVA_PEEK: |
| 3632 | radio->riva_data_req.cmd_params.subopcode = RIVA_PEEK_OPCODE; |
| 3633 | ctrl->value = hci_peek_data(&radio->riva_data_req.cmd_params , |
| 3634 | radio->fm_hdev); |
| 3635 | break; |
| 3636 | case V4L2_CID_PRIVATE_IRIS_SSBI_PEEK: |
| 3637 | radio->ssbi_peek_reg.start_address = ctrl->value; |
| 3638 | hci_ssbi_peek_reg(&radio->ssbi_peek_reg, radio->fm_hdev); |
| 3639 | break; |
Srinivasa Rao Uppala | 0f4098f | 2011-09-06 16:46:28 +0530 | [diff] [blame] | 3640 | case V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS: |
| 3641 | temp_val = ctrl->value; |
| 3642 | hci_read_grp_counters(&temp_val, radio->fm_hdev); |
| 3643 | break; |
| 3644 | case V4L2_CID_PRIVATE_IRIS_HLSI: |
| 3645 | retval = hci_cmd(HCI_FM_GET_RECV_CONF_CMD, |
| 3646 | radio->fm_hdev); |
| 3647 | if (retval) |
| 3648 | break; |
| 3649 | radio->recv_conf.hlsi = ctrl->value; |
| 3650 | retval = hci_set_fm_recv_conf( |
| 3651 | &radio->recv_conf, |
| 3652 | radio->fm_hdev); |
| 3653 | break; |
| 3654 | case V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER: |
| 3655 | temp_val = ctrl->value; |
| 3656 | retval = hci_set_notch_filter(&temp_val, radio->fm_hdev); |
| 3657 | break; |
Srinivasa Rao Uppala | d3184a4 | 2012-01-04 21:18:01 +0530 | [diff] [blame] | 3658 | case V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD: |
| 3659 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 3660 | if (retval < 0) { |
| 3661 | FMDERR("Failed to get chnl det thresholds %d", retval); |
| 3662 | return retval; |
| 3663 | } |
| 3664 | radio->ch_det_threshold.high_th = ctrl->value; |
| 3665 | retval = hci_set_ch_det_thresholds_req(&radio->ch_det_threshold, |
| 3666 | radio->fm_hdev); |
| 3667 | if (retval < 0) { |
| 3668 | FMDERR("Failed to set High det threshold %d ", retval); |
| 3669 | return retval; |
| 3670 | } |
| 3671 | break; |
| 3672 | |
| 3673 | case V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD: |
| 3674 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 3675 | if (retval < 0) { |
| 3676 | FMDERR("Failed to get chnl det thresholds %d", retval); |
| 3677 | return retval; |
| 3678 | } |
| 3679 | radio->ch_det_threshold.low_th = ctrl->value; |
| 3680 | retval = hci_set_ch_det_thresholds_req(&radio->ch_det_threshold, |
| 3681 | radio->fm_hdev); |
| 3682 | if (retval < 0) { |
| 3683 | FMDERR("Failed to Set Low det threshold %d", retval); |
| 3684 | return retval; |
| 3685 | } |
| 3686 | break; |
| 3687 | |
| 3688 | case V4L2_CID_PRIVATE_SINR_THRESHOLD: |
| 3689 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 3690 | if (retval < 0) { |
| 3691 | FMDERR("Failed to get chnl det thresholds %d", retval); |
| 3692 | return retval; |
| 3693 | } |
| 3694 | radio->ch_det_threshold.sinr = ctrl->value; |
| 3695 | retval = hci_set_ch_det_thresholds_req(&radio->ch_det_threshold, |
| 3696 | radio->fm_hdev); |
| 3697 | if (retval < 0) { |
| 3698 | FMDERR("Failed to set SINR threshold %d", retval); |
| 3699 | return retval; |
| 3700 | } |
| 3701 | break; |
| 3702 | |
| 3703 | case V4L2_CID_PRIVATE_SINR_SAMPLES: |
| 3704 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 3705 | if (retval < 0) { |
| 3706 | FMDERR("Failed to get chnl det thresholds %d", retval); |
| 3707 | return retval; |
| 3708 | } |
| 3709 | radio->ch_det_threshold.sinr_samples = ctrl->value; |
| 3710 | retval = hci_set_ch_det_thresholds_req(&radio->ch_det_threshold, |
| 3711 | radio->fm_hdev); |
| 3712 | if (retval < 0) { |
| 3713 | FMDERR("Failed to set SINR samples %d", retval); |
| 3714 | return retval; |
| 3715 | } |
| 3716 | break; |
| 3717 | |
Anantha Krishnan | 61dc15e | 2011-12-06 11:39:02 +0530 | [diff] [blame] | 3718 | case V4L2_CID_PRIVATE_IRIS_SRCH_ALGORITHM: |
Srinivasa Rao Uppala | de0b5d9 | 2011-12-27 18:09:10 +0530 | [diff] [blame] | 3719 | case V4L2_CID_PRIVATE_IRIS_SET_AUDIO_PATH: |
Anantha Krishnan | 61dc15e | 2011-12-06 11:39:02 +0530 | [diff] [blame] | 3720 | /* |
Srinivasa Rao Uppala | de0b5d9 | 2011-12-27 18:09:10 +0530 | [diff] [blame] | 3721 | These private controls are place holders to keep the |
Anantha Krishnan | 61dc15e | 2011-12-06 11:39:02 +0530 | [diff] [blame] | 3722 | driver compatible with changes done in the frameworks |
| 3723 | which are specific to TAVARUA. |
| 3724 | */ |
| 3725 | retval = 0; |
| 3726 | break; |
Anantha Krishnan | f950e32 | 2012-06-06 14:25:49 +0530 | [diff] [blame] | 3727 | case V4L2_CID_PRIVATE_SPUR_FREQ: |
| 3728 | if (radio->spur_table_size >= MAX_SPUR_FREQ_LIMIT) { |
| 3729 | FMDERR("%s: Spur Table Full!\n", __func__); |
| 3730 | retval = -1; |
| 3731 | } else |
| 3732 | radio->spur_data.freq[radio->spur_table_size] = |
| 3733 | ctrl->value; |
| 3734 | break; |
| 3735 | case V4L2_CID_PRIVATE_SPUR_FREQ_RMSSI: |
| 3736 | if (radio->spur_table_size >= MAX_SPUR_FREQ_LIMIT) { |
| 3737 | FMDERR("%s: Spur Table Full!\n", __func__); |
| 3738 | retval = -1; |
| 3739 | } else |
| 3740 | radio->spur_data.rmssi[radio->spur_table_size] = |
| 3741 | ctrl->value; |
| 3742 | break; |
| 3743 | case V4L2_CID_PRIVATE_SPUR_SELECTION: |
| 3744 | if (radio->spur_table_size >= MAX_SPUR_FREQ_LIMIT) { |
| 3745 | FMDERR("%s: Spur Table Full!\n", __func__); |
| 3746 | retval = -1; |
| 3747 | } else { |
| 3748 | radio->spur_data.enable[radio->spur_table_size] = |
| 3749 | ctrl->value; |
| 3750 | radio->spur_table_size++; |
| 3751 | } |
| 3752 | break; |
| 3753 | case V4L2_CID_PRIVATE_UPDATE_SPUR_TABLE: |
| 3754 | update_spur_table(radio); |
| 3755 | break; |
Ayaz Ahmad | 37294ba | 2012-07-10 16:38:11 +0530 | [diff] [blame] | 3756 | case V4L2_CID_PRIVATE_VALID_CHANNEL: |
| 3757 | retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev); |
| 3758 | if (retval < 0) { |
| 3759 | FMDERR("%s: Failed to determine channel's validity\n", |
| 3760 | __func__); |
| 3761 | return retval; |
| 3762 | } else { |
| 3763 | sinr_th = radio->ch_det_threshold.sinr; |
| 3764 | intf_det_low_th = radio->ch_det_threshold.low_th; |
| 3765 | intf_det_high_th = radio->ch_det_threshold.high_th; |
| 3766 | } |
| 3767 | |
| 3768 | retval = hci_cmd(HCI_FM_GET_STATION_PARAM_CMD, radio->fm_hdev); |
| 3769 | if (retval < 0) { |
| 3770 | FMDERR("%s: Failed to determine channel's validity\n", |
| 3771 | __func__); |
| 3772 | return retval; |
| 3773 | } else |
| 3774 | sinr = radio->fm_st_rsp.station_rsp.sinr; |
| 3775 | |
| 3776 | retval = hci_cmd(HCI_FM_STATION_DBG_PARAM_CMD, radio->fm_hdev); |
| 3777 | if (retval < 0) { |
| 3778 | FMDERR("%s: Failed to determine channel's validity\n", |
| 3779 | __func__); |
| 3780 | return retval; |
| 3781 | } else |
| 3782 | intf_det_out = radio->st_dbg_param.in_det_out; |
| 3783 | |
| 3784 | if ((sinr >= sinr_th) && (intf_det_out >= intf_det_low_th) && |
| 3785 | (intf_det_out <= intf_det_high_th)) |
| 3786 | radio->is_station_valid = VALID_CHANNEL; |
| 3787 | else |
| 3788 | radio->is_station_valid = INVALID_CHANNEL; |
| 3789 | break; |
Ayaz Ahmad | db04b0c | 2013-02-01 17:18:34 +0530 | [diff] [blame] | 3790 | case V4L2_CID_PRIVATE_AF_RMSSI_TH: |
| 3791 | rd.mode = FM_RDS_CNFG_MODE; |
| 3792 | rd.length = FM_RDS_CNFG_LEN; |
| 3793 | rd.param_len = 0; |
| 3794 | rd.param = 0; |
| 3795 | |
| 3796 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3797 | if (retval < 0) { |
| 3798 | FMDERR("default data read failed %x", retval); |
| 3799 | return retval; |
| 3800 | } |
| 3801 | wrd.mode = FM_RDS_CNFG_MODE; |
| 3802 | wrd.length = FM_RDS_CNFG_LEN; |
| 3803 | memcpy(&wrd.data, &radio->default_data.data, |
| 3804 | radio->default_data.ret_data_len); |
| 3805 | wrd.data[AF_RMSSI_TH_LSB_OFFSET] = ((ctrl->value) & 255); |
| 3806 | wrd.data[AF_RMSSI_TH_MSB_OFFSET] = ((ctrl->value) >> 8); |
| 3807 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
| 3808 | if (retval < 0) |
| 3809 | FMDERR("set AF jump RMSSI threshold failed\n"); |
| 3810 | break; |
| 3811 | case V4L2_CID_PRIVATE_AF_RMSSI_SAMPLES: |
| 3812 | rd.mode = FM_RDS_CNFG_MODE; |
| 3813 | rd.length = FM_RDS_CNFG_LEN; |
| 3814 | rd.param_len = 0; |
| 3815 | rd.param = 0; |
| 3816 | |
| 3817 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3818 | if (retval < 0) { |
| 3819 | FMDERR("default data read failed %x", retval); |
| 3820 | return retval; |
| 3821 | } |
| 3822 | wrd.mode = FM_RDS_CNFG_MODE; |
| 3823 | wrd.length = FM_RDS_CNFG_LEN; |
| 3824 | memcpy(&wrd.data, &radio->default_data.data, |
| 3825 | radio->default_data.ret_data_len); |
| 3826 | wrd.data[AF_RMSSI_SAMPLES_OFFSET] = ctrl->value; |
| 3827 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
| 3828 | if (retval < 0) |
| 3829 | FMDERR("set AF jump RMSSI Samples failed\n"); |
| 3830 | break; |
| 3831 | case V4L2_CID_PRIVATE_GOOD_CH_RMSSI_TH: |
| 3832 | rd.mode = FM_RX_CONFG_MODE; |
| 3833 | rd.length = FM_RX_CNFG_LEN; |
| 3834 | rd.param_len = 0; |
| 3835 | rd.param = 0; |
| 3836 | |
| 3837 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3838 | if (retval < 0) { |
| 3839 | FMDERR("default data read failed %x", retval); |
| 3840 | return retval; |
| 3841 | } |
| 3842 | wrd.mode = FM_RX_CONFG_MODE; |
| 3843 | wrd.length = FM_RX_CNFG_LEN; |
| 3844 | memcpy(&wrd.data, &radio->default_data.data, |
| 3845 | radio->default_data.ret_data_len); |
| 3846 | wrd.data[GD_CH_RMSSI_TH_OFFSET] = ctrl->value; |
| 3847 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
| 3848 | if (retval < 0) |
| 3849 | FMDERR("set good channel RMSSI th failed\n"); |
| 3850 | break; |
| 3851 | case V4L2_CID_PRIVATE_SRCHALGOTYPE: |
| 3852 | rd.mode = FM_RX_CONFG_MODE; |
| 3853 | rd.length = FM_RX_CNFG_LEN; |
| 3854 | rd.param_len = 0; |
| 3855 | rd.param = 0; |
| 3856 | |
| 3857 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3858 | if (retval < 0) { |
| 3859 | FMDERR("default data read failed %x", retval); |
| 3860 | return retval; |
| 3861 | } |
| 3862 | wrd.mode = FM_RX_CONFG_MODE; |
| 3863 | wrd.length = FM_RX_CNFG_LEN; |
| 3864 | memcpy(&wrd.data, &radio->default_data.data, |
| 3865 | radio->default_data.ret_data_len); |
| 3866 | wrd.data[SRCH_ALGO_TYPE_OFFSET] = ctrl->value; |
| 3867 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
| 3868 | if (retval < 0) |
| 3869 | FMDERR("set Search Algo Type failed\n"); |
| 3870 | break; |
| 3871 | case V4L2_CID_PRIVATE_SINRFIRSTSTAGE: |
| 3872 | rd.mode = FM_RX_CONFG_MODE; |
| 3873 | rd.length = FM_RX_CNFG_LEN; |
| 3874 | rd.param_len = 0; |
| 3875 | rd.param = 0; |
| 3876 | |
| 3877 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3878 | if (retval < 0) { |
| 3879 | FMDERR("default data read failed %x", retval); |
| 3880 | return retval; |
| 3881 | } |
| 3882 | wrd.mode = FM_RX_CONFG_MODE; |
| 3883 | wrd.length = FM_RX_CNFG_LEN; |
| 3884 | memcpy(&wrd.data, &radio->default_data.data, |
| 3885 | radio->default_data.ret_data_len); |
| 3886 | wrd.data[SINRFIRSTSTAGE_OFFSET] = ctrl->value; |
| 3887 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
| 3888 | if (retval < 0) |
| 3889 | FMDERR("set SINR First Stage failed\n"); |
| 3890 | break; |
| 3891 | case V4L2_CID_PRIVATE_RMSSIFIRSTSTAGE: |
| 3892 | rd.mode = FM_RX_CONFG_MODE; |
| 3893 | rd.length = FM_RX_CNFG_LEN; |
| 3894 | rd.param_len = 0; |
| 3895 | rd.param = 0; |
| 3896 | |
| 3897 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3898 | if (retval < 0) { |
| 3899 | FMDERR("default data read failed %x", retval); |
| 3900 | return retval; |
| 3901 | } |
| 3902 | wrd.mode = FM_RX_CONFG_MODE; |
| 3903 | wrd.length = FM_RX_CNFG_LEN; |
| 3904 | memcpy(&wrd.data, &radio->default_data.data, |
| 3905 | radio->default_data.ret_data_len); |
| 3906 | wrd.data[RMSSIFIRSTSTAGE_OFFSET] = ctrl->value; |
| 3907 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
| 3908 | if (retval < 0) |
| 3909 | FMDERR("set RMSSI First Stage failed\n"); |
| 3910 | break; |
| 3911 | case V4L2_CID_PRIVATE_CF0TH12: |
| 3912 | rd.mode = FM_RX_CONFG_MODE; |
| 3913 | rd.length = FM_RX_CNFG_LEN; |
| 3914 | rd.param_len = 0; |
| 3915 | rd.param = 0; |
| 3916 | |
| 3917 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3918 | if (retval < 0) { |
| 3919 | FMDERR("default data read failed %x", retval); |
| 3920 | return retval; |
| 3921 | } |
| 3922 | wrd.mode = FM_RX_CONFG_MODE; |
| 3923 | wrd.length = FM_RX_CNFG_LEN; |
| 3924 | memcpy(&wrd.data, &radio->default_data.data, |
| 3925 | radio->default_data.ret_data_len); |
| 3926 | wrd.data[CF0TH12_BYTE1_OFFSET] = (ctrl->value & 255); |
| 3927 | wrd.data[CF0TH12_BYTE2_OFFSET] = ((ctrl->value >> 8) & 255); |
| 3928 | wrd.data[CF0TH12_BYTE3_OFFSET] = ((ctrl->value >> 16) & 255); |
| 3929 | wrd.data[CF0TH12_BYTE4_OFFSET] = ((ctrl->value >> 24) & 255); |
| 3930 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
| 3931 | if (retval < 0) |
| 3932 | FMDERR("set CF0 Threshold failed\n"); |
| 3933 | break; |
Venkateshwarlu Domakonda | 70e4716 | 2013-04-30 14:12:13 +0530 | [diff] [blame] | 3934 | case V4L2_CID_PRIVATE_RXREPEATCOUNT: |
| 3935 | rd.mode = RDS_PS0_XFR_MODE; |
| 3936 | rd.length = RDS_PS0_LEN; |
| 3937 | rd.param_len = 0; |
| 3938 | rd.param = 0; |
| 3939 | |
| 3940 | retval = hci_def_data_read(&rd, radio->fm_hdev); |
| 3941 | if (retval < 0) { |
| 3942 | FMDERR("default data read failed for PS0 %x", retval); |
| 3943 | return retval; |
| 3944 | } |
| 3945 | wrd.mode = RDS_PS0_XFR_MODE; |
| 3946 | wrd.length = RDS_PS0_LEN; |
| 3947 | memcpy(&wrd.data, &radio->default_data.data, |
| 3948 | radio->default_data.ret_data_len); |
| 3949 | wrd.data[RX_REPEATE_BYTE_OFFSET] = ctrl->value; |
| 3950 | |
| 3951 | retval = hci_def_data_write(&wrd, radio->fm_hdev); |
| 3952 | if (retval < 0) |
| 3953 | FMDERR("set RxRePeat count failed\n"); |
| 3954 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3955 | default: |
| 3956 | retval = -EINVAL; |
| 3957 | } |
| 3958 | return retval; |
| 3959 | } |
| 3960 | |
Anantha Krishnan | f950e32 | 2012-06-06 14:25:49 +0530 | [diff] [blame] | 3961 | static int update_spur_table(struct iris_device *radio) |
| 3962 | { |
| 3963 | struct hci_fm_def_data_wr_req default_data; |
| 3964 | int len = 0, index = 0, offset = 0, i = 0; |
| 3965 | int retval = 0, temp = 0, cnt = 0; |
| 3966 | |
| 3967 | memset(&default_data, 0, sizeof(default_data)); |
| 3968 | |
| 3969 | /* Pass the mode of SPUR_CLK */ |
| 3970 | default_data.mode = CKK_SPUR; |
| 3971 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 3972 | if (radio == NULL) { |
| 3973 | FMDERR(":radio is null"); |
| 3974 | return -EINVAL; |
| 3975 | } |
Anantha Krishnan | f950e32 | 2012-06-06 14:25:49 +0530 | [diff] [blame] | 3976 | temp = radio->spur_table_size; |
| 3977 | for (cnt = 0; cnt < (temp / 5); cnt++) { |
| 3978 | offset = 0; |
| 3979 | /* |
| 3980 | * Program the spur entries in spur table in following order: |
| 3981 | * Spur index |
| 3982 | * Length of the spur data |
| 3983 | * Spur Data: |
| 3984 | * MSB of the spur frequency |
| 3985 | * LSB of the spur frequency |
| 3986 | * Enable/Disable the spur frequency |
| 3987 | * RMSSI value of the spur frequency |
| 3988 | */ |
| 3989 | default_data.data[offset++] = ENTRY_0 + cnt; |
| 3990 | for (i = 0; i < SPUR_ENTRIES_PER_ID; i++) { |
| 3991 | default_data.data[offset++] = GET_FREQ(COMPUTE_SPUR( |
| 3992 | radio->spur_data.freq[index]), 0); |
| 3993 | default_data.data[offset++] = GET_FREQ(COMPUTE_SPUR( |
| 3994 | radio->spur_data.freq[index]), 1); |
| 3995 | default_data.data[offset++] = |
| 3996 | radio->spur_data.enable[index]; |
| 3997 | default_data.data[offset++] = |
| 3998 | radio->spur_data.rmssi[index]; |
| 3999 | index++; |
| 4000 | } |
| 4001 | len = (SPUR_ENTRIES_PER_ID * SPUR_DATA_SIZE); |
| 4002 | default_data.length = (len + 1); |
| 4003 | retval = hci_def_data_write(&default_data, radio->fm_hdev); |
| 4004 | if (retval < 0) { |
| 4005 | FMDBG("%s: Failed to configure entries for ID : %d\n", |
| 4006 | __func__, default_data.data[0]); |
| 4007 | return retval; |
| 4008 | } |
| 4009 | } |
| 4010 | |
| 4011 | /* Compute balance SPUR frequencies to be programmed */ |
| 4012 | temp %= SPUR_ENTRIES_PER_ID; |
| 4013 | if (temp > 0) { |
| 4014 | offset = 0; |
| 4015 | default_data.data[offset++] = (radio->spur_table_size / 5); |
| 4016 | for (i = 0; i < temp; i++) { |
| 4017 | default_data.data[offset++] = GET_FREQ(COMPUTE_SPUR( |
| 4018 | radio->spur_data.freq[index]), 0); |
| 4019 | default_data.data[offset++] = GET_FREQ(COMPUTE_SPUR( |
| 4020 | radio->spur_data.freq[index]), 1); |
| 4021 | default_data.data[offset++] = |
| 4022 | radio->spur_data.enable[index]; |
| 4023 | default_data.data[offset++] = |
| 4024 | radio->spur_data.rmssi[index]; |
| 4025 | index++; |
| 4026 | } |
| 4027 | len = (temp * SPUR_DATA_SIZE); |
| 4028 | default_data.length = (len + 1); |
| 4029 | retval = hci_def_data_write(&default_data, radio->fm_hdev); |
| 4030 | if (retval < 0) { |
| 4031 | FMDERR("%s: Failed to configure entries for ID : %d\n", |
| 4032 | __func__, default_data.data[0]); |
| 4033 | return retval; |
| 4034 | } |
| 4035 | } |
| 4036 | |
| 4037 | return retval; |
| 4038 | } |
| 4039 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4040 | static int iris_vidioc_g_tuner(struct file *file, void *priv, |
| 4041 | struct v4l2_tuner *tuner) |
| 4042 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4043 | int retval; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 4044 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4045 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 4046 | if (radio == NULL) { |
| 4047 | FMDERR(":radio is null"); |
| 4048 | return -EINVAL; |
| 4049 | } |
Srinivasa Rao Uppala | d2ec468 | 2011-12-12 14:02:15 +0530 | [diff] [blame] | 4050 | if (tuner->index > 0) { |
| 4051 | FMDERR("Invalid Tuner Index"); |
| 4052 | return -EINVAL; |
| 4053 | } |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 4054 | if (radio->mode == FM_RECV) { |
| 4055 | retval = hci_cmd(HCI_FM_GET_STATION_PARAM_CMD, radio->fm_hdev); |
| 4056 | if (retval < 0) { |
| 4057 | FMDERR("Failed to Get station params"); |
| 4058 | return retval; |
| 4059 | } |
| 4060 | tuner->type = V4L2_TUNER_RADIO; |
| 4061 | tuner->rangelow = |
| 4062 | radio->recv_conf.band_low_limit * TUNE_PARAM; |
| 4063 | tuner->rangehigh = |
| 4064 | radio->recv_conf.band_high_limit * TUNE_PARAM; |
| 4065 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; |
| 4066 | tuner->capability = V4L2_TUNER_CAP_LOW; |
| 4067 | tuner->signal = radio->fm_st_rsp.station_rsp.rssi; |
| 4068 | tuner->audmode = radio->fm_st_rsp.station_rsp.stereo_prg; |
| 4069 | tuner->afc = 0; |
| 4070 | } else if (radio->mode == FM_TRANS) { |
| 4071 | retval = hci_cmd(HCI_FM_GET_TX_CONFIG, radio->fm_hdev); |
| 4072 | if (retval < 0) { |
| 4073 | FMDERR("get Tx config failed %d\n", retval); |
| 4074 | return retval; |
| 4075 | } else { |
| 4076 | tuner->type = V4L2_TUNER_RADIO; |
| 4077 | tuner->rangelow = |
| 4078 | radio->trans_conf.band_low_limit * TUNE_PARAM; |
| 4079 | tuner->rangehigh = |
| 4080 | radio->trans_conf.band_high_limit * TUNE_PARAM; |
| 4081 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4082 | |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 4083 | } else |
| 4084 | return -EINVAL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4085 | return 0; |
| 4086 | } |
| 4087 | |
| 4088 | static int iris_vidioc_s_tuner(struct file *file, void *priv, |
| 4089 | struct v4l2_tuner *tuner) |
| 4090 | { |
| 4091 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 4092 | int retval = 0; |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 4093 | |
| 4094 | if (radio == NULL) { |
| 4095 | FMDERR(":radio is null"); |
| 4096 | return -EINVAL; |
| 4097 | } |
| 4098 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4099 | if (tuner->index > 0) |
| 4100 | return -EINVAL; |
| 4101 | |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 4102 | if (radio->mode == FM_RECV) { |
| 4103 | radio->recv_conf.band_low_limit = tuner->rangelow / TUNE_PARAM; |
| 4104 | radio->recv_conf.band_high_limit = |
| 4105 | tuner->rangehigh / TUNE_PARAM; |
| 4106 | if (tuner->audmode == V4L2_TUNER_MODE_MONO) { |
| 4107 | radio->stereo_mode.stereo_mode = 0x01; |
| 4108 | retval = hci_set_fm_stereo_mode( |
| 4109 | &radio->stereo_mode, |
| 4110 | radio->fm_hdev); |
| 4111 | } else { |
| 4112 | radio->stereo_mode.stereo_mode = 0x00; |
| 4113 | retval = hci_set_fm_stereo_mode( |
| 4114 | &radio->stereo_mode, |
| 4115 | radio->fm_hdev); |
| 4116 | } |
| 4117 | if (retval < 0) |
| 4118 | FMDERR(": set tuner failed with %d\n", retval); |
| 4119 | return retval; |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 4120 | } else if (radio->mode == FM_TRANS) { |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 4121 | radio->trans_conf.band_low_limit = |
| 4122 | tuner->rangelow / TUNE_PARAM; |
| 4123 | radio->trans_conf.band_high_limit = |
| 4124 | tuner->rangehigh / TUNE_PARAM; |
Srinivasa Rao Uppala | c5320c2 | 2011-11-28 14:28:51 +0530 | [diff] [blame] | 4125 | } else |
| 4126 | return -EINVAL; |
Ankur Nandwani | d928d54 | 2011-08-11 13:15:41 -0700 | [diff] [blame] | 4127 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4128 | return retval; |
| 4129 | } |
| 4130 | |
| 4131 | static int iris_vidioc_g_frequency(struct file *file, void *priv, |
| 4132 | struct v4l2_frequency *freq) |
| 4133 | { |
| 4134 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
Srinivasa Rao Uppala | d2ec468 | 2011-12-12 14:02:15 +0530 | [diff] [blame] | 4135 | if ((freq != NULL) && (radio != NULL)) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4136 | freq->frequency = |
| 4137 | radio->fm_st_rsp.station_rsp.station_freq * TUNE_PARAM; |
Srinivasa Rao Uppala | d2ec468 | 2011-12-12 14:02:15 +0530 | [diff] [blame] | 4138 | } else |
| 4139 | return -EINVAL; |
| 4140 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4141 | } |
| 4142 | |
| 4143 | static int iris_vidioc_s_frequency(struct file *file, void *priv, |
| 4144 | struct v4l2_frequency *freq) |
| 4145 | { |
| 4146 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
| 4147 | int retval = -1; |
| 4148 | freq->frequency = freq->frequency / TUNE_PARAM; |
| 4149 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 4150 | if (radio == NULL) { |
| 4151 | FMDERR(":radio is null"); |
| 4152 | return -EINVAL; |
| 4153 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4154 | if (freq->type != V4L2_TUNER_RADIO) |
| 4155 | return -EINVAL; |
| 4156 | |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 4157 | /* We turn off RDS prior to tuning to a new station. |
| 4158 | because of a bug in SoC which prevents tuning |
| 4159 | during RDS transmission. |
| 4160 | */ |
| 4161 | if (radio->mode == FM_TRANS |
| 4162 | && (radio->trans_conf.rds_std == 0 || |
| 4163 | radio->trans_conf.rds_std == 1)) { |
| 4164 | radio->prev_trans_rds = radio->trans_conf.rds_std; |
| 4165 | radio->trans_conf.rds_std = 2; |
| 4166 | hci_set_fm_trans_conf(&radio->trans_conf, |
| 4167 | radio->fm_hdev); |
| 4168 | } |
| 4169 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4170 | retval = iris_set_freq(radio, freq->frequency); |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 4171 | |
| 4172 | if (radio->mode == FM_TRANS |
| 4173 | && radio->trans_conf.rds_std == 2 |
| 4174 | && (radio->prev_trans_rds == 1 |
| 4175 | || radio->prev_trans_rds == 0)) { |
| 4176 | radio->trans_conf.rds_std = radio->prev_trans_rds; |
| 4177 | hci_set_fm_trans_conf(&radio->trans_conf, |
| 4178 | radio->fm_hdev); |
| 4179 | } |
| 4180 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4181 | if (retval < 0) |
| 4182 | FMDERR(" set frequency failed with %d\n", retval); |
| 4183 | return retval; |
| 4184 | } |
| 4185 | |
Venkateshwarlu Domakonda | 4a15ec7 | 2013-02-28 18:03:36 +0530 | [diff] [blame] | 4186 | static int iris_fops_release(struct file *file) |
| 4187 | { |
| 4188 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
| 4189 | int retval = 0; |
| 4190 | |
| 4191 | FMDBG("Enter %s ", __func__); |
| 4192 | if (radio == NULL) |
| 4193 | return -EINVAL; |
| 4194 | |
| 4195 | if (radio->mode == FM_OFF) |
| 4196 | return 0; |
| 4197 | |
Venkateshwarlu Domakonda | b750fba | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 4198 | if (radio->mode == FM_RECV) { |
| 4199 | radio->mode = FM_OFF; |
Venkateshwarlu Domakonda | 4a15ec7 | 2013-02-28 18:03:36 +0530 | [diff] [blame] | 4200 | retval = hci_cmd(HCI_FM_DISABLE_RECV_CMD, |
| 4201 | radio->fm_hdev); |
Venkateshwarlu Domakonda | b750fba | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 4202 | } else if (radio->mode == FM_TRANS) { |
| 4203 | radio->mode = FM_OFF; |
Venkateshwarlu Domakonda | 4a15ec7 | 2013-02-28 18:03:36 +0530 | [diff] [blame] | 4204 | retval = hci_cmd(HCI_FM_DISABLE_TRANS_CMD, |
| 4205 | radio->fm_hdev); |
Venkateshwarlu Domakonda | b750fba | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 4206 | } |
Venkateshwarlu Domakonda | 4a15ec7 | 2013-02-28 18:03:36 +0530 | [diff] [blame] | 4207 | if (retval < 0) |
| 4208 | FMDERR("Err on disable FM %d\n", retval); |
| 4209 | |
Venkateshwarlu Domakonda | 4a15ec7 | 2013-02-28 18:03:36 +0530 | [diff] [blame] | 4210 | return retval; |
| 4211 | } |
| 4212 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4213 | static int iris_vidioc_dqbuf(struct file *file, void *priv, |
| 4214 | struct v4l2_buffer *buffer) |
| 4215 | { |
| 4216 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
Venkateshwarlu Domakonda | 7f095c4 | 2012-05-30 15:31:38 +0530 | [diff] [blame] | 4217 | enum iris_buf_t buf_type = -1; |
| 4218 | unsigned char buf_fifo[STD_BUF_SIZE] = {0}; |
| 4219 | struct kfifo *data_fifo = NULL; |
| 4220 | unsigned char *buf = NULL; |
| 4221 | unsigned int len = 0, retval = -1; |
| 4222 | |
| 4223 | if ((radio == NULL) || (buffer == NULL)) { |
| 4224 | FMDERR("radio/buffer is NULL\n"); |
| 4225 | return -ENXIO; |
| 4226 | } |
| 4227 | buf_type = buffer->index; |
| 4228 | buf = (unsigned char *)buffer->m.userptr; |
| 4229 | len = buffer->length; |
| 4230 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4231 | if ((buf_type < IRIS_BUF_MAX) && (buf_type >= 0)) { |
| 4232 | data_fifo = &radio->data_buf[buf_type]; |
| 4233 | if (buf_type == IRIS_BUF_EVENTS) |
| 4234 | if (wait_event_interruptible(radio->event_queue, |
| 4235 | kfifo_len(data_fifo)) < 0) |
| 4236 | return -EINTR; |
| 4237 | } else { |
| 4238 | FMDERR("invalid buffer type\n"); |
| 4239 | return -EINVAL; |
| 4240 | } |
Venkateshwarlu Domakonda | 7f095c4 | 2012-05-30 15:31:38 +0530 | [diff] [blame] | 4241 | if (len <= STD_BUF_SIZE) { |
| 4242 | buffer->bytesused = kfifo_out_locked(data_fifo, &buf_fifo[0], |
| 4243 | len, &radio->buf_lock[buf_type]); |
| 4244 | } else { |
| 4245 | FMDERR("kfifo_out_locked can not use len more than 128\n"); |
| 4246 | return -EINVAL; |
| 4247 | } |
| 4248 | retval = copy_to_user(buf, &buf_fifo[0], buffer->bytesused); |
| 4249 | if (retval > 0) { |
| 4250 | FMDERR("Failed to copy %d bytes of data\n", retval); |
| 4251 | return -EAGAIN; |
| 4252 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4253 | |
Venkateshwarlu Domakonda | 7f095c4 | 2012-05-30 15:31:38 +0530 | [diff] [blame] | 4254 | return retval; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4255 | } |
| 4256 | |
| 4257 | static int iris_vidioc_g_fmt_type_private(struct file *file, void *priv, |
| 4258 | struct v4l2_format *f) |
| 4259 | { |
| 4260 | return 0; |
| 4261 | |
| 4262 | } |
| 4263 | |
| 4264 | static int iris_vidioc_s_hw_freq_seek(struct file *file, void *priv, |
| 4265 | struct v4l2_hw_freq_seek *seek) |
| 4266 | { |
| 4267 | struct iris_device *radio = video_get_drvdata(video_devdata(file)); |
Anantha Krishnan | d7b5a77 | 2012-04-30 04:21:03 -0700 | [diff] [blame] | 4268 | int dir; |
| 4269 | if (seek->seek_upward) |
| 4270 | dir = SRCH_DIR_UP; |
| 4271 | else |
| 4272 | dir = SRCH_DIR_DOWN; |
| 4273 | return iris_search(radio, CTRL_ON, dir); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4274 | } |
| 4275 | |
| 4276 | static int iris_vidioc_querycap(struct file *file, void *priv, |
| 4277 | struct v4l2_capability *capability) |
| 4278 | { |
| 4279 | struct iris_device *radio; |
| 4280 | radio = video_get_drvdata(video_devdata(file)); |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 4281 | |
| 4282 | if (radio == NULL) { |
| 4283 | FMDERR(":radio is null"); |
| 4284 | return -EINVAL; |
| 4285 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4286 | strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver)); |
| 4287 | strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card)); |
Venkateshwarlu Domakonda | c48f59d | 2013-07-23 16:55:04 +0530 | [diff] [blame] | 4288 | capability->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4289 | radio->g_cap = capability; |
| 4290 | return 0; |
| 4291 | } |
| 4292 | |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 4293 | static int initialise_recv(struct iris_device *radio) |
| 4294 | { |
| 4295 | int retval; |
| 4296 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 4297 | if (radio == NULL) { |
| 4298 | FMDERR(":radio is null"); |
| 4299 | return -EINVAL; |
| 4300 | } |
| 4301 | |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 4302 | radio->mute_mode.soft_mute = CTRL_ON; |
| 4303 | retval = hci_set_fm_mute_mode(&radio->mute_mode, |
| 4304 | radio->fm_hdev); |
| 4305 | |
| 4306 | if (retval < 0) { |
| 4307 | FMDERR("Failed to enable Smute\n"); |
| 4308 | return retval; |
| 4309 | } |
| 4310 | |
| 4311 | radio->stereo_mode.stereo_mode = CTRL_OFF; |
Sheng Fang | 8ec3c6f | 2013-08-12 14:09:14 +0800 | [diff] [blame] | 4312 | radio->stereo_mode.sig_blend = sig_blend; |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 4313 | radio->stereo_mode.intf_blend = CTRL_ON; |
| 4314 | radio->stereo_mode.most_switch = CTRL_ON; |
| 4315 | retval = hci_set_fm_stereo_mode(&radio->stereo_mode, |
| 4316 | radio->fm_hdev); |
| 4317 | |
| 4318 | if (retval < 0) { |
| 4319 | FMDERR("Failed to set stereo mode\n"); |
| 4320 | return retval; |
| 4321 | } |
| 4322 | |
| 4323 | radio->event_mask = SIG_LEVEL_INTR | RDS_SYNC_INTR | AUDIO_CTRL_INTR; |
| 4324 | retval = hci_conf_event_mask(&radio->event_mask, radio->fm_hdev); |
| 4325 | if (retval < 0) { |
| 4326 | FMDERR("Enable Async events failed"); |
| 4327 | return retval; |
| 4328 | } |
| 4329 | |
| 4330 | retval = hci_cmd(HCI_FM_GET_RECV_CONF_CMD, radio->fm_hdev); |
| 4331 | if (retval < 0) |
| 4332 | FMDERR("Failed to get the Recv Config\n"); |
| 4333 | return retval; |
| 4334 | } |
| 4335 | |
| 4336 | static int initialise_trans(struct iris_device *radio) |
| 4337 | { |
| 4338 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 4339 | int retval; |
| 4340 | |
| 4341 | if (radio == NULL) { |
| 4342 | FMDERR(":radio is null"); |
| 4343 | return -EINVAL; |
| 4344 | } |
| 4345 | |
| 4346 | retval = hci_cmd(HCI_FM_GET_TX_CONFIG, radio->fm_hdev); |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 4347 | if (retval < 0) |
| 4348 | FMDERR("get frequency failed %d\n", retval); |
| 4349 | |
| 4350 | return retval; |
| 4351 | } |
| 4352 | |
| 4353 | static int is_enable_rx_possible(struct iris_device *radio) |
| 4354 | { |
| 4355 | int retval = 1; |
| 4356 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 4357 | if (radio == NULL) { |
| 4358 | FMDERR(":radio is null"); |
| 4359 | return -EINVAL; |
| 4360 | } |
| 4361 | |
Ayaz Ahmad | 64b1e47 | 2013-06-04 15:19:56 +0530 | [diff] [blame] | 4362 | if (radio->mode == FM_OFF || radio->mode == FM_RECV) |
| 4363 | retval = 0; |
| 4364 | |
| 4365 | return retval; |
| 4366 | } |
| 4367 | |
| 4368 | static int is_enable_tx_possible(struct iris_device *radio) |
| 4369 | { |
| 4370 | int retval = 1; |
| 4371 | |
| 4372 | if (radio->mode == FM_OFF || radio->mode == FM_TRANS) |
| 4373 | retval = 0; |
| 4374 | |
| 4375 | return retval; |
| 4376 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4377 | |
| 4378 | static const struct v4l2_ioctl_ops iris_ioctl_ops = { |
| 4379 | .vidioc_querycap = iris_vidioc_querycap, |
| 4380 | .vidioc_queryctrl = iris_vidioc_queryctrl, |
| 4381 | .vidioc_g_ctrl = iris_vidioc_g_ctrl, |
| 4382 | .vidioc_s_ctrl = iris_vidioc_s_ctrl, |
| 4383 | .vidioc_g_tuner = iris_vidioc_g_tuner, |
| 4384 | .vidioc_s_tuner = iris_vidioc_s_tuner, |
| 4385 | .vidioc_g_frequency = iris_vidioc_g_frequency, |
| 4386 | .vidioc_s_frequency = iris_vidioc_s_frequency, |
| 4387 | .vidioc_s_hw_freq_seek = iris_vidioc_s_hw_freq_seek, |
| 4388 | .vidioc_dqbuf = iris_vidioc_dqbuf, |
| 4389 | .vidioc_g_fmt_type_private = iris_vidioc_g_fmt_type_private, |
| 4390 | .vidioc_s_ext_ctrls = iris_vidioc_s_ext_ctrls, |
Venkateshwarlu Domakonda | 787af69 | 2011-10-14 21:23:03 +0530 | [diff] [blame] | 4391 | .vidioc_g_ext_ctrls = iris_vidioc_g_ext_ctrls, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4392 | }; |
| 4393 | |
| 4394 | static const struct v4l2_file_operations iris_fops = { |
| 4395 | .owner = THIS_MODULE, |
| 4396 | .unlocked_ioctl = video_ioctl2, |
Venkateshwarlu Domakonda | 4a15ec7 | 2013-02-28 18:03:36 +0530 | [diff] [blame] | 4397 | .release = iris_fops_release, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4398 | }; |
| 4399 | |
| 4400 | static struct video_device iris_viddev_template = { |
| 4401 | .fops = &iris_fops, |
| 4402 | .ioctl_ops = &iris_ioctl_ops, |
| 4403 | .name = DRIVER_NAME, |
| 4404 | .release = video_device_release, |
| 4405 | }; |
| 4406 | |
| 4407 | static struct video_device *video_get_dev(void) |
| 4408 | { |
| 4409 | return priv_videodev; |
| 4410 | } |
| 4411 | |
| 4412 | static int __init iris_probe(struct platform_device *pdev) |
| 4413 | { |
| 4414 | struct iris_device *radio; |
| 4415 | int retval; |
| 4416 | int radio_nr = -1; |
| 4417 | int i; |
| 4418 | |
| 4419 | if (!pdev) { |
| 4420 | FMDERR(": pdev is null\n"); |
| 4421 | return -ENOMEM; |
| 4422 | } |
| 4423 | |
| 4424 | radio = kzalloc(sizeof(struct iris_device), GFP_KERNEL); |
| 4425 | if (!radio) { |
| 4426 | FMDERR(": Could not allocate radio device\n"); |
| 4427 | return -ENOMEM; |
| 4428 | } |
| 4429 | |
| 4430 | radio->dev = &pdev->dev; |
| 4431 | platform_set_drvdata(pdev, radio); |
| 4432 | |
| 4433 | radio->videodev = video_device_alloc(); |
| 4434 | if (!radio->videodev) { |
| 4435 | FMDERR(": Could not allocate V4L device\n"); |
| 4436 | kfree(radio); |
| 4437 | return -ENOMEM; |
| 4438 | } |
| 4439 | |
| 4440 | memcpy(radio->videodev, &iris_viddev_template, |
| 4441 | sizeof(iris_viddev_template)); |
| 4442 | |
| 4443 | for (i = 0; i < IRIS_BUF_MAX; i++) { |
| 4444 | int kfifo_alloc_rc = 0; |
| 4445 | spin_lock_init(&radio->buf_lock[i]); |
| 4446 | |
Srinivasa Rao Uppala | 6cc0e32 | 2011-08-12 10:54:48 -0700 | [diff] [blame] | 4447 | if ((i == IRIS_BUF_RAW_RDS) || (i == IRIS_BUF_PEEK)) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4448 | kfifo_alloc_rc = kfifo_alloc(&radio->data_buf[i], |
| 4449 | rds_buf*3, GFP_KERNEL); |
Srinivasa Rao Uppala | 6983984 | 2012-01-13 18:36:12 +0530 | [diff] [blame] | 4450 | else if ((i == IRIS_BUF_CAL_DATA) || (i == IRIS_BUF_RT_RDS)) |
Venkateshwarlu Domakonda | 3a0b75d | 2011-11-23 17:03:27 +0530 | [diff] [blame] | 4451 | kfifo_alloc_rc = kfifo_alloc(&radio->data_buf[i], |
| 4452 | STD_BUF_SIZE*2, GFP_KERNEL); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4453 | else |
| 4454 | kfifo_alloc_rc = kfifo_alloc(&radio->data_buf[i], |
| 4455 | STD_BUF_SIZE, GFP_KERNEL); |
| 4456 | |
| 4457 | if (kfifo_alloc_rc != 0) { |
| 4458 | FMDERR("failed allocating buffers %d\n", |
| 4459 | kfifo_alloc_rc); |
| 4460 | for (; i > -1; i--) { |
| 4461 | kfifo_free(&radio->data_buf[i]); |
| 4462 | kfree(radio); |
| 4463 | return -ENOMEM; |
| 4464 | } |
| 4465 | } |
| 4466 | } |
| 4467 | |
| 4468 | mutex_init(&radio->lock); |
| 4469 | init_completion(&radio->sync_xfr_start); |
| 4470 | radio->tune_req = 0; |
Ankur Nandwani | 8f972e5 | 2011-08-24 11:48:32 -0700 | [diff] [blame] | 4471 | radio->prev_trans_rds = 2; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4472 | init_waitqueue_head(&radio->event_queue); |
| 4473 | init_waitqueue_head(&radio->read_queue); |
| 4474 | |
| 4475 | video_set_drvdata(radio->videodev, radio); |
| 4476 | |
| 4477 | if (NULL == video_get_drvdata(radio->videodev)) |
| 4478 | FMDERR(": video_get_drvdata failed\n"); |
| 4479 | |
| 4480 | retval = video_register_device(radio->videodev, VFL_TYPE_RADIO, |
| 4481 | radio_nr); |
| 4482 | if (retval) { |
| 4483 | FMDERR(": Could not register video device\n"); |
| 4484 | video_device_release(radio->videodev); |
| 4485 | for (; i > -1; i--) |
| 4486 | kfifo_free(&radio->data_buf[i]); |
| 4487 | kfree(radio); |
| 4488 | return retval; |
| 4489 | } else { |
| 4490 | priv_videodev = kzalloc(sizeof(struct video_device), |
| 4491 | GFP_KERNEL); |
| 4492 | memcpy(priv_videodev, radio->videodev, |
| 4493 | sizeof(struct video_device)); |
| 4494 | } |
| 4495 | return 0; |
| 4496 | } |
| 4497 | |
| 4498 | |
| 4499 | static int __devexit iris_remove(struct platform_device *pdev) |
| 4500 | { |
| 4501 | int i; |
| 4502 | struct iris_device *radio = platform_get_drvdata(pdev); |
| 4503 | |
Ayaz Ahmad | 5317757 | 2013-10-09 16:20:40 +0530 | [diff] [blame^] | 4504 | if (radio == NULL) { |
| 4505 | FMDERR(":radio is null"); |
| 4506 | return -EINVAL; |
| 4507 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4508 | video_unregister_device(radio->videodev); |
| 4509 | |
| 4510 | for (i = 0; i < IRIS_BUF_MAX; i++) |
| 4511 | kfifo_free(&radio->data_buf[i]); |
| 4512 | |
| 4513 | kfree(radio); |
| 4514 | |
| 4515 | platform_set_drvdata(pdev, NULL); |
| 4516 | |
| 4517 | return 0; |
| 4518 | } |
| 4519 | |
Venkateshwarlu Domakonda | 54ec325 | 2013-02-18 21:25:57 +0530 | [diff] [blame] | 4520 | static const struct of_device_id iris_fm_match[] = { |
| 4521 | {.compatible = "qcom,iris_fm"}, |
| 4522 | {} |
| 4523 | }; |
| 4524 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4525 | static struct platform_driver iris_driver = { |
| 4526 | .driver = { |
| 4527 | .owner = THIS_MODULE, |
| 4528 | .name = "iris_fm", |
Venkateshwarlu Domakonda | 54ec325 | 2013-02-18 21:25:57 +0530 | [diff] [blame] | 4529 | .of_match_table = iris_fm_match, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 4530 | }, |
| 4531 | .remove = __devexit_p(iris_remove), |
| 4532 | }; |
| 4533 | |
| 4534 | static int __init iris_radio_init(void) |
| 4535 | { |
| 4536 | return platform_driver_probe(&iris_driver, iris_probe); |
| 4537 | } |
| 4538 | module_init(iris_radio_init); |
| 4539 | |
| 4540 | static void __exit iris_radio_exit(void) |
| 4541 | { |
| 4542 | platform_driver_unregister(&iris_driver); |
| 4543 | } |
| 4544 | module_exit(iris_radio_exit); |
| 4545 | |
| 4546 | MODULE_LICENSE("GPL v2"); |
| 4547 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 4548 | MODULE_DESCRIPTION(DRIVER_DESC); |