s5p_mfc_opr_v6.c 53 KB

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