summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/diagchar.h52
-rw-r--r--include/linux/mmzone.h1
-rw-r--r--include/linux/power_supply.h3
-rw-r--r--include/linux/qdsp6v2/audio-anc-dev-mgr.h46
-rw-r--r--include/linux/qdsp6v2/sdsp_anc.h302
-rw-r--r--include/sound/apr_audio-v2.h257
-rw-r--r--include/sound/q6afe-v2.h10
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/msm_audio_anc.h53
9 files changed, 701 insertions, 24 deletions
diff --git a/include/linux/diagchar.h b/include/linux/diagchar.h
index 7c92113e20c3..112d8b73d066 100644
--- a/include/linux/diagchar.h
+++ b/include/linux/diagchar.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2008-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -145,10 +145,10 @@ the appropriate macros. */
/* This needs to be modified manually now, when we add
a new RANGE of SSIDs to the msg_mask_tbl */
#define MSG_MASK_TBL_CNT 26
-#define APPS_EVENT_LAST_ID 0x0B3F
+#define APPS_EVENT_LAST_ID 0x0C5A
#define MSG_SSID_0 0
-#define MSG_SSID_0_LAST 121
+#define MSG_SSID_0_LAST 125
#define MSG_SSID_1 500
#define MSG_SSID_1_LAST 506
#define MSG_SSID_2 1000
@@ -160,11 +160,11 @@ the appropriate macros. */
#define MSG_SSID_5 4000
#define MSG_SSID_5_LAST 4010
#define MSG_SSID_6 4500
-#define MSG_SSID_6_LAST 4583
+#define MSG_SSID_6_LAST 4584
#define MSG_SSID_7 4600
-#define MSG_SSID_7_LAST 4615
+#define MSG_SSID_7_LAST 4616
#define MSG_SSID_8 5000
-#define MSG_SSID_8_LAST 5033
+#define MSG_SSID_8_LAST 5034
#define MSG_SSID_9 5500
#define MSG_SSID_9_LAST 5516
#define MSG_SSID_10 6000
@@ -264,7 +264,7 @@ static const uint32_t msg_bld_masks_0[] = {
MSG_MASK_6|MSG_MASK_7|MSG_MASK_8|MSG_MASK_9|MSG_MASK_10,
MSG_LVL_MED,
MSG_LVL_LOW,
- MSG_LVL_LOW,
+ MSG_LVL_MED,
MSG_LVL_MED,
MSG_LVL_LOW,
MSG_LVL_LOW,
@@ -317,7 +317,7 @@ static const uint32_t msg_bld_masks_0[] = {
MSG_LVL_LOW|MSG_LVL_MED|MSG_LVL_HIGH|MSG_LVL_ERROR|MSG_LVL_FATAL,
MSG_LVL_MED,
MSG_LVL_HIGH,
- MSG_LVL_LOW,
+ MSG_LVL_MED,
MSG_LVL_HIGH,
MSG_LVL_LOW|MSG_LVL_MED|MSG_LVL_HIGH|MSG_LVL_ERROR|MSG_LVL_FATAL,
MSG_LVL_MED|MSG_LVL_HIGH|MSG_LVL_ERROR,
@@ -486,6 +486,7 @@ static const uint32_t msg_bld_masks_6[] = {
MSG_LVL_LOW,
MSG_LVL_LOW,
MSG_LVL_LOW,
+ MSG_LVL_LOW,
MSG_LVL_LOW
};
@@ -505,7 +506,9 @@ static const uint32_t msg_bld_masks_7[] = {
MSG_LVL_LOW,
MSG_LVL_LOW,
MSG_LVL_LOW,
- MSG_LVL_LOW|MSG_LVL_MED|MSG_LVL_HIGH|MSG_LVL_ERROR|MSG_LVL_FATAL
+ MSG_LVL_LOW | MSG_LVL_MED | MSG_LVL_HIGH | MSG_LVL_ERROR |
+ MSG_LVL_FATAL,
+ MSG_LVL_LOW
};
static const uint32_t msg_bld_masks_8[] = {
@@ -525,9 +528,6 @@ static const uint32_t msg_bld_masks_8[] = {
MSG_LVL_MED,
MSG_LVL_MED,
MSG_LVL_MED,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
MSG_LVL_MED,
MSG_LVL_MED,
MSG_LVL_MED,
@@ -542,6 +542,10 @@ static const uint32_t msg_bld_masks_8[] = {
MSG_LVL_MED,
MSG_LVL_MED,
MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_HIGH,
MSG_LVL_HIGH
};
@@ -644,14 +648,14 @@ static const uint32_t msg_bld_masks_10[] = {
MSG_LVL_MED,
MSG_LVL_MED,
MSG_LVL_LOW,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
- MSG_LVL_LOW,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
+ MSG_LVL_MED,
MSG_LVL_MED
};
@@ -797,7 +801,9 @@ static const uint32_t msg_bld_masks_19[] = {
};
static const uint32_t msg_bld_masks_20[] = {
- MSG_LVL_LOW,
+ MSG_LVL_LOW | MSG_MASK_5 | MSG_MASK_6 | MSG_MASK_7 |
+ MSG_MASK_8 | MSG_MASK_9 | MSG_MASK_10 | MSG_MASK_11 |
+ MSG_MASK_12,
MSG_LVL_LOW,
MSG_LVL_LOW,
MSG_LVL_LOW,
@@ -875,7 +881,7 @@ static const uint32_t msg_bld_masks_25[] = {
/* LOG CODES */
static const uint32_t log_code_last_tbl[] = {
0x0, /* EQUIP ID 0 */
- 0x1A11, /* EQUIP ID 1 */
+ 0x1C68, /* EQUIP ID 1 */
0x0, /* EQUIP ID 2 */
0x0, /* EQUIP ID 3 */
0x4910, /* EQUIP ID 4 */
@@ -885,7 +891,7 @@ static const uint32_t log_code_last_tbl[] = {
0x0, /* EQUIP ID 8 */
0x0, /* EQUIP ID 9 */
0xA38A, /* EQUIP ID 10 */
- 0xB201, /* EQUIP ID 11 */
+ 0xB9FF, /* EQUIP ID 11 */
0x0, /* EQUIP ID 12 */
0xD1FF, /* EQUIP ID 13 */
0x0, /* EQUIP ID 14 */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 0db2f3cb1b6c..f09c5b28ed70 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -176,6 +176,7 @@ enum zone_stat_item {
NR_ANON_TRANSPARENT_HUGEPAGES,
NR_FREE_CMA_PAGES,
NR_SWAPCACHE,
+ NR_INDIRECTLY_RECLAIMABLE_BYTES, /* measured in bytes */
NR_VM_ZONE_STAT_ITEMS };
/*
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 8b8a46ce32d0..64d0797cc3a7 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -103,6 +103,9 @@ enum {
POWER_SUPPLY_DP_DM_HVDCP3_SUPPORTED = 10,
POWER_SUPPLY_DP_DM_ICL_DOWN = 11,
POWER_SUPPLY_DP_DM_ICL_UP = 12,
+ POWER_SUPPLY_DP_DM_FORCE_5V = 13,
+ POWER_SUPPLY_DP_DM_FORCE_9V = 14,
+ POWER_SUPPLY_DP_DM_FORCE_12V = 15,
};
enum {
diff --git a/include/linux/qdsp6v2/audio-anc-dev-mgr.h b/include/linux/qdsp6v2/audio-anc-dev-mgr.h
new file mode 100644
index 000000000000..dfa6752bc31b
--- /dev/null
+++ b/include/linux/qdsp6v2/audio-anc-dev-mgr.h
@@ -0,0 +1,46 @@
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _AUDIO_ANC_DEV_MGR_H_
+#define _AUDIO_ANC_DEV_MGR_H_
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/wcd9xxx/core.h>
+#include <linux/bitops.h>
+#include <linux/slab.h>
+#include <linux/clk.h>
+#include <linux/of_device.h>
+#include <linux/clk/msm-clk.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/apr_audio-v2.h>
+#include <sound/q6afe-v2.h>
+#include <sound/msm-dai-q6-v2.h>
+#include <linux/msm_audio_anc.h>
+
+int msm_anc_dev_init(void);
+int msm_anc_dev_deinit(void);
+
+int msm_anc_dev_start(void);
+int msm_anc_dev_stop(void);
+
+int msm_anc_dev_set_info(void *info_p, int32_t anc_cmd);
+
+int msm_anc_dev_create(struct platform_device *pdev);
+
+int msm_anc_dev_destroy(struct platform_device *pdev);
+
+#endif
diff --git a/include/linux/qdsp6v2/sdsp_anc.h b/include/linux/qdsp6v2/sdsp_anc.h
new file mode 100644
index 000000000000..3b236e827e3d
--- /dev/null
+++ b/include/linux/qdsp6v2/sdsp_anc.h
@@ -0,0 +1,302 @@
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#ifndef __SDSP_ANC_H__
+#define __SDSP_ANC_H__
+
+#include <sound/q6afe-v2.h>
+#include <sound/apr_audio-v2.h>
+
+
+#define AUD_MSVC_MODULE_AUDIO_DEV_RESOURCE_SHARE 0x0001028A
+#define AUD_MSVC_PARAM_ID_PORT_SHARE_RESOURCE_CONFIG 0x00010297
+#define AUD_MSVC_API_VERSION_SHARE_RESOURCE_CONFIG 0x1
+#define AUD_MSVC_MODULE_AUDIO_DEV_ANC_REFS 0x00010254
+#define AUD_MSVC_PARAM_ID_DEV_ANC_REFS_CONFIG 0x00010286
+#define AUD_MSVC_API_VERSION_DEV_ANC_REFS_CONFIG 0x1
+#define AUD_MSVC_MODULE_AUDIO_DEV_ANC_ALGO 0x00010234
+#define AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_RPM 0x00010235
+#define AUD_MSVC_API_VERSION_DEV_ANC_ALGO_RPM 0x1
+
+struct aud_msvc_port_param_data_v2 {
+ /* ID of the module to be configured.
+ * Supported values: Valid module ID
+ */
+ u32 module_id;
+
+ /* ID of the parameter corresponding to the supported parameters
+ * for the module ID.
+ * Supported values: Valid parameter ID
+ */
+ u32 param_id;
+
+ /* Actual size of the data for the
+ * module_id/param_id pair. The size is a
+ * multiple of four bytes.
+ * Supported values: > 0
+ */
+ u16 param_size;
+
+ /* This field must be set to zero.
+ */
+ u16 reserved;
+} __packed;
+
+
+/* Payload of the #AFE_PORT_CMD_SET_PARAM_V2 command's
+ * configuration/calibration settings for the AFE port.
+ */
+struct aud_msvc_port_cmd_set_param_v2 {
+ /* Port interface and direction (Rx or Tx) to start.
+ */
+ u16 port_id;
+
+ /* Actual size of the payload in bytes.
+ * This is used for parsing the parameter payload.
+ * Supported values: > 0
+ */
+ u16 payload_size;
+
+ /* LSW of 64 bit Payload address.
+ * Address should be 32-byte,
+ * 4kbyte aligned and must be contiguous memory.
+ */
+ u32 payload_address_lsw;
+
+ /* MSW of 64 bit Payload address.
+ * In case of 32-bit shared memory address,
+ * this field must be set to zero.
+ * In case of 36-bit shared memory address,
+ * bit-4 to bit-31 must be set to zero.
+ * Address should be 32-byte, 4kbyte aligned
+ * and must be contiguous memory.
+ */
+ u32 payload_address_msw;
+
+ /* Memory map handle returned by
+ * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands.
+ * Supported Values:
+ * - NULL -- Message. The parameter data is in-band.
+ * - Non-NULL -- The parameter data is Out-band.Pointer to
+ * the physical address
+ * in shared memory of the payload data.
+ * An optional field is available if parameter
+ * data is in-band:
+ * aud_msvc_param_data_v2 param_data[...].
+ * For detailed payload content, see the
+ * aud_msvc_port_param_data_v2 structure.
+ */
+ u32 mem_map_handle;
+
+} __packed;
+
+/* Payload of the #AFE_PORT_CMD_GET_PARAM_V2 command,
+ * which queries for one post/preprocessing parameter of a
+ * stream.
+ */
+struct aud_msvc_port_cmd_get_param_v2 {
+ /* Port interface and direction (Rx or Tx) to start. */
+ u16 port_id;
+
+ /* Maximum data size of the parameter ID/module ID combination.
+ * This is a multiple of four bytes
+ * Supported values: > 0
+ */
+ u16 payload_size;
+
+ /* LSW of 64 bit Payload address. Address should be 32-byte,
+ * 4kbyte aligned and must be contig memory.
+ */
+ u32 payload_address_lsw;
+
+ /* MSW of 64 bit Payload address. In case of 32-bit shared
+ * memory address, this field must be set to zero. In case of 36-bit
+ * shared memory address, bit-4 to bit-31 must be set to zero.
+ * Address should be 32-byte, 4kbyte aligned and must be contiguous
+ * memory.
+ */
+ u32 payload_address_msw;
+
+ /* Memory map handle returned by
+ * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands.
+ * Supported Values: - NULL -- Message. The parameter data is
+ * in-band. - Non-NULL -- The parameter data is Out-band.Pointer to
+ * - the physical address in shared memory of the payload data.
+ * For detailed payload content, see the aud_msvc_port_param_data_v2
+ * structure
+ */
+ u32 mem_map_handle;
+
+ /* ID of the module to be queried.
+ * Supported values: Valid module ID
+ */
+ u32 module_id;
+
+ /* ID of the parameter to be queried.
+ * Supported values: Valid parameter ID
+ */
+ u32 param_id;
+
+} __packed;
+
+struct aud_audioif_config_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_set_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ union afe_port_config port;
+} __packed;
+
+struct aud_msvc_param_id_dev_share_resource_cfg {
+ u32 minor_version;
+ u16 rddma_idx;
+ u16 wrdma_idx;
+ u32 lpm_start_addr;
+ u32 lpm_length;
+} __packed;
+
+
+struct aud_msvc_param_id_dev_anc_algo_rpm {
+ u32 minor_version;
+ u32 rpm;
+} __packed;
+
+
+struct aud_msvc_param_id_dev_anc_refs_cfg {
+ u32 minor_version;
+ u16 port_id;
+ u16 num_channel;
+ u32 sample_rate;
+ u32 bit_width;
+} __packed;
+
+
+struct anc_share_resource_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_set_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ struct aud_msvc_param_id_dev_share_resource_cfg resource;
+} __packed;
+
+
+struct anc_config_ref_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_set_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ struct aud_msvc_param_id_dev_anc_refs_cfg refs;
+} __packed;
+
+
+
+struct anc_set_rpm_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_set_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ struct aud_msvc_param_id_dev_anc_algo_rpm set_rpm;
+} __packed;
+
+struct anc_get_rpm_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_get_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ struct aud_msvc_param_id_dev_anc_algo_rpm get_rpm;
+} __packed;
+
+struct anc_get_rpm_resp {
+ uint32_t status;
+ struct aud_msvc_port_param_data_v2 pdata;
+ struct aud_msvc_param_id_dev_anc_algo_rpm res_rpm;
+} __packed;
+
+#define AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_BYPASS_MODE 0x0001029B
+
+#define AUD_MSVC_API_VERSION_DEV_ANC_ALGO_BYPASS_MODE 0x1
+
+#define AUD_MSVC_ANC_ALGO_BYPASS_MODE_NO 0x0
+#define AUD_MSVC_ANC_ALGO_BYPASS_MODE_REFS_TO_ANC_SPKR 0x1
+#define AUD_MSVC_ANC_ALGO_BYPASS_MODE_ANC_MIC_TO_ANC_SPKR 0x2
+#define AUD_MSVC_ANC_ALGO_BYPASS_MODE_REFS_MIXED_ANC_MIC_TO_ANC_SPKR 0x3
+
+struct aud_msvc_param_id_dev_anc_algo_bypass_mode {
+ uint32_t minor_version;
+ uint32_t bypass_mode;
+} __packed;
+
+struct anc_set_bypass_mode_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_set_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ struct aud_msvc_param_id_dev_anc_algo_bypass_mode set_bypass_mode;
+} __packed;
+
+#define AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_MODULE_ID 0x0001023A
+
+struct aud_msvc_param_id_dev_anc_algo_module_id {
+ uint32_t minor_version;
+ uint32_t module_id;
+} __packed;
+
+struct anc_set_algo_module_id_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_set_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ struct aud_msvc_param_id_dev_anc_algo_module_id set_algo_module_id;
+} __packed;
+
+
+#define AUD_MSVC_PARAM_ID_PORT_ANC_MIC_SPKR_LAYOUT_INFO 0x0001029C
+
+#define AUD_MSVC_API_VERSION_DEV_ANC_MIC_SPKR_LAYOUT_INFO 0x1
+
+#define AUD_MSVC_ANC_MAX_NUM_OF_MICS 16
+#define AUD_MSVC_ANC_MAX_NUM_OF_SPKRS 16
+
+struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info {
+ uint32_t minor_version;
+ uint16_t mic_layout_array[AUD_MSVC_ANC_MAX_NUM_OF_MICS];
+ uint16_t spkr_layout_array[AUD_MSVC_ANC_MAX_NUM_OF_SPKRS];
+ uint16_t num_anc_mic;
+ uint16_t num_anc_spkr;
+ uint16_t num_add_mic_signal;
+ uint16_t num_add_spkr_signal;
+} __packed;
+
+struct anc_set_mic_spkr_layout_info_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_set_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info
+ set_mic_spkr_layout;
+} __packed;
+
+int anc_if_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port);
+
+int anc_if_tdm_port_stop(u16 port_id);
+
+int anc_if_share_resource(u16 port_id, u16 rddma_idx, u16 wrdma_idx,
+ u32 lpm_start_addr, u32 lpm_length);
+
+int anc_if_config_ref(u16 port_id, u32 sample_rate, u32 bit_width,
+ u16 num_channel);
+
+int anc_if_set_rpm(u16 port_id, u32 rpm);
+
+int anc_if_set_bypass_mode(u16 port_id, u32 bypass_mode);
+
+int anc_if_set_algo_module_id(u16 port_id, u32 module_id);
+
+int anc_if_set_anc_mic_spkr_layout(u16 port_id,
+struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info *set_mic_spkr_layout_p);
+
+int anc_if_shared_mem_map(void);
+
+int anc_if_shared_mem_unmap(void);
+
+#endif /* __SDSP_ANC_H__ */
diff --git a/include/sound/apr_audio-v2.h b/include/sound/apr_audio-v2.h
index 0393c8869b8f..ee65bdae9971 100644
--- a/include/sound/apr_audio-v2.h
+++ b/include/sound/apr_audio-v2.h
@@ -3512,6 +3512,263 @@ struct afe_param_id_set_topology_cfg {
u32 topology_id;
} __packed;
+/*
+ * This command is used by client to request the LPASS resources.
+ * Currently this command supports only LPAIF DMA resources.
+ * Allocated resources will be in control of remote client until
+ * they get released.
+ *
+ * If all the requested resources are available then response status in
+ * AFE_CMDRSP_REQUEST_LPASS_RESOURCES payload will
+ * be updated with ADSP_EOK, otherwise it will be ADSP_EFAILED.
+ *
+ * This command is variable payload size command, and size depends
+ * on the type of resource requested.
+ *
+ * For example, if client requests AFE_LPAIF_DMA_RESOURCE_ID
+ * resources, afe_cmd_request_lpass_resources structure will
+ * be followed with the afe_cmd_request_lpass_dma_resources
+ * structure.
+ *
+ * AFE_CMDRSP_REQUEST_LPASS_RESOURCES is the response for
+ * this command, which returns the allocated resources.
+ *
+ * @apr_hdr_fields
+ * Opcode -- AFE_CMD_REQUEST_LPASS_RESOURCES
+ *
+ * @return
+ * #AFE_CMDRSP_REQUEST_LPASS_RESOURCES
+ */
+#define AFE_CMD_REQUEST_LPASS_RESOURCES 0x00010109
+
+/* Macro for requesting LPAIF DMA resources */
+#define AFE_LPAIF_DMA_RESOURCE_ID 0x00000001
+
+struct afe_cmd_request_lpass_resources {
+ /*
+ * LPASS Resource ID
+ * @values:
+ * - AFE_LPAIF_DMA_RESOURCE_ID
+ */
+ u32 resource_id;
+} __packed;
+
+/*
+ * AFE_CMD_REQUEST_LPASS_RESOURCES uses this structure when
+ * client is requesting LPAIF DMA resources.
+ *
+ * Number of read DMA channels and write DMA channels varies from chipset to
+ * chipset. HLOS needs to make sure that when it requests LPASS DMA
+ * resources, it should not impact the concurrencies which
+ * are mandatory for a given chipset.
+ */
+
+/* Macro for AFE LPAIF default DMA data type */
+#define AFE_LPAIF_DEFAULT_DMA_TYPE 0x0
+
+struct afe_cmd_request_lpass_dma_resources {
+ /*
+ * LPASS DMA Type
+ * @values:
+ * - AFE_LPAIF_DEFAULT_DMA_TYPE
+ */
+ u8 dma_type;
+ /*
+ * Number of read DMA channels required
+ * @values: >=0
+ * - 0 indicates channels are not requested
+ */
+ u8 num_read_dma_channels;
+ /*
+ * Number of write DMA channels required
+ * @values: >=0
+ * - 0 indicates channels are not requested
+ */
+ u8 num_write_dma_channels;
+ /*
+ * Reserved field for 4 byte alignment
+ * @values: 0
+ */
+ u8 reserved;
+} __packed;
+
+struct afe_request_lpass_dma_resources_command {
+ struct apr_hdr hdr;
+ struct afe_cmd_request_lpass_resources resources;
+ struct afe_cmd_request_lpass_dma_resources dma_resources;
+} __packed;
+
+/*
+ * This is the response for the command AFE_CMD_REQUEST_LPASS_RESOURCES.
+ * Payload of this command is variable.
+ *
+ * Resources allocated successfully or not, are determined by the "status"
+ * in the payload. If status is ADSP_EOK, then resources are
+ * allocated successfully and allocated resource information
+ * follows.
+ *
+ * For example, if the response resource id is AFE_LPAIF_DMA_RESOURCE_ID,
+ * afe_cmdrsp_request_lpass_dma_resources structure will
+ * follow after afe_cmdrsp_request_lpass_resources.
+ *
+ * If status is ADSP_EFAILED, this indicates requested resources
+ * are not allocated successfully. In this case the payload following
+ * this structure is invalid.
+ * @apr_hdr_fields
+ * Opcode -- AFE_CMDRSP_REQUEST_LPASS_RESOURCES
+*/
+#define AFE_CMDRSP_REQUEST_LPASS_RESOURCES 0x0001010A
+
+struct afe_cmdrsp_request_lpass_resources {
+ /*
+ * ADSP_EOK if all requested resources are allocated.
+ * ADSP_EFAILED if resource allocation is failed.
+ */
+ u32 status;
+ /*
+ * Returned LPASS DMA resource ID
+ * @values:
+ * - AFE_LPAIF_DMA_RESOURCE_ID
+ */
+ u32 resource_id;
+} __packed;
+
+/*
+ * This command will be sent as a payload for
+ * AFE_CMDRSP_REQUEST_LPASS_RESOURCES, when the LPAIF DMA resources
+ * were requested. Payload of this command is variable, which
+ * follows after the afe_cmdrsp_request_lpass_dma_resources structure.
+ * The size in bytes following this structure is sum of
+ * num_read_dma_channels and num_write_dma_channels.
+ *
+ * If the resource allocation is successful, then the payload contains
+ * the valid DMA channel indices.
+ *
+ * For example, if number of requested DMA read channels is 2, and they
+ * are successfully allocated, the variable payload contains
+ * valid DMA channel index values in first two bytes array.
+ *
+ * In the failure case this payload can be ignored, and all the values will be
+ * initialized with zeros.
+ *
+ * An example payload of the command response is below:
+ * <struct afe_cmdrsp_request_lpass_resources>
+ * <struct afe_cmdrsp_request_lpass_dma_resources>
+ * read DMA index value for each byte.
+ * write DMA index value for each byte.
+ * padded zeros, if sum of num_read_dma_channels and num_write_dma_channels
+ * are not multiples of 4.
+*/
+
+struct afe_cmdrsp_request_lpass_dma_resources {
+ /*
+ * LPASS DMA Type
+ * @values:
+ * - AFE_LPAIF_DEFAULT_DMA_TYPE
+ */
+ u8 dma_type;
+ /*
+ * Returned number of read DMA channels allocated
+ * @values: >=0
+ */
+ u8 num_read_dma_channels;
+ /*
+ * Returned number of write DMA channels allocated
+ * @values: >=0
+ */
+ u8 num_write_dma_channels;
+ /*
+ * Reserved field for 4 byte alignment
+ * @values: 0
+ */
+ u8 reserved;
+} __packed;
+
+/*
+ * This command is for releasing resources which are allocated as
+ * part of AFE_CMD_REQUEST_LPASS_RESOURCES.
+ *
+ * Payload of this command is variable, which follows
+ * after the afe_cmd_release_lpass_resources structure.
+ *
+ * If release resource is AFE_LPAIF_DMA_RESOURCE_ID
+ * afe_cmd_release_lpass_dma_resources structure will be
+ * followed after afe_cmd_release_lpass_resources.
+ *
+ *
+ * @apr_hdr_fields
+ * Opcode -- AFE_CMD_RELEASE_LPASS_RESOURCES
+
+ * @return
+ * #APRv2 IBASIC RSP Result
+*/
+#define AFE_CMD_RELEASE_LPASS_RESOURCES 0x0001010B
+
+struct afe_cmd_release_lpass_resources {
+ /*
+ * LPASS DMA resource ID
+ * @values:
+ * - AFE_LPAIF_DMA_RESOURCE_ID
+ */
+ u32 resource_id;
+} __packed;
+
+/*
+ * This payload to be appended as part of AFE_CMD_RELEASE_LPASS_RESOURCES
+ * when resource id AFE_LPAIF_DMA_RESOURCE_ID is used.
+ *
+ * Payload of this command is variable, which will be followed after the
+ * afe_cmd_release_lpass_dma_resources structure.
+ * The variable payload's size in bytes is sum of
+ * num_read_dma_channels and num_write_dma_channels.
+ * Variable payload data contains the valid DMA channel indices which are
+ * allocated as part of AFE_CMD_REQUEST_LPASS_RESOURCES.
+ *
+ * For example, if number of DMA read channels released are 2,
+ * the variable payload contains valid DMA channel
+ * index values in first two bytes of variable payload.
+ * Client needs to fill the same DMA channel indices were returned
+ * as part of AFE_CMD_RELEASE_LPASS_RESOURCES, otherwise
+ * ADSP will return the error.
+ *
+ * An example payload of the release command is below:
+ * <struct afe_cmd_release_lpass_resources>
+ * <struct afe_cmd_release_lpass_dma_resources>
+ * read DMA index value for each byte.
+ * write DMA index value for each byte.
+*/
+
+struct afe_cmd_release_lpass_dma_resources {
+ /*
+ * LPASS DMA Type
+ * @values:
+ * - AFE_LPAIF_DEFAULT_DMA_TYPE
+ */
+ u8 dma_type;
+ /*
+ * Number of read DMA channels to be released
+ * @values: >=0
+ * - 0 indicates channels are not released
+ */
+ u8 num_read_dma_channels;
+ /*
+ * Number of write DMA channels to be released
+ * @values: >=0
+ * - 0 indicates channels are not released
+ */
+ u8 num_write_dma_channels;
+ /*
+ * Reserved field for 4 byte alignment
+ * @values: 0
+ */
+ u8 reserved;
+} __packed;
+
+struct afe_release_lpass_dma_resources_command {
+ struct apr_hdr hdr;
+ struct afe_cmd_release_lpass_resources resources;
+ struct afe_cmd_release_lpass_dma_resources dma_resources;
+} __packed;
/*
* Generic encoder module ID.
diff --git a/include/sound/q6afe-v2.h b/include/sound/q6afe-v2.h
index 922ebb69205d..cdbf97023f66 100644
--- a/include/sound/q6afe-v2.h
+++ b/include/sound/q6afe-v2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -42,6 +42,9 @@
#define AFE_CLK_VERSION_V1 1
#define AFE_CLK_VERSION_V2 2
+#define AFE_MAX_RDDMA 10
+#define AFE_MAX_WRDMA 10
+
typedef int (*routing_cb)(int port);
enum {
@@ -450,4 +453,9 @@ void afe_set_routing_callback(routing_cb);
int afe_get_av_dev_drift(struct afe_param_id_dev_timing_stats *timing_stats,
u16 port);
int afe_get_svc_version(uint32_t service_id);
+int afe_request_dma_resources(uint8_t dma_type, uint8_t num_read_dma_channels,
+ uint8_t num_write_dma_channels);
+int afe_get_dma_idx(bool **ret_rddma_idx,
+ bool **ret_wrdma_idx);
+int afe_release_all_dma_resources(void);
#endif /* __Q6AFE_V2_H__ */
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index 2604d3f387ba..c06237170542 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -296,6 +296,7 @@ header-y += msm_audio_amrnb.h
header-y += msm_audio_amrwb.h
header-y += msm_audio_amrwbplus.h
header-y += msm_audio_calibration.h
+header-y += msm_audio_anc.h
header-y += msm_audio_mvs.h
header-y += msm_audio_qcp.h
header-y += msm_audio_sbc.h
diff --git a/include/uapi/linux/msm_audio_anc.h b/include/uapi/linux/msm_audio_anc.h
new file mode 100644
index 000000000000..028d381bc1a6
--- /dev/null
+++ b/include/uapi/linux/msm_audio_anc.h
@@ -0,0 +1,53 @@
+#ifndef _UAPI_MSM_AUDIO_ANC_H
+#define _UAPI_MSM_AUDIO_ANC_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define ANC_IOCTL_MAGIC 'a'
+
+#define AUDIO_ANC_SET_PARAM _IOWR(ANC_IOCTL_MAGIC, \
+ 300, struct audio_anc_packet *)
+#define AUDIO_ANC_GET_PARAM _IOWR(ANC_IOCTL_MAGIC, \
+ 301, struct audio_anc_packet *)
+
+#define ANC_CMD_START 0
+#define ANC_CMD_STOP 1
+#define ANC_CMD_RPM 2
+#define ANC_CMD_BYPASS_MODE 3
+#define ANC_CMD_ALGO_MODULE 4
+
+/* room for ANC_CMD define extend */
+#define ANC_CMD_MAX 0xFF
+
+struct audio_anc_header {
+ int32_t data_size;
+ int32_t version;
+ int32_t anc_cmd;
+ int32_t anc_cmd_size;
+};
+
+struct audio_anc_rpm_info {
+ int32_t rpm;
+};
+
+struct audio_anc_bypass_mode {
+ int32_t mode;
+};
+
+struct audio_anc_algo_module_info {
+ int32_t module_id;
+};
+
+union audio_anc_data {
+ struct audio_anc_rpm_info rpm_info;
+ struct audio_anc_bypass_mode bypass_mode_info;
+ struct audio_anc_algo_module_info algo_info;
+};
+
+struct audio_anc_packet {
+ struct audio_anc_header hdr;
+ union audio_anc_data anc_data;
+};
+
+#endif /* _UAPI_MSM_AUDIO_ANC_H */