• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef __SECRIL_CLIENT_H__
19 #define __SECRIL_CLIENT_H__
20 
21 #include <sys/types.h>
22 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 struct RilClient {
29     void *prv;
30 };
31 
32 typedef struct RilClient * HRilClient;
33 
34 
35 //---------------------------------------------------------------------------
36 // Defines
37 //---------------------------------------------------------------------------
38 #define RIL_CLIENT_ERR_SUCCESS      0
39 #define RIL_CLIENT_ERR_AGAIN        1
40 #define RIL_CLIENT_ERR_INIT         2 // Client is not initialized
41 #define RIL_CLIENT_ERR_INVAL        3 // Invalid value
42 #define RIL_CLIENT_ERR_CONNECT      4 // Connection error
43 #define RIL_CLIENT_ERR_IO           5 // IO error
44 #define RIL_CLIENT_ERR_RESOURCE     6 // Resource not available
45 #define RIL_CLIENT_ERR_UNKNOWN      7
46 
47 
48 //---------------------------------------------------------------------------
49 // Type definitions
50 //---------------------------------------------------------------------------
51 
52 typedef int (*RilOnComplete)(HRilClient handle, const void *data, size_t datalen);
53 
54 typedef int (*RilOnUnsolicited)(HRilClient handle, const void *data, size_t datalen);
55 
56 typedef int (*RilOnError)(void *data, int error);
57 
58 
59 //---------------------------------------------------------------------------
60 // Client APIs
61 //---------------------------------------------------------------------------
62 
63 /**
64  * Open RILD multi-client.
65  * Return is client handle, NULL on error.
66  */
67 HRilClient OpenClient_RILD(void);
68 
69 /**
70  * Stop RILD multi-client. If client socket was connected,
71  * it will be disconnected.
72  */
73 int CloseClient_RILD(HRilClient client);
74 
75 /**
76  * Connect to RIL deamon. One client task starts.
77  * Return is 0 or error code.
78  */
79 int Connect_RILD(HRilClient client);
80 
81 /**
82  * check whether RILD is connected
83  * Returns 0 or 1
84  */
85 int isConnected_RILD(HRilClient client);
86 
87 /**
88  * Disconnect connection to RIL deamon(socket close).
89  * Return is 0 or error code.
90  */
91 int Disconnect_RILD(HRilClient client);
92 
93 /**
94  * Register unsolicited response handler. If handler is NULL,
95  * the handler for the request ID is unregistered.
96  * The response handler is invoked in the client task context.
97  * Return is 0 or error code.
98  */
99 int RegisterUnsolicitedHandler(HRilClient client, uint32_t id, RilOnUnsolicited handler);
100 
101 /**
102  * Register solicited response handler. If handler is NULL,
103  * the handler for the ID is unregistered.
104  * The response handler is invoked in the client task context.
105  * Return is 0 or error code.
106  */
107 int RegisterRequestCompleteHandler(HRilClient client, uint32_t id, RilOnComplete handler);
108 
109 /**
110  * Register error callback. If handler is NULL,
111  * the callback is unregistered.
112  * The response handler is invoked in the client task context.
113  * Return is 0 or error code.
114  */
115 int RegisterErrorCallback(HRilClient client, RilOnError cb, void *data);
116 
117 /**
118  * Invoke OEM request. Request ID is RIL_REQUEST_OEM_HOOK_RAW.
119  * Return is 0 or error code. For RIL_CLIENT_ERR_AGAIN caller should retry.
120  */
121 int InvokeOemRequestHookRaw(HRilClient client, char *data, size_t len);
122 
123 /**
124  * Sound device types.
125  */
126 typedef enum _SoundType {
127     SOUND_TYPE_VOICE,
128     SOUND_TYPE_SPEAKER,
129     SOUND_TYPE_HEADSET,
130     SOUND_TYPE_BTVOICE
131 } SoundType;
132 
133 /**
134  * External sound device path.
135  */
136 typedef enum _AudioPath {
137     SOUND_AUDIO_PATH_HANDSET,
138     SOUND_AUDIO_PATH_HEADSET,
139     SOUND_AUDIO_PATH_SPEAKER,
140     SOUND_AUDIO_PATH_BLUETOOTH,
141     SOUND_AUDIO_PATH_BLUETOOTH_NO_NR,
142     SOUND_AUDIO_PATH_HEADPHONE
143 } AudioPath;
144 
145 /**
146  * Clock adjustment parameters.
147  */
148 typedef enum _SoundClockCondition {
149     SOUND_CLOCK_STOP,
150     SOUND_CLOCK_START
151 } SoundClockCondition;
152 
153 /**
154  * Set in-call volume.
155  */
156 int SetCallVolume(HRilClient client, SoundType type, int vol_level);
157 
158 /**
159  * Set external sound device path for noise reduction.
160  */
161 int SetCallAudioPath(HRilClient client, AudioPath path);
162 
163 /**
164  * Set modem clock to master or slave.
165  */
166 int SetCallClockSync(HRilClient client, SoundClockCondition condition);
167 
168 #ifdef __cplusplus
169 };
170 #endif
171 
172 #endif // __SECRIL_CLIENT_H__
173 
174 // end of file
175 
176