2011-06-21 21:51:26 +08:00
|
|
|
/*
|
2012-10-04 09:19:08 +08:00
|
|
|
* drivers/media/platform/samsung/mfc5/s5p_mfc_opr_v5.c
|
2011-06-21 21:51:26 +08:00
|
|
|
*
|
|
|
|
* Samsung MFC (Multi Function Codec - FIMV) driver
|
|
|
|
* This file contains hw related functions.
|
|
|
|
*
|
|
|
|
* Kamil Debski, Copyright (c) 2011 Samsung Electronics
|
|
|
|
* http://www.samsung.com/
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "s5p_mfc_common.h"
|
2012-10-04 09:19:08 +08:00
|
|
|
#include "s5p_mfc_cmd.h"
|
2011-06-21 21:51:26 +08:00
|
|
|
#include "s5p_mfc_ctrl.h"
|
|
|
|
#include "s5p_mfc_debug.h"
|
|
|
|
#include "s5p_mfc_intr.h"
|
|
|
|
#include "s5p_mfc_pm.h"
|
2012-10-04 09:19:08 +08:00
|
|
|
#include "s5p_mfc_opr.h"
|
|
|
|
#include "s5p_mfc_opr_v5.h"
|
2011-06-21 21:51:26 +08:00
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
|
2017-03-20 18:49:24 +08:00
|
|
|
#define OFFSETA(x) (((x) - dev->dma_base[BANK_L_CTX]) >> MFC_OFFSET_SHIFT)
|
|
|
|
#define OFFSETB(x) (((x) - dev->dma_base[BANK_R_CTX]) >> MFC_OFFSET_SHIFT)
|
2011-06-21 21:51:26 +08:00
|
|
|
|
|
|
|
/* Allocate temporary buffers for decoding */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_alloc_dec_temp_buffers_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
2012-10-04 09:19:09 +08:00
|
|
|
struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
|
2013-01-03 18:06:04 +08:00
|
|
|
int ret;
|
2011-06-21 21:51:26 +08:00
|
|
|
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->dsc.size = buf_size->dsc;
|
2017-03-20 18:49:24 +08:00
|
|
|
ret = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &ctx->dsc);
|
2013-01-03 18:06:04 +08:00
|
|
|
if (ret) {
|
|
|
|
mfc_err("Failed to allocate temporary buffer\n");
|
|
|
|
return ret;
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
2013-01-03 18:06:04 +08:00
|
|
|
|
2012-10-04 09:19:09 +08:00
|
|
|
BUG_ON(ctx->dsc.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1));
|
2013-01-03 18:06:04 +08:00
|
|
|
memset(ctx->dsc.virt, 0, ctx->dsc.size);
|
2011-06-21 21:51:26 +08:00
|
|
|
wmb();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-03 18:06:04 +08:00
|
|
|
|
2011-06-21 21:51:26 +08:00
|
|
|
/* Release temporary buffers for decoding */
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_release_dec_desc_buffer_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
2017-02-08 19:16:02 +08:00
|
|
|
s5p_mfc_release_priv_buf(ctx->dev, &ctx->dsc);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate codec buffers */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_alloc_codec_buffers_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
unsigned int enc_ref_y_size = 0;
|
|
|
|
unsigned int enc_ref_c_size = 0;
|
|
|
|
unsigned int guard_width, guard_height;
|
2013-01-03 18:06:04 +08:00
|
|
|
int ret;
|
2011-06-21 21:51:26 +08:00
|
|
|
|
|
|
|
if (ctx->type == MFCINST_DECODER) {
|
|
|
|
mfc_debug(2, "Luma size:%d Chroma size:%d MV size:%d\n",
|
|
|
|
ctx->luma_size, ctx->chroma_size, ctx->mv_size);
|
|
|
|
mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count);
|
|
|
|
} else if (ctx->type == MFCINST_ENCODER) {
|
|
|
|
enc_ref_y_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN)
|
|
|
|
* ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
enc_ref_y_size = ALIGN(enc_ref_y_size, S5P_FIMV_NV12MT_SALIGN);
|
|
|
|
|
2012-10-04 09:19:08 +08:00
|
|
|
if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) {
|
2011-06-21 21:51:26 +08:00
|
|
|
enc_ref_c_size = ALIGN(ctx->img_width,
|
|
|
|
S5P_FIMV_NV12MT_HALIGN)
|
|
|
|
* ALIGN(ctx->img_height >> 1,
|
|
|
|
S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
enc_ref_c_size = ALIGN(enc_ref_c_size,
|
|
|
|
S5P_FIMV_NV12MT_SALIGN);
|
|
|
|
} else {
|
|
|
|
guard_width = ALIGN(ctx->img_width + 16,
|
|
|
|
S5P_FIMV_NV12MT_HALIGN);
|
|
|
|
guard_height = ALIGN((ctx->img_height >> 1) + 4,
|
|
|
|
S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
enc_ref_c_size = ALIGN(guard_width * guard_height,
|
|
|
|
S5P_FIMV_NV12MT_SALIGN);
|
|
|
|
}
|
|
|
|
mfc_debug(2, "recon luma size: %d chroma size: %d\n",
|
|
|
|
enc_ref_y_size, enc_ref_c_size);
|
|
|
|
} else {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
/* Codecs have different memory requirements */
|
|
|
|
switch (ctx->codec_mode) {
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_H264_DEC:
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank1.size =
|
2011-06-21 21:51:26 +08:00
|
|
|
ALIGN(S5P_FIMV_DEC_NB_IP_SIZE +
|
|
|
|
S5P_FIMV_DEC_VERT_NB_MV_SIZE,
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank2.size = ctx->total_dpb_count * ctx->mv_size;
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_MPEG4_DEC:
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank1.size =
|
2011-06-21 21:51:26 +08:00
|
|
|
ALIGN(S5P_FIMV_DEC_NB_DCAC_SIZE +
|
|
|
|
S5P_FIMV_DEC_UPNB_MV_SIZE +
|
|
|
|
S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE +
|
|
|
|
S5P_FIMV_DEC_STX_PARSER_SIZE +
|
|
|
|
S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE,
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank2.size = 0;
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_VC1RCV_DEC:
|
|
|
|
case S5P_MFC_CODEC_VC1_DEC:
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank1.size =
|
2011-06-21 21:51:26 +08:00
|
|
|
ALIGN(S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE +
|
|
|
|
S5P_FIMV_DEC_UPNB_MV_SIZE +
|
|
|
|
S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE +
|
|
|
|
S5P_FIMV_DEC_NB_DCAC_SIZE +
|
|
|
|
3 * S5P_FIMV_DEC_VC1_BITPLANE_SIZE,
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank2.size = 0;
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_MPEG2_DEC:
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank1.size = 0;
|
|
|
|
ctx->bank2.size = 0;
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_H263_DEC:
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank1.size =
|
2011-06-21 21:51:26 +08:00
|
|
|
ALIGN(S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE +
|
|
|
|
S5P_FIMV_DEC_UPNB_MV_SIZE +
|
|
|
|
S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE +
|
|
|
|
S5P_FIMV_DEC_NB_DCAC_SIZE,
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank2.size = 0;
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_H264_ENC:
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank1.size = (enc_ref_y_size * 2) +
|
2011-06-21 21:51:26 +08:00
|
|
|
S5P_FIMV_ENC_UPMV_SIZE +
|
|
|
|
S5P_FIMV_ENC_COLFLG_SIZE +
|
|
|
|
S5P_FIMV_ENC_INTRAMD_SIZE +
|
|
|
|
S5P_FIMV_ENC_NBORINFO_SIZE;
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank2.size = (enc_ref_y_size * 2) +
|
2011-06-21 21:51:26 +08:00
|
|
|
(enc_ref_c_size * 4) +
|
|
|
|
S5P_FIMV_ENC_INTRAPRED_SIZE;
|
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_MPEG4_ENC:
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank1.size = (enc_ref_y_size * 2) +
|
2011-06-21 21:51:26 +08:00
|
|
|
S5P_FIMV_ENC_UPMV_SIZE +
|
|
|
|
S5P_FIMV_ENC_COLFLG_SIZE +
|
|
|
|
S5P_FIMV_ENC_ACDCCOEF_SIZE;
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank2.size = (enc_ref_y_size * 2) +
|
2011-06-21 21:51:26 +08:00
|
|
|
(enc_ref_c_size * 4);
|
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_H263_ENC:
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank1.size = (enc_ref_y_size * 2) +
|
2011-06-21 21:51:26 +08:00
|
|
|
S5P_FIMV_ENC_UPMV_SIZE +
|
|
|
|
S5P_FIMV_ENC_ACDCCOEF_SIZE;
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->bank2.size = (enc_ref_y_size * 2) +
|
2011-06-21 21:51:26 +08:00
|
|
|
(enc_ref_c_size * 4);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Allocate only if memory from bank 1 is necessary */
|
2013-01-03 18:06:04 +08:00
|
|
|
if (ctx->bank1.size > 0) {
|
|
|
|
|
2017-03-20 18:49:24 +08:00
|
|
|
ret = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &ctx->bank1);
|
2013-01-03 18:06:04 +08:00
|
|
|
if (ret) {
|
|
|
|
mfc_err("Failed to allocate Bank1 temporary buffer\n");
|
|
|
|
return ret;
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
2013-01-03 18:06:04 +08:00
|
|
|
BUG_ON(ctx->bank1.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1));
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
/* Allocate only if memory from bank 2 is necessary */
|
2013-01-03 18:06:04 +08:00
|
|
|
if (ctx->bank2.size > 0) {
|
2017-03-20 18:49:24 +08:00
|
|
|
ret = s5p_mfc_alloc_priv_buf(dev, BANK_R_CTX, &ctx->bank2);
|
2013-01-03 18:06:04 +08:00
|
|
|
if (ret) {
|
|
|
|
mfc_err("Failed to allocate Bank2 temporary buffer\n");
|
2017-02-08 19:16:02 +08:00
|
|
|
s5p_mfc_release_priv_buf(ctx->dev, &ctx->bank1);
|
2013-01-03 18:06:04 +08:00
|
|
|
return ret;
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
2013-01-03 18:06:04 +08:00
|
|
|
BUG_ON(ctx->bank2.dma & ((1 << MFC_BANK2_ALIGN_ORDER) - 1));
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release buffers allocated for codec */
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_release_codec_buffers_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
2017-02-08 19:16:02 +08:00
|
|
|
s5p_mfc_release_priv_buf(ctx->dev, &ctx->bank1);
|
|
|
|
s5p_mfc_release_priv_buf(ctx->dev, &ctx->bank2);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate memory for instance data buffer */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_alloc_instance_buffer_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
2012-10-04 09:19:09 +08:00
|
|
|
struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
|
2013-01-03 18:06:04 +08:00
|
|
|
int ret;
|
2011-06-21 21:51:26 +08:00
|
|
|
|
2012-10-04 09:19:09 +08:00
|
|
|
if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC ||
|
|
|
|
ctx->codec_mode == S5P_MFC_CODEC_H264_ENC)
|
|
|
|
ctx->ctx.size = buf_size->h264_ctx;
|
2011-06-21 21:51:26 +08:00
|
|
|
else
|
2012-10-04 09:19:09 +08:00
|
|
|
ctx->ctx.size = buf_size->non_h264_ctx;
|
2013-01-03 18:06:04 +08:00
|
|
|
|
2017-03-20 18:49:24 +08:00
|
|
|
ret = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &ctx->ctx);
|
2013-01-03 18:06:04 +08:00
|
|
|
if (ret) {
|
|
|
|
mfc_err("Failed to allocate instance buffer\n");
|
|
|
|
return ret;
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
2012-10-04 09:19:09 +08:00
|
|
|
ctx->ctx.ofs = OFFSETA(ctx->ctx.dma);
|
2013-01-03 18:06:04 +08:00
|
|
|
|
2011-06-21 21:51:26 +08:00
|
|
|
/* Zero content of the allocated memory */
|
2012-10-04 09:19:09 +08:00
|
|
|
memset(ctx->ctx.virt, 0, ctx->ctx.size);
|
2011-06-21 21:51:26 +08:00
|
|
|
wmb();
|
2012-10-04 09:19:07 +08:00
|
|
|
|
|
|
|
/* Initialize shared memory */
|
2013-01-03 18:06:04 +08:00
|
|
|
ctx->shm.size = buf_size->shm;
|
2017-03-20 18:49:24 +08:00
|
|
|
ret = s5p_mfc_alloc_priv_buf(dev, BANK_L_CTX, &ctx->shm);
|
2013-01-03 18:06:04 +08:00
|
|
|
if (ret) {
|
|
|
|
mfc_err("Failed to allocate shared memory buffer\n");
|
2017-02-08 19:16:02 +08:00
|
|
|
s5p_mfc_release_priv_buf(dev, &ctx->ctx);
|
2013-01-03 18:06:04 +08:00
|
|
|
return ret;
|
2012-10-04 09:19:07 +08:00
|
|
|
}
|
2013-01-03 18:06:04 +08:00
|
|
|
|
2012-10-04 09:19:07 +08:00
|
|
|
/* shared memory offset only keeps the offset from base (port a) */
|
2017-03-20 18:49:24 +08:00
|
|
|
ctx->shm.ofs = ctx->shm.dma - dev->dma_base[BANK_L_CTX];
|
2012-10-04 09:19:09 +08:00
|
|
|
BUG_ON(ctx->shm.ofs & ((1 << MFC_BANK1_ALIGN_ORDER) - 1));
|
2012-10-04 09:19:07 +08:00
|
|
|
|
2013-01-03 18:06:04 +08:00
|
|
|
memset(ctx->shm.virt, 0, buf_size->shm);
|
2012-10-04 09:19:07 +08:00
|
|
|
wmb();
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release instance buffer */
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_release_instance_buffer_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
2017-02-08 19:16:02 +08:00
|
|
|
s5p_mfc_release_priv_buf(ctx->dev, &ctx->ctx);
|
|
|
|
s5p_mfc_release_priv_buf(ctx->dev, &ctx->shm);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_alloc_dev_context_buffer_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
/* NOP */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_release_dev_context_buffer_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
/* NOP */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void s5p_mfc_write_info_v5(struct s5p_mfc_ctx *ctx, unsigned int data,
|
2012-10-04 09:19:07 +08:00
|
|
|
unsigned int ofs)
|
|
|
|
{
|
2015-05-28 19:11:47 +08:00
|
|
|
*(u32 *)(ctx->shm.virt + ofs) = data;
|
2012-10-04 09:19:07 +08:00
|
|
|
wmb();
|
|
|
|
}
|
|
|
|
|
2012-10-04 09:19:08 +08:00
|
|
|
static unsigned int s5p_mfc_read_info_v5(struct s5p_mfc_ctx *ctx,
|
2015-03-04 21:55:22 +08:00
|
|
|
unsigned long ofs)
|
2012-10-04 09:19:07 +08:00
|
|
|
{
|
|
|
|
rmb();
|
2015-05-28 19:11:47 +08:00
|
|
|
return *(u32 *)(ctx->shm.virt + ofs);
|
2012-10-04 09:19:07 +08:00
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_dec_calc_dpb_size_v5(struct s5p_mfc_ctx *ctx)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
2012-10-04 09:19:09 +08:00
|
|
|
unsigned int guard_width, guard_height;
|
|
|
|
|
|
|
|
ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN);
|
|
|
|
ctx->buf_height = ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
mfc_debug(2,
|
|
|
|
"SEQ Done: Movie dimensions %dx%d, buffer dimensions: %dx%d\n",
|
|
|
|
ctx->img_width, ctx->img_height, ctx->buf_width,
|
|
|
|
ctx->buf_height);
|
|
|
|
|
|
|
|
if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC) {
|
|
|
|
ctx->luma_size = ALIGN(ctx->buf_width * ctx->buf_height,
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
|
|
|
ctx->chroma_size = ALIGN(ctx->buf_width *
|
|
|
|
ALIGN((ctx->img_height >> 1),
|
|
|
|
S5P_FIMV_NV12MT_VALIGN),
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
|
|
|
ctx->mv_size = ALIGN(ctx->buf_width *
|
|
|
|
ALIGN((ctx->buf_height >> 2),
|
|
|
|
S5P_FIMV_NV12MT_VALIGN),
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
|
|
|
} else {
|
|
|
|
guard_width =
|
|
|
|
ALIGN(ctx->img_width + 24, S5P_FIMV_NV12MT_HALIGN);
|
|
|
|
guard_height =
|
|
|
|
ALIGN(ctx->img_height + 16, S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
ctx->luma_size = ALIGN(guard_width * guard_height,
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
|
|
|
|
|
|
|
guard_width =
|
|
|
|
ALIGN(ctx->img_width + 16, S5P_FIMV_NV12MT_HALIGN);
|
|
|
|
guard_height =
|
|
|
|
ALIGN((ctx->img_height >> 1) + 4,
|
|
|
|
S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
ctx->chroma_size = ALIGN(guard_width * guard_height,
|
|
|
|
S5P_FIMV_DEC_BUF_ALIGN);
|
|
|
|
|
|
|
|
ctx->mv_size = 0;
|
|
|
|
}
|
2012-10-04 09:19:08 +08:00
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_enc_calc_src_size_v5(struct s5p_mfc_ctx *ctx)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
2012-10-04 09:19:09 +08:00
|
|
|
if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M) {
|
|
|
|
ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN);
|
|
|
|
|
|
|
|
ctx->luma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN)
|
|
|
|
* ALIGN(ctx->img_height, S5P_FIMV_NV12M_LVALIGN);
|
|
|
|
ctx->chroma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN)
|
|
|
|
* ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12M_CVALIGN);
|
|
|
|
|
|
|
|
ctx->luma_size = ALIGN(ctx->luma_size, S5P_FIMV_NV12M_SALIGN);
|
|
|
|
ctx->chroma_size =
|
|
|
|
ALIGN(ctx->chroma_size, S5P_FIMV_NV12M_SALIGN);
|
|
|
|
} else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT) {
|
|
|
|
ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN);
|
|
|
|
|
|
|
|
ctx->luma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN)
|
|
|
|
* ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
ctx->chroma_size =
|
|
|
|
ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN)
|
|
|
|
* ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
|
|
|
|
ctx->luma_size = ALIGN(ctx->luma_size, S5P_FIMV_NV12MT_SALIGN);
|
|
|
|
ctx->chroma_size =
|
|
|
|
ALIGN(ctx->chroma_size, S5P_FIMV_NV12MT_SALIGN);
|
|
|
|
}
|
2012-10-04 09:19:08 +08:00
|
|
|
}
|
|
|
|
|
2011-06-21 21:51:26 +08:00
|
|
|
/* Set registers for decoding temporary buffers */
|
2012-10-04 09:19:08 +08:00
|
|
|
static void s5p_mfc_set_dec_desc_buffer(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
2012-10-04 09:19:09 +08:00
|
|
|
struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
|
2011-06-21 21:51:26 +08:00
|
|
|
|
2012-10-04 09:19:09 +08:00
|
|
|
mfc_write(dev, OFFSETA(ctx->dsc.dma), S5P_FIMV_SI_CH0_DESC_ADR);
|
|
|
|
mfc_write(dev, buf_size->dsc, S5P_FIMV_SI_CH0_DESC_SIZE);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set registers for shared buffer */
|
2012-05-10 14:32:01 +08:00
|
|
|
static void s5p_mfc_set_shared_buffer(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
2012-10-04 09:19:09 +08:00
|
|
|
mfc_write(dev, ctx->shm.ofs, S5P_FIMV_SI_CH0_HOST_WR_ADR);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set registers for decoding stream buffer */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_set_dec_stream_buffer_v5(struct s5p_mfc_ctx *ctx,
|
|
|
|
int buf_addr, unsigned int start_num_byte,
|
|
|
|
unsigned int buf_size)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr), S5P_FIMV_SI_CH0_SB_ST_ADR);
|
|
|
|
mfc_write(dev, ctx->dec_src_buf_size, S5P_FIMV_SI_CH0_CPB_SIZE);
|
|
|
|
mfc_write(dev, buf_size, S5P_FIMV_SI_CH0_SB_FRM_SIZE);
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, start_num_byte, START_BYTE_NUM);
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set decoding frame buffer */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_set_dec_frame_buffer_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
2014-09-04 10:28:43 +08:00
|
|
|
unsigned int frame_size_lu, i;
|
2011-06-21 21:51:26 +08:00
|
|
|
unsigned int frame_size_ch, frame_size_mv;
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
unsigned int dpb;
|
|
|
|
size_t buf_addr1, buf_addr2;
|
|
|
|
int buf_size1, buf_size2;
|
|
|
|
|
2013-01-03 18:06:04 +08:00
|
|
|
buf_addr1 = ctx->bank1.dma;
|
|
|
|
buf_size1 = ctx->bank1.size;
|
|
|
|
buf_addr2 = ctx->bank2.dma;
|
|
|
|
buf_size2 = ctx->bank2.size;
|
2011-06-21 21:51:26 +08:00
|
|
|
dpb = mfc_read(dev, S5P_FIMV_SI_CH0_DPB_CONF_CTRL) &
|
|
|
|
~S5P_FIMV_DPB_COUNT_MASK;
|
|
|
|
mfc_write(dev, ctx->total_dpb_count | dpb,
|
|
|
|
S5P_FIMV_SI_CH0_DPB_CONF_CTRL);
|
|
|
|
s5p_mfc_set_shared_buffer(ctx);
|
|
|
|
switch (ctx->codec_mode) {
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_H264_DEC:
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_H264_VERT_NB_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_VERT_NB_MV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_VERT_NB_MV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H264_NB_IP_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_NB_IP_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_NB_IP_SIZE;
|
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_MPEG4_DEC:
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_NB_DCAC_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_NB_DCAC_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_NB_DCAC_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_UP_NB_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_UPNB_MV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_UPNB_MV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_SA_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_SP_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_STX_PARSER_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_STX_PARSER_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_OT_LINE_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE;
|
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_H263_DEC:
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_OT_LINE_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_UP_NB_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_UPNB_MV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_UPNB_MV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_SA_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_NB_DCAC_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_NB_DCAC_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_NB_DCAC_SIZE;
|
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_VC1_DEC:
|
|
|
|
case S5P_MFC_CODEC_VC1RCV_DEC:
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_NB_DCAC_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_NB_DCAC_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_NB_DCAC_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_OT_LINE_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_UP_NB_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_UPNB_MV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_UPNB_MV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_SA_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_BITPLANE3_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_VC1_BITPLANE_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_VC1_BITPLANE_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_BITPLANE2_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_VC1_BITPLANE_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_VC1_BITPLANE_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_BITPLANE1_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_DEC_VC1_BITPLANE_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_DEC_VC1_BITPLANE_SIZE;
|
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_MPEG2_DEC:
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mfc_err("Unknown codec for decoding (%x)\n",
|
|
|
|
ctx->codec_mode);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2014-09-04 10:28:43 +08:00
|
|
|
frame_size_lu = ctx->luma_size;
|
2011-06-21 21:51:26 +08:00
|
|
|
frame_size_ch = ctx->chroma_size;
|
|
|
|
frame_size_mv = ctx->mv_size;
|
2014-09-04 10:28:43 +08:00
|
|
|
mfc_debug(2, "Frm size: %d ch: %d mv: %d\n", frame_size_lu, frame_size_ch,
|
2011-06-21 21:51:26 +08:00
|
|
|
frame_size_mv);
|
|
|
|
for (i = 0; i < ctx->total_dpb_count; i++) {
|
|
|
|
/* Bank2 */
|
[media] s5p_mfc_opr_v5: Fix lots of warnings on x86_64
When compiled on x86_64, several warnings popup:
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:476:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:480:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:485:4: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:493:2: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:570:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:570:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:609:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:609:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:640:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:640:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:666:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:666:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-25 05:32:54 +08:00
|
|
|
mfc_debug(2, "Luma %d: %zx\n", i,
|
2011-06-21 21:51:26 +08:00
|
|
|
ctx->dst_bufs[i].cookie.raw.luma);
|
|
|
|
mfc_write(dev, OFFSETB(ctx->dst_bufs[i].cookie.raw.luma),
|
|
|
|
S5P_FIMV_DEC_LUMA_ADR + i * 4);
|
[media] s5p_mfc_opr_v5: Fix lots of warnings on x86_64
When compiled on x86_64, several warnings popup:
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:476:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:480:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:485:4: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:493:2: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:570:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:570:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:609:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:609:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:640:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:640:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:666:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:666:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-25 05:32:54 +08:00
|
|
|
mfc_debug(2, "\tChroma %d: %zx\n", i,
|
2011-06-21 21:51:26 +08:00
|
|
|
ctx->dst_bufs[i].cookie.raw.chroma);
|
|
|
|
mfc_write(dev, OFFSETA(ctx->dst_bufs[i].cookie.raw.chroma),
|
|
|
|
S5P_FIMV_DEC_CHROMA_ADR + i * 4);
|
2012-10-04 09:19:08 +08:00
|
|
|
if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC) {
|
[media] s5p_mfc_opr_v5: Fix lots of warnings on x86_64
When compiled on x86_64, several warnings popup:
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:476:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:480:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:485:4: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:493:2: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:570:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:570:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:609:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:609:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:640:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:640:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:666:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:666:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-25 05:32:54 +08:00
|
|
|
mfc_debug(2, "\tBuf2: %zx, size: %d\n",
|
2011-06-21 21:51:26 +08:00
|
|
|
buf_addr2, buf_size2);
|
|
|
|
mfc_write(dev, OFFSETB(buf_addr2),
|
|
|
|
S5P_FIMV_H264_MV_ADR + i * 4);
|
|
|
|
buf_addr2 += frame_size_mv;
|
|
|
|
buf_size2 -= frame_size_mv;
|
|
|
|
}
|
|
|
|
}
|
[media] s5p_mfc_opr_v5: Fix lots of warnings on x86_64
When compiled on x86_64, several warnings popup:
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:476:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:480:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:485:4: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:493:2: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:570:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:570:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:609:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:609:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:640:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:640:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:666:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
drivers/media//platform/s5p-mfc/s5p_mfc_opr_v5.c:666:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-25 05:32:54 +08:00
|
|
|
mfc_debug(2, "Buf1: %zu, buf_size1: %d\n", buf_addr1, buf_size1);
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_debug(2, "Buf 1/2 size after: %d/%d (frames %d)\n",
|
|
|
|
buf_size1, buf_size2, ctx->total_dpb_count);
|
|
|
|
if (buf_size1 < 0 || buf_size2 < 0) {
|
|
|
|
mfc_debug(2, "Not enough memory has been allocated\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2014-09-04 10:28:43 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, frame_size_lu, ALLOC_LUMA_DPB_SIZE);
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, frame_size_ch, ALLOC_CHROMA_DPB_SIZE);
|
2012-10-04 09:19:08 +08:00
|
|
|
if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC)
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, frame_size_mv, ALLOC_MV_SIZE);
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_write(dev, ((S5P_FIMV_CH_INIT_BUFS & S5P_FIMV_CH_MASK)
|
|
|
|
<< S5P_FIMV_CH_SHIFT) | (ctx->inst_no),
|
|
|
|
S5P_FIMV_SI_CH0_INST_ID);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set registers for encoding stream buffer */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_set_enc_stream_buffer_v5(struct s5p_mfc_ctx *ctx,
|
2011-06-21 21:51:26 +08:00
|
|
|
unsigned long addr, unsigned int size)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
|
|
|
|
mfc_write(dev, OFFSETA(addr), S5P_FIMV_ENC_SI_CH0_SB_ADR);
|
|
|
|
mfc_write(dev, size, S5P_FIMV_ENC_SI_CH0_SB_SIZE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_set_enc_frame_buffer_v5(struct s5p_mfc_ctx *ctx,
|
2011-06-21 21:51:26 +08:00
|
|
|
unsigned long y_addr, unsigned long c_addr)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
|
|
|
|
mfc_write(dev, OFFSETB(y_addr), S5P_FIMV_ENC_SI_CH0_CUR_Y_ADR);
|
|
|
|
mfc_write(dev, OFFSETB(c_addr), S5P_FIMV_ENC_SI_CH0_CUR_C_ADR);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_get_enc_frame_buffer_v5(struct s5p_mfc_ctx *ctx,
|
2011-06-21 21:51:26 +08:00
|
|
|
unsigned long *y_addr, unsigned long *c_addr)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
|
2017-03-20 18:49:24 +08:00
|
|
|
*y_addr = dev->dma_base[BANK_R_CTX] +
|
2017-02-08 16:53:48 +08:00
|
|
|
(mfc_read(dev, S5P_FIMV_ENCODED_Y_ADDR) << MFC_OFFSET_SHIFT);
|
2017-03-20 18:49:24 +08:00
|
|
|
*c_addr = dev->dma_base[BANK_R_CTX] +
|
2017-02-08 16:53:48 +08:00
|
|
|
(mfc_read(dev, S5P_FIMV_ENCODED_C_ADDR) << MFC_OFFSET_SHIFT);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set encoding ref & codec buffer */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_set_enc_ref_buffer_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
size_t buf_addr1, buf_addr2;
|
|
|
|
size_t buf_size1, buf_size2;
|
|
|
|
unsigned int enc_ref_y_size, enc_ref_c_size;
|
|
|
|
unsigned int guard_width, guard_height;
|
|
|
|
int i;
|
|
|
|
|
2013-01-03 18:06:04 +08:00
|
|
|
buf_addr1 = ctx->bank1.dma;
|
|
|
|
buf_size1 = ctx->bank1.size;
|
|
|
|
buf_addr2 = ctx->bank2.dma;
|
|
|
|
buf_size2 = ctx->bank2.size;
|
2011-06-21 21:51:26 +08:00
|
|
|
enc_ref_y_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN)
|
|
|
|
* ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
enc_ref_y_size = ALIGN(enc_ref_y_size, S5P_FIMV_NV12MT_SALIGN);
|
2012-10-04 09:19:08 +08:00
|
|
|
if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) {
|
2011-06-21 21:51:26 +08:00
|
|
|
enc_ref_c_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN)
|
|
|
|
* ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
enc_ref_c_size = ALIGN(enc_ref_c_size, S5P_FIMV_NV12MT_SALIGN);
|
|
|
|
} else {
|
|
|
|
guard_width = ALIGN(ctx->img_width + 16,
|
|
|
|
S5P_FIMV_NV12MT_HALIGN);
|
|
|
|
guard_height = ALIGN((ctx->img_height >> 1) + 4,
|
|
|
|
S5P_FIMV_NV12MT_VALIGN);
|
|
|
|
enc_ref_c_size = ALIGN(guard_width * guard_height,
|
|
|
|
S5P_FIMV_NV12MT_SALIGN);
|
|
|
|
}
|
2014-09-25 06:07:36 +08:00
|
|
|
mfc_debug(2, "buf_size1: %zu, buf_size2: %zu\n", buf_size1, buf_size2);
|
2011-06-21 21:51:26 +08:00
|
|
|
switch (ctx->codec_mode) {
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_H264_ENC:
|
2011-06-21 21:51:26 +08:00
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_ENC_REF0_LUMA_ADR + (4 * i));
|
|
|
|
buf_addr1 += enc_ref_y_size;
|
|
|
|
buf_size1 -= enc_ref_y_size;
|
|
|
|
|
|
|
|
mfc_write(dev, OFFSETB(buf_addr2),
|
|
|
|
S5P_FIMV_ENC_REF2_LUMA_ADR + (4 * i));
|
|
|
|
buf_addr2 += enc_ref_y_size;
|
|
|
|
buf_size2 -= enc_ref_y_size;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
mfc_write(dev, OFFSETB(buf_addr2),
|
|
|
|
S5P_FIMV_ENC_REF0_CHROMA_ADR + (4 * i));
|
|
|
|
buf_addr2 += enc_ref_c_size;
|
|
|
|
buf_size2 -= enc_ref_c_size;
|
|
|
|
}
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H264_UP_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_UPMV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_UPMV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_H264_COZERO_FLAG_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_COLFLG_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_COLFLG_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_H264_UP_INTRA_MD_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_INTRAMD_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_INTRAMD_SIZE;
|
|
|
|
mfc_write(dev, OFFSETB(buf_addr2),
|
|
|
|
S5P_FIMV_H264_UP_INTRA_PRED_ADR);
|
|
|
|
buf_addr2 += S5P_FIMV_ENC_INTRAPRED_SIZE;
|
|
|
|
buf_size2 -= S5P_FIMV_ENC_INTRAPRED_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_H264_NBOR_INFO_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_NBORINFO_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_NBORINFO_SIZE;
|
2014-09-25 06:07:36 +08:00
|
|
|
mfc_debug(2, "buf_size1: %zu, buf_size2: %zu\n",
|
2011-06-21 21:51:26 +08:00
|
|
|
buf_size1, buf_size2);
|
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_MPEG4_ENC:
|
2011-06-21 21:51:26 +08:00
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_ENC_REF0_LUMA_ADR + (4 * i));
|
|
|
|
buf_addr1 += enc_ref_y_size;
|
|
|
|
buf_size1 -= enc_ref_y_size;
|
|
|
|
mfc_write(dev, OFFSETB(buf_addr2),
|
|
|
|
S5P_FIMV_ENC_REF2_LUMA_ADR + (4 * i));
|
|
|
|
buf_addr2 += enc_ref_y_size;
|
|
|
|
buf_size2 -= enc_ref_y_size;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
mfc_write(dev, OFFSETB(buf_addr2),
|
|
|
|
S5P_FIMV_ENC_REF0_CHROMA_ADR + (4 * i));
|
|
|
|
buf_addr2 += enc_ref_c_size;
|
|
|
|
buf_size2 -= enc_ref_c_size;
|
|
|
|
}
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_UP_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_UPMV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_UPMV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_MPEG4_COZERO_FLAG_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_COLFLG_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_COLFLG_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_MPEG4_ACDC_COEF_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_ACDCCOEF_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_ACDCCOEF_SIZE;
|
2014-09-25 06:07:36 +08:00
|
|
|
mfc_debug(2, "buf_size1: %zu, buf_size2: %zu\n",
|
2011-06-21 21:51:26 +08:00
|
|
|
buf_size1, buf_size2);
|
|
|
|
break;
|
2012-10-04 09:19:08 +08:00
|
|
|
case S5P_MFC_CODEC_H263_ENC:
|
2011-06-21 21:51:26 +08:00
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1),
|
|
|
|
S5P_FIMV_ENC_REF0_LUMA_ADR + (4 * i));
|
|
|
|
buf_addr1 += enc_ref_y_size;
|
|
|
|
buf_size1 -= enc_ref_y_size;
|
|
|
|
mfc_write(dev, OFFSETB(buf_addr2),
|
|
|
|
S5P_FIMV_ENC_REF2_LUMA_ADR + (4 * i));
|
|
|
|
buf_addr2 += enc_ref_y_size;
|
|
|
|
buf_size2 -= enc_ref_y_size;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
mfc_write(dev, OFFSETB(buf_addr2),
|
|
|
|
S5P_FIMV_ENC_REF0_CHROMA_ADR + (4 * i));
|
|
|
|
buf_addr2 += enc_ref_c_size;
|
|
|
|
buf_size2 -= enc_ref_c_size;
|
|
|
|
}
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_UP_MV_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_UPMV_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_UPMV_SIZE;
|
|
|
|
mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_ACDC_COEF_ADR);
|
|
|
|
buf_addr1 += S5P_FIMV_ENC_ACDCCOEF_SIZE;
|
|
|
|
buf_size1 -= S5P_FIMV_ENC_ACDCCOEF_SIZE;
|
2014-09-25 06:07:36 +08:00
|
|
|
mfc_debug(2, "buf_size1: %zu, buf_size2: %zu\n",
|
2011-06-21 21:51:26 +08:00
|
|
|
buf_size1, buf_size2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mfc_err("Unknown codec set for encoding: %d\n",
|
|
|
|
ctx->codec_mode);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_enc_params *p = &ctx->enc_params;
|
|
|
|
unsigned int reg;
|
|
|
|
unsigned int shm;
|
|
|
|
|
|
|
|
/* width */
|
|
|
|
mfc_write(dev, ctx->img_width, S5P_FIMV_ENC_HSIZE_PX);
|
|
|
|
/* height */
|
|
|
|
mfc_write(dev, ctx->img_height, S5P_FIMV_ENC_VSIZE_PX);
|
|
|
|
/* pictype : enable, IDR period */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_PIC_TYPE_CTRL);
|
|
|
|
reg |= (1 << 18);
|
|
|
|
reg &= ~(0xFFFF);
|
|
|
|
reg |= p->gop_size;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_PIC_TYPE_CTRL);
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_B_RECON_WRITE_ON);
|
|
|
|
/* multi-slice control */
|
|
|
|
/* multi-slice MB number or bit size */
|
|
|
|
mfc_write(dev, p->slice_mode, S5P_FIMV_ENC_MSLICE_CTRL);
|
|
|
|
if (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) {
|
|
|
|
mfc_write(dev, p->slice_mb, S5P_FIMV_ENC_MSLICE_MB);
|
|
|
|
} else if (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES) {
|
|
|
|
mfc_write(dev, p->slice_bit, S5P_FIMV_ENC_MSLICE_BIT);
|
|
|
|
} else {
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_MSLICE_MB);
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_MSLICE_BIT);
|
|
|
|
}
|
|
|
|
/* cyclic intra refresh */
|
|
|
|
mfc_write(dev, p->intra_refresh_mb, S5P_FIMV_ENC_CIR_CTRL);
|
|
|
|
/* memory structure cur. frame */
|
|
|
|
if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M)
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_MAP_FOR_CUR);
|
|
|
|
else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT)
|
|
|
|
mfc_write(dev, 3, S5P_FIMV_ENC_MAP_FOR_CUR);
|
|
|
|
/* padding control & value */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_PADDING_CTRL);
|
|
|
|
if (p->pad) {
|
|
|
|
/** enable */
|
|
|
|
reg |= (1 << 31);
|
|
|
|
/** cr value */
|
|
|
|
reg &= ~(0xFF << 16);
|
|
|
|
reg |= (p->pad_cr << 16);
|
|
|
|
/** cb value */
|
|
|
|
reg &= ~(0xFF << 8);
|
|
|
|
reg |= (p->pad_cb << 8);
|
|
|
|
/** y value */
|
|
|
|
reg &= ~(0xFF);
|
|
|
|
reg |= (p->pad_luma);
|
|
|
|
} else {
|
|
|
|
/** disable & all value clear */
|
|
|
|
reg = 0;
|
|
|
|
}
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_PADDING_CTRL);
|
|
|
|
/* rate control config. */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_RC_CONFIG);
|
|
|
|
/** frame-level rate control */
|
|
|
|
reg &= ~(0x1 << 9);
|
|
|
|
reg |= (p->rc_frame << 9);
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_RC_CONFIG);
|
|
|
|
/* bit rate */
|
|
|
|
if (p->rc_frame)
|
|
|
|
mfc_write(dev, p->rc_bitrate,
|
|
|
|
S5P_FIMV_ENC_RC_BIT_RATE);
|
|
|
|
else
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_RC_BIT_RATE);
|
|
|
|
/* reaction coefficient */
|
|
|
|
if (p->rc_frame)
|
|
|
|
mfc_write(dev, p->rc_reaction_coeff, S5P_FIMV_ENC_RC_RPARA);
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* seq header ctrl */
|
|
|
|
shm &= ~(0x1 << 3);
|
|
|
|
shm |= (p->seq_hdr_mode << 3);
|
|
|
|
/* frame skip mode */
|
|
|
|
shm &= ~(0x3 << 1);
|
|
|
|
shm |= (p->frame_skip_mode << 1);
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* fixed target bit */
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, p->fixed_target_bit, RC_CONTROL_CONFIG);
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_enc_params *p = &ctx->enc_params;
|
|
|
|
struct s5p_mfc_h264_enc_params *p_264 = &p->codec.h264;
|
|
|
|
unsigned int reg;
|
|
|
|
unsigned int shm;
|
|
|
|
|
|
|
|
s5p_mfc_set_enc_params(ctx);
|
|
|
|
/* pictype : number of B */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_PIC_TYPE_CTRL);
|
|
|
|
/* num_b_frame - 0 ~ 2 */
|
|
|
|
reg &= ~(0x3 << 16);
|
|
|
|
reg |= (p->num_b_frame << 16);
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_PIC_TYPE_CTRL);
|
|
|
|
/* profile & level */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_PROFILE);
|
|
|
|
/* level */
|
|
|
|
reg &= ~(0xFF << 8);
|
|
|
|
reg |= (p_264->level << 8);
|
|
|
|
/* profile - 0 ~ 2 */
|
|
|
|
reg &= ~(0x3F);
|
|
|
|
reg |= p_264->profile;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_PROFILE);
|
|
|
|
/* interlace */
|
2012-10-04 09:19:09 +08:00
|
|
|
mfc_write(dev, p_264->interlace, S5P_FIMV_ENC_PIC_STRUCT);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* height */
|
2012-10-04 09:19:09 +08:00
|
|
|
if (p_264->interlace)
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_write(dev, ctx->img_height >> 1, S5P_FIMV_ENC_VSIZE_PX);
|
|
|
|
/* loopfilter ctrl */
|
|
|
|
mfc_write(dev, p_264->loop_filter_mode, S5P_FIMV_ENC_LF_CTRL);
|
|
|
|
/* loopfilter alpha offset */
|
|
|
|
if (p_264->loop_filter_alpha < 0) {
|
|
|
|
reg = 0x10;
|
|
|
|
reg |= (0xFF - p_264->loop_filter_alpha) + 1;
|
|
|
|
} else {
|
|
|
|
reg = 0x00;
|
|
|
|
reg |= (p_264->loop_filter_alpha & 0xF);
|
|
|
|
}
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_ALPHA_OFF);
|
|
|
|
/* loopfilter beta offset */
|
|
|
|
if (p_264->loop_filter_beta < 0) {
|
|
|
|
reg = 0x10;
|
|
|
|
reg |= (0xFF - p_264->loop_filter_beta) + 1;
|
|
|
|
} else {
|
|
|
|
reg = 0x00;
|
|
|
|
reg |= (p_264->loop_filter_beta & 0xF);
|
|
|
|
}
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_BETA_OFF);
|
|
|
|
/* entropy coding mode */
|
|
|
|
if (p_264->entropy_mode == V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC)
|
|
|
|
mfc_write(dev, 1, S5P_FIMV_ENC_H264_ENTROPY_MODE);
|
|
|
|
else
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_H264_ENTROPY_MODE);
|
|
|
|
/* number of ref. picture */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_H264_NUM_OF_REF);
|
|
|
|
/* num of ref. pictures of P */
|
|
|
|
reg &= ~(0x3 << 5);
|
|
|
|
reg |= (p_264->num_ref_pic_4p << 5);
|
|
|
|
/* max number of ref. pictures */
|
|
|
|
reg &= ~(0x1F);
|
|
|
|
reg |= p_264->max_ref_pic;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_H264_NUM_OF_REF);
|
|
|
|
/* 8x8 transform enable */
|
|
|
|
mfc_write(dev, p_264->_8x8_transform, S5P_FIMV_ENC_H264_TRANS_FLAG);
|
|
|
|
/* rate control config. */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_RC_CONFIG);
|
|
|
|
/* macroblock level rate control */
|
|
|
|
reg &= ~(0x1 << 8);
|
2012-10-04 09:19:09 +08:00
|
|
|
reg |= (p->rc_mb << 8);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* frame QP */
|
|
|
|
reg &= ~(0x3F);
|
|
|
|
reg |= p_264->rc_frame_qp;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_RC_CONFIG);
|
|
|
|
/* frame rate */
|
|
|
|
if (p->rc_frame && p->rc_framerate_denom)
|
|
|
|
mfc_write(dev, p->rc_framerate_num * 1000
|
|
|
|
/ p->rc_framerate_denom, S5P_FIMV_ENC_RC_FRAME_RATE);
|
|
|
|
else
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_RC_FRAME_RATE);
|
|
|
|
/* max & min value of QP */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_RC_QBOUND);
|
|
|
|
/* max QP */
|
|
|
|
reg &= ~(0x3F << 8);
|
|
|
|
reg |= (p_264->rc_max_qp << 8);
|
|
|
|
/* min QP */
|
|
|
|
reg &= ~(0x3F);
|
|
|
|
reg |= p_264->rc_min_qp;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND);
|
|
|
|
/* macroblock adaptive scaling features */
|
2012-10-04 09:19:09 +08:00
|
|
|
if (p->rc_mb) {
|
2011-06-21 21:51:26 +08:00
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_RC_MB_CTRL);
|
|
|
|
/* dark region */
|
|
|
|
reg &= ~(0x1 << 3);
|
|
|
|
reg |= (p_264->rc_mb_dark << 3);
|
|
|
|
/* smooth region */
|
|
|
|
reg &= ~(0x1 << 2);
|
|
|
|
reg |= (p_264->rc_mb_smooth << 2);
|
|
|
|
/* static region */
|
|
|
|
reg &= ~(0x1 << 1);
|
|
|
|
reg |= (p_264->rc_mb_static << 1);
|
|
|
|
/* high activity region */
|
|
|
|
reg &= ~(0x1);
|
|
|
|
reg |= p_264->rc_mb_activity;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_RC_MB_CTRL);
|
|
|
|
}
|
2012-10-04 09:19:09 +08:00
|
|
|
if (!p->rc_frame && !p->rc_mb) {
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP);
|
2011-06-21 21:51:26 +08:00
|
|
|
shm &= ~(0xFFF);
|
|
|
|
shm |= ((p_264->rc_b_frame_qp & 0x3F) << 6);
|
|
|
|
shm |= (p_264->rc_p_frame_qp & 0x3F);
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
/* extended encoder ctrl */
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* AR VUI control */
|
|
|
|
shm &= ~(0x1 << 15);
|
|
|
|
shm |= (p_264->vui_sar << 1);
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
if (p_264->vui_sar) {
|
|
|
|
/* aspect ration IDC */
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, SAMPLE_ASPECT_RATIO_IDC);
|
2011-06-21 21:51:26 +08:00
|
|
|
shm &= ~(0xFF);
|
|
|
|
shm |= p_264->vui_sar_idc;
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, SAMPLE_ASPECT_RATIO_IDC);
|
2011-06-21 21:51:26 +08:00
|
|
|
if (p_264->vui_sar_idc == 0xFF) {
|
|
|
|
/* sample AR info */
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, EXTENDED_SAR);
|
2011-06-21 21:51:26 +08:00
|
|
|
shm &= ~(0xFFFFFFFF);
|
|
|
|
shm |= p_264->vui_ext_sar_width << 16;
|
|
|
|
shm |= p_264->vui_ext_sar_height;
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, EXTENDED_SAR);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* intra picture period for H.264 */
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, H264_I_PERIOD);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* control */
|
|
|
|
shm &= ~(0x1 << 16);
|
|
|
|
shm |= (p_264->open_gop << 16);
|
|
|
|
/* value */
|
|
|
|
if (p_264->open_gop) {
|
|
|
|
shm &= ~(0xFFFF);
|
|
|
|
shm |= p_264->open_gop_size;
|
|
|
|
}
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, H264_I_PERIOD);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* extended encoder ctrl */
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* vbv buffer size */
|
|
|
|
if (p->frame_skip_mode ==
|
|
|
|
V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
|
|
|
|
shm &= ~(0xFFFF << 16);
|
|
|
|
shm |= (p_264->cpb_size << 16);
|
|
|
|
}
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_enc_params *p = &ctx->enc_params;
|
|
|
|
struct s5p_mfc_mpeg4_enc_params *p_mpeg4 = &p->codec.mpeg4;
|
|
|
|
unsigned int reg;
|
|
|
|
unsigned int shm;
|
|
|
|
unsigned int framerate;
|
|
|
|
|
|
|
|
s5p_mfc_set_enc_params(ctx);
|
|
|
|
/* pictype : number of B */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_PIC_TYPE_CTRL);
|
|
|
|
/* num_b_frame - 0 ~ 2 */
|
|
|
|
reg &= ~(0x3 << 16);
|
|
|
|
reg |= (p->num_b_frame << 16);
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_PIC_TYPE_CTRL);
|
|
|
|
/* profile & level */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_PROFILE);
|
|
|
|
/* level */
|
|
|
|
reg &= ~(0xFF << 8);
|
|
|
|
reg |= (p_mpeg4->level << 8);
|
|
|
|
/* profile - 0 ~ 2 */
|
|
|
|
reg &= ~(0x3F);
|
|
|
|
reg |= p_mpeg4->profile;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_PROFILE);
|
|
|
|
/* quarter_pixel */
|
|
|
|
mfc_write(dev, p_mpeg4->quarter_pixel, S5P_FIMV_ENC_MPEG4_QUART_PXL);
|
|
|
|
/* qp */
|
|
|
|
if (!p->rc_frame) {
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP);
|
2011-06-21 21:51:26 +08:00
|
|
|
shm &= ~(0xFFF);
|
|
|
|
shm |= ((p_mpeg4->rc_b_frame_qp & 0x3F) << 6);
|
|
|
|
shm |= (p_mpeg4->rc_p_frame_qp & 0x3F);
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
/* frame rate */
|
|
|
|
if (p->rc_frame) {
|
|
|
|
if (p->rc_framerate_denom > 0) {
|
|
|
|
framerate = p->rc_framerate_num * 1000 /
|
|
|
|
p->rc_framerate_denom;
|
|
|
|
mfc_write(dev, framerate,
|
|
|
|
S5P_FIMV_ENC_RC_FRAME_RATE);
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, RC_VOP_TIMING);
|
2011-06-21 21:51:26 +08:00
|
|
|
shm &= ~(0xFFFFFFFF);
|
|
|
|
shm |= (1 << 31);
|
|
|
|
shm |= ((p->rc_framerate_num & 0x7FFF) << 16);
|
|
|
|
shm |= (p->rc_framerate_denom & 0xFFFF);
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, RC_VOP_TIMING);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_RC_FRAME_RATE);
|
|
|
|
}
|
|
|
|
/* rate control config. */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_RC_CONFIG);
|
|
|
|
/* frame QP */
|
|
|
|
reg &= ~(0x3F);
|
|
|
|
reg |= p_mpeg4->rc_frame_qp;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_RC_CONFIG);
|
|
|
|
/* max & min value of QP */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_RC_QBOUND);
|
|
|
|
/* max QP */
|
|
|
|
reg &= ~(0x3F << 8);
|
|
|
|
reg |= (p_mpeg4->rc_max_qp << 8);
|
|
|
|
/* min QP */
|
|
|
|
reg &= ~(0x3F);
|
|
|
|
reg |= p_mpeg4->rc_min_qp;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND);
|
|
|
|
/* extended encoder ctrl */
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* vbv buffer size */
|
|
|
|
if (p->frame_skip_mode ==
|
|
|
|
V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
|
|
|
|
shm &= ~(0xFFFF << 16);
|
|
|
|
shm |= (p->vbv_size << 16);
|
|
|
|
}
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_enc_params *p = &ctx->enc_params;
|
|
|
|
struct s5p_mfc_mpeg4_enc_params *p_h263 = &p->codec.mpeg4;
|
|
|
|
unsigned int reg;
|
|
|
|
unsigned int shm;
|
|
|
|
|
|
|
|
s5p_mfc_set_enc_params(ctx);
|
|
|
|
/* qp */
|
|
|
|
if (!p->rc_frame) {
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP);
|
2011-06-21 21:51:26 +08:00
|
|
|
shm &= ~(0xFFF);
|
|
|
|
shm |= (p_h263->rc_p_frame_qp & 0x3F);
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
/* frame rate */
|
|
|
|
if (p->rc_frame && p->rc_framerate_denom)
|
|
|
|
mfc_write(dev, p->rc_framerate_num * 1000
|
|
|
|
/ p->rc_framerate_denom, S5P_FIMV_ENC_RC_FRAME_RATE);
|
|
|
|
else
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_RC_FRAME_RATE);
|
|
|
|
/* rate control config. */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_RC_CONFIG);
|
|
|
|
/* frame QP */
|
|
|
|
reg &= ~(0x3F);
|
|
|
|
reg |= p_h263->rc_frame_qp;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_RC_CONFIG);
|
|
|
|
/* max & min value of QP */
|
|
|
|
reg = mfc_read(dev, S5P_FIMV_ENC_RC_QBOUND);
|
|
|
|
/* max QP */
|
|
|
|
reg &= ~(0x3F << 8);
|
|
|
|
reg |= (p_h263->rc_max_qp << 8);
|
|
|
|
/* min QP */
|
|
|
|
reg &= ~(0x3F);
|
|
|
|
reg |= p_h263->rc_min_qp;
|
|
|
|
mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND);
|
|
|
|
/* extended encoder ctrl */
|
2012-10-04 09:19:07 +08:00
|
|
|
shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
/* vbv buffer size */
|
|
|
|
if (p->frame_skip_mode ==
|
|
|
|
V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
|
|
|
|
shm &= ~(0xFFFF << 16);
|
|
|
|
shm |= (p->vbv_size << 16);
|
|
|
|
}
|
2012-10-04 09:19:07 +08:00
|
|
|
s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL);
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize decoding */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_init_decode_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
|
|
|
|
s5p_mfc_set_shared_buffer(ctx);
|
|
|
|
/* Setup loop filter, for decoding this is only valid for MPEG4 */
|
2012-10-04 09:19:08 +08:00
|
|
|
if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_DEC)
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_write(dev, ctx->loop_filter_mpeg4, S5P_FIMV_ENC_LF_CTRL);
|
|
|
|
else
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_LF_CTRL);
|
|
|
|
mfc_write(dev, ((ctx->slice_interface & S5P_FIMV_SLICE_INT_MASK) <<
|
|
|
|
S5P_FIMV_SLICE_INT_SHIFT) | (ctx->display_delay_enable <<
|
|
|
|
S5P_FIMV_DDELAY_ENA_SHIFT) | ((ctx->display_delay &
|
|
|
|
S5P_FIMV_DDELAY_VAL_MASK) << S5P_FIMV_DDELAY_VAL_SHIFT),
|
|
|
|
S5P_FIMV_SI_CH0_DPB_CONF_CTRL);
|
|
|
|
mfc_write(dev,
|
|
|
|
((S5P_FIMV_CH_SEQ_HEADER & S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT)
|
|
|
|
| (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void s5p_mfc_set_flush(struct s5p_mfc_ctx *ctx, int flush)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
unsigned int dpb;
|
|
|
|
|
|
|
|
if (flush)
|
|
|
|
dpb = mfc_read(dev, S5P_FIMV_SI_CH0_DPB_CONF_CTRL) | (
|
|
|
|
S5P_FIMV_DPB_FLUSH_MASK << S5P_FIMV_DPB_FLUSH_SHIFT);
|
|
|
|
else
|
|
|
|
dpb = mfc_read(dev, S5P_FIMV_SI_CH0_DPB_CONF_CTRL) &
|
|
|
|
~(S5P_FIMV_DPB_FLUSH_MASK << S5P_FIMV_DPB_FLUSH_SHIFT);
|
|
|
|
mfc_write(dev, dpb, S5P_FIMV_SI_CH0_DPB_CONF_CTRL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Decode a single frame */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_decode_one_frame_v5(struct s5p_mfc_ctx *ctx,
|
2011-06-21 21:51:26 +08:00
|
|
|
enum s5p_mfc_decode_arg last_frame)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
|
|
|
|
mfc_write(dev, ctx->dec_dst_flag, S5P_FIMV_SI_CH0_RELEASE_BUF);
|
|
|
|
s5p_mfc_set_shared_buffer(ctx);
|
|
|
|
s5p_mfc_set_flush(ctx, ctx->dpb_flush_flag);
|
|
|
|
/* Issue different commands to instance basing on whether it
|
|
|
|
* is the last frame or not. */
|
|
|
|
switch (last_frame) {
|
|
|
|
case MFC_DEC_FRAME:
|
|
|
|
mfc_write(dev, ((S5P_FIMV_CH_FRAME_START & S5P_FIMV_CH_MASK) <<
|
|
|
|
S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID);
|
|
|
|
break;
|
|
|
|
case MFC_DEC_LAST_FRAME:
|
|
|
|
mfc_write(dev, ((S5P_FIMV_CH_LAST_FRAME & S5P_FIMV_CH_MASK) <<
|
|
|
|
S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID);
|
|
|
|
break;
|
|
|
|
case MFC_DEC_RES_CHANGE:
|
|
|
|
mfc_write(dev, ((S5P_FIMV_CH_FRAME_START_REALLOC &
|
|
|
|
S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT) | (ctx->inst_no),
|
|
|
|
S5P_FIMV_SI_CH0_INST_ID);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mfc_debug(2, "Decoding a usual frame\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_init_encode_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
|
2012-10-04 09:19:08 +08:00
|
|
|
if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC)
|
2011-06-21 21:51:26 +08:00
|
|
|
s5p_mfc_set_enc_params_h264(ctx);
|
2012-10-04 09:19:08 +08:00
|
|
|
else if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_ENC)
|
2011-06-21 21:51:26 +08:00
|
|
|
s5p_mfc_set_enc_params_mpeg4(ctx);
|
2012-10-04 09:19:08 +08:00
|
|
|
else if (ctx->codec_mode == S5P_MFC_CODEC_H263_ENC)
|
2011-06-21 21:51:26 +08:00
|
|
|
s5p_mfc_set_enc_params_h263(ctx);
|
|
|
|
else {
|
|
|
|
mfc_err("Unknown codec for encoding (%x)\n",
|
|
|
|
ctx->codec_mode);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
s5p_mfc_set_shared_buffer(ctx);
|
|
|
|
mfc_write(dev, ((S5P_FIMV_CH_SEQ_HEADER << 16) & 0x70000) |
|
|
|
|
(ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Encode a single frame */
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_encode_one_frame_v5(struct s5p_mfc_ctx *ctx)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
2012-08-21 19:05:32 +08:00
|
|
|
int cmd;
|
2011-06-21 21:51:26 +08:00
|
|
|
/* memory structure cur. frame */
|
|
|
|
if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M)
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_ENC_MAP_FOR_CUR);
|
|
|
|
else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT)
|
|
|
|
mfc_write(dev, 3, S5P_FIMV_ENC_MAP_FOR_CUR);
|
|
|
|
s5p_mfc_set_shared_buffer(ctx);
|
2012-08-21 19:05:32 +08:00
|
|
|
|
|
|
|
if (ctx->state == MFCINST_FINISHING)
|
|
|
|
cmd = S5P_FIMV_CH_LAST_FRAME;
|
|
|
|
else
|
|
|
|
cmd = S5P_FIMV_CH_FRAME_START;
|
|
|
|
mfc_write(dev, ((cmd & S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT)
|
|
|
|
| (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID);
|
|
|
|
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void s5p_mfc_run_res_change(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0);
|
2011-06-21 21:51:26 +08:00
|
|
|
dev->curr_ctx = ctx->num;
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_decode_one_frame_v5(ctx, MFC_DEC_RES_CHANGE);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_buf *temp_vb;
|
|
|
|
|
2013-01-11 23:29:33 +08:00
|
|
|
if (ctx->state == MFCINST_FINISHING) {
|
|
|
|
last_frame = MFC_DEC_LAST_FRAME;
|
|
|
|
s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0);
|
|
|
|
dev->curr_ctx = ctx->num;
|
|
|
|
s5p_mfc_decode_one_frame_v5(ctx, last_frame);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-21 21:51:26 +08:00
|
|
|
/* Frames are being decoded */
|
|
|
|
if (list_empty(&ctx->src_queue)) {
|
|
|
|
mfc_debug(2, "No src buffers\n");
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
/* Get the next source buffer */
|
|
|
|
temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
|
2012-08-21 19:05:32 +08:00
|
|
|
temp_vb->flags |= MFC_BUF_FLAG_USED;
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_set_dec_stream_buffer_v5(ctx,
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
|
|
|
|
ctx->consumed_stream, temp_vb->b->vb2_buf.planes[0].bytesused);
|
2011-06-21 21:51:26 +08:00
|
|
|
dev->curr_ctx = ctx->num;
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
if (temp_vb->b->vb2_buf.planes[0].bytesused == 0) {
|
2011-06-21 21:51:26 +08:00
|
|
|
last_frame = MFC_DEC_LAST_FRAME;
|
|
|
|
mfc_debug(2, "Setting ctx->state to FINISHING\n");
|
|
|
|
ctx->state = MFCINST_FINISHING;
|
|
|
|
}
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_decode_one_frame_v5(ctx, last_frame);
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_buf *dst_mb;
|
|
|
|
struct s5p_mfc_buf *src_mb;
|
|
|
|
unsigned long src_y_addr, src_c_addr, dst_addr;
|
|
|
|
unsigned int dst_size;
|
|
|
|
|
2012-08-21 19:05:32 +08:00
|
|
|
if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) {
|
2011-06-21 21:51:26 +08:00
|
|
|
mfc_debug(2, "no src buffers\n");
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
if (list_empty(&ctx->dst_queue)) {
|
|
|
|
mfc_debug(2, "no dst buffers\n");
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
2012-08-21 19:05:32 +08:00
|
|
|
if (list_empty(&ctx->src_queue)) {
|
|
|
|
/* send null frame */
|
2017-03-20 18:49:24 +08:00
|
|
|
s5p_mfc_set_enc_frame_buffer_v5(ctx, dev->dma_base[BANK_R_CTX],
|
|
|
|
dev->dma_base[BANK_R_CTX]);
|
2012-08-21 19:05:32 +08:00
|
|
|
src_mb = NULL;
|
|
|
|
} else {
|
|
|
|
src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf,
|
|
|
|
list);
|
|
|
|
src_mb->flags |= MFC_BUF_FLAG_USED;
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
if (src_mb->b->vb2_buf.planes[0].bytesused == 0) {
|
2012-08-21 19:05:32 +08:00
|
|
|
/* send null frame */
|
2017-02-08 16:53:48 +08:00
|
|
|
s5p_mfc_set_enc_frame_buffer_v5(ctx,
|
2017-03-20 18:49:24 +08:00
|
|
|
dev->dma_base[BANK_R_CTX],
|
|
|
|
dev->dma_base[BANK_R_CTX]);
|
2012-08-21 19:05:32 +08:00
|
|
|
ctx->state = MFCINST_FINISHING;
|
|
|
|
} else {
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
src_y_addr = vb2_dma_contig_plane_dma_addr(
|
|
|
|
&src_mb->b->vb2_buf, 0);
|
|
|
|
src_c_addr = vb2_dma_contig_plane_dma_addr(
|
|
|
|
&src_mb->b->vb2_buf, 1);
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_set_enc_frame_buffer_v5(ctx, src_y_addr,
|
2012-08-21 19:05:32 +08:00
|
|
|
src_c_addr);
|
|
|
|
if (src_mb->flags & MFC_BUF_FLAG_EOS)
|
|
|
|
ctx->state = MFCINST_FINISHING;
|
|
|
|
}
|
|
|
|
}
|
2011-06-21 21:51:26 +08:00
|
|
|
dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
|
2012-08-21 19:05:32 +08:00
|
|
|
dst_mb->flags |= MFC_BUF_FLAG_USED;
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
|
|
|
|
dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size);
|
2011-06-21 21:51:26 +08:00
|
|
|
dev->curr_ctx = ctx->num;
|
2013-05-28 14:26:16 +08:00
|
|
|
mfc_debug(2, "encoding buffer with index=%d state=%d\n",
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
src_mb ? src_mb->b->vb2_buf.index : -1, ctx->state);
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_encode_one_frame_v5(ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_buf *temp_vb;
|
|
|
|
|
|
|
|
/* Initializing decoding - parsing header */
|
|
|
|
mfc_debug(2, "Preparing to init decoding\n");
|
|
|
|
temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
|
|
|
|
s5p_mfc_set_dec_desc_buffer(ctx);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
mfc_debug(2, "Header size: %d\n",
|
|
|
|
temp_vb->b->vb2_buf.planes[0].bytesused);
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_set_dec_stream_buffer_v5(ctx,
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
|
|
|
|
0, temp_vb->b->vb2_buf.planes[0].bytesused);
|
2011-06-21 21:51:26 +08:00
|
|
|
dev->curr_ctx = ctx->num;
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_init_decode_v5(ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_buf *dst_mb;
|
|
|
|
unsigned long dst_addr;
|
|
|
|
unsigned int dst_size;
|
|
|
|
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_set_enc_ref_buffer_v5(ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
dst_addr = vb2_dma_contig_plane_dma_addr(&dst_mb->b->vb2_buf, 0);
|
|
|
|
dst_size = vb2_plane_size(&dst_mb->b->vb2_buf, 0);
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size);
|
2011-06-21 21:51:26 +08:00
|
|
|
dev->curr_ctx = ctx->num;
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_init_encode_v5(ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct s5p_mfc_dev *dev = ctx->dev;
|
|
|
|
struct s5p_mfc_buf *temp_vb;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Header was parsed now starting processing
|
|
|
|
* First set the output frame buffers
|
|
|
|
*/
|
|
|
|
if (ctx->capture_state != QUEUE_BUFS_MMAPED) {
|
2019-02-19 03:29:00 +08:00
|
|
|
mfc_err("It seems that not all destination buffers were mmapped\nMFC requires that all destination are mmapped before starting processing\n");
|
2011-06-21 21:51:26 +08:00
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
if (list_empty(&ctx->src_queue)) {
|
[media] s5p-mfc: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-19 03:44:10 +08:00
|
|
|
mfc_err("Header has been deallocated in the middle of initialization\n");
|
2011-06-21 21:51:26 +08:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
mfc_debug(2, "Header size: %d\n",
|
|
|
|
temp_vb->b->vb2_buf.planes[0].bytesused);
|
2012-10-04 09:19:08 +08:00
|
|
|
s5p_mfc_set_dec_stream_buffer_v5(ctx,
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vb2_dma_contig_plane_dma_addr(&temp_vb->b->vb2_buf, 0),
|
|
|
|
0, temp_vb->b->vb2_buf.planes[0].bytesused);
|
2011-06-21 21:51:26 +08:00
|
|
|
dev->curr_ctx = ctx->num;
|
2012-10-04 09:19:08 +08:00
|
|
|
ret = s5p_mfc_set_dec_frame_buffer_v5(ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
if (ret) {
|
|
|
|
mfc_err("Failed to alloc frame mem\n");
|
|
|
|
ctx->state = MFCINST_ERROR;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try running an operation on hardware */
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev)
|
2011-06-21 21:51:26 +08:00
|
|
|
{
|
|
|
|
struct s5p_mfc_ctx *ctx;
|
|
|
|
int new_ctx;
|
|
|
|
unsigned int ret = 0;
|
|
|
|
|
|
|
|
if (test_bit(0, &dev->enter_suspend)) {
|
|
|
|
mfc_debug(1, "Entering suspend so do not schedule any jobs\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Check whether hardware is not running */
|
|
|
|
if (test_and_set_bit(0, &dev->hw_lock) != 0) {
|
|
|
|
/* This is perfectly ok, the scheduled ctx should wait */
|
|
|
|
mfc_debug(1, "Couldn't lock HW\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Choose the context to run */
|
|
|
|
new_ctx = s5p_mfc_get_new_ctx(dev);
|
|
|
|
if (new_ctx < 0) {
|
|
|
|
/* No contexts to run */
|
|
|
|
if (test_and_clear_bit(0, &dev->hw_lock) == 0) {
|
|
|
|
mfc_err("Failed to unlock hardware\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mfc_debug(1, "No ctx is scheduled to be run\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctx = dev->ctx[new_ctx];
|
|
|
|
/* Got context to run in ctx */
|
|
|
|
/*
|
|
|
|
* Last frame has already been sent to MFC.
|
|
|
|
* Now obtaining frames from MFC buffer
|
|
|
|
*/
|
|
|
|
s5p_mfc_clock_on();
|
2014-10-21 19:07:07 +08:00
|
|
|
s5p_mfc_clean_ctx_int_flags(ctx);
|
|
|
|
|
2011-06-21 21:51:26 +08:00
|
|
|
if (ctx->type == MFCINST_DECODER) {
|
|
|
|
s5p_mfc_set_dec_desc_buffer(ctx);
|
|
|
|
switch (ctx->state) {
|
|
|
|
case MFCINST_FINISHING:
|
|
|
|
s5p_mfc_run_dec_frame(ctx, MFC_DEC_LAST_FRAME);
|
|
|
|
break;
|
|
|
|
case MFCINST_RUNNING:
|
|
|
|
ret = s5p_mfc_run_dec_frame(ctx, MFC_DEC_FRAME);
|
|
|
|
break;
|
|
|
|
case MFCINST_INIT:
|
2012-10-04 09:19:08 +08:00
|
|
|
ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd,
|
|
|
|
ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
|
|
|
case MFCINST_RETURN_INST:
|
2012-10-04 09:19:08 +08:00
|
|
|
ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd,
|
|
|
|
ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
|
|
|
case MFCINST_GOT_INST:
|
|
|
|
s5p_mfc_run_init_dec(ctx);
|
|
|
|
break;
|
|
|
|
case MFCINST_HEAD_PARSED:
|
|
|
|
ret = s5p_mfc_run_init_dec_buffers(ctx);
|
|
|
|
mfc_debug(1, "head parsed\n");
|
|
|
|
break;
|
|
|
|
case MFCINST_RES_CHANGE_INIT:
|
|
|
|
s5p_mfc_run_res_change(ctx);
|
|
|
|
break;
|
|
|
|
case MFCINST_RES_CHANGE_FLUSH:
|
|
|
|
s5p_mfc_run_dec_frame(ctx, MFC_DEC_FRAME);
|
|
|
|
break;
|
|
|
|
case MFCINST_RES_CHANGE_END:
|
|
|
|
mfc_debug(2, "Finished remaining frames after resolution change\n");
|
|
|
|
ctx->capture_state = QUEUE_FREE;
|
|
|
|
mfc_debug(2, "Will re-init the codec\n");
|
|
|
|
s5p_mfc_run_init_dec(ctx);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EAGAIN;
|
|
|
|
}
|
|
|
|
} else if (ctx->type == MFCINST_ENCODER) {
|
|
|
|
switch (ctx->state) {
|
|
|
|
case MFCINST_FINISHING:
|
|
|
|
case MFCINST_RUNNING:
|
|
|
|
ret = s5p_mfc_run_enc_frame(ctx);
|
|
|
|
break;
|
|
|
|
case MFCINST_INIT:
|
2012-10-04 09:19:08 +08:00
|
|
|
ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd,
|
|
|
|
ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
|
|
|
case MFCINST_RETURN_INST:
|
2012-10-04 09:19:08 +08:00
|
|
|
ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd,
|
|
|
|
ctx);
|
2011-06-21 21:51:26 +08:00
|
|
|
break;
|
|
|
|
case MFCINST_GOT_INST:
|
|
|
|
s5p_mfc_run_init_enc(ctx);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EAGAIN;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mfc_err("Invalid context type: %d\n", ctx->type);
|
|
|
|
ret = -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
/* Free hardware lock */
|
|
|
|
if (test_and_clear_bit(0, &dev->hw_lock) == 0)
|
|
|
|
mfc_err("Failed to unlock hardware\n");
|
|
|
|
|
|
|
|
/* This is in deed imporant, as no operation has been
|
|
|
|
* scheduled, reduce the clock count as no one will
|
|
|
|
* ever do this, because no interrupt related to this try_run
|
|
|
|
* will ever come from hardware. */
|
|
|
|
s5p_mfc_clock_off();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static void s5p_mfc_clear_int_flags_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT);
|
|
|
|
mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD);
|
|
|
|
mfc_write(dev, 0xffff, S5P_FIMV_SI_RTN_CHID);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_dspl_y_adr_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_SI_DISPLAY_Y_ADR) << MFC_OFFSET_SHIFT;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_dec_y_adr_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_SI_DECODE_Y_ADR) << MFC_OFFSET_SHIFT;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_dspl_status_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_SI_DISPLAY_STATUS);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_dec_status_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_SI_DECODE_STATUS);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_dec_frame_type_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_DECODE_FRAME_TYPE) &
|
|
|
|
S5P_FIMV_DECODE_FRAME_MASK;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_disp_frame_type_v5(struct s5p_mfc_ctx *ctx)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
2012-10-04 09:19:09 +08:00
|
|
|
return (s5p_mfc_read_info_v5(ctx, DISP_PIC_FRAME_TYPE) >>
|
|
|
|
S5P_FIMV_SHARED_DISP_FRAME_TYPE_SHIFT) &
|
|
|
|
S5P_FIMV_DECODE_FRAME_MASK;
|
2012-10-04 09:19:08 +08:00
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_consumed_stream_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_SI_CONSUMED_BYTES);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_int_reason_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
int reason;
|
|
|
|
reason = mfc_read(dev, S5P_FIMV_RISC2HOST_CMD) &
|
|
|
|
S5P_FIMV_RISC2HOST_CMD_MASK;
|
|
|
|
switch (reason) {
|
|
|
|
case S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_SEQ_DONE_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_SEQ_DONE_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_FRAME_DONE_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_FRAME_DONE_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_SLICE_DONE_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_SLICE_DONE_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_SYS_INIT_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_SYS_INIT_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_FW_STATUS_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_FW_STATUS_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_SLEEP_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_SLEEP_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_WAKEUP_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_WAKEUP_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_INIT_BUFFERS_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_ENC_COMPLETE_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET;
|
|
|
|
break;
|
|
|
|
case S5P_FIMV_R2H_CMD_ERR_RET:
|
|
|
|
reason = S5P_MFC_R2H_CMD_ERR_RET;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
reason = S5P_MFC_R2H_CMD_EMPTY;
|
2013-10-09 07:29:08 +08:00
|
|
|
}
|
2012-10-04 09:19:08 +08:00
|
|
|
return reason;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_int_err_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_RISC2HOST_ARG2);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_err_dec_v5(unsigned int err)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return (err & S5P_FIMV_ERR_DEC_MASK) >> S5P_FIMV_ERR_DEC_SHIFT;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_img_width_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_SI_HRESOL);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_img_height_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_SI_VRESOL);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_dpb_count_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_SI_BUF_NUMBER);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_mv_count_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
/* NOP */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_inst_no_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_RISC2HOST_ARG1);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_enc_strm_size_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_ENC_SI_STRM_SIZE);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_enc_slice_type_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return mfc_read(dev, S5P_FIMV_ENC_SI_SLICE_TYPE);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static int s5p_mfc_get_enc_dpb_count_v5(struct s5p_mfc_dev *dev)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static unsigned int s5p_mfc_get_pic_type_top_v5(struct s5p_mfc_ctx *ctx)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return s5p_mfc_read_info_v5(ctx, PIC_TIME_TOP);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static unsigned int s5p_mfc_get_pic_type_bot_v5(struct s5p_mfc_ctx *ctx)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return s5p_mfc_read_info_v5(ctx, PIC_TIME_BOT);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static unsigned int s5p_mfc_get_crop_info_h_v5(struct s5p_mfc_ctx *ctx)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return s5p_mfc_read_info_v5(ctx, CROP_INFO_H);
|
|
|
|
}
|
|
|
|
|
2013-03-02 18:50:14 +08:00
|
|
|
static unsigned int s5p_mfc_get_crop_info_v_v5(struct s5p_mfc_ctx *ctx)
|
2012-10-04 09:19:08 +08:00
|
|
|
{
|
|
|
|
return s5p_mfc_read_info_v5(ctx, CROP_INFO_V);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize opr function pointers for MFC v5 */
|
|
|
|
static struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = {
|
|
|
|
.alloc_dec_temp_buffers = s5p_mfc_alloc_dec_temp_buffers_v5,
|
|
|
|
.release_dec_desc_buffer = s5p_mfc_release_dec_desc_buffer_v5,
|
|
|
|
.alloc_codec_buffers = s5p_mfc_alloc_codec_buffers_v5,
|
|
|
|
.release_codec_buffers = s5p_mfc_release_codec_buffers_v5,
|
|
|
|
.alloc_instance_buffer = s5p_mfc_alloc_instance_buffer_v5,
|
|
|
|
.release_instance_buffer = s5p_mfc_release_instance_buffer_v5,
|
|
|
|
.alloc_dev_context_buffer = s5p_mfc_alloc_dev_context_buffer_v5,
|
|
|
|
.release_dev_context_buffer = s5p_mfc_release_dev_context_buffer_v5,
|
|
|
|
.dec_calc_dpb_size = s5p_mfc_dec_calc_dpb_size_v5,
|
|
|
|
.enc_calc_src_size = s5p_mfc_enc_calc_src_size_v5,
|
|
|
|
.set_enc_stream_buffer = s5p_mfc_set_enc_stream_buffer_v5,
|
|
|
|
.set_enc_frame_buffer = s5p_mfc_set_enc_frame_buffer_v5,
|
|
|
|
.get_enc_frame_buffer = s5p_mfc_get_enc_frame_buffer_v5,
|
|
|
|
.try_run = s5p_mfc_try_run_v5,
|
|
|
|
.clear_int_flags = s5p_mfc_clear_int_flags_v5,
|
|
|
|
.get_dspl_y_adr = s5p_mfc_get_dspl_y_adr_v5,
|
|
|
|
.get_dec_y_adr = s5p_mfc_get_dec_y_adr_v5,
|
|
|
|
.get_dspl_status = s5p_mfc_get_dspl_status_v5,
|
|
|
|
.get_dec_status = s5p_mfc_get_dec_status_v5,
|
|
|
|
.get_dec_frame_type = s5p_mfc_get_dec_frame_type_v5,
|
|
|
|
.get_disp_frame_type = s5p_mfc_get_disp_frame_type_v5,
|
|
|
|
.get_consumed_stream = s5p_mfc_get_consumed_stream_v5,
|
|
|
|
.get_int_reason = s5p_mfc_get_int_reason_v5,
|
|
|
|
.get_int_err = s5p_mfc_get_int_err_v5,
|
|
|
|
.err_dec = s5p_mfc_err_dec_v5,
|
|
|
|
.get_img_width = s5p_mfc_get_img_width_v5,
|
|
|
|
.get_img_height = s5p_mfc_get_img_height_v5,
|
|
|
|
.get_dpb_count = s5p_mfc_get_dpb_count_v5,
|
|
|
|
.get_mv_count = s5p_mfc_get_mv_count_v5,
|
|
|
|
.get_inst_no = s5p_mfc_get_inst_no_v5,
|
|
|
|
.get_enc_strm_size = s5p_mfc_get_enc_strm_size_v5,
|
|
|
|
.get_enc_slice_type = s5p_mfc_get_enc_slice_type_v5,
|
|
|
|
.get_enc_dpb_count = s5p_mfc_get_enc_dpb_count_v5,
|
|
|
|
.get_pic_type_top = s5p_mfc_get_pic_type_top_v5,
|
|
|
|
.get_pic_type_bot = s5p_mfc_get_pic_type_bot_v5,
|
|
|
|
.get_crop_info_h = s5p_mfc_get_crop_info_h_v5,
|
|
|
|
.get_crop_info_v = s5p_mfc_get_crop_info_v_v5,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v5(void)
|
|
|
|
{
|
|
|
|
return &s5p_mfc_ops_v5;
|
|
|
|
}
|