msm-vidc: Modify Q6 HFI not to alter VP8 max supported width

Modify Q6 HFI not to alter the core returned max supported
width and height. Whereas venus HFI will alter the the max
supported width and height to 1080p.

Signed-off-by: Ravi Kiran Vonteddu <rvontedd@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: vidc: Query deblocker parameters from cluster

Various fields of h264_db_control were left uninitialised before being
sent to the firmware.  As a result, due to poor luck, the resulting
encoded bitstreams were invalid as the alpha and beta were not in the
acceptable range of [-6, 6].  This commit fills the uninitialised values
with values obtained by querying the cluster.

Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Add memory pool information to debugfs

This change adds the address of different diag memory pools to
debugfs to check for corruption.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Handle diag memory pool correctly in diagchar_write

Memory allocated from the diag memory pool was not freed
correctly and mutexes were not unlocked properly. This
change adds fixes the memory leak and the mutex unlocking
issues.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: dci: Protect dci client's data buffer with mutex

Data coming from smd is processed and written into client's data
buffer. The read thread reads the data from the buffer and resets
the length of the data in the buffer. This change fixes the
concurrency problem.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: dci: Add dci-smd debug information

This patch adds dci debug information to diag debugfs. We now
store the information about the last few dci smd reads - including
the size of data and the timestamp of data arrival.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Add Support to switch between real time modes

Adding support to switch mode of Diag on peripherals between
real time and non real time modes while using DCI/Memory Device.
Also added changes to record debug information related to
DCI in debugfs.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Ignore connecting to invalid hsic channel

Diag currently has support for 4 hsic channels. Added checks to
discard connections to invalid hsic channel in diag driver.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
usb: gadget: Remove usb_diag_free_req() API

Freeing USB requests either as part of cable disconnect or in unbind
case, both doesn't depends on diag driver to initiate usb free request
using usb_diag_free_req(). Freeing of USB request as part of cable
disconnect is handled in the code by freeing the USB requests in next
cable connect. In unbind case, usb requests are freed in usb driver
before releasing reference to usb diag device context.

Although freeing of usb request is taken care in usb driver, but it
is seen in few regression testing that calling usb_diag_free_req()
from diag is leading to synchronization issues. As USB doesn't depend
on the diag driver to initiate usb free request using API
usb_diag_free_req(), hence remove API usb_diag_free_req() from code.

Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Add wake_up when HSIC driver is finished writing

When the HSIC driver calls the write complete callback function
in the diag kernel driver, diag does not make a wake_up_interuptible
call. There is a chance that the thread in the corresponding
wait_event_interuptible may not be woken up. Make changes to ensure
that the thread that may be waiting is woken up.

Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Add apps diag support for STM

Add apps diag support for recording of apps diag
data (F3s, logs, and events) to STM.

[neo: Also add missing define of MAX_SSID_PER_RANGE]

Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: dci: Prevent apps proc from sleeping while processing DCI data

This change prevents apps processor from going to power collapse while
receiving data from the DCI channels. The driver now activates wakeup
sources on arrival of data and releases them upon copying the data
to the user space. This ensures the DCI clients get data while apps
processor is in deep sleep.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Add separate read threads for SMD data channels

Currently, diag uses a single thread for reading the data from
the SMD data channels. Make changes in diag so that there is a
separate thread used in reading each SMD data channel.

Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Add checks before allocating and freeing memory

Diag driver uses memory pool for internal  buffers. This patch adds
checks for freeing the buffer in a specific mode and while allocating
buffer in all modes.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Fix incorrect handling of diag polling command

During SSR, diag driver clears its command registration table and
rescans the table for polling command. It sets a flag after taking
into consideration the table entries that are zeroed out leading
to an incorrect registration status. This patch ignores the table
entries that are zeroed out and compares against the correct
polling commands to set the flag.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Handle Mutexes correctly in the case of Callback data

Diag driver grabs a mutex incorrectly when processing data from the
callback process leading to a deadlock. This patch fixes this
problem.

Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: diag over uart not working for QSC

On executing diag_uart_log app with QSC option
switching is not happening. On the other hand, MSM
switching is working fine. Added changes in order
to allocate memory to user space data type buffer
during diag char initialization.

Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Safeguard for bound checks and integer underflow

At certain point in diag driver there can be integer underflow
and thus can lead to memory leak. Bound checks are placed to
ensure correct behavior of condition statements.

Signed-off-by: Katish Paran <kparan@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Fix for diag debugfs buffer overflow

Diag debugfs buffer has potential buffer overflow scenario which can cause
memory corruption. Added safeguard to prevent this.

Signed-off-by: Sreelakshmi Gownipalli <sgownipa@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diag: Add hdlc encoding support for diag data sent from peripherals

Diag running on the peripherals currently hdlc encodes the diag
data prior to being sent to the APPS processor over the diag data
smd channels. To offload the peripherals of this workload, add support
to accept non-hdlc encoded diag data from the peripherals and
hdlc encode that data on the APPS processor. Maintain the backwards
compatability to accept and properly process hdlc encoded data.
Add ability to determine at run-time whether a peripheral is sending
hdlc or non-hdlc encoded data and process the data appropriately.

Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>