audio: hal: Add Hal extension for transcode loopback usecase

Adding HAL extension for transcode hw loopback
Userspace qahwi APIs introduced to exercise this extension

Change-Id: Iffae3f6936c2519f0c5349c2430eb598b97c3364
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 3980ab6..20edc99 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -81,6 +81,12 @@
 #define DEFAULT_HDMI_OUT_SAMPLE_RATE 48000
 #define DEFAULT_HDMI_OUT_FORMAT AUDIO_FORMAT_PCM_16_BIT
 
+#define SND_CARD_STATE_OFFLINE 0
+#define SND_CARD_STATE_ONLINE 1
+
+#define STREAM_DIRECTION_IN 0
+#define STREAM_DIRECTION_OUT 1
+
 #define MAX_PERF_LOCK_OPTS 20
 
 #define MAX_STREAM_PROFILE_STR_LEN 32
@@ -157,6 +163,7 @@
 
     USECASE_AUDIO_PLAYBACK_EXT_DISP_SILENCE,
 
+    USECASE_AUDIO_TRANSCODE_LOOPBACK,
     AUDIO_USECASE_MAX
 };
 
@@ -204,6 +211,20 @@
     int app_type;
 };
 
+struct stream_config {
+    unsigned int sample_rate;
+    audio_channel_mask_t channel_mask;
+    audio_format_t format;
+    audio_devices_t devices;
+    unsigned int bit_width;
+};
+struct stream_inout {
+    pthread_mutex_t lock; /* see note below on mutex acquisition order */
+    pthread_mutex_t pre_lock; /* acquire before lock to avoid DOS by playback thread */
+    pthread_cond_t  cond;
+    struct stream_config in_config;
+    struct stream_config out_config;
+};
 struct stream_out {
     struct audio_stream_out stream;
     pthread_mutex_t lock; /* see note below on mutex acquisition order */
@@ -310,12 +331,14 @@
     PCM_CAPTURE,
     VOICE_CALL,
     VOIP_CALL,
-    PCM_HFP_CALL
+    PCM_HFP_CALL,
+    TRANSCODE_LOOPBACK
 } usecase_type_t;
 
 union stream_ptr {
     struct stream_in *in;
     struct stream_out *out;
+    struct stream_inout *inout;
 };
 
 struct audio_usecase {