diff options
author | Vaibhav Agarwal <vaibhav.agarwal@linaro.org> | 2016-01-13 14:07:53 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-01-13 16:43:32 -0800 |
commit | 17247da52ee8694429e089f452dd14f4dbda9f06 (patch) | |
tree | aa2d81fe592a1b74c6c4cd9f5baf03873b7af4fd /drivers/staging/greybus/audio_codec.c | |
parent | b7f0088df7369bafc5029be7c0085961904086fc (diff) | |
download | op-kernel-dev-17247da52ee8694429e089f452dd14f4dbda9f06.zip op-kernel-dev-17247da52ee8694429e089f452dd14f4dbda9f06.tar.gz |
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>
Diffstat (limited to 'drivers/staging/greybus/audio_codec.c')
-rw-r--r-- | drivers/staging/greybus/audio_codec.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index a03caa0..93906c8 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -13,6 +13,7 @@ #include "audio_codec.h" #include "audio_apbridgea.h" +#include "audio_manager.h" #define GB_AUDIO_MGMT_DRIVER_NAME "gb_audio_mgmt" #define GB_AUDIO_DATA_DRIVER_NAME "gb_audio_data" @@ -577,6 +578,7 @@ static int gbaudio_codec_probe(struct gb_connection *connection) int ret, i; struct gbaudio_codec_info *gbcodec; struct gb_audio_topology *topology; + struct gb_audio_manager_module_descriptor desc; struct device *dev = &connection->bundle->dev; int dev_id = connection->bundle->id; @@ -639,6 +641,21 @@ static int gbaudio_codec_probe(struct gb_connection *connection) mutex_lock(&gbcodec->lock); gbcodec->codec_registered = 1; + /* inform above layer for uevent */ + if (!gbcodec->set_uevent && + (gbcodec->dai_added == gbcodec->num_dais)) { + dev_dbg(dev, "Inform set_event:%d to above layer\n", 1); + /* prepare for the audio manager */ + strlcpy(desc.name, gbcodec->name, + GB_AUDIO_MANAGER_MODULE_NAME_LEN); /* todo */ + desc.slot = 1; /* todo */ + desc.vid = 2; /* todo */ + desc.pid = 3; /* todo */ + desc.cport = gbcodec->dev_id; + desc.devices = 0x2; /* todo */ + gbcodec->manager_id = gb_audio_manager_add(&desc); + gbcodec->set_uevent = 1; + } mutex_unlock(&gbcodec->lock); return ret; @@ -669,6 +686,16 @@ static void gbaudio_codec_remove(struct gb_connection *connection) if (!gbcodec) return; + /* inform uevent to above layers */ + mutex_lock(&gbcodec->lock); + if (gbcodec->set_uevent) { + /* notify the audio manager */ + dev_dbg(dev, "Inform set_event:%d to above layer\n", 0); + gb_audio_manager_remove(gbcodec->manager_id); + gbcodec->set_uevent = 0; + } + mutex_unlock(&gbcodec->lock); + msm8994_remove_dailink("msm8994-tomtom-mtp-snd-card", &gbaudio_dailink, 1); gbaudio_remove_dailinks(gbcodec); @@ -712,6 +739,7 @@ static int gbaudio_dai_probe(struct gb_connection *connection) struct device *dev = &connection->bundle->dev; int dev_id = connection->bundle->id; struct gbaudio_codec_info *gbcodec = dev_get_drvdata(dev); + struct gb_audio_manager_module_descriptor desc; dev_dbg(dev, "Add DAI device:%d:%s\n", dev_id, dev_name(dev)); @@ -729,6 +757,22 @@ static int gbaudio_dai_probe(struct gb_connection *connection) /* update dai_added count */ mutex_lock(&gbcodec->lock); gbcodec->dai_added++; + + /* inform above layer for uevent */ + if (!gbcodec->set_uevent && gbcodec->codec_registered && + (gbcodec->dai_added == gbcodec->num_dais)) { + /* prepare for the audio manager */ + dev_dbg(dev, "Inform set_event:%d to above layer\n", 1); + strlcpy(desc.name, gbcodec->name, + GB_AUDIO_MANAGER_MODULE_NAME_LEN); /* todo */ + desc.slot = 1; /* todo */ + desc.vid = 2; /* todo */ + desc.pid = 3; /* todo */ + desc.cport = gbcodec->dev_id; + desc.devices = 0x2; /* todo */ + gbcodec->manager_id = gb_audio_manager_add(&desc); + gbcodec->set_uevent = 1; + } mutex_unlock(&gbcodec->lock); return 0; @@ -749,6 +793,12 @@ static void gbaudio_dai_remove(struct gb_connection *connection) /* inform uevent to above layers */ mutex_lock(&gbcodec->lock); + if (gbcodec->set_uevent) { + /* notify the audio manager */ + dev_dbg(dev, "Inform set_event:%d to above layer\n", 0); + gb_audio_manager_remove(gbcodec->manager_id); + gbcodec->set_uevent = 0; + } /* update dai_added count */ gbcodec->dai_added--; mutex_unlock(&gbcodec->lock); |