Commit graph

15 commits

Author SHA1 Message Date
Mark Greer f4706b848e greybus: gb-audio: Ensure i2c adapter struct exists before using
The current audio code uses i2c_get_adapter() without checking
that a non-NULL pointer is returned (i.e., that the i2c device
actually exists).  When that happens, the system panics.
Fix the potential panic by erroring out with -ENODEV when
i2c_get_adapter() returns NULL.

CC: John Stultz <john.stultz@linaro.com>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-29 18:04:38 -07:00
Phong Tran df76422113 greybus: audio: Remove the MODULE_LICENSE()
This is not a kernel module. It should not use
the module license macro.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:38:38 -07:00
Alex Elder 2de1a8b1a9 greybus: add copyright statements
The Greybus audio source files included no copyright statements.
Add them.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:47:56 -07:00
Alex Elder e9385e5d5a greybus: include "gpbridge.h" from "greybus.h"
Avoid the need for all the source files to include "gpbridge.h"
by just having "greybus.h" include it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:34:39 -07:00
Mark A. Greer 0d17e0c9f1 greybus: gb-audio: Set samples per message during init
A recent commit moved the I2S samples per message operation
to the PCM's 'hw_params' callback.  However, the 'hw_params'
callback is called numerous times while the samples per
message need only be done once (or seldom).  Eliminate the
unnecessary samples per message operations by doing it only
once at Greybus protocol init time.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:26:41 -07:00
Mark A. Greer 6b34099ec3 greybus: gb-audio: Set I2S Configuration according to ASOC requests
Currently, the audio driver unconditionally sets the I2S
configuration to have a sample rate of 48KHz, two channels,
16 bits per channel, in little endian order.  Make this
more flexible by setting the I2S configuration according to
the arguments passed to the PCM 'hw_params' callback.

To accomplish this, query for the supported I2S configurations
at Greybus protocol init time and save them in the 'snd_dev'
structure.  When the 'hw_params' callback is called, compare its
arguments to the table of supported configurations.  If there is
a match, set the I2S connection accordingly.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:26:41 -07:00
Mark A. Greer f9a4fee7fa greybus: gb-audio: Activate TX CPort in PCM workqueue
Currently, the I2S TX CPort is configured and activated during
the Greybus audio initialization.  Unfortunately, this prevents
the audio driver from ever changing the I2S configuration.

To allow the I2S configuration to change according to ASOC requests,
move the CPort activation & deactivation to the audio-pcm workqueue.
Now, when audio is running but the CPort is not active, it will be
activated.  When audio is not running and the CPort is active, it
will be deactivated.

This has the side-effect of sending the first piece of audio data
immediately after activating the CPort which is really how it should
work anyway.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:26:41 -07:00
Mark A. Greer 415b83111c greybus: gb-audio: Add I2C device for rt5647 codec
Add the I2C device node for the rt5647 codec.

Eventually, this will be done automatically somewhere
else but for now its done in the audio driver.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:26:41 -07:00
Mark A. Greer 827e27e8fe greybus: gb-audio: cpu_dai.fmt does not exist in v4.1
The asoc_simple_dai structure does not contain the 'fmt'
member in Linux kernel version v4.1 and later so only
build code that uses it when the kernel version is earlier
than v4.1.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:26:41 -07:00
Mark A. Greer 4c739e3ada greybus: gb-audio: Fix DAI formats and master/slave settings
Set the various DAI formats so the bridge on the module
is the master of all clocks and the codec is the slave.
The only DAI protocol currently supported is I2S.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:26:41 -07:00
Mark A. Greer 34aa7e1cad greybus: gb-audio: Clean up codec name generation
Instead of using the fixed suffix, '6-001b', in the
codec name, generate it from the I2S adapter number
and I2C address of the codec.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:26:41 -07:00
Greg Kroah-Hartman 13956900b0 greybus: audio: fix some sparse static warnings
This makes some functions and structures static, as warned by sparse, as
they don't need to be global.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-05-12 10:21:56 -07:00
Greg Kroah-Hartman 61c0926eec greybus: gb-audio: fix build breakage on 4.1-rc1
In commit 1efb53a220 ("ASoC: simple-card: Remove support for setting
differing DAI formats"), the .fmt field was removed from struct
asoc_simple_dai.  Fix this build breakage by not trying to set it.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Acked-by: John Stultz <john.stultz@linaro.org>
2015-05-11 13:26:44 -07:00
Greg Kroah-Hartman 7f3f356e45 greybus: gb-audio: fix build warning
sizeof wants %zu when on a 64bit build, so change the dev_err() call to
remove a build warning in the audio.c file.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Acked-by: John Stultz <john.stultz@linaro.org>
2015-05-11 13:26:44 -07:00
John Stultz a4749bbeee greybus: gb-audio: Add integrated greybus audio driver
So here's the current greybus audio driver, which I
wanted to send out for more serious review and
consideration for merging.

I've tried to integrate much of the feedback from the
last round and most of the hotplug issues that I've found
have been resolved. I've tested this via gbsim, and the
Android ARA HAL layer seems to work with it.

Mark has also successfully played audio with this driver,
adding a few hacks to get the codec's i2c connection to
probe.

Current issues:
* Hotplug problem - When gbsim is killed, or the module
  removed, the greybus driver gets stuck since the android
  mediaserver process is holding the audio device open.
  Killing the mediaserver allows things to clean up and
  allows greybus to accept new gbsim connections. I have
  a workaround patch to the soc-core.c logic which converts
  the snd_card_free() call to snd_card_free_when_closed()
  which allows the greybus connection cleanup to finish.

Remaining todos:
* Probably need to break apart the mgmt_setup function
  to integrate better with the constraint logic. I took
  a really basic stab at this, but more is probably
  needed.
* Figure out how to properly find and tie in the
  codec's I2C bus-id to the driver.

This code requires that the kernel support the following
config options, which I've enabled in a separate kernel
patch:
	CONFIG_SND_SIMPLE_CARD
	CONFIG_SND_SOC_SPDIF
	CONFIG_SND_SOC_RT5645

I really can't calim to be the sole author of this, since
many many fixes and tweaks that have been folded in have
come from Mark Greer. His analsysis and debugging is really
what has made this dummy-framework driver evolve into an
actual audio driver. So much credit and thanks to Mark!

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-08 22:23:58 +02:00