Revert "REVERT THIS BEFORE UPDATE ion: Rename heap_mask when used in userspace"

This reverts commit 163ab5fbe9b2db46bb169fd8d883aa15eac3d3cb.

Change-Id: Iabb6617c0a1b0d0a3987bac251e770fb8a3cc5c2
msm: vidc: Send resolution along with output buffer

This is only used for building the new kernel/caf-new
This reverts commit 6dc7b8cace93bd1bf2d28cf5194eb466b0513f6f.

Change-Id: If5838bf339a0f76913542804969caa1410792c4f
msm: vidc: Add error handling for load resource failure

- If the clip dimensions are less than/equal to the max dimensions,
  then FW returns HFI_ERR_SESSION_UNSUPPORTED_SETTING.
- Added error handling for load resource failure.

Change-Id: I3dff79b08fbc5bf9c2e61bfd157b12bb2cd93966
CRs-Fixed: 527188
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
msm: vidc: Validate session_id in video hardware response

Validate session_id present in video hardware response
packet before processing it. This will avoid system reset
resulting from invalid session_id returned from video hardware.

Change-Id: I37525a3d10b5efe00734c5533931e2700f3c7513
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
msm: vidc: Add support for H.264 LEVEL 5.2

For high resolutions and bit rates, H.264 spec
defined new level. This change adds support to
pass LEVEL 5.2 to FW.

Change-Id: I2298989734450a4f5eee285326afacc4a0836b41
Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
msm: vidc: Enable venus power management

Besides clock gating, turn venus core power off
if the core stays idle for given amount of time.
Powering off venus core involves telling TZ to
suspend venus core, detach IOMMU, disable GDSC
regulator, unvote DDR/OCMEM buses.

Turn it on again when driver starts processing new
commands before enabling clocks.

Protect clock and power states and operations
with a common lock.

Change-Id: I49654069920ddaae0e2f8792b14cd1bfeb431c34
Signed-off-by: Sachin Shah <sachins@codeaurora.org>
msm: vidc: Make HW timeout and power collapse delay configurable

Provide debugfs node for HW response timeout and a sysfs device
attribute for power collapse delay.

Signed-off-by: Sachin Shah <sachins@codeaurora.org>

Conflicts:
	drivers/media/platform/msm/vidc/msm_v4l2_vidc.c

Change-Id: I03333836409ba50e1532997f5b7bd66fbabf592d
msm: vidc: Fix a race condition with core instances list

All list operations for core instances list needs to be
protected by mutex. Add mutex for the same.While adding
the new instance to the core instances list, the list
needs to be protected by mutex. This is protected by
incorrect mutex.Fix an issue to acquire proper mutex.

Change-Id: Ibbb11678881fb5d63ce4161fcb4fcd317ddf3259
Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
msm: vidc: Skip session id validation for HFI_EVENT_SYS_ERROR

When SSR is triggered from driver, firmware is responding with session id
as 0X0000dead. Hence, firmware response is being discarded due to such
invalid session id. Skip session id validation for HFI_EVENT_SYS_ERROR
event type.

Change-Id: I750a7332baab4ebeb7702b49ffb744aae9803a36
CRs-Fixed: 539080
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
msm: vidc: Protect remaining clock operations

Clock enable/disable operations are only protected
during interframe clock gating and power collapse.
With this change, clock operations are also protected
during device initialization and removal.

Change-Id: Idcc81b7563349a45affe4abf0a148c4386be3aa0
Signed-off-by: Sachin Shah <sachins@codeaurora.org>
msm: vidc: Supress non fatal Session errors

FW sends SESSION_ERROR for various reasons. The session error
might not be fatal always. This is conveyed using event_data1.
Driver needs to process this message and supress non fatal
errors and reports only fatal errors to clients.

Change-Id: If9ded26977805e2c2299ef1c4a63212d2679495c
Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
msm: vidc: allow clients to set buffer size on OUTPUT plane

Accept the size set by clients for buffers on decoder's OUTPUT
plane. Limit the size based on the max width and height
supported by fw.

Change-Id: I76d0641ede9f3a5aa444e192a723b97b789229e1
Signed-off-by: Shalaj Jain <shalajj@codeaurora.org>
msm: vidc: Add clocks and power counts

Enable power and clock ref counts in debugfs
to easily debug any ref count mismatch.

Change-Id: If06ef139f5a4517cb29a84e86193a6cc2c0f9e64
Signed-off-by: Sachin Shah <sachins@codeaurora.org>
msm: vidc: Add correct enum session_type instead of core_id

- Initial setup_event_queue is using core_id enum instead of
  session_type for msm_video_device parameter
- Fix the issue by using session_type instead of core_id

Change-Id: I2b1c2c46351afbba1488cb5b1aa4d6f8a2a0f1d3
CRs-fixed: 537916
Signed-off-by: Jayasena Sangaraboina <jsanga@codeaurora.org>
msm: vidc: Add support for encoder rotation

Venus FW supports rotation. Driver sets the rotation
angle and updated height and width. Rotation support
added for Venus based chips.

Change-Id: I564dea14140accf09621357c4a40b8769e719e3a
Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

Conflicts:
	drivers/media/platform/msm/vidc/msm_venc.c
msm: vidc: Synchronise data shared between controls

Some of the V4L2 controls perform similar tasks and have some shared
data between them.  Unexpected sequences of controls can possibly cause
data coherency issues causing the firmware to be programmed incorrectly.
So, when a control is updated with a new value, update related controls
with a similar enum so that they both have similar values.

Also, change the frame rate values to normal FPS rather than Q16 format.

Change-Id: Iebb0ddc33374ab8eb7106b005965c2eede797aea
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
msm: vidc: Add support for encoder scaling

Venus FW supports upscaling and downscaling for encoder.
The supported scaling ratios are returned from Venus FW
as part of session_init_done message. Driver needs to
make sure that the scaling ratios are within the range.
This change adds the scaling support for encoder.

Change-Id: Ibf158cf35e93c45dd89715845a549871146a8eea
Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
msm: vidc: Add support for encoder deinterlacing

Venus FW supports deinterlacing for encoder. FW doesn't
support deinterlacing along rotation. Driver needs to
make sure that rotation and deinterlacing are not called
together. This change adds encoder deinterlacing support.

Change-Id: I97545e48190720af243a62b395efdf6a1a1fd15d
Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

Conflicts:
	drivers/media/platform/msm/vidc/msm_venc.c
	include/linux/videodev2.h
msm: vidc: Add support for FW version check

Encoder VPE and decoder DS features need to be supported
on targets which are using Venus 1.4 FW. FW sends version
as part of system property message. Driver needs to process
the version and reject VPE and DS features accordingly.

Change-Id: I600d402f36aa9bb484fc8dca76fce7d8f9120521
Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
msm: vidc: Add support for decoder downscaling

Venus FW supports downscaling for decoder. Venus
FW sends the supported downscaled ratios. Driver
needs to make sure that the scaling is inside the
supported range. This change adds support for decoder
downscaling.

Change-Id: I919e563a6ba64751b3355658bcdbcec9d9ef17eb
Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

Conflicts:
	drivers/media/platform/msm/vidc/msm_vdec.c