/arch/arm/mach-msm/qdsp5/adsp_lpm_verify_cmd.c

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase · C · 66 lines · 43 code · 6 blank · 17 comment · 11 complexity · a1e218441a69008bb023ce4c395c267e MD5 · raw file

  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. #include <mach/qdsp5/qdsp5lpmcmdi.h>
  19. #include "adsp.h"
  20. #include <mach/debug_mm.h>
  21. int adsp_lpm_verify_cmd(struct msm_adsp_module *module,
  22. unsigned int queue_id, void *cmd_data,
  23. size_t cmd_size)
  24. {
  25. uint32_t cmd_id, col_height, input_row_incr, output_row_incr,
  26. input_size, output_size;
  27. uint32_t size_mask = 0x0fff;
  28. lpm_cmd_start *cmd;
  29. if (queue_id != QDSP_lpmCommandQueue) {
  30. MM_ERR("module %s: wrong queue id %d\n",
  31. module->name, queue_id);
  32. return -1;
  33. }
  34. cmd = (lpm_cmd_start *)cmd_data;
  35. cmd_id = cmd->cmd_id;
  36. if (cmd_id == LPM_CMD_START) {
  37. if (cmd_size != sizeof(lpm_cmd_start)) {
  38. MM_ERR("module %s: wrong size %d, \
  39. expect %d\n", module->name,
  40. cmd_size, sizeof(lpm_cmd_start));
  41. return -1;
  42. }
  43. col_height = cmd->ip_data_cfg_part1 & size_mask;
  44. input_row_incr = cmd->ip_data_cfg_part2 & size_mask;
  45. output_row_incr = cmd->op_data_cfg_part1 & size_mask;
  46. input_size = col_height * input_row_incr;
  47. output_size = col_height * output_row_incr;
  48. if ((cmd->ip_data_cfg_part4 && adsp_pmem_fixup(module,
  49. (void **)(&cmd->ip_data_cfg_part4),
  50. input_size)) ||
  51. (cmd->op_data_cfg_part3 && adsp_pmem_fixup(module,
  52. (void **)(&cmd->op_data_cfg_part3),
  53. output_size)))
  54. return -1;
  55. } else if (cmd_id > 1) {
  56. MM_ERR("module %s: invalid cmd_id %d\n", module->name, cmd_id);
  57. return -1;
  58. }
  59. return 0;
  60. }