msm_fb: display: add early_off during panel off

Some panels need to send display_off command before
dsi controller turned off. This patch add early_off
feature for this purpose.

Change-Id: Id377120e9d6972c5f773760369ec056be37e93ff
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c
	drivers/video/msm/mipi_dsi.c
	drivers/video/msm/mipi_toshiba.c
	drivers/video/msm/msm_fb_panel.h
msm_fb: Optimize the resolution change on hdmi interface

HDMI resolution is changed twice on cable connect.
This will optimize resolution change by turning on
HDMI core only once, with best possible resolution.

Change-Id: I7f636b0c2c64eb3c661fda2a709b5480db05bd27
Signed-off-by: Nagamalleswararao Ganji <nganji@codeaurora.org>
Signed-off-by: Abhishek Kharbanda <akharban@codeaurora.org>
usb: gadget: u_bam: Fix NULL pointer dereference crash

port->port_usb could be NULL as part of assigning to in endpoint, so,
check port->port_usb is valid before assigning the endpoint.

CRs-Fixed: 451723
Change-Id: I3b5f7acaaeaae399f9a2482eb3f75b51fb36080b
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
EHCI: HSIC: Fix a race between root hub resume and controller removal

The pm_qos request is removed before unregistering the HCD in remove
function. If root hub resume runs in parallel, there is a possibility
of adding the pm_qos request back to the active list. The pm_qos request
memory is freed after unregistering the HCD and this would lead to
pm_qos list corruption. A crash is observed when another driver is
submitting a pm_qos request after HSIC controller is removed during
shutdown.  Remove HCD prior to releasing controller resources.

CRs-Fixed: 444928
Change-Id: Iaed6964e7d4245b8ae6c295ed6c76f5a9d32e20f
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Conflicts:
	drivers/usb/host/ehci-msm-hsic.c
media: dvb: mpq: Secure demux API updates

Add support for the following features in the secure demux API:
* Setting TS output format for recording filters.
* PES counters reported by the secure demux.
* Filter flags support - CRC checking for section can be disabled.

Change-Id: I621f395154137c6470c278907961792c85c6c09c
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
media: dvb: mpq: Limit number of TS packets on secure demux input

Limit number of TS packets available to secure demux for processing
in any single processing session. This is done in order to prevent
large input buffer that require a long processing time and may cause
latency and overflow situations.
The limit can be fine-tuned as it is a module parameter.

Change-Id: I36f007da1b8152be27885ba4674bf42e6eb86ffa
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
msm: display: dsi command mode vsync time generation

In each vsync cycle there will be two vsync interrupts
generated, need ignore the wrong one to provide the correct vsync
timestamp.

CRs-fixed: 452269
Change-Id: Ic13eea77d15eb46f4879f818d346425c63efe41a
Signed-off-by: Ken Zhang <kenz@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay_dsi_cmd.c
ASoC: msm: avoid negative time stamp check

Time stamp is unsigned. There is no need to check for
negative value.

Change-Id: I15e380f81e46908f6a9fe8d29c174de1b7c33173
CRs-fixed: 423372
Signed-off-by: Patrick Lai <plai@codeaurora.org>
msm: display: reset vsync state when display is turned on

In the case that vsync ctrl is unbalanced, vsync IRQ is cleared
in suspend,  vsync cannot be enabled after resume.
Clear the status when display is turned on

CRs-fixed: 449155
Change-Id: I5ecf23053b60d1fbd91f042758d67d39c83ab444
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Bosch Sensortec BMP18x device driver V1.1

Change-Id: Ic0211615b6535cb45f8752afebb6db33962c9299

Signed-off-by: Hongji Zhou <Hongji.Zhou@cn.bosch.com>
Signed-off-by: Wentao Xu <wentaox@codeaurora.org>

Conflicts:
	drivers/input/misc/Kconfig
	drivers/input/misc/Makefile
msm8930: add i2c device for barometer bmp18x

This device is present on 8x30 MTP/MDP platforms

Change-Id: Icfecc1a396e98782b4590ed68bd268608cae1c35
Signed-off-by: Orkhan Karimov <okarimov@codeaurora.org>
thermal: pm8xxx-tm: Modify userspace notification method

Change the userspace notification mechanism in the over
temperature interrupt handler from kobject_uevent() to
sysfs_notify() in order to simplify userspace notification
handling.  Ensure that the new notification mechanism is
independent from the current pm8xxx-tm mode.  This means that the
"mode" thermalfs file does not need to be modified in order for
sysfs_notify() to get called in the interrupt handler.

As before, writing "enabled" to mode will enable the software
override of the automatic PMIC hardware stage 2 partial shutdown
and stage 3 full shutdown.  Turning off these features is
typically undesirable and should be avoided unless userspace is
able to take immediate corrective action.

Change-Id: Ibd92b790778fd559df5ce74231e6cf71bef16370
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit 729c3ae9646cb8dc2a0ad0f301f7222bec70f6c6)
thermal: pm8xxx-tm: Improve temp alarm logging and notification filtering

Modify the kernel log message which is output when the PMIC
temperature alarm triggers so that the current (or estimated)
PMIC die temperature is shown regardless of ADC type.

Also change the log message printing and userspace notification
logic so that they only happen when the PMIC temp alarm stage
differs from what was previously seen.  This will reduce the
number of messages seen while the temperature fluctuates around
one of the thresholds.

Change-Id: I5ee2206ea05dee86666308d11dad1fc5560e58e0
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit 76e6e2a17d89d79711ecff9182f12460368bd5d9)
thermal: pm8xxx-tm: Use delayed_work task for temp alarm status reading

Use a delayed_work task to wait at least 40 ms in order for the
temp alarm status value to be updated after the TEMP_STAT IRQ
goes high.  Also remove IRQ enable and disable calls in the ISR
since the work item can only be enqueued once before it is run.

Change-Id: Ib5f13d0e82258b399749de96152c081d71981909
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit a42ed24bdc1a1ab8e2c0148430df063ee0679d18)
thermal: pm8xxx-tm: Add configuration option for allowing shutdown override

Add a field to the PMIC thermal alarm core data named
allow_software_override which is used to control whether or not
userspace may switch the mode of a PMIC thermal device to
"enabled" in order to enable software override of PMIC automatic
over temperature shutdown.

allow_software_override -
true:  writing "enabled" to thermalfs mode file results in
       software override of PMIC automatic over temperature
       shutdown.
false: PMIC automatic over temperature shutdown is always
       enabled.  mode file cannot be set to "enabled".

Change-Id: I4c47fdf0c0c4704008591755296118ad7fac95ae
Signed-off-by: David Collins <collinsd@codeaurora.org>
(cherry picked from commit 8f6d8a8e7e1d149687819af7f9abbb24a8459cc0)
msm: kgsl: Remove duplicate code for checking timestamps

Event based as well as interruptible based timestamp checks
use the same code, they differ on if the mutex is held or not.
Separate the common code out to avoid confusion.

Change-Id: Ie2ee01d7a07ff2ba7755ab8d327796345f9ca9ea
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>

Conflicts:
	drivers/gpu/msm/adreno.c
	drivers/gpu/msm/adreno_ringbuffer.c
msm: kgsl: Move events to context specific lists

Move the event accounting from a master list on the device to individual
context lists. This makes the management code more simple and reduces
the amount of extra cycles taken trying to walk a single largish list.
The new added code makes the event code slightly bigger than kgsl.c can
bear. As events become more commonplace this code will be more important
and it will be easier to maintain in a dedicated file so move all the event
related code into kgsl_events.c

Change-Id: Ic0dedbadf00b96eee53aea1d26acb195f1a916ce
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

Conflicts:
	drivers/gpu/msm/kgsl.c
	drivers/gpu/msm/kgsl_device.h
msm: kgsl: Add context reference counting to KGSL events

Add reference counting to all KGSL events since they are dependent
on the context.  This avoids a race condition where the context
could be destroyed while the events are being processed during cleanup.

Change-Id: Ifcd9655a6335d22c01f2606a0fbc5346d9a0314f
CRs-fixed: 438134
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Send the correct timestamp to an expired event

Instead of sending the currently expired timestamp to expired
events, send the timestamp that the event expected. This avoids
confusion for events that don't compare the actual timestamp
to the one they expected.  Canceled events send the current
timestamp when they were canceled.

The kgsl_sync handler wasn't prepared for the second case so
add a check to prevent strange things from happening on the
timeline when a event is canceled.

Change-Id: Ic0dedbad3681db6222720884688dcddb9b06bda2
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

Conflicts:
	drivers/gpu/msm/kgsl_sync.c
msm: kgsl: Don't silently ignore events that have a retired timestamp

After all the current events are processed in the main loop, the next
pending event is marked to fire an interrupt to start the cycle anew.
When the event is marked, we check the timestamp again to make sure that
we are always caught up with the GPU.  If the timestamp for the next
event happens to be retired when we get to this point, we silently leave
the function.

If there are no other subsequent events or waittimestamp requests, then
it is possible that another interrupt might never be fired for that context
and then the event gets missed.  Return a 1 in this case all the way back
up the stack and make the event code keep processing events until we are
positive that none are past.

Change-Id: I5a770e7f06612e1aecbfe2e8ccbfeebdab3fc9fc
CRs-Fixed: 441191
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>