/arch/arm/mach-msm/qdsp5/adsp_lpm_verify_cmd.c
C | 66 lines | 43 code | 6 blank | 17 comment | 11 complexity | a1e218441a69008bb023ce4c395c267e MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
1/* arch/arm/mach-msm/qdsp5/adsp_lpm_verify_cmd.c
2 *
3 * Verificion code for aDSP LPM packets from userspace.
4 *
5 * Copyright (C) 2008 Google, Inc.
6 * Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#include <mach/qdsp5/qdsp5lpmcmdi.h>
20#include "adsp.h"
21#include <mach/debug_mm.h>
22
23int adsp_lpm_verify_cmd(struct msm_adsp_module *module,
24 unsigned int queue_id, void *cmd_data,
25 size_t cmd_size)
26{
27 uint32_t cmd_id, col_height, input_row_incr, output_row_incr,
28 input_size, output_size;
29 uint32_t size_mask = 0x0fff;
30 lpm_cmd_start *cmd;
31
32 if (queue_id != QDSP_lpmCommandQueue) {
33 MM_ERR("module %s: wrong queue id %d\n",
34 module->name, queue_id);
35 return -1;
36 }
37
38 cmd = (lpm_cmd_start *)cmd_data;
39 cmd_id = cmd->cmd_id;
40
41 if (cmd_id == LPM_CMD_START) {
42 if (cmd_size != sizeof(lpm_cmd_start)) {
43 MM_ERR("module %s: wrong size %d, \
44 expect %d\n", module->name,
45 cmd_size, sizeof(lpm_cmd_start));
46 return -1;
47 }
48 col_height = cmd->ip_data_cfg_part1 & size_mask;
49 input_row_incr = cmd->ip_data_cfg_part2 & size_mask;
50 output_row_incr = cmd->op_data_cfg_part1 & size_mask;
51 input_size = col_height * input_row_incr;
52 output_size = col_height * output_row_incr;
53 if ((cmd->ip_data_cfg_part4 && adsp_pmem_fixup(module,
54 (void **)(&cmd->ip_data_cfg_part4),
55 input_size)) ||
56 (cmd->op_data_cfg_part3 && adsp_pmem_fixup(module,
57 (void **)(&cmd->op_data_cfg_part3),
58 output_size)))
59 return -1;
60 } else if (cmd_id > 1) {
61 MM_ERR("module %s: invalid cmd_id %d\n", module->name, cmd_id);
62 return -1;
63 }
64 return 0;
65}
66