s5p_mfc_opr_v6.c 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893
  1. /*
  2. * drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
  3. *
  4. * Samsung MFC (Multi Function Codec - FIMV) driver
  5. * This file contains hw related functions.
  6. *
  7. * Copyright (c) 2012 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. #undef DEBUG
  15. #include <linux/delay.h>
  16. #include <linux/mm.h>
  17. #include <linux/io.h>
  18. #include <linux/jiffies.h>
  19. #include <linux/firmware.h>
  20. #include <linux/err.h>
  21. #include <linux/sched.h>
  22. #include <linux/dma-mapping.h>
  23. #include <asm/cacheflush.h>
  24. #include "s5p_mfc_common.h"
  25. #include "s5p_mfc_cmd.h"
  26. #include "s5p_mfc_intr.h"
  27. #include "s5p_mfc_pm.h"
  28. #include "s5p_mfc_debug.h"
  29. #include "s5p_mfc_opr.h"
  30. #include "s5p_mfc_opr_v6.h"
  31. /* #define S5P_MFC_DEBUG_REGWRITE */
  32. #ifdef S5P_MFC_DEBUG_REGWRITE
  33. #undef writel
  34. #define writel(v, r) \
  35. do { \
  36. pr_err("MFCWRITE(%p): %08x\n", r, (unsigned int)v); \
  37. __raw_writel(v, r); \
  38. } while (0)
  39. #endif /* S5P_MFC_DEBUG_REGWRITE */
  40. #define READL(offset) readl(dev->regs_base + (offset))
  41. #define WRITEL(data, offset) writel((data), dev->regs_base + (offset))
  42. #define OFFSETA(x) (((x) - dev->port_a) >> S5P_FIMV_MEM_OFFSET)
  43. #define OFFSETB(x) (((x) - dev->port_b) >> S5P_FIMV_MEM_OFFSET)
  44. /* Allocate temporary buffers for decoding */
  45. static int s5p_mfc_alloc_dec_temp_buffers_v6(struct s5p_mfc_ctx *ctx)
  46. {
  47. /* NOP */
  48. return 0;
  49. }
  50. /* Release temproary buffers for decoding */
  51. static void s5p_mfc_release_dec_desc_buffer_v6(struct s5p_mfc_ctx *ctx)
  52. {
  53. /* NOP */
  54. }
  55. /* Allocate codec buffers */
  56. static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
  57. {
  58. struct s5p_mfc_dev *dev = ctx->dev;
  59. unsigned int mb_width, mb_height;
  60. int ret;
  61. mb_width = MB_WIDTH(ctx->img_width);
  62. mb_height = MB_HEIGHT(ctx->img_height);
  63. if (ctx->type == MFCINST_DECODER) {
  64. mfc_debug(2, "Luma size:%d Chroma size:%d MV size:%d\n",
  65. ctx->luma_size, ctx->chroma_size, ctx->mv_size);
  66. mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count);
  67. } else if (ctx->type == MFCINST_ENCODER) {
  68. ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
  69. ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V6(mb_width, mb_height),
  70. S5P_FIMV_TMV_BUFFER_ALIGN_V6);
  71. ctx->luma_dpb_size = ALIGN((mb_width * mb_height) *
  72. S5P_FIMV_LUMA_MB_TO_PIXEL_V6,
  73. S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6);
  74. ctx->chroma_dpb_size = ALIGN((mb_width * mb_height) *
  75. S5P_FIMV_CHROMA_MB_TO_PIXEL_V6,
  76. S5P_FIMV_CHROMA_DPB_BUFFER_ALIGN_V6);
  77. ctx->me_buffer_size = ALIGN(S5P_FIMV_ME_BUFFER_SIZE_V6(
  78. ctx->img_width, ctx->img_height,
  79. mb_width, mb_height),
  80. S5P_FIMV_ME_BUFFER_ALIGN_V6);
  81. mfc_debug(2, "recon luma size: %d chroma size: %d\n",
  82. ctx->luma_dpb_size, ctx->chroma_dpb_size);
  83. } else {
  84. return -EINVAL;
  85. }
  86. /* Codecs have different memory requirements */
  87. switch (ctx->codec_mode) {
  88. case S5P_MFC_CODEC_H264_DEC:
  89. case S5P_MFC_CODEC_H264_MVC_DEC:
  90. ctx->scratch_buf_size =
  91. S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V6(
  92. mb_width,
  93. mb_height);
  94. ctx->scratch_buf_size = ALIGN(ctx->scratch_buf_size,
  95. S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
  96. ctx->bank1.size =
  97. ctx->scratch_buf_size +
  98. (ctx->mv_count * ctx->mv_size);
  99. break;
  100. case S5P_MFC_CODEC_MPEG4_DEC:
  101. ctx->scratch_buf_size =
  102. S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(
  103. mb_width,
  104. mb_height);
  105. ctx->scratch_buf_size = ALIGN(ctx->scratch_buf_size,
  106. S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
  107. ctx->bank1.size = ctx->scratch_buf_size;
  108. break;
  109. case S5P_MFC_CODEC_VC1RCV_DEC:
  110. case S5P_MFC_CODEC_VC1_DEC:
  111. ctx->scratch_buf_size =
  112. S5P_FIMV_SCRATCH_BUF_SIZE_VC1_DEC_V6(
  113. mb_width,
  114. mb_height);
  115. ctx->scratch_buf_size = ALIGN(ctx->scratch_buf_size,
  116. S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
  117. ctx->bank1.size = ctx->scratch_buf_size;
  118. break;
  119. case S5P_MFC_CODEC_MPEG2_DEC:
  120. ctx->bank1.size = 0;
  121. ctx->bank2.size = 0;
  122. break;
  123. case S5P_MFC_CODEC_H263_DEC:
  124. ctx->scratch_buf_size =
  125. S5P_FIMV_SCRATCH_BUF_SIZE_H263_DEC_V6(
  126. mb_width,
  127. mb_height);
  128. ctx->scratch_buf_size = ALIGN(ctx->scratch_buf_size,
  129. S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
  130. ctx->bank1.size = ctx->scratch_buf_size;
  131. break;
  132. case S5P_MFC_CODEC_VP8_DEC:
  133. ctx->scratch_buf_size =
  134. S5P_FIMV_SCRATCH_BUF_SIZE_VP8_DEC_V6(
  135. mb_width,
  136. mb_height);
  137. ctx->scratch_buf_size = ALIGN(ctx->scratch_buf_size,
  138. S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
  139. ctx->bank1.size = ctx->scratch_buf_size;
  140. break;
  141. case S5P_MFC_CODEC_H264_ENC:
  142. ctx->scratch_buf_size =
  143. S5P_FIMV_SCRATCH_BUF_SIZE_H264_ENC_V6(
  144. mb_width,
  145. mb_height);
  146. ctx->scratch_buf_size = ALIGN(ctx->scratch_buf_size,
  147. S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
  148. ctx->bank1.size =
  149. ctx->scratch_buf_size + ctx->tmv_buffer_size +
  150. (ctx->pb_count * (ctx->luma_dpb_size +
  151. ctx->chroma_dpb_size + ctx->me_buffer_size));
  152. ctx->bank2.size = 0;
  153. break;
  154. case S5P_MFC_CODEC_MPEG4_ENC:
  155. case S5P_MFC_CODEC_H263_ENC:
  156. ctx->scratch_buf_size =
  157. S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_ENC_V6(
  158. mb_width,
  159. mb_height);
  160. ctx->scratch_buf_size = ALIGN(ctx->scratch_buf_size,
  161. S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
  162. ctx->bank1.size =
  163. ctx->scratch_buf_size + ctx->tmv_buffer_size +
  164. (ctx->pb_count * (ctx->luma_dpb_size +
  165. ctx->chroma_dpb_size + ctx->me_buffer_size));
  166. ctx->bank2.size = 0;
  167. break;
  168. default:
  169. break;
  170. }
  171. /* Allocate only if memory from bank 1 is necessary */
  172. if (ctx->bank1.size > 0) {
  173. ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->bank1);
  174. if (ret) {
  175. mfc_err("Failed to allocate Bank1 memory\n");
  176. return ret;
  177. }
  178. BUG_ON(ctx->bank1.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1));
  179. }
  180. return 0;
  181. }
  182. /* Release buffers allocated for codec */
  183. static void s5p_mfc_release_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
  184. {
  185. s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->bank1);
  186. }
  187. /* Allocate memory for instance data buffer */
  188. static int s5p_mfc_alloc_instance_buffer_v6(struct s5p_mfc_ctx *ctx)
  189. {
  190. struct s5p_mfc_dev *dev = ctx->dev;
  191. struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
  192. int ret;
  193. mfc_debug_enter();
  194. switch (ctx->codec_mode) {
  195. case S5P_MFC_CODEC_H264_DEC:
  196. case S5P_MFC_CODEC_H264_MVC_DEC:
  197. ctx->ctx.size = buf_size->h264_dec_ctx;
  198. break;
  199. case S5P_MFC_CODEC_MPEG4_DEC:
  200. case S5P_MFC_CODEC_H263_DEC:
  201. case S5P_MFC_CODEC_VC1RCV_DEC:
  202. case S5P_MFC_CODEC_VC1_DEC:
  203. case S5P_MFC_CODEC_MPEG2_DEC:
  204. case S5P_MFC_CODEC_VP8_DEC:
  205. ctx->ctx.size = buf_size->other_dec_ctx;
  206. break;
  207. case S5P_MFC_CODEC_H264_ENC:
  208. ctx->ctx.size = buf_size->h264_enc_ctx;
  209. break;
  210. case S5P_MFC_CODEC_MPEG4_ENC:
  211. case S5P_MFC_CODEC_H263_ENC:
  212. ctx->ctx.size = buf_size->other_enc_ctx;
  213. break;
  214. default:
  215. ctx->ctx.size = 0;
  216. mfc_err("Codec type(%d) should be checked!\n", ctx->codec_mode);
  217. break;
  218. }
  219. ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->ctx);
  220. if (ret) {
  221. mfc_err("Failed to allocate instance buffer\n");
  222. return ret;
  223. }
  224. memset(ctx->ctx.virt, 0, ctx->ctx.size);
  225. wmb();
  226. mfc_debug_leave();
  227. return 0;
  228. }
  229. /* Release instance buffer */
  230. static void s5p_mfc_release_instance_buffer_v6(struct s5p_mfc_ctx *ctx)
  231. {
  232. s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->ctx);
  233. }
  234. /* Allocate context buffers for SYS_INIT */
  235. static int s5p_mfc_alloc_dev_context_buffer_v6(struct s5p_mfc_dev *dev)
  236. {
  237. struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
  238. int ret;
  239. mfc_debug_enter();
  240. dev->ctx_buf.size = buf_size->dev_ctx;
  241. ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &dev->ctx_buf);
  242. if (ret) {
  243. mfc_err("Failed to allocate device context buffer\n");
  244. return ret;
  245. }
  246. memset(dev->ctx_buf.virt, 0, buf_size->dev_ctx);
  247. wmb();
  248. mfc_debug_leave();
  249. return 0;
  250. }
  251. /* Release context buffers for SYS_INIT */
  252. static void s5p_mfc_release_dev_context_buffer_v6(struct s5p_mfc_dev *dev)
  253. {
  254. s5p_mfc_release_priv_buf(dev->mem_dev_l, &dev->ctx_buf);
  255. }
  256. static int calc_plane(int width, int height)
  257. {
  258. int mbX, mbY;
  259. mbX = DIV_ROUND_UP(width, S5P_FIMV_NUM_PIXELS_IN_MB_ROW_V6);
  260. mbY = DIV_ROUND_UP(height, S5P_FIMV_NUM_PIXELS_IN_MB_COL_V6);
  261. if (width * height < S5P_FIMV_MAX_FRAME_SIZE_V6)
  262. mbY = (mbY + 1) / 2 * 2;
  263. return (mbX * S5P_FIMV_NUM_PIXELS_IN_MB_COL_V6) *
  264. (mbY * S5P_FIMV_NUM_PIXELS_IN_MB_ROW_V6);
  265. }
  266. static void s5p_mfc_dec_calc_dpb_size_v6(struct s5p_mfc_ctx *ctx)
  267. {
  268. ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN_V6);
  269. ctx->buf_height = ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN_V6);
  270. mfc_debug(2, "SEQ Done: Movie dimensions %dx%d,\n"
  271. "buffer dimensions: %dx%d\n", ctx->img_width,
  272. ctx->img_height, ctx->buf_width, ctx->buf_height);
  273. ctx->luma_size = calc_plane(ctx->img_width, ctx->img_height);
  274. ctx->chroma_size = calc_plane(ctx->img_width, (ctx->img_height >> 1));
  275. if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC ||
  276. ctx->codec_mode == S5P_MFC_CODEC_H264_MVC_DEC) {
  277. ctx->mv_size = S5P_MFC_DEC_MV_SIZE_V6(ctx->img_width,
  278. ctx->img_height);
  279. ctx->mv_size = ALIGN(ctx->mv_size, 16);
  280. } else {
  281. ctx->mv_size = 0;
  282. }
  283. }
  284. static void s5p_mfc_enc_calc_src_size_v6(struct s5p_mfc_ctx *ctx)
  285. {
  286. unsigned int mb_width, mb_height;
  287. mb_width = MB_WIDTH(ctx->img_width);
  288. mb_height = MB_HEIGHT(ctx->img_height);
  289. ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN_V6);
  290. ctx->luma_size = ALIGN((mb_width * mb_height) * 256, 256);
  291. ctx->chroma_size = ALIGN((mb_width * mb_height) * 128, 256);
  292. }
  293. /* Set registers for decoding stream buffer */
  294. static int s5p_mfc_set_dec_stream_buffer_v6(struct s5p_mfc_ctx *ctx,
  295. int buf_addr, unsigned int start_num_byte,
  296. unsigned int strm_size)
  297. {
  298. struct s5p_mfc_dev *dev = ctx->dev;
  299. struct s5p_mfc_buf_size *buf_size = dev->variant->buf_size;
  300. mfc_debug_enter();
  301. mfc_debug(2, "inst_no: %d, buf_addr: 0x%08x,\n"
  302. "buf_size: 0x%08x (%d)\n",
  303. ctx->inst_no, buf_addr, strm_size, strm_size);
  304. WRITEL(strm_size, S5P_FIMV_D_STREAM_DATA_SIZE_V6);
  305. WRITEL(buf_addr, S5P_FIMV_D_CPB_BUFFER_ADDR_V6);
  306. WRITEL(buf_size->cpb, S5P_FIMV_D_CPB_BUFFER_SIZE_V6);
  307. WRITEL(start_num_byte, S5P_FIMV_D_CPB_BUFFER_OFFSET_V6);
  308. mfc_debug_leave();
  309. return 0;
  310. }
  311. /* Set decoding frame buffer */
  312. static int s5p_mfc_set_dec_frame_buffer_v6(struct s5p_mfc_ctx *ctx)
  313. {
  314. unsigned int frame_size, i;
  315. unsigned int frame_size_ch, frame_size_mv;
  316. struct s5p_mfc_dev *dev = ctx->dev;
  317. size_t buf_addr1;
  318. int buf_size1;
  319. int align_gap;
  320. buf_addr1 = ctx->bank1.dma;
  321. buf_size1 = ctx->bank1.size;
  322. mfc_debug(2, "Buf1: %p (%d)\n", (void *)buf_addr1, buf_size1);
  323. mfc_debug(2, "Total DPB COUNT: %d\n", ctx->total_dpb_count);
  324. mfc_debug(2, "Setting display delay to %d\n", ctx->display_delay);
  325. WRITEL(ctx->total_dpb_count, S5P_FIMV_D_NUM_DPB_V6);
  326. WRITEL(ctx->luma_size, S5P_FIMV_D_LUMA_DPB_SIZE_V6);
  327. WRITEL(ctx->chroma_size, S5P_FIMV_D_CHROMA_DPB_SIZE_V6);
  328. WRITEL(buf_addr1, S5P_FIMV_D_SCRATCH_BUFFER_ADDR_V6);
  329. WRITEL(ctx->scratch_buf_size, S5P_FIMV_D_SCRATCH_BUFFER_SIZE_V6);
  330. buf_addr1 += ctx->scratch_buf_size;
  331. buf_size1 -= ctx->scratch_buf_size;
  332. if (ctx->codec_mode == S5P_FIMV_CODEC_H264_DEC ||
  333. ctx->codec_mode == S5P_FIMV_CODEC_H264_MVC_DEC){
  334. WRITEL(ctx->mv_size, S5P_FIMV_D_MV_BUFFER_SIZE_V6);
  335. WRITEL(ctx->mv_count, S5P_FIMV_D_NUM_MV_V6);
  336. }
  337. frame_size = ctx->luma_size;
  338. frame_size_ch = ctx->chroma_size;
  339. frame_size_mv = ctx->mv_size;
  340. mfc_debug(2, "Frame size: %d ch: %d mv: %d\n",
  341. frame_size, frame_size_ch, frame_size_mv);
  342. for (i = 0; i < ctx->total_dpb_count; i++) {
  343. /* Bank2 */
  344. mfc_debug(2, "Luma %d: %x\n", i,
  345. ctx->dst_bufs[i].cookie.raw.luma);
  346. WRITEL(ctx->dst_bufs[i].cookie.raw.luma,
  347. S5P_FIMV_D_LUMA_DPB_V6 + i * 4);
  348. mfc_debug(2, "\tChroma %d: %x\n", i,
  349. ctx->dst_bufs[i].cookie.raw.chroma);
  350. WRITEL(ctx->dst_bufs[i].cookie.raw.chroma,
  351. S5P_FIMV_D_CHROMA_DPB_V6 + i * 4);
  352. }
  353. if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC ||
  354. ctx->codec_mode == S5P_MFC_CODEC_H264_MVC_DEC) {
  355. for (i = 0; i < ctx->mv_count; i++) {
  356. /* To test alignment */
  357. align_gap = buf_addr1;
  358. buf_addr1 = ALIGN(buf_addr1, 16);
  359. align_gap = buf_addr1 - align_gap;
  360. buf_size1 -= align_gap;
  361. mfc_debug(2, "\tBuf1: %x, size: %d\n",
  362. buf_addr1, buf_size1);
  363. WRITEL(buf_addr1, S5P_FIMV_D_MV_BUFFER_V6 + i * 4);
  364. buf_addr1 += frame_size_mv;
  365. buf_size1 -= frame_size_mv;
  366. }
  367. }
  368. mfc_debug(2, "Buf1: %u, buf_size1: %d (frames %d)\n",
  369. buf_addr1, buf_size1, ctx->total_dpb_count);
  370. if (buf_size1 < 0) {
  371. mfc_debug(2, "Not enough memory has been allocated.\n");
  372. return -ENOMEM;
  373. }
  374. WRITEL(ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  375. s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
  376. S5P_FIMV_CH_INIT_BUFS_V6, NULL);
  377. mfc_debug(2, "After setting buffers.\n");
  378. return 0;
  379. }
  380. /* Set registers for encoding stream buffer */
  381. static int s5p_mfc_set_enc_stream_buffer_v6(struct s5p_mfc_ctx *ctx,
  382. unsigned long addr, unsigned int size)
  383. {
  384. struct s5p_mfc_dev *dev = ctx->dev;
  385. WRITEL(addr, S5P_FIMV_E_STREAM_BUFFER_ADDR_V6); /* 16B align */
  386. WRITEL(size, S5P_FIMV_E_STREAM_BUFFER_SIZE_V6);
  387. mfc_debug(2, "stream buf addr: 0x%08lx, size: 0x%d\n",
  388. addr, size);
  389. return 0;
  390. }
  391. static void s5p_mfc_set_enc_frame_buffer_v6(struct s5p_mfc_ctx *ctx,
  392. unsigned long y_addr, unsigned long c_addr)
  393. {
  394. struct s5p_mfc_dev *dev = ctx->dev;
  395. WRITEL(y_addr, S5P_FIMV_E_SOURCE_LUMA_ADDR_V6); /* 256B align */
  396. WRITEL(c_addr, S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6);
  397. mfc_debug(2, "enc src y buf addr: 0x%08lx\n", y_addr);
  398. mfc_debug(2, "enc src c buf addr: 0x%08lx\n", c_addr);
  399. }
  400. static void s5p_mfc_get_enc_frame_buffer_v6(struct s5p_mfc_ctx *ctx,
  401. unsigned long *y_addr, unsigned long *c_addr)
  402. {
  403. struct s5p_mfc_dev *dev = ctx->dev;
  404. unsigned long enc_recon_y_addr, enc_recon_c_addr;
  405. *y_addr = READL(S5P_FIMV_E_ENCODED_SOURCE_LUMA_ADDR_V6);
  406. *c_addr = READL(S5P_FIMV_E_ENCODED_SOURCE_CHROMA_ADDR_V6);
  407. enc_recon_y_addr = READL(S5P_FIMV_E_RECON_LUMA_DPB_ADDR_V6);
  408. enc_recon_c_addr = READL(S5P_FIMV_E_RECON_CHROMA_DPB_ADDR_V6);
  409. mfc_debug(2, "recon y addr: 0x%08lx\n", enc_recon_y_addr);
  410. mfc_debug(2, "recon c addr: 0x%08lx\n", enc_recon_c_addr);
  411. }
  412. /* Set encoding ref & codec buffer */
  413. static int s5p_mfc_set_enc_ref_buffer_v6(struct s5p_mfc_ctx *ctx)
  414. {
  415. struct s5p_mfc_dev *dev = ctx->dev;
  416. size_t buf_addr1;
  417. int i, buf_size1;
  418. mfc_debug_enter();
  419. buf_addr1 = ctx->bank1.dma;
  420. buf_size1 = ctx->bank1.size;
  421. mfc_debug(2, "Buf1: %p (%d)\n", (void *)buf_addr1, buf_size1);
  422. for (i = 0; i < ctx->pb_count; i++) {
  423. WRITEL(buf_addr1, S5P_FIMV_E_LUMA_DPB_V6 + (4 * i));
  424. buf_addr1 += ctx->luma_dpb_size;
  425. WRITEL(buf_addr1, S5P_FIMV_E_CHROMA_DPB_V6 + (4 * i));
  426. buf_addr1 += ctx->chroma_dpb_size;
  427. WRITEL(buf_addr1, S5P_FIMV_E_ME_BUFFER_V6 + (4 * i));
  428. buf_addr1 += ctx->me_buffer_size;
  429. buf_size1 -= (ctx->luma_dpb_size + ctx->chroma_dpb_size +
  430. ctx->me_buffer_size);
  431. }
  432. WRITEL(buf_addr1, S5P_FIMV_E_SCRATCH_BUFFER_ADDR_V6);
  433. WRITEL(ctx->scratch_buf_size, S5P_FIMV_E_SCRATCH_BUFFER_SIZE_V6);
  434. buf_addr1 += ctx->scratch_buf_size;
  435. buf_size1 -= ctx->scratch_buf_size;
  436. WRITEL(buf_addr1, S5P_FIMV_E_TMV_BUFFER0_V6);
  437. buf_addr1 += ctx->tmv_buffer_size >> 1;
  438. WRITEL(buf_addr1, S5P_FIMV_E_TMV_BUFFER1_V6);
  439. buf_addr1 += ctx->tmv_buffer_size >> 1;
  440. buf_size1 -= ctx->tmv_buffer_size;
  441. mfc_debug(2, "Buf1: %u, buf_size1: %d (ref frames %d)\n",
  442. buf_addr1, buf_size1, ctx->pb_count);
  443. if (buf_size1 < 0) {
  444. mfc_debug(2, "Not enough memory has been allocated.\n");
  445. return -ENOMEM;
  446. }
  447. WRITEL(ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  448. s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
  449. S5P_FIMV_CH_INIT_BUFS_V6, NULL);
  450. mfc_debug_leave();
  451. return 0;
  452. }
  453. static int s5p_mfc_set_slice_mode(struct s5p_mfc_ctx *ctx)
  454. {
  455. struct s5p_mfc_dev *dev = ctx->dev;
  456. /* multi-slice control */
  457. /* multi-slice MB number or bit size */
  458. WRITEL(ctx->slice_mode, S5P_FIMV_E_MSLICE_MODE_V6);
  459. if (ctx->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) {
  460. WRITEL(ctx->slice_size.mb, S5P_FIMV_E_MSLICE_SIZE_MB_V6);
  461. } else if (ctx->slice_mode ==
  462. V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES) {
  463. WRITEL(ctx->slice_size.bits, S5P_FIMV_E_MSLICE_SIZE_BITS_V6);
  464. } else {
  465. WRITEL(0x0, S5P_FIMV_E_MSLICE_SIZE_MB_V6);
  466. WRITEL(0x0, S5P_FIMV_E_MSLICE_SIZE_BITS_V6);
  467. }
  468. return 0;
  469. }
  470. static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
  471. {
  472. struct s5p_mfc_dev *dev = ctx->dev;
  473. struct s5p_mfc_enc_params *p = &ctx->enc_params;
  474. unsigned int reg = 0;
  475. mfc_debug_enter();
  476. /* width */
  477. WRITEL(ctx->img_width, S5P_FIMV_E_FRAME_WIDTH_V6); /* 16 align */
  478. /* height */
  479. WRITEL(ctx->img_height, S5P_FIMV_E_FRAME_HEIGHT_V6); /* 16 align */
  480. /* cropped width */
  481. WRITEL(ctx->img_width, S5P_FIMV_E_CROPPED_FRAME_WIDTH_V6);
  482. /* cropped height */
  483. WRITEL(ctx->img_height, S5P_FIMV_E_CROPPED_FRAME_HEIGHT_V6);
  484. /* cropped offset */
  485. WRITEL(0x0, S5P_FIMV_E_FRAME_CROP_OFFSET_V6);
  486. /* pictype : IDR period */
  487. reg = 0;
  488. reg |= p->gop_size & 0xFFFF;
  489. WRITEL(reg, S5P_FIMV_E_GOP_CONFIG_V6);
  490. /* multi-slice control */
  491. /* multi-slice MB number or bit size */
  492. ctx->slice_mode = p->slice_mode;
  493. reg = 0;
  494. if (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) {
  495. reg |= (0x1 << 3);
  496. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  497. ctx->slice_size.mb = p->slice_mb;
  498. } else if (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES) {
  499. reg |= (0x1 << 3);
  500. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  501. ctx->slice_size.bits = p->slice_bit;
  502. } else {
  503. reg &= ~(0x1 << 3);
  504. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  505. }
  506. s5p_mfc_set_slice_mode(ctx);
  507. /* cyclic intra refresh */
  508. WRITEL(p->intra_refresh_mb, S5P_FIMV_E_IR_SIZE_V6);
  509. reg = READL(S5P_FIMV_E_ENC_OPTIONS_V6);
  510. if (p->intra_refresh_mb == 0)
  511. reg &= ~(0x1 << 4);
  512. else
  513. reg |= (0x1 << 4);
  514. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  515. /* 'NON_REFERENCE_STORE_ENABLE' for debugging */
  516. reg = READL(S5P_FIMV_E_ENC_OPTIONS_V6);
  517. reg &= ~(0x1 << 9);
  518. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  519. /* memory structure cur. frame */
  520. if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M) {
  521. /* 0: Linear, 1: 2D tiled*/
  522. reg = READL(S5P_FIMV_E_ENC_OPTIONS_V6);
  523. reg &= ~(0x1 << 7);
  524. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  525. /* 0: NV12(CbCr), 1: NV21(CrCb) */
  526. WRITEL(0x0, S5P_FIMV_PIXEL_FORMAT_V6);
  527. } else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV21M) {
  528. /* 0: Linear, 1: 2D tiled*/
  529. reg = READL(S5P_FIMV_E_ENC_OPTIONS_V6);
  530. reg &= ~(0x1 << 7);
  531. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  532. /* 0: NV12(CbCr), 1: NV21(CrCb) */
  533. WRITEL(0x1, S5P_FIMV_PIXEL_FORMAT_V6);
  534. } else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16) {
  535. /* 0: Linear, 1: 2D tiled*/
  536. reg = READL(S5P_FIMV_E_ENC_OPTIONS_V6);
  537. reg |= (0x1 << 7);
  538. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  539. /* 0: NV12(CbCr), 1: NV21(CrCb) */
  540. WRITEL(0x0, S5P_FIMV_PIXEL_FORMAT_V6);
  541. }
  542. /* memory structure recon. frame */
  543. /* 0: Linear, 1: 2D tiled */
  544. reg = READL(S5P_FIMV_E_ENC_OPTIONS_V6);
  545. reg |= (0x1 << 8);
  546. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  547. /* padding control & value */
  548. WRITEL(0x0, S5P_FIMV_E_PADDING_CTRL_V6);
  549. if (p->pad) {
  550. reg = 0;
  551. /** enable */
  552. reg |= (1 << 31);
  553. /** cr value */
  554. reg |= ((p->pad_cr & 0xFF) << 16);
  555. /** cb value */
  556. reg |= ((p->pad_cb & 0xFF) << 8);
  557. /** y value */
  558. reg |= p->pad_luma & 0xFF;
  559. WRITEL(reg, S5P_FIMV_E_PADDING_CTRL_V6);
  560. }
  561. /* rate control config. */
  562. reg = 0;
  563. /* frame-level rate control */
  564. reg |= ((p->rc_frame & 0x1) << 9);
  565. WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
  566. /* bit rate */
  567. if (p->rc_frame)
  568. WRITEL(p->rc_bitrate,
  569. S5P_FIMV_E_RC_BIT_RATE_V6);
  570. else
  571. WRITEL(1, S5P_FIMV_E_RC_BIT_RATE_V6);
  572. /* reaction coefficient */
  573. if (p->rc_frame) {
  574. if (p->rc_reaction_coeff < TIGHT_CBR_MAX) /* tight CBR */
  575. WRITEL(1, S5P_FIMV_E_RC_RPARAM_V6);
  576. else /* loose CBR */
  577. WRITEL(2, S5P_FIMV_E_RC_RPARAM_V6);
  578. }
  579. /* seq header ctrl */
  580. reg = READL(S5P_FIMV_E_ENC_OPTIONS_V6);
  581. reg &= ~(0x1 << 2);
  582. reg |= ((p->seq_hdr_mode & 0x1) << 2);
  583. /* frame skip mode */
  584. reg &= ~(0x3);
  585. reg |= (p->frame_skip_mode & 0x3);
  586. WRITEL(reg, S5P_FIMV_E_ENC_OPTIONS_V6);
  587. /* 'DROP_CONTROL_ENABLE', disable */
  588. reg = READL(S5P_FIMV_E_RC_CONFIG_V6);
  589. reg &= ~(0x1 << 10);
  590. WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
  591. /* setting for MV range [16, 256] */
  592. reg = 0;
  593. reg &= ~(0x3FFF);
  594. reg = 256;
  595. WRITEL(reg, S5P_FIMV_E_MV_HOR_RANGE_V6);
  596. reg = 0;
  597. reg &= ~(0x3FFF);
  598. reg = 256;
  599. WRITEL(reg, S5P_FIMV_E_MV_VER_RANGE_V6);
  600. WRITEL(0x0, S5P_FIMV_E_FRAME_INSERTION_V6);
  601. WRITEL(0x0, S5P_FIMV_E_ROI_BUFFER_ADDR_V6);
  602. WRITEL(0x0, S5P_FIMV_E_PARAM_CHANGE_V6);
  603. WRITEL(0x0, S5P_FIMV_E_RC_ROI_CTRL_V6);
  604. WRITEL(0x0, S5P_FIMV_E_PICTURE_TAG_V6);
  605. WRITEL(0x0, S5P_FIMV_E_BIT_COUNT_ENABLE_V6);
  606. WRITEL(0x0, S5P_FIMV_E_MAX_BIT_COUNT_V6);
  607. WRITEL(0x0, S5P_FIMV_E_MIN_BIT_COUNT_V6);
  608. WRITEL(0x0, S5P_FIMV_E_METADATA_BUFFER_ADDR_V6);
  609. WRITEL(0x0, S5P_FIMV_E_METADATA_BUFFER_SIZE_V6);
  610. mfc_debug_leave();
  611. return 0;
  612. }
  613. static int s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx)
  614. {
  615. struct s5p_mfc_dev *dev = ctx->dev;
  616. struct s5p_mfc_enc_params *p = &ctx->enc_params;
  617. struct s5p_mfc_h264_enc_params *p_h264 = &p->codec.h264;
  618. unsigned int reg = 0;
  619. int i;
  620. mfc_debug_enter();
  621. s5p_mfc_set_enc_params(ctx);
  622. /* pictype : number of B */
  623. reg = READL(S5P_FIMV_E_GOP_CONFIG_V6);
  624. reg &= ~(0x3 << 16);
  625. reg |= ((p->num_b_frame & 0x3) << 16);
  626. WRITEL(reg, S5P_FIMV_E_GOP_CONFIG_V6);
  627. /* profile & level */
  628. reg = 0;
  629. /** level */
  630. reg |= ((p_h264->level & 0xFF) << 8);
  631. /** profile - 0 ~ 3 */
  632. reg |= p_h264->profile & 0x3F;
  633. WRITEL(reg, S5P_FIMV_E_PICTURE_PROFILE_V6);
  634. /* rate control config. */
  635. reg = READL(S5P_FIMV_E_RC_CONFIG_V6);
  636. /** macroblock level rate control */
  637. reg &= ~(0x1 << 8);
  638. reg |= ((p->rc_mb & 0x1) << 8);
  639. WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
  640. /** frame QP */
  641. reg &= ~(0x3F);
  642. reg |= p_h264->rc_frame_qp & 0x3F;
  643. WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
  644. /* max & min value of QP */
  645. reg = 0;
  646. /** max QP */
  647. reg |= ((p_h264->rc_max_qp & 0x3F) << 8);
  648. /** min QP */
  649. reg |= p_h264->rc_min_qp & 0x3F;
  650. WRITEL(reg, S5P_FIMV_E_RC_QP_BOUND_V6);
  651. /* other QPs */
  652. WRITEL(0x0, S5P_FIMV_E_FIXED_PICTURE_QP_V6);
  653. if (!p->rc_frame && !p->rc_mb) {
  654. reg = 0;
  655. reg |= ((p_h264->rc_b_frame_qp & 0x3F) << 16);
  656. reg |= ((p_h264->rc_p_frame_qp & 0x3F) << 8);
  657. reg |= p_h264->rc_frame_qp & 0x3F;
  658. WRITEL(reg, S5P_FIMV_E_FIXED_PICTURE_QP_V6);
  659. }
  660. /* frame rate */
  661. if (p->rc_frame && p->rc_framerate_num && p->rc_framerate_denom) {
  662. reg = 0;
  663. reg |= ((p->rc_framerate_num & 0xFFFF) << 16);
  664. reg |= p->rc_framerate_denom & 0xFFFF;
  665. WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE_V6);
  666. }
  667. /* vbv buffer size */
  668. if (p->frame_skip_mode ==
  669. V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
  670. WRITEL(p_h264->cpb_size & 0xFFFF,
  671. S5P_FIMV_E_VBV_BUFFER_SIZE_V6);
  672. if (p->rc_frame)
  673. WRITEL(p->vbv_delay, S5P_FIMV_E_VBV_INIT_DELAY_V6);
  674. }
  675. /* interlace */
  676. reg = 0;
  677. reg |= ((p_h264->interlace & 0x1) << 3);
  678. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  679. /* height */
  680. if (p_h264->interlace) {
  681. WRITEL(ctx->img_height >> 1,
  682. S5P_FIMV_E_FRAME_HEIGHT_V6); /* 32 align */
  683. /* cropped height */
  684. WRITEL(ctx->img_height >> 1,
  685. S5P_FIMV_E_CROPPED_FRAME_HEIGHT_V6);
  686. }
  687. /* loop filter ctrl */
  688. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  689. reg &= ~(0x3 << 1);
  690. reg |= ((p_h264->loop_filter_mode & 0x3) << 1);
  691. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  692. /* loopfilter alpha offset */
  693. if (p_h264->loop_filter_alpha < 0) {
  694. reg = 0x10;
  695. reg |= (0xFF - p_h264->loop_filter_alpha) + 1;
  696. } else {
  697. reg = 0x00;
  698. reg |= (p_h264->loop_filter_alpha & 0xF);
  699. }
  700. WRITEL(reg, S5P_FIMV_E_H264_LF_ALPHA_OFFSET_V6);
  701. /* loopfilter beta offset */
  702. if (p_h264->loop_filter_beta < 0) {
  703. reg = 0x10;
  704. reg |= (0xFF - p_h264->loop_filter_beta) + 1;
  705. } else {
  706. reg = 0x00;
  707. reg |= (p_h264->loop_filter_beta & 0xF);
  708. }
  709. WRITEL(reg, S5P_FIMV_E_H264_LF_BETA_OFFSET_V6);
  710. /* entropy coding mode */
  711. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  712. reg &= ~(0x1);
  713. reg |= p_h264->entropy_mode & 0x1;
  714. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  715. /* number of ref. picture */
  716. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  717. reg &= ~(0x1 << 7);
  718. reg |= (((p_h264->num_ref_pic_4p - 1) & 0x1) << 7);
  719. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  720. /* 8x8 transform enable */
  721. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  722. reg &= ~(0x3 << 12);
  723. reg |= ((p_h264->_8x8_transform & 0x3) << 12);
  724. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  725. /* macroblock adaptive scaling features */
  726. WRITEL(0x0, S5P_FIMV_E_MB_RC_CONFIG_V6);
  727. if (p->rc_mb) {
  728. reg = 0;
  729. /** dark region */
  730. reg |= ((p_h264->rc_mb_dark & 0x1) << 3);
  731. /** smooth region */
  732. reg |= ((p_h264->rc_mb_smooth & 0x1) << 2);
  733. /** static region */
  734. reg |= ((p_h264->rc_mb_static & 0x1) << 1);
  735. /** high activity region */
  736. reg |= p_h264->rc_mb_activity & 0x1;
  737. WRITEL(reg, S5P_FIMV_E_MB_RC_CONFIG_V6);
  738. }
  739. /* aspect ratio VUI */
  740. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  741. reg &= ~(0x1 << 5);
  742. reg |= ((p_h264->vui_sar & 0x1) << 5);
  743. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  744. WRITEL(0x0, S5P_FIMV_E_ASPECT_RATIO_V6);
  745. WRITEL(0x0, S5P_FIMV_E_EXTENDED_SAR_V6);
  746. if (p_h264->vui_sar) {
  747. /* aspect ration IDC */
  748. reg = 0;
  749. reg |= p_h264->vui_sar_idc & 0xFF;
  750. WRITEL(reg, S5P_FIMV_E_ASPECT_RATIO_V6);
  751. if (p_h264->vui_sar_idc == 0xFF) {
  752. /* extended SAR */
  753. reg = 0;
  754. reg |= (p_h264->vui_ext_sar_width & 0xFFFF) << 16;
  755. reg |= p_h264->vui_ext_sar_height & 0xFFFF;
  756. WRITEL(reg, S5P_FIMV_E_EXTENDED_SAR_V6);
  757. }
  758. }
  759. /* intra picture period for H.264 open GOP */
  760. /* control */
  761. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  762. reg &= ~(0x1 << 4);
  763. reg |= ((p_h264->open_gop & 0x1) << 4);
  764. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  765. /* value */
  766. WRITEL(0x0, S5P_FIMV_E_H264_I_PERIOD_V6);
  767. if (p_h264->open_gop) {
  768. reg = 0;
  769. reg |= p_h264->open_gop_size & 0xFFFF;
  770. WRITEL(reg, S5P_FIMV_E_H264_I_PERIOD_V6);
  771. }
  772. /* 'WEIGHTED_BI_PREDICTION' for B is disable */
  773. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  774. reg &= ~(0x3 << 9);
  775. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  776. /* 'CONSTRAINED_INTRA_PRED_ENABLE' is disable */
  777. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  778. reg &= ~(0x1 << 14);
  779. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  780. /* ASO */
  781. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  782. reg &= ~(0x1 << 6);
  783. reg |= ((p_h264->aso & 0x1) << 6);
  784. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  785. /* hier qp enable */
  786. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  787. reg &= ~(0x1 << 8);
  788. reg |= ((p_h264->open_gop & 0x1) << 8);
  789. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  790. reg = 0;
  791. if (p_h264->hier_qp && p_h264->hier_qp_layer) {
  792. reg |= (p_h264->hier_qp_type & 0x1) << 0x3;
  793. reg |= p_h264->hier_qp_layer & 0x7;
  794. WRITEL(reg, S5P_FIMV_E_H264_NUM_T_LAYER_V6);
  795. /* QP value for each layer */
  796. for (i = 0; i < (p_h264->hier_qp_layer & 0x7); i++)
  797. WRITEL(p_h264->hier_qp_layer_qp[i],
  798. S5P_FIMV_E_H264_HIERARCHICAL_QP_LAYER0_V6 +
  799. i * 4);
  800. }
  801. /* number of coding layer should be zero when hierarchical is disable */
  802. WRITEL(reg, S5P_FIMV_E_H264_NUM_T_LAYER_V6);
  803. /* frame packing SEI generation */
  804. reg = READL(S5P_FIMV_E_H264_OPTIONS_V6);
  805. reg &= ~(0x1 << 25);
  806. reg |= ((p_h264->sei_frame_packing & 0x1) << 25);
  807. WRITEL(reg, S5P_FIMV_E_H264_OPTIONS_V6);
  808. if (p_h264->sei_frame_packing) {
  809. reg = 0;
  810. /** current frame0 flag */
  811. reg |= ((p_h264->sei_fp_curr_frame_0 & 0x1) << 2);
  812. /** arrangement type */
  813. reg |= p_h264->sei_fp_arrangement_type & 0x3;
  814. WRITEL(reg, S5P_FIMV_E_H264_FRAME_PACKING_SEI_INFO_V6);
  815. }
  816. if (p_h264->fmo) {
  817. switch (p_h264->fmo_map_type) {
  818. case V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_INTERLEAVED_SLICES:
  819. if (p_h264->fmo_slice_grp > 4)
  820. p_h264->fmo_slice_grp = 4;
  821. for (i = 0; i < (p_h264->fmo_slice_grp & 0xF); i++)
  822. WRITEL(p_h264->fmo_run_len[i] - 1,
  823. S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_0_V6 +
  824. i * 4);
  825. break;
  826. case V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_SCATTERED_SLICES:
  827. if (p_h264->fmo_slice_grp > 4)
  828. p_h264->fmo_slice_grp = 4;
  829. break;
  830. case V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_RASTER_SCAN:
  831. case V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_WIPE_SCAN:
  832. if (p_h264->fmo_slice_grp > 2)
  833. p_h264->fmo_slice_grp = 2;
  834. WRITEL(p_h264->fmo_chg_dir & 0x1,
  835. S5P_FIMV_E_H264_FMO_SLICE_GRP_CHANGE_DIR_V6);
  836. /* the valid range is 0 ~ number of macroblocks -1 */
  837. WRITEL(p_h264->fmo_chg_rate,
  838. S5P_FIMV_E_H264_FMO_SLICE_GRP_CHANGE_RATE_MINUS1_V6);
  839. break;
  840. default:
  841. mfc_err("Unsupported map type for FMO: %d\n",
  842. p_h264->fmo_map_type);
  843. p_h264->fmo_map_type = 0;
  844. p_h264->fmo_slice_grp = 1;
  845. break;
  846. }
  847. WRITEL(p_h264->fmo_map_type,
  848. S5P_FIMV_E_H264_FMO_SLICE_GRP_MAP_TYPE_V6);
  849. WRITEL(p_h264->fmo_slice_grp - 1,
  850. S5P_FIMV_E_H264_FMO_NUM_SLICE_GRP_MINUS1_V6);
  851. } else {
  852. WRITEL(0, S5P_FIMV_E_H264_FMO_NUM_SLICE_GRP_MINUS1_V6);
  853. }
  854. mfc_debug_leave();
  855. return 0;
  856. }
  857. static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx)
  858. {
  859. struct s5p_mfc_dev *dev = ctx->dev;
  860. struct s5p_mfc_enc_params *p = &ctx->enc_params;
  861. struct s5p_mfc_mpeg4_enc_params *p_mpeg4 = &p->codec.mpeg4;
  862. unsigned int reg = 0;
  863. mfc_debug_enter();
  864. s5p_mfc_set_enc_params(ctx);
  865. /* pictype : number of B */
  866. reg = READL(S5P_FIMV_E_GOP_CONFIG_V6);
  867. reg &= ~(0x3 << 16);
  868. reg |= ((p->num_b_frame & 0x3) << 16);
  869. WRITEL(reg, S5P_FIMV_E_GOP_CONFIG_V6);
  870. /* profile & level */
  871. reg = 0;
  872. /** level */
  873. reg |= ((p_mpeg4->level & 0xFF) << 8);
  874. /** profile - 0 ~ 1 */
  875. reg |= p_mpeg4->profile & 0x3F;
  876. WRITEL(reg, S5P_FIMV_E_PICTURE_PROFILE_V6);
  877. /* rate control config. */
  878. reg = READL(S5P_FIMV_E_RC_CONFIG_V6);
  879. /** macroblock level rate control */
  880. reg &= ~(0x1 << 8);
  881. reg |= ((p->rc_mb & 0x1) << 8);
  882. WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
  883. /** frame QP */
  884. reg &= ~(0x3F);
  885. reg |= p_mpeg4->rc_frame_qp & 0x3F;
  886. WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
  887. /* max & min value of QP */
  888. reg = 0;
  889. /** max QP */
  890. reg |= ((p_mpeg4->rc_max_qp & 0x3F) << 8);
  891. /** min QP */
  892. reg |= p_mpeg4->rc_min_qp & 0x3F;
  893. WRITEL(reg, S5P_FIMV_E_RC_QP_BOUND_V6);
  894. /* other QPs */
  895. WRITEL(0x0, S5P_FIMV_E_FIXED_PICTURE_QP_V6);
  896. if (!p->rc_frame && !p->rc_mb) {
  897. reg = 0;
  898. reg |= ((p_mpeg4->rc_b_frame_qp & 0x3F) << 16);
  899. reg |= ((p_mpeg4->rc_p_frame_qp & 0x3F) << 8);
  900. reg |= p_mpeg4->rc_frame_qp & 0x3F;
  901. WRITEL(reg, S5P_FIMV_E_FIXED_PICTURE_QP_V6);
  902. }
  903. /* frame rate */
  904. if (p->rc_frame && p->rc_framerate_num && p->rc_framerate_denom) {
  905. reg = 0;
  906. reg |= ((p->rc_framerate_num & 0xFFFF) << 16);
  907. reg |= p->rc_framerate_denom & 0xFFFF;
  908. WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE_V6);
  909. }
  910. /* vbv buffer size */
  911. if (p->frame_skip_mode ==
  912. V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
  913. WRITEL(p->vbv_size & 0xFFFF, S5P_FIMV_E_VBV_BUFFER_SIZE_V6);
  914. if (p->rc_frame)
  915. WRITEL(p->vbv_delay, S5P_FIMV_E_VBV_INIT_DELAY_V6);
  916. }
  917. /* Disable HEC */
  918. WRITEL(0x0, S5P_FIMV_E_MPEG4_OPTIONS_V6);
  919. WRITEL(0x0, S5P_FIMV_E_MPEG4_HEC_PERIOD_V6);
  920. mfc_debug_leave();
  921. return 0;
  922. }
  923. static int s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx)
  924. {
  925. struct s5p_mfc_dev *dev = ctx->dev;
  926. struct s5p_mfc_enc_params *p = &ctx->enc_params;
  927. struct s5p_mfc_mpeg4_enc_params *p_h263 = &p->codec.mpeg4;
  928. unsigned int reg = 0;
  929. mfc_debug_enter();
  930. s5p_mfc_set_enc_params(ctx);
  931. /* profile & level */
  932. reg = 0;
  933. /** profile */
  934. reg |= (0x1 << 4);
  935. WRITEL(reg, S5P_FIMV_E_PICTURE_PROFILE_V6);
  936. /* rate control config. */
  937. reg = READL(S5P_FIMV_E_RC_CONFIG_V6);
  938. /** macroblock level rate control */
  939. reg &= ~(0x1 << 8);
  940. reg |= ((p->rc_mb & 0x1) << 8);
  941. WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
  942. /** frame QP */
  943. reg &= ~(0x3F);
  944. reg |= p_h263->rc_frame_qp & 0x3F;
  945. WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
  946. /* max & min value of QP */
  947. reg = 0;
  948. /** max QP */
  949. reg |= ((p_h263->rc_max_qp & 0x3F) << 8);
  950. /** min QP */
  951. reg |= p_h263->rc_min_qp & 0x3F;
  952. WRITEL(reg, S5P_FIMV_E_RC_QP_BOUND_V6);
  953. /* other QPs */
  954. WRITEL(0x0, S5P_FIMV_E_FIXED_PICTURE_QP_V6);
  955. if (!p->rc_frame && !p->rc_mb) {
  956. reg = 0;
  957. reg |= ((p_h263->rc_b_frame_qp & 0x3F) << 16);
  958. reg |= ((p_h263->rc_p_frame_qp & 0x3F) << 8);
  959. reg |= p_h263->rc_frame_qp & 0x3F;
  960. WRITEL(reg, S5P_FIMV_E_FIXED_PICTURE_QP_V6);
  961. }
  962. /* frame rate */
  963. if (p->rc_frame && p->rc_framerate_num && p->rc_framerate_denom) {
  964. reg = 0;
  965. reg |= ((p->rc_framerate_num & 0xFFFF) << 16);
  966. reg |= p->rc_framerate_denom & 0xFFFF;
  967. WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE_V6);
  968. }
  969. /* vbv buffer size */
  970. if (p->frame_skip_mode ==
  971. V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
  972. WRITEL(p->vbv_size & 0xFFFF, S5P_FIMV_E_VBV_BUFFER_SIZE_V6);
  973. if (p->rc_frame)
  974. WRITEL(p->vbv_delay, S5P_FIMV_E_VBV_INIT_DELAY_V6);
  975. }
  976. mfc_debug_leave();
  977. return 0;
  978. }
  979. /* Initialize decoding */
  980. static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx)
  981. {
  982. struct s5p_mfc_dev *dev = ctx->dev;
  983. unsigned int reg = 0;
  984. int fmo_aso_ctrl = 0;
  985. mfc_debug_enter();
  986. mfc_debug(2, "InstNo: %d/%d\n", ctx->inst_no,
  987. S5P_FIMV_CH_SEQ_HEADER_V6);
  988. mfc_debug(2, "BUFs: %08x %08x %08x\n",
  989. READL(S5P_FIMV_D_CPB_BUFFER_ADDR_V6),
  990. READL(S5P_FIMV_D_CPB_BUFFER_ADDR_V6),
  991. READL(S5P_FIMV_D_CPB_BUFFER_ADDR_V6));
  992. /* FMO_ASO_CTRL - 0: Enable, 1: Disable */
  993. reg |= (fmo_aso_ctrl << S5P_FIMV_D_OPT_FMO_ASO_CTRL_MASK_V6);
  994. /* When user sets desplay_delay to 0,
  995. * It works as "display_delay enable" and delay set to 0.
  996. * If user wants display_delay disable, It should be
  997. * set to negative value. */
  998. if (ctx->display_delay >= 0) {
  999. reg |= (0x1 << S5P_FIMV_D_OPT_DDELAY_EN_SHIFT_V6);
  1000. WRITEL(ctx->display_delay, S5P_FIMV_D_DISPLAY_DELAY_V6);
  1001. }
  1002. /* Setup loop filter, for decoding this is only valid for MPEG4 */
  1003. if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_DEC) {
  1004. mfc_debug(2, "Set loop filter to: %d\n",
  1005. ctx->loop_filter_mpeg4);
  1006. reg |= (ctx->loop_filter_mpeg4 <<
  1007. S5P_FIMV_D_OPT_LF_CTRL_SHIFT_V6);
  1008. }
  1009. if (ctx->dst_fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)
  1010. reg |= (0x1 << S5P_FIMV_D_OPT_TILE_MODE_SHIFT_V6);
  1011. WRITEL(reg, S5P_FIMV_D_DEC_OPTIONS_V6);
  1012. /* 0: NV12(CbCr), 1: NV21(CrCb) */
  1013. if (ctx->dst_fmt->fourcc == V4L2_PIX_FMT_NV21M)
  1014. WRITEL(0x1, S5P_FIMV_PIXEL_FORMAT_V6);
  1015. else
  1016. WRITEL(0x0, S5P_FIMV_PIXEL_FORMAT_V6);
  1017. /* sei parse */
  1018. WRITEL(ctx->sei_fp_parse & 0x1, S5P_FIMV_D_SEI_ENABLE_V6);
  1019. WRITEL(ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  1020. s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
  1021. S5P_FIMV_CH_SEQ_HEADER_V6, NULL);
  1022. mfc_debug_leave();
  1023. return 0;
  1024. }
  1025. static inline void s5p_mfc_set_flush(struct s5p_mfc_ctx *ctx, int flush)
  1026. {
  1027. struct s5p_mfc_dev *dev = ctx->dev;
  1028. if (flush) {
  1029. dev->curr_ctx = ctx->num;
  1030. s5p_mfc_clean_ctx_int_flags(ctx);
  1031. WRITEL(ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  1032. s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
  1033. S5P_FIMV_H2R_CMD_FLUSH_V6, NULL);
  1034. }
  1035. }
  1036. /* Decode a single frame */
  1037. static int s5p_mfc_decode_one_frame_v6(struct s5p_mfc_ctx *ctx,
  1038. enum s5p_mfc_decode_arg last_frame)
  1039. {
  1040. struct s5p_mfc_dev *dev = ctx->dev;
  1041. WRITEL(ctx->dec_dst_flag, S5P_FIMV_D_AVAILABLE_DPB_FLAG_LOWER_V6);
  1042. WRITEL(ctx->slice_interface & 0x1, S5P_FIMV_D_SLICE_IF_ENABLE_V6);
  1043. WRITEL(ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  1044. /* Issue different commands to instance basing on whether it
  1045. * is the last frame or not. */
  1046. switch (last_frame) {
  1047. case 0:
  1048. s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
  1049. S5P_FIMV_CH_FRAME_START_V6, NULL);
  1050. break;
  1051. case 1:
  1052. s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
  1053. S5P_FIMV_CH_LAST_FRAME_V6, NULL);
  1054. break;
  1055. default:
  1056. mfc_err("Unsupported last frame arg.\n");
  1057. return -EINVAL;
  1058. }
  1059. mfc_debug(2, "Decoding a usual frame.\n");
  1060. return 0;
  1061. }
  1062. static int s5p_mfc_init_encode_v6(struct s5p_mfc_ctx *ctx)
  1063. {
  1064. struct s5p_mfc_dev *dev = ctx->dev;
  1065. if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC)
  1066. s5p_mfc_set_enc_params_h264(ctx);
  1067. else if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_ENC)
  1068. s5p_mfc_set_enc_params_mpeg4(ctx);
  1069. else if (ctx->codec_mode == S5P_MFC_CODEC_H263_ENC)
  1070. s5p_mfc_set_enc_params_h263(ctx);
  1071. else {
  1072. mfc_err("Unknown codec for encoding (%x).\n",
  1073. ctx->codec_mode);
  1074. return -EINVAL;
  1075. }
  1076. WRITEL(ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  1077. s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
  1078. S5P_FIMV_CH_SEQ_HEADER_V6, NULL);
  1079. return 0;
  1080. }
  1081. static int s5p_mfc_h264_set_aso_slice_order_v6(struct s5p_mfc_ctx *ctx)
  1082. {
  1083. struct s5p_mfc_dev *dev = ctx->dev;
  1084. struct s5p_mfc_enc_params *p = &ctx->enc_params;
  1085. struct s5p_mfc_h264_enc_params *p_h264 = &p->codec.h264;
  1086. int i;
  1087. if (p_h264->aso) {
  1088. for (i = 0; i < 8; i++)
  1089. WRITEL(p_h264->aso_slice_order[i],
  1090. S5P_FIMV_E_H264_ASO_SLICE_ORDER_0_V6 + i * 4);
  1091. }
  1092. return 0;
  1093. }
  1094. /* Encode a single frame */
  1095. static int s5p_mfc_encode_one_frame_v6(struct s5p_mfc_ctx *ctx)
  1096. {
  1097. struct s5p_mfc_dev *dev = ctx->dev;
  1098. mfc_debug(2, "++\n");
  1099. /* memory structure cur. frame */
  1100. if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC)
  1101. s5p_mfc_h264_set_aso_slice_order_v6(ctx);
  1102. s5p_mfc_set_slice_mode(ctx);
  1103. WRITEL(ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
  1104. s5p_mfc_hw_call(dev->mfc_cmds, cmd_host2risc, dev,
  1105. S5P_FIMV_CH_FRAME_START_V6, NULL);
  1106. mfc_debug(2, "--\n");
  1107. return 0;
  1108. }
  1109. static inline int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev)
  1110. {
  1111. unsigned long flags;
  1112. int new_ctx;
  1113. int cnt;
  1114. spin_lock_irqsave(&dev->condlock, flags);
  1115. mfc_debug(2, "Previous context: %d (bits %08lx)\n", dev->curr_ctx,
  1116. dev->ctx_work_bits);
  1117. new_ctx = (dev->curr_ctx + 1) % MFC_NUM_CONTEXTS;
  1118. cnt = 0;
  1119. while (!test_bit(new_ctx, &dev->ctx_work_bits)) {
  1120. new_ctx = (new_ctx + 1) % MFC_NUM_CONTEXTS;
  1121. cnt++;
  1122. if (cnt > MFC_NUM_CONTEXTS) {
  1123. /* No contexts to run */
  1124. spin_unlock_irqrestore(&dev->condlock, flags);
  1125. return -EAGAIN;
  1126. }
  1127. }
  1128. spin_unlock_irqrestore(&dev->condlock, flags);
  1129. return new_ctx;
  1130. }
  1131. static inline void s5p_mfc_run_dec_last_frames(struct s5p_mfc_ctx *ctx)
  1132. {
  1133. struct s5p_mfc_dev *dev = ctx->dev;
  1134. struct s5p_mfc_buf *temp_vb;
  1135. unsigned long flags;
  1136. spin_lock_irqsave(&dev->irqlock, flags);
  1137. /* Frames are being decoded */
  1138. if (list_empty(&ctx->src_queue)) {
  1139. mfc_debug(2, "No src buffers.\n");
  1140. spin_unlock_irqrestore(&dev->irqlock, flags);
  1141. return;
  1142. }
  1143. /* Get the next source buffer */
  1144. temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
  1145. temp_vb->flags |= MFC_BUF_FLAG_USED;
  1146. s5p_mfc_set_dec_stream_buffer_v6(ctx,
  1147. vb2_dma_contig_plane_dma_addr(temp_vb->b, 0), 0, 0);
  1148. spin_unlock_irqrestore(&dev->irqlock, flags);
  1149. dev->curr_ctx = ctx->num;
  1150. s5p_mfc_clean_ctx_int_flags(ctx);
  1151. s5p_mfc_decode_one_frame_v6(ctx, 1);
  1152. }
  1153. static inline int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx)
  1154. {
  1155. struct s5p_mfc_dev *dev = ctx->dev;
  1156. struct s5p_mfc_buf *temp_vb;
  1157. unsigned long flags;
  1158. int last_frame = 0;
  1159. if (ctx->state == MFCINST_FINISHING) {
  1160. last_frame = MFC_DEC_LAST_FRAME;
  1161. s5p_mfc_set_dec_stream_buffer_v6(ctx, 0, 0, 0);
  1162. dev->curr_ctx = ctx->num;
  1163. s5p_mfc_clean_ctx_int_flags(ctx);
  1164. s5p_mfc_decode_one_frame_v6(ctx, last_frame);
  1165. return 0;
  1166. }
  1167. spin_lock_irqsave(&dev->irqlock, flags);
  1168. /* Frames are being decoded */
  1169. if (list_empty(&ctx->src_queue)) {
  1170. mfc_debug(2, "No src buffers.\n");
  1171. spin_unlock_irqrestore(&dev->irqlock, flags);
  1172. return -EAGAIN;
  1173. }
  1174. /* Get the next source buffer */
  1175. temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
  1176. temp_vb->flags |= MFC_BUF_FLAG_USED;
  1177. s5p_mfc_set_dec_stream_buffer_v6(ctx,
  1178. vb2_dma_contig_plane_dma_addr(temp_vb->b, 0),
  1179. ctx->consumed_stream,
  1180. temp_vb->b->v4l2_planes[0].bytesused);
  1181. spin_unlock_irqrestore(&dev->irqlock, flags);
  1182. dev->curr_ctx = ctx->num;
  1183. s5p_mfc_clean_ctx_int_flags(ctx);
  1184. if (temp_vb->b->v4l2_planes[0].bytesused == 0) {
  1185. last_frame = 1;
  1186. mfc_debug(2, "Setting ctx->state to FINISHING\n");
  1187. ctx->state = MFCINST_FINISHING;
  1188. }
  1189. s5p_mfc_decode_one_frame_v6(ctx, last_frame);
  1190. return 0;
  1191. }
  1192. static inline int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
  1193. {
  1194. struct s5p_mfc_dev *dev = ctx->dev;
  1195. unsigned long flags;
  1196. struct s5p_mfc_buf *dst_mb;
  1197. struct s5p_mfc_buf *src_mb;
  1198. unsigned long src_y_addr, src_c_addr, dst_addr;
  1199. /*
  1200. unsigned int src_y_size, src_c_size;
  1201. */
  1202. unsigned int dst_size;
  1203. spin_lock_irqsave(&dev->irqlock, flags);
  1204. if (list_empty(&ctx->src_queue)) {
  1205. mfc_debug(2, "no src buffers.\n");
  1206. spin_unlock_irqrestore(&dev->irqlock, flags);
  1207. return -EAGAIN;
  1208. }
  1209. if (list_empty(&ctx->dst_queue)) {
  1210. mfc_debug(2, "no dst buffers.\n");
  1211. spin_unlock_irqrestore(&dev->irqlock, flags);
  1212. return -EAGAIN;
  1213. }
  1214. src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
  1215. src_mb->flags |= MFC_BUF_FLAG_USED;
  1216. src_y_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 0);
  1217. src_c_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 1);
  1218. mfc_debug(2, "enc src y addr: 0x%08lx\n", src_y_addr);
  1219. mfc_debug(2, "enc src c addr: 0x%08lx\n", src_c_addr);
  1220. s5p_mfc_set_enc_frame_buffer_v6(ctx, src_y_addr, src_c_addr);
  1221. dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
  1222. dst_mb->flags |= MFC_BUF_FLAG_USED;
  1223. dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0);
  1224. dst_size = vb2_plane_size(dst_mb->b, 0);
  1225. s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size);
  1226. spin_unlock_irqrestore(&dev->irqlock, flags);
  1227. dev->curr_ctx = ctx->num;
  1228. s5p_mfc_clean_ctx_int_flags(ctx);
  1229. s5p_mfc_encode_one_frame_v6(ctx);
  1230. return 0;
  1231. }
  1232. static inline void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
  1233. {
  1234. struct s5p_mfc_dev *dev = ctx->dev;
  1235. unsigned long flags;
  1236. struct s5p_mfc_buf *temp_vb;
  1237. /* Initializing decoding - parsing header */
  1238. spin_lock_irqsave(&dev->irqlock, flags);
  1239. mfc_debug(2, "Preparing to init decoding.\n");
  1240. temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
  1241. mfc_debug(2, "Header size: %d\n", temp_vb->b->v4l2_planes[0].bytesused);
  1242. s5p_mfc_set_dec_stream_buffer_v6(ctx,
  1243. vb2_dma_contig_plane_dma_addr(temp_vb->b, 0), 0,
  1244. temp_vb->b->v4l2_planes[0].bytesused);
  1245. spin_unlock_irqrestore(&dev->irqlock, flags);
  1246. dev->curr_ctx = ctx->num;
  1247. s5p_mfc_clean_ctx_int_flags(ctx);
  1248. s5p_mfc_init_decode_v6(ctx);
  1249. }
  1250. static inline void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx)
  1251. {
  1252. struct s5p_mfc_dev *dev = ctx->dev;
  1253. unsigned long flags;
  1254. struct s5p_mfc_buf *dst_mb;
  1255. unsigned long dst_addr;
  1256. unsigned int dst_size;
  1257. spin_lock_irqsave(&dev->irqlock, flags);
  1258. dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
  1259. dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0);
  1260. dst_size = vb2_plane_size(dst_mb->b, 0);
  1261. s5p_mfc_set_enc_stream_buffer_v6(ctx, dst_addr, dst_size);
  1262. spin_unlock_irqrestore(&dev->irqlock, flags);
  1263. dev->curr_ctx = ctx->num;
  1264. s5p_mfc_clean_ctx_int_flags(ctx);
  1265. s5p_mfc_init_encode_v6(ctx);
  1266. }
  1267. static inline int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
  1268. {
  1269. struct s5p_mfc_dev *dev = ctx->dev;
  1270. int ret;
  1271. /* Header was parsed now start processing
  1272. * First set the output frame buffers
  1273. * s5p_mfc_alloc_dec_buffers(ctx); */
  1274. if (ctx->capture_state != QUEUE_BUFS_MMAPED) {
  1275. mfc_err("It seems that not all destionation buffers were\n"
  1276. "mmaped.MFC requires that all destination are mmaped\n"
  1277. "before starting processing.\n");
  1278. return -EAGAIN;
  1279. }
  1280. dev->curr_ctx = ctx->num;
  1281. s5p_mfc_clean_ctx_int_flags(ctx);
  1282. ret = s5p_mfc_set_dec_frame_buffer_v6(ctx);
  1283. if (ret) {
  1284. mfc_err("Failed to alloc frame mem.\n");
  1285. ctx->state = MFCINST_ERROR;
  1286. }
  1287. return ret;
  1288. }
  1289. static inline int s5p_mfc_run_init_enc_buffers(struct s5p_mfc_ctx *ctx)
  1290. {
  1291. struct s5p_mfc_dev *dev = ctx->dev;
  1292. int ret;
  1293. dev->curr_ctx = ctx->num;
  1294. s5p_mfc_clean_ctx_int_flags(ctx);
  1295. ret = s5p_mfc_set_enc_ref_buffer_v6(ctx);
  1296. if (ret) {
  1297. mfc_err("Failed to alloc frame mem.\n");
  1298. ctx->state = MFCINST_ERROR;
  1299. }
  1300. return ret;
  1301. }
  1302. /* Try running an operation on hardware */
  1303. static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)
  1304. {
  1305. struct s5p_mfc_ctx *ctx;
  1306. int new_ctx;
  1307. unsigned int ret = 0;
  1308. mfc_debug(1, "Try run dev: %p\n", dev);
  1309. /* Check whether hardware is not running */
  1310. if (test_and_set_bit(0, &dev->hw_lock) != 0) {
  1311. /* This is perfectly ok, the scheduled ctx should wait */
  1312. mfc_debug(1, "Couldn't lock HW.\n");
  1313. return;
  1314. }
  1315. /* Choose the context to run */
  1316. new_ctx = s5p_mfc_get_new_ctx(dev);
  1317. if (new_ctx < 0) {
  1318. /* No contexts to run */
  1319. if (test_and_clear_bit(0, &dev->hw_lock) == 0) {
  1320. mfc_err("Failed to unlock hardware.\n");
  1321. return;
  1322. }
  1323. mfc_debug(1, "No ctx is scheduled to be run.\n");
  1324. return;
  1325. }
  1326. mfc_debug(1, "New context: %d\n", new_ctx);
  1327. ctx = dev->ctx[new_ctx];
  1328. mfc_debug(1, "Seting new context to %p\n", ctx);
  1329. /* Got context to run in ctx */
  1330. mfc_debug(1, "ctx->dst_queue_cnt=%d ctx->dpb_count=%d ctx->src_queue_cnt=%d\n",
  1331. ctx->dst_queue_cnt, ctx->pb_count, ctx->src_queue_cnt);
  1332. mfc_debug(1, "ctx->state=%d\n", ctx->state);
  1333. /* Last frame has already been sent to MFC
  1334. * Now obtaining frames from MFC buffer */
  1335. s5p_mfc_clock_on();
  1336. if (ctx->type == MFCINST_DECODER) {
  1337. switch (ctx->state) {
  1338. case MFCINST_FINISHING:
  1339. s5p_mfc_run_dec_last_frames(ctx);
  1340. break;
  1341. case MFCINST_RUNNING:
  1342. ret = s5p_mfc_run_dec_frame(ctx);
  1343. break;
  1344. case MFCINST_INIT:
  1345. s5p_mfc_clean_ctx_int_flags(ctx);
  1346. ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd,
  1347. ctx);
  1348. break;
  1349. case MFCINST_RETURN_INST:
  1350. s5p_mfc_clean_ctx_int_flags(ctx);
  1351. ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd,
  1352. ctx);
  1353. break;
  1354. case MFCINST_GOT_INST:
  1355. s5p_mfc_run_init_dec(ctx);
  1356. break;
  1357. case MFCINST_HEAD_PARSED:
  1358. ret = s5p_mfc_run_init_dec_buffers(ctx);
  1359. break;
  1360. case MFCINST_FLUSH:
  1361. s5p_mfc_set_flush(ctx, ctx->dpb_flush_flag);
  1362. break;
  1363. case MFCINST_RES_CHANGE_INIT:
  1364. s5p_mfc_run_dec_last_frames(ctx);
  1365. break;
  1366. case MFCINST_RES_CHANGE_FLUSH:
  1367. s5p_mfc_run_dec_last_frames(ctx);
  1368. break;
  1369. case MFCINST_RES_CHANGE_END:
  1370. mfc_debug(2, "Finished remaining frames after resolution change.\n");
  1371. ctx->capture_state = QUEUE_FREE;
  1372. mfc_debug(2, "Will re-init the codec`.\n");
  1373. s5p_mfc_run_init_dec(ctx);
  1374. break;
  1375. default:
  1376. ret = -EAGAIN;
  1377. }
  1378. } else if (ctx->type == MFCINST_ENCODER) {
  1379. switch (ctx->state) {
  1380. case MFCINST_FINISHING:
  1381. case MFCINST_RUNNING:
  1382. ret = s5p_mfc_run_enc_frame(ctx);
  1383. break;
  1384. case MFCINST_INIT:
  1385. ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd,
  1386. ctx);
  1387. break;
  1388. case MFCINST_RETURN_INST:
  1389. ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd,
  1390. ctx);
  1391. break;
  1392. case MFCINST_GOT_INST:
  1393. s5p_mfc_run_init_enc(ctx);
  1394. break;
  1395. case MFCINST_HEAD_PRODUCED:
  1396. ret = s5p_mfc_run_init_enc_buffers(ctx);
  1397. break;
  1398. default:
  1399. ret = -EAGAIN;
  1400. }
  1401. } else {
  1402. mfc_err("invalid context type: %d\n", ctx->type);
  1403. ret = -EAGAIN;
  1404. }
  1405. if (ret) {
  1406. /* Free hardware lock */
  1407. if (test_and_clear_bit(0, &dev->hw_lock) == 0)
  1408. mfc_err("Failed to unlock hardware.\n");
  1409. /* This is in deed imporant, as no operation has been
  1410. * scheduled, reduce the clock count as no one will
  1411. * ever do this, because no interrupt related to this try_run
  1412. * will ever come from hardware. */
  1413. s5p_mfc_clock_off();
  1414. }
  1415. }
  1416. static void s5p_mfc_cleanup_queue_v6(struct list_head *lh, struct vb2_queue *vq)
  1417. {
  1418. struct s5p_mfc_buf *b;
  1419. int i;
  1420. while (!list_empty(lh)) {
  1421. b = list_entry(lh->next, struct s5p_mfc_buf, list);
  1422. for (i = 0; i < b->b->num_planes; i++)
  1423. vb2_set_plane_payload(b->b, i, 0);
  1424. vb2_buffer_done(b->b, VB2_BUF_STATE_ERROR);
  1425. list_del(&b->list);
  1426. }
  1427. }
  1428. static void s5p_mfc_clear_int_flags_v6(struct s5p_mfc_dev *dev)
  1429. {
  1430. mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6);
  1431. mfc_write(dev, 0, S5P_FIMV_RISC2HOST_INT_V6);
  1432. }
  1433. static void s5p_mfc_write_info_v6(struct s5p_mfc_ctx *ctx, unsigned int data,
  1434. unsigned int ofs)
  1435. {
  1436. struct s5p_mfc_dev *dev = ctx->dev;
  1437. s5p_mfc_clock_on();
  1438. WRITEL(data, ofs);
  1439. s5p_mfc_clock_off();
  1440. }
  1441. static unsigned int
  1442. s5p_mfc_read_info_v6(struct s5p_mfc_ctx *ctx, unsigned int ofs)
  1443. {
  1444. struct s5p_mfc_dev *dev = ctx->dev;
  1445. int ret;
  1446. s5p_mfc_clock_on();
  1447. ret = READL(ofs);
  1448. s5p_mfc_clock_off();
  1449. return ret;
  1450. }
  1451. static int s5p_mfc_get_dspl_y_adr_v6(struct s5p_mfc_dev *dev)
  1452. {
  1453. return mfc_read(dev, S5P_FIMV_D_DISPLAY_LUMA_ADDR_V6);
  1454. }
  1455. static int s5p_mfc_get_dec_y_adr_v6(struct s5p_mfc_dev *dev)
  1456. {
  1457. return mfc_read(dev, S5P_FIMV_D_DECODED_LUMA_ADDR_V6);
  1458. }
  1459. static int s5p_mfc_get_dspl_status_v6(struct s5p_mfc_dev *dev)
  1460. {
  1461. return mfc_read(dev, S5P_FIMV_D_DISPLAY_STATUS_V6);
  1462. }
  1463. static int s5p_mfc_get_dec_status_v6(struct s5p_mfc_dev *dev)
  1464. {
  1465. return mfc_read(dev, S5P_FIMV_D_DECODED_STATUS_V6);
  1466. }
  1467. static int s5p_mfc_get_dec_frame_type_v6(struct s5p_mfc_dev *dev)
  1468. {
  1469. return mfc_read(dev, S5P_FIMV_D_DECODED_FRAME_TYPE_V6) &
  1470. S5P_FIMV_DECODE_FRAME_MASK_V6;
  1471. }
  1472. static int s5p_mfc_get_disp_frame_type_v6(struct s5p_mfc_ctx *ctx)
  1473. {
  1474. return mfc_read(ctx->dev, S5P_FIMV_D_DISPLAY_FRAME_TYPE_V6) &
  1475. S5P_FIMV_DECODE_FRAME_MASK_V6;
  1476. }
  1477. static int s5p_mfc_get_consumed_stream_v6(struct s5p_mfc_dev *dev)
  1478. {
  1479. return mfc_read(dev, S5P_FIMV_D_DECODED_NAL_SIZE_V6);
  1480. }
  1481. static int s5p_mfc_get_int_reason_v6(struct s5p_mfc_dev *dev)
  1482. {
  1483. return mfc_read(dev, S5P_FIMV_RISC2HOST_CMD_V6) &
  1484. S5P_FIMV_RISC2HOST_CMD_MASK;
  1485. }
  1486. static int s5p_mfc_get_int_err_v6(struct s5p_mfc_dev *dev)
  1487. {
  1488. return mfc_read(dev, S5P_FIMV_ERROR_CODE_V6);
  1489. }
  1490. static int s5p_mfc_err_dec_v6(unsigned int err)
  1491. {
  1492. return (err & S5P_FIMV_ERR_DEC_MASK_V6) >> S5P_FIMV_ERR_DEC_SHIFT_V6;
  1493. }
  1494. static int s5p_mfc_err_dspl_v6(unsigned int err)
  1495. {
  1496. return (err & S5P_FIMV_ERR_DSPL_MASK_V6) >> S5P_FIMV_ERR_DSPL_SHIFT_V6;
  1497. }
  1498. static int s5p_mfc_get_img_width_v6(struct s5p_mfc_dev *dev)
  1499. {
  1500. return mfc_read(dev, S5P_FIMV_D_DISPLAY_FRAME_WIDTH_V6);
  1501. }
  1502. static int s5p_mfc_get_img_height_v6(struct s5p_mfc_dev *dev)
  1503. {
  1504. return mfc_read(dev, S5P_FIMV_D_DISPLAY_FRAME_HEIGHT_V6);
  1505. }
  1506. static int s5p_mfc_get_dpb_count_v6(struct s5p_mfc_dev *dev)
  1507. {
  1508. return mfc_read(dev, S5P_FIMV_D_MIN_NUM_DPB_V6);
  1509. }
  1510. static int s5p_mfc_get_mv_count_v6(struct s5p_mfc_dev *dev)
  1511. {
  1512. return mfc_read(dev, S5P_FIMV_D_MIN_NUM_MV_V6);
  1513. }
  1514. static int s5p_mfc_get_inst_no_v6(struct s5p_mfc_dev *dev)
  1515. {
  1516. return mfc_read(dev, S5P_FIMV_RET_INSTANCE_ID_V6);
  1517. }
  1518. static int s5p_mfc_get_enc_dpb_count_v6(struct s5p_mfc_dev *dev)
  1519. {
  1520. return mfc_read(dev, S5P_FIMV_E_NUM_DPB_V6);
  1521. }
  1522. static int s5p_mfc_get_enc_strm_size_v6(struct s5p_mfc_dev *dev)
  1523. {
  1524. return mfc_read(dev, S5P_FIMV_E_STREAM_SIZE_V6);
  1525. }
  1526. static int s5p_mfc_get_enc_slice_type_v6(struct s5p_mfc_dev *dev)
  1527. {
  1528. return mfc_read(dev, S5P_FIMV_E_SLICE_TYPE_V6);
  1529. }
  1530. static int s5p_mfc_get_enc_pic_count_v6(struct s5p_mfc_dev *dev)
  1531. {
  1532. return mfc_read(dev, S5P_FIMV_E_PICTURE_COUNT_V6);
  1533. }
  1534. static int s5p_mfc_get_sei_avail_status_v6(struct s5p_mfc_ctx *ctx)
  1535. {
  1536. return mfc_read(ctx->dev, S5P_FIMV_D_FRAME_PACK_SEI_AVAIL_V6);
  1537. }
  1538. static int s5p_mfc_get_mvc_num_views_v6(struct s5p_mfc_dev *dev)
  1539. {
  1540. return mfc_read(dev, S5P_FIMV_D_MVC_NUM_VIEWS_V6);
  1541. }
  1542. static int s5p_mfc_get_mvc_view_id_v6(struct s5p_mfc_dev *dev)
  1543. {
  1544. return mfc_read(dev, S5P_FIMV_D_MVC_VIEW_ID_V6);
  1545. }
  1546. static unsigned int s5p_mfc_get_pic_type_top_v6(struct s5p_mfc_ctx *ctx)
  1547. {
  1548. return s5p_mfc_read_info_v6(ctx, PIC_TIME_TOP_V6);
  1549. }
  1550. static unsigned int s5p_mfc_get_pic_type_bot_v6(struct s5p_mfc_ctx *ctx)
  1551. {
  1552. return s5p_mfc_read_info_v6(ctx, PIC_TIME_BOT_V6);
  1553. }
  1554. static unsigned int s5p_mfc_get_crop_info_h_v6(struct s5p_mfc_ctx *ctx)
  1555. {
  1556. return s5p_mfc_read_info_v6(ctx, CROP_INFO_H_V6);
  1557. }
  1558. static unsigned int s5p_mfc_get_crop_info_v_v6(struct s5p_mfc_ctx *ctx)
  1559. {
  1560. return s5p_mfc_read_info_v6(ctx, CROP_INFO_V_V6);
  1561. }
  1562. /* Initialize opr function pointers for MFC v6 */
  1563. static struct s5p_mfc_hw_ops s5p_mfc_ops_v6 = {
  1564. .alloc_dec_temp_buffers = s5p_mfc_alloc_dec_temp_buffers_v6,
  1565. .release_dec_desc_buffer = s5p_mfc_release_dec_desc_buffer_v6,
  1566. .alloc_codec_buffers = s5p_mfc_alloc_codec_buffers_v6,
  1567. .release_codec_buffers = s5p_mfc_release_codec_buffers_v6,
  1568. .alloc_instance_buffer = s5p_mfc_alloc_instance_buffer_v6,
  1569. .release_instance_buffer = s5p_mfc_release_instance_buffer_v6,
  1570. .alloc_dev_context_buffer =
  1571. s5p_mfc_alloc_dev_context_buffer_v6,
  1572. .release_dev_context_buffer =
  1573. s5p_mfc_release_dev_context_buffer_v6,
  1574. .dec_calc_dpb_size = s5p_mfc_dec_calc_dpb_size_v6,
  1575. .enc_calc_src_size = s5p_mfc_enc_calc_src_size_v6,
  1576. .set_dec_stream_buffer = s5p_mfc_set_dec_stream_buffer_v6,
  1577. .set_dec_frame_buffer = s5p_mfc_set_dec_frame_buffer_v6,
  1578. .set_enc_stream_buffer = s5p_mfc_set_enc_stream_buffer_v6,
  1579. .set_enc_frame_buffer = s5p_mfc_set_enc_frame_buffer_v6,
  1580. .get_enc_frame_buffer = s5p_mfc_get_enc_frame_buffer_v6,
  1581. .set_enc_ref_buffer = s5p_mfc_set_enc_ref_buffer_v6,
  1582. .init_decode = s5p_mfc_init_decode_v6,
  1583. .init_encode = s5p_mfc_init_encode_v6,
  1584. .encode_one_frame = s5p_mfc_encode_one_frame_v6,
  1585. .try_run = s5p_mfc_try_run_v6,
  1586. .cleanup_queue = s5p_mfc_cleanup_queue_v6,
  1587. .clear_int_flags = s5p_mfc_clear_int_flags_v6,
  1588. .write_info = s5p_mfc_write_info_v6,
  1589. .read_info = s5p_mfc_read_info_v6,
  1590. .get_dspl_y_adr = s5p_mfc_get_dspl_y_adr_v6,
  1591. .get_dec_y_adr = s5p_mfc_get_dec_y_adr_v6,
  1592. .get_dspl_status = s5p_mfc_get_dspl_status_v6,
  1593. .get_dec_status = s5p_mfc_get_dec_status_v6,
  1594. .get_dec_frame_type = s5p_mfc_get_dec_frame_type_v6,
  1595. .get_disp_frame_type = s5p_mfc_get_disp_frame_type_v6,
  1596. .get_consumed_stream = s5p_mfc_get_consumed_stream_v6,
  1597. .get_int_reason = s5p_mfc_get_int_reason_v6,
  1598. .get_int_err = s5p_mfc_get_int_err_v6,
  1599. .err_dec = s5p_mfc_err_dec_v6,
  1600. .err_dspl = s5p_mfc_err_dspl_v6,
  1601. .get_img_width = s5p_mfc_get_img_width_v6,
  1602. .get_img_height = s5p_mfc_get_img_height_v6,
  1603. .get_dpb_count = s5p_mfc_get_dpb_count_v6,
  1604. .get_mv_count = s5p_mfc_get_mv_count_v6,
  1605. .get_inst_no = s5p_mfc_get_inst_no_v6,
  1606. .get_enc_strm_size = s5p_mfc_get_enc_strm_size_v6,
  1607. .get_enc_slice_type = s5p_mfc_get_enc_slice_type_v6,
  1608. .get_enc_dpb_count = s5p_mfc_get_enc_dpb_count_v6,
  1609. .get_enc_pic_count = s5p_mfc_get_enc_pic_count_v6,
  1610. .get_sei_avail_status = s5p_mfc_get_sei_avail_status_v6,
  1611. .get_mvc_num_views = s5p_mfc_get_mvc_num_views_v6,
  1612. .get_mvc_view_id = s5p_mfc_get_mvc_view_id_v6,
  1613. .get_pic_type_top = s5p_mfc_get_pic_type_top_v6,
  1614. .get_pic_type_bot = s5p_mfc_get_pic_type_bot_v6,
  1615. .get_crop_info_h = s5p_mfc_get_crop_info_h_v6,
  1616. .get_crop_info_v = s5p_mfc_get_crop_info_v_v6,
  1617. };
  1618. struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v6(void)
  1619. {
  1620. return &s5p_mfc_ops_v6;
  1621. }