CRAS: gpio jacks - support HDMI jacks.

Look for /dev/input entries with HDMI in the name that export a LINEOUT
switch.

BUG=chrome-os-partner:14435
TEST=plug/unplug HDMi jack on Daisy.  updated unit tests.

Change-Id: Ic1121f8ebe2f678553fa83e90cda5e8490626e3f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34576
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: alsa_io - Replace default output with a prioritzed list.

On Daisy, the main iodev has three outputs, Speaker, Headphone, and
HDMI.  This breaks the current scheme of routing to Headphones whenever
they are plugged, then falling back to default(speaker) when unplugged.
Instead there is a priority of devices, Headphones, then HDMI, then
Speaker.  Each time a plug event is received, find the highest priority
plugged device.

BUG=chrome-os-partner:14435
TEST=alsa_io_unittest, and manual plug/unplug of devices on Lumpy, Link,
and Daisy.

Change-Id: I7ec3bafb7bf0cf840c87cfd50b6edc2618a69d76
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34577
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
daisy asound.state - add HDMI switch init.

Default the new HDMI playback switch to off.

BUG=chrome-os-partner:14435
TEST=check state of control 91 after boot.

Change-Id: I087d496a06c352edb080a99c7ec452d24fdd5476
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34578
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: alsa_io - Set plugged for input devs.

Input dev setting of plugged had been overlooked.  Add it.

BUG=chromium-os:35056
TEST=Updated unittest.  Manual, plug USB headset, then analog, check
that analog mic is being used.

Change-Id: I1de5f3c727e940e4be9fbcd397abc9ceea3d813f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34687
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: dbus - connect to system bus

To support Bluetooth Audio we need a connection to the D-Bus System Bus
so that we can communicate with BlueZ; both to obtain the set of known
audio devices, and to create transports for media to them.

BUG=chromium-os:21369
TEST=D-Bus ListNames & GetConnectionUnixProcessID

Change-Id: I9e421bf40cc33332e22456a5cd638edaf362c358
Signed-off-by: Scott James Remnant <keybuk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35063
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CRAS: udev - coding style cleanup.

Remove unused enum.
Remove typedef for struct.
Fix one line over 80 char limit.

BUG=none
TEST=make check

Change-Id: I40ce030f614411f88665342a4b733cf74cf3cbfe
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35085
Reviewed-by: Scott James Remnant <keybuk@chromium.org>
CRAS: remove void param lists.

'(void)' for param lists were in a few places. Remove to match the rest
of the system.

BUG=none
TEST='make check'

Change-Id: I630b691bc2826148bbd3c4c61bf86fe65119572d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35075
CRAS: don't start dbus

It is asserting when it starts and isn't used yet.

BUG=chromium-os:35180
TEST=run cras, check it doesn't assert.

Change-Id: Ie178a82e8db2e50f9cbff226a98db329122dff06
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35199
CRAS: iodev - update supported frame rates.

Before setting the format of the iodev, check which formats are
currently supported.  On Daisy, the input and output must be run at the
same rate if used concurrently.  Updating the supported rates before
opening the device makes sure that a rate/channel count that will work
is chosen.

BUG=chrome-os-partner:15126
TEST=play youtube (44.1) then start a hangout(48k) check that the mic
works in the hangout.

Change-Id: I3430dc0f8fb13495dd6e385732bc8f46a4fc9619
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35369
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Set initial controls in daisy UCM config.

Configure the necessary controls for playback from the UCM config.  This
causes the settings to be configured later than asound.state and does it
in a way that is not dependent on control numbers.

BUG=chrome-os-partner:14870
TEST=remove asound.state from /etc and reboot.  Check that audio still
plays/records.

Change-Id: I88cad187f818efc7ad371d84023d7f7be68dcf9f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35609
Reviewed-by: Doug Anderson <dianders@chromium.org>
CRAS: dbus - cleanup and re-enable

Remove the use of assert() from the D-Bus code, replace with syslog()
in the non-recoverable cases.

Call cras_system_rm_select_fd() before closing a timeout fd to remove
it from the main loop, otherwise repeated timeout additions fail.

Dispatch pending D-Bus messages each time through the main loop.

BUG=chromium-os:21369
TEST=emerge-$BOARD cras & reboot, check for respawn

Change-Id: Ia49d3dbd35b1376011ad6bb2d76d3ebf5eb8ad98
Signed-off-by: Scott James Remnant <keybuk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35611
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CRAS: Import edid_utils from chrontel.

Cras needs to parse EDID and determine if the monitor is audio-capable.
Take edid_parser from the chrontel project.  Later commits will export
this from cras so chrontel can use this copy as well.

BUG=chromium-os:35285
TEST=none, coming later.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I6c9ef0f1cbfd39c6c4d15c4e6a9567d1aaf156dd
Reviewed-on: https://gerrit.chromium.org/gerrit/36183
CRAS: include edid_utils in libcras.

This will be used by chrontel on ZGB (Where it was stolen from).

BUG=chromium-os:35285
TEST=build Chrontel without it's local copy of edid_utils.

Change-Id: I34f8cf1012c4bbc27adbc915b321e0f855021cef
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36293
CRAS: Add UT for edid utils.

And add some consts so constant edid can be checked.

BUG=none
TEST=this is a test.

Change-Id: Ied6da0bc0320a355c326525751df37892ad07cee
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36184
CRAS: edid_utils - convert to kernel coding style.

BUG=none
TEST=edid_utils_unittest, checkpatch

Change-Id: Ib4e4f68de8d404ca5ae21d8f006ce86f536e9063
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36185
CRAS: ucm - Allow ucm config to specify an EDID file.

The EDID needs to be check to make sure than an HDMI device supports
audio.  Specify the EDID file per-jack in the UCM config as there isn't
a way to easily discover it.

BUG=chromium-os:35285
TEST=updated alsa_ucm_unittest.

Change-Id: Iddebf2def57b439ff8e51a46a129be2b69bf63c6
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36186
Add EDID file location to daisy UCM config.

CRAS will read this file to fetch EDID and check for audio support.

BUG=chromium-os35285
TEST=Attach HDMI monitor that doesn't support audio, sound should
continue from Daisy's speakers.  Attach audio-capable sink and audio is
routed to it.

Change-Id: Ifccc23f6b7ff2fd26dfae51939a6be1fa03d878d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36189
CRAS: Move timespec subtract to utils.

Function is needed outside of cras_clent too.

BUG=chromium-os:35285
TEST=Play some audio through the test client.

Change-Id: I6028fab23ca7d851ec277790219756bf24c34740
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36181
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: Add a timer module.

Add a timer module that can be used to implement delayed callbacks.
Delayed callbacks are needed by bluetooth already and will also be
needed to delay reading edid after a hotplug event.

BUG=chromium-os:35285
TEST=cras_tm_unittest

Change-Id: Ice16083fcf844a4342fdb31372eacef32a5c7c0d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36180
CRAS: system - run timer manager.

Initialize the timer manager in system state and export a function to
fetch it.  From the main server loop, wake up when timers are about to
fire and call the callbacks.

BUG=chromium-os:35285
TEST=make check, and play audio through the test client.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I410435c1d351f34345107277602b61cc26803ad3
Reviewed-on: https://gerrit.chromium.org/gerrit/36182