Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c77be90 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: wcd_cpe_services: Add initial CPE Services"

parents dd0918db 12a172af
Loading
Loading
Loading
Loading
+337 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, 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 __CPE_CMI_H__
#define __CPE_CMI_H__

#include <linux/types.h>

#define CPE_AFE_PORT_1_TX 1
#define CMI_INBAND_MESSAGE_SIZE 127

/*
 * Multiple mad types can be supported at once.
 * these values can be OR'ed to form the set of
 * supported mad types
 */
#define MAD_TYPE_AUDIO (1 << 0)
#define MAD_TYPE_BEACON (1 << 1)
#define MAD_TYPE_ULTRASND (1 << 2)

/* Core service command opcodes */
#define CPE_CORE_SVC_CMD_SHARED_MEM_ALLOC	(0x3001)
#define CPE_CORE_SVC_CMDRSP_SHARED_MEM_ALLOC	(0x3002)
#define CPE_CORE_SVC_CMD_SHARED_MEM_DEALLOC	(0x3003)
#define CPE_CORE_SVC_CMD_DRAM_ACCESS_REQ	(0x3004)
#define CPE_CORE_SVC_EVENT_SYSTEM_BOOT		(0x3005)

#define CPE_BOOT_SUCCESS 0x00
#define CPE_BOOT_FAILED 0x01

/* LSM Service command opcodes */
#define CPE_LSM_SESSION_CMD_OPEN_TX		(0x2000)
#define CPE_LSM_SESSION_CMD_SET_PARAMS		(0x2001)
#define CPE_LSM_SESSION_CMD_REGISTER_SOUND_MODEL (0x2002)
#define CPE_LSM_SESSION_CMD_DEREGISTER_SOUND_MODEL (0x2003)
#define CPE_LSM_SESSION_CMD_START		(0x2004)
#define CPE_LSM_SESSION_CMD_STOP		(0x2005)
#define CPE_LSM_SESSION_EVENT_DETECTION_STATUS_V2 (0x2006)
#define CPE_LSM_SESSION_CMD_CLOSE_TX		(0x2007)
#define CPE_LSM_SESSION_CMD_SHARED_MEM_ALLOC	(0x2008)
#define CPE_LSM_SESSION_CMDRSP_SHARED_MEM_ALLOC (0x2009)
#define CPE_LSM_SESSION_CMD_SHARED_MEM_DEALLOC	(0x200A)

/* LSM Service module and param IDs */
#define LSM_MODULE_ID_VOICE_WAKEUP		(0x00012C00)
#define LSM_PARAM_ID_ENDPOINT_DETECT_THRESHOLD	(0x00012C01)
#define LSM_PARAM_ID_OPERATION_MODE		(0x00012C02)
#define LSM_PARAM_ID_GAIN			(0x00012C03)
#define LSM_PARAM_ID_CONNECT_TO_PORT		(0x00012C04)
#define LSM_PARAM_ID_MIN_CONFIDENCE_LEVELS	(0x00012C07)

/* AFE Service command opcodes */
#define CPE_AFE_PORT_CMD_START			(0x1001)
#define CPE_AFE_PORT_CMD_STOP			(0x1002)
#define CPE_AFE_PORT_CMD_SUSPEND		(0x1003)
#define CPE_AFE_PORT_CMD_RESUME			(0x1004)
#define CPE_AFE_PORT_CMD_SHARED_MEM_ALLOC	(0x1005)
#define CPE_AFE_PORT_CMDRSP_SHARED_MEM_ALLOC	(0x1006)
#define CPE_AFE_PORT_CMD_SHARED_MEM_DEALLOC	(0x1007)

/* AFE Service module and param IDs */
#define CPE_AFE_CMD_SET_PARAM			(0x1000)
#define CPE_AFE_MODULE_ID_SW_MAD		(0x0001022D)
#define CPE_AFE_PARAM_ID_SW_MAD_CFG		(0x0001022E)
#define CPE_AFE_PARAM_ID_SVM_MODEL		(0x0001022F)

#define CPE_AFE_MODULE_HW_MAD			(0x00010230)
#define CPE_AFE_PARAM_ID_HW_MAD_CTL		(0x00010232)
#define CPE_AFE_PARAM_ID_HW_MAD_CFG		(0x00010231)

#define CPE_AFE_MODULE_AUDIO_DEV_INTERFACE	(0x0001020C)
#define CPE_AFE_PARAM_ID_GENERIC_PORT_CONFIG	(0x00010253)

#define CPE_CMI_BASIC_RSP_OPCODE	(0x0001)
#define CPE_HDR_MAX_PLD_SIZE	(0x7F)

#define CMI_OBM_FLAG_IN_BAND	0
#define CMI_OBM_FLAG_OUT_BAND	1

/*
 * Future Service ID's can be added one line
 * before the CMI_CPE_SERVICE_ID_MAX
 */
enum {
	CMI_CPE_SERVICE_ID_MIN = 0,
	CMI_CPE_CORE_SERVICE_ID,
	CMI_CPE_AFE_SERVICE_ID,
	CMI_CPE_LSM_SERVICE_ID,
	CMI_CPE_SERVICE_ID_MAX,
};

#define CPE_LSM_SESSION_ID_MAX 1

#define IS_VALID_SESSION_ID(s_id) \
	(s_id <= CPE_LSM_SESSION_ID_MAX)

#define IS_VALID_SERVICE_ID(s_id) \
	(s_id > CMI_CPE_SERVICE_ID_MIN && \
	 s_id < CMI_CPE_SERVICE_ID_MAX)

#define IS_VALID_PLD_SIZE(p_size) \
	(p_size <= CPE_HDR_MAX_PLD_SIZE)

#define CMI_HDR_SET_OPCODE(hdr, cmd) (hdr->opcode = cmd)


#define CMI_HDR_SET(hdr_info, mask, shift, value) \
		(hdr_info = (((hdr_info) & ~(mask)) | \
			((value << shift) & mask)))

#define SVC_ID_SHIFT 4
#define SVC_ID_MASK (0x07 << SVC_ID_SHIFT)

#define SESSION_ID_SHIFT 0
#define SESSION_ID_MASK (0x0F << SESSION_ID_SHIFT)

#define PAYLD_SIZE_SHIFT 0
#define PAYLD_SIZE_MASK (0x7F << PAYLD_SIZE_SHIFT)

#define OBM_FLAG_SHIFT 7
#define OBM_FLAG_MASK (1 << OBM_FLAG_SHIFT)

#define VERSION_SHIFT 7
#define VERSION_MASK (1 << VERSION_SHIFT)

#define CMI_HDR_SET_SERVICE(hdr, s_id) \
		CMI_HDR_SET(hdr->hdr_info, SVC_ID_MASK,\
			    SVC_ID_SHIFT, s_id)
#define CMI_HDR_GET_SERVICE(hdr) \
		((hdr->hdr_info >> SVC_ID_SHIFT) & \
			(SVC_ID_MASK >> SVC_ID_SHIFT))


#define CMI_HDR_SET_SESSION(hdr, s_id) \
		CMI_HDR_SET(hdr->hdr_info, SESSION_ID_MASK,\
			    SESSION_ID_SHIFT, s_id)

#define CMI_HDR_GET_SESSION_ID(hdr) \
		((hdr->hdr_info >> SESSION_ID_SHIFT) & \
			 (SESSION_ID_MASK >> SESSION_ID_SHIFT))

#define CMI_GET_HEADER(msg)	((struct cmi_hdr *)(msg))
#define CMI_GET_PAYLOAD(msg)	((void *)(CMI_GET_HEADER(msg) + 1))
#define CMI_GET_OPCODE(msg)	(CMI_GET_HEADER(msg)->opcode)

#define CMI_HDR_SET_VERSION(hdr, ver) \
		CMI_HDR_SET(hdr->hdr_info, VERSION_MASK, \
				VERSION_SHIFT, ver)

#define CMI_HDR_SET_PAYLOAD_SIZE(hdr, p_size) \
		CMI_HDR_SET(hdr->pld_info, PAYLD_SIZE_MASK, \
			    PAYLD_SIZE_SHIFT, p_size)

#define CMI_HDR_GET_PAYLOAD_SIZE(hdr) \
		((hdr->pld_info >> PAYLD_SIZE_SHIFT) & \
			(PAYLD_SIZE_MASK >> PAYLD_SIZE_SHIFT))

#define CMI_HDR_SET_OBM(hdr, obm_flag) \
		CMI_HDR_SET(hdr->pld_info, OBM_FLAG_MASK, \
			    OBM_FLAG_SHIFT, obm_flag)

#define CMI_HDR_GET_OBM_FLAG(hdr) \
	((hdr->pld_info >> OBM_FLAG_SHIFT) & \
		(OBM_FLAG_MASK >> OBM_FLAG_SHIFT))

struct cmi_hdr {
	/*
	 * bits 0:3 is session id
	 * bits 4:6 is service id
	 * bit 7 is the version flag
	 */
	u8 hdr_info;

	/*
	 * bits 0:6 is payload size in case of in-band message
	 * bits 0:6 is size (OBM message size)
	 * bit 7 is the OBM flag
	 */
	u8 pld_info;

	/* 16 bit command opcode */
	u16 opcode;
} __packed;

union cpe_addr {
	u64 msw_lsw;
	void *kvaddr;
} __packed;

struct cmi_obm {
	u32 version;
	u32 size;
	union cpe_addr data_ptr;
	u32 mem_handle;
} __packed;

struct cmi_obm_msg {
	struct cmi_hdr hdr;
	struct cmi_obm pld;
} __packed;

struct cmi_core_svc_event_system_boot {
	u8 status;
} __packed;

struct cmi_core_svc_cmd_shared_mem_alloc {
	u32 size;
} __packed;

struct cmi_core_svc_cmdrsp_shared_mem_alloc {
	u32 addr;
} __packed;

struct cmi_msg_transport {
	u32 size;
	u32 addr;
} __packed;

struct cpe_lsm_cmd_open_tx {
	struct cmi_hdr	hdr;
	u16 app_id;
	u16 reserved;
	u32 sampling_rate;
} __packed;

struct cpe_cmd_shmem_alloc {
	struct cmi_hdr hdr;
	u32 size;
} __packed;

struct cpe_cmdrsp_shmem_alloc {
	struct cmi_hdr hdr;
	u32 addr;
} __packed;

struct cpe_cmd_shmem_dealloc {
	struct cmi_hdr	hdr;
	u32 addr;
} __packed;

struct cpe_lsm_event_detect_v2 {
	struct cmi_hdr	hdr;
	u8 detection_status;
	u8 size;
	u8 payload[0];
} __packed;

struct cpe_param_data {
	u32 module_id;
	u32 param_id;
	u16 param_size;
	u16 reserved;
} __packed;

struct cpe_afe_hw_mad_ctrl {
	struct cpe_param_data param;
	u32 minor_version;
	u16 mad_type;
	u16 mad_enable;
} __packed;

struct cpe_afe_port_cfg {
	struct cpe_param_data param;
	u32 minor_version;
	u16 bit_width;
	u16 num_channels;
	u32 sample_rate;
} __packed;

struct cpe_afe_params {
	struct cmi_hdr hdr;
	struct cpe_afe_hw_mad_ctrl hw_mad_ctrl;
	struct cpe_afe_port_cfg port_cfg;
};

struct cpe_lsm_operation_mode {
	struct cpe_param_data param;
	u32 minor_version;
	u16 mode;
	u16 reserved;
} __packed;

struct cpe_lsm_connect_to_port {
	struct cpe_param_data param;
	u32 minor_version;
	u16 afe_port_id;
	u16 reserved;
} __packed;

/*
 * This cannot be sent to CPE as is,
 * need to append the conf_levels dynamically
 */
struct cpe_lsm_conf_level {
	struct cmi_hdr hdr;
	struct cpe_param_data param;
	u8 num_active_models;
} __packed;

struct cpe_lsm_params {
	struct cmi_hdr hdr;
	struct cpe_lsm_operation_mode op_mode;
	struct cpe_lsm_connect_to_port connect_port;
} __packed;

#define PARAM_SIZE_LSM_OP_MODE (sizeof(struct cpe_lsm_operation_mode) - \
				sizeof(struct cpe_param_data))
#define PARAM_SIZE_LSM_CONNECT_PORT (sizeof(struct cpe_lsm_connect_to_port) - \
				sizeof(struct cpe_param_data))
#define CPE_PARAM_PAYLOAD_SIZE (sizeof(struct cpe_lsm_params) - \
				sizeof(struct cmi_hdr))
#define PARAM_SIZE_AFE_HW_MAD_CTRL (sizeof(struct cpe_afe_hw_mad_ctrl) - \
				sizeof(struct cpe_param_data))
#define PARAM_SIZE_AFE_PORT_CFG (sizeof(struct cpe_afe_port_cfg) - \
				 sizeof(struct cpe_param_data))
#define CPE_AFE_PARAM_PAYLOAD_SIZE (sizeof(struct cpe_afe_params) - \
				sizeof(struct cmi_hdr))

#define OPEN_CMD_PAYLOAD_SIZE (sizeof(struct cpe_lsm_cmd_open_tx) - \
			       sizeof(struct cmi_hdr))

#define SHMEM_ALLOC_CMD_PLD_SIZE (sizeof(struct cpe_cmd_shmem_alloc) - \
				      sizeof(struct cmi_hdr))

#define SHMEM_DEALLOC_CMD_PLD_SIZE (sizeof(struct cpe_cmd_shmem_dealloc) - \
				      sizeof(struct cmi_hdr))
#endif /* __CPE_CMI_H__ */
+4 −0
Original line number Diff line number Diff line
@@ -377,6 +377,10 @@ config SND_SOC_MSM8X10_WCD
config SND_SOC_MSM8X16_WCD
	tristate

config SND_SOC_WCD_CPE
	tristate
	default y if SND_SOC_WCD9330=y

config SND_SOC_WL1273
	tristate

+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ snd-soc-wcd9330-objs := wcd9330.o wcd9330-tables.o
snd-soc-wcd9xxx-objs := wcd9xxx-resmgr.o wcd9xxx-mbhc.o wcd9xxx-common.o
snd-soc-msm8x10-wcd-objs := msm8x10-wcd.o msm8x10-wcd-tables.o wcd9xxx-common.o
snd-soc-msm8x16-wcd-objs := msm8x16-wcd.o msm8x16-wcd-tables.o wcd-mbhc-v2.o
snd-soc-wcd-cpe-objs := wcd_cpe_services.o
snd-soc-wl1273-objs := wl1273.o
snd-soc-wm-adsp-objs := wm_adsp.o
snd-soc-wm0010-objs := wm0010.o
@@ -207,6 +208,7 @@ obj-$(CONFIG_SND_SOC_WCD9330) += snd-soc-wcd9330.o
obj-$(CONFIG_SND_SOC_MSM8X10_WCD)	+= snd-soc-msm8x10-wcd.o wcd9xxx-resmgr.o wcd9xxx-mbhc.o
obj-$(CONFIG_SND_SOC_WCD9XXX)   += snd-soc-wcd9xxx.o
obj-$(CONFIG_SND_SOC_MSM8X16_WCD)	+= snd-soc-msm8x16-wcd.o msm8916-wcd-irq.o
obj-$(CONFIG_SND_SOC_WCD_CPE) += snd-soc-wcd-cpe.o
obj-$(CONFIG_SND_SOC_WL1273)	+= snd-soc-wl1273.o
obj-$(CONFIG_SND_SOC_WM0010)	+= snd-soc-wm0010.o
obj-$(CONFIG_SND_SOC_WM1250_EV1) += snd-soc-wm1250-ev1.o
+43 −0
Original line number Diff line number Diff line
/* Copyright (c) 2014, 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 __CMI_API__
#define __CMI_API__

enum cmi_api_result {
	CMI_API_FAILED = 1,
	CMI_API_BUSY,
	CMI_API_NO_MEMORY,
	CMI_API_NOT_READY,
};

enum cmi_api_event {
	CMI_API_MSG = 1,
	CMI_API_OFFLINE,
	CMI_API_ONLINE,
	CMI_API_DEINITIALIZED,
};

struct cmi_api_notification {
	enum cmi_api_event event;
	enum cmi_api_result result;
	void *message;
};

void *cmi_register(
	void notification_callback
		(const struct cmi_api_notification *parameter),
	u32 service);
enum cmi_api_result cmi_deregister(void *reg_handle);
enum cmi_api_result cmi_send_msg(void *message);

#endif /*__CMI_API__*/
+1780 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading