From 17247da52ee8694429e089f452dd14f4dbda9f06 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Wed, 13 Jan 2016 14:07:53 -0700 Subject: 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 Signed-off-by: Mark Greer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_codec.c | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'drivers/staging/greybus/audio_codec.c') diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index a03caa09a68a..93906c8128de 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); -- cgit v1.2.3-55-g7522