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