From a9234bfd6cec4420b5bef29d77dce1f9cb0543e2 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Wed, 30 Mar 2016 13:23:55 +0530 Subject: [PATCH] greybus: audio_manager: Split device type into i/p & o/p devices Currently, single field is used to report device type say SPK, MIC, HS, HP, etc. However above HAL expects separate fields for input & ouput device types. Signed-off-by: Vaibhav Agarwal Reviewed-by: Mark Greer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_manager.h | 3 +- .../staging/greybus/audio_manager_module.c | 38 ++++++++++++++----- drivers/staging/greybus/audio_manager_sysfs.c | 7 ++-- drivers/staging/greybus/audio_module.c | 3 +- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/drivers/staging/greybus/audio_manager.h b/drivers/staging/greybus/audio_manager.h index 9ca7ac09719e..c4ca09754a6a 100644 --- a/drivers/staging/greybus/audio_manager.h +++ b/drivers/staging/greybus/audio_manager.h @@ -22,7 +22,8 @@ struct gb_audio_manager_module_descriptor { int vid; int pid; int cport; - unsigned int devices; + unsigned int ip_devices; + unsigned int op_devices; }; struct gb_audio_manager_module { diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c index e5cffa362671..a10e96ad79c1 100644 --- a/drivers/staging/greybus/audio_manager_module.c +++ b/drivers/staging/greybus/audio_manager_module.c @@ -122,16 +122,27 @@ static struct gb_audio_manager_module_attribute gb_audio_module_cport_attribute = __ATTR(cport, 0664, gb_audio_module_cport_show, NULL); -static ssize_t gb_audio_module_devices_show( +static ssize_t gb_audio_module_ip_devices_show( struct gb_audio_manager_module *module, struct gb_audio_manager_module_attribute *attr, char *buf) { - return sprintf(buf, "0x%X", module->desc.devices); + return sprintf(buf, "0x%X", module->desc.ip_devices); } static struct gb_audio_manager_module_attribute - gb_audio_module_devices_attribute = - __ATTR(devices, 0664, gb_audio_module_devices_show, NULL); + gb_audio_module_ip_devices_attribute = + __ATTR(ip_devices, 0664, gb_audio_module_ip_devices_show, NULL); + +static ssize_t gb_audio_module_op_devices_show( + struct gb_audio_manager_module *module, + struct gb_audio_manager_module_attribute *attr, char *buf) +{ + return sprintf(buf, "0x%X", module->desc.op_devices); +} + +static struct gb_audio_manager_module_attribute + gb_audio_module_op_devices_attribute = + __ATTR(op_devices, 0664, gb_audio_module_op_devices_show, NULL); static struct attribute *gb_audio_module_default_attrs[] = { &gb_audio_module_name_attribute.attr, @@ -139,7 +150,8 @@ static struct attribute *gb_audio_module_default_attrs[] = { &gb_audio_module_vid_attribute.attr, &gb_audio_module_pid_attribute.attr, &gb_audio_module_cport_attribute.attr, - &gb_audio_module_devices_attribute.attr, + &gb_audio_module_ip_devices_attribute.attr, + &gb_audio_module_op_devices_attribute.attr, NULL, /* need to NULL terminate the list of attributes */ }; @@ -156,7 +168,8 @@ static void send_add_uevent(struct gb_audio_manager_module *module) char vid_string[64]; char pid_string[64]; char cport_string[64]; - char devices_string[64]; + char ip_devices_string[64]; + char op_devices_string[64]; char *envp[] = { name_string, @@ -164,7 +177,8 @@ static void send_add_uevent(struct gb_audio_manager_module *module) vid_string, pid_string, cport_string, - devices_string, + ip_devices_string, + op_devices_string, NULL }; @@ -173,7 +187,10 @@ static void send_add_uevent(struct gb_audio_manager_module *module) snprintf(vid_string, 64, "VID=%d", module->desc.vid); snprintf(pid_string, 64, "PID=%d", module->desc.pid); snprintf(cport_string, 64, "CPORT=%d", module->desc.cport); - snprintf(devices_string, 64, "DEVICES=0x%X", module->desc.devices); + snprintf(ip_devices_string, 64, "I/P DEVICES=0x%X", + module->desc.ip_devices); + snprintf(op_devices_string, 64, "O/P DEVICES=0x%X", + module->desc.op_devices); kobject_uevent_env(&module->kobj, KOBJ_ADD, envp); } @@ -229,12 +246,13 @@ int gb_audio_manager_module_create( void gb_audio_manager_module_dump(struct gb_audio_manager_module *module) { - pr_info("audio module #%d name=%s slot=%d vid=%d pid=%d cport=%d devices=0x%X\n", + pr_info("audio module #%d name=%s slot=%d vid=%d pid=%d cport=%d i/p devices=0x%X o/p devices=0x%X\n", module->id, module->desc.name, module->desc.slot, module->desc.vid, module->desc.pid, module->desc.cport, - module->desc.devices); + module->desc.ip_devices, + module->desc.op_devices); } diff --git a/drivers/staging/greybus/audio_manager_sysfs.c b/drivers/staging/greybus/audio_manager_sysfs.c index c713f5f7aaca..d8bf8591ff9e 100644 --- a/drivers/staging/greybus/audio_manager_sysfs.c +++ b/drivers/staging/greybus/audio_manager_sysfs.c @@ -20,11 +20,12 @@ static ssize_t manager_sysfs_add_store( int num = sscanf(buf, "name=%" GB_AUDIO_MANAGER_MODULE_NAME_LEN_SSCANF "s " - "slot=%d vid=%d pid=%d cport=%d devices=0x%X", + "slot=%d vid=%d pid=%d cport=%d i/p devices=0x%X" + "o/p devices=0x%X", desc.name, &desc.slot, &desc.vid, &desc.pid, - &desc.cport, &desc.devices); + &desc.cport, &desc.ip_devices, &desc.op_devices); - if (num != 6) + if (num != 7) return -EINVAL; num = gb_audio_manager_add(&desc); diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c index 9039aa63e040..a7f961f85e21 100644 --- a/drivers/staging/greybus/audio_module.c +++ b/drivers/staging/greybus/audio_module.c @@ -353,7 +353,8 @@ static int gb_audio_probe(struct gb_bundle *bundle, desc.vid = 2; /* todo */ desc.pid = 3; /* todo */ desc.cport = gbmodule->dev_id; - desc.devices = 0x2; /* todo */ + desc.op_devices = 0x2; /* todo */ + desc.ip_devices = 0x0; /* todo */ gbmodule->manager_id = gb_audio_manager_add(&desc); dev_dbg(dev, "Add GB Audio device:%s\n", gbmodule->name); -- 2.39.5