aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Kumar K <arun.kk@samsung.com>2012-10-03 21:19:07 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-05 21:44:40 -0400
commit77a788fc2d4089c64eb355a004f1f16b22eb3ab1 (patch)
tree57375840139518336f610247f422f5fa0094b19e
parent2e81dde94316dfaa19f0b6f9d4131ef7eaf124a3 (diff)
[media] s5p-mfc: Prepare driver for callback based re-architecture
The patch renames hardware specific opr and cmd files to opr_v5 and cmd_v5 respectively. This is done for accomodating firmware v6. Also the shared memory management files are removed and the functionality is added to the opr_v5 file. Signed-off-by: Arun Kumar K <arun.kk@samsung.com> Acked-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/platform/s5p-mfc/Makefile6
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c11
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c (renamed from drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c)2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.h (renamed from drivers/media/platform/s5p-mfc/s5p_mfc_cmd.h)0
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.c7
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c (renamed from drivers/media/platform/s5p-mfc/s5p_mfc_opr.c)103
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.h (renamed from drivers/media/platform/s5p-mfc/s5p_mfc_opr.h)70
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_shm.c47
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_shm.h90
11 files changed, 151 insertions, 189 deletions
diff --git a/drivers/media/platform/s5p-mfc/Makefile b/drivers/media/platform/s5p-mfc/Makefile
index d0663409af00..39496b806b11 100644
--- a/drivers/media/platform/s5p-mfc/Makefile
+++ b/drivers/media/platform/s5p-mfc/Makefile
@@ -1,5 +1,5 @@
1obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) := s5p-mfc.o 1obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) := s5p-mfc.o
2s5p-mfc-y += s5p_mfc.o s5p_mfc_intr.o s5p_mfc_opr.o 2s5p-mfc-y += s5p_mfc.o s5p_mfc_intr.o s5p_mfc_opr_v5.o
3s5p-mfc-y += s5p_mfc_dec.o s5p_mfc_enc.o 3s5p-mfc-y += s5p_mfc_dec.o s5p_mfc_enc.o
4s5p-mfc-y += s5p_mfc_ctrl.o s5p_mfc_cmd.o 4s5p-mfc-y += s5p_mfc_ctrl.o s5p_mfc_cmd_v5.o
5s5p-mfc-y += s5p_mfc_pm.o s5p_mfc_shm.o 5s5p-mfc-y += s5p_mfc_pm.o
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 5587ef15ca4f..74bb28482844 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -28,9 +28,8 @@
28#include "s5p_mfc_dec.h" 28#include "s5p_mfc_dec.h"
29#include "s5p_mfc_enc.h" 29#include "s5p_mfc_enc.h"
30#include "s5p_mfc_intr.h" 30#include "s5p_mfc_intr.h"
31#include "s5p_mfc_opr.h" 31#include "s5p_mfc_opr_v5.h"
32#include "s5p_mfc_pm.h" 32#include "s5p_mfc_pm.h"
33#include "s5p_mfc_shm.h"
34 33
35#define S5P_MFC_NAME "s5p-mfc" 34#define S5P_MFC_NAME "s5p-mfc"
36#define S5P_MFC_DEC_NAME "s5p-mfc-dec" 35#define S5P_MFC_DEC_NAME "s5p-mfc-dec"
@@ -213,8 +212,8 @@ static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx)
213 ctx->dst_queue_cnt--; 212 ctx->dst_queue_cnt--;
214 dst_buf->b->v4l2_buf.sequence = (ctx->sequence++); 213 dst_buf->b->v4l2_buf.sequence = (ctx->sequence++);
215 214
216 if (s5p_mfc_read_shm(ctx, PIC_TIME_TOP) == 215 if (s5p_mfc_read_info_v5(ctx, PIC_TIME_TOP) ==
217 s5p_mfc_read_shm(ctx, PIC_TIME_BOT)) 216 s5p_mfc_read_info_v5(ctx, PIC_TIME_BOT))
218 dst_buf->b->v4l2_buf.field = V4L2_FIELD_NONE; 217 dst_buf->b->v4l2_buf.field = V4L2_FIELD_NONE;
219 else 218 else
220 dst_buf->b->v4l2_buf.field = V4L2_FIELD_INTERLACED; 219 dst_buf->b->v4l2_buf.field = V4L2_FIELD_INTERLACED;
@@ -285,8 +284,8 @@ static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx, unsigned int err)
285 list_del(&dst_buf->list); 284 list_del(&dst_buf->list);
286 ctx->dst_queue_cnt--; 285 ctx->dst_queue_cnt--;
287 dst_buf->b->v4l2_buf.sequence = ctx->sequence; 286 dst_buf->b->v4l2_buf.sequence = ctx->sequence;
288 if (s5p_mfc_read_shm(ctx, PIC_TIME_TOP) == 287 if (s5p_mfc_read_info_v5(ctx, PIC_TIME_TOP) ==
289 s5p_mfc_read_shm(ctx, PIC_TIME_BOT)) 288 s5p_mfc_read_info_v5(ctx, PIC_TIME_BOT))
290 dst_buf->b->v4l2_buf.field = V4L2_FIELD_NONE; 289 dst_buf->b->v4l2_buf.field = V4L2_FIELD_NONE;
291 else 290 else
292 dst_buf->b->v4l2_buf.field = 291 dst_buf->b->v4l2_buf.field =
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c
index 91a415573bd2..cdd02b9295c1 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c
@@ -11,7 +11,7 @@
11 */ 11 */
12 12
13#include "regs-mfc.h" 13#include "regs-mfc.h"
14#include "s5p_mfc_cmd.h" 14#include "s5p_mfc_cmd_v5.h"
15#include "s5p_mfc_common.h" 15#include "s5p_mfc_common.h"
16#include "s5p_mfc_debug.h" 16#include "s5p_mfc_debug.h"
17 17
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.h b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.h
index 8b090d3723e7..8b090d3723e7 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.h
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 0deba6bc687c..f31bff981a54 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -16,7 +16,7 @@
16#include <linux/jiffies.h> 16#include <linux/jiffies.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include "regs-mfc.h" 18#include "regs-mfc.h"
19#include "s5p_mfc_cmd.h" 19#include "s5p_mfc_cmd_v5.h"
20#include "s5p_mfc_common.h" 20#include "s5p_mfc_common.h"
21#include "s5p_mfc_debug.h" 21#include "s5p_mfc_debug.h"
22#include "s5p_mfc_intr.h" 22#include "s5p_mfc_intr.h"
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 6ee21bb71398..653f14bca380 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -28,9 +28,8 @@
28#include "s5p_mfc_debug.h" 28#include "s5p_mfc_debug.h"
29#include "s5p_mfc_dec.h" 29#include "s5p_mfc_dec.h"
30#include "s5p_mfc_intr.h" 30#include "s5p_mfc_intr.h"
31#include "s5p_mfc_opr.h" 31#include "s5p_mfc_opr_v5.h"
32#include "s5p_mfc_pm.h" 32#include "s5p_mfc_pm.h"
33#include "s5p_mfc_shm.h"
34 33
35static struct s5p_mfc_fmt formats[] = { 34static struct s5p_mfc_fmt formats[] = {
36 { 35 {
@@ -695,10 +694,10 @@ static int vidioc_g_crop(struct file *file, void *priv,
695 return -EINVAL; 694 return -EINVAL;
696 } 695 }
697 if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_H264) { 696 if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_H264) {
698 left = s5p_mfc_read_shm(ctx, CROP_INFO_H); 697 left = s5p_mfc_read_info_v5(ctx, CROP_INFO_H);
699 right = left >> S5P_FIMV_SHARED_CROP_RIGHT_SHIFT; 698 right = left >> S5P_FIMV_SHARED_CROP_RIGHT_SHIFT;
700 left = left & S5P_FIMV_SHARED_CROP_LEFT_MASK; 699 left = left & S5P_FIMV_SHARED_CROP_LEFT_MASK;
701 top = s5p_mfc_read_shm(ctx, CROP_INFO_V); 700 top = s5p_mfc_read_info_v5(ctx, CROP_INFO_V);
702 bottom = top >> S5P_FIMV_SHARED_CROP_BOTTOM_SHIFT; 701 bottom = top >> S5P_FIMV_SHARED_CROP_BOTTOM_SHIFT;
703 top = top & S5P_FIMV_SHARED_CROP_TOP_MASK; 702 top = top & S5P_FIMV_SHARED_CROP_TOP_MASK;
704 cr->c.left = left; 703 cr->c.left = left;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 179e4db60b15..f5f7e3c9a1a3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -30,7 +30,7 @@
30#include "s5p_mfc_debug.h" 30#include "s5p_mfc_debug.h"
31#include "s5p_mfc_enc.h" 31#include "s5p_mfc_enc.h"
32#include "s5p_mfc_intr.h" 32#include "s5p_mfc_intr.h"
33#include "s5p_mfc_opr.h" 33#include "s5p_mfc_opr_v5.h"
34 34
35static struct s5p_mfc_fmt formats[] = { 35static struct s5p_mfc_fmt formats[] = {
36 { 36 {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
index 767a51271dc2..baa05af6ca88 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
@@ -13,14 +13,13 @@
13 */ 13 */
14 14
15#include "regs-mfc.h" 15#include "regs-mfc.h"
16#include "s5p_mfc_cmd.h" 16#include "s5p_mfc_cmd_v5.h"
17#include "s5p_mfc_common.h" 17#include "s5p_mfc_common.h"
18#include "s5p_mfc_ctrl.h" 18#include "s5p_mfc_ctrl.h"
19#include "s5p_mfc_debug.h" 19#include "s5p_mfc_debug.h"
20#include "s5p_mfc_intr.h" 20#include "s5p_mfc_intr.h"
21#include "s5p_mfc_opr.h" 21#include "s5p_mfc_opr_v5.h"
22#include "s5p_mfc_pm.h" 22#include "s5p_mfc_pm.h"
23#include "s5p_mfc_shm.h"
24#include <asm/cacheflush.h> 23#include <asm/cacheflush.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
@@ -262,12 +261,30 @@ int s5p_mfc_alloc_instance_buffer(struct s5p_mfc_ctx *ctx)
262 /* Zero content of the allocated memory */ 261 /* Zero content of the allocated memory */
263 memset(context_virt, 0, ctx->ctx_size); 262 memset(context_virt, 0, ctx->ctx_size);
264 wmb(); 263 wmb();
265 if (s5p_mfc_init_shm(ctx) < 0) { 264
266 vb2_dma_contig_memops.put(ctx->ctx_buf); 265 /* Initialize shared memory */
267 ctx->ctx_phys = 0; 266 ctx->shm_alloc = vb2_dma_contig_memops.alloc(
268 ctx->ctx_buf = NULL; 267 dev->alloc_ctx[MFC_BANK1_ALLOC_CTX], SHARED_BUF_SIZE);
268 if (IS_ERR(ctx->shm_alloc)) {
269 mfc_err("failed to allocate shared memory\n");
270 return PTR_ERR(ctx->shm_alloc);
271 }
272 /* shared memory offset only keeps the offset from base (port a) */
273 ctx->shm_ofs = s5p_mfc_mem_cookie(
274 dev->alloc_ctx[MFC_BANK1_ALLOC_CTX], ctx->shm_alloc)
275 - dev->bank1;
276 BUG_ON(ctx->shm_ofs & ((1 << MFC_BANK1_ALIGN_ORDER) - 1));
277
278 ctx->shm = vb2_dma_contig_memops.vaddr(ctx->shm_alloc);
279 if (!ctx->shm) {
280 vb2_dma_contig_memops.put(ctx->shm_alloc);
281 ctx->shm_ofs = 0;
282 ctx->shm_alloc = NULL;
283 mfc_err("failed to virt addr of shared memory\n");
269 return -ENOMEM; 284 return -ENOMEM;
270 } 285 }
286 memset((void *)ctx->shm, 0, SHARED_BUF_SIZE);
287 wmb();
271 return 0; 288 return 0;
272} 289}
273 290
@@ -286,6 +303,20 @@ void s5p_mfc_release_instance_buffer(struct s5p_mfc_ctx *ctx)
286 } 303 }
287} 304}
288 305
306void s5p_mfc_write_info_v5(struct s5p_mfc_ctx *ctx, unsigned int data,
307 unsigned int ofs)
308{
309 writel(data, (ctx->shm + ofs));
310 wmb();
311}
312
313unsigned int s5p_mfc_read_info_v5(struct s5p_mfc_ctx *ctx,
314 unsigned int ofs)
315{
316 rmb();
317 return readl(ctx->shm + ofs);
318}
319
289/* Set registers for decoding temporary buffers */ 320/* Set registers for decoding temporary buffers */
290void s5p_mfc_set_dec_desc_buffer(struct s5p_mfc_ctx *ctx) 321void s5p_mfc_set_dec_desc_buffer(struct s5p_mfc_ctx *ctx)
291{ 322{
@@ -311,7 +342,7 @@ int s5p_mfc_set_dec_stream_buffer(struct s5p_mfc_ctx *ctx, int buf_addr,
311 mfc_write(dev, OFFSETA(buf_addr), S5P_FIMV_SI_CH0_SB_ST_ADR); 342 mfc_write(dev, OFFSETA(buf_addr), S5P_FIMV_SI_CH0_SB_ST_ADR);
312 mfc_write(dev, ctx->dec_src_buf_size, S5P_FIMV_SI_CH0_CPB_SIZE); 343 mfc_write(dev, ctx->dec_src_buf_size, S5P_FIMV_SI_CH0_CPB_SIZE);
313 mfc_write(dev, buf_size, S5P_FIMV_SI_CH0_SB_FRM_SIZE); 344 mfc_write(dev, buf_size, S5P_FIMV_SI_CH0_SB_FRM_SIZE);
314 s5p_mfc_write_shm(ctx, start_num_byte, START_BYTE_NUM); 345 s5p_mfc_write_info_v5(ctx, start_num_byte, START_BYTE_NUM);
315 return 0; 346 return 0;
316} 347}
317 348
@@ -438,10 +469,10 @@ int s5p_mfc_set_dec_frame_buffer(struct s5p_mfc_ctx *ctx)
438 mfc_debug(2, "Not enough memory has been allocated\n"); 469 mfc_debug(2, "Not enough memory has been allocated\n");
439 return -ENOMEM; 470 return -ENOMEM;
440 } 471 }
441 s5p_mfc_write_shm(ctx, frame_size, ALLOC_LUMA_DPB_SIZE); 472 s5p_mfc_write_info_v5(ctx, frame_size, ALLOC_LUMA_DPB_SIZE);
442 s5p_mfc_write_shm(ctx, frame_size_ch, ALLOC_CHROMA_DPB_SIZE); 473 s5p_mfc_write_info_v5(ctx, frame_size_ch, ALLOC_CHROMA_DPB_SIZE);
443 if (ctx->codec_mode == S5P_FIMV_CODEC_H264_DEC) 474 if (ctx->codec_mode == S5P_FIMV_CODEC_H264_DEC)
444 s5p_mfc_write_shm(ctx, frame_size_mv, ALLOC_MV_SIZE); 475 s5p_mfc_write_info_v5(ctx, frame_size_mv, ALLOC_MV_SIZE);
445 mfc_write(dev, ((S5P_FIMV_CH_INIT_BUFS & S5P_FIMV_CH_MASK) 476 mfc_write(dev, ((S5P_FIMV_CH_INIT_BUFS & S5P_FIMV_CH_MASK)
446 << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), 477 << S5P_FIMV_CH_SHIFT) | (ctx->inst_no),
447 S5P_FIMV_SI_CH0_INST_ID); 478 S5P_FIMV_SI_CH0_INST_ID);
@@ -685,16 +716,16 @@ static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
685 /* reaction coefficient */ 716 /* reaction coefficient */
686 if (p->rc_frame) 717 if (p->rc_frame)
687 mfc_write(dev, p->rc_reaction_coeff, S5P_FIMV_ENC_RC_RPARA); 718 mfc_write(dev, p->rc_reaction_coeff, S5P_FIMV_ENC_RC_RPARA);
688 shm = s5p_mfc_read_shm(ctx, EXT_ENC_CONTROL); 719 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
689 /* seq header ctrl */ 720 /* seq header ctrl */
690 shm &= ~(0x1 << 3); 721 shm &= ~(0x1 << 3);
691 shm |= (p->seq_hdr_mode << 3); 722 shm |= (p->seq_hdr_mode << 3);
692 /* frame skip mode */ 723 /* frame skip mode */
693 shm &= ~(0x3 << 1); 724 shm &= ~(0x3 << 1);
694 shm |= (p->frame_skip_mode << 1); 725 shm |= (p->frame_skip_mode << 1);
695 s5p_mfc_write_shm(ctx, shm, EXT_ENC_CONTROL); 726 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
696 /* fixed target bit */ 727 /* fixed target bit */
697 s5p_mfc_write_shm(ctx, p->fixed_target_bit, RC_CONTROL_CONFIG); 728 s5p_mfc_write_info_v5(ctx, p->fixed_target_bit, RC_CONTROL_CONFIG);
698 return 0; 729 return 0;
699} 730}
700 731
@@ -806,35 +837,35 @@ static int s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx)
806 } 837 }
807 if (!p->rc_frame && 838 if (!p->rc_frame &&
808 !p_264->rc_mb) { 839 !p_264->rc_mb) {
809 shm = s5p_mfc_read_shm(ctx, P_B_FRAME_QP); 840 shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP);
810 shm &= ~(0xFFF); 841 shm &= ~(0xFFF);
811 shm |= ((p_264->rc_b_frame_qp & 0x3F) << 6); 842 shm |= ((p_264->rc_b_frame_qp & 0x3F) << 6);
812 shm |= (p_264->rc_p_frame_qp & 0x3F); 843 shm |= (p_264->rc_p_frame_qp & 0x3F);
813 s5p_mfc_write_shm(ctx, shm, P_B_FRAME_QP); 844 s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP);
814 } 845 }
815 /* extended encoder ctrl */ 846 /* extended encoder ctrl */
816 shm = s5p_mfc_read_shm(ctx, EXT_ENC_CONTROL); 847 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
817 /* AR VUI control */ 848 /* AR VUI control */
818 shm &= ~(0x1 << 15); 849 shm &= ~(0x1 << 15);
819 shm |= (p_264->vui_sar << 1); 850 shm |= (p_264->vui_sar << 1);
820 s5p_mfc_write_shm(ctx, shm, EXT_ENC_CONTROL); 851 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
821 if (p_264->vui_sar) { 852 if (p_264->vui_sar) {
822 /* aspect ration IDC */ 853 /* aspect ration IDC */
823 shm = s5p_mfc_read_shm(ctx, SAMPLE_ASPECT_RATIO_IDC); 854 shm = s5p_mfc_read_info_v5(ctx, SAMPLE_ASPECT_RATIO_IDC);
824 shm &= ~(0xFF); 855 shm &= ~(0xFF);
825 shm |= p_264->vui_sar_idc; 856 shm |= p_264->vui_sar_idc;
826 s5p_mfc_write_shm(ctx, shm, SAMPLE_ASPECT_RATIO_IDC); 857 s5p_mfc_write_info_v5(ctx, shm, SAMPLE_ASPECT_RATIO_IDC);
827 if (p_264->vui_sar_idc == 0xFF) { 858 if (p_264->vui_sar_idc == 0xFF) {
828 /* sample AR info */ 859 /* sample AR info */
829 shm = s5p_mfc_read_shm(ctx, EXTENDED_SAR); 860 shm = s5p_mfc_read_info_v5(ctx, EXTENDED_SAR);
830 shm &= ~(0xFFFFFFFF); 861 shm &= ~(0xFFFFFFFF);
831 shm |= p_264->vui_ext_sar_width << 16; 862 shm |= p_264->vui_ext_sar_width << 16;
832 shm |= p_264->vui_ext_sar_height; 863 shm |= p_264->vui_ext_sar_height;
833 s5p_mfc_write_shm(ctx, shm, EXTENDED_SAR); 864 s5p_mfc_write_info_v5(ctx, shm, EXTENDED_SAR);
834 } 865 }
835 } 866 }
836 /* intra picture period for H.264 */ 867 /* intra picture period for H.264 */
837 shm = s5p_mfc_read_shm(ctx, H264_I_PERIOD); 868 shm = s5p_mfc_read_info_v5(ctx, H264_I_PERIOD);
838 /* control */ 869 /* control */
839 shm &= ~(0x1 << 16); 870 shm &= ~(0x1 << 16);
840 shm |= (p_264->open_gop << 16); 871 shm |= (p_264->open_gop << 16);
@@ -843,16 +874,16 @@ static int s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx)
843 shm &= ~(0xFFFF); 874 shm &= ~(0xFFFF);
844 shm |= p_264->open_gop_size; 875 shm |= p_264->open_gop_size;
845 } 876 }
846 s5p_mfc_write_shm(ctx, shm, H264_I_PERIOD); 877 s5p_mfc_write_info_v5(ctx, shm, H264_I_PERIOD);
847 /* extended encoder ctrl */ 878 /* extended encoder ctrl */
848 shm = s5p_mfc_read_shm(ctx, EXT_ENC_CONTROL); 879 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
849 /* vbv buffer size */ 880 /* vbv buffer size */
850 if (p->frame_skip_mode == 881 if (p->frame_skip_mode ==
851 V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) { 882 V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
852 shm &= ~(0xFFFF << 16); 883 shm &= ~(0xFFFF << 16);
853 shm |= (p_264->cpb_size << 16); 884 shm |= (p_264->cpb_size << 16);
854 } 885 }
855 s5p_mfc_write_shm(ctx, shm, EXT_ENC_CONTROL); 886 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
856 return 0; 887 return 0;
857} 888}
858 889
@@ -885,11 +916,11 @@ static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx)
885 mfc_write(dev, p_mpeg4->quarter_pixel, S5P_FIMV_ENC_MPEG4_QUART_PXL); 916 mfc_write(dev, p_mpeg4->quarter_pixel, S5P_FIMV_ENC_MPEG4_QUART_PXL);
886 /* qp */ 917 /* qp */
887 if (!p->rc_frame) { 918 if (!p->rc_frame) {
888 shm = s5p_mfc_read_shm(ctx, P_B_FRAME_QP); 919 shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP);
889 shm &= ~(0xFFF); 920 shm &= ~(0xFFF);
890 shm |= ((p_mpeg4->rc_b_frame_qp & 0x3F) << 6); 921 shm |= ((p_mpeg4->rc_b_frame_qp & 0x3F) << 6);
891 shm |= (p_mpeg4->rc_p_frame_qp & 0x3F); 922 shm |= (p_mpeg4->rc_p_frame_qp & 0x3F);
892 s5p_mfc_write_shm(ctx, shm, P_B_FRAME_QP); 923 s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP);
893 } 924 }
894 /* frame rate */ 925 /* frame rate */
895 if (p->rc_frame) { 926 if (p->rc_frame) {
@@ -898,12 +929,12 @@ static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx)
898 p->rc_framerate_denom; 929 p->rc_framerate_denom;
899 mfc_write(dev, framerate, 930 mfc_write(dev, framerate,
900 S5P_FIMV_ENC_RC_FRAME_RATE); 931 S5P_FIMV_ENC_RC_FRAME_RATE);
901 shm = s5p_mfc_read_shm(ctx, RC_VOP_TIMING); 932 shm = s5p_mfc_read_info_v5(ctx, RC_VOP_TIMING);
902 shm &= ~(0xFFFFFFFF); 933 shm &= ~(0xFFFFFFFF);
903 shm |= (1 << 31); 934 shm |= (1 << 31);
904 shm |= ((p->rc_framerate_num & 0x7FFF) << 16); 935 shm |= ((p->rc_framerate_num & 0x7FFF) << 16);
905 shm |= (p->rc_framerate_denom & 0xFFFF); 936 shm |= (p->rc_framerate_denom & 0xFFFF);
906 s5p_mfc_write_shm(ctx, shm, RC_VOP_TIMING); 937 s5p_mfc_write_info_v5(ctx, shm, RC_VOP_TIMING);
907 } 938 }
908 } else { 939 } else {
909 mfc_write(dev, 0, S5P_FIMV_ENC_RC_FRAME_RATE); 940 mfc_write(dev, 0, S5P_FIMV_ENC_RC_FRAME_RATE);
@@ -924,14 +955,14 @@ static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx)
924 reg |= p_mpeg4->rc_min_qp; 955 reg |= p_mpeg4->rc_min_qp;
925 mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND); 956 mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND);
926 /* extended encoder ctrl */ 957 /* extended encoder ctrl */
927 shm = s5p_mfc_read_shm(ctx, EXT_ENC_CONTROL); 958 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
928 /* vbv buffer size */ 959 /* vbv buffer size */
929 if (p->frame_skip_mode == 960 if (p->frame_skip_mode ==
930 V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) { 961 V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
931 shm &= ~(0xFFFF << 16); 962 shm &= ~(0xFFFF << 16);
932 shm |= (p->vbv_size << 16); 963 shm |= (p->vbv_size << 16);
933 } 964 }
934 s5p_mfc_write_shm(ctx, shm, EXT_ENC_CONTROL); 965 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
935 return 0; 966 return 0;
936} 967}
937 968
@@ -946,10 +977,10 @@ static int s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx)
946 s5p_mfc_set_enc_params(ctx); 977 s5p_mfc_set_enc_params(ctx);
947 /* qp */ 978 /* qp */
948 if (!p->rc_frame) { 979 if (!p->rc_frame) {
949 shm = s5p_mfc_read_shm(ctx, P_B_FRAME_QP); 980 shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP);
950 shm &= ~(0xFFF); 981 shm &= ~(0xFFF);
951 shm |= (p_h263->rc_p_frame_qp & 0x3F); 982 shm |= (p_h263->rc_p_frame_qp & 0x3F);
952 s5p_mfc_write_shm(ctx, shm, P_B_FRAME_QP); 983 s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP);
953 } 984 }
954 /* frame rate */ 985 /* frame rate */
955 if (p->rc_frame && p->rc_framerate_denom) 986 if (p->rc_frame && p->rc_framerate_denom)
@@ -973,14 +1004,14 @@ static int s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx)
973 reg |= p_h263->rc_min_qp; 1004 reg |= p_h263->rc_min_qp;
974 mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND); 1005 mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND);
975 /* extended encoder ctrl */ 1006 /* extended encoder ctrl */
976 shm = s5p_mfc_read_shm(ctx, EXT_ENC_CONTROL); 1007 shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
977 /* vbv buffer size */ 1008 /* vbv buffer size */
978 if (p->frame_skip_mode == 1009 if (p->frame_skip_mode ==
979 V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) { 1010 V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
980 shm &= ~(0xFFFF << 16); 1011 shm &= ~(0xFFFF << 16);
981 shm |= (p->vbv_size << 16); 1012 shm |= (p->vbv_size << 16);
982 } 1013 }
983 s5p_mfc_write_shm(ctx, shm, EXT_ENC_CONTROL); 1014 s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
984 return 0; 1015 return 0;
985} 1016}
986 1017
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.h
index 2ad3def052f8..97c1ecafa0f9 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.h
@@ -17,6 +17,69 @@
17 17
18#include "s5p_mfc_common.h" 18#include "s5p_mfc_common.h"
19 19
20enum MFC_SHM_OFS {
21 EXTENEDED_DECODE_STATUS = 0x00, /* D */
22 SET_FRAME_TAG = 0x04, /* D */
23 GET_FRAME_TAG_TOP = 0x08, /* D */
24 GET_FRAME_TAG_BOT = 0x0C, /* D */
25 PIC_TIME_TOP = 0x10, /* D */
26 PIC_TIME_BOT = 0x14, /* D */
27 START_BYTE_NUM = 0x18, /* D */
28
29 CROP_INFO_H = 0x20, /* D */
30 CROP_INFO_V = 0x24, /* D */
31 EXT_ENC_CONTROL = 0x28, /* E */
32 ENC_PARAM_CHANGE = 0x2C, /* E */
33 RC_VOP_TIMING = 0x30, /* E, MPEG4 */
34 HEC_PERIOD = 0x34, /* E, MPEG4 */
35 METADATA_ENABLE = 0x38, /* C */
36 METADATA_STATUS = 0x3C, /* C */
37 METADATA_DISPLAY_INDEX = 0x40, /* C */
38 EXT_METADATA_START_ADDR = 0x44, /* C */
39 PUT_EXTRADATA = 0x48, /* C */
40 EXTRADATA_ADDR = 0x4C, /* C */
41
42 ALLOC_LUMA_DPB_SIZE = 0x64, /* D */
43 ALLOC_CHROMA_DPB_SIZE = 0x68, /* D */
44 ALLOC_MV_SIZE = 0x6C, /* D */
45 P_B_FRAME_QP = 0x70, /* E */
46 SAMPLE_ASPECT_RATIO_IDC = 0x74, /* E, H.264, depend on
47 ASPECT_RATIO_VUI_ENABLE in EXT_ENC_CONTROL */
48 EXTENDED_SAR = 0x78, /* E, H.264, depned on
49 ASPECT_RATIO_VUI_ENABLE in EXT_ENC_CONTROL */
50 DISP_PIC_PROFILE = 0x7C, /* D */
51 FLUSH_CMD_TYPE = 0x80, /* C */
52 FLUSH_CMD_INBUF1 = 0x84, /* C */
53 FLUSH_CMD_INBUF2 = 0x88, /* C */
54 FLUSH_CMD_OUTBUF = 0x8C, /* E */
55 NEW_RC_BIT_RATE = 0x90, /* E, format as RC_BIT_RATE(0xC5A8)
56 depend on RC_BIT_RATE_CHANGE in ENC_PARAM_CHANGE */
57 NEW_RC_FRAME_RATE = 0x94, /* E, format as RC_FRAME_RATE(0xD0D0)
58 depend on RC_FRAME_RATE_CHANGE in ENC_PARAM_CHANGE */
59 NEW_I_PERIOD = 0x98, /* E, format as I_FRM_CTRL(0xC504)
60 depend on I_PERIOD_CHANGE in ENC_PARAM_CHANGE */
61 H264_I_PERIOD = 0x9C, /* E, H.264, open GOP */
62 RC_CONTROL_CONFIG = 0xA0, /* E */
63 BATCH_INPUT_ADDR = 0xA4, /* E */
64 BATCH_OUTPUT_ADDR = 0xA8, /* E */
65 BATCH_OUTPUT_SIZE = 0xAC, /* E */
66 MIN_LUMA_DPB_SIZE = 0xB0, /* D */
67 DEVICE_FORMAT_ID = 0xB4, /* C */
68 H264_POC_TYPE = 0xB8, /* D */
69 MIN_CHROMA_DPB_SIZE = 0xBC, /* D */
70 DISP_PIC_FRAME_TYPE = 0xC0, /* D */
71 FREE_LUMA_DPB = 0xC4, /* D, VC1 MPEG4 */
72 ASPECT_RATIO_INFO = 0xC8, /* D, MPEG4 */
73 EXTENDED_PAR = 0xCC, /* D, MPEG4 */
74 DBG_HISTORY_INPUT0 = 0xD0, /* C */
75 DBG_HISTORY_INPUT1 = 0xD4, /* C */
76 DBG_HISTORY_OUTPUT = 0xD8, /* C */
77 HIERARCHICAL_P_QP = 0xE0, /* E, H.264 */
78 FRAME_PACK_SEI_ENABLE = 0x168, /* C */
79 FRAME_PACK_SEI_AVAIL = 0x16c, /* D */
80 FRAME_PACK_SEI_INFO = 0x17c, /* E */
81};
82
20int s5p_mfc_init_decode(struct s5p_mfc_ctx *ctx); 83int s5p_mfc_init_decode(struct s5p_mfc_ctx *ctx);
21int s5p_mfc_init_encode(struct s5p_mfc_ctx *mfc_ctx); 84int s5p_mfc_init_encode(struct s5p_mfc_ctx *mfc_ctx);
22 85
@@ -53,6 +116,13 @@ void s5p_mfc_release_instance_buffer(struct s5p_mfc_ctx *ctx);
53void s5p_mfc_try_run(struct s5p_mfc_dev *dev); 116void s5p_mfc_try_run(struct s5p_mfc_dev *dev);
54void s5p_mfc_cleanup_queue(struct list_head *lh, struct vb2_queue *vq); 117void s5p_mfc_cleanup_queue(struct list_head *lh, struct vb2_queue *vq);
55 118
119/* Shared memory ops */
120void s5p_mfc_write_info_v5(struct s5p_mfc_ctx *ctx, unsigned int data,
121 unsigned int ofs);
122
123unsigned int s5p_mfc_read_info_v5(struct s5p_mfc_ctx *ctx,
124 unsigned int ofs);
125
56#define s5p_mfc_get_dspl_y_adr() (readl(dev->regs_base + \ 126#define s5p_mfc_get_dspl_y_adr() (readl(dev->regs_base + \
57 S5P_FIMV_SI_DISPLAY_Y_ADR) << \ 127 S5P_FIMV_SI_DISPLAY_Y_ADR) << \
58 MFC_OFFSET_SHIFT) 128 MFC_OFFSET_SHIFT)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_shm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_shm.c
deleted file mode 100644
index b5933d233a4b..000000000000
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_shm.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * linux/drivers/media/platform/s5p-mfc/s5p_mfc_shm.c
3 *
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifdef CONFIG_ARCH_EXYNOS4
14#include <linux/dma-mapping.h>
15#endif
16#include <linux/io.h>
17#include "s5p_mfc_common.h"
18#include "s5p_mfc_debug.h"
19
20int s5p_mfc_init_shm(struct s5p_mfc_ctx *ctx)
21{
22 struct s5p_mfc_dev *dev = ctx->dev;
23 void *shm_alloc_ctx = dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
24
25 ctx->shm_alloc = vb2_dma_contig_memops.alloc(shm_alloc_ctx,
26 SHARED_BUF_SIZE);
27 if (IS_ERR(ctx->shm_alloc)) {
28 mfc_err("failed to allocate shared memory\n");
29 return PTR_ERR(ctx->shm_alloc);
30 }
31 /* shm_ofs only keeps the offset from base (port a) */
32 ctx->shm_ofs = s5p_mfc_mem_cookie(shm_alloc_ctx, ctx->shm_alloc)
33 - dev->bank1;
34 BUG_ON(ctx->shm_ofs & ((1 << MFC_BANK1_ALIGN_ORDER) - 1));
35 ctx->shm = vb2_dma_contig_memops.vaddr(ctx->shm_alloc);
36 if (!ctx->shm) {
37 vb2_dma_contig_memops.put(ctx->shm_alloc);
38 ctx->shm_ofs = 0;
39 ctx->shm_alloc = NULL;
40 mfc_err("failed to virt addr of shared memory\n");
41 return -ENOMEM;
42 }
43 memset((void *)ctx->shm, 0, SHARED_BUF_SIZE);
44 wmb();
45 return 0;
46}
47
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_shm.h b/drivers/media/platform/s5p-mfc/s5p_mfc_shm.h
deleted file mode 100644
index 416ebd7ba35a..000000000000
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_shm.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * linux/drivers/media/platform/s5p-mfc/s5p_mfc_shm.h
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef S5P_MFC_SHM_H_
14#define S5P_MFC_SHM_H_
15
16enum MFC_SHM_OFS {
17 EXTENEDED_DECODE_STATUS = 0x00, /* D */
18 SET_FRAME_TAG = 0x04, /* D */
19 GET_FRAME_TAG_TOP = 0x08, /* D */
20 GET_FRAME_TAG_BOT = 0x0C, /* D */
21 PIC_TIME_TOP = 0x10, /* D */
22 PIC_TIME_BOT = 0x14, /* D */
23 START_BYTE_NUM = 0x18, /* D */
24
25 CROP_INFO_H = 0x20, /* D */
26 CROP_INFO_V = 0x24, /* D */
27 EXT_ENC_CONTROL = 0x28, /* E */
28 ENC_PARAM_CHANGE = 0x2C, /* E */
29 RC_VOP_TIMING = 0x30, /* E, MPEG4 */
30 HEC_PERIOD = 0x34, /* E, MPEG4 */
31 METADATA_ENABLE = 0x38, /* C */
32 METADATA_STATUS = 0x3C, /* C */
33 METADATA_DISPLAY_INDEX = 0x40, /* C */
34 EXT_METADATA_START_ADDR = 0x44, /* C */
35 PUT_EXTRADATA = 0x48, /* C */
36 EXTRADATA_ADDR = 0x4C, /* C */
37
38 ALLOC_LUMA_DPB_SIZE = 0x64, /* D */
39 ALLOC_CHROMA_DPB_SIZE = 0x68, /* D */
40 ALLOC_MV_SIZE = 0x6C, /* D */
41 P_B_FRAME_QP = 0x70, /* E */
42 SAMPLE_ASPECT_RATIO_IDC = 0x74, /* E, H.264, depend on
43 ASPECT_RATIO_VUI_ENABLE in EXT_ENC_CONTROL */
44 EXTENDED_SAR = 0x78, /* E, H.264, depned on
45 ASPECT_RATIO_VUI_ENABLE in EXT_ENC_CONTROL */
46 DISP_PIC_PROFILE = 0x7C, /* D */
47 FLUSH_CMD_TYPE = 0x80, /* C */
48 FLUSH_CMD_INBUF1 = 0x84, /* C */
49 FLUSH_CMD_INBUF2 = 0x88, /* C */
50 FLUSH_CMD_OUTBUF = 0x8C, /* E */
51 NEW_RC_BIT_RATE = 0x90, /* E, format as RC_BIT_RATE(0xC5A8)
52 depend on RC_BIT_RATE_CHANGE in ENC_PARAM_CHANGE */
53 NEW_RC_FRAME_RATE = 0x94, /* E, format as RC_FRAME_RATE(0xD0D0)
54 depend on RC_FRAME_RATE_CHANGE in ENC_PARAM_CHANGE */
55 NEW_I_PERIOD = 0x98, /* E, format as I_FRM_CTRL(0xC504)
56 depend on I_PERIOD_CHANGE in ENC_PARAM_CHANGE */
57 H264_I_PERIOD = 0x9C, /* E, H.264, open GOP */
58 RC_CONTROL_CONFIG = 0xA0, /* E */
59 BATCH_INPUT_ADDR = 0xA4, /* E */
60 BATCH_OUTPUT_ADDR = 0xA8, /* E */
61 BATCH_OUTPUT_SIZE = 0xAC, /* E */
62 MIN_LUMA_DPB_SIZE = 0xB0, /* D */
63 DEVICE_FORMAT_ID = 0xB4, /* C */
64 H264_POC_TYPE = 0xB8, /* D */
65 MIN_CHROMA_DPB_SIZE = 0xBC, /* D */
66 DISP_PIC_FRAME_TYPE = 0xC0, /* D */
67 FREE_LUMA_DPB = 0xC4, /* D, VC1 MPEG4 */
68 ASPECT_RATIO_INFO = 0xC8, /* D, MPEG4 */
69 EXTENDED_PAR = 0xCC, /* D, MPEG4 */
70 DBG_HISTORY_INPUT0 = 0xD0, /* C */
71 DBG_HISTORY_INPUT1 = 0xD4, /* C */
72 DBG_HISTORY_OUTPUT = 0xD8, /* C */
73 HIERARCHICAL_P_QP = 0xE0, /* E, H.264 */
74};
75
76int s5p_mfc_init_shm(struct s5p_mfc_ctx *ctx);
77
78#define s5p_mfc_write_shm(ctx, x, ofs) \
79 do { \
80 writel(x, (ctx->shm + ofs)); \
81 wmb(); \
82 } while (0)
83
84static inline u32 s5p_mfc_read_shm(struct s5p_mfc_ctx *ctx, unsigned int ofs)
85{
86 rmb();
87 return readl(ctx->shm + ofs);
88}
89
90#endif /* S5P_MFC_SHM_H_ */