CHROMIUM: alsa/soc: ignore dvi mode bit when phy is unstable

HDMI Audio driver doesn't apply Audio settings if DVI
mode is set. But due to hardware implementation, DVI bit
in HDMI_MODE_SEL register cannot be used untill phy is in
stable state.

When hdmi cable is unplugged, phy is first reset and then
powered off. We can observe the DVI bit setting to 1 during
PHY reset. This bit remains 1 until HDMI driver sets it
based on the EDID values.

With this patch, driver is not relying on DVI mode bit alone
and also checks phy state before skipping the register
setting.

BUG=chrome-os-partner:22200
TEST=System works fine on Peach board along with S2R. HDMI
audio is enabled after hdmi cable is plugged.

Change-Id: Ib5a063f4cfea0620be84d7a107afbe8ce21b5329
Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/169742
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Humberto Silva Naves <hsnaves@gmail.com>
CHROMIUM: alsa/soc: fix the bps conversion from enum to value

hdmi audio driver in alsa/soc converts the SNDRV_PCM_FORMAT_S*
enums to corresponding bits per sample value. This coversion
was not done properly for bps 16 and 24. It is fixed with this
patch

BUG=chrome-os-partner:20249
TEST=basic hdmi works fine on Snow, Peach board.

Change-Id: I3a4f050460e18801734ebd9b8d52a3421b109f87
Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/58866
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: alsa/soc: increase wait count for hdmi poweron

When hdmi cable is plugged in during audio playback, it is
observed that few times hdmi IP is not powered on within 500
ms window after hotplug (each iteration of 5 ms, counts upto
100. To ensure that there are no such failures count is increased
to 200. This value seems safe as all failed cases windup within
107 to 120 iterations.

BUG=chrome-os-partner:20249
TEST=basic hdmi works fine on Snow, Peach board.

Change-Id: Ida89308c9f8ad81c3a1eeb5444c5892ce0d4cd9b
Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/58869
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Humberto Silva Naves <hsnaves@gmail.com>
CHROMIUM: alsa/soc: skip checking hdmi power status on unplug

While hdmi cable is upplugged, stop checking the runtime power
state of hdmi ip. During unplug, hdmi-audio driver doesn't access
the registers.

It is only meaningful when cable is plugged and hdmi audio registers
need to be updated with playing audio parameters.

BUG=chrome-os-partner:20249
TEST=basic hdmi works fine on Snow, Peach board.

Change-Id: I0d9920523f4cb096c1a72e64f3b904f0ac8d1209
Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/58870
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Humberto Silva Naves <hsnaves@gmail.com>
CHROMIUM: alsa/soc: check phy status before configuring audio registers

HDMI audio driver needs to configure the hdmi registers only after
phy is in stable state. Previously, register configuration is delayed
until HDMI driver has resumed from suspended state. But now HDMI
driver is not registering Runtime PM callbacks. Secondly due to
de-bounce logic added in hdmi driver for hotplug, it takes more time
for Phy to get stable.

This patch replaces the condition with a check for PHY stable state
before setting the audio configuration.

BUG=chrome-os-partner:22200
TEST=System works fine on Peach board along with S2R. Played audio and
then plugged hdmi cable. Audio is heard from hdmi display.

Change-Id: I7aecc841207dc3bf42c4968c0d7df7e073bedae2
Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/169743
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Humberto Silva Naves <hsnaves@gmail.com>
CHROMIUM: ASoC: samsung - make hdmi_audio ignore non-playback requests.

The hdmi_audio plugin callbacks change the HDMI audio state even if
those requests are not for playback (like recording). This inadvertently
makes stopping recording turn off HDMI audio playback. Now we ignore
those requests.

BUG=chrome-os-partner:22492
TEST=On daisy, while playing a wav file, start and stop recording. The
playback should not be affected.

Change-Id: I879732206b2c1e67730694d65fd77e5062d2af5b
Signed-off-by: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169515
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
(cherry picked from commit 25716b457ad56f5369cc4b0ec2fb906ab63e54fa)
Reviewed-on: https://chromium-review.googlesource.com/173363

Signed-off-by: Humberto Silva Naves <hsnaves@gmail.com>
CHROMIUM: ALSA: ASoC: exynos hdmi - disable audio in DVI mode

exynos-hdmi-audio used to configure HDMI to send ACR and AUI infoframes
even when DVI sink was plugged using HDMI-DVI cable.
This would cause monitor to go to sleep.

So, don't configure audio if HDMI is in DVI mode,
assuming the graphics driver already disabled it.

Also, if HDMI audio jack hotplugging was previously reported,
report that it was unplugged when DVI mode is detected.

BUG=chromium:222145,chromium:239641
TEST=Various HDMI/DVI plug/unplug scenarios, the most complex being:
play music, plug HDMI, suspend, unplug HDMI, plug DVI, resume,
listen to sound on internal speakers.

Signed-off-by: Yuly Novikov <ynovikov@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50726
Reviewed-by: Dylan Reid <dgreid@chromium.org>
(cherry picked from commit 1819d3da10dd1ee0c398a98e36d5ea0625855d3b)
(cherry picked from commit c17dd45a794c63db0b66faa2e3eddff3104cd6d0)
Change-Id: I7ff4f4c5c55de9dbed58a46dd103007762314d24
Reviewed-on: https://chromium-review.googlesource.com/174263
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>

Signed-off-by: Humberto Silva Naves <hsnaves@gmail.com>
alsa/soc: add pm callbacks to hdmi audio driver

HDMI audio driver does not provide PM callbacks to
handle S2R scenarios. Due to this audio doesn't
resume after S2R as hdmi-audio related registers get
reset.

While suspending, hdmi hotplug variable is set to
unplugged state to ensure that no dapm callback
access the registers. Resume callback checks the status
of the HPD gpio line and trigger the hotplug handler.
This ensures that registers are back to the pre-S2R state.
This is equivalent to call hdmi_commit for drm hdmi
driver in resume callback.

BUG=chrome-os-partner:24068
TEST=System works fine on Peach board. Tested S2R when hdmi
is connected along with audio playback.

Change-Id: I79fdaf2565b6074ca922d56ef081cfa4d74c9d77
Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/178483
Reviewed-by: shirish s <s.shirish@samsung.com>
Signed-off-by: Humberto Silva Naves <hsnaves@gmail.com>
CHROMIUM: alsa/soc: do not set AUI transmit when setting up infoframe

hdmi_reg_infoframe called from hdmi_conf_init unconditionally enables
sending AUI infoframe on every vsync. This register is also controlled
from hdmi_audio_control which is supposed to control HDMI audio.
Setting it from hdmi_reg_infoframe overrides hdmi_audio_control causing
HDMI audio to be always enabled, even on DVI monitors, which causes some
of them to blank when audio is playing in Chrome OS. This change removes
the unconditional setting of HDMI AUI transmit from hdmi_reg_infoframe
so hdmi_audio_control is really in control.
As a bonus, it also adds use of defines instead of literals for HDMI AUI
enable/disable in hdmi_audio_control.

BUG=chromium:331938
TEST=connect DVI monitor and play sound, it should not blank
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Ibb299597e57b294beb57299bc132786f7f9af7a7
Reviewed-on: https://chromium-review.googlesource.com/181967
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Commit-Queue: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Signed-off-by: Humberto Silva Naves <hsnaves@gmail.com>