radio: iris: Shutdown the FM Radio gracefully

Abrupt killing of FM process causes FM Radio not to be turned off properly
and results in audio getting routed to the output devices.
Implemented the release function which takes care of shutting down the
FM Radio in such scenarios.

CRs-Fixed: 456512
Change-Id: I57d0ef59c1fa4f844e794f1adb4f42ea929c7710
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
radio: iris: Allow user to set number of stations

Maximum number of stations to be searched passed from application
is not passed to FM Soc

Set max number of stations to be searched passed from framework
instead of always setting number of stations to zero

(cherry picked from commit 7ba5c1ccceac56a2c4de59d379af68289f5726d4)

Change-Id: Ib1d213be7ee9eca9a9e9f71c9595d277b1be8c14
CRs-Fixed: 421945
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio: iris: Add synchronize mechanism to handle multiple command requests

Used mutex to synchronize the command requests.

Change-Id: Ie58b996bbc76b36095020556a2046b7aa5c351fa
CRs-Fixed: 448591
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
radio: iris: Added IOCTLS to get/set AF Jump, Search Thresholds

Implement ioctl to get/set AF Jump RMSSI Threshold,
AF Jump RMSSI Samples, Good Channel RMSSI Threshold,
Search Algo Type, SINR FIRST STAGE, RMSSI FIRST STAGE

Change-Id: I0c79de6966cb93fbbc5befafc9aaaea95982ddb8
CRs-Fixed: 460621
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio-iris: Configure repeat count for PS string

- When FM Rx tuned to a station, not receiving complete PS string.
  SOC is not waiting for complete PS string. it is sending PS event
  even if it has part of PS string as well.
- Added support for setting repeat count for PS string
  to get refined PS string from receiver.

CRs-Fixed: 474719
Change-Id: I71c0c1c8af9488573c05d816c37982f9ed935a87
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
radio-iris: Fix in the AF_LIST event handling

- Copying more than available size in AF list buffer which leads to crash.
- Added a check to avoid copy more than available size.

Change-Id: I8f00c6dd82e64ee2744bfad63ea4523b206732a6
CRs-Fixed: 498758
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
radio: iris: Fix 64th character in  RDS RT field is missing

FM driver sends only upto 63 characters as Radio Text data
to upper layer.

Pass upto 64 characters as Radio Text

Change-Id: I3d49d85eb0c6e91ef0ea5660e572734a38281d62
CRs-Fixed: 505062
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
radio: iris: Handle force close gracefully

Do not queue the FM disabled event while in OFF state.

Change-Id: I8f8cd31198f8bb1a7521920844e0f0c5c3190b08
CRs-Fixed: 492216
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
radio: iris: Checking if driver's buffer is large enough.

Checking if driver's buffer is large enough to copy
the data from user space.

Change-Id: I7b4eed81cf77ce2973669ce18ccd95a5df397d82
CRs-fixed: 552329
Signed-off-by: Satish Kodishala <skodisha@codeaurora.org>
radio-iris: Fix bug in the AF_LIST event handling

- Bug in the AF_LIST event handling, there copying af_list bytes,
  but it should be (af_list * 4).

Change-Id: I13b2535347e1030945d78d506c656279f311fb90
CRs-Fixed: 476076
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
radio: iris: Use proper condition to queue stereo, mono event

Upper layer does not receive any audio output mode when fm is
tuned to a station after FM is turned on.Use proper condition
to queue stereo/mono event.

Change-Id: I7e0ac57a93c4ea30b92b08ce476ba553401ecd22
CRs-Fixed: 525975
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio-iris: Return hardware capabilities

  Radio iris isn't properly advertising its hardware capabilities to
  userspace which makes it look like radio is unsupported.
  Fix this so that userspace sees that radio is in fact supported
  Upadate the hardware capabilities while returning response to query
  device capabilities.

CRs-fixed: 512171
Change-Id: I52d6479cfc1e974735be5f835a0d564fb6d5c1d4
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
radio: iris: Prevent probable overflow

casting a unsigned int into an integer, integer to
unsigned int may cause buffer overflow.

Change-Id: I54be4d4c5470616a59a772c587fe6d5f32575c32
CRs-Fixed: 539008
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio: iris: Prevent loss of data

Down casting a variable may lead to loss
of data, other various kind of subtle errors.

Change-Id: If1f8a8c463333a5283c5ba66f099e33d66dc21e4
CRs-Fixed: 569313
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio: iris: Use kernel API to copy data from user space

Use copy_from_user kernel api to copy any data from user space
to kernel space.

Change-Id: Ia3b7bb0f98180bd8792c1c18e930cb5609b8dc82
CRs-Fixed: 540320
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio: iris: Maintain different FM states

Unexpected disabled event gets queued when FM is turned
on after turning off FM, sending SSR command. Therefore
FM fails to turn on.Maintain different states FM OFF,
FM RECV TURNING ON, FM TRANS TURNING ON, FM_OFF,
FM CALIBRATION and only queue unexpected disabled event
when either Receiver or Transmitter is enabled.

CRs-Fixed: 518378

Change-Id: Iffa55bef3dc5ce605cf270ad41f4c9a8b8d70392
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio: iris: Avoid memory leak and NULL pointer dereferencing

 - Avoid memory leak by freeing allocated memory
 - Do not derefer NULL pointer

CRs-Fixed: 537955
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
Change-Id: I7624d73e5c25233e9d03c67e4204c611b9a8fff6
radio: iris: Allow task to be interrupted

Not allowing task to be interrupted can cause
delay in response to upper layer. Allow task pending
to be interrupted when corresponding command's status
is received.

Change-Id: Ibb84673dfa92458c1ef45da12e63dd041abd0c39
CRs-Fixed: 569318
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio: iris: Add NULL pointer check

Dereferencing a NULL pointer may cause kernel crash,
Check for NULL pointer before dereferencing

Change-Id: I43b1aa8054646f29833f82b7203192aa3494d912
CRs-Fixed: 548404
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
radio: iris: Removed reference to user provided pointer.

Removed reference to user provided capability structure
pointer.

Change-Id: Ie16abbe9143cad19a8fc535972de18823af4ef51
CRs-fixed: 539042
Signed-off-by: Satish Kodishala <skodisha@codeaurora.org>