diff options
Diffstat (limited to 'audio_hw.c')
-rw-r--r-- | audio_hw.c | 71 |
1 files changed, 28 insertions, 43 deletions
@@ -40,28 +40,11 @@ * Functions */ -static uint32_t audio_hw_get_supported_devices(const struct audio_hw_device *dev) -{ - struct tinyalsa_audio_device *device; - - LOGD("%s(%p)", __func__, dev); - - if(dev == NULL) - return -1; - - device = (struct tinyalsa_audio_device *) dev; - - if(device->mixer == NULL) - return -1; - - return (uint32_t) tinyalsa_mixer_get_supported_devices(device->mixer); -} - static int audio_hw_init_check(const struct audio_hw_device *dev) { struct tinyalsa_audio_device *device; - LOGD("%s(%p)", __func__, dev); + ALOGD("%s(%p)", __func__, dev); if(dev == NULL) return -1; @@ -79,7 +62,7 @@ static int audio_hw_set_voice_volume(struct audio_hw_device *dev, float volume) struct tinyalsa_audio_device *device; audio_devices_t device_modem; - LOGD("%s(%p, %f)", __func__, dev, volume); + ALOGD("%s(%p, %f)", __func__, dev, volume); if(dev == NULL) return -1; @@ -119,7 +102,7 @@ static int audio_hw_set_master_volume(struct audio_hw_device *dev, float volume) { struct tinyalsa_audio_device *device; - LOGD("%s(%p, %f)", __func__, dev, volume); + ALOGD("%s(%p, %f)", __func__, dev, volume); if(dev == NULL) return -1; @@ -143,7 +126,7 @@ static int audio_hw_set_mode(struct audio_hw_device *dev, int mode) audio_devices_t device_modem; int rc; - LOGD("%s(%p, %d)", __func__, dev, mode); + ALOGD("%s(%p, %d)", __func__, dev, mode); if(dev == NULL) return -1; @@ -166,13 +149,13 @@ static int audio_hw_set_mode(struct audio_hw_device *dev, int mode) #ifdef YAMAHA_MC1N2_AUDIO rc = yamaha_mc1n2_audio_modem_start(device->mc1n2_pdata); if(rc < 0) { - LOGE("Failed to set Yamaha-MC1N2-Audio route"); + ALOGE("Failed to set Yamaha-MC1N2-Audio route"); } #endif rc = audio_ril_interface_open((struct audio_hw_device *) device, device_modem, &ril_interface); if(rc < 0 || ril_interface == NULL) { - LOGE("Failed to open RIL interface"); + ALOGE("Failed to open RIL interface"); device->ril_interface = NULL; } else { device->ril_interface = ril_interface; @@ -186,7 +169,7 @@ static int audio_hw_set_mode(struct audio_hw_device *dev, int mode) #ifdef YAMAHA_MC1N2_AUDIO rc = yamaha_mc1n2_audio_modem_stop(device->mc1n2_pdata); if(rc < 0) { - LOGE("Failed to set Yamaha-MC1N2-Audio route"); + ALOGE("Failed to set Yamaha-MC1N2-Audio route"); } #endif @@ -207,7 +190,7 @@ static int audio_hw_set_mic_mute(struct audio_hw_device *dev, bool state) struct tinyalsa_audio_device *device; audio_devices_t device_modem; - LOGD("%s(%p, %d)", __func__, dev, state); + ALOGD("%s(%p, %d)", __func__, dev, state); if(dev == NULL) return -1; @@ -252,7 +235,7 @@ static int audio_hw_get_mic_mute(const struct audio_hw_device *dev, bool *state) { struct tinyalsa_audio_device *device; - LOGD("%s(%p, %p)", __func__, dev, state); + ALOGD("%s(%p, %p)", __func__, dev, state); if(dev == NULL) return -1; @@ -273,7 +256,7 @@ static int audio_hw_set_parameters(struct audio_hw_device *dev, int value; int rc; - LOGD("%s(%p, %s)", __func__, dev, kvpairs); + ALOGD("%s(%p, %s)", __func__, dev, kvpairs); if(dev == NULL || kvpairs == NULL) return -1; @@ -327,21 +310,22 @@ error_params: static char *audio_hw_get_parameters(const struct audio_hw_device *dev, const char *keys) { - LOGD("%s(%p, %s)", __func__, dev, keys); + ALOGD("%s(%p, %s)", __func__, dev, keys); return strdup(""); } static size_t audio_hw_get_input_buffer_size(const struct audio_hw_device *dev, - uint32_t sample_rate, int format, int channel_count) + const struct audio_config *config) { struct tinyalsa_audio_device *device; struct tinyalsa_mixer_io_props *mixer_props; + int channel_count; size_t size; - LOGD("%s(%p, %d, %d, %d)", __func__, dev, sample_rate, format, channel_count); + ALOGD("%s(%p, %p)", __func__, dev, config); - if(dev == NULL) + if(dev == NULL || config == NULL) return -1; device = (struct tinyalsa_audio_device *) dev; @@ -357,16 +341,18 @@ static size_t audio_hw_get_input_buffer_size(const struct audio_hw_device *dev, if(mixer_props->rate == 0) mixer_props->rate = 44100; - size = (mixer_props->period_size * sample_rate) / mixer_props->rate; + channel_count = popcount(config->channel_mask); + + size = (mixer_props->period_size * config->sample_rate) / mixer_props->rate; size = ((size + 15) / 16) * 16; - size = size * channel_count * audio_bytes_per_sample(format); + size = size * channel_count * audio_bytes_per_sample(config->format); return size; } static int audio_hw_dump(const audio_hw_device_t *device, int fd) { - LOGD("%s(%p, %d)", __func__, device, fd); + ALOGD("%s(%p, %d)", __func__, device, fd); return 0; } @@ -379,7 +365,7 @@ int audio_hw_close(hw_device_t *device) { struct tinyalsa_audio_device *tinyalsa_audio_device; - LOGD("%s(%p)", __func__, device); + ALOGD("%s(%p)", __func__, device); if(device != NULL) { tinyalsa_audio_device = (struct tinyalsa_audio_device *) device; @@ -410,7 +396,7 @@ int audio_hw_open(const hw_module_t *module, const char *name, struct audio_hw_device *dev; int rc; - LOGD("%s(%p, %s, %p)", __func__, module, name, device); + ALOGD("%s(%p, %s, %p)", __func__, module, name, device); if(device == NULL) return -EINVAL; @@ -425,11 +411,10 @@ int audio_hw_open(const hw_module_t *module, const char *name, dev = &(tinyalsa_audio_device->device); dev->common.tag = HARDWARE_DEVICE_TAG; - dev->common.version = 0; + dev->common.version = AUDIO_DEVICE_API_VERSION_CURRENT; dev->common.module = (struct hw_module_t *) module; dev->common.close = audio_hw_close; - dev->get_supported_devices = audio_hw_get_supported_devices; dev->init_check = audio_hw_init_check; dev->set_voice_volume = audio_hw_set_voice_volume; dev->set_master_volume = audio_hw_set_master_volume; @@ -452,19 +437,19 @@ int audio_hw_open(const hw_module_t *module, const char *name, rc = yamaha_mc1n2_audio_start(&tinyalsa_audio_device->mc1n2_pdata, YAMAHA_MC1N2_AUDIO_DEVICE); if(rc < 0) { - LOGE("Failed to open Yamaha-MC1N2-Audio"); + ALOGE("Failed to open Yamaha-MC1N2-Audio"); goto error_device; } rc = yamaha_mc1n2_audio_init(tinyalsa_audio_device->mc1n2_pdata); if(rc < 0) { - LOGE("Failed to init Yamaha-MC1N2-Audio"); + ALOGE("Failed to init Yamaha-MC1N2-Audio"); } #endif rc = tinyalsa_mixer_open(&tinyalsa_mixer, TINYALSA_MIXER_CONFIG_FILE); if(rc < 0 || tinyalsa_mixer == NULL) { - LOGE("Failed to open mixer!"); + ALOGE("Failed to open mixer!"); goto error_device; } @@ -488,8 +473,8 @@ struct hw_module_methods_t audio_hw_module_methods = { struct audio_module HAL_MODULE_INFO_SYM = { .common = { .tag = HARDWARE_MODULE_TAG, - .version_major = 1, - .version_minor = 0, + .module_api_version = AUDIO_MODULE_API_VERSION_0_1, + .hal_api_version = HARDWARE_HAL_API_VERSION, .id = AUDIO_HARDWARE_MODULE_ID, .name = "TinyALSA-Audio", .author = "Paul Kocialkowski", |