Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) // Copyright(c) 2020 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) // Author: Cezary Rojewski <cezary.rojewski@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "messages.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "registers.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) int catpt_ipc_get_fw_version(struct catpt_dev *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 			     struct catpt_fw_version *version)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	union catpt_global_msg msg = CATPT_GLOBAL_MSG(GET_FW_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	struct catpt_ipc_msg request = {{0}}, reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	reply.size = sizeof(*version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	reply.data = version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	ret = catpt_dsp_send_msg(cdev, request, &reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		dev_err(cdev->dev, "get fw version failed: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) struct catpt_alloc_stream_input {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	enum catpt_path_id path_id:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	enum catpt_stream_type stream_type:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	enum catpt_format_id format_id:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u8 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct catpt_audio_format input_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct catpt_ring_info ring_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	u8 num_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	/* flex array with entries here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct catpt_memory_info persistent_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	struct catpt_memory_info scratch_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	u32 num_notifications; /* obsolete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) int catpt_ipc_alloc_stream(struct catpt_dev *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			   enum catpt_path_id path_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 			   enum catpt_stream_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 			   struct catpt_audio_format *afmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 			   struct catpt_ring_info *rinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 			   u8 num_modules,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 			   struct catpt_module_entry *modules,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 			   struct resource *persistent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			   struct resource *scratch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 			   struct catpt_stream_info *sinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	union catpt_global_msg msg = CATPT_GLOBAL_MSG(ALLOCATE_STREAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct catpt_alloc_stream_input input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct catpt_ipc_msg request, reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	size_t size, arrsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	u8 *payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	off_t off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	off = offsetof(struct catpt_alloc_stream_input, persistent_mem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	arrsz = sizeof(*modules) * num_modules;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	size = sizeof(input) + arrsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	payload = kzalloc(size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	if (!payload)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	memset(&input, 0, sizeof(input));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	input.path_id = path_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	input.stream_type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	input.format_id = CATPT_FORMAT_PCM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	input.input_format = *afmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	input.ring_info = *rinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	input.num_entries = num_modules;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	input.persistent_mem.offset = catpt_to_dsp_offset(persistent->start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	input.persistent_mem.size = resource_size(persistent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (scratch) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		input.scratch_mem.offset = catpt_to_dsp_offset(scratch->start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		input.scratch_mem.size = resource_size(scratch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	/* re-arrange the input: account for flex array 'entries' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	memcpy(payload, &input, sizeof(input));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	memmove(payload + off + arrsz, payload + off, sizeof(input) - off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	memcpy(payload + off, modules, arrsz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	request.size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	request.data = payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	reply.size = sizeof(*sinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	reply.data = sinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	ret = catpt_dsp_send_msg(cdev, request, &reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		dev_err(cdev->dev, "alloc stream type %d failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			type, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	kfree(payload);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int catpt_ipc_free_stream(struct catpt_dev *cdev, u8 stream_hw_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	union catpt_global_msg msg = CATPT_GLOBAL_MSG(FREE_STREAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct catpt_ipc_msg request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	request.size = sizeof(stream_hw_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	request.data = &stream_hw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	ret = catpt_dsp_send_msg(cdev, request, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		dev_err(cdev->dev, "free stream %d failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			stream_hw_id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) int catpt_ipc_set_device_format(struct catpt_dev *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 				struct catpt_ssp_device_format *devfmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	union catpt_global_msg msg = CATPT_GLOBAL_MSG(SET_DEVICE_FORMATS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	struct catpt_ipc_msg request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	request.size = sizeof(*devfmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	request.data = devfmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	ret = catpt_dsp_send_msg(cdev, request, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		dev_err(cdev->dev, "set device format failed: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) int catpt_ipc_enter_dxstate(struct catpt_dev *cdev, enum catpt_dx_state state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			    struct catpt_dx_context *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	union catpt_global_msg msg = CATPT_GLOBAL_MSG(ENTER_DX_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct catpt_ipc_msg request, reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	request.size = sizeof(state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	request.data = &state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	reply.size = sizeof(*context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	reply.data = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	ret = catpt_dsp_send_msg(cdev, request, &reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		dev_err(cdev->dev, "enter dx state failed: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int catpt_ipc_get_mixer_stream_info(struct catpt_dev *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 				    struct catpt_mixer_stream_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	union catpt_global_msg msg = CATPT_GLOBAL_MSG(GET_MIXER_STREAM_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	struct catpt_ipc_msg request = {{0}}, reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	reply.size = sizeof(*info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	reply.data = info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	ret = catpt_dsp_send_msg(cdev, request, &reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		dev_err(cdev->dev, "get mixer info failed: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int catpt_ipc_reset_stream(struct catpt_dev *cdev, u8 stream_hw_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	union catpt_stream_msg msg = CATPT_STREAM_MSG(RESET_STREAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	struct catpt_ipc_msg request = {{0}};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	msg.stream_hw_id = stream_hw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	ret = catpt_dsp_send_msg(cdev, request, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		dev_err(cdev->dev, "reset stream %d failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			stream_hw_id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) int catpt_ipc_pause_stream(struct catpt_dev *cdev, u8 stream_hw_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	union catpt_stream_msg msg = CATPT_STREAM_MSG(PAUSE_STREAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	struct catpt_ipc_msg request = {{0}};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	msg.stream_hw_id = stream_hw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	ret = catpt_dsp_send_msg(cdev, request, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		dev_err(cdev->dev, "pause stream %d failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			stream_hw_id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) int catpt_ipc_resume_stream(struct catpt_dev *cdev, u8 stream_hw_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	union catpt_stream_msg msg = CATPT_STREAM_MSG(RESUME_STREAM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	struct catpt_ipc_msg request = {{0}};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	msg.stream_hw_id = stream_hw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	ret = catpt_dsp_send_msg(cdev, request, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		dev_err(cdev->dev, "resume stream %d failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			stream_hw_id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct catpt_set_volume_input {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	u32 channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	u32 target_volume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	u64 curve_duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	u32 curve_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) int catpt_ipc_set_volume(struct catpt_dev *cdev, u8 stream_hw_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			 u32 channel, u32 volume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			 u32 curve_duration,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			 enum catpt_audio_curve_type curve_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	union catpt_stream_msg msg = CATPT_STAGE_MSG(SET_VOLUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	struct catpt_ipc_msg request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	struct catpt_set_volume_input input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	msg.stream_hw_id = stream_hw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	input.channel = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	input.target_volume = volume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	input.curve_duration = curve_duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	input.curve_type = curve_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	request.size = sizeof(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	request.data = &input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	ret = catpt_dsp_send_msg(cdev, request, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		dev_err(cdev->dev, "set stream %d volume failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 			stream_hw_id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) struct catpt_set_write_pos_input {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	u32 new_write_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	bool end_of_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	bool low_latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) int catpt_ipc_set_write_pos(struct catpt_dev *cdev, u8 stream_hw_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			    u32 pos, bool eob, bool ll)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	union catpt_stream_msg msg = CATPT_STAGE_MSG(SET_WRITE_POSITION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	struct catpt_ipc_msg request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	struct catpt_set_write_pos_input input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	msg.stream_hw_id = stream_hw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	input.new_write_pos = pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	input.end_of_buffer = eob;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	input.low_latency = ll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	request.size = sizeof(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	request.data = &input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	ret = catpt_dsp_send_msg(cdev, request, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		dev_err(cdev->dev, "set stream %d write pos failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 			stream_hw_id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) int catpt_ipc_mute_loopback(struct catpt_dev *cdev, u8 stream_hw_id, bool mute)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	union catpt_stream_msg msg = CATPT_STAGE_MSG(MUTE_LOOPBACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	struct catpt_ipc_msg request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	msg.stream_hw_id = stream_hw_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	request.header = msg.val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	request.size = sizeof(mute);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	request.data = &mute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	ret = catpt_dsp_send_msg(cdev, request, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		dev_err(cdev->dev, "mute loopback failed: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }