History log of /linux-master/drivers/staging/greybus/audio_codec.c
Revision Date Author Comments
# dc438bac 18-Jul-2023 Takashi Iwai <tiwai@suse.de>

staging: greybus: Avoid abusing controls_rwsem

The controls_rwsem of snd_card object is rather an internal lock, and
not really meant to be used by others for its data protection.

This patch addresses it by replacing the controls_rwsem usages with
the own (new) mutex.

Note that the up_write() and down_write() calls around
gbaudio_remove_component_controls() are simply dropped without
replacement. These temporary up/down were a workaround since
gbaudio_remove_component_controls() itself took the rwsem. Now it was
also gone, we can clean up the workaround, too.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: Mark Greer <mgreer@animalcreek.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: greybus-dev@lists.linaro.org
Link: https://lore.kernel.org/r/20230718141304.1032-8-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 16227e4b 12-Dec-2022 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

staging: greybus: codecs: Drop empty platform remove function

A remove callback just returning 0 is equivalent to no remove callback
at all. So drop the useless function.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20221212221315.3778788-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# cfb12180 12-Apr-2022 Jaehee Park <jhpark1013@gmail.com>

staging: greybus: remove empty callback function

Remove the optional remove callback for the soc_codec_dev_gbaudio
structure. The only place it is referenced is
snd_soc_component_remove() which is only called if the sound_component
pointer is non-null. The null function pointers here can be optionally
ommitted. When a sound component is registered this way, the remove
callback is optional. We can safely remove the whole gbcodec_remove
function, which used to be an empty function with a void return type.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jaehee Park <jhpark1013@gmail.com>
Link: https://lore.kernel.org/r/12037ae2502ad7d0311bcdf2178c3d2156293236.1649824370.git.jhpark1013@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 84ef2565 21-Mar-2022 Jakob Koschel <jakobkoschel@gmail.com>

staging: greybus: codecs: fix type confusion of list iterator variable

If the list does not exit early then data == NULL and 'module' does not
point to a valid list element.
Using 'module' in such a case is not valid and was therefore removed.

Fixes: 6dd67645f22c ("greybus: audio: Use single codec driver registration")
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
Link: https://lore.kernel.org/r/20220321123626.3068639-1-jakobkoschel@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6c73d320 21-Mar-2022 Jakob Koschel <jakobkoschel@gmail.com>

staging: greybus: codecs: use dedicated list iterator variable

In preparation to limit the scope of the list iterator to the list
traversal loop, use a dedicated pointer to point to the found element [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
Link: https://lore.kernel.org/r/20220321123712.3068778-1-jakobkoschel@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 19aed2d6 07-Apr-2022 Akihiko Odaki <akihiko.odaki@gmail.com>

ASoC: soc-card: Create jack kcontrol without pins

snd_soc_card_jack_new() allowed to create jack kcontrol without pins,
but did not create kcontrols. The jack would not have kcontrols if pins
were not going to be added.

This renames the old snd_soc_card_jack_new() to
snd_soc_card_jack_new_pins() for use when pins are provided or will be
added later. The new snd_soc_card_jack_new() appropriately creates a
jack for use without pins and adds a kcontrol.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Link: https://lore.kernel.org/r/20220408041114.6024-1-akihiko.odaki@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 3952659a 09-Nov-2020 Zhang Qilong <zhangqilong3@huawei.com>

staging: greybus: codecs: Fix reference counter leak in error handling

gb_pm_runtime_get_sync has increased the usage counter of the device here.
Forgetting to call gb_pm_runtime_put_noidle will result in usage counter
leak in the error branch of (gbcodec_hw_params and gbcodec_prepare). We
fixed it by adding it.

Fixes: c388ae7696992 ("greybus: audio: Update pm runtime support in dai_ops callback")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Link: https://lore.kernel.org/r/20201109131347.1725288-2-zhangqilong3@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 620d2844 21-Oct-2020 Deepak R Varma <mh12gx2825@gmail.com>

staging: greybus: audio: code indentation and formatting changes

Correct code indentation and realignment as per the coding style
guidelines. Issue reported by checkpatch script.

Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
Link: https://lore.kernel.org/r/20201022063230.GA351623@ubuntu204
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8bb5b59d 02-Oct-2020 Coiby Xu <coiby.xu@gmail.com>

staging: greybus: codecs: use SNDRV_PCM_FMTBIT_S16_LE for format bitmask

snd_soc_pcm_stream.formats should use the bitmask SNDRV_PCM_FMTBIT_*
instead of the sequential integers SNDRV_PCM_FORMAT_* as explained by
commit e712bfca1ac1f63f622f87c2f33b57608f2a4d19
("ASoC: codecs: use SNDRV_PCM_FMTBIT_* for format bitmask").

Found by sparse,

$ make C=2 drivers/staging/greybus/
drivers/staging/greybus/audio_codec.c:691:36: warning: incorrect type in initializer (different base types)
drivers/staging/greybus/audio_codec.c:691:36: expected unsigned long long [usertype] formats
drivers/staging/greybus/audio_codec.c:691:36: got restricted snd_pcm_format_t [usertype]
drivers/staging/greybus/audio_codec.c:701:36: warning: incorrect type in initializer (different base types)
drivers/staging/greybus/audio_codec.c:701:36: expected unsigned long long [usertype] formats
drivers/staging/greybus/audio_codec.c:701:36: got restricted snd_pcm_format_t [usertype]

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
Link: https://lore.kernel.org/r/20201002233057.74462-2-coiby.xu@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 510e340e 09-Jul-2020 Vaibhav Agarwal <vaibhav.sr@gmail.com>

staging: greybus: audio: Add helper APIs for dynamic audio modules

Greybus Codec driver allows modules to be dynamically added and removed,
which further requires updating the DAPM configurations as well.

With current snd_soc architecture, dynamic audio modules is not yet
supported. This patch provides helper APIs to update DAPM configurations
in response to modules which are dynamically added or removed. The
source is primarily based on snd_dapm.c

Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/35e1baaae10a3f2162e71be4c2f75a701584f0e6.1594290158.git.vaibhav.sr@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ce7bd832 09-Jul-2020 Vaibhav Agarwal <vaibhav.sr@gmail.com>

staging: greybus: audio: Resolve compilation errors for GB codec module

Due to dependencies on ASoC framework changes, GB dummy codec module
compilation is currently disabled. This patch updates codec driver as
per the latest ASoC APIs.

Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/dd66a960fca186da055600fe1e622b7a814cb543.1594290158.git.vaibhav.sr@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ac40b4d1 09-Jul-2020 Vaibhav Agarwal <vaibhav.sr@gmail.com>

staging: greybus: audio: Maintain jack list within GB Audio module

As per the current implementation for GB codec driver, a jack list is
maintained for each module. And it expects the list to be populated by
the snd_soc_jack structure which would require modifications in
mainstream code.

However, this is not a necessary requirement and the list can be easily
maintained within gbaudio_module_info as well. This patch provides the
relevant changes for the same.

Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/4ee030af7a8e203f89a6e513313e36f4e2991e5b.1594290158.git.vaibhav.sr@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b503aef3 09-Jul-2020 Vaibhav Agarwal <vaibhav.sr@gmail.com>

staging: greybus: audio: Update snd_jack FW usage as per new APIs

snd_soc_jack APIs are modified in recent kernel versions. This patch
updates the codec driver to resolve the compilation errors related to
jack framework.

Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/896b8e24d990f2bca5aafaebd26e37095042951e.1594290158.git.vaibhav.sr@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# faeeeea8 11-Sep-2018 zhong jiang <zhongjiang@huawei.com>

staging: remove unneeded static set .owner field in platform_driver

platform_driver_register will set the .owner field. So it is safe
to remove the redundant assignment.

The issue is detected with the help of Coccinelle.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6236015f 17-Jan-2018 Kamal Heib <kamalheib1@gmail.com>

staging: greybus: audio_codec.c: Prefer kernel type 'u32' over 'uint32_t'

Fix the following errors found by checkpatch.pl:
CHECK: Prefer kernel type 'u32' over 'uint32_t'

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6a4dd600 17-Jan-2018 Kamal Heib <kamalheib1@gmail.com>

staging: greybus: audio_codec.c: Logical continuations should be on the previous line

Fix the following error found by checkpatch.pl:
CHECK: Logical continuations should be on the previous line

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0c3ba27b 17-Jan-2018 Kamal Heib <kamalheib1@gmail.com>

staging: greybus: audio_codec.c: Space required around ':'

Space is required when using the question mark operator around ':'

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 15f24ca4 17-Jan-2018 Kamal Heib <kamalheib1@gmail.com>

staging: greybus: audio_codec.c: Cleanup blank lines

Remove the blank lines.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c688bd9a 17-Jan-2018 Kamal Heib <kamalheib1@gmail.com>

staging: greybus: audio_codec.c: Fix alignment should match open parenthesis

Cleanup "Alignment should match open parenthesis" checkpatch.pl errors.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 863dbc52 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: Remove redundant license text

Now that the SPDX tag is in all greybus files, that identifies the
license in a specific and legally-defined manner. So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eb50fd3a 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: add SPDX identifiers to all greybus driver files

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself. The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ccc5d98a 20-Aug-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

staging: greybus: audio: constify snd_soc_dai_ops structures

snd_soc_dai_ops are not supposed to change at runtime. All functions
working with snd_soc_dai_ops provided by <sound/soc-dai.h> work with
const snd_soc_dai_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 461ab807 09-Feb-2017 Gioh Kim <gi-oh.kim@profitbricks.com>

staging: greybus: fix "line over 80 characters" coding style issues

This patch fixes only obvious lines.
There are still more issues.

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 96249da9 18-Jan-2017 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

staging: greybus: audio: Cleanup junk codec registers

Dummy codec register were initially added while populating dummy codec
mixer controls until module topology parser was available. Now, these
dummy registers are nowhere used and thus can be safely removed.

Since ASoC framework requires a valid callback for both read & write
register APIS, currently empty placeholders are kept to avoid panic.

Later, register mapping logic can be defined:
1. Assuming fixed number of maximum modules connected and register bits
corresponds to basic info of each module OR
2. With a logic to dynamically grow register_cache_size based on codec
modules added/removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1023ab9c 18-Jan-2017 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

staging: greybus: audio: Initialize sig_bits before configuring hwparams

Uninitialized variable sig_bits was used while configuring stream params
for codec module. These params are used to configure PCM settings for
APBridgeA.

Usually, this is dependent on codec capability and thus populated via
codec dai_driver definition. In our case, it is fixed to 16 based on the
data format, container supported.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3f98afe0 13-Oct-2016 Elise Lennion <elise.lennion@gmail.com>

staging: greybus: audio_codec: Remove useless return statement.

Remove return statement that is immediately followed by the function
closing bracket.

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9ae7a47f 09-Oct-2016 Chase Metzger <chasemetzger15@gmail.com>

drivers: staging: greybus: audio_codec.c: Fixed CHECKS for brace issues

Added braces to else statement where checkpatch complained.

Signed-off-by: Chase Metzger <chasemetzger15@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 33111574 21-Sep-2016 Richard Groux <rgroux@sauron-mordor.net>

staging: greybus: audio_codec.c: code indent should use tabs where possible

Minor error spotted by checkpatch.pl in greybus
code indent should use tabs where possible

Signed-off-by: Richard Groux <rgroux@sauron-mordor.net>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0c8d9c73 21-Sep-2016 Richard Groux <rgroux@sauron-mordor.net>

staging: greybus: audio_codec.c: space required before the open brace

Minor error spotted by checkpatch.pl in greybus
space required before the open brace '{'

Signed-off-by: Richard Groux <rgroux@sauron-mordor.net>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 79cb2b26 19-Sep-2016 Chaehyun Lim <chaehyun.lim@gmail.com>

staging: greybus: use preferred kernel type u16

As suggested by checkpatch.pl:

CHECK: Prefer kernel type 'u16' over 'uint16_t'

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 31959392 19-Sep-2016 Chaehyun Lim <chaehyun.lim@gmail.com>

staging: greybus: use preferred kernel type u8

As suggested by checkpatch.pl:

CHECK: Prefer kernel type 'u8' over 'uint8_t'

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 847175e8 01-Sep-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Fetch jack_mask, button_mask from module's topology data

Added extra fields namely jack_mask & button_mask for each module_info.
These fields are required while registering jack & reporting jack
events.

Earlier, these were hard coded values assuming fixed capabilities say
HEADSET, LINEOUT, etc. supported by GB-codec driver. Now these are
computed dynamically based on module's jack capability shared via
topology data.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 79c222bc 01-Sep-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Remove unnecessary num_jack field from module_info

snd_jack will be registered based on real capabilities shared by
module's FW instead of parsing widgets and register it with fixed
capabilities. Remove module_info->num_jack, since it is no more
required.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# f0ec8cd5 20-Aug-2016 Mark Greer <mgreer@animalcreek.com>

greybus: audio: Fix incorrect direction value when enabling RX

The direction value passed to gb_audio_apbridgea_register_cport()
in the gbaudio_module_enable_rx() routine is TX and not RX like
it should be so fix it.

Testing Done: Recorded microphone data from a headset.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Fixes: c80e7c6fafa5 ("audio: Split helper APIs based on stream direction")
Tested-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewd-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 33cc2839 05-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Report jack removal along with module removal

For GB module with jack slot supported, headset/headphone can still
be inserted at the time of module removal. In this case, above layer is
unaware about jack removal event which happened due to module removal.
This may lead to inconsistent state in above HAL layer. Fix this by
reporting jack removal event explicitly.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 591c4522 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Maintain module stream state for each data connection

For SPK module, each data connection corresponds to codec DAI. Now
stream state is maintained for each DAI. So, need to maintain stream
state for each DAI/data connection for individual module as well.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 19866603 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Maintain runtime stream params for each DAI

Runtime streams are required while configuring GB module plugged-in
during active stream. Currently, it is maintained for single stream.
However, this should be maintained for a stream corresponding to each
DAI. Fix this!

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# c388ae76 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Update pm runtime support in dai_ops callback

Ensure pm runtime get_sync/put protection in codec_dai ops callback
functions before accessing apbridge.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 60e7327d 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Find data connection based on id

Currently we are using dai->name to identify data connection from list
for a module. Now since we are enabling data path based on widget,
dai->name might be invalid by the time driver receives disable request
for a widget. So, use id fetched from AIF widget->sname to identify data
connection for a module.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 487dcbd6 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Use AIF widget to enable path between module & APB

Currently, SPK Amp switch is used to identify when to enable data path
between module and APB. With headset, other switch controls added, it is
not possible to use this switch to control data path. Instead path
should be established based on AIF widget.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4ffca62a 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Update parameters for gbaudio_module_update API

Earlier, module path was enabled based on module's control switch e.g.
'SPK Amp switch'. Thus widget's name was sufficient to parse and
identify the direction. Now individual modules' path will be enabled
based on AIF widget status. So, it is required to get complete widget
details, say w->type is used to identify direction (playback/capture)
and w->sname is used to identify module's DATA connection used for
communication via greybus.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 15681598 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Update dai_driver table with appropriate fields

Currently, the stream name for the DAI driver is generically set to "GB
Audio Playback" and "GB Audio Capture". This is OK since we use a single
interface on APB1 but that could change in the future. Update the DAI
driver table entries to properly reflect the interface used.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# aaef32a6 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Split helper APIs based on stream direction

Now, module is enabled/disabled based on widget event only and not
during startup/shutdown callbacks. Thus, we needn't compare codec_state
in enable/disable module helper APIs. Also, these can be further
simplified based on stream direction.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# ce941306 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Enable audio path based on control switch state only

As per current implementation, audio data is played from each individual
SPK module connected to endo frame. This is not a valid requirement in
case of capture/headset path. So, provide a mechanism to enable
individual module path based on it's control switch state.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 90579d4b 04-Aug-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Remove un-necessary goto statement

For most of the helper functions, goto statement is widely used. It was
originally used with an intent of single exit point for the function
with some cleanup required. This is no more the case. So, simplify code
by avoiding un-necessary gotos.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 098dfaf4 21-Jul-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Avoid using ARA keyword

It is suggested to avoid using ARA keyword externally. So we need to
update GB codec driver. Also, codec name is currently set to 'gb-codec'.
However, it makes more sense to name it as apb-dummy-codec, since it is
used to control various audio modules connected to APB via greybus.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 12ce5231 12-Jul-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Maintain proper codec state during shutdown sequence.

During shutdown sequence, in case all modules are already removed,
codec state is not updated. Though it's not causing any harm for now,
but it's good to maintain proper codec state. Fix this.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Alex Elder <elder@linaro.org>


# cf1caac6 12-Jul-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Fix incorrect codec state modification

In case module is removed dynamically with ongoing playback, during
module cleanup codec state is mistakenly modified. State should be
modified for module only. Fix this.

Fixes: 76414cb499b7 ("audio: Use single codec driver
registration")

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Alex Elder <elder@linaro.org>


# 9e138dd4 24-Jun-2016 David Lin <dtwlin@google.com>

greybus: audio: remove the unnecessary return statement

The return statement immediately after the BUG_ON of the gbcodec_write()
call is added by mistake. It's not causing any errors right now due to
that gbcodec_reg is currently not being used.

Testing Done:
- Audio playback on EVT2

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 60fb3405 10-Jun-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: Remove extra blank lines

This patch removes few blank lines across the repository at places where
two blank lines were present together or when a blank line is present at
the start or end of a routine.

Note that this doesn't remove most of them from greybus_protocols.h as
they were added on purpose.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# f2b6303d 08-Jun-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: Remove apbridgea_shutdown_xx sequence if already done

While reordering gb_deactivate sequence to avoid protocol error this was
mistakenly added even during shutdown_tx/rx. It is supposed to be done
immediately after stop_tx and only once.

Fixes: 739f25d5f490 ("audio: Reorder gb_deactivate sequence to avoid protocol error")
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 27c243cf 08-Jun-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: Use mute_stream callback to initiate GB data xfer

Currently trigger callback is used to start/stop greybus tx/rx
path. This works well for almost all scenario except few
specially handled usecases by Android Audio subsystem.

In case of Music playback followed by Incoming ringtone, above
layer tries to trigger_pause from one FE dailink and start a
fresh playback via different FE dailink. Since, same BE dailink
is used for both cases, an invalid state transition is requested
i.e. from PAUSE->START. This fails & thus causes ringtone playback
failure. With built-in codec, trigger callback is not required to
initiate data xfer unlike gb-codec driver.

This state transition should be handled in Android layer, but
since it can lead to multiple side effects for various usecase
we are trying to avoid trigger callback in gbcodec driver as well.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4d27574c 08-Jun-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Ratelimit err messages

In case of audio mgmt connection failure, GB requests would fail giving
an error message within the driver and reporting error. However there is
no error handling in above HAL and it'll keep on triggering similar
request via GB codec driver. This may overflood serial console. In one
of the instance it locked CPU for >10sec and caused a watchdog bite.
Thus ratelimit those error messages.

Testing Done: compile tested

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# c188fdc8 04-May-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Reduce codec->lock granularity

Earlier codec->lock protects almost complete register/unregister
module function. This can be reduced to specific operations.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# bb9986ef 04-May-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Reorganize sequence in GB audio bundle & codec driver

Modify sequence of register_module & unregister_module in bundle
driver. This would affect the uevent generated for above user
space. Accordingly, we need to modify snd_soc_xxx sequence in
register_module() in codec driver.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 852859ab 04-May-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Remove redundant lock protection & is_connected field

Each module maintains connected status & a lock to protect it.
Using codec->lock we can safely serialize ASoC specific callbacks
(in response to mixer_ctl update or dai_ops) and gb module
disconnect. Thus is_connected field can be removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 54e9070b 23-Apr-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Reorder gb_deactivate sequence to avoid protocol error

gb_activate_tx/rx is triggered from _prepare() & gb_deactivate
from shutdown(). This may cause protocol error in case shutdown
executes without _prepare due to some hw_params failure.

Also, reorganise _prepare & _shutdown calls to make it more
readable & cleaner.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 2b8c2b51 21-Apr-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Changes in response to ASoC cleanup

Update Makefile in response to SND_SOC_DYNAMIC_DAILINK cflag
removal.

Update files for msm-dynamic-dailink.h header file removal.

Update in response to API name changes. Also, acquire sound card
controls_rwsem before adding kcontrols to avoid deadlock.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# d7ed7cbf 25-Apr-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: acquire wakelock during active playback

This change was missed while merging original patch
commit-id: 53c765c33f4a69c31027ec012e717d303bd4feca
Thus submitting it again.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# f2bf63a3 22-Apr-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: acquire wakelock during active playback

use pm_stay_awake & pm_relax to avoid suspend sequence during
active playback

testing Done:
Music Playback ongoing
$ cat /sys/devices/soc.0/qcom,ara-codec.82/power/wakeup_active
1
Music Playback stopped
$ cat /sys/devices/soc.0/qcom,ara-codec.82/power/wakeup_active
0

Tested-by: David Lin <dtwlin@google.com>
Reviewed-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Akash Choudhari <akashtc@google.com>
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>


# 36460e8a 20-Apr-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: audio-codec: Staticize few routines to fix build warnings

This fixes below warnings ..

greybus/audio_codec.c:20:32: warning: symbol 'find_data' was not declared. Should it be static?
greybus/audio_codec.c:955:6: warning: symbol 'gbaudio_codec_cleanup' was not declared. Should it be static?

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 094c4302 29-Mar-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Add I2S_RX path related settings

Capture path related settings during startup, perpare &
hwparams were earlier missing.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 64a7e2cc 29-Mar-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Added jack support to audio module

Register jack with ASoC sound card in case audio module
populates it via codec FW. Currently, only a single jack
with 4 buttons can be registered for each module.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# d764212f 29-Mar-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: fix to resolve multiple audio module playback issue

Cleanup APBridge sequence only in case of last module plugged-out.
For other modules, unregister cportid is sufficient.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mark.greer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6dd67645 29-Mar-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Use single codec driver registration

We have single I2S port via APB1 for communication with all
audio modules. Thus, we should register single codec driver
and manage all individual audio modules internally within
this driver.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mark.greer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 0ec30632 22-Mar-2016 Greg Kroah-Hartman <gregkh@google.com>

greybus: convert drivers to use connection->private set/get

This converts all drivers to use the gb_connection_get_data() and
gb_connection_set_data() functions to make it a bit more explicit as to
what is going on.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 309520ec 17-Mar-2016 Mark Greer <mgreer@animalcreek.com>

greybus: audio: Use CSD instead of E2EFC for audio data connections

There is no reason to use end-to-end flow control for Greybus
audio data connections so disable it and enable Controlled
Segment Dropping (CSD).

Testing Done: Played music using audio modules on an EVT1.5.

CC: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
CC: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 5bbe14b7 29-Feb-2016 Mark Greer <mgreer@animalcreek.com>

greybus: audio: Split start and stop APBridgeA requests

Provide finer-grained control of the audio streaming on APB1 by
splitting the transmit/receive start and stop requests into prepare,
start, stop, and shutdown.

CC: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4a8e5199 26-Feb-2016 Mark Greer <mgreer@animalcreek.com>

greybus: audio: Register CPorts for specific directions

Currently, it is assumed that all audio data CPorts registered on
APB1 are used for transmitting audio data. That may not always be
true like when a microphone is connected but no speakers. Also,
the current special protocol lacks a way to tell APB1 whether the CPort
being registered is for transmitting, receiving, or both.

Fix by adding a 'direction' field to the register and unregister CPort
requests and define bits indicating which direction (or both) audio
data will go on that CPort.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# b07868bd 16-Feb-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: return success for stop trigger if device removed

In case GB codec module is already removed, no action is required
at the HW level. Thus, report SUCCESS to above layer.

Reporting error to above layer will cause repeated trials and won't
allow to update DPCM connections.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 29386f05 15-Feb-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: schedule workqueue to perform codec cleanup on module removal

In response to codec module removal, user space is reported about
the event. In response to this, ALSA layer will update DAPM route
and cleanup DAPM states.
As a fallback mechanism, kernel can cleanup the DAPM state for codec
module. But, this would cause immediate playback (first trial) to fail,
since DSP is still in inconsistent state.
To avoid such situation, a workqueue is scheduled for codec cleanup
with timeout=50ms.
Thus, normally it is expected from above layers to update routes and
perform cleanup. However, fallback mechanism still holds good after
50ms.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# b19df7b9 15-Feb-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Enable support for multiple codec modules

Update params, sequence in response to changes in msm8994
helper APIs

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 3994e0b1 28-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: use variable 'is_connected' to maintain module state

there is race condition between _disconnect() request &
stop_trigger() in case of abrupt module removal.
And sometimes this can lead to deadlock while acquiring
codec_info->lock.
To avoid such situation, atomic variable is used to maintain
codec connected state.
During dai operations (trigger, shutdown, etc.), 'is_connected'
variable is validated to avoid unnecessary lock acquire in
case module already removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 796fad44 28-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: codec driver cleanup

audio codec driver is now moved to bundle driver approach.
This resolved many race conditions related to audio mgmt &
data connection init/exit sequence.
Thus, a lot of helper functions can now be safely removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 3b710ec0 26-Jan-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: audio: Rename Audio class and remove the unused one

There should be a single class macro for Audio and two protocol macros.
Rename class with value 0x12 as GREYBUS_CLASS_AUDIO and remove the other
unused class GREYBUS_CLASS_AUDIO_DATA.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 35e28794 27-Jan-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: audio_codec: convert to bundle driver

Convert the legacy audio management and data protocol drivers to a
bundle driver.

The Audio bundle driver can support a single management and any number
of data cports, and so we expect multiple data cports to be present for
the bundle during initialization.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4b27be12 26-Jan-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: audio_codec: Free gccodec on dia probe failure

We aren't freeing the codec, that we allocated before failing to probe
the connection. Free it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 2df63961 26-Jan-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: audio_codec: Free gccodec on codec probe failure

We aren't freeing the codec, that we allocated before failing to probe
the connection. Free it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# a547deb5 21-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio_codec: update codec_name as per driver->name

Originally, driver->name was not poluated from GB and thus
manually set from audio_codec driver as a hack.
This is no more required.
Another patch already removes that hack.

Now, with new driver->name as "legacy.<id-bundle.interface>"
codec is registered with different name.
So, during DAI link registration as well it needs modification.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4b874134 20-Jan-2016 Greg Kroah-Hartman <gregkh@google.com>

greybus: audio_codec: Don't be tricky with the driver model

With the recent changes by Johan to the driver model of the greybus
code, the audio_codec no longer should need to provide a "dummy" driver
when registering the codec. In fact, having it there causes the greybus
core to crash when inserting the module. Removing it all fixes the
crash.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 83ec6283 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Enable codec module detection on different slots

driver_name associated with dev_name was hard coded earlier.
This limits, audio codec module to be detected on Port#5 only.

Now, driver_name is generated dynamically based on dev_name.
This enables codec module detection on any 1x2 slot.

Also, Update dev_id based on slot number, instead of bundle->id.
bundle->id is not unique for multiple modules added, thus now
using slot number for unique identification.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 25de3491 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Cleanup GB protocol connections in case of abrupt codec removal

We need to clean up GB protocl connections, otherwise successive
codec insertions fails repeatedly.

NOTE: As per suggestion, since codec is already removed, one should
not trigger any GB command. It'll cause a delay of atleast TIMEOUT
value.
HOwever, failing to cleanup GB protocol, causes successive module
insertion to fail

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 17247da5 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Report uevent on GB codec module insertion/removal

GB-Audio-manager module is currently used to report uevent
to above layer in response to any codec module inserted or
removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# b7f0088d 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Add GB Audio class protocol functionality in GB codec DAI ops

GB Audio class driver provides APIs to configure GB codec module.
This patch adds relevant operations in DAI ops callback functions to
configure codec module as per DAPM sequence triggered.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6339d232 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Add topology parser for GB codec

For each GB codec module inserted, DAPM widgets, kcontrols, routes
and DAIs can be fetched through greybus in a binary chunk and parsed
locally to create & populate DAPM graph for the specific module.

It is required by each codec module to populate a minimum set of
kcontrols with fixed names to support basic audio usecase.
To support advanced features of codec module, the same can be polpulated
with existing topology parser. However, to use them for different usecase
separate mechanism (may be via MSP) is required to inform userspace about
their configuration value & enable/disable sequence.

ToDos:
Currently, support for enumerated kcontrol/dapm control is hardcoded.
Need to add complete logic within the parser.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 2a70e49f 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Use greybus connection device for codec registration

Use GB Audio mgmt, data protocol ids to register codec module with
GB protocol. And in response to mgmt->connection_init(), register
GB codec driver with ASoC.

Now, using msm8994 machine to register DAI link dynamically on
codec insertion.

ToDos:
- snd_soc_register_codec() uses driver->name to identify device id.
However, for GB device, .driver{} is not yet populated by GB core.
Thus, defining dummy structure within codec driver. This should
come from GB core itself.
Even existing .driver{} may cause problem in case of multiple
modules inserted or inserted at a different slot.
- Fix logic for gbcodec->dais & gbcodec->dailinks. Current
implementation contains some hard coded data with assumption of
count=1.
- Evaluate definition of 'gbaudio_dailink.be_id' in case of multiple
DAI links.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 7885342c 13-Jan-2016 Vaibhav Agarwal <vaibhav.agarwal@linaro.org>

greybus: audio: Build audio module conditionally

Added CONFIG_XXX flag check before compiling audio module.
Once we add dynamic DAI link registration from audio driver,
this check wil be required to avoid compilation failures with
other kernel revisions.

Also, renamed header file to better align with .c file name.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# fd8f9e12 13-Jan-2016 Mark Greer <mgreer@animalcreek.com>

greybus: audio: Use underscore in file name

For consistency with most other files in the Greybus repository,
change 'audio-codec.c' to use an underscore instead of a hyphen
in its name.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>