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