1 /* acoustics_default.cpp
2 **
3 ** Copyright 2009 Wind River Systems
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #define LOG_TAG "AcousticsModule"
19 #include <utils/Log.h>
20
21 #include "AudioHardwareALSA.h"
22
23 namespace android
24 {
25
26 static int s_device_open(const hw_module_t*, const char*, hw_device_t**);
27 static int s_device_close(hw_device_t*);
28
29 static status_t s_use_handle(acoustic_device_t *, alsa_handle_t *);
30 static status_t s_cleanup(acoustic_device_t *);
31 static status_t s_set_params(acoustic_device_t *,
32 AudioSystem::audio_in_acoustics, void *params);
33
34 static hw_module_methods_t s_module_methods = {
35 open : s_device_open
36 };
37
38 extern "C" hw_module_t HAL_MODULE_INFO_SYM = {
39 tag : HARDWARE_MODULE_TAG,
40 version_major : 1,
41 version_minor : 0,
42 id : ACOUSTICS_HARDWARE_MODULE_ID,
43 name : "ALSA acoustics module",
44 author : "Wind River",
45 methods : &s_module_methods,
46 dso : 0,
47 reserved : { 0, },
48 };
49
s_device_open(const hw_module_t * module,const char * name,hw_device_t ** device)50 static int s_device_open(const hw_module_t* module, const char* name,
51 hw_device_t** device)
52 {
53 acoustic_device_t *dev;
54 dev = (acoustic_device_t *) malloc(sizeof(*dev));
55 if (!dev) return -ENOMEM;
56
57 memset(dev, 0, sizeof(*dev));
58
59 /* initialize the procs */
60 dev->common.tag = HARDWARE_DEVICE_TAG;
61 dev->common.version = 0;
62 dev->common.module = (hw_module_t *) module;
63 dev->common.close = s_device_close;
64
65 // Required methods...
66 dev->use_handle = s_use_handle;
67 dev->cleanup = s_cleanup;
68 dev->set_params = s_set_params;
69
70 // read, write, and recover are optional methods...
71
72 *device = &dev->common;
73 return 0;
74 }
75
s_device_close(hw_device_t * device)76 static int s_device_close(hw_device_t* device)
77 {
78 free(device);
79 return 0;
80 }
81
s_use_handle(acoustic_device_t * dev,alsa_handle_t * h)82 static status_t s_use_handle(acoustic_device_t *dev, alsa_handle_t *h)
83 {
84 return NO_ERROR;
85 }
86
s_cleanup(acoustic_device_t * dev)87 static status_t s_cleanup(acoustic_device_t *dev)
88 {
89 ALOGD("Acoustics close stub called.");
90 return NO_ERROR;
91 }
92
s_set_params(acoustic_device_t * dev,AudioSystem::audio_in_acoustics acoustics,void * params)93 static status_t s_set_params(acoustic_device_t *dev,
94 AudioSystem::audio_in_acoustics acoustics, void *params)
95 {
96 ALOGD("Acoustics set_params stub called with %d.", (int)acoustics);
97 return NO_ERROR;
98 }
99 }
100