s5p_mfc_intr.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * drivers/media/video/samsung/mfc5/s5p_mfc_intr.c
  3. *
  4. * C file for Samsung MFC (Multi Function Codec - FIMV) driver
  5. * This file contains functions used to wait for command completion.
  6. *
  7. * Kamil Debski, Copyright (C) 2011 Samsung Electronics Co., Ltd.
  8. * http://www.samsung.com/
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/delay.h>
  15. #include <linux/errno.h>
  16. #include <linux/io.h>
  17. #include <linux/sched.h>
  18. #include <linux/wait.h>
  19. #include "regs-mfc.h"
  20. #include "s5p_mfc_common.h"
  21. #include "s5p_mfc_debug.h"
  22. #include "s5p_mfc_intr.h"
  23. int s5p_mfc_wait_for_done_dev(struct s5p_mfc_dev *dev, int command)
  24. {
  25. int ret;
  26. ret = wait_event_interruptible_timeout(dev->queue,
  27. (dev->int_cond && (dev->int_type == command
  28. || dev->int_type == S5P_FIMV_R2H_CMD_ERR_RET)),
  29. msecs_to_jiffies(MFC_INT_TIMEOUT));
  30. if (ret == 0) {
  31. mfc_err("Interrupt (dev->int_type:%d, command:%d) timed out\n",
  32. dev->int_type, command);
  33. return 1;
  34. } else if (ret == -ERESTARTSYS) {
  35. mfc_err("Interrupted by a signal\n");
  36. return 1;
  37. }
  38. mfc_debug(1, "Finished waiting (dev->int_type:%d, command: %d)\n",
  39. dev->int_type, command);
  40. if (dev->int_type == S5P_FIMV_R2H_CMD_ERR_RET)
  41. return 1;
  42. return 0;
  43. }
  44. void s5p_mfc_clean_dev_int_flags(struct s5p_mfc_dev *dev)
  45. {
  46. dev->int_cond = 0;
  47. dev->int_type = 0;
  48. dev->int_err = 0;
  49. }
  50. int s5p_mfc_wait_for_done_ctx(struct s5p_mfc_ctx *ctx,
  51. int command, int interrupt)
  52. {
  53. int ret;
  54. if (interrupt) {
  55. ret = wait_event_interruptible_timeout(ctx->queue,
  56. (ctx->int_cond && (ctx->int_type == command
  57. || ctx->int_type == S5P_FIMV_R2H_CMD_ERR_RET)),
  58. msecs_to_jiffies(MFC_INT_TIMEOUT));
  59. } else {
  60. ret = wait_event_timeout(ctx->queue,
  61. (ctx->int_cond && (ctx->int_type == command
  62. || ctx->int_type == S5P_FIMV_R2H_CMD_ERR_RET)),
  63. msecs_to_jiffies(MFC_INT_TIMEOUT));
  64. }
  65. if (ret == 0) {
  66. mfc_err("Interrupt (ctx->int_type:%d, command:%d) timed out\n",
  67. ctx->int_type, command);
  68. return 1;
  69. } else if (ret == -ERESTARTSYS) {
  70. mfc_err("Interrupted by a signal\n");
  71. return 1;
  72. }
  73. mfc_debug(1, "Finished waiting (ctx->int_type:%d, command: %d)\n",
  74. ctx->int_type, command);
  75. if (ctx->int_type == S5P_FIMV_R2H_CMD_ERR_RET)
  76. return 1;
  77. return 0;
  78. }
  79. void s5p_mfc_clean_ctx_int_flags(struct s5p_mfc_ctx *ctx)
  80. {
  81. ctx->int_cond = 0;
  82. ctx->int_type = 0;
  83. ctx->int_err = 0;
  84. }