1 /* 2 * Greybus operations 3 * 4 * Copyright 2015-2016 Google Inc. 5 * 6 * Released under the GPLv2 only. 7 */ 8 9 #ifndef _GB_AUDIO_MANAGER_H_ 10 #define _GB_AUDIO_MANAGER_H_ 11 12 #include <linux/kobject.h> 13 #include <linux/list.h> 14 15 #define GB_AUDIO_MANAGER_NAME "gb_audio_manager" 16 #define GB_AUDIO_MANAGER_MODULE_NAME_LEN 64 17 #define GB_AUDIO_MANAGER_MODULE_NAME_LEN_SSCANF "63" 18 19 struct gb_audio_manager_module_descriptor { 20 char name[GB_AUDIO_MANAGER_MODULE_NAME_LEN]; 21 int slot; 22 int vid; 23 int pid; 24 int cport; 25 unsigned int ip_devices; 26 unsigned int op_devices; 27 }; 28 29 struct gb_audio_manager_module { 30 struct kobject kobj; 31 struct list_head list; 32 int id; 33 struct gb_audio_manager_module_descriptor desc; 34 }; 35 36 /* 37 * Creates a new gb_audio_manager_module_descriptor, using the specified 38 * descriptor. 39 * 40 * Returns a negative result on error, or the id of the newly created module. 41 * 42 */ 43 int gb_audio_manager_add(struct gb_audio_manager_module_descriptor *desc); 44 45 /* 46 * Removes a connected gb_audio_manager_module_descriptor for the specified ID. 47 * 48 * Returns zero on success, or a negative value on error. 49 */ 50 int gb_audio_manager_remove(int id); 51 52 /* 53 * Removes all connected gb_audio_modules 54 * 55 * Returns zero on success, or a negative value on error. 56 */ 57 void gb_audio_manager_remove_all(void); 58 59 /* 60 * Retrieves a gb_audio_manager_module_descriptor for the specified id. 61 * Returns the gb_audio_manager_module_descriptor structure, 62 * or NULL if there is no module with the specified ID. 63 */ 64 struct gb_audio_manager_module *gb_audio_manager_get_module(int id); 65 66 /* 67 * Decreases the refcount of the module, obtained by the get function. 68 * Modules are removed via gb_audio_manager_remove 69 */ 70 void gb_audio_manager_put_module(struct gb_audio_manager_module *module); 71 72 /* 73 * Dumps the module for the specified id 74 * Return 0 on success 75 */ 76 int gb_audio_manager_dump_module(int id); 77 78 /* 79 * Dumps all connected modules 80 */ 81 void gb_audio_manager_dump_all(void); 82 83 #endif /* _GB_AUDIO_MANAGER_H_ */ 84