msm: ultrasound: add support for proximity

Add support for the proximity daemon:
new command and definition in the DSP interface for the proximity usage

Change-Id: I5acd768d4beeb0dd9b30b6167365167974af2b78
Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: add support for various msm families

Various msm families have differences in interface with QDSP6.
To support these differences some updates in the ultrasound framework's
source files hierarchy are required.
Ultrasound related interface with QDSP6 for msm family
is implemented in dedicated files; the proper directory,
including the files, is selected during the kernel build.

Change-Id: Ic60f5822670e5c511f997e34f9530fb87cc32d62
Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
Ultrasound: Palm Rejection Support for Protocol B TSC Drivers

The Ultrasound stylus can't work simultaneously with touch screen
driver, because Android input module can't handle events from multiple
input drivers. The solution proposed was to filter out touchscreen
driver events, this solution proved to be efficient for Touchscreen
drivers that work with multitouch protocol A, but for drivers working
with multitouch protocol B this solution was not enough to clear out
all touchscreen driver trace. This commit fixes this by 'free'ing all
mt slots allocated by the touchscreen driver before filtering out all
of touchscreen driver's events.

Change-Id: Icde80fc9e238a72dac30a46927a7863424b209a7

Signed-off-by: Rani Khoury <rkhoury@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: add support for new msm family

Various msm families have differences in interface with QDSP6.
To support these differences some updates in the ultrasound framework's
source files hierarchy are required.
Ultrasound related interface with QDSP6 for msm family
is implemented in dedicated files; the proper directory,
including the files, is selected during the kernel build.

Change-Id: If3cf5a1d65695551d10831cc4c28975bae1e2774
Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: fix potential memory leak in usf driver

A previously allocated memory was not being released in certain conditions.

Change-Id: Ia204fc6ec6f0df30c518f5b04be80e154c422471
Signed-off-by: Rani Khoury <rkhoury@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: support five TX channels

Ultrasound digital pen service requires five TX channels for
the service performance improvement.

Change-Id: I0ca7e2ffd20bd73684df8d4112089b9b8ca98668
Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>

[poondog: adapt to flo]
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: update proximity data format

Data format has been updated in the proximity service,
running on QDSP6.
This update should be supported in the ultrasound related
definitions in the kernel.

Change-Id: I27260fff55b48bb10f22e8bbaaaa13c4202c2121
Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: support up to eight TX and RX channels

Ultrasound digital pen service requires six TX channels for
the service performance improvement.

Change-Id: Id01f9cf2c9df6a55a72bfa395ffe1c2e85d8cdc7
Signed-off-by: Ravit Dennis <rdennis@codeaurora.org>

[poondog: modify for flo]
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: Add a new input device configuration

Add a new input device configuration in order to
support an external display.

Change-Id: I0acca1324013a7bd812857aea715f204f5e3c005
Signed-off-by: Ravit Dennis <rdennis@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: Support side buttons

Add new button notifications in order to be
able to report stylus side button states.

Change-Id: I49598b4aab23ff1e041257640d8f63e2da3dd554
Signed-off-by: Ravit Dennis <rdennis@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: Add Sync Gesture data format

A new Sync Gesture service has been added to userspace and QDSP6.
This service data format should be supported in the ultrasound
related definitions in the kernel.

Change-Id: I99dcaa74915c73ffb7329fb88226866b79a7ef73
Signed-off-by: Ravit Dennis <rdennis@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: support multiple devices, conflicting with USF

The USF input device can have a number of devices,
conflicting with it.
The first registered device (primary) is real TSC device.
Optionally, later registered devices are simulated ones.
The input events from the multiple devices should be
controlled by USF.

CR-Fixed: 583511
Change-Id: I07983546c6e70e562bdf3f833ab1ba17b2b9e399
Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: add verifications of some input parameters

Some security vulnerabilities were found.
To fix them, additional verifications of some input parameters
are required.

CRs-Fixed: 554575, 554560, 555030
Change-Id: Ie87a433bcda89c3e462cfd511c168e8306056020
Signed-off-by: Baruch Eruchimovitch <baruche@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: Add support for general button events

The side buttons bitmap was expanded to allow sending button
events for tool type buttons (stylus, rubber) and also for a new
button which signals that the hovering icon should be displayed.

The event source field was removed as it was previously used to
set the tool type, which is now done explicitly via the buttons
bitmap.

Change-Id: Id08921c392eeec8928ca0c730988f8c83be2ba8f
Signed-off-by: Lior Barenboim <liorb@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: add support for aDSP Sub-System Restart

Add handling of RESET_EVENTS message from APR, which indicates
aDSP sub-system restart has begun.

Add a new internal state, USF_ADSP_RESTART_STATE, for this
scenario.

Change-Id: Ic1178f8fb4e659abc29947fac4079ba088e51447
Signed-off-by: Lior Barenboim <liorb@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: ultrasound: add support for stream parameters

Add new IOCTLs to get and set ultrasound stream parameters in DSP
using shared memory.

Change-Id: I627e9e40e29c6233dab4295e2c355a718e30bd01
Acked-by: Hadar Sivan <hsivan@qti.qualcomm.com>
Signed-off-by: Lior Barenboim <liorb@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
ultrasound: hack to build ULTRASOUND_B into the kernel
On m7 we liked it better

Signed-off-by: poondog <markj338@gmail.com>
DEFCONFIG: turn off android logger
as done here
https://github.com/android/kernel_msm/commit/faaca6a2f56ae74d4f630b65a7eb74505276330a

Signed-off-by: poondog <markj338@gmail.com>
prctl: adds the capable(CAP_SYS_NICE) check to PR_SET_TIMERSLACK_PID.

Adds a capable() check to make sure that arbitary apps do not change the
timer slack for other apps.

Bug: 15000427
Change-Id: I558a2551a0e3579c7f7e7aae54b28aa9d982b209
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Signed-off-by: poondog <markj338@gmail.com>
msm: kgsl: Return HI offset from kgsl_perfcounter_get

Previously, kgsl_perfcounter_get only returned the offset
of the LO perf counter register. This assumed that the HI
register would always be adjacent to the LO register. With
VBIF 2.0, this assumption has now been broken, so both the
HI and LO register offsets must be returned.

CRs-fixed: 578771
Change-Id: Ie74da5d797e58a143b89a61aba7ebaf1ed42ed5e
Signed-off-by: Kevin Matlage <kmatlage@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>