blob: c0d840f983ea6520aa66dc2eed4c0c9150ad67e8 [file] [log] [blame]
Ethan Chenb6e32fd2015-06-07 11:34:30 -07001/*
2 * Copyright (C) 2015 The CyanogenMod 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#define LOG_TAG "amplifier_default"
18//#define LOG_NDEBUG 0
19
20#include <stdint.h>
21#include <stdlib.h>
22#include <sys/types.h>
23
24#include <cutils/log.h>
25#include <cutils/str_parms.h>
26
27#include <hardware/audio_amplifier.h>
28#include <hardware/hardware.h>
29
30static int amp_set_input_devices(amplifier_device_t *device, uint32_t devices)
31{
32 return 0;
33}
34
35static int amp_set_output_devices(amplifier_device_t *device, uint32_t devices)
36{
37 return 0;
38}
39
40static int amp_enable_output_devices(amplifier_device_t *device,
41 uint32_t devices, bool enable)
42{
43 return 0;
44}
45
46static int amp_enable_input_devices(amplifier_device_t *device,
47 uint32_t devices, bool enable)
48{
49 return 0;
50}
51
52static int amp_set_mode(amplifier_device_t *device, audio_mode_t mode)
53{
54 return 0;
55}
56
57static int amp_output_stream_start(amplifier_device_t *device,
58 struct audio_stream_out *stream, bool offload)
59{
60 return 0;
61}
62
63static int amp_input_stream_start(amplifier_device_t *device,
64 struct audio_stream_in *stream)
65{
66 return 0;
67}
68
69static int amp_output_stream_standby(amplifier_device_t *device,
70 struct audio_stream_out *stream)
71{
72 return 0;
73}
74
75static int amp_input_stream_standby(amplifier_device_t *device,
76 struct audio_stream_in *stream)
77{
78 return 0;
79}
80
81static int amp_set_parameters(struct amplifier_device *device,
82 struct str_parms *parms)
83{
84 return 0;
85}
86
87static int amp_out_set_parameters(struct amplifier_device *device,
88 struct str_parms *parms)
89{
90 return 0;
91}
92
93static int amp_in_set_parameters(struct amplifier_device *device,
94 struct str_parms *parms)
95{
96 return 0;
97}
98
99static int amp_dev_close(hw_device_t *device)
100{
101 if (device)
102 free(device);
103
104 return 0;
105}
106
107static int amp_module_open(const hw_module_t *module, const char *name,
108 hw_device_t **device)
109{
110 if (strcmp(name, AMPLIFIER_HARDWARE_INTERFACE)) {
111 ALOGE("%s:%d: %s does not match amplifier hardware interface name\n",
112 __func__, __LINE__, name);
113 return -ENODEV;
114 }
115
116 amplifier_device_t *amp_dev = calloc(1, sizeof(amplifier_device_t));
117 if (!amp_dev) {
118 ALOGE("%s:%d: Unable to allocate memory for amplifier device\n",
119 __func__, __LINE__);
120 return -ENOMEM;
121 }
122
123 amp_dev->common.tag = HARDWARE_DEVICE_TAG;
124 amp_dev->common.module = (hw_module_t *) module;
125 amp_dev->common.version = HARDWARE_DEVICE_API_VERSION(1, 0);
126 amp_dev->common.close = amp_dev_close;
127
128 amp_dev->set_input_devices = amp_set_input_devices;
129 amp_dev->set_output_devices = amp_set_output_devices;
130 amp_dev->enable_output_devices = amp_enable_output_devices;
131 amp_dev->enable_input_devices = amp_enable_input_devices;
132 amp_dev->set_mode = amp_set_mode;
133 amp_dev->output_stream_start = amp_output_stream_start;
134 amp_dev->input_stream_start = amp_input_stream_start;
135 amp_dev->output_stream_standby = amp_output_stream_standby;
136 amp_dev->input_stream_standby = amp_input_stream_standby;
137 amp_dev->set_parameters = amp_set_parameters;
138 amp_dev->out_set_parameters = amp_out_set_parameters;
139 amp_dev->in_set_parameters = amp_in_set_parameters;
140
141 *device = (hw_device_t *) amp_dev;
142
143 return 0;
144}
145
146static struct hw_module_methods_t hal_module_methods = {
147 .open = amp_module_open,
148};
149
150amplifier_module_t HAL_MODULE_INFO_SYM = {
151 .common = {
152 .tag = HARDWARE_MODULE_TAG,
153 .module_api_version = AMPLIFIER_MODULE_API_VERSION_0_1,
154 .hal_api_version = HARDWARE_HAL_API_VERSION,
155 .id = AMPLIFIER_HARDWARE_MODULE_ID,
156 .name = "Default audio amplifier HAL",
157 .author = "The CyanogenMod Open Source Project",
158 .methods = &hal_module_methods,
159 },
160};