blob: c7794ac602de62ea54ae3da1390b459ee636db99 [file] [log] [blame]
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#ifndef __AUDIO_NOTIFIER_H_
15#define __AUDIO_NOTIFIER_H_
16
17/* State of the notifier domain */
18enum {
19 AUDIO_NOTIFIER_SERVICE_DOWN,
20 AUDIO_NOTIFIER_SERVICE_UP
21};
22
23/* Service order determines connection priority
24 * Highest number connected first
25 */
26enum {
27 AUDIO_NOTIFIER_SSR_SERVICE,
28 AUDIO_NOTIFIER_PDR_SERVICE,
29 AUDIO_NOTIFIER_MAX_SERVICES
30};
31
32enum {
33 AUDIO_NOTIFIER_ADSP_DOMAIN,
34 AUDIO_NOTIFIER_MODEM_DOMAIN,
35 AUDIO_NOTIFIER_MAX_DOMAINS
36};
37
38/* Structure populated in void *data of nb function
39 * callback used for audio_notifier_register
40 */
41struct audio_notifier_cb_data {
42 int service;
43 int domain;
44};
45
Laxminath Kasam8b1366a2017-10-05 01:44:16 +053046#if IS_ENABLED(CONFIG_MSM_QDSP6_NOTIFIER)
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053047
48/*
49 * Use audio_notifier_register to register any audio
50 * clients who need to be notified of a remote process.
51 * This API will determine and register the client with
52 * the best available subsystem (SSR or PDR) for that
53 * domain (Adsp or Modem). When an event is sent from that
54 * domain the notifier block callback function will be called.
55 *
56 * client_name - A unique user name defined by the client.
57 * If the same name is used for multiple calls each will
58 * be tracked & called back separately and a single call
59 * to deregister will delete them all.
60 * domain - Domain the client wants to get events from.
61 * AUDIO_NOTIFIER_ADSP_DOMAIN
62 * AUDIO_NOTIFIER_MODEM_DOMAIN
63 * *nb - Pointer to a notifier block. Provide a callback function
64 * to be notified of an even on that domain.
65 *
66 * nb_func(struct notifier_block *this, unsigned long opcode, void *data)
67 * this - pointer to own nb
68 * opcode - event from registered domain
69 * AUDIO_NOTIFIER_SERVICE_DOWN
70 * AUDIO_NOTIFIER_SERVICE_UP
71 * *data - pointer to struct audio_notifier_cb_data
72 *
73 * Returns: Success: 0
74 * Error: -#
75 */
76int audio_notifier_register(char *client_name, int domain,
77 struct notifier_block *nb);
78
79/*
80 * Use audio_notifier_deregister to deregister the clients from
81 * all domains registered using audio_notifier_register that
82 * match the client name.
83 *
84 * client_name - Unique user name used in audio_notifier_register.
85 * Returns: Success: 0
86 * Error: -#
87 */
88int audio_notifier_deregister(char *client_name);
89
90#else
91
92static inline int audio_notifier_register(char *client_name, int domain,
93 struct notifier_block *nb)
94{
95 return -ENODEV;
96}
97
98static inline int audio_notifier_deregister(char *client_name)
99{
100 return 0;
101}
102
Laxminath Kasam8b1366a2017-10-05 01:44:16 +0530103#endif /* CONFIG_MSM_QDSP6_NOTIFIER */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530104
105#endif