Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/uaccess.h> |
| 16 | #include <linux/spinlock.h> |
| 17 | #include <linux/kernel.h> |
Laxminath Kasam | 605b42f | 2017-08-01 22:02:15 +0530 | [diff] [blame] | 18 | #include <dsp/audio_notifier.h> |
| 19 | #include <ipc/apr.h> |
| 20 | #include <ipc/apr_tal.h> |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 21 | |
Rohit Kumar | 39603af | 2017-09-11 00:00:37 +0530 | [diff] [blame] | 22 | /** |
| 23 | * apr_get_subsys_state - get Q6 subsys status |
| 24 | * |
| 25 | * Returns apr_subsys_state |
| 26 | */ |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 27 | enum apr_subsys_state apr_get_subsys_state(void) |
| 28 | { |
| 29 | return apr_get_q6_state(); |
| 30 | } |
Rohit Kumar | 39603af | 2017-09-11 00:00:37 +0530 | [diff] [blame] | 31 | EXPORT_SYMBOL(apr_get_subsys_state); |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 32 | |
| 33 | void apr_set_subsys_state(void) |
| 34 | { |
| 35 | apr_set_q6_state(APR_SUBSYS_DOWN); |
| 36 | apr_set_modem_state(APR_SUBSYS_UP); |
| 37 | } |
| 38 | |
| 39 | uint16_t apr_get_data_src(struct apr_hdr *hdr) |
| 40 | { |
| 41 | if (hdr->src_domain == APR_DOMAIN_MODEM) |
| 42 | return APR_DEST_MODEM; |
| 43 | else if (hdr->src_domain == APR_DOMAIN_ADSP) |
| 44 | return APR_DEST_QDSP6; |
| 45 | |
| 46 | pr_err("APR: Pkt from wrong source: %d\n", hdr->src_domain); |
| 47 | return APR_DEST_MAX; /*RETURN INVALID VALUE*/ |
| 48 | } |
| 49 | |
| 50 | int apr_get_dest_id(char *dest) |
| 51 | { |
| 52 | if (!strcmp(dest, "ADSP")) |
| 53 | return APR_DEST_QDSP6; |
| 54 | else |
| 55 | return APR_DEST_MODEM; |
| 56 | } |
| 57 | |
| 58 | void subsys_notif_register(char *client_name, int domain, |
| 59 | struct notifier_block *nb) |
| 60 | { |
| 61 | int ret; |
| 62 | |
| 63 | ret = audio_notifier_register(client_name, domain, nb); |
| 64 | if (ret < 0) |
| 65 | pr_err("%s: Audio notifier register failed for domain %d ret = %d\n", |
| 66 | __func__, domain, ret); |
| 67 | } |
| 68 | |
Laxminath Kasam | 8b1366a | 2017-10-05 01:44:16 +0530 | [diff] [blame] | 69 | void subsys_notif_deregister(char *client_name) |
| 70 | { |
| 71 | int ret; |
| 72 | |
| 73 | ret = audio_notifier_deregister(client_name); |
| 74 | if (ret < 0) |
| 75 | pr_err("%s: Audio notifier de-register failed for client %s\n", |
| 76 | __func__, client_name); |
| 77 | } |
| 78 | |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 79 | uint16_t apr_get_reset_domain(uint16_t proc) |
| 80 | { |
| 81 | return proc; |
| 82 | } |