blob: 9ca7ac09719e555954e6fbe906d12fc8fbed7717 [file] [log] [blame]
Svetlin Ankov8db00732016-01-13 14:07:48 -07001/*
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
19struct 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 devices;
26};
27
28struct gb_audio_manager_module {
29 struct kobject kobj;
30 struct list_head list;
31 int id;
32 struct gb_audio_manager_module_descriptor desc;
33};
34
35/*
36 * Creates a new gb_audio_manager_module_descriptor, using the specified
37 * descriptor.
38 *
39 * Returns a negative result on error, or the id of the newly created module.
40 *
41 */
42int gb_audio_manager_add(struct gb_audio_manager_module_descriptor *desc);
43
44/*
45 * Removes a connected gb_audio_manager_module_descriptor for the specified ID.
46 *
47 * Returns zero on success, or a negative value on error.
48 */
49int gb_audio_manager_remove(int id);
50
51/*
52 * Removes all connected gb_audio_modules
53 *
54 * Returns zero on success, or a negative value on error.
55 */
56void gb_audio_manager_remove_all(void);
57
58/*
59 * Retrieves a gb_audio_manager_module_descriptor for the specified id.
60 * Returns the gb_audio_manager_module_descriptor structure,
61 * or NULL if there is no module with the specified ID.
62 */
63struct gb_audio_manager_module *gb_audio_manager_get_module(int id);
64
65/*
66 * Decreases the refcount of the module, obtained by the get function.
67 * Modules are removed via gb_audio_manager_remove
68 */
69void gb_audio_manager_put_module(struct gb_audio_manager_module *module);
70
71/*
72 * Dumps the module for the specified id
73 * Return 0 on success
74 */
75int gb_audio_manager_dump_module(int id);
76
77/*
78 * Dumps all connected modules
79 */
80void gb_audio_manager_dump_all(void);
81
82#endif /* _GB_AUDIO_MANAGER_H_ */