~sergiusens/libhybris/autotests

« back to all changes in this revision

Viewing changes to debian/patches/0010-hardware-include-adding-audio-hal-related-headers-fr.patch

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2013-06-24 23:03:45 UTC
  • Revision ID: package-import@ubuntu.com-20130624230345-6878jmp7is1uywe0
Tags: 0.1.0+git20130606+c5d897a-0ubuntu5
* 0010-hardware-include-adding-audio-hal-related-headers-fr.patch:
  - Updating based on the version set upstream
* Adding 0011-hooks.c-no-need-to-map-strcasestr.patch:
  - Remove hook for strcasesrt, glibc verision behaves differently

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
From: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
2
 
Subject: hardware/include: adding audio hal related headers (from phablet CM 10.1)
 
2
Subject: Adding headers and test to support the Android Audio HAL
3
3
 
4
 
Changing headers to work with path defined by libhybris.
 
4
Headers originally from AOSP 4.2.2_r1.2, changed to have the correct
 
5
include path from other files provided by libhybris.
5
6
 
6
7
Origin: vendor
7
 
Forwarded: no
 
8
Forwarded: yes
8
9
---
9
10
 hybris/include/Makefile.am                     |    6 +
10
11
 hybris/include/android/cutils/bitops.h         |   41 +
11
 
 hybris/include/android/hardware/audio.h        |  659 +++++++++++++++
 
12
 hybris/include/android/hardware/audio.h        |  453 +++++++++++
12
13
 hybris/include/android/hardware/audio_effect.h | 1028 ++++++++++++++++++++++++
13
 
 hybris/include/android/hardware/audio_policy.h |  491 +++++++++++
14
 
 hybris/include/android/system/audio.h          |  693 ++++++++++++++++
15
 
 hybris/include/android/system/audio_policy.h   |  110 +++
 
14
 hybris/include/android/hardware/audio_policy.h |  445 ++++++++++
 
15
 hybris/include/android/system/audio.h          |  518 ++++++++++++
 
16
 hybris/include/android/system/audio_policy.h   |   99 +++
16
17
 hybris/tests/Makefile.am                       |    8 +
17
18
 hybris/tests/test_audio.c                      |   58 ++
18
 
 9 files changed, 3094 insertions(+)
 
19
 9 files changed, 2656 insertions(+)
19
20
 create mode 100644 hybris/include/android/cutils/bitops.h
20
21
 create mode 100644 hybris/include/android/hardware/audio.h
21
22
 create mode 100644 hybris/include/android/hardware/audio_effect.h
25
26
 create mode 100644 hybris/tests/test_audio.c
26
27
 
27
28
diff --git a/hybris/include/Makefile.am b/hybris/include/Makefile.am
28
 
index 4eb2d9d..686df44 100644
 
29
index 5f5ab51..39b2d6a 100644
29
30
--- a/hybris/include/Makefile.am
30
31
+++ b/hybris/include/Makefile.am
31
32
@@ -41,15 +41,21 @@ vginclude_HEADERS = \
99
100
+#endif /* __CUTILS_BITOPS_H */
100
101
diff --git a/hybris/include/android/hardware/audio.h b/hybris/include/android/hardware/audio.h
101
102
new file mode 100644
102
 
index 0000000..fa7e8a7
 
103
index 0000000..b1de42c
103
104
--- /dev/null
104
105
+++ b/hybris/include/android/hardware/audio.h
105
 
@@ -0,0 +1,659 @@
 
106
@@ -0,0 +1,453 @@
106
107
+/*
107
108
+ * Copyright (C) 2011 The Android Open Source Project
108
 
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
109
109
+ *
110
110
+ * Licensed under the Apache License, Version 2.0 (the "License");
111
111
+ * you may not use this file except in compliance with the License.
125
125
+#define ANDROID_AUDIO_HAL_INTERFACE_H
126
126
+
127
127
+#include <stdint.h>
128
 
+#include <string.h>
129
128
+#include <strings.h>
130
129
+#include <sys/cdefs.h>
131
130
+#include <sys/types.h>
161
160
+#define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0)
162
161
+#define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
163
162
+#define AUDIO_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
164
 
+#ifndef ICS_AUDIO_BLOB
165
163
+#define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_2_0
166
 
+#else
167
 
+#define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_1_0
168
 
+#endif
169
164
+
170
165
+/**
171
166
+ * List of known audio HAL modules. This is the base name of the audio HAL
228
223
+ * "sup_sampling_rates=44100|48000" */
229
224
+#define AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates"
230
225
+
231
 
+/* Query handle fm parameter*/
232
 
+#define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm"
233
 
+
234
 
+/* Query voip flag */
235
 
+#define AUDIO_PARAMETER_KEY_VOIP_CHECK "voip_flag"
236
 
+
237
 
+/* Query Fluence type */
238
 
+#define AUDIO_PARAMETER_KEY_FLUENCE_TYPE "fluence"
239
 
+
240
 
+/* Query if surround sound recording is supported */
241
 
+#define AUDIO_PARAMETER_KEY_SSR "ssr"
242
 
+
243
 
+/* Query if a2dp  is supported */
244
 
+#define AUDIO_PARAMETER_KEY_HANDLE_A2DP_DEVICE "isA2dpDeviceSupported"
 
226
+
245
227
+/**************************************/
246
228
+
247
229
+/* common audio stream configuration parameters */
252
234
+};
253
235
+
254
236
+typedef struct audio_config audio_config_t;
255
 
+#ifdef QCOM_HARDWARE
256
 
+typedef struct buf_info;
257
 
+#endif
258
237
+
259
238
+/* common audio stream parameters and operations */
260
239
+struct audio_stream {
379
358
+    int (*get_render_position)(const struct audio_stream_out *stream,
380
359
+                               uint32_t *dsp_frames);
381
360
+
382
 
+#ifdef QCOM_HARDWARE
383
 
+    /**
384
 
+     * start audio data rendering
385
 
+     */
386
 
+    int (*start)(struct audio_stream_out *stream);
387
 
+
388
 
+    /**
389
 
+     * pause audio rendering
390
 
+     */
391
 
+    int (*pause)(struct audio_stream_out *stream);
392
 
+
393
 
+    /**
394
 
+     * flush audio data with driver
395
 
+     */
396
 
+    int (*flush)(struct audio_stream_out *stream);
397
 
+
398
 
+    /**
399
 
+     * stop audio data rendering
400
 
+     */
401
 
+    int (*stop)(struct audio_stream_out *stream);
402
 
+#endif
403
 
+
404
361
+    /**
405
362
+     * get the local time at which the next write to the audio driver will be presented.
406
363
+     * The units are microseconds, where the epoch is decided by the local audio HAL.
407
364
+     */
408
365
+    int (*get_next_write_timestamp)(const struct audio_stream_out *stream,
409
366
+                                    int64_t *timestamp);
410
 
+#ifdef QCOM_HARDWARE
411
 
+    /**
412
 
+    * return the current timestamp after quering to the driver
413
 
+     */
414
 
+    int (*get_time_stamp)(const struct audio_stream_out *stream,
415
 
+                               uint64_t *time_stamp);
416
 
+    /**
417
 
+    * EOS notification from HAL to Player
418
 
+     */
419
 
+    int (*set_observer)(const struct audio_stream_out *stream,
420
 
+                               void *observer);
421
 
+    /**
422
 
+     * Get the physical address of the buffer allocated in the
423
 
+     * driver
424
 
+     */
425
 
+    int (*get_buffer_info) (const struct audio_stream_out *stream,
426
 
+                                struct buf_info **buf);
427
 
+    /**
428
 
+     * Check if next buffer is available. Waits until next buffer is
429
 
+     * available
430
 
+     */
431
 
+    int (*is_buffer_available) (const struct audio_stream_out *stream,
432
 
+                                     int *isAvail);
433
 
+#endif
434
367
+
435
368
+};
436
369
+typedef struct audio_stream_out audio_stream_out_t;
437
370
+
438
 
+#ifdef QCOM_HARDWARE
439
 
+/**
440
 
+ * audio_broadcast_stream is the abstraction interface for the
441
 
+ * audio output hardware.
442
 
+ *
443
 
+ * It provides information about various properties of the audio output
444
 
+ * hardware driver.
445
 
+ */
446
 
+
447
 
+struct audio_broadcast_stream {
448
 
+    struct audio_stream common;
449
 
+
450
 
+    /**
451
 
+     * return the audio hardware driver latency in milli seconds.
452
 
+     */
453
 
+    uint32_t (*get_latency)(const struct audio_broadcast_stream *stream);
454
 
+
455
 
+    /**
456
 
+     * Use this method in situations where audio mixing is done in the
457
 
+     * hardware. This method serves as a direct interface with hardware,
458
 
+     * allowing you to directly set the volume as apposed to via the framework.
459
 
+     * This method might produce multiple PCM outputs or hardware accelerated
460
 
+     * codecs, such as MP3 or AAC.
461
 
+     */
462
 
+    int (*set_volume)(struct audio_broadcast_stream *stream, float left, float right);
463
 
+
464
 
+    int (*mute)(struct audio_broadcast_stream *stream, bool mute);
465
 
+
466
 
+    int (*start)(struct audio_broadcast_stream *stream, int64_t absTimeToStart);
467
 
+    /**
468
 
+     * write audio buffer to driver. Returns number of bytes written
469
 
+     */
470
 
+    ssize_t (*write)(struct audio_broadcast_stream *stream, const void* buffer,
471
 
+                     size_t bytes, int64_t timestamp, int audioType);
472
 
+
473
 
+};
474
 
+typedef struct audio_broadcast_stream audio_broadcast_stream_t;
475
 
+#endif
476
 
+
477
371
+struct audio_stream_in {
478
372
+    struct audio_stream common;
479
373
+
508
402
+static inline size_t audio_stream_frame_size(const struct audio_stream *s)
509
403
+{
510
404
+    size_t chan_samp_sz;
511
 
+    uint32_t chan_mask = s->get_channels(s);
512
 
+    int format = s->get_format(s);
513
 
+
514
 
+#ifdef QCOM_HARDWARE
515
 
+    if (!s)
516
 
+        return 0;
517
 
+
518
 
+    if (audio_is_input_channel(chan_mask)) {
519
 
+        chan_mask &= (AUDIO_CHANNEL_IN_STEREO | \
520
 
+                      AUDIO_CHANNEL_IN_MONO | \
521
 
+                      AUDIO_CHANNEL_IN_5POINT1);
522
 
+    }
523
 
+
524
 
+    if(!strncmp(s->get_parameters(s, "voip_flag"),"voip_flag=1",sizeof("voip_flag=1"))) {
525
 
+        if(format != AUDIO_FORMAT_PCM_8_BIT)
526
 
+            return popcount(chan_mask) * sizeof(int16_t);
527
 
+        else
528
 
+            return popcount(chan_mask) * sizeof(int8_t);
529
 
+    }
530
 
+#endif
531
 
+
532
 
+    switch (format) {
533
 
+#ifdef QCOM_HARDWARE
534
 
+    case AUDIO_FORMAT_AMR_NB:
535
 
+        chan_samp_sz = 32;
536
 
+        break;
537
 
+    case AUDIO_FORMAT_EVRC:
538
 
+        chan_samp_sz = 23;
539
 
+        break;
540
 
+    case AUDIO_FORMAT_QCELP:
541
 
+        chan_samp_sz = 35;
542
 
+        break;
543
 
+#endif
 
405
+
 
406
+    switch (s->get_format(s)) {
544
407
+    case AUDIO_FORMAT_PCM_16_BIT:
545
408
+        chan_samp_sz = sizeof(int16_t);
546
409
+        break;
550
413
+        break;
551
414
+    }
552
415
+
553
 
+    return popcount(chan_mask) * chan_samp_sz;
 
416
+    return popcount(s->get_channels(s)) * chan_samp_sz;
554
417
+}
555
418
+
556
419
+
598
461
+     */
599
462
+    int (*set_master_volume)(struct audio_hw_device *dev, float volume);
600
463
+
601
 
+#ifndef ICS_AUDIO_BLOB
602
464
+    /**
603
465
+     * Get the current master volume value for the HAL, if the HAL supports
604
466
+     * master volume control.  AudioFlinger will query this value from the
607
469
+     * this method may leave it set to NULL.
608
470
+     */
609
471
+    int (*get_master_volume)(struct audio_hw_device *dev, float *volume);
610
 
+#endif
611
 
+
612
 
+#ifdef QCOM_FM_ENABLED
613
 
+    /** set the fm audio volume. Range is between 0.0 and 1.0 */
614
 
+    int (*set_fm_volume)(struct audio_hw_device *dev, float volume);
615
 
+#endif
616
472
+
617
473
+    /**
618
474
+     * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode
640
496
+     * See also get_buffer_size which is for a particular stream.
641
497
+     */
642
498
+    size_t (*get_input_buffer_size)(const struct audio_hw_device *dev,
643
 
+#ifndef ICS_AUDIO_BLOB
644
499
+                                    const struct audio_config *config);
645
 
+#else
646
 
+                                    uint32_t sample_rate, int format,
647
 
+                                    int channel_count);
648
 
+#endif
649
500
+
650
501
+    /** This method creates and opens the audio hardware output stream */
651
 
+#ifndef ICS_AUDIO_BLOB
652
502
+    int (*open_output_stream)(struct audio_hw_device *dev,
653
503
+                              audio_io_handle_t handle,
654
504
+                              audio_devices_t devices,
655
505
+                              audio_output_flags_t flags,
656
506
+                              struct audio_config *config,
657
507
+                              struct audio_stream_out **stream_out);
658
 
+#else
659
 
+    int (*open_output_stream)(struct audio_hw_device *dev, uint32_t devices,
660
 
+                              int *format, uint32_t *channels,
661
 
+                              uint32_t *sample_rate,
662
 
+                              struct audio_stream_out **out);
663
 
+#endif
664
 
+
665
 
+#ifdef QCOM_ICS_LPA_COMPAT
666
 
+    /** This method creates and opens the audio hardware output session */
667
 
+    int (*open_output_session)(struct audio_hw_device *dev, uint32_t devices,
668
 
+                              int *format, int sessionId,
669
 
+                              struct audio_stream_out **out);
670
 
+#endif
671
508
+
672
509
+    void (*close_output_stream)(struct audio_hw_device *dev,
673
510
+                                struct audio_stream_out* stream_out);
674
511
+
675
 
+#ifdef QCOM_HARDWARE
676
 
+    /** This method creates and opens the audio hardware output
677
 
+     *  for broadcast stream */
678
 
+    int (*open_broadcast_stream)(struct audio_hw_device *dev, uint32_t devices,
679
 
+                                 int format, uint32_t channels,
680
 
+                                 uint32_t sample_rate,
681
 
+                                 uint32_t audio_source,
682
 
+                                 struct audio_broadcast_stream **out);
683
 
+
684
 
+    void (*close_broadcast_stream)(struct audio_hw_device *dev,
685
 
+                                   struct audio_broadcast_stream *out);
686
 
+#endif
687
 
+
688
512
+    /** This method creates and opens the audio hardware input stream */
689
 
+#ifndef ICS_AUDIO_BLOB
690
513
+    int (*open_input_stream)(struct audio_hw_device *dev,
691
514
+                             audio_io_handle_t handle,
692
515
+                             audio_devices_t devices,
693
516
+                             struct audio_config *config,
694
517
+                             struct audio_stream_in **stream_in);
695
 
+#else
696
 
+    int (*open_input_stream)(struct audio_hw_device *dev, uint32_t devices,
697
 
+                             int *format, uint32_t *channels,
698
 
+                             uint32_t *sample_rate,
699
 
+                             audio_in_acoustics_t acoustics,
700
 
+                             struct audio_stream_in **stream_in);
701
 
+#endif
702
518
+
703
519
+    void (*close_input_stream)(struct audio_hw_device *dev,
704
520
+                               struct audio_stream_in *stream_in);
706
522
+    /** This method dumps the state of the audio hardware */
707
523
+    int (*dump)(const struct audio_hw_device *dev, int fd);
708
524
+
709
 
+#ifndef ICS_AUDIO_BLOB
710
525
+    /**
711
526
+     * set the audio mute status for all audio activities.  If any value other
712
527
+     * than 0 is returned, the software mixer will emulate this capability.
721
536
+     * method may leave it set to NULL.
722
537
+     */
723
538
+    int (*get_master_mute)(struct audio_hw_device *dev, bool *mute);
724
 
+#endif
725
539
+};
726
540
+typedef struct audio_hw_device audio_hw_device_t;
727
541
+
739
553
+    return device->common.close(&device->common);
740
554
+}
741
555
+
742
 
+#ifdef QCOM_HARDWARE
743
 
+/** Structure to save buffer information for applying effects for
744
 
+ *  LPA buffers */
745
 
+struct buf_info {
746
 
+    int bufsize;
747
 
+    int nBufs;
748
 
+    int **buffers;
749
 
+};
750
556
+
751
 
+#ifdef __cplusplus
752
 
+/**
753
 
+ *Observer class to post the Events from HAL to Flinger
754
 
+*/
755
 
+class AudioEventObserver {
756
 
+public:
757
 
+    virtual ~AudioEventObserver() {}
758
 
+    virtual void postEOS(int64_t delayUs) = 0;
759
 
+};
760
 
+#endif
761
 
+#endif
762
557
+__END_DECLS
763
558
+
764
559
+#endif  // ANDROID_AUDIO_INTERFACE_H
1798
1593
+#endif  // ANDROID_AUDIO_EFFECT_H
1799
1594
diff --git a/hybris/include/android/hardware/audio_policy.h b/hybris/include/android/hardware/audio_policy.h
1800
1595
new file mode 100644
1801
 
index 0000000..5a54014
 
1596
index 0000000..252049a
1802
1597
--- /dev/null
1803
1598
+++ b/hybris/include/android/hardware/audio_policy.h
1804
 
@@ -0,0 +1,491 @@
 
1599
@@ -0,0 +1,445 @@
1805
1600
+/*
1806
1601
+ * Copyright (C) 2011 The Android Open Source Project
1807
 
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
1808
1602
+ *
1809
1603
+ * Licensed under the Apache License, Version 2.0 (the "License");
1810
1604
+ * you may not use this file except in compliance with the License.
1931
1725
+     * Audio routing query functions
1932
1726
+     */
1933
1727
+
1934
 
+#ifdef QCOM_ICS_LPA_COMPAT
1935
 
+    /* request an session appropriate for playback of the supplied stream type and
1936
 
+     * parameters */
1937
 
+    audio_io_handle_t (*get_session)(struct audio_policy *pol,
1938
 
+                                    audio_stream_type_t stream,
1939
 
+                                    uint32_t format,
1940
 
+                                    audio_output_flags_t flags,
1941
 
+                                    int sessionId);
1942
 
+
1943
 
+    /* pause session created for LPA Playback */
1944
 
+    void (*pause_session)(struct audio_policy *pol,
1945
 
+                          audio_io_handle_t output,
1946
 
+                          audio_stream_type_t stream);
1947
 
+
1948
 
+    /* resume session created for LPA Playback */
1949
 
+    void (*resume_session)(struct audio_policy *pol,
1950
 
+                          audio_io_handle_t output,
1951
 
+                          audio_stream_type_t stream);
1952
 
+
1953
 
+    /* release session created for LPA Playback */
1954
 
+    void (*release_session)(struct audio_policy *pol,
1955
 
+                          audio_io_handle_t output);
1956
 
+#endif
1957
 
+
1958
1728
+    /* request an output appropriate for playback of the supplied stream type and
1959
1729
+     * parameters */
1960
1730
+    audio_io_handle_t (*get_output)(struct audio_policy *pol,
2020
1790
+                                   audio_stream_type_t stream,
2021
1791
+                                   int *index);
2022
1792
+
2023
 
+#ifndef ICS_AUDIO_BLOB
2024
1793
+    /* sets the new stream volume at a level corresponding to the supplied
2025
1794
+     * index for the specified device.
2026
1795
+     * The index is within the range specified by init_stream_volume() */
2034
1803
+                                   audio_stream_type_t stream,
2035
1804
+                                   int *index,
2036
1805
+                                   audio_devices_t device);
2037
 
+#endif
2038
1806
+
2039
1807
+    /* return the strategy corresponding to a given stream type */
2040
1808
+    uint32_t (*get_strategy_for_stream)(const struct audio_policy *pol,
2099
1867
+                                     uint32_t *pLatencyMs,
2100
1868
+                                     audio_output_flags_t flags);
2101
1869
+
2102
 
+#ifdef QCOM_ICS_LPA_COMPAT
2103
 
+    audio_io_handle_t (*open_session)(void *service,
2104
 
+                                     uint32_t *pDevices,
2105
 
+                                     uint32_t *pFormat,
2106
 
+                                     audio_output_flags_t flags,
2107
 
+                                     int32_t stream,
2108
 
+                                     int32_t sessionId);
2109
 
+
2110
 
+    audio_io_handle_t (*close_session)(void *service,
2111
 
+                                      audio_io_handle_t output);
2112
 
+#endif
2113
 
+
2114
1870
+    /* creates a special output that is duplicated to the two outputs passed as
2115
1871
+     * arguments. The duplication is performed by
2116
1872
+     * a special mixer thread in the AudioFlinger.
2209
1965
+                        audio_io_handle_t src_output,
2210
1966
+                        audio_io_handle_t dst_output);
2211
1967
+
2212
 
+#ifdef QCOM_FM_ENABLED
2213
 
+    /* set fm audio volume. */
2214
 
+    int (*set_fm_volume)(void *service,
2215
 
+                         float volume,
2216
 
+                         int delay_ms);
2217
 
+#endif
2218
 
+
2219
1968
+    /* loads an audio hw module.
2220
1969
+     *
2221
1970
+     * The module name passed is the base name of the HW module library, e.g "primary" or "a2dp".
2295
2044
+#endif  // ANDROID_AUDIO_POLICY_INTERFACE_H
2296
2045
diff --git a/hybris/include/android/system/audio.h b/hybris/include/android/system/audio.h
2297
2046
new file mode 100644
2298
 
index 0000000..7a22b4e
 
2047
index 0000000..27babce
2299
2048
--- /dev/null
2300
2049
+++ b/hybris/include/android/system/audio.h
2301
 
@@ -0,0 +1,693 @@
 
2050
@@ -0,0 +1,518 @@
2302
2051
+/*
2303
2052
+ * Copyright (C) 2011 The Android Open Source Project
2304
 
+ * Copyright (c) 2012, The Linux Foundation. All rights reserved.
2305
2053
+ *
2306
2054
+ * Licensed under the Apache License, Version 2.0 (the "License");
2307
2055
+ * you may not use this file except in compliance with the License.
2365
2113
+    AUDIO_SOURCE_CAMCORDER           = 5,
2366
2114
+    AUDIO_SOURCE_VOICE_RECOGNITION   = 6,
2367
2115
+    AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
2368
 
+    AUDIO_SOURCE_REMOTE_SUBMIX       = 8, /* Source for the mix to be presented remotely.      */
2369
 
+                                          /* An example of remote presentation is Wifi Display */
2370
 
+                                          /*  where a dongle attached to a TV can be used to   */
2371
 
+                                          /*  play the mix captured by this audio source.      */
 
2116
+
2372
2117
+    AUDIO_SOURCE_CNT,
2373
2118
+    AUDIO_SOURCE_MAX                 = AUDIO_SOURCE_CNT - 1,
2374
2119
+} audio_source_t;
2443
2188
+    AUDIO_FORMAT_HE_AAC_V1           = 0x05000000UL,
2444
2189
+    AUDIO_FORMAT_HE_AAC_V2           = 0x06000000UL,
2445
2190
+    AUDIO_FORMAT_VORBIS              = 0x07000000UL,
2446
 
+#ifdef QCOM_HARDWARE
2447
 
+    AUDIO_FORMAT_EVRC                = 0x08000000UL,
2448
 
+    AUDIO_FORMAT_QCELP               = 0x09000000UL,
2449
 
+    AUDIO_FORMAT_AC3                 = 0x0a000000UL,
2450
 
+    AUDIO_FORMAT_AC3_PLUS            = 0x0b000000UL,
2451
 
+    AUDIO_FORMAT_DTS                 = 0x0c000000UL,
2452
 
+    AUDIO_FORMAT_WMA                 = 0x0d000000UL,
2453
 
+    AUDIO_FORMAT_WMA_PRO             = 0x0e000000UL,
2454
 
+    AUDIO_FORMAT_AAC_ADIF            = 0x0f000000UL,
2455
 
+    AUDIO_FORMAT_EVRCB               = 0x10000000UL,
2456
 
+    AUDIO_FORMAT_EVRCWB              = 0x11000000UL,
2457
 
+    AUDIO_FORMAT_EAC3                = 0x12000000UL,
2458
 
+    AUDIO_FORMAT_DTS_LBR             = 0x13000000UL,
2459
 
+    AUDIO_FORMAT_AMR_WB_PLUS         = 0x14000000UL,
2460
 
+    AUDIO_FORMAT_MP2                 = 0x15000000UL,
2461
 
+#endif
2462
2191
+    AUDIO_FORMAT_MAIN_MASK           = 0xFF000000UL,
2463
2192
+    AUDIO_FORMAT_SUB_MASK            = 0x00FFFFFFUL,
2464
2193
+
2473
2202
+                                        AUDIO_FORMAT_PCM_SUB_8_24_BIT),
2474
2203
+} audio_format_t;
2475
2204
+
2476
 
+enum {
 
2205
+typedef enum {
2477
2206
+    /* output channels */
2478
2207
+    AUDIO_CHANNEL_OUT_FRONT_LEFT            = 0x1,
2479
2208
+    AUDIO_CHANNEL_OUT_FRONT_RIGHT           = 0x2,
2497
2226
+    AUDIO_CHANNEL_OUT_MONO     = AUDIO_CHANNEL_OUT_FRONT_LEFT,
2498
2227
+    AUDIO_CHANNEL_OUT_STEREO   = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
2499
2228
+                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT),
2500
 
+#ifdef QCOM_HARDWARE
2501
 
+    AUDIO_CHANNEL_OUT_2POINT1  = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
2502
 
+                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
2503
 
+                                  AUDIO_CHANNEL_OUT_FRONT_CENTER),
2504
 
+#endif
2505
2229
+    AUDIO_CHANNEL_OUT_QUAD     = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
2506
2230
+                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
2507
2231
+                                  AUDIO_CHANNEL_OUT_BACK_LEFT |
2510
2234
+                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
2511
2235
+                                  AUDIO_CHANNEL_OUT_FRONT_CENTER |
2512
2236
+                                  AUDIO_CHANNEL_OUT_BACK_CENTER),
2513
 
+#ifdef QCOM_HARDWARE
2514
 
+    AUDIO_CHANNEL_OUT_PENTA =    (AUDIO_CHANNEL_OUT_QUAD |
2515
 
+                                  AUDIO_CHANNEL_OUT_FRONT_CENTER),
2516
 
+#endif
2517
2237
+    AUDIO_CHANNEL_OUT_5POINT1  = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
2518
2238
+                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
2519
2239
+                                  AUDIO_CHANNEL_OUT_FRONT_CENTER |
2520
2240
+                                  AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
2521
2241
+                                  AUDIO_CHANNEL_OUT_BACK_LEFT |
2522
2242
+                                  AUDIO_CHANNEL_OUT_BACK_RIGHT),
2523
 
+#ifdef QCOM_HARDWARE
2524
 
+    AUDIO_CHANNEL_OUT_6POINT1  = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
2525
 
+                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
2526
 
+                                  AUDIO_CHANNEL_OUT_FRONT_CENTER |
2527
 
+                                  AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
2528
 
+                                  AUDIO_CHANNEL_OUT_BACK_LEFT |
2529
 
+                                  AUDIO_CHANNEL_OUT_BACK_RIGHT |
2530
 
+                                  AUDIO_CHANNEL_OUT_BACK_CENTER),
2531
 
+#endif
2532
2243
+    // matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND definition for 7.1
2533
2244
+    AUDIO_CHANNEL_OUT_7POINT1  = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
2534
2245
+                                  AUDIO_CHANNEL_OUT_FRONT_RIGHT |
2572
2283
+    AUDIO_CHANNEL_IN_Z_AXIS          = 0x2000,
2573
2284
+    AUDIO_CHANNEL_IN_VOICE_UPLINK    = 0x4000,
2574
2285
+    AUDIO_CHANNEL_IN_VOICE_DNLINK    = 0x8000,
2575
 
+#ifdef QCOM_HARDWARE
2576
 
+    AUDIO_CHANNEL_IN_FRONT_LEFT      = 0x10000,
2577
 
+    AUDIO_CHANNEL_IN_FRONT_RIGHT     = 0x20000,
2578
 
+    AUDIO_CHANNEL_IN_FRONT_CENTER    = 0x40000,
2579
 
+    AUDIO_CHANNEL_IN_LOW_FREQUENCY   = 0x80000,
2580
 
+    AUDIO_CHANNEL_IN_BACK_LEFT       = 0x100000,
2581
 
+    AUDIO_CHANNEL_IN_BACK_RIGHT      = 0x200000,
2582
 
+#endif
2583
2286
+
2584
2287
+    AUDIO_CHANNEL_IN_MONO   = AUDIO_CHANNEL_IN_FRONT,
2585
2288
+    AUDIO_CHANNEL_IN_STEREO = (AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT),
2586
 
+#ifdef QCOM_HARDWARE
2587
 
+    AUDIO_CHANNEL_IN_5POINT1 = (AUDIO_CHANNEL_IN_FRONT_LEFT |
2588
 
+                               AUDIO_CHANNEL_IN_FRONT_RIGHT |
2589
 
+                               AUDIO_CHANNEL_IN_FRONT_CENTER |
2590
 
+                               AUDIO_CHANNEL_IN_LOW_FREQUENCY |
2591
 
+                               AUDIO_CHANNEL_IN_BACK_LEFT |
2592
 
+                               AUDIO_CHANNEL_IN_BACK_RIGHT),
2593
 
+    AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO = (AUDIO_CHANNEL_IN_VOICE_UPLINK | AUDIO_CHANNEL_IN_MONO),
2594
 
+    AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO = (AUDIO_CHANNEL_IN_VOICE_DNLINK | AUDIO_CHANNEL_IN_MONO),
2595
 
+    AUDIO_CHANNEL_IN_VOICE_CALL_MONO   = (AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO | AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO),
2596
 
+#endif
2597
2289
+    AUDIO_CHANNEL_IN_ALL    = (AUDIO_CHANNEL_IN_LEFT |
2598
2290
+                               AUDIO_CHANNEL_IN_RIGHT |
2599
2291
+                               AUDIO_CHANNEL_IN_FRONT |
2606
2298
+                               AUDIO_CHANNEL_IN_X_AXIS |
2607
2299
+                               AUDIO_CHANNEL_IN_Y_AXIS |
2608
2300
+                               AUDIO_CHANNEL_IN_Z_AXIS |
2609
 
+#ifdef QCOM_HARDWARE
2610
 
+                               AUDIO_CHANNEL_IN_5POINT1 |
2611
 
+#endif
2612
2301
+                               AUDIO_CHANNEL_IN_VOICE_UPLINK |
2613
 
+                               AUDIO_CHANNEL_IN_VOICE_DNLINK)
 
2302
+                               AUDIO_CHANNEL_IN_VOICE_DNLINK),
2614
2303
+};
2615
2304
+
2616
2305
+typedef uint32_t audio_channel_mask_t;
2636
2325
+    AUDIO_IN_ACOUSTICS_TX_DISABLE    = 0,
2637
2326
+} audio_in_acoustics_t;
2638
2327
+
2639
 
+enum {
2640
 
+    AUDIO_DEVICE_NONE                          = 0x0,
2641
 
+    /* reserved bits */
2642
 
+#if defined(ICS_AUDIO_BLOB) || defined(MR0_AUDIO_BLOB)
2643
 
+    AUDIO_DEVICE_BIT_IN                        = 0x10000,
2644
 
+#else
2645
 
+    AUDIO_DEVICE_BIT_IN                        = 0x80000000,
2646
 
+#endif
2647
 
+    AUDIO_DEVICE_BIT_DEFAULT                   = 0x40000000,
 
2328
+typedef enum {
2648
2329
+    /* output devices */
2649
2330
+    AUDIO_DEVICE_OUT_EARPIECE                  = 0x1,
2650
2331
+    AUDIO_DEVICE_OUT_SPEAKER                   = 0x2,
2661
2342
+    AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET         = 0x1000,
2662
2343
+    AUDIO_DEVICE_OUT_USB_ACCESSORY             = 0x2000,
2663
2344
+    AUDIO_DEVICE_OUT_USB_DEVICE                = 0x4000,
2664
 
+    AUDIO_DEVICE_OUT_REMOTE_SUBMIX             = 0x8000,
2665
 
+#ifdef QCOM_HARDWARE
2666
 
+    AUDIO_DEVICE_OUT_ANC_HEADSET               = 0x10000,
2667
 
+    AUDIO_DEVICE_OUT_ANC_HEADPHONE             = 0x20000,
2668
 
+    AUDIO_DEVICE_OUT_PROXY                     = 0x40000,
2669
 
+    AUDIO_DEVICE_OUT_FM                        = 0x80000,
2670
 
+    AUDIO_DEVICE_OUT_FM_TX                     = 0x100000,
2671
 
+#endif
2672
 
+    AUDIO_DEVICE_OUT_DEFAULT                   = AUDIO_DEVICE_BIT_DEFAULT,
 
2345
+    AUDIO_DEVICE_OUT_DEFAULT                   = 0x8000,
2673
2346
+    AUDIO_DEVICE_OUT_ALL      = (AUDIO_DEVICE_OUT_EARPIECE |
2674
2347
+                                 AUDIO_DEVICE_OUT_SPEAKER |
2675
2348
+                                 AUDIO_DEVICE_OUT_WIRED_HEADSET |
2685
2358
+                                 AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET |
2686
2359
+                                 AUDIO_DEVICE_OUT_USB_ACCESSORY |
2687
2360
+                                 AUDIO_DEVICE_OUT_USB_DEVICE |
2688
 
+                                 AUDIO_DEVICE_OUT_REMOTE_SUBMIX |
2689
 
+#ifdef QCOM_HARDWARE
2690
 
+                                 AUDIO_DEVICE_OUT_ANC_HEADSET |
2691
 
+                                 AUDIO_DEVICE_OUT_ANC_HEADPHONE |
2692
 
+                                 AUDIO_DEVICE_OUT_PROXY |
2693
 
+                                 AUDIO_DEVICE_OUT_FM |
2694
 
+                                 AUDIO_DEVICE_OUT_FM_TX |
2695
 
+#endif
2696
2361
+                                 AUDIO_DEVICE_OUT_DEFAULT),
2697
2362
+    AUDIO_DEVICE_OUT_ALL_A2DP = (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
2698
2363
+                                 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
2704
2369
+                                 AUDIO_DEVICE_OUT_USB_DEVICE),
2705
2370
+
2706
2371
+    /* input devices */
2707
 
+#if defined(ICS_AUDIO_BLOB) || defined(MR0_AUDIO_BLOB)
2708
 
+    AUDIO_DEVICE_IN_COMMUNICATION         = AUDIO_DEVICE_BIT_IN * 0x1,
2709
 
+    AUDIO_DEVICE_IN_AMBIENT               = AUDIO_DEVICE_BIT_IN * 0x2,
2710
 
+    AUDIO_DEVICE_IN_BUILTIN_MIC           = AUDIO_DEVICE_BIT_IN * 0x4,
2711
 
+    AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = AUDIO_DEVICE_BIT_IN * 0x8,
2712
 
+    AUDIO_DEVICE_IN_WIRED_HEADSET         = AUDIO_DEVICE_BIT_IN * 0x10,
2713
 
+    AUDIO_DEVICE_IN_AUX_DIGITAL           = AUDIO_DEVICE_BIT_IN * 0x20,
2714
 
+    AUDIO_DEVICE_IN_VOICE_CALL            = AUDIO_DEVICE_BIT_IN * 0x40,
2715
 
+    AUDIO_DEVICE_IN_BACK_MIC              = AUDIO_DEVICE_BIT_IN * 0x80,
2716
 
+    AUDIO_DEVICE_IN_REMOTE_SUBMIX         = AUDIO_DEVICE_BIT_IN * 0x100,
2717
 
+    AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET     = AUDIO_DEVICE_BIT_IN * 0x200,
2718
 
+    AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET     = AUDIO_DEVICE_BIT_IN * 0x400,
2719
 
+    AUDIO_DEVICE_IN_USB_ACCESSORY         = AUDIO_DEVICE_BIT_IN * 0x800,
2720
 
+    AUDIO_DEVICE_IN_USB_DEVICE            = AUDIO_DEVICE_BIT_IN * 0x1000,
2721
 
+    AUDIO_DEVICE_IN_DEFAULT               = AUDIO_DEVICE_IN_BUILTIN_MIC,
2722
 
+#else
2723
 
+    AUDIO_DEVICE_IN_COMMUNICATION         = AUDIO_DEVICE_BIT_IN | 0x1,
2724
 
+    AUDIO_DEVICE_IN_AMBIENT               = AUDIO_DEVICE_BIT_IN | 0x2,
2725
 
+    AUDIO_DEVICE_IN_BUILTIN_MIC           = AUDIO_DEVICE_BIT_IN | 0x4,
2726
 
+    AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = AUDIO_DEVICE_BIT_IN | 0x8,
2727
 
+    AUDIO_DEVICE_IN_WIRED_HEADSET         = AUDIO_DEVICE_BIT_IN | 0x10,
2728
 
+    AUDIO_DEVICE_IN_AUX_DIGITAL           = AUDIO_DEVICE_BIT_IN | 0x20,
2729
 
+    AUDIO_DEVICE_IN_VOICE_CALL            = AUDIO_DEVICE_BIT_IN | 0x40,
2730
 
+    AUDIO_DEVICE_IN_BACK_MIC              = AUDIO_DEVICE_BIT_IN | 0x80,
2731
 
+    AUDIO_DEVICE_IN_REMOTE_SUBMIX         = AUDIO_DEVICE_BIT_IN | 0x100,
2732
 
+    AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET     = AUDIO_DEVICE_BIT_IN | 0x200,
2733
 
+    AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET     = AUDIO_DEVICE_BIT_IN | 0x400,
2734
 
+    AUDIO_DEVICE_IN_USB_ACCESSORY         = AUDIO_DEVICE_BIT_IN | 0x800,
2735
 
+    AUDIO_DEVICE_IN_USB_DEVICE            = AUDIO_DEVICE_BIT_IN | 0x1000,
2736
 
+#ifdef QCOM_HARDWARE
2737
 
+    AUDIO_DEVICE_IN_ANC_HEADSET           = AUDIO_DEVICE_BIT_IN | 0x2000,
2738
 
+    AUDIO_DEVICE_IN_PROXY                 = AUDIO_DEVICE_BIT_IN | 0x4000,
2739
 
+    AUDIO_DEVICE_IN_FM_RX                 = AUDIO_DEVICE_BIT_IN | 0x8000,
2740
 
+    AUDIO_DEVICE_IN_FM_RX_A2DP            = AUDIO_DEVICE_BIT_IN | 0x10000,
2741
 
+#endif
2742
 
+    AUDIO_DEVICE_IN_DEFAULT               = AUDIO_DEVICE_BIT_IN | AUDIO_DEVICE_BIT_DEFAULT,
2743
 
+#endif
 
2372
+    AUDIO_DEVICE_IN_COMMUNICATION         = 0x10000,
 
2373
+    AUDIO_DEVICE_IN_AMBIENT               = 0x20000,
 
2374
+    AUDIO_DEVICE_IN_BUILTIN_MIC           = 0x40000,
 
2375
+    AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000,
 
2376
+    AUDIO_DEVICE_IN_WIRED_HEADSET         = 0x100000,
 
2377
+    AUDIO_DEVICE_IN_AUX_DIGITAL           = 0x200000,
 
2378
+    AUDIO_DEVICE_IN_VOICE_CALL            = 0x400000,
 
2379
+    AUDIO_DEVICE_IN_BACK_MIC              = 0x800000,
 
2380
+    AUDIO_DEVICE_IN_DEFAULT               = 0x80000000,
2744
2381
+
2745
2382
+    AUDIO_DEVICE_IN_ALL     = (AUDIO_DEVICE_IN_COMMUNICATION |
2746
2383
+                               AUDIO_DEVICE_IN_AMBIENT |
2750
2387
+                               AUDIO_DEVICE_IN_AUX_DIGITAL |
2751
2388
+                               AUDIO_DEVICE_IN_VOICE_CALL |
2752
2389
+                               AUDIO_DEVICE_IN_BACK_MIC |
2753
 
+                               AUDIO_DEVICE_IN_REMOTE_SUBMIX |
2754
 
+                               AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET |
2755
 
+                               AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET |
2756
 
+                               AUDIO_DEVICE_IN_USB_ACCESSORY |
2757
 
+                               AUDIO_DEVICE_IN_USB_DEVICE |
2758
 
+#ifdef QCOM_HARDWARE
2759
 
+                               AUDIO_DEVICE_IN_ANC_HEADSET |
2760
 
+                               AUDIO_DEVICE_IN_FM_RX |
2761
 
+                               AUDIO_DEVICE_IN_FM_RX_A2DP |
2762
 
+                               AUDIO_DEVICE_IN_PROXY |
2763
 
+#endif
2764
2390
+                               AUDIO_DEVICE_IN_DEFAULT),
2765
2391
+    AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
2766
 
+};
2767
 
+
2768
 
+typedef uint32_t audio_devices_t;
 
2392
+} audio_devices_t;
2769
2393
+
2770
2394
+/* the audio output flags serve two purposes:
2771
2395
+ * - when an AudioTrack is created they indicate a "wish" to be connected to an
2787
2411
+                                        // controls related to voice calls.
2788
2412
+    AUDIO_OUTPUT_FLAG_FAST = 0x4,       // output supports "fast tracks",
2789
2413
+                                        // defined elsewhere
2790
 
+    AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8,// use deep audio buffers
2791
 
+#ifdef QCOM_HARDWARE
2792
 
+    //Qualcomm Flags
2793
 
+    AUDIO_OUTPUT_FLAG_LPA = 0x1000,      // use LPA
2794
 
+    AUDIO_OUTPUT_FLAG_TUNNEL = 0x2000,   // use Tunnel
2795
 
+    AUDIO_OUTPUT_FLAG_VOIP_RX = 0x4000   // use this flag in combination with DIRECT to
2796
 
+                                         // indicate HAL to activate EC & NS
2797
 
+                                         // path for VOIP calls
2798
 
+#endif
 
2414
+    AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8 // use deep audio buffers
2799
2415
+} audio_output_flags_t;
2800
2416
+
2801
2417
+static inline bool audio_is_output_device(audio_devices_t device)
2802
2418
+{
2803
 
+    if (((device & AUDIO_DEVICE_BIT_IN) == 0) &&
2804
 
+            (popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0))
 
2419
+    if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0))
2805
2420
+        return true;
2806
2421
+    else
2807
2422
+        return false;
2809
2424
+
2810
2425
+static inline bool audio_is_input_device(audio_devices_t device)
2811
2426
+{
2812
 
+    if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
2813
 
+        device &= ~AUDIO_DEVICE_BIT_IN;
2814
 
+        if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0))
2815
 
+            return true;
2816
 
+    }
2817
 
+    return false;
2818
 
+}
2819
 
+
2820
 
+static inline bool audio_is_output_devices(audio_devices_t device)
2821
 
+{
2822
 
+    return (device & AUDIO_DEVICE_BIT_IN) == 0;
2823
 
+}
2824
 
+
 
2427
+    if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0))
 
2428
+        return true;
 
2429
+    else
 
2430
+        return false;
 
2431
+}
2825
2432
+
2826
2433
+static inline bool audio_is_a2dp_device(audio_devices_t device)
2827
2434
+{
2833
2440
+
2834
2441
+static inline bool audio_is_bluetooth_sco_device(audio_devices_t device)
2835
2442
+{
2836
 
+    device &= ~AUDIO_DEVICE_BIT_IN;
2837
2443
+    if ((popcount(device) == 1) && (device & (AUDIO_DEVICE_OUT_ALL_SCO |
2838
2444
+                   AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET)))
2839
2445
+        return true;
2849
2455
+        return false;
2850
2456
+}
2851
2457
+
2852
 
+static inline bool audio_is_remote_submix_device(audio_devices_t device)
2853
 
+{
2854
 
+    if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX))
2855
 
+        return true;
2856
 
+    else
2857
 
+        return false;
2858
 
+}
2859
 
+
2860
2458
+static inline bool audio_is_input_channel(uint32_t channel)
2861
2459
+{
2862
2460
+    if ((channel & ~AUDIO_CHANNEL_IN_ALL) == 0)
2905
2503
+    }
2906
2504
+}
2907
2505
+
2908
 
+/* Similar to above, but for input.  Currently handles mono and stereo and 5.1 input. */
 
2506
+/* Similar to above, but for input.  Currently handles only mono and stereo. */
2909
2507
+static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count)
2910
2508
+{
2911
2509
+    switch (channel_count) {
2913
2511
+        return AUDIO_CHANNEL_IN_MONO;
2914
2512
+    case 2:
2915
2513
+        return AUDIO_CHANNEL_IN_STEREO;
2916
 
+#ifdef QCOM_HARDWARE
2917
 
+    case 6:
2918
 
+        return AUDIO_CHANNEL_IN_5POINT1;
2919
 
+#endif
2920
2514
+    default:
2921
2515
+        return 0;
2922
2516
+    }
2937
2531
+    case AUDIO_FORMAT_HE_AAC_V1:
2938
2532
+    case AUDIO_FORMAT_HE_AAC_V2:
2939
2533
+    case AUDIO_FORMAT_VORBIS:
2940
 
+#ifdef QCOM_HARDWARE
2941
 
+    case AUDIO_FORMAT_QCELP:
2942
 
+    case AUDIO_FORMAT_EVRC:
2943
 
+    case AUDIO_FORMAT_EVRCB:
2944
 
+    case AUDIO_FORMAT_EVRCWB:
2945
 
+    case AUDIO_FORMAT_AC3:
2946
 
+    case AUDIO_FORMAT_EAC3:
2947
 
+    case AUDIO_FORMAT_AAC_ADIF:
2948
 
+    case AUDIO_FORMAT_WMA:
2949
 
+    case AUDIO_FORMAT_WMA_PRO:
2950
 
+    case AUDIO_FORMAT_DTS:
2951
 
+    case AUDIO_FORMAT_DTS_LBR:
2952
 
+    case AUDIO_FORMAT_AMR_WB_PLUS:
2953
 
+    case AUDIO_FORMAT_MP2:
2954
 
+#endif
2955
2534
+        return true;
2956
2535
+    default:
2957
2536
+        return false;
2978
2557
+    case AUDIO_FORMAT_PCM_8_BIT:
2979
2558
+        size = sizeof(uint8_t);
2980
2559
+        break;
2981
 
+#ifdef QCOM_HARDWARE
2982
 
+    case AUDIO_FORMAT_AMR_WB:
2983
 
+        size = 61;
2984
 
+        break;
2985
 
+#endif
2986
2560
+    default:
2987
2561
+        break;
2988
2562
+    }
2994
2568
+#endif  // ANDROID_AUDIO_CORE_H
2995
2569
diff --git a/hybris/include/android/system/audio_policy.h b/hybris/include/android/system/audio_policy.h
2996
2570
new file mode 100644
2997
 
index 0000000..feb1676
 
2571
index 0000000..a91b944
2998
2572
--- /dev/null
2999
2573
+++ b/hybris/include/android/system/audio_policy.h
3000
 
@@ -0,0 +1,110 @@
 
2574
@@ -0,0 +1,99 @@
3001
2575
+/*
3002
2576
+ * Copyright (C) 2011 The Android Open Source Project
3003
2577
+ *
3029
2603
+/* The enums were moved here mostly from
3030
2604
+ * frameworks/base/include/media/AudioSystem.h
3031
2605
+ */
3032
 
+#ifdef QCOM_HARDWARE
3033
 
+/* request to open a direct output with get_output() (by opposition to
3034
 
+ * sharing an output with other AudioTracks)
3035
 
+ */
3036
 
+typedef enum {
3037
 
+    AUDIO_POLICY_OUTPUT_FLAG_INDIRECT = 0x0,
3038
 
+    AUDIO_POLICY_OUTPUT_FLAG_DIRECT = 0x1
3039
 
+} audio_policy_output_flags_t;
3040
 
+#endif
3041
2606
+
3042
2607
+/* device categories used for audio_policy->set_force_use() */
3043
2608
+typedef enum {
3052
2617
+    AUDIO_POLICY_FORCE_ANALOG_DOCK,
3053
2618
+    AUDIO_POLICY_FORCE_DIGITAL_DOCK,
3054
2619
+    AUDIO_POLICY_FORCE_NO_BT_A2DP, /* A2DP sink is not preferred to speaker or wired HS */
3055
 
+    AUDIO_POLICY_FORCE_SYSTEM_ENFORCED,
3056
2620
+
3057
2621
+    AUDIO_POLICY_FORCE_CFG_CNT,
3058
2622
+    AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1,
3066
2630
+    AUDIO_POLICY_FORCE_FOR_MEDIA,
3067
2631
+    AUDIO_POLICY_FORCE_FOR_RECORD,
3068
2632
+    AUDIO_POLICY_FORCE_FOR_DOCK,
3069
 
+    AUDIO_POLICY_FORCE_FOR_SYSTEM,
3070
2633
+
3071
2634
+    AUDIO_POLICY_FORCE_USE_CNT,
3072
2635
+    AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1,
3109
2672
+
3110
2673
+#endif  // ANDROID_AUDIO_POLICY_CORE_H
3111
2674
diff --git a/hybris/tests/Makefile.am b/hybris/tests/Makefile.am
3112
 
index 88904db..08db229 100644
 
2675
index e4f3dce..cb30e8c 100644
3113
2676
--- a/hybris/tests/Makefile.am
3114
2677
+++ b/hybris/tests/Makefile.am
3115
2678
@@ -1,4 +1,5 @@
3118
2681
        test_egl \
3119
2682
        test_glesv2 \
3120
2683
        test_sensors \
3121
 
@@ -11,6 +12,13 @@ bin_PROGRAMS = \
 
2684
@@ -11,6 +12,13 @@
3122
2685
        test_recorder \
3123
2686
        test_gps
3124
2687