video: msm: wfd: Delete from free_queue before freeing memory

VSG has a stale pointer to deallocated memory that is accessed, causing
a page fault.

Change-Id: I036293950795f601c0592c39b6da20d3c0cbb77f
CRs-Fixed: 348977
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit c73f497b1ce2d267c1b9b5b272f625b406ab36b2)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm_fb: hdmi: Disable 1.1_FEATURE

Some displays support Enhanced Link Verfications(1.1_FEATURE)
which makes HDMI Tx to verify Pj on every 16th frame. Three
consecutive Pj mismatch will result in HDCP authentication
failure. If 1.1_FEATURE is supported(this can be detected by
reading BCAPS), it needs to be enabled by writing into AInfo
of display. Default is disbaled.
This change sets HDMI Tx core to disable 1.1_FEATURE by
default so that we don't see Pj mismatch error unless the
feature is enabled.

CRs-fixed: 348752
Change-Id: I996f60b852a7e867e8e13e700beecbac8190a59e
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
(cherry picked from commit 97e2fcf862d913feff157f536ee14cfc5f3197f7)
(cherry picked from commit 88cb4da47697fe407b013554678ec68d7c8ab93c)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
video: msm: wfd: Reduce first frame latency in CFR mode

When we get the first frame, push it immediately to the encoder rather
than waiting for the timer to expire.

Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
(cherry picked from commit 47ef81ffe4ffd35db48a0a8795697a910378664a)

Change-Id: If7f85e747646a5022b416d1189d5d55d16b19343
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit bf844198db86317b2e73c98dab5b2f85f08f7555)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: Allocate physical pages instead of using vmalloc

Replace vmalloc allocation with physical page allocation. For most
allocations we do not need a kernel virual address. vmalloc uses up
the kernel virtual address space. By replacing vmalloc with physical
page alloction and mapping that allocation to kernel space only
when it is required prevents the kgsl driver from using unnecessary
vmalloc virtual space.

CRs-Fixed: 346921

Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
(cherry picked from commit 8cb835b656ae2c3faa79af4f374563d344b46d4a)

Conflicts:

	drivers/gpu/msm/kgsl_sharedmem.c

Change-Id: I88e1eb282cc4822970811728d00b1096188f64e9
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit d5fa912f599a71223496d2ff97ecd5040b95baaf)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm:kgsl: set state as requested state when in NAP

Fix the state to requested state so that when both ISR and
timer fire at the same time, the state is set as SLEEP

CRs-Fixed: 340484
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
(cherry picked from commit 9b6110bb38c7acf61e065ec206b62b1e1f089908)

Change-Id: Ie625aba09feddf495647be2844dc0a4014605141
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 7704bbd086590ef68aa30530c0ea18dc7f379780)

Conflicts:

	drivers/gpu/msm/kgsl_pwrctrl.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: vidc: Adds API to request performance level.

Adds API to request for a particular performance
level from video core. This is needed for Wi-fi
display (WFD) to reduce end to end latency.

Change-Id: Ib4133b8cd62ccad286be1984f944911754b887c5
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit 3c51cb669e9ca03773444f69aa9c7fb6131cb726)

Conflicts:

	drivers/media/video/msm/wfd/enc-subdev.c
	drivers/video/msm/vidc/common/vcd/vcd_client_sm.c
	include/media/msm/vcd_property.h

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: flush outer cache for alloc_page() pages

The outer cache needs to be flushed for these pages
after they are allocated so that the GPU and CPU
have a consistent view of them.

CRs-Fixed: 346921
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
(cherry picked from commit 7018a21bf2b52f1296557d1f6ec9ed64e9169de7)

Change-Id: Id5c11ab8d856fc270330fd3258baa51b8efca192
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit a240fca76b5562d3ca53677151213286306bbc96)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: vidc: Use pre-computed frame delta values in WFD use case

In WFD use case with frame skipping enabled, we wish to fool the core
into thinking that that the frames are coming at a consistent rate so
that we don't run into any issues with the core's rate control
mechanism.

The following change introduces a property that the client may set that
dictates what the timestamp delta between any two frames might be.

Change-Id: Iea3f97879227b7932543d3449d311758dc4a2f59
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit 806e8d1cf43de34ad38181a227bbcebb64a5fd9e)
msm: kgsl: call sysfs_notify when a hang snapshot is made

/sys/class/kgsl/kgsl-3d0/snapshot/timestamp will have sysfs_notify()
called when a hang happens, so that a userspace process can
poll(2) on this file to detect a hang.

CRs-Fixed: 354385
Change-Id: I0a3c8fcbe3fb09256bcd12f6e63c107536734485
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
(cherry picked from commit 90812c8eac42b5ce7bb48e35897537021e01e6de)
(cherry picked from commit 15456a25c55409ee3032c4e083d232a3d3aedf6e)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
vidc: send flush done if flush is issued in EoS while encoding

There is a race condition in encoder, when an input buffer
is received with an EoS flag but doesn't have an output
buffer to process that and if simultaneously flush is issued.
This is fixed by sending flush done if flush is issued in EoS.

CRs-Fixed: 353081
Change-Id: I925f49779ed5cb91bfab805ba4b7102c1e3f728b
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
base: genlock: allow synchronization with a single gralloc handle

In order to support synchronization in a process with a single
gralloc handle we require the ability to write lock a buffer
while it is already read locked by the same handle. This change
extends the concept of an exclusive write lock or recursive read
locks to a genlock handle (rather than the genlock lock).
Genlock cannot provide deadlock protection because the same
handle can be used simultaneously by a producer and consumer.
In practice an error will still be generated when the timeout
expires.

CRs-fixed: 356263
Change-Id: I322e7fadc8b43287f53b211242b176d3de731db2
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:

	drivers/base/genlock.c

Conflicts:

	drivers/base/genlock.c
msm: kgsl: release the wakelock when going to suspend

This change is needed only if slumber is disabled
CRs-Fixed: 355216
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
(cherry picked from commit 48e727689b8fabbb44f20e86f1ad6a04b8111e0a)

Change-Id: I5183e9e409f494757e44a919b87d3b078ac9ea7d
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: disable early suspend and late resume for 2d cores.

The powerrail off during slumber is causing a GPU hang

CRs-Fixed: 355216
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
(cherry picked from commit 2bd5c33b0c7a47fffc089ced6d14efc0369a5bdc)

Change-Id: I6a1d933abaca690124170dbda2a3ccc0cb1879b3
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: fix cleanup code in kgsl_ioctl_map_user_mem()

ion handles need to be handled differently than pmem or
ashmem handles.

CRs-Fixed: 359268
Change-Id: I20637644f247859245fbba80e5bc6b50fd896403
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: convert timestamp_cmp logic to use unsigned logic

The meaning of timestamps becomes difficult to understand when
converting between unsigned and signed values. Values that
were seperated by 0x80000000 also returned inconsistent
results.

CRs-Fixed: 355752

Conflicts:

	drivers/gpu/msm/kgsl.h

Change-Id: I5d5d1ad64ef120da8769d72ac69dde37f8f5c6ae
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
base: genlock: remove BIT macro usage

The BIT macro is not defined for !_KERNEL_ resulting in compile errors.

CRs-fixed: 356263
Change-Id: Ib2acd913033fccca63716d6585a51707c72debf0
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm_fb: HDMI: Do not add HDCP reauth timer during probe

Currently all HDMI/HDCP timers are initialized in the driver's
probe function with a maximum possible expiration value. However,
the 32-bit jiffies value is initialized in the kernel so as to
wrap 5 minutes after boot. This results in the HDCP timer being
fired 5 minutes after boot even though reauthentication is not
necessary. This change fixes this issue by not starting the HDCP
reauth timer during probe. The timer is only started when an
authentication failure is detected from an existing valid HDCP
session.

CRs-Fixed: 352080
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
(cherry picked from commit ca15287e50fe00dd6526fdc166cb526298099fb2)

Change-Id: Ia3e240c3c0c32b6ef9fa2c58e48a5cadb64791b8
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit b44b96003a28d22433731b7d53db57cc5641a052)
vidc: Add extra cases for error handling in vidc init

Currently error conditions are not handled properly
if failures occur during irq request or while creating
work queue. With this commit these error conditions
are properly handled.

Change-Id: I618ca5c2a4f6bd09a3edd164a7867a90a9ed9f9a
CRs-Fixed: 355753
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit c9a9332a743459e44744e630f3e734e7788c477d)
(cherry picked from commit efb9b72a643d6e499e5e5b94c5cc1fe32b652851)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
video: msm: wfd: Don't signal HDMIDaemon to mirror on FB1

Remove obsolete code that signalled HDMIDaemon to mirror the
display on FB1.

Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
CRs-Fixed: 352830
(cherry picked from commit 4102d704243cf0ff297cdbe8d5b731da4c0bb9d5)

Change-Id: I07fabb754a49fe398813e864067f96c66a47f489
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: vidc: Metadata memory release issue.

Metadata memory is not freed when there is
memory allocation failure in ddl open. Fixed
this issue by freeing the metadata memory.

CRs-Fixed: 353109
Change-Id: I3f6fd93498aea0ce78092bd3a28cf08625b0ca77
Signed-off-by: Anil Gahlot <anilg@codeaurora.org>
Signed-off-by: Mohan Kumar Gubbihalli Lachma Naik <mgubbi@codeaurora.org>
(cherry picked from commit af296715bd5db6c38997d1171d079331c8650287)
(cherry picked from commit 572e147402717bb0c77ecc807659d05a617e370f)