CHROMIUM: ASoC: SMDK: WM8994: Add device tree lookup support

Add the basic device tree based lookup.

Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
Signed-off-by: Prathyush K <prathyush.k@samsung.com>
CHROMIUM: ASoC: Samsung: Rename samsung i2s secondary device name

All Samsung SoCs has max 3 i2s controllers. So the i2s secondary fifo
interface device id was named as samsung-i2s.4. Renaming this to
"samsung-i2s-sec" to support device tree in i2s driver.

Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
CHROMIUM: ASoC: SAMSUNG: Add DT support for i2s

Add support for device based discovery.

Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
CHROMIUM: ASoC: Samsung: Update Kconfig for I2S,SPDIF and PCM audio

Update Kconfig file to enable I2S,PCM audio for wm8994 and spdif on all
samsung platforms.

Signed-off-by: Sangsu Park <sangsu4u.park@samsung.com>
Signed-off-by: Sangbeom Kim <sbkim73@samsung.com>
Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
CHROMIUM: ASoC: SMDK: wm8994: Add .pm to struct smdk_audio_driver

Missed .pm of struct smdk_audio_driver will prevent the audio
framework to call corresponding pm functions

Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
CHROMIUM: Asoc: Samsung: Add support for I2S runtime S2R

This patch adds runtime suspend to resume support for I2S

Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
CHROMIUM: Asoc: Samsung: Add I2S S/W RST in startup function

I2S module need to be reset after S2R. Keeping the S/W rst
control part in resume didn't help in playing audio after resume.
So this patch adds S/W RST control part in startup function which
gets triggered for every new audio stream playback.

Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
CHROMIUM: ASoC: samsung i2s - Don't setup if already active.

If the dai is already running when setup is called, skip setup.  Setting
up again caused set_sysclk to set rclk_srcrate to other->rclk_srcrate,
other would often be set to the default of 44.1.  Playing a 48k stream
then adding a 48k capture stream would lead to both streams set to 44.1
(The value of other->rclk_srcrate).

Similarly in shutdown, if either playback or capture are still active,
return instead of turning off the clocks.

BUG=chrome-os-partner:13769, 13749
TEST=aplay -Dhw:0 <any 48k wav file>, then arecord -Dhw:0 -f dat
/tmp/asdf.wav.  Make sure audio continues from aplay and is captured by
arecord, before this change aplay would stop and arecord would capture
silence.
Gmail settings, make sure microphone progress bar moves when you talk.

Change-Id: I1dd02854e234d23ac25ad686c7603e4bc9265b4e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32477
Reviewed-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: ASoC: Update pointer to account for pending dma transfers.

Make dma_pointer check how much of the current dma transfer has
completed.  This improves the accuracy of the pointer operation, which
previously was only updated once a period.  Before this change calling
snd_pcm_avail() right before a dma transfer completed would indicate
that the entire transfer was still pending, now it will indicate the
actual count of free frames.

If the dma being used doesn't support the residue operation to query a
pending transfer, then assume that no bytes have been transfered.  This
leads to the same behavior as before the change.

BUG=chrome-os-partner:12278
TEST=aplay -B10000 file assure no dropouts.
cras_test_client --playback_file sine.wav --buffer_frames 960 --callback_threshold 480 --min_cb_level 480 --rate 48000

Change-Id: I9149c1b54a1e56242094ea6ea9ff6246b384851b
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/30615
Reviewed-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: ASoC: Samsung: Protect the dma pointer position access

Takes spin lock to protect prtd->dma_pos from
concurrent access by the driver and the tasklet

BUG=chrome-os-partner:12565
TEST=ran multimedia tests for audio, video and webgl

Change-Id: I29054e75d01eb7a10401dbc75a17fca13e24ea0e
Signed-off-by: Abhinav Kochhar <abhinav@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33298
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Vikas Sajjan <vikas.sajjan@samsung.com>
CHROMIUM: ASoC: samsung: add daisy_max98095.c board

Add the ASoC board plumbing for max98095 on daisy/snow.

Change-Id: I34d390d808574dafc9dd463aaf21a6c7886d97a0
BUG=chrome-os-partner:8920
TEST=Kernel builds.
Signed-off-by: Taylor Hutt <thutt@chromium.org>
[olofj: Changed to device tree and some misc cleanup]
Signed-off-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: https://gerrit-int.chromium.org/19831
Commit-Ready: Olof Johansson <olofj@google.com>
Tested-by: Olof Johansson <olofj@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: ASoC: max98095: first fragment of DT support

First pieces of DT support for max98095. It will be filled in more as
we move the ASoC for exynos to device tree (and upstreamed when it has
more than just a fragment in there).

BUG=chrome-os-partner:10849
TEST=boot; arecord -r 44100 /tmp/foo ; aplay /tmp/foo

Change-Id: Ib1cece184a26a801caa82b496610bfc98063ca68
Signed-off-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27913
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: ASoC: samsung: HP detect plumbing for snow

This adds HP detect through the external GPIO on Snow. I've hardcoded
the GPIO for now since we need to move the whole ASoC configuration to
device tree (a la tegra) and will move it to a proper gpio specifier
there when we do so.

BUG=none
TEST=start up, browse youtube, bring up an awesome music video, plug in
headphones, rock out.

Change-Id: I9b7d1452f43f68f1e17bc8868f1d9c56d09db87b
Signed-off-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27866
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Katie Roberts-Hoffman <katierh@chromium.org>
CHROMIUM: ASoC: samsung: Route clocks to i2s.

Configure the clocks so that the i2s block is driven with a clock that
can be divided to the current audio frequency.  The rate of epll is
already being adjusted to match the frame rate, but epll was not being
configured to drive the audio clocks.  At init, set the clock muxes to
route epll through the muxes.  This fixes audio on Daisy playing back
too fast (6% fast for 44.1, almost 2x for 48k).

BUG=chrome-os-partner:11225
TEST=Play sine waves of various frequencies and check they are rendered
correctly with a spectrum analyzer.

Change-Id: I46c5f466088a825942931007b49fcde2e40e9fc6
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28453
Reviewed-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: ASoC: samsung: daisy_max98095 is a platform driver.

Convert daisy_max98095 to a platform driver that is compatible with
'google,daisy-audio-max98095'.  This brings it more in line with other
machine drivers from the soc tree and provides the ability to add GPIO
specifiers to device tree in subsequent commits.

BUG=chrome-os-partner;12112
TEST=aplay <wav file>, arecord, youtube audio works.

Change-Id: I5624686178d89afaef911c9a3eb067b7fb4902a0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29625
Reviewed-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: ALSA: ASoC: Get snow hp/mic detect GPIOs from device tree.

Get the GPIOs used for hp and mic detect from the device tree.  Getting
them from device tree allows for the pull up/pull down to be properly
configured (it is disabled) and for mic detect to be inverted.

BUG=chrome-os-partner:10849
TEST=aplay/arecord on snow work.  evtest shows events for hp and mic
detection.

Signed-off-by: Dylan Reid <dgreid@chromium.org>

Change-Id: I93d994a2ec5c22683c6eb5fd502f6a54c8e8d964
Reviewed-on: https://gerrit.chromium.org/gerrit/29626
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Ready: Dylan Reid <dgreid@chromium.org>
CHROMIUM: ASoC: max98095 - Add control for DMIC1 enable.

Add ability to switch the digital mic path on and off.  Daisy needs to
change this when an external mic is attached.  Just setting DMIC on/off
in device tree isn't sufficient.

BUG=chrome-os-partner:10849
TEST=Set control with amixer and check value with i2cdump.
Signed-off-by: Dylan Reid <dgreid@chromium.org>

Change-Id: Ied02eccb060a06742208ec7f8c3ef08e5f361964
Reviewed-on: https://gerrit.chromium.org/gerrit/30165
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: ASoC: max98095 - Export switches for MIC3 route.

MIC3 can route to either the MIC1 or MIC2 input.  Add a switch that
selects MIC3 as the source for each.

BUG=chrome-os-partner:10849
TEST=Set control with amixer check value with i2cdump.
Signed-off-by: Dylan Reid <dgreid@chromium.org>

Change-Id: I7095202d272f6d61bbf004426b3ce7cd2b710b5e
Reviewed-on: https://gerrit.chromium.org/gerrit/30166
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: ASOC: Samsung: Change MAX98095 MCLK input clk

This patch configures the codec system clock with xclkout.
with out this patch there is a error while playing 8,22.05,
32KHz sampling rate files. The error was

max98095 7-0011: Invalid master clock frequency
[ 46.194905] asoc: machine hw_params failed: -22
Stream error -22

BUG=chrome-os-partner:12733
TEST=Tested with all supported sampling frequencys in cramfs.
All are playing fine except 8KHz and 32KHz are playing with
some error messages like below

[ 1262.417869] exynos5_epll_set_rate: Invalid Clock EPLL Frequency
[ 1262.417885] failed to clk_set_rate of fout_epll for audio

Change-Id: I5891ac9bbae1eeb6befb6992699e59e3e8977c24
Signed-off-by: R. Chandrasekar <rcsekar@samsung.com>
Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/30538
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Ready: Doug Anderson <dianders@chromium.org>
CHROMIUM: ALSA: ASoC: max98095 0 Add built in EQ for 44.1k and 48k.

EQ setting supplied by Maxim after tuning a snow PVT device.
We need to move this to device tree eventually, but Samsung says it is
important for speaker protection to get it in right away.

BUG=chrome-os-partner:12039
TEST=listen to youtube with EQ enabled and disabled.

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