msm: camera: Exit gracefully while camera daemon crashes

Add camera daemon shutdown handling in all camera
sub devices to exit camera gracefully and it helps
to restart camera.

Change-Id: I39643a16f100b873275efe3a0c6184fe54e52830
Signed-off-by: Suresh Vankadara <svankada@codeaurora.org>
msm: camera: Update sensor mount angle and position

Update sensor driver to add sensor mount angle and
position as part of media entity flag. This info
is used by upper layers to get the info from
media device entity insted of opening camera
to reduce the launch latency.

Change-Id: Ie807a21206f95bbcc784aa4d2259cef7ac51e544
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
msm: camera: Fix VFE IOMMU page faults

To avoid VFE IOMMU page faults in case of
vfe write masters bus overflows, enable
bus overflow override flag to allow
non overflowing write masters to continue
thier operation.

Change-Id: I9452acac2b70786217b3d65029e1b68cee2fdf3e
Signed-off-by: Suresh Vankadara <svankada@codeaurora.org>
msm: camera: Check length of cmd_len to zero in isp driver

Validate the length of cmd_len not to be zero
in ISP driver which is from a userspace argument.

Change-Id: I3238cd7426c5315e49c5ac7b453156e0b3d48ec0
CRs-Fixed: 548804
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
msm: camera: Prevent camera suspend while active

Prevent camera from getting suspended from external
sources while the camera is active

Change-Id: Iaf3ebe8bb3ea568fb76bdcadacfe1923a872ce73
Signed-off-by: Lakshmi Narayana Kalavala <lkalaval@codeaurora.org>
msm: cpp: Attach/detach iommu device on open/close node

Change the iommu device attachement to happen on
cpp_open_node and detachment in cpp_close_node.
It decrease the power consumption when Camera is not
working.

Change-Id: I7f8d65e14af2949d9512191459d313ac4d3fff9c
Signed-off-by: Iliya Varadzhakov <ivarad@codeaurora.org>
msm:cpp: Fix for spurious interrupts from CPP hardware

When power up the CPP, it generates spurious interrupts
that can confuse microntroller and halt it. This fix
clears the interrupt requests from CPP before enable
Microcontroller at "Open Camera" event.

Change-Id: I3b75f2513efc30fb0f35dd086464f0b6c3a6ff9b
Signed-off-by: Iliya Varadzhakov <ivarad@codeaurora.org>
msm: camera2: cpp: Reset MICRO block before clock enable

The MICRO can be triggered to enter in bad state when the
corresponding clock is enabled. This patch resets MICRO block and
then enables clock.

Change-Id: I08128211e561026eed76041e73fa971ba369576a
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
msm:cpp: Set inst_info before send it to userspace

If IOCTL command VIDIOC_MSM_CPP_GET_INST_INFO is
called, inst_info structure must be initilaized before
it is sent to userspace.

Change-Id: I4936ae31ecd19cfd25cf22de32101fe3257889d6
Signed-off-by: Iliya Varadzhakov <ivarad@codeaurora.org>
msm: camera: Fix for memory leaks and error handlers.

(a) Fix leak during error cases.
(b) Handle error cases like releasing devices in case of
    failures.

Change-Id: I9e01855e1de968cac6708aaf6a2522d277f93f7c
Signed-off-by: Azam Sadiq Pasha Kapatrala Syed <akapatra@codeaurora.org>
msm: camera2: cpp: Set exact size for firmware loading.

The poll reads after during and after firmware loading fails.
This is because the exact size of firmware changes with the
version of the firmware. This change uses the firmware size
based on actual firmware file being loaded.

Change-Id: I949954347a48d0b388b11b3c81fd5d1a4627cbf7
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
(cherry picked from commit 7f0705c6eb86ceca1adec45bbaeb44bcd0b87079)
msm: camera: Cleanup msm generic buf queue on userspace crash

Clean-up the msm camera generic buff queue on userspace
crash to avoid invalid memory access in next session
which might lead to corruption in other modules
and system stability issues and also avoid memory leak.

Change-Id: Icd989cf9ef944c01e1193fead105963f745bcbc4
CRs-Fixed: 522939
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
msm: camera: Cleanup msm generic buf queue handling

Clean-up the msm camera generic buff queue when all
client closes the handle and also provide init-deinit
ioctl for cpp to open-close the buff mngr handle.

Change-Id: Ie484174e0ffaee02e85c9c9cda8ac26103aaddd0
CRs-Fixed: 582261
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
msm: camera: Cleanup msm generic buf queue handling

Clean-up the msm camera generic buff queue when all
client closes the handle and also provide init-deinit
ioctl for cpp to open-close the buff mngr handle.

Change-Id: Ie484174e0ffaee02e85c9c9cda8ac26103aaddd0
CRs-Fixed: 582261
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
msm: camera: Non-busy polling and timeout when stopping ISPIF.

Previously a busy loop used to wait for ISPIF stop on frame
boundary. This was bad not only for busy polling, but
because if sensor has stopped streaming for some reason, the ISPIF
will never stop thus making the loop endless.
The new solution uses readl_poll_timeout macro, polling once in
millisecond for maximum of 500 milliseconds (which corresponds to
2FPS - minimum supported frame rate). If polling times out, driver
reports the error to the user space for appropriate recovery.

Change-Id: I14e9825e2c8b67bab7a2e13fa0b0ef4710456805
Signed-off-by: Petar Sivenov <psiven@codeaurora.org>
msm: camera: Fix ispif stop frame boundary timeout issue

Previously a 500ms timeout set for stop frame boundary.
But sometimes when doing snapshot with large linecount may make
the frame rate drop to 1fps. Set the timeout to 1s to avoid camera
crash.

Change-Id: Id51fb3eb58300df20e792bdab9702af7c4e18943
Signed-off-by: Ju He <juhe@codeaurora.org>
arm/dt: msm8974: Change I2C clock for main and sub camera separately

Change I2C clock for main and sub camera separately

Change-Id: Ifdd8d2458f1d47d13bed978e29ffbb23757bf860
Signed-off-by: Vasko Kalanoski <vaskok@codeaurora.org>
msm: camera2: Validate frame during timeout in cpp driver

During long stability stress runs, invalid frames are encountered
in timeout processing. When frame acknowledgement is delayed by
firmware due to various reasons the timeout handler could hit
frame that are already processed. Hence adding NULL condition
check to avoid invalid frame access.

Change-Id: Icaa5e630d5190a7bf0a4e07a95d08e116cb304db
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
camera_v2: jpeg: Use buf_cmd.offset for v2p size calculation

Start using buf_cmd.offset when calculating the memory map
size for v2p. This is needed to enable ION input buffer support
for JPEG decoding.The input buffer has a header before the actual
bitstream.

Signed-off-by: Kamen Kirov <kkirov@codeaurora.org>
Change-Id: If9bdcefe3628bd21c9e76916e4d7e3dc3cc39447
msm: actuator: fix to prevent kernel heap buffer overflow

fix to prevent kernel heap buffer overflow allows user
controlled data to be written to the heap via the
msm_camera actuator IOCTLs

Change-Id: I4458831e28e0081fb2f5ae55506be866100e1b4f
Signed-off-by: Vasko Kalanoski <vaskok@codeaurora.org>