Commit 17247da5 authored by Vaibhav Agarwal's avatar Vaibhav Agarwal Committed by Greg Kroah-Hartman

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: default avatarVaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: default avatarMark Greer <mgreer@animalcreek.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent b7f0088d
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "audio_codec.h" #include "audio_codec.h"
#include "audio_apbridgea.h" #include "audio_apbridgea.h"
#include "audio_manager.h"
#define GB_AUDIO_MGMT_DRIVER_NAME "gb_audio_mgmt" #define GB_AUDIO_MGMT_DRIVER_NAME "gb_audio_mgmt"
#define GB_AUDIO_DATA_DRIVER_NAME "gb_audio_data" #define GB_AUDIO_DATA_DRIVER_NAME "gb_audio_data"
...@@ -577,6 +578,7 @@ static int gbaudio_codec_probe(struct gb_connection *connection) ...@@ -577,6 +578,7 @@ static int gbaudio_codec_probe(struct gb_connection *connection)
int ret, i; int ret, i;
struct gbaudio_codec_info *gbcodec; struct gbaudio_codec_info *gbcodec;
struct gb_audio_topology *topology; struct gb_audio_topology *topology;
struct gb_audio_manager_module_descriptor desc;
struct device *dev = &connection->bundle->dev; struct device *dev = &connection->bundle->dev;
int dev_id = connection->bundle->id; int dev_id = connection->bundle->id;
...@@ -639,6 +641,21 @@ static int gbaudio_codec_probe(struct gb_connection *connection) ...@@ -639,6 +641,21 @@ static int gbaudio_codec_probe(struct gb_connection *connection)
mutex_lock(&gbcodec->lock); mutex_lock(&gbcodec->lock);
gbcodec->codec_registered = 1; 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); mutex_unlock(&gbcodec->lock);
return ret; return ret;
...@@ -669,6 +686,16 @@ static void gbaudio_codec_remove(struct gb_connection *connection) ...@@ -669,6 +686,16 @@ static void gbaudio_codec_remove(struct gb_connection *connection)
if (!gbcodec) if (!gbcodec)
return; 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, msm8994_remove_dailink("msm8994-tomtom-mtp-snd-card", &gbaudio_dailink,
1); 1);
gbaudio_remove_dailinks(gbcodec); gbaudio_remove_dailinks(gbcodec);
...@@ -712,6 +739,7 @@ static int gbaudio_dai_probe(struct gb_connection *connection) ...@@ -712,6 +739,7 @@ static int gbaudio_dai_probe(struct gb_connection *connection)
struct device *dev = &connection->bundle->dev; struct device *dev = &connection->bundle->dev;
int dev_id = connection->bundle->id; int dev_id = connection->bundle->id;
struct gbaudio_codec_info *gbcodec = dev_get_drvdata(dev); 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)); 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) ...@@ -729,6 +757,22 @@ static int gbaudio_dai_probe(struct gb_connection *connection)
/* update dai_added count */ /* update dai_added count */
mutex_lock(&gbcodec->lock); mutex_lock(&gbcodec->lock);
gbcodec->dai_added++; 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); mutex_unlock(&gbcodec->lock);
return 0; return 0;
...@@ -749,6 +793,12 @@ static void gbaudio_dai_remove(struct gb_connection *connection) ...@@ -749,6 +793,12 @@ static void gbaudio_dai_remove(struct gb_connection *connection)
/* inform uevent to above layers */ /* inform uevent to above layers */
mutex_lock(&gbcodec->lock); 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 */ /* update dai_added count */
gbcodec->dai_added--; gbcodec->dai_added--;
mutex_unlock(&gbcodec->lock); mutex_unlock(&gbcodec->lock);
......
...@@ -97,10 +97,13 @@ struct gbaudio_codec_info { ...@@ -97,10 +97,13 @@ struct gbaudio_codec_info {
int type; int type;
int dai_added; int dai_added;
int codec_registered; int codec_registered;
int set_uevent;
char vstr[NAME_SIZE]; char vstr[NAME_SIZE];
char pstr[NAME_SIZE]; char pstr[NAME_SIZE];
struct list_head list; struct list_head list;
struct gb_audio_topology *topology; struct gb_audio_topology *topology;
/* need to share this info to above user space */
int manager_id;
char name[NAME_SIZE]; char name[NAME_SIZE];
/* soc related data */ /* soc related data */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment