hal: Fix pulseaudio build error

Add undefined attribute to fix pulseaudio build error.

Change-Id: Ia289a7d626aff4dcd230187f8a5663b95846473b
diff --git a/hal/audio_extn/audio_defs.h b/hal/audio_extn/audio_defs.h
index d8d1bbb..3ed869b 100644
--- a/hal/audio_extn/audio_defs.h
+++ b/hal/audio_extn/audio_defs.h
@@ -212,6 +212,15 @@
                                                  */
 } audio_extn_callback_id;
 
+typedef int audio_stream_callback_t(audio_extn_callback_id event,
+                                    void *param,
+                                    void *cookie);
+
+struct audio_stream_callback_param {
+    audio_stream_callback_t *cb;    /* callback function */
+    void *cookie;                   /* callback context */
+};
+
 #define AUDIO_MAX_ADSP_STREAM_CMD_PAYLOAD_LEN 504
 
 typedef enum {
@@ -317,6 +326,7 @@
 
 typedef union {
     struct audio_out_render_window_param render_window_params;
+    struct audio_stream_callback_param stream_callback_params;
 } audio_extn_loopback_param_payload;
 
 typedef enum {
diff --git a/qahw/inc/qahw.h b/qahw/inc/qahw.h
index dd920e2..0950c92 100644
--- a/qahw/inc/qahw.h
+++ b/qahw/inc/qahw.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2011 The Android Open Source Project *
@@ -364,6 +364,12 @@
  * Stop input stream. Returns zero on success.
  */
 int qahw_in_stop_l(qahw_stream_handle_t *in_handle);
+
+/* API to set capture stream specific config parameters */
+int qahw_in_set_param_data_l(qahw_stream_handle_t *in_handle,
+                            qahw_param_id param_id,
+                            qahw_param_payload *payload);
+
 /*
  * Return the amount of input frames lost in the audio driver since the
  * last call of this function.
@@ -467,6 +473,11 @@
                         const struct audio_port_config *sinks,
                         audio_patch_handle_t *handle);
 
+int qahw_create_audio_patch_v2_l(qahw_module_handle_t *hw_module,
+                        qahw_source_port_config_t *source_port_config,
+                        qahw_sink_port_config_t *sink_port_config,
+                        audio_patch_handle_t *handle);
+
 /* Release an audio patch */
 int qahw_release_audio_patch_l(qahw_module_handle_t *hw_module,
                         audio_patch_handle_t handle);
diff --git a/qahw/inc/qahw_defs.h b/qahw/inc/qahw_defs.h
index b0eb332..b7bbaa5 100644
--- a/qahw/inc/qahw_defs.h
+++ b/qahw/inc/qahw_defs.h
@@ -176,6 +176,9 @@
 #define QAHW_AUDIO_FLAG_HPCM_TX 0x00020000
 #define QAHW_AUDIO_FLAG_HPCM_RX 0x00040000
 
+/* audio output flag for timestamp mode */
+#define QAHW_OUTPUT_FLAG_TIMESTAMP 0x20000000
+
 /* Query fm volume */
 #define QAHW_PARAMETER_KEY_FM_VOLUME "fm_volume"
 
@@ -223,6 +226,13 @@
 
 #define QAHW_AUDIO_DEVICE_OUT_SPEAKER2 0x10000000
 #define QAHW_AUDIO_DEVICE_OUT_SPEAKER3 0x20000000
+#define QAHW_AUDIO_DEVICE_OUT_OPTICAL 0x40000
+
+#define QAHW_PCM_CUSTOM_CHANNEL_MAP_12  59
+#define QAHW_PCM_CUSTOM_CHANNEL_MAP_13  60
+#define QAHW_PCM_CUSTOM_CHANNEL_MAP_14  61
+#define QAHW_PCM_CUSTOM_CHANNEL_MAP_15  62
+#define QAHW_PCM_CUSTOM_CHANNEL_MAP_16  63
 
 /* type of asynchronous write callback events. Mutually exclusive */
 typedef enum {
@@ -240,6 +250,11 @@
                                    void *param,
                                    void *cookie);
 
+struct qahw_stream_callback_param {
+    qahw_stream_callback_t *cb;    /* callback function */
+    void *cookie;                  /* callback context */
+};
+
 /* type of drain requested to audio_stream_out->drain(). Mutually exclusive */
 typedef enum {
     QAHW_DRAIN_ALL,            /* drain() returns when all data has been played */
@@ -252,6 +267,8 @@
 /*TBD: Extend this based on stb requirement*/
 typedef enum {
  QAHW_META_DATA_FLAGS_NONE = 0,
+ QAHW_META_DATA_FLAGS_TIMESTAMP_VALID,
+ QAHW_META_DATA_FLAGS_TIMESTAMP_CONTINUE,
 } qahw_meta_data_flags_t;
 
 typedef struct {
@@ -358,6 +375,7 @@
 typedef enum {
     QAHW_STREAM_PP_EVENT = 0,
     QAHW_STREAM_ENCDEC_EVENT = 1,
+    QAHW_STREAM_IEC_61937_FMT_UPDATE_EVENT = 2,
 } qahw_event_id;
 
 /* payload format for HAL parameter
@@ -369,6 +387,11 @@
     void *payload;                 /* the actual payload */
 };
 
+struct qahw_in_channel_map_param {
+   uint8_t       channels;                               /* Input Channels */
+   uint8_t       channel_map[AUDIO_CHANNEL_COUNT_MAX];   /* Input Channel Map */
+};
+
 struct qahw_out_channel_map_param {
    uint8_t       channels;                               /* Input Channels */
    uint8_t       channel_map[AUDIO_CHANNEL_COUNT_MAX];   /* Input Channel Map */
@@ -439,6 +462,21 @@
    qahw_hpcm_direction direction;
 } qahw_hpcm_params_t;
 
+struct qahw_in_ttp_offset_param {
+   uint64_t        ttp_offset; /* TTP value is derived from ttp offset*/
+};
+
+struct qahw_out_channel_status_info {
+    /* Channel status is 192 bits each for CH A and CH B*/
+    char channel_status[48];
+};
+
+struct qahw_device_channel_bit_mask {
+    audio_devices_t device;
+    /* Channel status bit mask is 192 bits each for CH A and CH B*/
+    char bit_mask[48];
+};
+
 typedef union {
     struct qahw_source_tracking_param st_params;
     struct qahw_sound_focus_param sf_params;
@@ -449,6 +487,7 @@
     struct qahw_out_enable_drift_correction drift_enable_param;
     struct qahw_out_correct_drift drift_correction_param;
     struct qahw_adsp_event adsp_event_params;
+	struct qahw_in_channel_map_param in_channel_map_params;
     struct qahw_out_channel_map_param channel_map_params;
     struct qahw_device_cfg_param device_cfg_params;
     struct qahw_mix_matrix_params mix_matrix_params;
@@ -457,6 +496,9 @@
     struct qahw_dtmf_gen_params dtmf_gen_params;
     struct qahw_tty_params tty_mode_params;
     struct qahw_hpcm_params hpcm_params;
+	struct qahw_in_ttp_offset_param ttp_offset;
+	struct qahw_out_channel_status_info ch_status_info;
+	struct qahw_device_channel_bit_mask ch_bit_mask;
 } qahw_param_payload;
 
 typedef enum {
@@ -480,16 +522,34 @@
     QAHW_PARAM_DTMF_GEN,
     QAHW_PARAM_TTY_MODE,
     QAHW_PARAM_HPCM,
+	QAHW_PARAM_IN_TTP_OFFSET,
+	QAHW_PARAM_IN_CHANNEL_MAP,     /* PARAM to set i/p channel map */
+	QAHW_PARAM_CHANNEL_STATUS_INFO,
+	QAHW_PARAM_CHANNEL_BIT_MASK,
 } qahw_param_id;
 
 typedef union {
     struct qahw_out_render_window_param render_window_params;
+    struct qahw_stream_callback_param stream_callback_params;
 } qahw_loopback_param_payload;
 
 typedef enum {
-    QAHW_PARAM_LOOPBACK_RENDER_WINDOW /* PARAM to set render window */
+    QAHW_PARAM_LOOPBACK_RENDER_WINDOW, /* PARAM to set render window */
+    QAHW_PARAM_LOOPBACK_SET_CALLBACK
 } qahw_loopback_param_id;
 
+typedef struct {
+    uint32_t num_sources;
+    audio_input_flags_t flags;
+    struct audio_port_config *source_config;
+} qahw_source_port_config_t;
+
+typedef struct {
+    uint32_t num_sinks;
+    audio_output_flags_t flags;
+    struct audio_port_config *sink_config;
+} qahw_sink_port_config_t;
+
 /** stream direction enumeration */
 typedef enum {
     QAHW_STREAM_INPUT,
diff --git a/qahw/src/qahw.c b/qahw/src/qahw.c
index 2ae6906..0502f2f 100644
--- a/qahw/src/qahw.c
+++ b/qahw/src/qahw.c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -80,6 +80,15 @@
                                                qahw_loopback_param_id param_id,
                                                qahw_loopback_param_payload *payload);
 
+typedef int (*qahwi_create_audio_patch_v2_t)(const audio_hw_device_t *,
+                        qahw_source_port_config_t *source_port_config,
+                        qahw_sink_port_config_t *sink_port_config,
+                        audio_patch_handle_t *);
+
+typedef int (*qahwi_in_set_param_data_t)(struct audio_stream_in *in,
+                                      qahw_param_id param_id,
+                                      qahw_param_payload *payload);
+
 typedef struct {
     audio_hw_device_t *audio_device;
     char module_name[MAX_MODULE_NAME_LENGTH];
@@ -92,6 +101,7 @@
     qahwi_get_param_data_t qahwi_get_param_data;
     qahwi_set_param_data_t qahwi_set_param_data;
     qahwi_loopback_set_param_data_t qahwi_loopback_set_param_data;
+    qahwi_create_audio_patch_v2_t qahwi_create_audio_patch_v2;
 } qahw_module_t;
 
 typedef struct {
@@ -117,6 +127,7 @@
     pthread_mutex_t lock;
     qahwi_in_read_v2_t qahwi_in_read_v2;
     qahwi_in_stop_t qahwi_in_stop;
+    qahwi_in_set_param_data_t qahwi_in_set_param_data;
 } qahw_stream_in_t;
 
 typedef enum {
@@ -1001,6 +1012,39 @@
     return str_param;
 }
 
+/* API to get capture stream specific config parameters */
+int qahw_in_set_param_data_l(qahw_stream_handle_t *in_handle,
+                            qahw_param_id param_id,
+                            qahw_param_payload *payload)
+{
+    int rc = -EINVAL;
+    qahw_stream_in_t *qahw_stream_in = (qahw_stream_in_t *)in_handle;
+    audio_stream_in_t *in = NULL;
+
+    if (!payload) {
+        ALOGE("%s::Invalid param", __func__);
+        goto exit;
+    }
+
+    if (!is_valid_qahw_stream_l((void *)qahw_stream_in, STREAM_DIR_IN)) {
+        ALOGE("%s::Invalid in handle %p", __func__, in_handle);
+        goto exit;
+    }
+
+    pthread_mutex_lock(&qahw_stream_in->lock);
+    in = qahw_stream_in->stream;
+    if (qahw_stream_in->qahwi_in_set_param_data) {
+        rc = qahw_stream_in->qahwi_in_set_param_data(in, param_id, payload);
+    } else {
+        rc = -ENOSYS;
+        ALOGW("%s not supported", __func__);
+    }
+    pthread_mutex_unlock(&qahw_stream_in->lock);
+
+exit:
+    return rc;
+}
+
 /*
  * Read audio buffer in from audio driver. Returns number of bytes read, or a
  *  negative status_t. If at least one frame was read prior to the error,
@@ -1445,6 +1489,38 @@
      return ret;
 }
 
+int qahw_create_audio_patch_v2_l(qahw_module_handle_t *hw_module,
+                        qahw_source_port_config_t *source_port_config,
+                        qahw_sink_port_config_t *sink_port_config,
+                        audio_patch_handle_t *handle)
+{
+    int ret = 0;
+    qahw_module_t *qahw_module = (qahw_module_t *)hw_module;
+    qahw_module_t *qahw_module_temp;
+
+    pthread_mutex_lock(&qahw_module_init_lock);
+    qahw_module_temp = get_qahw_module_by_ptr_l(qahw_module);
+    pthread_mutex_unlock(&qahw_module_init_lock);
+    if (qahw_module_temp == NULL) {
+        ALOGE("%s:: invalid hw module %p", __func__, qahw_module);
+        goto exit;
+    }
+
+    pthread_mutex_lock(&qahw_module->lock);
+
+    if (qahw_module->qahwi_create_audio_patch_v2){
+        ret = qahw_module->qahwi_create_audio_patch_v2(qahw_module->audio_device,
+                                   source_port_config, sink_port_config, handle);
+    } else {
+         ret = -ENOSYS;
+         ALOGE("%s not supported\n",__func__);
+    }
+    pthread_mutex_unlock(&qahw_module->lock);
+
+exit:
+     return ret;
+}
+
 /* Release an audio patch */
 int qahw_release_audio_patch_l(qahw_module_handle_t *hw_module,
                         audio_patch_handle_t handle)
@@ -1805,6 +1881,17 @@
 
     /* clear any existing errors */
     dlerror();
+    qahw_stream_in->qahwi_in_set_param_data = (qahwi_in_set_param_data_t)
+                                             dlsym(qahw_module->module->dso,
+                                             "qahwi_in_set_param_data");
+    if ((error = dlerror()) != NULL) {
+        ALOGI("%s: dlsym error %s for qahwi_in_set_param_data",
+                   __func__, error);
+        qahw_stream_in->qahwi_in_set_param_data = NULL;
+    }
+
+    /* clear any existing errors */
+    dlerror();
     qahw_stream_in->qahwi_in_stop = (qahwi_in_stop_t)
         dlsym(qahw_module->module->dso, "qahwi_in_stop");
     if ((error = dlerror()) != NULL) {
@@ -1971,6 +2058,11 @@
     if (!qahw_module->qahwi_loopback_set_param_data)
          ALOGD("%s::qahwi_loopback_set_param_data api is not defined\n", __func__);
 
+    qahw_module->qahwi_create_audio_patch_v2 = (qahwi_create_audio_patch_v2_t) dlsym (module->dso,
+                            "qahwi_create_audio_patch_v2");
+    if (!qahw_module->qahwi_create_audio_patch_v2)
+         ALOGD("%s::qahwi_create_audio_patch_v2 api is not defined\n",__func__);
+
     if (!qahw_list_count)
         list_init(&qahw_module_list);
     qahw_list_count++;
diff --git a/qahw_api/inc/qahw_api.h b/qahw_api/inc/qahw_api.h
index 80d9c64..bfeefea 100644
--- a/qahw_api/inc/qahw_api.h
+++ b/qahw_api/inc/qahw_api.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2011 The Android Open Source Project *
@@ -386,6 +386,11 @@
 int qahw_in_get_capture_position(const qahw_stream_handle_t *in_handle,
                                  int64_t *frames, int64_t *time);
 
+/* API to set capture stream specific config parameters */
+int qahw_in_set_param_data(qahw_stream_handle_t *in_handle,
+                            qahw_param_id param_id,
+                            qahw_param_payload *payload);
+
 /* Module specific APIs */
 
 /* convenience API for opening and closing an audio HAL module */
@@ -460,6 +465,11 @@
                         const struct audio_port_config *sinks,
                         audio_patch_handle_t *handle);
 
+int qahw_create_audio_patch_v2(qahw_module_handle_t *hw_module,
+                        qahw_source_port_config_t *source_port_config,
+                        qahw_sink_port_config_t *sink_port_config,
+                        audio_patch_handle_t *handle);
+
 /* Release an audio patch */
 int qahw_release_audio_patch(qahw_module_handle_t *hw_module,
                         audio_patch_handle_t handle);
diff --git a/qahw_api/inc/qahw_defs.h b/qahw_api/inc/qahw_defs.h
index f979013..942e913 100644
--- a/qahw_api/inc/qahw_defs.h
+++ b/qahw_api/inc/qahw_defs.h
@@ -470,6 +470,18 @@
     QAHW_PARAM_LOOPBACK_RENDER_WINDOW /* PARAM to set render window */
 } qahw_loopback_param_id;
 
+typedef struct {
+    uint32_t num_sources;
+    audio_input_flags_t flags;
+    struct audio_port_config *source_config;
+} qahw_source_port_config_t;
+
+typedef struct {
+    uint32_t num_sinks;
+    audio_output_flags_t flags;
+    struct audio_port_config *sink_config;
+} qahw_sink_port_config_t;
+
 /** stream direction enumeration */
 typedef enum {
     QAHW_STREAM_INPUT,
diff --git a/qahw_api/src/qahw_api.cpp b/qahw_api/src/qahw_api.cpp
index 07d2678..a56387f 100644
--- a/qahw_api/src/qahw_api.cpp
+++ b/qahw_api/src/qahw_api.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -714,6 +714,17 @@
     }
 }
 
+int qahw_in_set_param_data(qahw_stream_handle_t *in_handle,
+                            qahw_param_id param_id,
+                            qahw_param_payload *payload)
+{
+    ALOGV("%d:%s",__LINE__, __func__);
+    if (g_binder_enabled)
+        return -ENODEV;
+    else
+        return qahw_in_set_param_data_l(in_handle, param_id, payload);
+}
+
 int qahw_in_set_parameters(qahw_stream_handle_t *in_handle, const char *kv_pairs)
 {
     ALOGV("%d:%s",__LINE__, __func__);
@@ -1001,6 +1012,16 @@
     }
 }
 
+int qahw_create_audio_patch_v2(qahw_module_handle_t *hw_module,
+                        qahw_source_port_config_t *source_port_config,
+                        qahw_sink_port_config_t *sink_port_config,
+                        audio_patch_handle_t *handle)
+{
+    ALOGV("%d:%s",__LINE__, __func__);
+    return qahw_create_audio_patch_v2_l(hw_module, source_port_config,
+                                     sink_port_config, handle);
+}
+
 int qahw_release_audio_patch(qahw_module_handle_t *hw_module,
                         audio_patch_handle_t handle)
 {
@@ -1666,6 +1687,14 @@
     return qahw_in_get_capture_position_l(in_handle, frames, time);
 }
 
+int qahw_in_set_param_data(qahw_stream_handle_t *in_handle,
+                            qahw_param_id param_id,
+                            qahw_param_payload *payload)
+{
+    ALOGV("%d:%s",__LINE__, __func__);
+    return qahw_in_set_param_data_l(in_handle, param_id, payload);
+}
+
 int qahw_init_check(const qahw_module_handle_t *hw_module)
 {
     ALOGV("%d:%s start",__LINE__, __func__);
@@ -1812,6 +1841,16 @@
                                      handle);
 }
 
+int qahw_create_audio_patch_v2(qahw_module_handle_t *hw_module,
+                        qahw_source_port_config_t *source_port_config,
+                        qahw_sink_port_config_t *sink_port_config,
+                        audio_patch_handle_t *handle)
+{
+    ALOGV("%d:%s",__LINE__, __func__);
+    return qahw_create_audio_patch_v2_l(hw_module, source_port_config,
+                                     sink_port_config, handle);
+}
+
 int qahw_release_audio_patch(qahw_module_handle_t *hw_module,
                         audio_patch_handle_t handle)
 {