s5p_mfc_cmd_v6.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. s5p_mfc_hw_call(dev->mfc_ops, alloc_dev_context_buffer, dev);
  34. mfc_write(dev, dev->ctx_buf.dma, S5P_FIMV_CONTEXT_MEM_ADDR_V6);
  35. mfc_write(dev, buf_size->dev_ctx, S5P_FIMV_CONTEXT_MEM_SIZE_V6);
  36. return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_SYS_INIT_V6,
  37. &h2r_args);
  38. }
  39. static int s5p_mfc_sleep_cmd_v6(struct s5p_mfc_dev *dev)
  40. {
  41. struct s5p_mfc_cmd_args h2r_args;
  42. memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
  43. return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_SLEEP_V6,
  44. &h2r_args);
  45. }
  46. static int s5p_mfc_wakeup_cmd_v6(struct s5p_mfc_dev *dev)
  47. {
  48. struct s5p_mfc_cmd_args h2r_args;
  49. memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
  50. return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_WAKEUP_V6,
  51. &h2r_args);
  52. }
  53. /* Open a new instance and get its number */
  54. static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
  55. {
  56. struct s5p_mfc_dev *dev = ctx->dev;
  57. struct s5p_mfc_cmd_args h2r_args;
  58. int codec_type;
  59. mfc_debug(2, "Requested codec mode: %d\n", ctx->codec_mode);
  60. dev->curr_ctx = ctx->num;
  61. switch (ctx->codec_mode) {
  62. case S5P_MFC_CODEC_H264_DEC:
  63. codec_type = S5P_FIMV_CODEC_H264_DEC_V6;
  64. break;
  65. case S5P_MFC_CODEC_H264_MVC_DEC:
  66. codec_type = S5P_FIMV_CODEC_H264_MVC_DEC_V6;
  67. break;
  68. case S5P_MFC_CODEC_VC1_DEC:
  69. codec_type = S5P_FIMV_CODEC_VC1_DEC_V6;
  70. break;
  71. case S5P_MFC_CODEC_MPEG4_DEC:
  72. codec_type = S5P_FIMV_CODEC_MPEG4_DEC_V6;
  73. break;
  74. case S5P_MFC_CODEC_MPEG2_DEC:
  75. codec_type = S5P_FIMV_CODEC_MPEG2_DEC_V6;
  76. break;
  77. case S5P_MFC_CODEC_H263_DEC:
  78. codec_type = S5P_FIMV_CODEC_H263_DEC_V6;
  79. break;
  80. case S5P_MFC_CODEC_VC1RCV_DEC:
  81. codec_type = S5P_FIMV_CODEC_VC1RCV_DEC_V6;
  82. break;
  83. case S5P_MFC_CODEC_VP8_DEC:
  84. codec_type = S5P_FIMV_CODEC_VP8_DEC_V6;
  85. break;
  86. case S5P_MFC_CODEC_H264_ENC:
  87. codec_type = S5P_FIMV_CODEC_H264_ENC_V6;
  88. break;
  89. case S5P_MFC_CODEC_H264_MVC_ENC:
  90. codec_type = S5P_FIMV_CODEC_H264_MVC_ENC_V6;
  91. break;
  92. case S5P_MFC_CODEC_MPEG4_ENC:
  93. codec_type = S5P_FIMV_CODEC_MPEG4_ENC_V6;
  94. break;
  95. case S5P_MFC_CODEC_H263_ENC:
  96. codec_type = S5P_FIMV_CODEC_H263_ENC_V6;
  97. break;
  98. case S5P_MFC_CODEC_VP8_ENC:
  99. codec_type = S5P_FIMV_CODEC_VP8_ENC_V7;
  100. break;
  101. default:
  102. codec_type = S5P_FIMV_CODEC_NONE_V6;
  103. }
  104. mfc_write(dev, codec_type, S5P_FIMV_CODEC_TYPE_V6);
  105. mfc_write(dev, ctx->ctx.dma, S5P_FIMV_CONTEXT_MEM_ADDR_V6);
  106. mfc_write(dev, ctx->ctx.size, S5P_FIMV_CONTEXT_MEM_SIZE_V6);
  107. mfc_write(dev, 0, S5P_FIMV_D_CRC_CTRL_V6); /* no crc */
  108. return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_OPEN_INSTANCE_V6,
  109. &h2r_args);
  110. }
  111. /* Close instance */
  112. static int s5p_mfc_close_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
  113. {
  114. struct s5p_mfc_dev *dev = ctx->dev;
  115. struct s5p_mfc_cmd_args h2r_args;
  116. int ret = 0;
  117. dev->curr_ctx = ctx->num;
  118. if (ctx->state != MFCINST_FREE) {
  119. mfc_write(dev, ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  120. ret = s5p_mfc_cmd_host2risc_v6(dev,
  121. S5P_FIMV_H2R_CMD_CLOSE_INSTANCE_V6,
  122. &h2r_args);
  123. } else {
  124. ret = -EINVAL;
  125. }
  126. return ret;
  127. }
  128. /* Initialize cmd function pointers for MFC v6 */
  129. static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
  130. .cmd_host2risc = s5p_mfc_cmd_host2risc_v6,
  131. .sys_init_cmd = s5p_mfc_sys_init_cmd_v6,
  132. .sleep_cmd = s5p_mfc_sleep_cmd_v6,
  133. .wakeup_cmd = s5p_mfc_wakeup_cmd_v6,
  134. .open_inst_cmd = s5p_mfc_open_inst_cmd_v6,
  135. .close_inst_cmd = s5p_mfc_close_inst_cmd_v6,
  136. };
  137. struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void)
  138. {
  139. return &s5p_mfc_cmds_v6;
  140. }