s5p_mfc_cmd_v6.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * linux/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
  3. *
  4. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  5. * http://www.samsung.com/
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include "s5p_mfc_common.h"
  13. #include "s5p_mfc_cmd.h"
  14. #include "s5p_mfc_debug.h"
  15. #include "s5p_mfc_intr.h"
  16. #include "s5p_mfc_opr.h"
  17. #include "s5p_mfc_cmd_v6.h"
  18. static int s5p_mfc_cmd_host2risc_v6(struct s5p_mfc_dev *dev, int cmd,
  19. struct s5p_mfc_cmd_args *args)
  20. {
  21. mfc_debug(2, "Issue the command: %d\n", cmd);
  22. /* Reset RISC2HOST command */
  23. mfc_write(dev, 0x0, S5P_FIMV_RISC2HOST_CMD_V6);
  24. /* Issue the command */
  25. mfc_write(dev, cmd, S5P_FIMV_HOST2RISC_CMD_V6);
  26. mfc_write(dev, 0x1, S5P_FIMV_HOST2RISC_INT_V6);
  27. return 0;
  28. }
  29. static int s5p_mfc_sys_init_cmd_v6(struct s5p_mfc_dev *dev)
  30. {
  31. struct s5p_mfc_cmd_args h2r_args;
  32. struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
  33. int ret;
  34. ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_dev_context_buffer, dev);
  35. if (ret)
  36. return ret;
  37. mfc_write(dev, dev->ctx_buf.dma, S5P_FIMV_CONTEXT_MEM_ADDR_V6);
  38. mfc_write(dev, buf_size->dev_ctx, S5P_FIMV_CONTEXT_MEM_SIZE_V6);
  39. return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_SYS_INIT_V6,
  40. &h2r_args);
  41. }
  42. static int s5p_mfc_sleep_cmd_v6(struct s5p_mfc_dev *dev)
  43. {
  44. struct s5p_mfc_cmd_args h2r_args;
  45. memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
  46. return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_SLEEP_V6,
  47. &h2r_args);
  48. }
  49. static int s5p_mfc_wakeup_cmd_v6(struct s5p_mfc_dev *dev)
  50. {
  51. struct s5p_mfc_cmd_args h2r_args;
  52. memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
  53. return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_WAKEUP_V6,
  54. &h2r_args);
  55. }
  56. /* Open a new instance and get its number */
  57. static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
  58. {
  59. struct s5p_mfc_dev *dev = ctx->dev;
  60. struct s5p_mfc_cmd_args h2r_args;
  61. int codec_type;
  62. mfc_debug(2, "Requested codec mode: %d\n", ctx->codec_mode);
  63. dev->curr_ctx = ctx->num;
  64. switch (ctx->codec_mode) {
  65. case S5P_MFC_CODEC_H264_DEC:
  66. codec_type = S5P_FIMV_CODEC_H264_DEC_V6;
  67. break;
  68. case S5P_MFC_CODEC_H264_MVC_DEC:
  69. codec_type = S5P_FIMV_CODEC_H264_MVC_DEC_V6;
  70. break;
  71. case S5P_MFC_CODEC_VC1_DEC:
  72. codec_type = S5P_FIMV_CODEC_VC1_DEC_V6;
  73. break;
  74. case S5P_MFC_CODEC_MPEG4_DEC:
  75. codec_type = S5P_FIMV_CODEC_MPEG4_DEC_V6;
  76. break;
  77. case S5P_MFC_CODEC_MPEG2_DEC:
  78. codec_type = S5P_FIMV_CODEC_MPEG2_DEC_V6;
  79. break;
  80. case S5P_MFC_CODEC_H263_DEC:
  81. codec_type = S5P_FIMV_CODEC_H263_DEC_V6;
  82. break;
  83. case S5P_MFC_CODEC_VC1RCV_DEC:
  84. codec_type = S5P_FIMV_CODEC_VC1RCV_DEC_V6;
  85. break;
  86. case S5P_MFC_CODEC_VP8_DEC:
  87. codec_type = S5P_FIMV_CODEC_VP8_DEC_V6;
  88. break;
  89. case S5P_MFC_CODEC_H264_ENC:
  90. codec_type = S5P_FIMV_CODEC_H264_ENC_V6;
  91. break;
  92. case S5P_MFC_CODEC_H264_MVC_ENC:
  93. codec_type = S5P_FIMV_CODEC_H264_MVC_ENC_V6;
  94. break;
  95. case S5P_MFC_CODEC_MPEG4_ENC:
  96. codec_type = S5P_FIMV_CODEC_MPEG4_ENC_V6;
  97. break;
  98. case S5P_MFC_CODEC_H263_ENC:
  99. codec_type = S5P_FIMV_CODEC_H263_ENC_V6;
  100. break;
  101. case S5P_MFC_CODEC_VP8_ENC:
  102. codec_type = S5P_FIMV_CODEC_VP8_ENC_V7;
  103. break;
  104. default:
  105. codec_type = S5P_FIMV_CODEC_NONE_V6;
  106. }
  107. mfc_write(dev, codec_type, S5P_FIMV_CODEC_TYPE_V6);
  108. mfc_write(dev, ctx->ctx.dma, S5P_FIMV_CONTEXT_MEM_ADDR_V6);
  109. mfc_write(dev, ctx->ctx.size, S5P_FIMV_CONTEXT_MEM_SIZE_V6);
  110. mfc_write(dev, 0, S5P_FIMV_D_CRC_CTRL_V6); /* no crc */
  111. return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_OPEN_INSTANCE_V6,
  112. &h2r_args);
  113. }
  114. /* Close instance */
  115. static int s5p_mfc_close_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
  116. {
  117. struct s5p_mfc_dev *dev = ctx->dev;
  118. struct s5p_mfc_cmd_args h2r_args;
  119. int ret = 0;
  120. dev->curr_ctx = ctx->num;
  121. if (ctx->state != MFCINST_FREE) {
  122. mfc_write(dev, ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  123. ret = s5p_mfc_cmd_host2risc_v6(dev,
  124. S5P_FIMV_H2R_CMD_CLOSE_INSTANCE_V6,
  125. &h2r_args);
  126. } else {
  127. ret = -EINVAL;
  128. }
  129. return ret;
  130. }
  131. /* Initialize cmd function pointers for MFC v6 */
  132. static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
  133. .cmd_host2risc = s5p_mfc_cmd_host2risc_v6,
  134. .sys_init_cmd = s5p_mfc_sys_init_cmd_v6,
  135. .sleep_cmd = s5p_mfc_sleep_cmd_v6,
  136. .wakeup_cmd = s5p_mfc_wakeup_cmd_v6,
  137. .open_inst_cmd = s5p_mfc_open_inst_cmd_v6,
  138. .close_inst_cmd = s5p_mfc_close_inst_cmd_v6,
  139. };
  140. struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void)
  141. {
  142. return &s5p_mfc_cmds_v6;
  143. }