msm: mdss: enable fb_split feature for dual-dsi panels

Currently fb_split feature is limited to dual-pipe but single
interface, i.e eDP 2560x1600, panels. Extend use of this feature
to dual-dsi panels as well and by default enable equal split to
support dual-dsi portrait panels, i.e 1600x2560. Default settings
will be over-ridden by split settings from device tree if available.

Change-Id: I38279e1af7dcd1278fa203f51b8b33f82d0848af
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
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>
msm: mdss: set default value of panel mode gpio to -EINVAL

Default value of panel mode gpio is set to 0 which is still a
valid gpio and preventing access to legitimate owners when not
provided explicitly in device tree file. This patch addresses
the issue by changing default value to -EINVAL.

Change-Id: Ifc34513d21323af9843f6bbc85a3afca79891357
Signed-off-by: Vishnuvardhan Prodduturi <vproddut@codeaurora.org>
msm: mdss: Support scalar programming for all usecases

Program scalar registers for both RGB and VIG pipes
when requested by the user. The scalar factors are
also computed by the user.

Change-Id: I6854a9ff3acdef07bb6a964f2f3686612230eff3
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
msm: kgsl: hold a process_private refcount in process_mem_print

There is a possible race condition where the process can be going
away while its debugfs 'mem' file is being read, which could cause
memory corruption.

Conflicts:

	drivers/gpu/msm/kgsl.c

CRs-Fixed: 627780
Change-Id: I697486faeb3f186fd1220d0acc1e449a4f7b77b0
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Look up the process struct in process_mem_open()

The pointer to an active process struct stands the risk of going stale
if process_mem_open() is called just before the debugfs dentry is
destroyed. Instead of storing and using the pointer pass the process pid
to process_mem_open() and do a lookup to ensure that we always get active
processes.

Conflicts:
        drivers/gpu/msm/kgsl_debugfs.c

Change-Id: Ic0dedbad3a3b54dc96251663fdf89c466fef3ca5
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: mdss: add tracing events in mdss driver

Add tracing points in key points in driver.

Change-Id: Ie31e27be4890e2e7cd573c00dbf3f66fa9c62060
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Ingrid Gallardo <ingridg@codeaurora.org>
Signed-off-by: Vineet Bajaj <vbajaj@codeaurora.org>
msm: mdss: Cleanup handling of dual dsi broadcast mode

When broadcast mode is enabled for dual dsi panels, the two dsi
controllers act in a master-slave configuration. A lot of configuration
in the driver requires special handling in such scenarios. Current
implementation has a lot of redundant code to check for broadcast mode
configurations. Rework the code to remove these and add a unified set of
APIs to query broadcast mode configurations.

Change-Id: I634f94266e8dce28bcaa897ef39e7c3ca9b558e5
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: cleanup dsi clock handling

Currently the DSI driver uses a two level reference counting for
the clocks used by the driver so as to ensure that the clocks are
correctly configured for dual-dsi use cases. However, this is not
necessary as the same can be achieved by using a single reference
count. Clean up the code to remove the sub-level ref counts and
add necessary error handling.

Change-Id: I6f1c1bfe83322dc0e1da3d757b6ca88cd629663e
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: Add support to selectively control bus and link clocks

DSI driver needs two different types of clocks for normal
operation - bus clocks and link clocks. The clock control function
enables/disables both these set of clocks together. However,
under certain circumstances, it is required to control just the
link clocks or the bus clocks. To support this, add separate
ref counts for link and bus clocks and modify the clock control
function to selectively control these clocks.

Change-Id: I25312131fc737b56dc15f4edf5e55a5824dad855
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: Turn on DSI link clocks after exiting ULPS

DSI branch clocks should only be enabled after removing the DSI clamps
when exiting the Ultra Low Power State (ULPS). If this is not enforced,
then the RCG for these clocks may not get turned on correctly which
may eventually lead to some display corruption. Fix this by
appropriately modifying ULPS exit sequence.

Change-Id: I5109dd140f8921256f95eb479dd33a73615d489f
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: dsi: check ULPS state only for active lanes

It is possible that for certain panels, not all four data lanes are
active. After configuring the lanes to Ultra Low Power State (ULPS),
only check the status of the active lanes since the lanes that are not
used will never enter ULPS.

Change-Id: I0da358f2bd24d4472cfccb6cca9ca8b26ffa8226
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss add bw related events for command mode panels

Add events to observe when bandwidth is requested,
when bandwidth is needed and when bandwidth is released
for command mode panels.

Change-Id: I56b8ce28683696bee50e9cd10351076c49e4a84c
Signed-off-by: Ingrid Gallardo <ingridg@codeaurora.org>
Signed-off-by: Vineet Bajaj <vbajaj@codeaurora.org>
msm: mdss: add systrace begin/end trace events

Adding trace points for systrace at various points in
the driver.

Change-Id: I4783fd2982bddb7f111de9e064bcaff153eb1ce1
Signed-off-by: Vineet Bajaj <vbajaj@codeaurora.org>
Merge "msm: mdss: set default value of panel mode gpio to -EINVAL"
msm: mdss: Dynamic FPS using VFP

Using Fixed fps and v_total for BW calculations, it
results in underrun if dynamic fps and v_total is used.
Dynamic FPS change should be Mutex protected for
synchronization between read/write so that multiple
processes don't change fps at the same time. Line
count should be checked to make sure we have sufficient
lines before we start programming FPS. Do not configure
new fps when vsync timeout happens. Add support for
FIFO empty recovery.

CRs-Fixed: 651333

Change-Id: Icff48a7f85755484a321f0de26d4816f895c367e
Signed-off-by: Justin Philip <jphili@codeaurora.org>
Signed-off-by: Nirmal Abraham <nabrah@codeaurora.org>
msm: vidc: Fix various decoder downscalar issues

Queue output buffers without extradata to Venus.
Venus is returning UPSCALE_NOT_SUPPORTED error when
output2 size is bigger than output size. This change
suppresses this error as it is not fatal.

Change-Id: I8a3f708092b131400b88828f6c1a684f08b3f18a
Signed-off-by: Manikanta Sivapala <msivap@codeaurora.org>
usb: gadget: Fix synchronization issue between f_audio_source

Race is happening when both audio_pcm_close() and audio_send()
executes in parallel.
When the PCM session is closed, the substream attribute of the
audio_dev structure is set to NULL in audio_pcm_close().
As there is no synchronization protection for the audio_dev subtream
attributes in audio_send(), it is causing NULL pointer dereference.
Hence fixing the issue by adding proper synchronization protection
for the audio_dev subtream attributes in audio_send().

CRs-Fixed: 613498
Change-Id: Id9ab0d4e347b8bb2f551f9033829e541bdcaf0e8
Signed-off-by: ChandanaKishori Chiluveru <cchilu@codeaurora.org>
usb: dwc3: otg: Don't set psy type to BATTERY if no charger connected

USB driver incorrectly sets USB power supply type to BATTERY on
charger disconnect. Some userspace client may fail to work properly
by assuming that usb_psy i.e. '/sys/class/power_supply/usb' is
of type battery and subsequent reading of battery status from this
USB supply will fail. Hence, set this to POWER_SUPPLY_TYPE_UNKNOWN.

CRs-fixed: 676051
Change-Id: I0a93b607f8cb328486397fa7bc96ff2177db5a77
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Merge "usb: dwc3: otg: Don't set psy type to BATTERY if no charger connected"