msm-camera: enable csi-ahb-clk while accessing csi phy registers.

Turning on csi_ahb_clk while accessing csi phy registers at boot
time to avoid boot time crashes.

Change-Id: I88474a99141036e5d1adb541545e22bda78dc01c
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
msm: camera: Handling get buf properly when buffer queue is empty

There can be a possibility that the buffer queue is empty and
we ask for a buffer. In that case the address holding the buffer queue
structure data is not NULL but the entries of the structure are
NULL.

In such a case in addition to checking if bufq address is NULL,
when we request for a buffer, we also make sure that handle is
not NULL.

CRs-Fixed: 533384

Change-Id: I78acdc0455cd187e709722a36d9943af0444eaee
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
msm: camera: increase the length of property array

Increase the length of property array as the pageen property may
be longer than 12.

Change-Id: I1b85e9b9eb01af991dd628a08ca5e334c0fdbc82
Signed-off-by: Wang Wenbin <wenbinw@codeaurora.org>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
msm: camera: solve twice request MCLK GPIO for camera

In 8x26 MTP/QRD design, main/front camera sensor shares
the same MCLK GPIO, the poweron may fails in some cases
Change the process to output a error message for driver
bringup state to make sure other gpio are handled properly.

Change-Id: I48ee01f32ae5d7e02d3efe8578a747f23a6d8a71
Signed-off-by: Su Liu <suliu@codeaurora.org>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
msm: camera: Fix various small issues in vpe driver

Upper and lower bound checks are enforced for num_buff
which is passed from userspace and memset inst_info
to zero to avoid unwanted data passed to userspace

CRs-fixed: 547927
Change-Id: I0d589ef26e57bb26dc006b5927461edcc95e593e
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
msm: camera: Maintain buffer queue in isp buf manager

we encountered a problem where we are trying to free one
of buffers from previous ion session and this is resulting
in a BUG_ON because of mismatch of ion_handles.

Inorder to avoid this we are now maintaining a queue for
all the buffers during prepare buf and we unprepare only
if the buffer is present in this queue.

Change-Id: Ifd526ec0e4dc9d83a7c1a095af97a833a8b82a57
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
camera_v2: JPEG 1.0: add alignment check on register offset

Adds a check on the offset value in msm_jpeg_hw_cmd structure
for correct alignment.

Signed-off-by: Kamen Kirov <kkirov@codeaurora.org>
Change-Id: I9233cf6b7b300958188d2c95fb5a2c5f7a1e9cfb
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
camera_v2: Use JPEG_DBG instead of JPEG_ERR for some messages

Avoid printing by default a number of debug messages, to decrease
the ioctl latency in the dual JPEG use case.

Signed-off-by: Kamen Kirov <kkirov@codeaurora.org>
Change-Id: I1cfd16270282587cbf1821d34f658af80fe69fd1
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>

Conflicts:
	arch/arm/boot/dts/msm8974-camera.dtsi
	drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
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>
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>
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
Signed-off-by: Joao Paulo <joaolrpaulo@gmail.com>
Signed-off-by: TomorrowLandAce <joaolrpaulo@gmail.com>