msm: mdss: prevent dereferencing of user space pointer

We were dereferencing a userspace pointer in kernel.

Change-Id: I128455904cd396690350fc6b784a8844d594539c
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
msm: mdss: Hold MDP clock Ref count in pan_display path

If handoff fails, the clock ref count becomes 0 and iommu
will get detached. In pan display path, since at that
particular instant iommu gets detached, we use physical
address. After this if iommu is again attached and physical
address is fetched, it can result in continuous IOMMU page
faults. To address this hold MDP clock ref count
in pan display path.

Change-Id: I2370b276acdced2cf22083eb80fcad1b2e454315
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: mdss: Return suspend without delay in NOTIFY UPDATE

NOTIFY_UPDATE returns Suspend after 4 seconds delay.
Delay would cause HISTOGRAM_STOP ioctl to be called late.

Return suspend case without setting timer for no delay.

Change-Id: I356086de96cab85cd203bf1ad529ecf0b3bbfce3
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: Add update notify for backlight change in static screen

Previously, the change of backlight sysfs node value will not trigger
notify updates if display is in static screen case. This will cause
delay or wrong configuration for assertive display. This patch fixes
the above issue by adding an update notify if backlight changes when
there are no display updates.

Change-Id: I1475896214a50dc1fa71739aa751b2e626d27adb
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
msm: mdss: disable irq to enforce mutex within dsi_event_thread

Mdp spin lock is used in dsi_event_thread and in irq context.
Disable irq while holding spinlock to avoid context switching
into irq context and cause spinlock recursion

CRs-fixed: 652850
Change-Id: I4bd8cadb1f5d83acc7e866344b7585e7944e08ac
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: mdss: Clear the previous state of pipe during SOLID_FILL

Clear the previous state of pipe when it is being used in SOLID_FILL
operation to prevent wrong register configuration. For ex: Use case
when DMA pipe was used in BLOCK mode in previous frame, then it is
being used in LINE mode for SOLID_FILL operation in current frame.

CRs-Fixed: 655993
Change-Id: I0ed257276428b96c10a92457a16df4dfdc42c1f8
Signed-off-by: Sushil Chauhan <sushilchauhan@codeaurora.org>
msm: mdss: Check extra mmb allocated to a pipe

If set call to a pipe changes smp configuration such that
calculated no. of  mmb blocks are less than allocated mmb
blocks, fail this set call. This ensures pipe disconnection
and smp configuration is possible in next commit cycle.
Also, check that no extra mmb is left allocated to any plane
when pipe's format changes. If so, fail the set call to let
correct smp configuration happen in next commit cycle.

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

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_pipe.c
msm: mdss: refactor pipe retrieval and ref count logic

Allow only retrieval of pipes that are on particular framebuffer device
used list. This ensures that pipe is not modified from a different fb
device node and cause potential issues.

Also, modify the ref count logic to use kref and ensure pipe is freed
only while holding mutex in case there could be race condition that
pipe is allocated while being freed.

Change-Id: I626323b5df981a7ed1e03196126cd4376b5ba6a6
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Anusha Koduru <kanusha@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_pipe.c
msm: mdss: Allow DMA pipe sharing only on WB mixer

DMA pipe can only be shared on the writeback mixer for
concurrent line and block mode operations. Only allow
sharing if the mixer attached to the pipe is already a
writeback mixer.

Change-Id: I9a0e5144fdf87f681493cd92d9cc809836ab1a5c
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
msm: mdss: remove extra lock for ctl calls

Some ctl functions need only protection for mixer programming changes,
since all of these calls are made within ov_lock there is no need for
additional protection. Specially since ctl->lock is still held when
mixer configuration is safe to be changed.

Change-Id: I4f39e28f40ef18789a653d02346358b7ca7590c6
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Fix rgb_565 format for 90 degree rotation

Make rotator output format for rgb_565 and bgr_565
as rgb_888 for 90 degree rotation as expected by
MDSS.

Change-Id: I0865b5688fa662d1e88d1efebef26a38d4abfd61
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>

msm: mdss: Swap RGBA format to BGRA with bwc rotation

When BWC is enabled, rotator format needs to be swapped from
RGBA to BGRA to avoid color mismatch on the ouput image.
This is specially needed with a GPU composed FB.

Change-Id: I956a354f3fe605e2c7bda4c4331cfe5bcd6417c7
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>

msm: mdss: synchronize formats across rotator output and pipe setup

The rules applied to switch formats must be the same across
rotator output and the following pipe setup. Also, yuv rotator
output format should always be set to pseudo planar for MDP
hardware optimality.

Change-Id: I3f5f09bcc599627e47495fab253ec0d9d8d5fa1c
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
msm: mdss: update pipe params on first update after suspend

Whenever panel is turned off, need to ensure that pipe is reprogrammed
fully when turned back on in case the pipes are not properly unset.

Change-Id: I6242b8f90695dd713c87924eb15306767b62803e
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Don't call pan_idle for MSMFB_OVERLAY_PREPARE ioctl

We keep calling MSMFB_OVERLAY_PREPARE for each composition
cycle, even if there are no changes in params. Because of this
we can hit performance degradation due to pan idle wait.
This change removes pan_idle wait for prepare call.

CRs-Fixed: 600539
CRs-Fixed: 608848
Change-Id: Ie99f4dbc4671caf9bfbd49bd9b200c3180002d56
Signed-off-by: Radhika Ranjan Soni <rrsoni@codeaurora.org>
msm: display: Add pipe type selection in overlay request

Allow user to specify the type when requesting an overlay pipe.
If field is set the pipe type indication in the flags will be
ignored.
Change-Id: Iee51d24b96c7a2a987dc70a439342e6548dfc8fa
Signed-off-by: Vineet Bajaj <vbajaj@codeaurora.org>
msm: mdss: use one dma pipe during block mode transaction

Use one dma pipe during block mode transaction instead of two pipes
for the buffer resolution greater than max mixer width

Change-Id: I2a9f1bba95bfb66d1c0168aa9b99b8b9de57cd6a
Signed-off-by: Ramkumar Radhakrishnan <ramkumar@codeaurora.org>
msm: mdss: Consider FLIP flags while optimizing pixel fetch

While calculating source and destination rect of a pipe for the
programmed ROI, consider FLIP flags set for the pipe.

Change-Id: I631453c26f443b08a23556f83195d9914e05b41d
Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>
msm: mdss: modify userspace src format during MSMFB_SET on rotator

The req->src.format field should be changed to the destination
format and propagated to the user so that appropriate buffer size
calculations for the destination buffer can be made. Note, this
only changes the user copy and the driver fetches the source buffer
based on source format.

CRs-fixed: 686496
Change-Id: I590829796c00aeea8e3d9b10578126dd7afe9c82
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
msm: mdss: check for fb node refcount before calling null commit

Add a frame buffer reference count check before calling
null commit to release the free list pipes. This avoids
unnecessary flickering on screen if a process tries to open
and close the fb node without performing any operation.

Change-Id: I96b824edccf27f0ddb796c420ef1feb49f65ddea
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
msm: mdss: add bus bandwidth request enable/disable during get/free buffer

Enable bus bandwidth request during get/free buffer to ensure
iommu is in proper state while mapping/un-mapping any buffers.

Change-Id: I85cc74a666dbfd29abd26609cbdd3e968d1ecd01
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: mdss: synchronize wfd driver iommu mmap/munmap with mdss

Add clocks reference during wfd driver iommu mdp_mmap/mdp_munmap
to ensure iommu is in proper state while wfd driver map/un-map
any buffers.

Change-Id: Id1a24285b81d5047e5e9f002ade9694ea49be59d
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>