msm: vidc: fix corruption of registered buffer list

The buffer list for output buffers is accessed from
different threads leading to race conditions. Consider
the case of firmware throwing up a fatal error, which gets
propagated to v4l2 client. The v4l2 client closes the
driver fd, which will trigger msm_vidc_release_buffers
to release all output buffers and free node from
the registered buffer list. During this time, if
firmware sends a release reference event, the buffer
node being accessed in msm_vidc_release_buffers could
be freed, triggering kernel panic.

Change-Id: I522edff06a62dbc2ab60d6cca5990babb18d5c6c
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: added v4l2 control to set the color of concealed MBs.

The conceal color is set to be green by default, while some users
required it to be black.
Set it to be configurable by adding this v4l2 control.

Change-Id: I25565ee837c011f5875ce91bde23a169fbdb0709
Signed-off-by: Jia Meng <jmeng@codeaurora.org>

Conflicts:
	drivers/media/platform/msm/vidc/msm_vdec.c
msm: vidc: Send ABORT in FLUSH command from the Client

When session error is sent to the client, client issues FLUSH
and release buffers commands. But as instance state is INVALID,
these commands are never sent to the firmware, instead FLUSH
DONE and Release buffer done are sent back to client even
though firmware might be working on these buffers which may
result into page faults.
This change fixes the issue by sending ABORT command to the
firmware at the time when driver receives FLUSH command. Then
firmware will release all buffers, clean up session and send
ABORT_DONE back to the driver.

Change-Id: Ie4c79a312d2336c68b858f5f5e2a85331cf55f7b
CRs-fixed: 592920
Signed-off-by: Deepak Verma <dverma@codeaurora.org>
msm: vidc: reduce clk frquency before disable

The change ensures that the clock frequency is reduced to min
before we disable it.
With just clk_disable, rpm still votes for high voltage on CX
as venus vote is not removed.
To unvote, the frequency is set to min.

CRs-Fixed: 574365
Change-Id: I8e0515b9816f8c451d545443573afaba611aafe7
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
msm: vidc: Fix unsupported codec error from video driver

- Client is getting unsupported codec error for set format
  sometimes after opening the video driver because driver
  was not updated with supported codecs information from
  video hardware.
- The same issue can be fixed by waiting for the driver state
  changed to CORE_INIT_DONE, which ensures the supported codecs
  information will be updated in video driver, before checking
  the supported codecs information.

CRs-fixed: 590158
Change-Id: Ia9132fdc01e4fa53533a3c9d14069d49501fa7d7
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
msm: vidc: Fix a race condition in masking interrupts

Fix a race condition when interaction with firmware happens
in following sequence:

1. Firmware writes IDLE message into the message queue.
2. Driver writes a new command into command queue.
3. Firmware reads this command and starts processing it.
4. Driver checks if command queue is empty and finds it empty.
5. Firmware writes the response (of the command sent in 2) in
   message queue. Firmware also writes another IDLE message and
   sets the idle register.
6. Driver check if the IDLE register is set and finds it set.
7. Driver masks the interrupts. Since interrupts are masked,
   driver misses the response written by firmware in 5.

This race condition is fixed by checking if message queue is
empty or not between 6 and 7.

Change-Id: I4e11210deeef855bb67337b8958aea73ae77d16b
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

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