From 840716ab55f7767d7fc3092cc739fe8e153ac55d Mon Sep 17 00:00:00 2001 From: Rohit Kumar Sindhu Date: Thu, 6 Oct 2011 16:18:37 +0100 Subject: [PATCH] intel_sst: changes for get tuning parameter interface There has been a change in SNDRV_SST_GET_ALGO ioctl interface. Earlier it only used to receive data from FW, but now it will take data from user space, send it to LPE and then get back the same buffer back from LPE. So The maximum size it will receive from LPE is the equal to the size of data which was sent to LPE. It will take data from user space exactly in similar fashion as done in SNDRV_SST_SET_ALGO ioctl. Change-Id: I3e5a5ec69569a3f287dd5ba8bc19d7587eafc665 Signed-off-by: Rohit Kumar Sindhu Signed-off-by: Vinod Koul --- .../staging/intel_sst/intel_sst_app_interface.c | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/staging/intel_sst/intel_sst_app_interface.c b/drivers/staging/intel_sst/intel_sst_app_interface.c index 25850d3..fcf2bfd 100644 --- a/drivers/staging/intel_sst/intel_sst_app_interface.c +++ b/drivers/staging/intel_sst/intel_sst_app_interface.c @@ -823,20 +823,30 @@ static void sst_print_stream_params(struct snd_sst_get_stream_params *get_prm) * @msg: post msg pointer * * This function is called to create ipc msg + * For copying the mailbox data the function returns offset in bytes to mailbox + * memory where the mailbox data should be copied after msg header */ int sst_create_algo_ipc(struct snd_ppp_params *algo_params, struct ipc_post **msg) { + u32 header_size = 0; + u32 ipc_msg_size = sizeof(u32) + sizeof(*algo_params) + - sizeof(algo_params->params) + algo_params->size; + u32 offset = 0; + + if (ipc_msg_size > SST_MAILBOX_SIZE) + return -ENOMEM; if (sst_create_large_msg(msg)) return -ENOMEM; sst_fill_header(&(*msg)->header, IPC_IA_ALG_PARAMS, 1, algo_params->str_id); - (*msg)->header.part.data = sizeof(u32) + sizeof(*algo_params) - - sizeof(algo_params->params) + algo_params->size; + (*msg)->header.part.data = ipc_msg_size; memcpy((*msg)->mailbox_data, &(*msg)->header, sizeof(u32)); - memcpy((*msg)->mailbox_data + sizeof(u32), algo_params, - sizeof(*algo_params) - sizeof(algo_params->params)); - return 0; + offset = sizeof(u32); + header_size = sizeof(*algo_params) - sizeof(algo_params->params); + memcpy((*msg)->mailbox_data + offset, algo_params, header_size); + offset += header_size; + return offset; } /** @@ -881,18 +891,15 @@ long intel_sst_ioctl_dsp(unsigned int cmd, unsigned long arg) if (copy_from_user(&algo_params, (void __user *)arg, sizeof(algo_params))) return -EFAULT; - if (algo_params.size > SST_MAILBOX_SIZE) - return -EMSGSIZE; pr_debug("Algo ID %d Str id %d Enable %d Size %d\n", algo_params.algo_id, algo_params.str_id, algo_params.enable, algo_params.size); + algo_params.reserved = 0; retval = sst_create_algo_ipc(&algo_params, &msg); - if (retval) + if (retval < 0) break; - algo_params.reserved = 0; - if (copy_from_user(msg->mailbox_data + sizeof(algo_params) - - sizeof(algo_params.params) + sizeof(u32), + if (copy_from_user(msg->mailbox_data + retval, algo_params.params, algo_params.size)) { kfree(msg); return -EFAULT; @@ -912,10 +919,16 @@ long intel_sst_ioctl_dsp(unsigned int cmd, unsigned long arg) pr_debug("Algo ID %d Str id %d Enable %d Size %d\n", algo_params.algo_id, algo_params.str_id, algo_params.enable, algo_params.size); + algo_params.reserved = 1; retval = sst_create_algo_ipc(&algo_params, &msg); - if (retval) + if (retval < 0) break; algo_params.reserved = 1; + if (copy_from_user(msg->mailbox_data + retval, + algo_params.params, algo_params.size)) { + kfree(msg); + return -EFAULT; + } retval = sst_send_algo_ipc(&msg); if (retval) { pr_debug("Error in sst_get_algo = %d\n", retval); -- 2.7.4