blob: e85173cd2158dae18d230bf0ded9343bd2cf5a8e [file] [log] [blame]
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301/*
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 Kasam605b42f2017-08-01 22:02:15 +053018#include <dsp/audio_notifier.h>
19#include <ipc/apr.h>
20#include <ipc/apr_tal.h>
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053021
Rohit Kumar39603af2017-09-11 00:00:37 +053022/**
23 * apr_get_subsys_state - get Q6 subsys status
24 *
25 * Returns apr_subsys_state
26 */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053027enum apr_subsys_state apr_get_subsys_state(void)
28{
29 return apr_get_q6_state();
30}
Rohit Kumar39603af2017-09-11 00:00:37 +053031EXPORT_SYMBOL(apr_get_subsys_state);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053032
33void apr_set_subsys_state(void)
34{
35 apr_set_q6_state(APR_SUBSYS_DOWN);
36 apr_set_modem_state(APR_SUBSYS_UP);
37}
38
39uint16_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
50int 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
58void 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 Kasam8b1366a2017-10-05 01:44:16 +053069void 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 Bhattacharya8e2277f2017-07-20 18:31:55 +053079uint16_t apr_get_reset_domain(uint16_t proc)
80{
81 return proc;
82}