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>

Conflicts:
	drivers/media/radio/radio-iris.c
radio-tavarua: Add support for WCN2243 v2.1 SOC

Enable support for WCN2243 v2.1 SoC which is respin of
WCN2243 v2.0 with the bug fixes.

Change-Id: I883ec0407224d875b1ba1b062903a4eefeb962c4
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
Signed-off-by: Ram Mohan Korukonda <rkorukon@codeaurora.org>
radio-tavarua: Configure channel spacing for enhanced search

Enhanced search algorithm detects 50Khz channel spacing frequencies
in a band with 100khz channel spacing.
Update channel spacing for enhanced Search algorithm on WCN2243 2.1.

Change-Id: If133895e33679a1bc84df8d25841e7e13aa36629
CRs-Fixed: 450643
Signed-off-by: Venkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>
radio-tavarua: Handle I2C read/write errors during sleep mode.

Getting read/write errors when the I2C is not resumed from the sleep

Added re-try mechanism to handle during I2C read/write

Change-Id: I5a533b085ccfcda2181a2d5ea792bbb3d187c477
CRs-Fixed: 427937
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: tavarua: Fixes for memory leaks.

Freeing memory allocated in case of failures.

Change-Id: I323b9c414d725d6b9dc0698e2ed03ef9c2450e5f
CRs-fixed: 557048
Signed-off-by: Satish Kodishala <skodisha@codeaurora.org>
radio: tavarua: Fix buffer overflow.

Removed improper typecasting to fix buffer overflow.

CRs-fixed: 554963

Change-Id: Ie3ae5a502f060c13eba7cb5c28a1af389b772af2
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: Avoid NULL pointer dereferencing

Before dereferencing a pointer check for NULL
pointer.

CRs-Fixed: 537890
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
Change-Id: If010b89fd4f5930d944c9e327c51de4b40f33c3c
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: Avoid inconsistent free

There is memory leak chance if we exit
from function early. Ensure to use free before
exiting from function.

Change-Id: I17dbecffc5713d95c66ecec0bffb5ed3c8660fe8
CRs-Fixed: 540334
Signed-off-by: Ayaz Ahmad <aahmad@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>