mdp: flo: Set minimum IB value for 4 layers

For 4 layer MDP composition, if the total composed area
doesn't cover the whole screen, there is a potential hole
in our calculation where we don't request enough bandwidth
especially for larger displays such as flo.
Pin the minimum bandwidth to ~1.6G (empirical) to fix this.

Bug: 10954796
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: kgsl: Update dispatcher/server-side sync

Refresh the dispatcher/server-side sync code with some general
fixes to functionality, stability and fault tolerance.

Change-Id: Ic0dedbad48161513a2670d3949fccbdbf14b8dff
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Allow sync points to be created on the submitter's context

There are situations where a submitting thread may wish to create a
syncpoint on an already issued timestamp to pause a context until a
previous command has been retired.  Relax the restriction against
submitting a sync point against one's own context and only check to
make sure the user isn't submitting a syncpoint against a future
timestamp (which would be an certain deadlock).

Change-Id: Ic0dedbad883fc228da0d94c8416a88504f5d1377
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: consolidate preamble based context switch code

Move logic for handling preamble based context switch
to the core adreno code. This makes it less burdensome
to implement support for newer GPU families that won't
ever support legacy context switching.

Change-Id: Id9ad5936ff91dcdbc9de869baf0d0b9fcf1b5170
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Add IB submission gate for device suspend

Add IB submission gate to stop the system from making requests
while suspend is requested.  This will force users to wait for
the system to resume before making more requests.

Change-Id: I2460ef9b4237b586a31d4cea64b6dd74d30b08d9
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Do not take active_cnt for events and waittimestamp

In the mists of time it was nessesary to take an active count
for waittimestamp and events because we did not want to run
the risk of suspending while the GPU was active.  Now that we
have the dispatcher we have much better control over the GPU
so the original risk is diminished.

The problem is that holding active_cnt prevents us from going
into nap and suspend and with server-side-sync a lot of the
events we are waiting for might take a very long time before
they even get dispatched on the GPU so we are essentially
keeping the clocks on waiting for other people.

z180 must take active count on its own.

Change-Id: Ic0dedbadcb608115938b198faebe333d19c6a8f6
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: always check kgsl_active_count_get() result

Getting an active count can fail if the hardware doesn't
actually wake up. Make active count get functions __mustcheck
to remind people of this and fix existing calls to
handle the error.

Change-Id: I5a0202c824ac7e436b9061da6d8f638e44e8b7f6
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: manage active count in adreno_ioctl()

Most of the adreno specific ioctls do not need the hardware
on. The few that do are perfcounter related, it may be
better at some point to optimize them further to shadow
the counters when the hardware is not on rather than
forcing the power on.

Change-Id: I9ea83106e0aaf3d3ac8d261bdec4e4c2e21c4659
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: remove KGSL_IOCTL_WAKE from context destruction

Adreno context destruction never needs the hardware on
to destroy the current context.

For z180, always take an active count while destroying.

Since this is the last ioctl to use KGSL_IOCTL_WAKE, remove
it entirely.

Change-Id: I97368c7f3c28f16538cc5f48b802b681d7af96ef
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Run the idle timer while the GPU is not power collapsed

If the GPU is not in its lowest permitted power collapse state,
make sure there is a timer running to get the GPU to that state.

Change-Id: If57aaaf02087036bc4e24725c0cd3de5bc1f1034
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
audio: asoc: headset: fix build-in mic recording fail.

During build-in mic recording, insert or remove headphone would
cause LDO_H power down which leads to recording fail.

Power on or down LDO_H by checking dapm widget LDO_H status.

Bug: 11523570

Change-Id: Ib7558748c093b60830eb41b2171c2eae95e4ed0a
Signed-off-by: sam_chen <sam_chen@asus.com>
msm: kgsl: update kgsl_cmdbatch_destroy with the tip

The kgsl_cmdbatch_destroy function is outdated with the tip and
the difference patch cannot be cherry-picked easily.

Signed-off-by: Jeff Boody <jboody@codeaurora.org>
msm: kgsl: protect syncpoint events with a reference count

Replace the event spinlock with krefs to avoid the possiblity
of calling a sleeping function while holding the spinlock and
to generally make the whole cmdbatch cancel loop a lot more
stable.

Change-Id: I08ba54fa4c5a11c05e3503dfc6a4ee040733e5a6
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: fix race condition setting the event->handle

A race condition existed for setting the event->handle since the
async event can signal at any time after it has been registered.
When the event signals the reference count for the synclist and
the async callback are decremented causing the event to be freed.
The kgsl_cmdbatch_add_sync_fence function needs to take another
reference to ensure that the handle can be set before the event
is freed.

Change-Id: I0d8a02246e42dce014661d6f14c685415f1704cd
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
audio: asoc: wcd9310: fix headset mic recording fail.

Headset mic fail in case of inserting headset while dmic is recording.
Keep LDO_H always on while headset is inserted.

Bug: 11506684
Change-Id: I8516d537d2c72d6f71236219e5d3e610e25ecf24
Signed-off-by: sam_chen <sam_chen@asus.com>
msm:camera: Fix overflow issue in ioctl_hw_cmds function

'len' is of type signed int 32bit,but the assigned value
may exceed maximum unsigned int32 range.Add overflow check
and graceful exit if 'm'exceeds UINT32_MAX value.

Bug:11518040

Signed-off-by: Apurva Rajguru <arajguru@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
msm:camera: Fix signedness issue in hw_exec_cmds

In hw_exec_cmds()second argument m_cmds should be
of type unsigned interger

Bug:11518040

Signed-off-by: Apurva Rajguru <arajguru@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
msm: vidc: cache-invalidate encoder output buffers after alloc

Invalidate output buffers explcitly once, during registration.
This ensures any pending CPU writes (eg. memset 0 after allocation)
are not flushed _after_the hardware has written bitstream.

b/ 11149679

Change-Id: I958466011e7d96c7b5e2691403c8386309997429
Signed-off-by: Praveen Chavan <pchavan@codeaurora.org>
charger: smb345: report wireless online = 0 when OTG is plugged

OTG has higher priority than wireless charging, we need to:
1. bypass wireless irq work when OTG is plugged
2. report wireless online = 0 when using wireless charging then
   plugging OTG
or it will show charging icon even battery status is "Not Charging"

Bug: 11073722
Change-Id: I5a807817a5733d043316d2ad04dde50b0b506895
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
driver: usb: otg: Add a wakelock for the usb cable and otg cable detected.

The msm_otg wakelock is unlocked becuase of the irq functions of usb cable and otg cable.

b/11110052

Change-Id: I78eb8bebbb47aa2c9843d72866b1cafa415bc847
Signed-off-by: yi-hsin_hung <yi-hsin_hung@asus.com>