Soumya Managoli | 07c68db | 2018-02-23 13:08:14 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 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_PDR_H_ |
| 15 | #define __AUDIO_PDR_H_ |
| 16 | |
| 17 | enum { |
| 18 | AUDIO_PDR_DOMAIN_ADSP, |
| 19 | AUDIO_PDR_DOMAIN_MAX |
| 20 | }; |
| 21 | |
| 22 | enum { |
| 23 | AUDIO_PDR_FRAMEWORK_DOWN, |
| 24 | AUDIO_PDR_FRAMEWORK_UP |
| 25 | }; |
| 26 | |
| 27 | #ifdef CONFIG_MSM_QDSP6_PDR |
| 28 | |
| 29 | /* |
| 30 | * Use audio_pdr_register to register with the PDR subsystem this |
| 31 | * should be done before module late init otherwise notification |
| 32 | * of the AUDIO_PDR_FRAMEWORK_UP cannot be guaranteed. |
| 33 | * |
| 34 | * *nb - Pointer to a notifier block. Provide a callback function |
| 35 | * to be notified once the PDR framework has been initialized. |
| 36 | * Callback will receive either the AUDIO_PDR_FRAMEWORK_DOWN |
| 37 | * or AUDIO_PDR_FRAMEWORK_UP ioctl depending on the state of |
| 38 | * the PDR framework. |
| 39 | * |
| 40 | * Returns: Success: 0 |
| 41 | * Failure: Error code |
| 42 | */ |
| 43 | int audio_pdr_register(struct notifier_block *nb); |
Laxminath Kasam | 8b1366a | 2017-10-05 01:44:16 +0530 | [diff] [blame] | 44 | int audio_pdr_deregister(struct notifier_block *nb); |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 45 | |
| 46 | /* |
| 47 | * Use audio_pdr_service_register to register with a PDR service |
| 48 | * Function should be called after nb callback registered with |
| 49 | * audio_pdr_register has been called back with the |
| 50 | * AUDIO_PDR_FRAMEWORK_UP ioctl. |
| 51 | * |
| 52 | * domain_id - Domain to use, example: AUDIO_PDR_ADSP |
| 53 | * *nb - Pointer to a notifier block. Provide a callback function |
| 54 | * that will be notified of the state of the domain |
| 55 | * requested. The ioctls received by the callback are |
| 56 | * defined in service-notifier.h. |
| 57 | * |
| 58 | * Returns: Success: Client handle |
| 59 | * Failure: Pointer error code |
| 60 | */ |
| 61 | void *audio_pdr_service_register(int domain_id, |
| 62 | struct notifier_block *nb, int *curr_state); |
| 63 | |
| 64 | /* |
| 65 | * Use audio_pdr_service_deregister to deregister with a PDR |
| 66 | * service that was registered using the audio_pdr_service_register |
| 67 | * API. |
| 68 | * |
| 69 | * *service_handle - Service handle returned by audio_pdr_service_register |
| 70 | * *nb - Pointer to the notifier block. Used in the call to |
| 71 | * audio_pdr_service_register. |
| 72 | * |
| 73 | * Returns: Success: Client handle |
| 74 | * Failure: Error code |
| 75 | */ |
| 76 | int audio_pdr_service_deregister(void *service_handle, |
| 77 | struct notifier_block *nb); |
| 78 | |
| 79 | #else |
| 80 | |
| 81 | static inline int audio_pdr_register(struct notifier_block *nb) |
| 82 | { |
| 83 | return -ENODEV; |
| 84 | } |
| 85 | |
Soumya Managoli | 07c68db | 2018-02-23 13:08:14 +0530 | [diff] [blame] | 86 | static inline int audio_pdr_deregister(struct notifier_block *nb) |
| 87 | { |
| 88 | return -ENODEV; |
| 89 | } |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 90 | |
| 91 | static inline void *audio_pdr_service_register(int domain_id, |
| 92 | struct notifier_block *nb, |
| 93 | int *curr_state) |
| 94 | { |
| 95 | return NULL; |
| 96 | } |
| 97 | |
| 98 | static inline int audio_pdr_service_deregister(void *service_handle, |
| 99 | struct notifier_block *nb) |
| 100 | { |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | #endif /* CONFIG_MSM_QDSP6_PDR */ |
| 105 | |
| 106 | #endif |