]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/staging/dream/qdsp5/adsp_lpm_verify_cmd.c
kconfig: Have streamline_config process menuconfigs too
[net-next-2.6.git] / drivers / staging / dream / qdsp5 / adsp_lpm_verify_cmd.c
CommitLineData
caff4cae
IM
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 QUALCOMM Incorporated
6 * Copyright (C) 2008 Google, Inc.
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
22int adsp_lpm_verify_cmd(struct msm_adsp_module *module,
23 unsigned int queue_id, void *cmd_data,
24 size_t cmd_size)
25{
26 uint32_t cmd_id, col_height, input_row_incr, output_row_incr,
27 input_size, output_size;
28 uint32_t size_mask = 0x0fff;
29 lpm_cmd_start *cmd;
30
31 if (queue_id != QDSP_lpmCommandQueue) {
32 printk(KERN_ERR "adsp: module %s: wrong queue id %d\n",
33 module->name, queue_id);
34 return -1;
35 }
36
37 cmd = (lpm_cmd_start *)cmd_data;
38 cmd_id = cmd->cmd_id;
39
40 if (cmd_id == LPM_CMD_START) {
41 if (cmd_size != sizeof(lpm_cmd_start)) {
42 printk(KERN_ERR "adsp: module %s: wrong size %d, expect %d\n",
43 module->name, cmd_size, sizeof(lpm_cmd_start));
44 return -1;
45 }
46 col_height = cmd->ip_data_cfg_part1 & size_mask;
47 input_row_incr = cmd->ip_data_cfg_part2 & size_mask;
48 output_row_incr = cmd->op_data_cfg_part1 & size_mask;
49 input_size = col_height * input_row_incr;
50 output_size = col_height * output_row_incr;
51 if ((cmd->ip_data_cfg_part4 && adsp_pmem_fixup(module,
52 (void **)(&cmd->ip_data_cfg_part4),
53 input_size)) ||
54 (cmd->op_data_cfg_part3 && adsp_pmem_fixup(module,
55 (void **)(&cmd->op_data_cfg_part3),
56 output_size)))
57 return -1;
58 } else if (cmd_id > 1) {
59 printk(KERN_ERR "adsp: module %s: invalid cmd_id %d\n",
60 module->name, cmd_id);
61 return -1;
62 }
63 return 0;
64}
65