CHROMIUM: drm/exynos: add support for hdmi audio through alsa soc

This patch adds provision for register hdmi-audio as a alsa component
and controlled bu ALSA core.

Change-Id: Ic69a718c281f2dfdf00df273f8687cc7e0cd5428
Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
(cherry picked from commit a8a603438f915ca808cd4efe40a6623dffa87e37)

Conflicts:
	drivers/gpu/drm/exynos/exynos_hdmi.c
drm/exynos: add mixer apply function

Currently, an enabled flag for each mixer window is being set
in both mixer and the common hdmi framework. This patch adds
an apply function in mixer and moves the enabled flag inside
the mixer. This is required to ensure the enabled flag is updated
by the resume flag during dpms.

Signed-off-by: Prathyush K <prathyush.k@samsung.com>
(cherry picked from commit 75357cccececdc25a7ecdab8f1088175cebdbbe7)

Conflicts:
	drivers/gpu/drm/exynos/exynos_drm_hdmi.c
	drivers/gpu/drm/exynos/exynos_drm_hdmi.h
	drivers/gpu/drm/exynos/exynos_mixer.c
drm/exynos: mixer: do not finish a pageflip if layer update in progress

We should not finish a pageflip or set wait_for_vblank to zero
if a layer update is pending. This might result in a page fault or corruption
on screen. This patch adds a check in the irq handler to exit if a layer
update is pending. Also, calls layer_update only once per layer per vsync.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Prathyush K <prathyush.k@samsung.com>
(cherry picked from commit f3d35d2eacc9303913dbb258fd66ab09bf38c950)

Conflicts:
	drivers/gpu/drm/exynos/exynos_mixer.c
drm/exynos: hdmi: add complete_scanout function

The wait_for_vblank interface is modified to the complete_scanout
function in hdmi. This inturn calls the complete_scanout mixer op.
This patch also adds the mixer_complete_scanout function.

Inside mixer_complete_scanout, we ensure that a framebuffer with a given
dma-address can be freed without causing a page fault. This is done in
two steps:
1> if the base register has that dma-address then the dma will start
reading from that address in the next vsync. So disable the window.
2> if the shadow register has that dma-address then we need to wait
for the next vsync so that the dma is finished. When the next vsync
comes, either the dma will start reading from a new address or the
window will be disabled. So we can free the framebuffer.

Change-Id: I41889e669dbafded293a66215e9c10057f739a89
Signed-off-by: Prathyush K <prathyush.k@samsung.com>
(cherry picked from commit 772bd25defe930488255a17f8c44784c01752794)

Conflicts:
	drivers/gpu/drm/exynos/exynos_drm_hdmi.c
CHROMIUM: drm/exynos: hdmi/mixer: remove useless mutexes

These mutexes don't do anything useful, they just add some pointless locking.

Perhaps we shouldn't be commiting or applying while powering on/off.
However, these mutexes certainly aren't stopping that the way they are used.

In fact, the mutex_lock in mixer_win_commit is really bad and can cause the following
BUG when committing a deferred page flip in the mixer irq.
This can happen during hdmi hotplug:

BUG: scheduling while atomic: swapper/0/0/0x40010000
...
[<805051dc>] (__schedule_bug+0x50/0x5c) from [<80509f00>] (__schedule+0x78/0x670)
[<80509f00>] (__schedule+0x78/0x670) from [<80058708>] (__cond_resched+0x30/0x40)
[<80058708>] (__cond_resched+0x30/0x40) from [<8050a5a4>] (_cond_resched+0x48/0x50)
[<8050a5a4>] (_cond_resched+0x48/0x50) from [<805095ec>] (mutex_lock+0x1c/0x60)
[<805095ec>] (mutex_lock+0x1c/0x60) from [<802c1098>] (mixer_win_commit+0x50/0x96c)
[<802c1098>] (mixer_win_commit+0x50/0x96c) from [<802c23b8>] (drm_mixer_commit+0x90/0xb0)
[<802c23b8>] (drm_mixer_commit+0x90/0xb0) from [<802b2258>] (exynos_drm_encoder_plane_commit+0x68/0x80)
[<802b2258>] (exynos_drm_encoder_plane_commit+0x68/0x80) from [<802b1ff4>] (exynos_drm_fn_encoder+0x68/0x80)
[<802b1ff4>] (exynos_drm_fn_encoder+0x68/0x80) from [<802b7128>] (exynos_plane_commit+0x28/0x30)
[<802b7128>] (exynos_plane_commit+0x28/0x30) from [<802b2d10>] (exynos_drm_crtc_update+0x68/0x7c)
[<802b2d10>] (exynos_drm_crtc_update+0x68/0x7c) from [<802b3c88>] (exynos_drm_crtc_finish_pageflip+0x1a4/0x21c)
[<802b3c88>] (exynos_drm_crtc_finish_pageflip+0x1a4/0x21c) from [<802c0578>] (mixer_irq_handler+0x100/0x150)
[<802c0578>] (mixer_irq_handler+0x100/0x150) from [<8008886c>] (handle_irq_event_percpu+0x4c/0x234)
[<8008886c>] (handle_irq_event_percpu+0x4c/0x234) from [<80088aa0>] (handle_irq_event+0x4c/0x6c)
[<80088aa0>] (handle_irq_event+0x4c/0x6c) from [<8008bbf4>] (handle_fasteoi_irq+0xc4/0x12c)
[<8008bbf4>] (handle_fasteoi_irq+0xc4/0x12c) from [<800881e8>] (generic_handle_irq+0x30/0x40)
[<800881e8>] (generic_handle_irq+0x30/0x40) from [<8000f320>] (handle_IRQ+0x74/0x9c)
[<8000f320>] (handle_IRQ+0x74/0x9c) from [<800085ec>] (gic_handle_irq+0x4c/0x70)
[<800085ec>] (gic_handle_irq+0x4c/0x70) from [<8000df00>] (__irq_svc+0x40/0x50)

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

BUG=none
TEST=none

Change-Id: Idb25a699e23a905eebe9b11bfac8751c2b0bbe45
Reviewed-on: https://gerrit.chromium.org/gerrit/50601
Commit-Queue: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
(cherry picked from commit 21f51242c8c4522587b3d715a09f1ef057c839eb)

Conflicts:
	drivers/gpu/drm/exynos/exynos_hdmi.c
	drivers/gpu/drm/exynos/exynos_mixer.c
drm/exynos: add complete_scanout interface

Before freeing a framebuffer, we call complete_scanout encoder
function which just calls wait for vblank of all the encoders.
This is not a very optimized method since a framebuffer might not
be in use by a crtc and we end up waiting for vblank unnecessarily.

Instead, this patch modifies the wait_for_vblank interface to
complete_scanout interface. In this function, each crtc must
check if the fb is currently being used. If it is being used,
it must wait for vsync (or even disable a window if necessary)
and ensure that the buffer is no longer used by crtc before returning.
So if a crtc is not actually reading from the buffer, the complete
scanout function will just return and not wait for vsync.

Signed-off-by: Prathyush K <prathyush.k@samsung.com>
(cherry picked from commit 294971c1bc1660637eb778a46281973fe4a205b9)

Conflicts:
	drivers/gpu/drm/exynos/exynos_drm_fb.c