msm: vidc: Add support for different errors

When hardware is overloaded or when max number of clients are
reached in driver or firmware, hardware error is sent to video
client. This change is to replace hardware error with actual
errors.

CRs-fixed: 575852
Change-Id: I07e599f894a3716a3dc4fed5eb7c987311f5bdde
Signed-off-by: Deepak Verma <dverma@codeaurora.org>
msm: vidc: configure and set hier-p layers

Firmware requires the max number of hier-p layers
to be used during the encode session to be set
in load resources state. Without this change,
firmware will not enable hier-p encoding. Also
switch to using HFI_PROPERTY_CONFIG_VENC_HIER_P_ENH_LAYER
to set the number of hier-p layers.

Change-Id: I1fbf835acdb7d0a06d33cf9c2d038fb87c10010d
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: Add support for setting initial qp

Adds support to set initial qp, thereby allowing the client to set
initial qp for I,P, and B frames.

Change-Id: Ie956651bde85e800d97a0007769af9aec8ca16a4
Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>
msm: vidc: Add AFD and CC metadata support to extradata

Add support and control for setting Active format
description and closed caption meta data in the
extradata. FW parses metadata and adds it to the
extradata. Client can use control to parse extradata
for the metadata information.

Change-Id: I79fb71e635927c95e0792862c9dea7d96f58e895
Signed-off-by: Jayasena Sangaraboina <jsanga@codeaurora.org>
msm: vidc: Amend calculation of buffer sizes in VENUS_BUFFER_SIZE

Add 8KB worth of padding for extradata. This is required to accommodate
some of the larger extradata types that didn't fit into the residual
space between the actual buffer size and its aligned size.

CRs-Fixed: 647378
Change-Id: I550f806079dfbdece229f68ffdfc5c0e20b3c9e1
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
msm: vidc: Expose extradata size to userspace

Previously, the extradata size was included within VENUS_BUFFER_SIZE
and callers (primarily in userspace) wouldn't know how much extra
padding was added to the buffer size. Exposing it allows userspace to
query directly instead of doing guesswork.

Change-Id: I7f9701a4adfe364d757028514bdd4fa84402a995
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
msm: vidc: change concealment color

0x8080 is gray color concealment, changing it to
black color, which is 0x8010.

Change-Id: I50897d771913ee33a5b2c2ea486996dfc0c294bf
Signed-off-by: Manikanta Sivapala <msivap@codeaurora.org>
msm: vidc: Change in input buffer size calculation

Right now, input buffer size is calculated based on
maximum supported height and width returned from FW.
These values are not true representation as they are
calculated for rotation usecase. Driver needs to use
max MB supported from FW. This change fixes the same.

CRs-Fixed: 599818
Change-Id: I5b5f7d0db1088a4bc16ec7a32b31e1f763d5da7c
Signed-off-by: Manikanta Sivapala <msivap@codeaurora.org>
msm: vidc: add new control for limiting i/p buffer size

Take the minimum of the size calculated by driver using
max width and height supported and the size set by client
for input buffers. Change interface to get input and
output buffer sizes.

Change-Id: Ia3eb4cc7ae7bb38e2650fff1b694623e2aab62ef
Signed-off-by: Manikanta Sivapala <msivap@codeaurora.org>
wlan: Add debug print NV download failure

Added a debug  print for the return type in case
of NV downlaod failed.
CRs-Fixed: 717777
Change-Id: I3287089cad83d37641c71da9829ef4e89d7aeca0
Signed-off-by: Kaushik, Sushant <skaushik@codeaurora.org>
diag: Mode reset command has to be handled on APPS proc

Mode reset command is handled by APPS proc. If the apps process
has not registered with diag for handling the mode reset command,
diag has to send error response code back. This patch fixes
that issue.

Change-Id: Id4d99f0e909fa3a78e8682825984a99042021bad
Signed-off-by: Katish Paran <kparan@codeaurora.org>
msm_serial_hs: Handle client requests without port open

Adding defensive checks in the APIs to handle the
client driver requests calling without port open.

Change-Id: I0d618abbc7a38151651550a07aa909689ce92054
Signed-off-by: Dilip Kota <c_dkota@codeaurora.org>
crypto: msm: re-work qcrypto driver clk and bus management

This patch re-works bus scaling and clk management to respond to
the actual crypto engine usage. The driver suspend/resume are
integrated with overall driver clk and bus management.

Furthermore, two functions are added to the low level crypto driver. Low
level crypto driver is informed to save and restored hardware context if
necessary across PM suspend/resume.

Change-Id: Ic906e0c7e96dee847253d6ef57341d1a38e294cf
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
crypto: msm: Add support for FIPS complience

FIPS140-2 certification asks to do a Power on Known Answer tests on each
algorithm which is getting certified. This patch implements the self tests
and hardcoded test vectors.  Also, we need to verify the integrity of
kernel as soon as it boots up. This patch also adds an ioctl for
integrity test along with ioctl to query FIPS status (pass / fail) from
user land.
also, The piece of code is added for FIPS compliance DRBG under
drivers/char/hw_random
This change is already merged to KK mainline.

Change-Id: I7f3355602d5c2dfaefce0c0e4f9225fde0c5f485
Signed-off-by: Dinesh K Garg <dineshg@codeaurora.org>
hw_random: msm_rng: fix a null pointer dereference

This change prevents a possible null pointer
dereference in msm_rng.c by moving the function
call under if block.

Change-Id: I481b39c91e495692e575a90b392095e95eb1f367
Acked-by: Saurabh Sabnis <ssabnis@qti.qualcomm.com>
Signed-off-by: Dinesh K Garg <dineshg@codeaurora.org>
crypto: msm: Remove bw_reaper_timer while in suspend mode

Remove bw_reaper_timer timer while in suspend mode. Otherwise, it
may cause power regression than normal.

Change-Id: I5cab2b75baf96e08c7f7a179fdd15509bd919a69
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: William Clark <wclark@codeaurora.org>
crypto: msm: change timer operation to fix timer list corruption

remove the dulplicate init_timer operation in _qcrypto_resume and
replace add_timer with mod_timer to resolve timer list corruption.

Change-Id: I206016686be568ce2eefc41ea74d34639a8b04e5
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
crypto: msm: Don't enable crypto clock in PM resume

If a PM suspend happens right after resume, crypto driver returns
-EBUSY, since reaper worker thread has not kicked in. The suspend
can only succeed after timer kicks in to disable crypto clock and
free bus.
The solution is as the following. Don't enable crypto
clock and allocate bus bandwidth when entering resume if
there is no outstanding crypto requests. The next crypto
operation will enable crypto clock then. Further more, this patch
shortens the reaper timer from 1 second to 200 ms.

Change-Id: I116cf1454b020ee2886c8bf6696b6411a5df83b6
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
crypto: msm: Make changes to the reaper timer

Change the periodical reaper timer to on-demand basis. The reaper timer
is only set to disable clock after the clock is enabled, and it is
removed when there is no crypto operations. So that we can prevent the
timers from unnecessarily waking up the CPU from power collapse. The
timer interval is changed to 1 second.

CRs-Fixed: 719848
Change-Id: I88901653b779315de558a33ec6d92979c0176e28
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
crypto: msm: check potential integer overflow

According to the specification of AEAD, AEAD request crypt length is
not a fixed maximum and associated length is also same. This could
lead to potential integer overflow, thus allocating less memory. So
we need to check potential integer overflow on AEAD request length.

CRs-Fixed: 726872
Change-Id: Ie7708000bfd8c57e2fba8e02230a7ce9cdc9634c
Signed-off-by: William Clark <wclark@codeaurora.org>