From 271444af385a288bf4164bd2b3e186525e4c0d40 Mon Sep 17 00:00:00 2001 From: Paul McLean Date: Mon, 15 Dec 2014 09:44:42 -0800 Subject: Renaming generic-sounding filenames to indicate "audio". Change-Id: Iba6403a3493379c39d22d23b438f028efc2e15b7 --- modules/usbaudio/Android.mk | 4 +- modules/usbaudio/alsa_device_profile.c | 4 +- modules/usbaudio/alsa_device_proxy.c | 2 +- modules/usbaudio/audio_format.c | 110 ++++++++++++++++++++++++++++ modules/usbaudio/audio_format.h | 26 +++++++ modules/usbaudio/audio_hw.c | 2 +- modules/usbaudio/audio_logging.c | 129 +++++++++++++++++++++++++++++++++ modules/usbaudio/audio_logging.h | 26 +++++++ modules/usbaudio/format.c | 110 ---------------------------- modules/usbaudio/format.h | 26 ------- modules/usbaudio/logging.c | 129 --------------------------------- modules/usbaudio/logging.h | 26 ------- 12 files changed, 297 insertions(+), 297 deletions(-) create mode 100644 modules/usbaudio/audio_format.c create mode 100644 modules/usbaudio/audio_format.h create mode 100644 modules/usbaudio/audio_logging.c create mode 100644 modules/usbaudio/audio_logging.h delete mode 100644 modules/usbaudio/format.c delete mode 100644 modules/usbaudio/format.h delete mode 100644 modules/usbaudio/logging.c delete mode 100644 modules/usbaudio/logging.h (limited to 'modules') diff --git a/modules/usbaudio/Android.mk b/modules/usbaudio/Android.mk index ec8a8c0..446281d 100644 --- a/modules/usbaudio/Android.mk +++ b/modules/usbaudio/Android.mk @@ -22,8 +22,8 @@ LOCAL_SRC_FILES := \ audio_hw.c \ alsa_device_profile.c \ alsa_device_proxy.c \ - logging.c \ - format.c + audio_logging.c \ + audio_format.c LOCAL_C_INCLUDES += \ external/tinyalsa/include \ $(call include-path-for, audio-utils) diff --git a/modules/usbaudio/alsa_device_profile.c b/modules/usbaudio/alsa_device_profile.c index 8e84471..6397b28 100644 --- a/modules/usbaudio/alsa_device_profile.c +++ b/modules/usbaudio/alsa_device_profile.c @@ -26,8 +26,8 @@ #include #include "alsa_device_profile.h" -#include "format.h" -#include "logging.h" +#include "audio_format.h" +#include "audio_logging.h" #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) diff --git a/modules/usbaudio/alsa_device_proxy.c b/modules/usbaudio/alsa_device_proxy.c index 081c05b..902a6d2 100644 --- a/modules/usbaudio/alsa_device_proxy.c +++ b/modules/usbaudio/alsa_device_proxy.c @@ -22,7 +22,7 @@ #include "alsa_device_proxy.h" -#include "logging.h" +#include "audio_logging.h" #define DEFAULT_PERIOD_SIZE 1024 #define DEFAULT_PERIOD_COUNT 2 diff --git a/modules/usbaudio/audio_format.c b/modules/usbaudio/audio_format.c new file mode 100644 index 0000000..63b1ba8 --- /dev/null +++ b/modules/usbaudio/audio_format.c @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "audio_format" +/*#define LOG_NDEBUG 0*/ + +#include "audio_format.h" + +#include + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + +/* + * Maps from bit position in pcm_mask to PCM_ format constants. + */ +int8_t const pcm_format_value_map[50] = { + PCM_FORMAT_S8, /* 00 - SNDRV_PCM_FORMAT_S8 */ + PCM_FORMAT_INVALID, /* 01 - SNDRV_PCM_FORMAT_U8 */ + PCM_FORMAT_S16_LE, /* 02 - SNDRV_PCM_FORMAT_S16_LE */ + PCM_FORMAT_INVALID, /* 03 - SNDRV_PCM_FORMAT_S16_BE */ + PCM_FORMAT_INVALID, /* 04 - SNDRV_PCM_FORMAT_U16_LE */ + PCM_FORMAT_INVALID, /* 05 - SNDRV_PCM_FORMAT_U16_BE */ + PCM_FORMAT_S24_3LE, /* 06 - SNDRV_PCM_FORMAT_S24_LE */ + PCM_FORMAT_INVALID, /* 07 - SNDRV_PCM_FORMAT_S24_BE */ + PCM_FORMAT_INVALID, /* 08 - SNDRV_PCM_FORMAT_U24_LE */ + PCM_FORMAT_INVALID, /* 09 - SNDRV_PCM_FORMAT_U24_BE */ + PCM_FORMAT_S32_LE, /* 10 - SNDRV_PCM_FORMAT_S32_LE */ + PCM_FORMAT_INVALID, /* 11 - SNDRV_PCM_FORMAT_S32_BE */ + PCM_FORMAT_INVALID, /* 12 - SNDRV_PCM_FORMAT_U32_LE */ + PCM_FORMAT_INVALID, /* 13 - SNDRV_PCM_FORMAT_U32_BE */ + PCM_FORMAT_INVALID, /* 14 - SNDRV_PCM_FORMAT_FLOAT_LE */ + PCM_FORMAT_INVALID, /* 15 - SNDRV_PCM_FORMAT_FLOAT_BE */ + PCM_FORMAT_INVALID, /* 16 - SNDRV_PCM_FORMAT_FLOAT64_LE */ + PCM_FORMAT_INVALID, /* 17 - SNDRV_PCM_FORMAT_FLOAT64_BE */ + PCM_FORMAT_INVALID, /* 18 - SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE */ + PCM_FORMAT_INVALID, /* 19 - SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE */ + PCM_FORMAT_INVALID, /* 20 - SNDRV_PCM_FORMAT_MU_LAW */ + PCM_FORMAT_INVALID, /* 21 - SNDRV_PCM_FORMAT_A_LAW */ + PCM_FORMAT_INVALID, /* 22 - SNDRV_PCM_FORMAT_IMA_ADPCM */ + PCM_FORMAT_INVALID, /* 23 - SNDRV_PCM_FORMAT_MPEG */ + PCM_FORMAT_INVALID, /* 24 - SNDRV_PCM_FORMAT_GSM */ + PCM_FORMAT_INVALID, /* 25 -> 30 (not assigned) */ + PCM_FORMAT_INVALID, + PCM_FORMAT_INVALID, + PCM_FORMAT_INVALID, + PCM_FORMAT_INVALID, + PCM_FORMAT_INVALID, + PCM_FORMAT_INVALID, /* 31 - SNDRV_PCM_FORMAT_SPECIAL */ + PCM_FORMAT_S24_3LE, /* 32 - SNDRV_PCM_FORMAT_S24_3LE */ /* ??? */ + PCM_FORMAT_INVALID, /* 33 - SNDRV_PCM_FORMAT_S24_3BE */ + PCM_FORMAT_INVALID, /* 34 - SNDRV_PCM_FORMAT_U24_3LE */ + PCM_FORMAT_INVALID, /* 35 - SNDRV_PCM_FORMAT_U24_3BE */ + PCM_FORMAT_INVALID, /* 36 - SNDRV_PCM_FORMAT_S20_3LE */ + PCM_FORMAT_INVALID, /* 37 - SNDRV_PCM_FORMAT_S20_3BE */ + PCM_FORMAT_INVALID, /* 38 - SNDRV_PCM_FORMAT_U20_3LE */ + PCM_FORMAT_INVALID, /* 39 - SNDRV_PCM_FORMAT_U20_3BE */ + PCM_FORMAT_INVALID, /* 40 - SNDRV_PCM_FORMAT_S18_3LE */ + PCM_FORMAT_INVALID, /* 41 - SNDRV_PCM_FORMAT_S18_3BE */ + PCM_FORMAT_INVALID, /* 42 - SNDRV_PCM_FORMAT_U18_3LE */ + PCM_FORMAT_INVALID, /* 43 - SNDRV_PCM_FORMAT_U18_3BE */ + PCM_FORMAT_INVALID, /* 44 - SNDRV_PCM_FORMAT_G723_24 */ + PCM_FORMAT_INVALID, /* 45 - SNDRV_PCM_FORMAT_G723_24_1B */ + PCM_FORMAT_INVALID, /* 46 - SNDRV_PCM_FORMAT_G723_40 */ + PCM_FORMAT_INVALID, /* 47 - SNDRV_PCM_FORMAT_G723_40_1B */ + PCM_FORMAT_INVALID, /* 48 - SNDRV_PCM_FORMAT_DSD_U8 */ + PCM_FORMAT_INVALID /* 49 - SNDRV_PCM_FORMAT_DSD_U16_LE */ +}; + +/* + * Scans the provided format mask and returns the first non-8 bit sample + * format supported by the devices. + */ +enum pcm_format get_pcm_format_for_mask(struct pcm_mask* mask) +{ + int num_slots = ARRAY_SIZE(mask->bits); + int bits_per_slot = sizeof(mask->bits[0]) * 8; + + int table_size = ARRAY_SIZE(pcm_format_value_map); + + int slot_index, bit_index, table_index; + table_index = 0; + int num_written = 0; + for (slot_index = 0; slot_index < num_slots && table_index < table_size; slot_index++) { + unsigned bit_mask = 1; + for (bit_index = 0; bit_index < bits_per_slot && table_index < table_size; bit_index++) { + /* skip any 8-bit formats */ + if (table_index >= 2 && (mask->bits[slot_index] & bit_mask) != 0) { + /* just return the first one which will be at least 16-bit */ + return (int)pcm_format_value_map[table_index]; + } + bit_mask <<= 1; + table_index++; + } + } + + return PCM_FORMAT_INVALID; +} diff --git a/modules/usbaudio/audio_format.h b/modules/usbaudio/audio_format.h new file mode 100644 index 0000000..712ef67 --- /dev/null +++ b/modules/usbaudio/audio_format.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_AUDIO_FORMAT_H +#define ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_AUDIO_FORMAT_H + +#include + +#include + +enum pcm_format get_pcm_format_for_mask(struct pcm_mask* mask); + +#endif /* ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_AUDIO_FORMAT_H */ diff --git a/modules/usbaudio/audio_hw.c b/modules/usbaudio/audio_hw.c index 0346408..d668787 100644 --- a/modules/usbaudio/audio_hw.c +++ b/modules/usbaudio/audio_hw.c @@ -51,7 +51,7 @@ static const unsigned k_force_channels = 0; #include "alsa_device_profile.h" #include "alsa_device_proxy.h" -#include "logging.h" +#include "audio_logging.h" #define DEFAULT_INPUT_BUFFER_SIZE_MS 20 diff --git a/modules/usbaudio/audio_logging.c b/modules/usbaudio/audio_logging.c new file mode 100644 index 0000000..77fbd51 --- /dev/null +++ b/modules/usbaudio/audio_logging.c @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "audio_logging" +/*#define LOG_NDEBUG 0*/ + +#include + +#include + +#include "audio_logging.h" + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + +/* + * Logging + */ +void log_pcm_mask(const char* mask_name, struct pcm_mask* mask) +{ + const size_t num_slots = ARRAY_SIZE(mask->bits); + const size_t bits_per_slot = (sizeof(mask->bits[0]) * 8); + const size_t chars_per_slot = (bits_per_slot + 1); /* comma */ + + const size_t BUFF_SIZE = + (num_slots * chars_per_slot + 2 + 1); /* brackets and null-terminator */ + char buff[BUFF_SIZE]; + buff[0] = '\0'; + + size_t slot_index, bit_index; + strcat(buff, "["); + for (slot_index = 0; slot_index < num_slots; slot_index++) { + unsigned bit_mask = 1; + for (bit_index = 0; bit_index < bits_per_slot; bit_index++) { + strcat(buff, (mask->bits[slot_index] & bit_mask) != 0 ? "1" : "0"); + bit_mask <<= 1; + } + if (slot_index < num_slots - 1) { + strcat(buff, ","); + } + } + strcat(buff, "]"); + + ALOGV("%s: mask:%s", mask_name, buff); +} + +void log_pcm_params(struct pcm_params * alsa_hw_params) +{ + ALOGV("usb:audio_hw - PCM_PARAM_SAMPLE_BITS min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_SAMPLE_BITS), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_SAMPLE_BITS)); + ALOGV("usb:audio_hw - PCM_PARAM_FRAME_BITS min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_FRAME_BITS), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_FRAME_BITS)); + log_pcm_mask("PCM_PARAM_FORMAT", + pcm_params_get_mask(alsa_hw_params, PCM_PARAM_FORMAT)); + log_pcm_mask("PCM_PARAM_SUBFORMAT", + pcm_params_get_mask(alsa_hw_params, PCM_PARAM_SUBFORMAT)); + ALOGV("usb:audio_hw - PCM_PARAM_CHANNELS min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_CHANNELS), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_CHANNELS)); + ALOGV("usb:audio_hw - PCM_PARAM_RATE min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_RATE), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_RATE)); + ALOGV("usb:audio_hw - PCM_PARAM_PERIOD_TIME min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIOD_TIME), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIOD_TIME)); + ALOGV("usb:audio_hw - PCM_PARAM_PERIOD_SIZE min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIOD_SIZE), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIOD_SIZE)); + ALOGV("usb:audio_hw - PCM_PARAM_PERIOD_BYTES min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIOD_BYTES), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIOD_BYTES)); + ALOGV("usb:audio_hw - PCM_PARAM_PERIODS min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIODS), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIODS)); + ALOGV("usb:audio_hw - PCM_PARAM_BUFFER_TIME min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_BUFFER_TIME), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_BUFFER_TIME)); + ALOGV("usb:audio_hw - PCM_PARAM_BUFFER_SIZE min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_BUFFER_SIZE), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_BUFFER_SIZE)); + ALOGV("usb:audio_hw - PCM_PARAM_BUFFER_BYTES min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_BUFFER_BYTES), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_BUFFER_BYTES)); + ALOGV("usb:audio_hw - PCM_PARAM_TICK_TIME min:%u, max:%u", + pcm_params_get_min(alsa_hw_params, PCM_PARAM_TICK_TIME), + pcm_params_get_max(alsa_hw_params, PCM_PARAM_TICK_TIME)); +} + +void log_pcm_config(struct pcm_config * config, const char* label) { + ALOGV("log_pcm_config() - %s", label); + ALOGV(" channels:%d", config->channels); + ALOGV(" rate:%d", config->rate); + ALOGV(" period_size:%d", config->period_size); + ALOGV(" period_count:%d", config->period_count); + ALOGV(" format:%d", config->format); +#if 0 + /* Values to use for the ALSA start, stop and silence thresholds. Setting + * any one of these values to 0 will cause the default tinyalsa values to be + * used instead. Tinyalsa defaults are as follows. + * + * start_threshold : period_count * period_size + * stop_threshold : period_count * period_size + * silence_threshold : 0 + */ + unsigned int start_threshold; + unsigned int stop_threshold; + unsigned int silence_threshold; + + /* Minimum number of frames available before pcm_mmap_write() will actually + * write into the kernel buffer. Only used if the stream is opened in mmap mode + * (pcm_open() called with PCM_MMAP flag set). Use 0 for default. + */ + int avail_min; +#endif +} diff --git a/modules/usbaudio/audio_logging.h b/modules/usbaudio/audio_logging.h new file mode 100644 index 0000000..082e8b2 --- /dev/null +++ b/modules/usbaudio/audio_logging.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_AUDIO_LOGGING_H +#define ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_AUDIO_LOGGING_H + +#include + +void log_pcm_mask(const char* mask_name, struct pcm_mask* mask); +void log_pcm_params(struct pcm_params * alsa_hw_params); +void log_pcm_config(struct pcm_config * config, const char* label); + +#endif /* ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_AUDIO_LOGGING_H */ diff --git a/modules/usbaudio/format.c b/modules/usbaudio/format.c deleted file mode 100644 index 701e4c6..0000000 --- a/modules/usbaudio/format.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "audio_format" -/*#define LOG_NDEBUG 0*/ - -#include "format.h" - -#include - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - -/* - * Maps from bit position in pcm_mask to PCM_ format constants. - */ -int8_t const pcm_format_value_map[50] = { - PCM_FORMAT_S8, /* 00 - SNDRV_PCM_FORMAT_S8 */ - PCM_FORMAT_INVALID, /* 01 - SNDRV_PCM_FORMAT_U8 */ - PCM_FORMAT_S16_LE, /* 02 - SNDRV_PCM_FORMAT_S16_LE */ - PCM_FORMAT_INVALID, /* 03 - SNDRV_PCM_FORMAT_S16_BE */ - PCM_FORMAT_INVALID, /* 04 - SNDRV_PCM_FORMAT_U16_LE */ - PCM_FORMAT_INVALID, /* 05 - SNDRV_PCM_FORMAT_U16_BE */ - PCM_FORMAT_S24_3LE, /* 06 - SNDRV_PCM_FORMAT_S24_LE */ - PCM_FORMAT_INVALID, /* 07 - SNDRV_PCM_FORMAT_S24_BE */ - PCM_FORMAT_INVALID, /* 08 - SNDRV_PCM_FORMAT_U24_LE */ - PCM_FORMAT_INVALID, /* 09 - SNDRV_PCM_FORMAT_U24_BE */ - PCM_FORMAT_S32_LE, /* 10 - SNDRV_PCM_FORMAT_S32_LE */ - PCM_FORMAT_INVALID, /* 11 - SNDRV_PCM_FORMAT_S32_BE */ - PCM_FORMAT_INVALID, /* 12 - SNDRV_PCM_FORMAT_U32_LE */ - PCM_FORMAT_INVALID, /* 13 - SNDRV_PCM_FORMAT_U32_BE */ - PCM_FORMAT_INVALID, /* 14 - SNDRV_PCM_FORMAT_FLOAT_LE */ - PCM_FORMAT_INVALID, /* 15 - SNDRV_PCM_FORMAT_FLOAT_BE */ - PCM_FORMAT_INVALID, /* 16 - SNDRV_PCM_FORMAT_FLOAT64_LE */ - PCM_FORMAT_INVALID, /* 17 - SNDRV_PCM_FORMAT_FLOAT64_BE */ - PCM_FORMAT_INVALID, /* 18 - SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE */ - PCM_FORMAT_INVALID, /* 19 - SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE */ - PCM_FORMAT_INVALID, /* 20 - SNDRV_PCM_FORMAT_MU_LAW */ - PCM_FORMAT_INVALID, /* 21 - SNDRV_PCM_FORMAT_A_LAW */ - PCM_FORMAT_INVALID, /* 22 - SNDRV_PCM_FORMAT_IMA_ADPCM */ - PCM_FORMAT_INVALID, /* 23 - SNDRV_PCM_FORMAT_MPEG */ - PCM_FORMAT_INVALID, /* 24 - SNDRV_PCM_FORMAT_GSM */ - PCM_FORMAT_INVALID, /* 25 -> 30 (not assigned) */ - PCM_FORMAT_INVALID, - PCM_FORMAT_INVALID, - PCM_FORMAT_INVALID, - PCM_FORMAT_INVALID, - PCM_FORMAT_INVALID, - PCM_FORMAT_INVALID, /* 31 - SNDRV_PCM_FORMAT_SPECIAL */ - PCM_FORMAT_S24_3LE, /* 32 - SNDRV_PCM_FORMAT_S24_3LE */ /* ??? */ - PCM_FORMAT_INVALID, /* 33 - SNDRV_PCM_FORMAT_S24_3BE */ - PCM_FORMAT_INVALID, /* 34 - SNDRV_PCM_FORMAT_U24_3LE */ - PCM_FORMAT_INVALID, /* 35 - SNDRV_PCM_FORMAT_U24_3BE */ - PCM_FORMAT_INVALID, /* 36 - SNDRV_PCM_FORMAT_S20_3LE */ - PCM_FORMAT_INVALID, /* 37 - SNDRV_PCM_FORMAT_S20_3BE */ - PCM_FORMAT_INVALID, /* 38 - SNDRV_PCM_FORMAT_U20_3LE */ - PCM_FORMAT_INVALID, /* 39 - SNDRV_PCM_FORMAT_U20_3BE */ - PCM_FORMAT_INVALID, /* 40 - SNDRV_PCM_FORMAT_S18_3LE */ - PCM_FORMAT_INVALID, /* 41 - SNDRV_PCM_FORMAT_S18_3BE */ - PCM_FORMAT_INVALID, /* 42 - SNDRV_PCM_FORMAT_U18_3LE */ - PCM_FORMAT_INVALID, /* 43 - SNDRV_PCM_FORMAT_U18_3BE */ - PCM_FORMAT_INVALID, /* 44 - SNDRV_PCM_FORMAT_G723_24 */ - PCM_FORMAT_INVALID, /* 45 - SNDRV_PCM_FORMAT_G723_24_1B */ - PCM_FORMAT_INVALID, /* 46 - SNDRV_PCM_FORMAT_G723_40 */ - PCM_FORMAT_INVALID, /* 47 - SNDRV_PCM_FORMAT_G723_40_1B */ - PCM_FORMAT_INVALID, /* 48 - SNDRV_PCM_FORMAT_DSD_U8 */ - PCM_FORMAT_INVALID /* 49 - SNDRV_PCM_FORMAT_DSD_U16_LE */ -}; - -/* - * Scans the provided format mask and returns the first non-8 bit sample - * format supported by the devices. - */ -enum pcm_format get_pcm_format_for_mask(struct pcm_mask* mask) -{ - int num_slots = ARRAY_SIZE(mask->bits); - int bits_per_slot = sizeof(mask->bits[0]) * 8; - - int table_size = ARRAY_SIZE(pcm_format_value_map); - - int slot_index, bit_index, table_index; - table_index = 0; - int num_written = 0; - for (slot_index = 0; slot_index < num_slots && table_index < table_size; slot_index++) { - unsigned bit_mask = 1; - for (bit_index = 0; bit_index < bits_per_slot && table_index < table_size; bit_index++) { - /* skip any 8-bit formats */ - if (table_index >= 2 && (mask->bits[slot_index] & bit_mask) != 0) { - /* just return the first one which will be at least 16-bit */ - return (int)pcm_format_value_map[table_index]; - } - bit_mask <<= 1; - table_index++; - } - } - - return PCM_FORMAT_INVALID; -} diff --git a/modules/usbaudio/format.h b/modules/usbaudio/format.h deleted file mode 100644 index 0d41c3a..0000000 --- a/modules/usbaudio/format.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_FORMAT_H -#define ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_FORMAT_H - -#include - -#include - -enum pcm_format get_pcm_format_for_mask(struct pcm_mask* mask); - -#endif /* ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_FORMAT_H */ diff --git a/modules/usbaudio/logging.c b/modules/usbaudio/logging.c deleted file mode 100644 index d3f7abf..0000000 --- a/modules/usbaudio/logging.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "audio_logging" -/*#define LOG_NDEBUG 0*/ - -#include - -#include - -#include "logging.h" - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - -/* - * Logging - */ -void log_pcm_mask(const char* mask_name, struct pcm_mask* mask) -{ - const size_t num_slots = ARRAY_SIZE(mask->bits); - const size_t bits_per_slot = (sizeof(mask->bits[0]) * 8); - const size_t chars_per_slot = (bits_per_slot + 1); /* comma */ - - const size_t BUFF_SIZE = - (num_slots * chars_per_slot + 2 + 1); /* brackets and null-terminator */ - char buff[BUFF_SIZE]; - buff[0] = '\0'; - - size_t slot_index, bit_index; - strcat(buff, "["); - for (slot_index = 0; slot_index < num_slots; slot_index++) { - unsigned bit_mask = 1; - for (bit_index = 0; bit_index < bits_per_slot; bit_index++) { - strcat(buff, (mask->bits[slot_index] & bit_mask) != 0 ? "1" : "0"); - bit_mask <<= 1; - } - if (slot_index < num_slots - 1) { - strcat(buff, ","); - } - } - strcat(buff, "]"); - - ALOGV("%s: mask:%s", mask_name, buff); -} - -void log_pcm_params(struct pcm_params * alsa_hw_params) -{ - ALOGV("usb:audio_hw - PCM_PARAM_SAMPLE_BITS min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_SAMPLE_BITS), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_SAMPLE_BITS)); - ALOGV("usb:audio_hw - PCM_PARAM_FRAME_BITS min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_FRAME_BITS), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_FRAME_BITS)); - log_pcm_mask("PCM_PARAM_FORMAT", - pcm_params_get_mask(alsa_hw_params, PCM_PARAM_FORMAT)); - log_pcm_mask("PCM_PARAM_SUBFORMAT", - pcm_params_get_mask(alsa_hw_params, PCM_PARAM_SUBFORMAT)); - ALOGV("usb:audio_hw - PCM_PARAM_CHANNELS min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_CHANNELS), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_CHANNELS)); - ALOGV("usb:audio_hw - PCM_PARAM_RATE min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_RATE), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_RATE)); - ALOGV("usb:audio_hw - PCM_PARAM_PERIOD_TIME min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIOD_TIME), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIOD_TIME)); - ALOGV("usb:audio_hw - PCM_PARAM_PERIOD_SIZE min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIOD_SIZE), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIOD_SIZE)); - ALOGV("usb:audio_hw - PCM_PARAM_PERIOD_BYTES min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIOD_BYTES), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIOD_BYTES)); - ALOGV("usb:audio_hw - PCM_PARAM_PERIODS min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_PERIODS), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_PERIODS)); - ALOGV("usb:audio_hw - PCM_PARAM_BUFFER_TIME min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_BUFFER_TIME), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_BUFFER_TIME)); - ALOGV("usb:audio_hw - PCM_PARAM_BUFFER_SIZE min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_BUFFER_SIZE), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_BUFFER_SIZE)); - ALOGV("usb:audio_hw - PCM_PARAM_BUFFER_BYTES min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_BUFFER_BYTES), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_BUFFER_BYTES)); - ALOGV("usb:audio_hw - PCM_PARAM_TICK_TIME min:%u, max:%u", - pcm_params_get_min(alsa_hw_params, PCM_PARAM_TICK_TIME), - pcm_params_get_max(alsa_hw_params, PCM_PARAM_TICK_TIME)); -} - -void log_pcm_config(struct pcm_config * config, const char* label) { - ALOGV("log_pcm_config() - %s", label); - ALOGV(" channels:%d", config->channels); - ALOGV(" rate:%d", config->rate); - ALOGV(" period_size:%d", config->period_size); - ALOGV(" period_count:%d", config->period_count); - ALOGV(" format:%d", config->format); -#if 0 - /* Values to use for the ALSA start, stop and silence thresholds. Setting - * any one of these values to 0 will cause the default tinyalsa values to be - * used instead. Tinyalsa defaults are as follows. - * - * start_threshold : period_count * period_size - * stop_threshold : period_count * period_size - * silence_threshold : 0 - */ - unsigned int start_threshold; - unsigned int stop_threshold; - unsigned int silence_threshold; - - /* Minimum number of frames available before pcm_mmap_write() will actually - * write into the kernel buffer. Only used if the stream is opened in mmap mode - * (pcm_open() called with PCM_MMAP flag set). Use 0 for default. - */ - int avail_min; -#endif -} diff --git a/modules/usbaudio/logging.h b/modules/usbaudio/logging.h deleted file mode 100644 index b5640ed..0000000 --- a/modules/usbaudio/logging.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_LOGGING_H -#define ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_LOGGING_H - -#include - -void log_pcm_mask(const char* mask_name, struct pcm_mask* mask); -void log_pcm_params(struct pcm_params * alsa_hw_params); -void log_pcm_config(struct pcm_config * config, const char* label); - -#endif /* ANDROID_HARDWARE_LIBHARDWARE_MODULES_USBAUDIO_LOGGING_H */ -- cgit v1.1