msm: camera: allocate memory properly to avoid passing local variable as reference.

1. allocate memory in msm_server_control to avoid passing local variable as
   reference to event queue
2. Safe coding: Set pointer to NULL in some kfree
3. only dqbuf when streamon
4. Add per instance lock to serialize stream operation

Change-Id: I6e87faa1bd05ada9dc94510cb6414c2a670dae63
Signed-off-by: Mingcheng Zhu <mingchen@codeaurora.org>
Signed-off-by: Peter Liu <pingchie@codeaurora.org>
(cherry picked from commit 49253c236c00ffa5d83e809a7d6f68db28aa3852)

Conflicts:

	drivers/media/video/msm/actuators/msm_actuator.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: camera: Not allocate memory for the buffer done event.

Unnecessary code cleaned.

Signed-off-by: Mingcheng Zhu <mingchen@codeaurora.org>
(cherry picked from commit a236290fa341c3bd10ffd7295e65eceb600f5b6c)

Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
(cherry picked from commit 269fd3713401028c4db9e21ddf615a59a92c1f31)

Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
(cherry picked from commit 07d49ca235577e2c35f3f52c620eb07a9a209405)

Change-Id: Iac57aec7aaf92d241c90dc4f5407f224991b3bf5
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: camera: Flush event queue during close.

Event queue needs to be drained to avoid picking any
stale entries in the future iterations

CRs-Fixed: 360672

Signed-off-by: Azam Sadiq Pasha Kapatrala Syed <akapatra@codeaurora.org>
(cherry picked from commit 34fc95b423796e7b1d474171af67784a5678cfd2)

Change-Id: I9fbbf0cc82482642fd7906e91a88781045e58494
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
video: msm: wfd: Send signal HDMI observer to mirror on  FB2.

 - Send KOBJ_ONLINE, KOBJ_OFFLINE events to HDMI observer
   to mirror on  FB2.

This reverts commit 4102d704243cf0ff297cdbe8d5b731da4c0bb9d5.

Change-Id: Ie5f0c4528ee43edf5ff8145520723a8095c0f542
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
video: msm: wfd: Delay fill_buffer until START_DONE

VCD requires we do not give any output buffers to be given until
START_DONE is received. In the case that buffers are given, it
introduces race conditions in the vidc with respect to the SPS/PPS
buffer, which vidc assumes to be present on the first fill_buffer but
actually isn't present until START_DONE.

Change-Id: Ie4dec3ed41e0f248175fb7d9719b458d3b699539
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
msm: camera: Add retry logic if stream ops fails.

During monkey/stability runs the open/close sequence is going out of
sync. This patch ensures that the sequence is maintained and also add
retry mechanism in case stream ops fails.

Signed-off-by: Azam Sadiq Pasha Kapatrala Syed <akapatra@codeaurora.org>
(cherry picked from commit 2ddecacee48508b4a89d568c01c9e5ddbdd29999)

Signed-off-by: Sunil Joseph <sunilj@codeaurora.org>
(cherry picked from commit 3351b3811abdd9e2158223bda15aac2d01091cd6)

Change-Id: I0f214b4e38ad53dffde5b211b3f54ed7f6e0d914
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: debug_patch: CLOSE SERVER HANG

Change-Id: Iec1f8aabbc97b4f9ad53e58f1189fd8dab79559a
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
msm: wfd: Add error handling for input buffer ion map failure

Target reset happens when trying to do a ion_unmap_iommu
on the above fd, which was never mapped. Added a check for
non-zero virtual address.

Change-Id: If77c268062fbf6e31aa930f09c0088e8844db5ea
CRs-fixed: 394779
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: camera: Fix color invert issue

The bayer pattern will invert if the frame lenght line
is odd. The change ensures frame length line is always
even.

Change-Id: I7f796b8b0580a563c376f13ed781535df7f54389
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
(cherry picked from commit ad09ecea54bb88dea5145a08f5b0c380f053d2c4)
msm: camera: synchronize vfe start/stop operations.

In monkey runs due to race condition vfe_start gets triggered
before vfe_stop. Add synchoronization mechanism to avoid this.

Change-Id: I78f1820e78dd1cd94098c5edb3ad92548e874713
Signed-off-by: Azam Sadiq Pasha Kapatrala Syed <akapatra@codeaurora.org>
(cherry picked from commit eeca82f2028f888f4895c6530879446cb3a2693f)
clean extraversion
msm: vidc: Enable turbo mode based on client request.

- video core is bumped up to turbo mode, if more performance
  level required from multiple clients.

- Enable turbo mode atleast one of client set turbo mode.

Change-Id: I579715b85e857ad194810c06a361448b775e470e
CRs-Fixed: 385454
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
vidc: 1080p: Reset meta data offset to zero

For multi-resolution clips, the meta data offset used while
doing cache clean of meta data buffer is from the previous
resolution & resulting in kernel panic. Resetting the offset
to zero during meta data buffer initialization for new
resolution fixes the issue.

CRs-fixed: 386245
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit 16145bcbd6af8db0eebc0eedec1f01ee1b0b3635)

Change-Id: I249c0cd220f8fa4f815488a9a321a398752329e4
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
vidc: Handle EOS with Codec config buffer.

Change will handle codec config buffer with EOS.
Video driver will make sure that the codec config buffer with
EOS will be requeued in case of reconfig and non-reconfig paths.

(cherry picked from commit 43b203869814fe5f0ddcb265a8f859aebdaa652f)

Change-Id: I424df5628aaededcbd65c36d369410909e46c515
CRs-fixed: 399347
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
vidc: 1080p: IDR picture type support for H264 format

Read IDR picture type from 1080p core register set
and propagate it to user space using IDR frame type
enumeration in api header file. The IDR frame type
info is used in SYNCFRAME logic for H264 format in
userspace.

Change-Id: Ic677eb4d28469f6712832b7e09050467420eb70b
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
(cherry picked from commit b2295e885966a000cceedcfd4a6462113fe3be4a)
vidc: 1080p: Handle flush for interlaced clips.

Video core expects one field per buffer for interlaced
clip playback.If a flush is issued we should reset the
need next field flag, so that new bitstream is processed
after flush is completed.
Reconfig flag shouldn't be reset in case of EOS.

Change-Id: Idf50a24c29e904a958b0b1e850813e2d9fc4346d
CRs-fixed: 382368
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
(cherry picked from commit f19f4d27088015842f9bd0945f62b34e90fd784d)
video: msm: Add QSEED Table reading support

Add support to read the tables of QSEED values. When the values of the
QSEED tables are able to be written to, it is beneficial to be able to read
what's there as well.

CRs-Fixed: 380315
Change-Id: I3110721906424f70a12bf5736de7875dec03f4c6
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit fbf467206a4b5d09f51268535364f0a1b462eef6)
video: msm: Add QSEED Table2 Support

Add support for QSEED Table2 reads/writes. Table 2 is a table of coeffients
for QSEED Table 1 to offset into. Table 2 is quite large, caution should be
taken when writing into it.

CRs-Fixed: 380315
Change-Id: I89be18c0047dcf1d9a3bcd538967b2bbe7b4efe1
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 382b00b9a664fa0bd9b8d8bee2dae3f4340d425d)
video: msm: Clear previous histogram data on next startup

Clear the pointer to the userspace histogram struct when histogram is
started. Previously, when the histogram was stopped while a histogram read
was in progress, the pointer was not cleared, causing the next histogram
read to think that someone was already using the histogram.

CRs-Fixed: 361640
(cherry picked from commit 19e4b71f617e307cacf0be077e08bec5c37df290)

Change-Id: If09017149e98b35c49603372c554aa4c97f2de82
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Check for multiple readers of histogram

Check to ensure that only one reader attempts to read one frame's worth of
data from a histogram block. Prevent the case where two readers attempt to
get data, but end up causing a loop where neither of them do.

CRs-Fixed: 361640
Change-Id: I48878d9fe02d96f306894ed9acc47bf41cd9984b
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>