s5p_mfc_opr_v6.c 52 KB

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