msm8960: squashed CM commits (2/4)
video: msm: Do not use disable_irq in the spin_lock_irqsave context

Both mdp_isr() and mdp_histogram_disable() uses the same
spin lock mdp_spin_lock variable.  One core waits for disabling
mdp_isr after acquiring mdp_spin_lock and other core in mdp_isr()
waits for spin lock mdp_spin_lock and dead lock between two cores.

Change-Id: I73a10494ab78e92fc88a348aed4f526091b51f89
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>

msm_fb: display: Correct dtv pipe black out

This change corrects the register values to black out
the dtv base pipe.

Change-Id: I80fefab3cc6dd006edbb673f41ccfe983af2cc3a
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>

msm_fb: display: skip one vsync event after enabling mdp and vsync clk

Both mdp and mdp_vsync clks are disabled for command mode panel when
no new frames are being played. When they are re-enabled if new
requests come in, the first vsync event which is signaled by read
pointer interrupt arrives in a random time due to the sync between mdp
and panel, so skip it to maintain correct vsync timing.

Change-Id: I683b765e4a16d3d152b9270f5982234b94921f1e
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>

msm_fb: display: Proper pipes solidfill

For MPQ/hdmi as primary, solid fill the pipes only during suspend.
This change also take care of the solidfill of the pipes unset
during overlay and pan display at suspend.

CRs-Fixed: 421461
Change-Id: I15096df681cbd94ae3cea63ecbfe915e01b7387f
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c

msm_fb: display: Fix blend configuration for command mode panels

For command mode panels, blend registers does not get configured
as per the use case. This leads to incorrect blending of layers
resulting in lower layers (eg. wallpaper or buttons in video
playback) to show above the upper ones, making overall user
experience to go bad. In order to resolve the issue, blend registers
are now configured properly by as per the use case.

CRs-Fixed: 410029
CRs-Fixed: 415553
Change-Id: Ibe7d594e0ad6a6f4d75ed2e59c7382c09b65d624
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>

msm_fb: display: Add alpha enable check in blend

FIR and M/N scalar when used for downscaling, drops
alpha channel of the given layer. To notify this, alpha_drop flag
is updated accordingly. This flag need not be checked for layers
with no alpha plane. In some scenarios alpha_drop may get enabled
for the layers with no alpha plane and cause issues realted to blend
composition of layers. Check for setting alpha_drop only if source
ayer has alpha plane.

Change-Id: Ie64b30c045a78d0d68eb9efacc76902afae7850d
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>

msm_fb: commit mixer stage for WFD during unset

Interfaces with Borderfill pipe as base layer needs to
be commited during unset which will reset the mixer cfg
structure. This is needed because overlay_commit will not
call stage commit as there is no buffer queued.

Change-Id: Ib3347e52ae437b20d5a85a09777f13aee2672edb
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>

msm_fb: display: Do not use ION_IOMMU_UNMAP_DELAYED

Since iommu buffer will be un-mapped after two newer commits
had passed, there is no need to request iommu driver to further
delay un-mapping an iommu buffer.

Change-Id: I8cf8d406cf509908035d12c9a04f0add12f3c7c7
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

msm_fb: display: Removing extra disable irq in cmds_rx API's

Disable IRQ for DSI_CMD_TERM was already called in the isr.
Removing the extra call present in the cmds_rx API's.

Change-Id: I0000dd3166beb2a3b0c788327e1d7520e0c11a13
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

msm_fb: display: Add support for vsync driven composition on 7x30

This patch will queue multiple surfaces and commit those
surfaces into mdp at same instance so that surfaces will
be blended and displayed at same time for 7x30. Hardware vsync event
is delivered to the user space frame work via uevent. Both
queue and commit are controlled by frame work and synchonized
with vsync event. Therefore frame rate will match with vsync rate.

Change-Id: I2acb83f871f16c2278dc10cb958580a2826efe70
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c
	drivers/video/msm/mdp4_overlay.c

msm_fb: display: wake up system around vsync

To avoid frame drops due to power collapse,
wake up cpu right before vsync.

Change-Id: I63385eb329ae5e74cbac5256823fd3a213e0a0e1
Signed-off-by: Ken Zhang <kenz@codeaurora.org>

msm_fb: display: change the location of wakeup timer call

There are two pathes (pan display and overlay commit) to commit
display buffer, so change the location of cpu timer wakup call to the
common pipe_commit function to make sure cpu get waked up around
vsync.

Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Change-Id: Idbe6049d740a7e17a6a90e28566f7a9c74e348f2

lib: genalloc: Change chunk allocation to vmalloc

Change the chunk allocation from kmalloc to vmalloc for
allocations greater than a page. This allows large
chunks to be allocated from physically non-contiguous
memory and increases the chance of the allocation
succeeding.

CRs-fixed: 387655
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 0614b96dc8e4c8a0dd0db41aec5a79daa3bdf091)

Conflicts:

	lib/genalloc.c

Change-Id: Ic0dedbad9d277d0842591b1f075ce3b80c8c05de
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

lib/sha1: use the git implementation of SHA-1

For ChromiumOS, we use SHA-1 to verify the integrity of the root
filesystem.  The speed of the kernel sha-1 implementation has a major
impact on our boot performance.

To improve boot performance, we investigated using the heavily optimized
sha-1 implementation used in git.  With the git sha-1 implementation, we
see a 11.7% improvement in boot time.

10 reboots, remove slowest/fastest.

Before:

  Mean: 6.58 seconds Stdev: 0.14

After (with git sha-1, this patch):

  Mean: 5.89 seconds Stdev: 0.07

The other cool thing about the git SHA-1 implementation is that it only
needs 64 bytes of stack for the workspace while the original kernel
implementation needed 320 bytes.

Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Cc: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Nicolas Pitre <nico@cam.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David S. Miller <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

arm: remove "optimized" SHA1 routines

Since commit 1eb19a12bd22 ("lib/sha1: use the git implementation of
SHA-1"), the ARM SHA1 routines no longer work.  The reason? They
depended on the larger 320-byte workspace, and now the sha1 workspace is
just 16 words (64 bytes).  So the assembly version would overwrite the
stack randomly.

The optimized asm version is also probably slower than the new improved
C version, so there's no reason to keep it around.  At least that was
the case in git, where what appears to be the same assembly language
version was removed two years ago because the optimized C BLK_SHA1 code
was faster.

Reported-and-tested-by: Joachim Eastwood <manabian@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Cc: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

lib/sha1.c: quiet sparse noise about symbol not declared

Include <linux/cryptohash.h> to pickup the declarations for sha_transform
and sha_init to quite the sparse noise:

  warning: symbol 'sha_transform' was not declared. Should it be static?
  warning: symbol 'sha_init' was not declared. Should it be static?

Change-Id: I267e649aef59e2fe9f6bdf7bfff3c2e0421cb51b
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: Mandeep Singh Baines <msb@chromium.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

msm_fb: display: blt always enabled for 720p,1080p, secure buf

Change-Id: Ifbf78b7f80978c4151d006eed6a375ac4819c448
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

Conflicts:
	drivers/video/msm/mipi_samsung_oled_video_hd_pt.c

msm_fb: hdmi: black out pipes on unset

For HDMI as primary case, we need to blackout the pipes
when they are unset so that any residue is not visible
on the DTV during suspend.

Change-Id: I2bf36f1002dd185c26fe6c4291977737daa73ae1
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>

Conflicts:
	drivers/video/msm/msm_fb.h

video: msm: Remove dead code

 * Remove deprecated and unused Samsung-specific code that causes
   various problems and display glitches.

Change-Id: I911b5796a45dca236656e5d1527a8f50fc3c19b5

Conflicts:
	arch/arm/mach-msm/board-8960-display.c
	drivers/video/msm/mdp4.h
	drivers/video/msm/mdp4_overlay_dsi_video.c

msm_fb: display: return fail if pipe still staged

Pipe is not un-staged from mixer when it is unset.
It expects a pan_display() to un-stage it out of mixer.
Return fail at overlay_set() if pipe was still stage
at mixer.

CRs-fixed: 399193, 393979
Change-Id: I562f6e133bb239b30f4f53669dbf1cc5ddf80d02
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

msm_fb: display: Add pseudo-planar 422 H1V2 support in the MDP4

Rotator outputs pseudo-planar 422 H1V2 for interleaved inputs
on 90 degree rotation. Add changes to support MDP_Y_CRCB_H1V2
in MDP4.

CRs-Fixed: 371303
Change-Id: I8083bf44f9e2addf9e8732268147c1c3f6c0e2af
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>

msm_fb: display: Program source address registers correctly

Scale filter FIR uses the adjacent pixels as part of the
processing. Source address registers should be program such that
they point to the first valid pixel so that non-ROI pixels are
ignored. This is done by making source x,y offsets to zero and
adding the computed offset to source address.

CRs-Fixed: 380020
Change-Id: I998fdd46f39dc67f32c422ec209da59d1add2e95
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>

msm: rotator: Add pseudo-planar 422 H1V2 dst format for MDP4

For interleaved 422 inputs, rotator outputs MDP_Y_CRCB_H1V2
format on 90 degree rotation. Add support as destination format
for MDP4.

CRs-Fixed: 371303
Change-Id: Ie0f98d40f58bf2cb9bc3298a94cae9c4e89b2f7a
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>

msm: display: Remove dead code

Change-Id: I8d61fab9b407849dca8c1f7c71a055f34011a6a9

Conflicts:
	drivers/video/msm/mdp4_overlay_dsi_video.c

msm: display: Clear performance request data in turning on

In resume, previous cached request data needs be cleared as
they do not reflect the current hw status.

Change-Id: I325e5d9e3019b0d6cc5f21b1d9b689c06484f561
Signed-off-by: Ken Zhang <kenz@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c

msm_fb: display: add iommu mapping for mdp cursor buffer address

The mdp h/w cursor buffer physical address needs to be mapped to an
iommu virtual address when iommu domain is enabled.

Change-Id: I73b4492fc4d63632117074136e4d908f5089eb93
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>

video: msm: More cleanups

Change-Id: Ica6545f17ada55ecb4edb29e47541387989a2f45

msm_fb: display:  add mdp bandwidth runtime calculation

Currently mdp bandwidth request logic is based on source image size
and number of layers. This logic can not support complicated mdp
usecases and it is not power efficient. The logic is improved by
calculating mdp bandwidth request at runtime from all pipes and mixers.

CRs-fixed: 425823
Change-Id: I63206f00f8d3017a2449f8ac617fce3ba2a4d36c
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4.h
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mipi_dsi.c
	drivers/video/msm/mipi_dsi.h

msm: cpuidle: Don't disable irqs again

cpu_idle() disables irqs before calling down into the cpuidle
driver via cpuidle_idle_call(). Disabling irqs again in
msm_cpuidle_enter() is wasteful and unnecessary. It also inhibits
our ability to determine the largest irq latency when the cpu
idles for extended periods of time because the irqsoff trace is
reenabled when the irqs are disabled in msm_cpuidle_enter().

Note that we still reenable irqs before returning, as is required
by the ARM idle loop.

Change-Id: I925478d8fef88ab490959622bc68303f59cc6e79
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

msm: cpuidle: Update C state time stats in the cpu idle device.

msm_pm_idle_enter function returns time spent by cpu in particular
C state. Update the cpu idle device last residency with the return
value which is required for cpuidle stats.

CRs-fixed: 391456
Change-Id: If9f1b59e05c233e53ba37ae0fe9399f12275f3d8
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>

msm: Remove idle stats and cpuidle hooks

Calling RCU functions from within the RCU quiescent state is
illegal and probably a bug. The idlestats code uses an atomic
notifier called from msm_cpuidle_enter() and that atomic notifier
takes an rcu read lock. We could fix this with a raw notifier,
but this code is unused so let's just remove the code entirely.

Change-Id: I319f0eabb56a8721c19a3b2b4bc9a7f416c88384
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/Kconfig
	arch/arm/mach-msm/Makefile

msm_fb: display: add wfd clk ctrl in pipe_commit

mdp_clk_ctrl on is not called when commit is from overlay commit path
which can cause mdp hang. mdp_clk_ctrl off should be after mdp
overlay2 is done, so schedule a work in overlay2 done isr.

Change-Id: I94fd08da27cfda114f5cc0056a5103f0a9b772f6
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@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>

Conflicts:
	drivers/media/video/msm/wfd/mdp-subdev.c

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>

msm: Add switch node mechanism for wfd

Add switch node mechanism for WFD to indicate the
connection/disconnection event.

Change-Id: I7623e50ba8053602e4b2924d75c0e23b641e2b9a
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>