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