summaryrefslogtreecommitdiffstats
path: root/include/hardware/audio.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/hardware/audio.h')
-rw-r--r--include/hardware/audio.h210
1 files changed, 208 insertions, 2 deletions
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 3a0962e..beac717 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 The Android Open Source Project
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +20,7 @@
#define ANDROID_AUDIO_HAL_INTERFACE_H
#include <stdint.h>
+#include <string.h>
#include <strings.h>
#include <sys/cdefs.h>
#include <sys/types.h>
@@ -54,7 +56,11 @@ __BEGIN_DECLS
#define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0)
#define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
#define AUDIO_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
+#ifndef ICS_AUDIO_BLOB
#define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_2_0
+#else
+#define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_1_0
+#endif
/**
* List of known audio HAL modules. This is the base name of the audio HAL
@@ -117,7 +123,20 @@ __BEGIN_DECLS
* "sup_sampling_rates=44100|48000" */
#define AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates"
+/* Query handle fm parameter*/
+#define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm"
+/* Query voip flag */
+#define AUDIO_PARAMETER_KEY_VOIP_CHECK "voip_flag"
+
+/* Query Fluence type */
+#define AUDIO_PARAMETER_KEY_FLUENCE_TYPE "fluence"
+
+/* Query if surround sound recording is supported */
+#define AUDIO_PARAMETER_KEY_SSR "ssr"
+
+/* Query if a2dp is supported */
+#define AUDIO_PARAMETER_KEY_HANDLE_A2DP_DEVICE "isA2dpDeviceSupported"
/**************************************/
/* common audio stream configuration parameters */
@@ -128,6 +147,9 @@ struct audio_config {
};
typedef struct audio_config audio_config_t;
+#ifdef QCOM_HARDWARE
+typedef struct buf_info;
+#endif
/* common audio stream parameters and operations */
struct audio_stream {
@@ -252,16 +274,101 @@ struct audio_stream_out {
int (*get_render_position)(const struct audio_stream_out *stream,
uint32_t *dsp_frames);
+#ifdef QCOM_HARDWARE
+ /**
+ * start audio data rendering
+ */
+ int (*start)(struct audio_stream_out *stream);
+
+ /**
+ * pause audio rendering
+ */
+ int (*pause)(struct audio_stream_out *stream);
+
+ /**
+ * flush audio data with driver
+ */
+ int (*flush)(struct audio_stream_out *stream);
+
+ /**
+ * stop audio data rendering
+ */
+ int (*stop)(struct audio_stream_out *stream);
+#endif
+
/**
* get the local time at which the next write to the audio driver will be presented.
* The units are microseconds, where the epoch is decided by the local audio HAL.
*/
int (*get_next_write_timestamp)(const struct audio_stream_out *stream,
int64_t *timestamp);
+#ifdef QCOM_HARDWARE
+ /**
+ * return the current timestamp after quering to the driver
+ */
+ int (*get_time_stamp)(const struct audio_stream_out *stream,
+ uint64_t *time_stamp);
+ /**
+ * EOS notification from HAL to Player
+ */
+ int (*set_observer)(const struct audio_stream_out *stream,
+ void *observer);
+ /**
+ * Get the physical address of the buffer allocated in the
+ * driver
+ */
+ int (*get_buffer_info) (const struct audio_stream_out *stream,
+ struct buf_info **buf);
+ /**
+ * Check if next buffer is available. Waits until next buffer is
+ * available
+ */
+ int (*is_buffer_available) (const struct audio_stream_out *stream,
+ int *isAvail);
+#endif
};
typedef struct audio_stream_out audio_stream_out_t;
+#ifdef QCOM_HARDWARE
+/**
+ * audio_broadcast_stream is the abstraction interface for the
+ * audio output hardware.
+ *
+ * It provides information about various properties of the audio output
+ * hardware driver.
+ */
+
+struct audio_broadcast_stream {
+ struct audio_stream common;
+
+ /**
+ * return the audio hardware driver latency in milli seconds.
+ */
+ uint32_t (*get_latency)(const struct audio_broadcast_stream *stream);
+
+ /**
+ * Use this method in situations where audio mixing is done in the
+ * hardware. This method serves as a direct interface with hardware,
+ * allowing you to directly set the volume as apposed to via the framework.
+ * This method might produce multiple PCM outputs or hardware accelerated
+ * codecs, such as MP3 or AAC.
+ */
+ int (*set_volume)(struct audio_broadcast_stream *stream, float left, float right);
+
+ int (*mute)(struct audio_broadcast_stream *stream, bool mute);
+
+ int (*start)(struct audio_broadcast_stream *stream, int64_t absTimeToStart);
+ /**
+ * write audio buffer to driver. Returns number of bytes written
+ */
+ ssize_t (*write)(struct audio_broadcast_stream *stream, const void* buffer,
+ size_t bytes, int64_t timestamp, int audioType);
+
+};
+typedef struct audio_broadcast_stream audio_broadcast_stream_t;
+#endif
+
struct audio_stream_in {
struct audio_stream common;
@@ -296,8 +403,39 @@ typedef struct audio_stream_in audio_stream_in_t;
static inline size_t audio_stream_frame_size(const struct audio_stream *s)
{
size_t chan_samp_sz;
+ uint32_t chan_mask = s->get_channels(s);
+ int format = s->get_format(s);
- switch (s->get_format(s)) {
+#ifdef QCOM_HARDWARE
+ if (!s)
+ return 0;
+
+ if (audio_is_input_channel(chan_mask)) {
+ chan_mask &= (AUDIO_CHANNEL_IN_STEREO | \
+ AUDIO_CHANNEL_IN_MONO | \
+ AUDIO_CHANNEL_IN_5POINT1);
+ }
+
+ if(!strncmp(s->get_parameters(s, "voip_flag"),"voip_flag=1",sizeof("voip_flag=1"))) {
+ if(format != AUDIO_FORMAT_PCM_8_BIT)
+ return popcount(chan_mask) * sizeof(int16_t);
+ else
+ return popcount(chan_mask) * sizeof(int8_t);
+ }
+#endif
+
+ switch (format) {
+#ifdef QCOM_HARDWARE
+ case AUDIO_FORMAT_AMR_NB:
+ chan_samp_sz = 32;
+ break;
+ case AUDIO_FORMAT_EVRC:
+ chan_samp_sz = 23;
+ break;
+ case AUDIO_FORMAT_QCELP:
+ chan_samp_sz = 35;
+ break;
+#endif
case AUDIO_FORMAT_PCM_16_BIT:
chan_samp_sz = sizeof(int16_t);
break;
@@ -307,7 +445,7 @@ static inline size_t audio_stream_frame_size(const struct audio_stream *s)
break;
}
- return popcount(s->get_channels(s)) * chan_samp_sz;
+ return popcount(chan_mask) * chan_samp_sz;
}
@@ -355,6 +493,7 @@ struct audio_hw_device {
*/
int (*set_master_volume)(struct audio_hw_device *dev, float volume);
+#ifndef ICS_AUDIO_BLOB
/**
* Get the current master volume value for the HAL, if the HAL supports
* master volume control. AudioFlinger will query this value from the
@@ -363,6 +502,12 @@ struct audio_hw_device {
* this method may leave it set to NULL.
*/
int (*get_master_volume)(struct audio_hw_device *dev, float *volume);
+#endif
+
+#ifdef QCOM_FM_ENABLED
+ /** set the fm audio volume. Range is between 0.0 and 1.0 */
+ int (*set_fm_volume)(struct audio_hw_device *dev, float volume);
+#endif
/**
* set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode
@@ -390,25 +535,65 @@ struct audio_hw_device {
* See also get_buffer_size which is for a particular stream.
*/
size_t (*get_input_buffer_size)(const struct audio_hw_device *dev,
+#ifndef ICS_AUDIO_BLOB
const struct audio_config *config);
+#else
+ uint32_t sample_rate, int format,
+ int channel_count);
+#endif
/** This method creates and opens the audio hardware output stream */
+#ifndef ICS_AUDIO_BLOB
int (*open_output_stream)(struct audio_hw_device *dev,
audio_io_handle_t handle,
audio_devices_t devices,
audio_output_flags_t flags,
struct audio_config *config,
struct audio_stream_out **stream_out);
+#else
+ int (*open_output_stream)(struct audio_hw_device *dev, uint32_t devices,
+ int *format, uint32_t *channels,
+ uint32_t *sample_rate,
+ struct audio_stream_out **out);
+#endif
+
+#ifdef QCOM_ICS_LPA_COMPAT
+ /** This method creates and opens the audio hardware output session */
+ int (*open_output_session)(struct audio_hw_device *dev, uint32_t devices,
+ int *format, int sessionId,
+ struct audio_stream_out **out);
+#endif
void (*close_output_stream)(struct audio_hw_device *dev,
struct audio_stream_out* stream_out);
+#ifdef QCOM_HARDWARE
+ /** This method creates and opens the audio hardware output
+ * for broadcast stream */
+ int (*open_broadcast_stream)(struct audio_hw_device *dev, uint32_t devices,
+ int format, uint32_t channels,
+ uint32_t sample_rate,
+ uint32_t audio_source,
+ struct audio_broadcast_stream **out);
+
+ void (*close_broadcast_stream)(struct audio_hw_device *dev,
+ struct audio_broadcast_stream *out);
+#endif
+
/** This method creates and opens the audio hardware input stream */
+#ifndef ICS_AUDIO_BLOB
int (*open_input_stream)(struct audio_hw_device *dev,
audio_io_handle_t handle,
audio_devices_t devices,
struct audio_config *config,
struct audio_stream_in **stream_in);
+#else
+ int (*open_input_stream)(struct audio_hw_device *dev, uint32_t devices,
+ int *format, uint32_t *channels,
+ uint32_t *sample_rate,
+ audio_in_acoustics_t acoustics,
+ struct audio_stream_in **stream_in);
+#endif
void (*close_input_stream)(struct audio_hw_device *dev,
struct audio_stream_in *stream_in);
@@ -416,6 +601,7 @@ struct audio_hw_device {
/** This method dumps the state of the audio hardware */
int (*dump)(const struct audio_hw_device *dev, int fd);
+#ifndef ICS_AUDIO_BLOB
/**
* set the audio mute status for all audio activities. If any value other
* than 0 is returned, the software mixer will emulate this capability.
@@ -430,6 +616,7 @@ struct audio_hw_device {
* method may leave it set to NULL.
*/
int (*get_master_mute)(struct audio_hw_device *dev, bool *mute);
+#endif
};
typedef struct audio_hw_device audio_hw_device_t;
@@ -447,7 +634,26 @@ static inline int audio_hw_device_close(struct audio_hw_device* device)
return device->common.close(&device->common);
}
+#ifdef QCOM_HARDWARE
+/** Structure to save buffer information for applying effects for
+ * LPA buffers */
+struct buf_info {
+ int bufsize;
+ int nBufs;
+ int **buffers;
+};
+#ifdef __cplusplus
+/**
+ *Observer class to post the Events from HAL to Flinger
+*/
+class AudioEventObserver {
+public:
+ virtual ~AudioEventObserver() {}
+ virtual void postEOS(int64_t delayUs) = 0;
+};
+#endif
+#endif
__END_DECLS
#endif // ANDROID_AUDIO_INTERFACE_H