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 Possible Integer overflow in ispif driver

Fix Possible Integer overflow in ispif driver in multiple places.

CRs-Fixed: 510051
Change-Id: I738c11b2d8e2ef7433bb01ba416590f7952acc2e
Signed-off-by: Lakshmi Narayana Kalavala <lkalaval@codeaurora.org>
msm: camera: ISPIF HW reset is incorrecty invoked

Currently ISPIF HW reset is implemented for msm8974 ISPIF HW module only.
However, the check for module is not correct and reset sequence is executed
for 8226 also, putting HW in bad state. The patch uses correct check
against HW version to prevent that.

Change-Id: Iff9ab2deb7c6c207d9493ce2abe56bad4d9d7f6f
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>
msm: camera: Enabling all CSI clocks for ISPIF hw reset.

To perform complete ISPIF HW reset need to enable all CSI
clocks. Earlier only csi0 clock was enabled, causing problems
in reseting RDI interface. Also added change to disable clocks
before returning from hw reset if there is a timeout.

Change-Id: Ia0befc058f06596688b9310ee6c8bf4b017a13ce
Signed-off-by: Sagar Gore <csgore@codeaurora.org>
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>

Conflicts:

	arch/arm/mach-msm/clock-8610.c
	drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
msm: ispif: Clean up typecasts/format specifiers

Clean up typecasts and format specifiers in msm_ispif.c

Change-Id: I53b8aec6f5a2a5f0271ca2f5cab5de6d72c186c2
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
msm: camera: Fix unterminated of_device_id table

Add a NULL table entry at end for msm, ispif and
msm_generic_buf_mgr device tree match tables.

Change-Id: I05f08c77a8a25112cd17955e98018ac88b7a834c
CRs-Fixed: 582110
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
msm: camera: Add defensive check in ISPIF driver

In case of error handling, call ispif release only if ispif handle
is valid. In case of mm-qcamara-daemon crash when camera is not open,
these handles are not valid. Hence it leads to kernel crash in ispif
release handler.

Change-Id: Ifb402b6907052594d12fcf9495694e6c5184af1b
Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
msm: camera: Add in-sensor mode support for eeprom

Add in-sensor mode calibration support for eeprom.
User are able to write back calibration settings
via ioctrl interface of the sensor.

Change-Id: I5fbfa8967885b683e498fe670a0c36d58d4b44e7
Signed-off-by: Ju He <juhe@codeaurora.org>
msm: camera: Fix various small issues in cci driver

Remove some unused ioctl exposed, Also add
some bound checks for ioctl user params.

Change-Id: Ifdd441fdb25fd20b005c4e4e1ebe4e203f1216ac
CRs-Fixed: 511382
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>

Conflicts:

	drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
msm: camera_v2: CCI release resources in case of timeout

Turn off the CCI clocks and release gpio if reset timeout error is
received in function_msm_cci_init()

Change-Id: Ib4387ce08635e0b4e6458f225bd3013557d6b5fa
Signed-off-by: Evgeniy Borisov <eborisov@codeaurora.org>
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>
msm: camera: Stream on optimization

Remove sleep in msm_csiphy_lane_config().

Change-Id: Ieede0ed325422c4323ffd69ddcbc20a36889c763
Signed-off-by: Evgeniy Borisov <eborisov@codeaurora.org>
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: 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>
msm_sensor: fix vreg dt parsing logic

Previously, dt parsing code for sensor power up sequence assumes certain
value and order in "qcom,cam-vreg-name".  Such assumption can't be
enforced by dt itself.  It leads to kernel panic when enum value of a vreg
is larger than total number of specified vregs.

New implementation dynamically search and match available vregs, instead of
relying on order and enum assumptions.

Change-Id: Iea519f2e4b4d805fecf6dd699ade2af4a00caa43
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

Conflicts:

	drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
msm: camera: eeprom: add gpio enable vdig support in eeprom probe

Add support for sensor power up through gpio enable vdig in eeprom
probe.

Change-Id: I84e1bc5a7278bac29db4575fa9fe69f3e464bedc
Signed-off-by: Wang Wenbin <wenbinw@codeaurora.org>
msm: camera: Bound check num_cid from userspace in csid driver

Upper and lower bound checks are enforced for num_cid
which is passed from userspace with lower as 1 and
max of 16.

Change-Id: Ic5456289cb2f2b4ea17610a7672eb2c5225b7954
Signed-off-by: Hariram Purushothaman <hpurus@codeaurora.org>
msm: camera: Change CCI I2C write interface

Every CCI I2C write involves one I2C transaction to CCI core.
Since CCI queue has maximum of 64 words, Write CCI commands
to CCI core and handle it in hardware.

Change-Id: Ic3b03bf70b1a5a23d4bdd42d2cbf8528fa8bd413
Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>