power: pm8921-bms: Fine tune SOC reporting during suspend/resume

Report SOC based on the time for which the system was suspended.

Remember -
1. If we recalculated the SOC in resume
2. The last_soc before going into suspend

Two cases arise - if we had a short suspend or if the suspend
was significant to case a drop in SOC. For the former do not
report a change in SOC and for the latter, report the
newly calculated_soc. In either of the cases, soc should not
increase because we cannot suspend while charging.

There is a possibility that the report_soc may be called
before BMS resume (update_power_supply), causing the driver
to report the old SOC. Handle this case by setting state
variables before recalculating the soc in resume.

CRs-Fixed: 482611
Change-Id: Ic21a24a1126800011f5e7e4531c1953436812811
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>

Conflicts:
	drivers/power/pm8921-bms.c
ASoC: msm: Support to configure the code for media button

There is mismatch in button 0 code value that is used
in kernel and userspace. Configure the code for button 0
to match with that of userspace.

Change-Id: Ie0518b69e50d50d81b44bea6ce48ce1db2bbae03
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>

Conflicts:
	sound/soc/msm/apq8064.c
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>
msm: kgsl: Do not try to resume the device from INIT state

If the device is still in INIT state there are no open instances
of it running.  Resume calls should be no-ops.  Do not attempt
to start the device at this point.

Change-Id: I1cb6d60581b0b5b0a2ab1b13418adc4ae3983c5e
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: vidc: Add LTR feature for H264 encoder

This change adds Long Term Reference picture
selection feature for H264 video encoder.

Change-Id: Ida957df244d8715c955afe8d809708123a94e999
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
EHCI: HSIC: fix driver removal function for msm_hsic_host

Upon driver removal function we need to disable the device pm runtime
in order to, first, undo all the logic done in probe and second, to keep
balanced disable depth counter in case of platform driver unbind.

However the removal function can be called also in consequences of
platform_device_del(), in this case the platform device was already
disabled and removed so if we call pm_runtime_disable() again we
decrease the disable_depth for the second time causing for unbalanced
counter.

Therefore we use an if statement to check if the device was already
removed or not.

CRs-Fixed: 445674
Change-Id: I5ff6b20d0f8e811a5c673903ca340f7bcc2e2d78
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
EHCI: HSIC: disable pm runtime device before remove hcd

Merge order of commits 21a480e and e50d914 introduced runtime pm
disable depth counter imbalance fixed by e50d914 again. Fix the
bug by disabling runtime pm before removing HCD.

Change-Id: I249a4f63db3a975652e6ce15545584e41bae284b
Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
power: pm8921-bms: fix calibration and UVLO issues

The bms is not running a hkadc calibration before calculating the
first SOC. This causes accuracy issues with the power on SOC.

Also when the battery gets in the low voltage range, don't limit
the corrections. We have seen UVLO where even though the BMS was
calculating SOC quickly it was not lowering the SOC fast enough.
Skip limiting ocv change when battery is near cutoff voltage.

Change-Id: I07747546867dcc90ccf7cb353c4e7a2c2c42520d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
driver: lc898300: implement sysfs interface for vibrator intensity

Change-Id: I911796e1ccbe3bbe27d67c21a263b3ce65083dcc

Conflicts:
	drivers/misc/vibrator-lc898300.c
msm: display: command mode panel release fence

For command mode panel, release fence should be signaled after the buffer is
sent to the panel.  For performance consideration, allow one more commit to be
queued.  Keep the second kick off as short as enough.

Change-Id: I19af075ebf480d3e81b46b1cd2ef21a2893f143e
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>

Conflicts:
	drivers/video/msm/mdp4.h
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/msm_fb.c
msm: mdp: Change msmfb kworker to kthread

This worker can be a longer running task depending on the number
of frames queued, hence change it to a thread.

Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Change-Id: Iebf7e95d0486ac43aa6a12d70442936600c0249a

Conflicts:
	drivers/video/msm/msm_fb.c
msm: mdp: Update sync pt. behaviour

Add a retire fence and clean up the existing release fence
implementation

Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Change-Id: Iecf7e95d0786ac43aa6a12d70442936600c0249a

Conflicts:
	include/linux/msm_mdp.h
msm: usbaudio: Fix memory allocation for USB audio module init

Fix memory allocation issue in snd_usb_audio_init()
use sizeof(struct) insead of sizeof(pointer)

Change-Id: I270bbd7111e97dd4e0e92378f61d5025e16f5fca
Signed-off-by: Alex Fradkin <afradkin@codeaurora.org>
ASoC: usb: move the switch setting to more appropriate location

There is a delay between creation of sound card and creating of
corresponding steam. Currently we set the switch at the time of
creation of card. And later streams get created, so its more
optimal if we set the switch only after creating the stream.

Change-Id: Ic9f29d7a8dbcd32cde0097289ce6e1404a837372
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
ASoC: wcd9310: Fix DMIC current leakage after disable

Observed after disabling DMIC path, some DMICs observe
power leakage of around 2mA and affecting power numbers.
This happens due to the DMIC clock runs off MCLK. 2 Stage
of Dividers are used to  generate various DMIC Clock Freq.
Since the SW Enable/Disabling is async to MCLK, the divider
will either hold the last stage 0 or 1.
Manually force the digital mic clock pin to GPIO mode from
functional mode through the TLMM mux option and force the value
of DMIC voltage to 0V. This will avoid any current leakage.

CRs-Fixed: 504468
Change-Id: I720fadda77b59454feb1a64d0c4951a6c09de66c
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>

Conflicts:
	sound/soc/codecs/wcd9310.c
ASoC: wcd9304: Fix DMIC current leakage after disable

Observed after disabling DMIC path, some DMICs observe
power leakage of around 2mA and affecting power numbers.
This happens due to the DMIC clock runs off MCLK. 2 Stage
of Dividers are used to  generate various DMIC Clock Freq.
Since the SW Enable/Disabling is async to MCLK, the Divider
will either hold the last stage 0 or 1.
Manually force the digital mic clock pin to GPIO mode from
functional mode through the TLMM mux option and force the value
of DMIC voltage to 0V. This will avoid any current leakage.

Change-Id: If676801df4e77047c85167453139541629f981d8
CRs-Fixed: 526779
Signed-off-by: johny <mjshai@codeaurora.org>
ALSA: core: Fix crash by avoiding appl_ptr crossing 32-bit boundary

Incase of A2DP usecase using proxy driver, appl_ptr has
boundary value as 0x60000000 frames in sw_params for stereo(2 channels).
When this value crosses 0x40000000, then userspace calculating
appl_ptr at bytes results in crossing 32-bit value 0x100000000,
and points to 0x0 offset which can result in crash or pop.
To avoid above scenario, set the sw_params appl_ptr boundary value
within 0x40000000. Added proper check at sw_params update
to set this value correctly within 32-bit boundary(frames).

Change-Id: I537a04156699d90549a0a468ae19539ecd552d3b
CRs-Fixed: 483203
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
Revert "msm: camera: restore Sony 10.1.1.A.1.253 camera driver"

This reverts commit 5a867d8dd8fa830a017c42d3c4053959b6db62bc.

Change-Id: If79c7c2caf7b61b7d770879b3bc8f33424cd6b85

Conflicts:
	drivers/media/video/msm/vfe/msm_vfe32.c
Revert "ion: ioctl compat with old api"

This reverts commit 857b0f1ce46efbaf214cc7615f0a81f0a544cbe0.

Change-Id: Ia9acc97bc2c7cb6183f9704c1d382f204e5cd040

Conflicts:
	drivers/gpu/ion/ion.c
	include/linux/ion.h
msm: camera: Add NULL pointer check for regulator

To avoid potential crashes, Null pointer check is added
before regulator calls are made

Change-Id: I3c745ff0600971d07d10b7a537e6f2375a2bf4ab
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>