Fixed MTP to work with TWRP

This commit is contained in:
awab228 2018-06-19 23:16:04 +02:00
commit f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions

View file

@ -0,0 +1,6 @@
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc.o
s5p-mfc-y += s5p_mfc.o s5p_mfc_intr.o
s5p-mfc-y += s5p_mfc_dec.o s5p_mfc_enc.o
s5p-mfc-y += s5p_mfc_ctrl.o s5p_mfc_pm.o
s5p-mfc-y += s5p_mfc_opr.o s5p_mfc_opr_v5.o s5p_mfc_opr_v6.o
s5p-mfc-y += s5p_mfc_cmd.o s5p_mfc_cmd_v5.o s5p_mfc_cmd_v6.o

View file

@ -0,0 +1,409 @@
/*
* Register definition file for Samsung MFC V6.x Interface (FIMV) driver
*
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
* 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.
*/
#ifndef _REGS_FIMV_V6_H
#define _REGS_FIMV_V6_H
#include <linux/kernel.h>
#include <linux/sizes.h>
#define S5P_FIMV_REG_SIZE_V6 (S5P_FIMV_END_ADDR - S5P_FIMV_START_ADDR)
#define S5P_FIMV_REG_COUNT_V6 ((S5P_FIMV_END_ADDR - S5P_FIMV_START_ADDR) / 4)
/* Number of bits that the buffer address should be shifted for particular
* MFC buffers. */
#define S5P_FIMV_MEM_OFFSET_V6 0
#define S5P_FIMV_START_ADDR_V6 0x0000
#define S5P_FIMV_END_ADDR_V6 0xfd80
#define S5P_FIMV_REG_CLEAR_BEGIN_V6 0xf000
#define S5P_FIMV_REG_CLEAR_COUNT_V6 1024
/* Codec Common Registers */
#define S5P_FIMV_RISC_ON_V6 0x0000
#define S5P_FIMV_RISC2HOST_INT_V6 0x003C
#define S5P_FIMV_HOST2RISC_INT_V6 0x0044
#define S5P_FIMV_RISC_BASE_ADDRESS_V6 0x0054
#define S5P_FIMV_MFC_RESET_V6 0x1070
#define S5P_FIMV_HOST2RISC_CMD_V6 0x1100
#define S5P_FIMV_H2R_CMD_EMPTY_V6 0
#define S5P_FIMV_H2R_CMD_SYS_INIT_V6 1
#define S5P_FIMV_H2R_CMD_OPEN_INSTANCE_V6 2
#define S5P_FIMV_CH_SEQ_HEADER_V6 3
#define S5P_FIMV_CH_INIT_BUFS_V6 4
#define S5P_FIMV_CH_FRAME_START_V6 5
#define S5P_FIMV_H2R_CMD_CLOSE_INSTANCE_V6 6
#define S5P_FIMV_H2R_CMD_SLEEP_V6 7
#define S5P_FIMV_H2R_CMD_WAKEUP_V6 8
#define S5P_FIMV_CH_LAST_FRAME_V6 9
#define S5P_FIMV_H2R_CMD_FLUSH_V6 10
/* RMVME: REALLOC used? */
#define S5P_FIMV_CH_FRAME_START_REALLOC_V6 5
#define S5P_FIMV_RISC2HOST_CMD_V6 0x1104
#define S5P_FIMV_R2H_CMD_EMPTY_V6 0
#define S5P_FIMV_R2H_CMD_SYS_INIT_RET_V6 1
#define S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET_V6 2
#define S5P_FIMV_R2H_CMD_SEQ_DONE_RET_V6 3
#define S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET_V6 4
#define S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET_V6 6
#define S5P_FIMV_R2H_CMD_SLEEP_RET_V6 7
#define S5P_FIMV_R2H_CMD_WAKEUP_RET_V6 8
#define S5P_FIMV_R2H_CMD_COMPLETE_SEQ_RET_V6 9
#define S5P_FIMV_R2H_CMD_DPB_FLUSH_RET_V6 10
#define S5P_FIMV_R2H_CMD_NAL_ABORT_RET_V6 11
#define S5P_FIMV_R2H_CMD_FW_STATUS_RET_V6 12
#define S5P_FIMV_R2H_CMD_FRAME_DONE_RET_V6 13
#define S5P_FIMV_R2H_CMD_FIELD_DONE_RET_V6 14
#define S5P_FIMV_R2H_CMD_SLICE_DONE_RET_V6 15
#define S5P_FIMV_R2H_CMD_ENC_BUFFER_FUL_RET_V6 16
#define S5P_FIMV_R2H_CMD_ERR_RET_V6 32
#define S5P_FIMV_FW_VERSION_V6 0xf000
#define S5P_FIMV_INSTANCE_ID_V6 0xf008
#define S5P_FIMV_CODEC_TYPE_V6 0xf00c
#define S5P_FIMV_CONTEXT_MEM_ADDR_V6 0xf014
#define S5P_FIMV_CONTEXT_MEM_SIZE_V6 0xf018
#define S5P_FIMV_PIXEL_FORMAT_V6 0xf020
#define S5P_FIMV_METADATA_ENABLE_V6 0xf024
#define S5P_FIMV_DBG_BUFFER_ADDR_V6 0xf030
#define S5P_FIMV_DBG_BUFFER_SIZE_V6 0xf034
#define S5P_FIMV_RET_INSTANCE_ID_V6 0xf070
#define S5P_FIMV_ERROR_CODE_V6 0xf074
#define S5P_FIMV_ERR_WARNINGS_START_V6 160
#define S5P_FIMV_ERR_DEC_MASK_V6 0xffff
#define S5P_FIMV_ERR_DEC_SHIFT_V6 0
#define S5P_FIMV_ERR_DSPL_MASK_V6 0xffff0000
#define S5P_FIMV_ERR_DSPL_SHIFT_V6 16
#define S5P_FIMV_DBG_BUFFER_OUTPUT_SIZE_V6 0xf078
#define S5P_FIMV_METADATA_STATUS_V6 0xf07C
#define S5P_FIMV_METADATA_ADDR_MB_INFO_V6 0xf080
#define S5P_FIMV_METADATA_SIZE_MB_INFO_V6 0xf084
/* Decoder Registers */
#define S5P_FIMV_D_CRC_CTRL_V6 0xf0b0
#define S5P_FIMV_D_DEC_OPTIONS_V6 0xf0b4
#define S5P_FIMV_D_OPT_FMO_ASO_CTRL_MASK_V6 4
#define S5P_FIMV_D_OPT_DDELAY_EN_SHIFT_V6 3
#define S5P_FIMV_D_OPT_LF_CTRL_SHIFT_V6 1
#define S5P_FIMV_D_OPT_LF_CTRL_MASK_V6 0x3
#define S5P_FIMV_D_OPT_TILE_MODE_SHIFT_V6 0
#define S5P_FIMV_D_DISPLAY_DELAY_V6 0xf0b8
#define S5P_FIMV_D_SET_FRAME_WIDTH_V6 0xf0bc
#define S5P_FIMV_D_SET_FRAME_HEIGHT_V6 0xf0c0
#define S5P_FIMV_D_SEI_ENABLE_V6 0xf0c4
/* Buffer setting registers */
#define S5P_FIMV_D_MIN_NUM_DPB_V6 0xf0f0
#define S5P_FIMV_D_MIN_LUMA_DPB_SIZE_V6 0xf0f4
#define S5P_FIMV_D_MIN_CHROMA_DPB_SIZE_V6 0xf0f8
#define S5P_FIMV_D_MVC_NUM_VIEWS_V6 0xf0fc
#define S5P_FIMV_D_MIN_NUM_MV_V6 0xf100
#define S5P_FIMV_D_NUM_DPB_V6 0xf130
#define S5P_FIMV_D_LUMA_DPB_SIZE_V6 0xf134
#define S5P_FIMV_D_CHROMA_DPB_SIZE_V6 0xf138
#define S5P_FIMV_D_MV_BUFFER_SIZE_V6 0xf13c
#define S5P_FIMV_D_LUMA_DPB_V6 0xf140
#define S5P_FIMV_D_CHROMA_DPB_V6 0xf240
#define S5P_FIMV_D_MV_BUFFER_V6 0xf340
#define S5P_FIMV_D_SCRATCH_BUFFER_ADDR_V6 0xf440
#define S5P_FIMV_D_SCRATCH_BUFFER_SIZE_V6 0xf444
#define S5P_FIMV_D_METADATA_BUFFER_ADDR_V6 0xf448
#define S5P_FIMV_D_METADATA_BUFFER_SIZE_V6 0xf44c
#define S5P_FIMV_D_NUM_MV_V6 0xf478
#define S5P_FIMV_D_CPB_BUFFER_ADDR_V6 0xf4b0
#define S5P_FIMV_D_CPB_BUFFER_SIZE_V6 0xf4b4
#define S5P_FIMV_D_AVAILABLE_DPB_FLAG_UPPER_V6 0xf4b8
#define S5P_FIMV_D_AVAILABLE_DPB_FLAG_LOWER_V6 0xf4bc
#define S5P_FIMV_D_CPB_BUFFER_OFFSET_V6 0xf4c0
#define S5P_FIMV_D_SLICE_IF_ENABLE_V6 0xf4c4
#define S5P_FIMV_D_PICTURE_TAG_V6 0xf4c8
#define S5P_FIMV_D_STREAM_DATA_SIZE_V6 0xf4d0
#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V6 0xf47c
/* Display information register */
#define S5P_FIMV_D_DISPLAY_FRAME_WIDTH_V6 0xf500
#define S5P_FIMV_D_DISPLAY_FRAME_HEIGHT_V6 0xf504
/* Display status */
#define S5P_FIMV_D_DISPLAY_STATUS_V6 0xf508
#define S5P_FIMV_D_DISPLAY_LUMA_ADDR_V6 0xf50c
#define S5P_FIMV_D_DISPLAY_CHROMA_ADDR_V6 0xf510
#define S5P_FIMV_D_DISPLAY_FRAME_TYPE_V6 0xf514
#define S5P_FIMV_D_DISPLAY_CROP_INFO1_V6 0xf518
#define S5P_FIMV_D_DISPLAY_CROP_INFO2_V6 0xf51c
#define S5P_FIMV_D_DISPLAY_PICTURE_PROFILE_V6 0xf520
#define S5P_FIMV_D_DISPLAY_LUMA_CRC_TOP_V6 0xf524
#define S5P_FIMV_D_DISPLAY_CHROMA_CRC_TOP_V6 0xf528
#define S5P_FIMV_D_DISPLAY_LUMA_CRC_BOT_V6 0xf52c
#define S5P_FIMV_D_DISPLAY_CHROMA_CRC_BOT_V6 0xf530
#define S5P_FIMV_D_DISPLAY_ASPECT_RATIO_V6 0xf534
#define S5P_FIMV_D_DISPLAY_EXTENDED_AR_V6 0xf538
/* Decoded picture information register */
#define S5P_FIMV_D_DECODED_FRAME_WIDTH_V6 0xf53c
#define S5P_FIMV_D_DECODED_FRAME_HEIGHT_V6 0xf540
#define S5P_FIMV_D_DECODED_STATUS_V6 0xf544
#define S5P_FIMV_DEC_CRC_GEN_MASK_V6 0x1
#define S5P_FIMV_DEC_CRC_GEN_SHIFT_V6 6
#define S5P_FIMV_D_DECODED_LUMA_ADDR_V6 0xf548
#define S5P_FIMV_D_DECODED_CHROMA_ADDR_V6 0xf54c
#define S5P_FIMV_D_DECODED_FRAME_TYPE_V6 0xf550
#define S5P_FIMV_DECODE_FRAME_MASK_V6 7
#define S5P_FIMV_D_DECODED_CROP_INFO1_V6 0xf554
#define S5P_FIMV_D_DECODED_CROP_INFO2_V6 0xf558
#define S5P_FIMV_D_DECODED_PICTURE_PROFILE_V6 0xf55c
#define S5P_FIMV_D_DECODED_NAL_SIZE_V6 0xf560
#define S5P_FIMV_D_DECODED_LUMA_CRC_TOP_V6 0xf564
#define S5P_FIMV_D_DECODED_CHROMA_CRC_TOP_V6 0xf568
#define S5P_FIMV_D_DECODED_LUMA_CRC_BOT_V6 0xf56c
#define S5P_FIMV_D_DECODED_CHROMA_CRC_BOT_V6 0xf570
/* Returned value register for specific setting */
#define S5P_FIMV_D_RET_PICTURE_TAG_TOP_V6 0xf574
#define S5P_FIMV_D_RET_PICTURE_TAG_BOT_V6 0xf578
#define S5P_FIMV_D_RET_PICTURE_TIME_TOP_V6 0xf57c
#define S5P_FIMV_D_RET_PICTURE_TIME_BOT_V6 0xf580
#define S5P_FIMV_D_CHROMA_FORMAT_V6 0xf588
#define S5P_FIMV_D_MPEG4_INFO_V6 0xf58c
#define S5P_FIMV_D_H264_INFO_V6 0xf590
#define S5P_FIMV_D_METADATA_ADDR_CONCEALED_MB_V6 0xf594
#define S5P_FIMV_D_METADATA_SIZE_CONCEALED_MB_V6 0xf598
#define S5P_FIMV_D_METADATA_ADDR_VC1_PARAM_V6 0xf59c
#define S5P_FIMV_D_METADATA_SIZE_VC1_PARAM_V6 0xf5a0
#define S5P_FIMV_D_METADATA_ADDR_SEI_NAL_V6 0xf5a4
#define S5P_FIMV_D_METADATA_SIZE_SEI_NAL_V6 0xf5a8
#define S5P_FIMV_D_METADATA_ADDR_VUI_V6 0xf5ac
#define S5P_FIMV_D_METADATA_SIZE_VUI_V6 0xf5b0
#define S5P_FIMV_D_MVC_VIEW_ID_V6 0xf5b4
/* SEI related information */
#define S5P_FIMV_D_FRAME_PACK_SEI_AVAIL_V6 0xf5f0
#define S5P_FIMV_D_FRAME_PACK_ARRGMENT_ID_V6 0xf5f4
#define S5P_FIMV_D_FRAME_PACK_SEI_INFO_V6 0xf5f8
#define S5P_FIMV_D_FRAME_PACK_GRID_POS_V6 0xf5fc
/* Encoder Registers */
#define S5P_FIMV_E_FRAME_WIDTH_V6 0xf770
#define S5P_FIMV_E_FRAME_HEIGHT_V6 0xf774
#define S5P_FIMV_E_CROPPED_FRAME_WIDTH_V6 0xf778
#define S5P_FIMV_E_CROPPED_FRAME_HEIGHT_V6 0xf77c
#define S5P_FIMV_E_FRAME_CROP_OFFSET_V6 0xf780
#define S5P_FIMV_E_ENC_OPTIONS_V6 0xf784
#define S5P_FIMV_E_PICTURE_PROFILE_V6 0xf788
#define S5P_FIMV_E_FIXED_PICTURE_QP_V6 0xf790
#define S5P_FIMV_E_RC_CONFIG_V6 0xf794
#define S5P_FIMV_E_RC_QP_BOUND_V6 0xf798
#define S5P_FIMV_E_RC_RPARAM_V6 0xf79c
#define S5P_FIMV_E_MB_RC_CONFIG_V6 0xf7a0
#define S5P_FIMV_E_PADDING_CTRL_V6 0xf7a4
#define S5P_FIMV_E_MV_HOR_RANGE_V6 0xf7ac
#define S5P_FIMV_E_MV_VER_RANGE_V6 0xf7b0
#define S5P_FIMV_E_MV_RANGE_V6_MASK 0x3fff
#define S5P_FIMV_E_VBV_BUFFER_SIZE_V6 0xf84c
#define S5P_FIMV_E_VBV_INIT_DELAY_V6 0xf850
#define S5P_FIMV_E_NUM_DPB_V6 0xf890
#define S5P_FIMV_E_LUMA_DPB_V6 0xf8c0
#define S5P_FIMV_E_CHROMA_DPB_V6 0xf904
#define S5P_FIMV_E_ME_BUFFER_V6 0xf948
#define S5P_FIMV_E_SCRATCH_BUFFER_ADDR_V6 0xf98c
#define S5P_FIMV_E_SCRATCH_BUFFER_SIZE_V6 0xf990
#define S5P_FIMV_E_TMV_BUFFER0_V6 0xf994
#define S5P_FIMV_E_TMV_BUFFER1_V6 0xf998
#define S5P_FIMV_E_SOURCE_LUMA_ADDR_V6 0xf9f0
#define S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6 0xf9f4
#define S5P_FIMV_E_STREAM_BUFFER_ADDR_V6 0xf9f8
#define S5P_FIMV_E_STREAM_BUFFER_SIZE_V6 0xf9fc
#define S5P_FIMV_E_ROI_BUFFER_ADDR_V6 0xfA00
#define S5P_FIMV_E_PARAM_CHANGE_V6 0xfa04
#define S5P_FIMV_E_IR_SIZE_V6 0xfa08
#define S5P_FIMV_E_GOP_CONFIG_V6 0xfa0c
#define S5P_FIMV_E_MSLICE_MODE_V6 0xfa10
#define S5P_FIMV_E_MSLICE_SIZE_MB_V6 0xfa14
#define S5P_FIMV_E_MSLICE_SIZE_BITS_V6 0xfa18
#define S5P_FIMV_E_FRAME_INSERTION_V6 0xfa1c
#define S5P_FIMV_E_RC_FRAME_RATE_V6 0xfa20
#define S5P_FIMV_E_RC_BIT_RATE_V6 0xfa24
#define S5P_FIMV_E_RC_QP_OFFSET_V6 0xfa28
#define S5P_FIMV_E_RC_ROI_CTRL_V6 0xfa2c
#define S5P_FIMV_E_PICTURE_TAG_V6 0xfa30
#define S5P_FIMV_E_BIT_COUNT_ENABLE_V6 0xfa34
#define S5P_FIMV_E_MAX_BIT_COUNT_V6 0xfa38
#define S5P_FIMV_E_MIN_BIT_COUNT_V6 0xfa3c
#define S5P_FIMV_E_METADATA_BUFFER_ADDR_V6 0xfa40
#define S5P_FIMV_E_METADATA_BUFFER_SIZE_V6 0xfa44
#define S5P_FIMV_E_STREAM_SIZE_V6 0xfa80
#define S5P_FIMV_E_SLICE_TYPE_V6 0xfa84
#define S5P_FIMV_E_PICTURE_COUNT_V6 0xfa88
#define S5P_FIMV_E_RET_PICTURE_TAG_V6 0xfa8c
#define S5P_FIMV_E_STREAM_BUFFER_WRITE_POINTER_V6 0xfa90
#define S5P_FIMV_E_ENCODED_SOURCE_LUMA_ADDR_V6 0xfa94
#define S5P_FIMV_E_ENCODED_SOURCE_CHROMA_ADDR_V6 0xfa98
#define S5P_FIMV_E_RECON_LUMA_DPB_ADDR_V6 0xfa9c
#define S5P_FIMV_E_RECON_CHROMA_DPB_ADDR_V6 0xfaa0
#define S5P_FIMV_E_METADATA_ADDR_ENC_SLICE_V6 0xfaa4
#define S5P_FIMV_E_METADATA_SIZE_ENC_SLICE_V6 0xfaa8
#define S5P_FIMV_E_MPEG4_OPTIONS_V6 0xfb10
#define S5P_FIMV_E_MPEG4_HEC_PERIOD_V6 0xfb14
#define S5P_FIMV_E_ASPECT_RATIO_V6 0xfb50
#define S5P_FIMV_E_EXTENDED_SAR_V6 0xfb54
#define S5P_FIMV_E_H264_OPTIONS_V6 0xfb58
#define S5P_FIMV_E_H264_LF_ALPHA_OFFSET_V6 0xfb5c
#define S5P_FIMV_E_H264_LF_BETA_OFFSET_V6 0xfb60
#define S5P_FIMV_E_H264_I_PERIOD_V6 0xfb64
#define S5P_FIMV_E_H264_FMO_SLICE_GRP_MAP_TYPE_V6 0xfb68
#define S5P_FIMV_E_H264_FMO_NUM_SLICE_GRP_MINUS1_V6 0xfb6c
#define S5P_FIMV_E_H264_FMO_SLICE_GRP_CHANGE_DIR_V6 0xfb70
#define S5P_FIMV_E_H264_FMO_SLICE_GRP_CHANGE_RATE_MINUS1_V6 0xfb74
#define S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_0_V6 0xfb78
#define S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_1_V6 0xfb7c
#define S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_2_V6 0xfb80
#define S5P_FIMV_E_H264_FMO_RUN_LENGTH_MINUS1_3_V6 0xfb84
#define S5P_FIMV_E_H264_ASO_SLICE_ORDER_0_V6 0xfb88
#define S5P_FIMV_E_H264_ASO_SLICE_ORDER_1_V6 0xfb8c
#define S5P_FIMV_E_H264_ASO_SLICE_ORDER_2_V6 0xfb90
#define S5P_FIMV_E_H264_ASO_SLICE_ORDER_3_V6 0xfb94
#define S5P_FIMV_E_H264_ASO_SLICE_ORDER_4_V6 0xfb98
#define S5P_FIMV_E_H264_ASO_SLICE_ORDER_5_V6 0xfb9c
#define S5P_FIMV_E_H264_ASO_SLICE_ORDER_6_V6 0xfba0
#define S5P_FIMV_E_H264_ASO_SLICE_ORDER_7_V6 0xfba4
#define S5P_FIMV_E_H264_CHROMA_QP_OFFSET_V6 0xfba8
#define S5P_FIMV_E_H264_NUM_T_LAYER_V6 0xfbac
#define S5P_FIMV_E_H264_HIERARCHICAL_QP_LAYER0_V6 0xfbb0
#define S5P_FIMV_E_H264_HIERARCHICAL_QP_LAYER1_V6 0xfbb4
#define S5P_FIMV_E_H264_HIERARCHICAL_QP_LAYER2_V6 0xfbb8
#define S5P_FIMV_E_H264_HIERARCHICAL_QP_LAYER3_V6 0xfbbc
#define S5P_FIMV_E_H264_HIERARCHICAL_QP_LAYER4_V6 0xfbc0
#define S5P_FIMV_E_H264_HIERARCHICAL_QP_LAYER5_V6 0xfbc4
#define S5P_FIMV_E_H264_HIERARCHICAL_QP_LAYER6_V6 0xfbc8
#define S5P_FIMV_E_H264_FRAME_PACKING_SEI_INFO_V6 0xfc4c
#define S5P_FIMV_ENC_FP_ARRANGEMENT_TYPE_SIDE_BY_SIDE_V6 0
#define S5P_FIMV_ENC_FP_ARRANGEMENT_TYPE_TOP_BOTTOM_V6 1
#define S5P_FIMV_ENC_FP_ARRANGEMENT_TYPE_TEMPORAL_V6 2
#define S5P_FIMV_E_MVC_FRAME_QP_VIEW1_V6 0xfd40
#define S5P_FIMV_E_MVC_RC_FRAME_RATE_VIEW1_V6 0xfd44
#define S5P_FIMV_E_MVC_RC_BIT_RATE_VIEW1_V6 0xfd48
#define S5P_FIMV_E_MVC_RC_QBOUND_VIEW1_V6 0xfd4c
#define S5P_FIMV_E_MVC_RC_RPARA_VIEW1_V6 0xfd50
#define S5P_FIMV_E_MVC_INTER_VIEW_PREDICTION_ON_V6 0xfd80
/* Codec numbers */
#define S5P_FIMV_CODEC_NONE_V6 -1
#define S5P_FIMV_CODEC_H264_DEC_V6 0
#define S5P_FIMV_CODEC_H264_MVC_DEC_V6 1
#define S5P_FIMV_CODEC_MPEG4_DEC_V6 3
#define S5P_FIMV_CODEC_FIMV1_DEC_V6 4
#define S5P_FIMV_CODEC_FIMV2_DEC_V6 5
#define S5P_FIMV_CODEC_FIMV3_DEC_V6 6
#define S5P_FIMV_CODEC_FIMV4_DEC_V6 7
#define S5P_FIMV_CODEC_H263_DEC_V6 8
#define S5P_FIMV_CODEC_VC1RCV_DEC_V6 9
#define S5P_FIMV_CODEC_VC1_DEC_V6 10
/* FIXME: Add 11~12 */
#define S5P_FIMV_CODEC_MPEG2_DEC_V6 13
#define S5P_FIMV_CODEC_VP8_DEC_V6 14
/* FIXME: Add 15~16 */
#define S5P_FIMV_CODEC_H264_ENC_V6 20
#define S5P_FIMV_CODEC_H264_MVC_ENC_V6 21
#define S5P_FIMV_CODEC_MPEG4_ENC_V6 23
#define S5P_FIMV_CODEC_H263_ENC_V6 24
#define S5P_FIMV_NV12M_HALIGN_V6 16
#define S5P_FIMV_NV12MT_HALIGN_V6 16
#define S5P_FIMV_NV12MT_VALIGN_V6 16
#define S5P_FIMV_TMV_BUFFER_ALIGN_V6 16
#define S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6 256
#define S5P_FIMV_CHROMA_DPB_BUFFER_ALIGN_V6 256
#define S5P_FIMV_ME_BUFFER_ALIGN_V6 256
#define S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6 256
#define S5P_FIMV_LUMA_MB_TO_PIXEL_V6 256
#define S5P_FIMV_CHROMA_MB_TO_PIXEL_V6 128
#define S5P_FIMV_NUM_TMV_BUFFERS_V6 2
#define S5P_FIMV_MAX_FRAME_SIZE_V6 (2 * SZ_1M)
#define S5P_FIMV_NUM_PIXELS_IN_MB_ROW_V6 16
#define S5P_FIMV_NUM_PIXELS_IN_MB_COL_V6 16
/* Buffer size requirements defined by hardware */
#define S5P_FIMV_TMV_BUFFER_SIZE_V6(w, h) (((w) + 1) * ((h) + 3) * 8)
#define S5P_FIMV_ME_BUFFER_SIZE_V6(imw, imh, mbw, mbh) \
(((((imw + 127) / 64) * 16) * DIV_ROUND_UP(imh, 64) * 256) + \
(DIV_ROUND_UP((mbw) * (mbh), 32) * 16))
#define S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V6(w, h) (((w) * 192) + 64)
#define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V6(w, h) \
((w) * 144 + 8192 * (h) + 49216 + 1048576)
#define S5P_FIMV_SCRATCH_BUF_SIZE_VC1_DEC_V6(w, h) \
(2096 * ((w) + (h) + 1))
#define S5P_FIMV_SCRATCH_BUF_SIZE_H263_DEC_V6(w, h) ((w) * 400)
#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_DEC_V6(w, h) \
((w) * 32 + (h) * 128 + (((w) + 1) / 2) * 64 + 2112)
#define S5P_FIMV_SCRATCH_BUF_SIZE_H264_ENC_V6(w, h) \
(((w) * 64) + (((w) + 1) * 16) + (4096 * 16))
#define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_ENC_V6(w, h) \
(((w) * 16) + (((w) + 1) * 16))
/* MFC Context buffer sizes */
#define MFC_CTX_BUF_SIZE_V6 (28 * SZ_1K) /* 28KB */
#define MFC_H264_DEC_CTX_BUF_SIZE_V6 (2 * SZ_1M) /* 2MB */
#define MFC_OTHER_DEC_CTX_BUF_SIZE_V6 (20 * SZ_1K) /* 20KB */
#define MFC_H264_ENC_CTX_BUF_SIZE_V6 (100 * SZ_1K) /* 100KB */
#define MFC_OTHER_ENC_CTX_BUF_SIZE_V6 (12 * SZ_1K) /* 12KB */
/* MFCv6 variant defines */
#define MAX_FW_SIZE_V6 (SZ_1M) /* 1MB */
#define MAX_CPB_SIZE_V6 (3 * SZ_1M) /* 3MB */
#define MFC_VERSION_V6 0x61
#define MFC_NUM_PORTS_V6 1
#endif /* _REGS_FIMV_V6_H */

View file

@ -0,0 +1,60 @@
/*
* Register definition file for Samsung MFC V7.x Interface (FIMV) driver
*
* Copyright (c) 2013 Samsung Electronics Co., Ltd.
* 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.
*/
#ifndef _REGS_MFC_V7_H
#define _REGS_MFC_V7_H
#include "regs-mfc-v6.h"
/* Additional features of v7 */
#define S5P_FIMV_CODEC_VP8_ENC_V7 25
/* Additional registers for v7 */
#define S5P_FIMV_E_SOURCE_FIRST_ADDR_V7 0xf9e0
#define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7 0xf9e4
#define S5P_FIMV_E_SOURCE_THIRD_ADDR_V7 0xf9e8
#define S5P_FIMV_E_SOURCE_FIRST_STRIDE_V7 0xf9ec
#define S5P_FIMV_E_SOURCE_SECOND_STRIDE_V7 0xf9f0
#define S5P_FIMV_E_SOURCE_THIRD_STRIDE_V7 0xf9f4
#define S5P_FIMV_E_ENCODED_SOURCE_FIRST_ADDR_V7 0xfa70
#define S5P_FIMV_E_ENCODED_SOURCE_SECOND_ADDR_V7 0xfa74
#define S5P_FIMV_E_VP8_OPTIONS_V7 0xfdb0
#define S5P_FIMV_E_VP8_FILTER_OPTIONS_V7 0xfdb4
#define S5P_FIMV_E_VP8_GOLDEN_FRAME_OPTION_V7 0xfdb8
#define S5P_FIMV_E_VP8_NUM_T_LAYER_V7 0xfdc4
/* MFCv7 variant defines */
#define MAX_FW_SIZE_V7 (SZ_1M) /* 1MB */
#define MAX_CPB_SIZE_V7 (3 * SZ_1M) /* 3MB */
#define MFC_VERSION_V7 0x72
#define MFC_NUM_PORTS_V7 1
#define MFC_LUMA_PAD_BYTES_V7 256
#define MFC_CHROMA_PAD_BYTES_V7 128
/* MFCv7 Context buffer sizes */
#define MFC_CTX_BUF_SIZE_V7 (30 * SZ_1K) /* 30KB */
#define MFC_H264_DEC_CTX_BUF_SIZE_V7 (2 * SZ_1M) /* 2MB */
#define MFC_OTHER_DEC_CTX_BUF_SIZE_V7 (20 * SZ_1K) /* 20KB */
#define MFC_H264_ENC_CTX_BUF_SIZE_V7 (100 * SZ_1K) /* 100KB */
#define MFC_OTHER_ENC_CTX_BUF_SIZE_V7 (10 * SZ_1K) /* 10KB */
/* Buffer size defines */
#define S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_DEC_V7(w, h) \
(SZ_1M + ((w) * 144) + (8192 * (h)) + 49216)
#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V7(w, h) \
(((w) * 48) + 8192 + ((((w) + 1) / 2) * 128) + 144 + \
((((((w) * 16) * ((h) * 16)) * 3) / 2) * 4))
#endif /*_REGS_MFC_V7_H*/

View file

@ -0,0 +1,124 @@
/*
* Register definition file for Samsung MFC V8.x Interface (FIMV) driver
*
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
* 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.
*/
#ifndef _REGS_MFC_V8_H
#define _REGS_MFC_V8_H
#include <linux/sizes.h>
#include "regs-mfc-v7.h"
/* Additional registers for v8 */
#define S5P_FIMV_D_MVC_NUM_VIEWS_V8 0xf104
#define S5P_FIMV_D_FIRST_PLANE_DPB_SIZE_V8 0xf144
#define S5P_FIMV_D_SECOND_PLANE_DPB_SIZE_V8 0xf148
#define S5P_FIMV_D_MV_BUFFER_SIZE_V8 0xf150
#define S5P_FIMV_D_FIRST_PLANE_DPB_STRIDE_SIZE_V8 0xf138
#define S5P_FIMV_D_SECOND_PLANE_DPB_STRIDE_SIZE_V8 0xf13c
#define S5P_FIMV_D_FIRST_PLANE_DPB_V8 0xf160
#define S5P_FIMV_D_SECOND_PLANE_DPB_V8 0xf260
#define S5P_FIMV_D_MV_BUFFER_V8 0xf460
#define S5P_FIMV_D_NUM_MV_V8 0xf134
#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V8 0xf154
#define S5P_FIMV_D_SCRATCH_BUFFER_ADDR_V8 0xf560
#define S5P_FIMV_D_SCRATCH_BUFFER_SIZE_V8 0xf564
#define S5P_FIMV_D_CPB_BUFFER_ADDR_V8 0xf5b0
#define S5P_FIMV_D_CPB_BUFFER_SIZE_V8 0xf5b4
#define S5P_FIMV_D_AVAILABLE_DPB_FLAG_LOWER_V8 0xf5bc
#define S5P_FIMV_D_CPB_BUFFER_OFFSET_V8 0xf5c0
#define S5P_FIMV_D_SLICE_IF_ENABLE_V8 0xf5c4
#define S5P_FIMV_D_STREAM_DATA_SIZE_V8 0xf5d0
/* Display information register */
#define S5P_FIMV_D_DISPLAY_FRAME_WIDTH_V8 0xf600
#define S5P_FIMV_D_DISPLAY_FRAME_HEIGHT_V8 0xf604
/* Display status */
#define S5P_FIMV_D_DISPLAY_STATUS_V8 0xf608
#define S5P_FIMV_D_DISPLAY_FIRST_PLANE_ADDR_V8 0xf60c
#define S5P_FIMV_D_DISPLAY_SECOND_PLANE_ADDR_V8 0xf610
#define S5P_FIMV_D_DISPLAY_FRAME_TYPE_V8 0xf618
#define S5P_FIMV_D_DISPLAY_CROP_INFO1_V8 0xf61c
#define S5P_FIMV_D_DISPLAY_CROP_INFO2_V8 0xf620
#define S5P_FIMV_D_DISPLAY_PICTURE_PROFILE_V8 0xf624
/* Decoded picture information register */
#define S5P_FIMV_D_DECODED_STATUS_V8 0xf644
#define S5P_FIMV_D_DECODED_FIRST_PLANE_ADDR_V8 0xf648
#define S5P_FIMV_D_DECODED_SECOND_PLANE_ADDR_V8 0xf64c
#define S5P_FIMV_D_DECODED_THIRD_PLANE_ADDR_V8 0xf650
#define S5P_FIMV_D_DECODED_FRAME_TYPE_V8 0xf654
#define S5P_FIMV_D_DECODED_NAL_SIZE_V8 0xf664
/* Returned value register for specific setting */
#define S5P_FIMV_D_RET_PICTURE_TAG_TOP_V8 0xf674
#define S5P_FIMV_D_RET_PICTURE_TAG_BOT_V8 0xf678
#define S5P_FIMV_D_MVC_VIEW_ID_V8 0xf6d8
/* SEI related information */
#define S5P_FIMV_D_FRAME_PACK_SEI_AVAIL_V8 0xf6dc
/* Encoder Registers */
#define S5P_FIMV_E_FIXED_PICTURE_QP_V8 0xf794
#define S5P_FIMV_E_RC_CONFIG_V8 0xf798
#define S5P_FIMV_E_RC_QP_BOUND_V8 0xf79c
#define S5P_FIMV_E_RC_RPARAM_V8 0xf7a4
#define S5P_FIMV_E_MB_RC_CONFIG_V8 0xf7a8
#define S5P_FIMV_E_PADDING_CTRL_V8 0xf7ac
#define S5P_FIMV_E_MV_HOR_RANGE_V8 0xf7b4
#define S5P_FIMV_E_MV_VER_RANGE_V8 0xf7b8
#define S5P_FIMV_E_VBV_BUFFER_SIZE_V8 0xf78c
#define S5P_FIMV_E_VBV_INIT_DELAY_V8 0xf790
#define S5P_FIMV_E_ASPECT_RATIO_V8 0xfb4c
#define S5P_FIMV_E_EXTENDED_SAR_V8 0xfb50
#define S5P_FIMV_E_H264_OPTIONS_V8 0xfb54
/* MFCv8 Context buffer sizes */
#define MFC_CTX_BUF_SIZE_V8 (30 * SZ_1K) /* 30KB */
#define MFC_H264_DEC_CTX_BUF_SIZE_V8 (2 * SZ_1M) /* 2MB */
#define MFC_OTHER_DEC_CTX_BUF_SIZE_V8 (20 * SZ_1K) /* 20KB */
#define MFC_H264_ENC_CTX_BUF_SIZE_V8 (100 * SZ_1K) /* 100KB */
#define MFC_OTHER_ENC_CTX_BUF_SIZE_V8 (10 * SZ_1K) /* 10KB */
/* Buffer size defines */
#define S5P_FIMV_TMV_BUFFER_SIZE_V8(w, h) (((w) + 1) * ((h) + 1) * 8)
#define S5P_FIMV_SCRATCH_BUF_SIZE_H264_DEC_V8(w, h) (((w) * 704) + 2176)
#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_DEC_V8(w, h) \
(((w) * 576 + (h) * 128) + 4128)
#define S5P_FIMV_SCRATCH_BUF_SIZE_H264_ENC_V8(w, h) \
(((w) * 592) + 2336)
#define S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V8(w, h) \
(((w) * 576) + 10512 + \
((((((w) * 16) * ((h) * 16)) * 3) / 2) * 4))
#define S5P_FIMV_ME_BUFFER_SIZE_V8(imw, imh, mbw, mbh) \
((DIV_ROUND_UP((mbw * 16), 64) * DIV_ROUND_UP((mbh * 16), 64) * 256) \
+ (DIV_ROUND_UP((mbw) * (mbh), 32) * 16))
/* BUffer alignment defines */
#define S5P_FIMV_D_ALIGN_PLANE_SIZE_V8 64
/* MFCv8 variant defines */
#define MAX_FW_SIZE_V8 (SZ_1M) /* 1MB */
#define MAX_CPB_SIZE_V8 (3 * SZ_1M) /* 3MB */
#define MFC_VERSION_V8 0x80
#define MFC_NUM_PORTS_V8 1
#endif /*_REGS_MFC_V8_H*/

View file

@ -0,0 +1,459 @@
/*
* Register definition file for Samsung MFC V5.1 Interface (FIMV) driver
*
* Kamil Debski, Copyright (c) 2010 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.
*/
#ifndef _REGS_FIMV_H
#define _REGS_FIMV_H
#include <linux/kernel.h>
#include <linux/sizes.h>
#define S5P_FIMV_REG_SIZE (S5P_FIMV_END_ADDR - S5P_FIMV_START_ADDR)
#define S5P_FIMV_REG_COUNT ((S5P_FIMV_END_ADDR - S5P_FIMV_START_ADDR) / 4)
/* Number of bits that the buffer address should be shifted for particular
* MFC buffers. */
#define S5P_FIMV_START_ADDR 0x0000
#define S5P_FIMV_END_ADDR 0xe008
#define S5P_FIMV_SW_RESET 0x0000
#define S5P_FIMV_RISC_HOST_INT 0x0008
/* Command from HOST to RISC */
#define S5P_FIMV_HOST2RISC_CMD 0x0030
#define S5P_FIMV_HOST2RISC_ARG1 0x0034
#define S5P_FIMV_HOST2RISC_ARG2 0x0038
#define S5P_FIMV_HOST2RISC_ARG3 0x003c
#define S5P_FIMV_HOST2RISC_ARG4 0x0040
/* Command from RISC to HOST */
#define S5P_FIMV_RISC2HOST_CMD 0x0044
#define S5P_FIMV_RISC2HOST_CMD_MASK 0x1FFFF
#define S5P_FIMV_RISC2HOST_ARG1 0x0048
#define S5P_FIMV_RISC2HOST_ARG2 0x004c
#define S5P_FIMV_RISC2HOST_ARG3 0x0050
#define S5P_FIMV_RISC2HOST_ARG4 0x0054
#define S5P_FIMV_FW_VERSION 0x0058
#define S5P_FIMV_SYS_MEM_SZ 0x005c
#define S5P_FIMV_FW_STATUS 0x0080
/* Memory controller register */
#define S5P_FIMV_MC_DRAMBASE_ADR_A 0x0508
#define S5P_FIMV_MC_DRAMBASE_ADR_B 0x050c
#define S5P_FIMV_MC_STATUS 0x0510
/* Common register */
#define S5P_FIMV_COMMON_BASE_A 0x0600
#define S5P_FIMV_COMMON_BASE_B 0x0700
/* Decoder */
#define S5P_FIMV_DEC_CHROMA_ADR (S5P_FIMV_COMMON_BASE_A)
#define S5P_FIMV_DEC_LUMA_ADR (S5P_FIMV_COMMON_BASE_B)
/* H.264 decoding */
#define S5P_FIMV_H264_VERT_NB_MV_ADR (S5P_FIMV_COMMON_BASE_A + 0x8c)
/* vertical neighbor motion vector */
#define S5P_FIMV_H264_NB_IP_ADR (S5P_FIMV_COMMON_BASE_A + 0x90)
/* neighbor pixels for intra pred */
#define S5P_FIMV_H264_MV_ADR (S5P_FIMV_COMMON_BASE_B + 0x80)
/* H264 motion vector */
/* MPEG4 decoding */
#define S5P_FIMV_MPEG4_NB_DCAC_ADR (S5P_FIMV_COMMON_BASE_A + 0x8c)
/* neighbor AC/DC coeff. */
#define S5P_FIMV_MPEG4_UP_NB_MV_ADR (S5P_FIMV_COMMON_BASE_A + 0x90)
/* upper neighbor motion vector */
#define S5P_FIMV_MPEG4_SA_MV_ADR (S5P_FIMV_COMMON_BASE_A + 0x94)
/* subseq. anchor motion vector */
#define S5P_FIMV_MPEG4_OT_LINE_ADR (S5P_FIMV_COMMON_BASE_A + 0x98)
/* overlap transform line */
#define S5P_FIMV_MPEG4_SP_ADR (S5P_FIMV_COMMON_BASE_A + 0xa8)
/* syntax parser */
/* H.263 decoding */
#define S5P_FIMV_H263_NB_DCAC_ADR (S5P_FIMV_COMMON_BASE_A + 0x8c)
#define S5P_FIMV_H263_UP_NB_MV_ADR (S5P_FIMV_COMMON_BASE_A + 0x90)
#define S5P_FIMV_H263_SA_MV_ADR (S5P_FIMV_COMMON_BASE_A + 0x94)
#define S5P_FIMV_H263_OT_LINE_ADR (S5P_FIMV_COMMON_BASE_A + 0x98)
/* VC-1 decoding */
#define S5P_FIMV_VC1_NB_DCAC_ADR (S5P_FIMV_COMMON_BASE_A + 0x8c)
#define S5P_FIMV_VC1_UP_NB_MV_ADR (S5P_FIMV_COMMON_BASE_A + 0x90)
#define S5P_FIMV_VC1_SA_MV_ADR (S5P_FIMV_COMMON_BASE_A + 0x94)
#define S5P_FIMV_VC1_OT_LINE_ADR (S5P_FIMV_COMMON_BASE_A + 0x98)
#define S5P_FIMV_VC1_BITPLANE3_ADR (S5P_FIMV_COMMON_BASE_A + 0x9c)
/* bitplane3 */
#define S5P_FIMV_VC1_BITPLANE2_ADR (S5P_FIMV_COMMON_BASE_A + 0xa0)
/* bitplane2 */
#define S5P_FIMV_VC1_BITPLANE1_ADR (S5P_FIMV_COMMON_BASE_A + 0xa4)
/* bitplane1 */
/* Encoder */
#define S5P_FIMV_ENC_REF0_LUMA_ADR (S5P_FIMV_COMMON_BASE_A + 0x1c)
#define S5P_FIMV_ENC_REF1_LUMA_ADR (S5P_FIMV_COMMON_BASE_A + 0x20)
/* reconstructed luma */
#define S5P_FIMV_ENC_REF0_CHROMA_ADR (S5P_FIMV_COMMON_BASE_B)
#define S5P_FIMV_ENC_REF1_CHROMA_ADR (S5P_FIMV_COMMON_BASE_B + 0x04)
/* reconstructed chroma */
#define S5P_FIMV_ENC_REF2_LUMA_ADR (S5P_FIMV_COMMON_BASE_B + 0x10)
#define S5P_FIMV_ENC_REF2_CHROMA_ADR (S5P_FIMV_COMMON_BASE_B + 0x08)
#define S5P_FIMV_ENC_REF3_LUMA_ADR (S5P_FIMV_COMMON_BASE_B + 0x14)
#define S5P_FIMV_ENC_REF3_CHROMA_ADR (S5P_FIMV_COMMON_BASE_B + 0x0c)
/* H.264 encoding */
#define S5P_FIMV_H264_UP_MV_ADR (S5P_FIMV_COMMON_BASE_A)
/* upper motion vector */
#define S5P_FIMV_H264_NBOR_INFO_ADR (S5P_FIMV_COMMON_BASE_A + 0x04)
/* entropy engine's neighbor info. */
#define S5P_FIMV_H264_UP_INTRA_MD_ADR (S5P_FIMV_COMMON_BASE_A + 0x08)
/* upper intra MD */
#define S5P_FIMV_H264_COZERO_FLAG_ADR (S5P_FIMV_COMMON_BASE_A + 0x10)
/* direct cozero flag */
#define S5P_FIMV_H264_UP_INTRA_PRED_ADR (S5P_FIMV_COMMON_BASE_B + 0x40)
/* upper intra PRED */
/* H.263 encoding */
#define S5P_FIMV_H263_UP_MV_ADR (S5P_FIMV_COMMON_BASE_A)
/* upper motion vector */
#define S5P_FIMV_H263_ACDC_COEF_ADR (S5P_FIMV_COMMON_BASE_A + 0x04)
/* upper Q coeff. */
/* MPEG4 encoding */
#define S5P_FIMV_MPEG4_UP_MV_ADR (S5P_FIMV_COMMON_BASE_A)
/* upper motion vector */
#define S5P_FIMV_MPEG4_ACDC_COEF_ADR (S5P_FIMV_COMMON_BASE_A + 0x04)
/* upper Q coeff. */
#define S5P_FIMV_MPEG4_COZERO_FLAG_ADR (S5P_FIMV_COMMON_BASE_A + 0x10)
/* direct cozero flag */
#define S5P_FIMV_ENC_REF_B_LUMA_ADR 0x062c /* ref B Luma addr */
#define S5P_FIMV_ENC_REF_B_CHROMA_ADR 0x0630 /* ref B Chroma addr */
#define S5P_FIMV_ENC_CUR_LUMA_ADR 0x0718 /* current Luma addr */
#define S5P_FIMV_ENC_CUR_CHROMA_ADR 0x071C /* current Chroma addr */
/* Codec common register */
#define S5P_FIMV_ENC_HSIZE_PX 0x0818 /* frame width at encoder */
#define S5P_FIMV_ENC_VSIZE_PX 0x081c /* frame height at encoder */
#define S5P_FIMV_ENC_PROFILE 0x0830 /* profile register */
#define S5P_FIMV_ENC_PROFILE_H264_MAIN 0
#define S5P_FIMV_ENC_PROFILE_H264_HIGH 1
#define S5P_FIMV_ENC_PROFILE_H264_BASELINE 2
#define S5P_FIMV_ENC_PROFILE_H264_CONSTRAINED_BASELINE 3
#define S5P_FIMV_ENC_PROFILE_MPEG4_SIMPLE 0
#define S5P_FIMV_ENC_PROFILE_MPEG4_ADVANCED_SIMPLE 1
#define S5P_FIMV_ENC_PIC_STRUCT 0x083c /* picture field/frame flag */
#define S5P_FIMV_ENC_LF_CTRL 0x0848 /* loop filter control */
#define S5P_FIMV_ENC_ALPHA_OFF 0x084c /* loop filter alpha offset */
#define S5P_FIMV_ENC_BETA_OFF 0x0850 /* loop filter beta offset */
#define S5P_FIMV_MR_BUSIF_CTRL 0x0854 /* hidden, bus interface ctrl */
#define S5P_FIMV_ENC_PXL_CACHE_CTRL 0x0a00 /* pixel cache control */
/* Channel & stream interface register */
#define S5P_FIMV_SI_RTN_CHID 0x2000 /* Return CH inst ID register */
#define S5P_FIMV_SI_CH0_INST_ID 0x2040 /* codec instance ID */
#define S5P_FIMV_SI_CH1_INST_ID 0x2080 /* codec instance ID */
/* Decoder */
#define S5P_FIMV_SI_VRESOL 0x2004 /* vertical res of decoder */
#define S5P_FIMV_SI_HRESOL 0x2008 /* horizontal res of decoder */
#define S5P_FIMV_SI_BUF_NUMBER 0x200c /* number of frames in the
decoded pic */
#define S5P_FIMV_SI_DISPLAY_Y_ADR 0x2010 /* luma addr of displayed pic */
#define S5P_FIMV_SI_DISPLAY_C_ADR 0x2014 /* chroma addrof displayed pic */
#define S5P_FIMV_SI_CONSUMED_BYTES 0x2018 /* Consumed number of bytes to
decode a frame */
#define S5P_FIMV_SI_DISPLAY_STATUS 0x201c /* status of decoded picture */
#define S5P_FIMV_SI_DECODE_Y_ADR 0x2024 /* luma addr of decoded pic */
#define S5P_FIMV_SI_DECODE_C_ADR 0x2028 /* chroma addrof decoded pic */
#define S5P_FIMV_SI_DECODE_STATUS 0x202c /* status of decoded picture */
#define S5P_FIMV_SI_CH0_SB_ST_ADR 0x2044 /* start addr of stream buf */
#define S5P_FIMV_SI_CH0_SB_FRM_SIZE 0x2048 /* size of stream buf */
#define S5P_FIMV_SI_CH0_DESC_ADR 0x204c /* addr of descriptor buf */
#define S5P_FIMV_SI_CH0_CPB_SIZE 0x2058 /* max size of coded pic. buf */
#define S5P_FIMV_SI_CH0_DESC_SIZE 0x205c /* max size of descriptor buf */
#define S5P_FIMV_SI_CH1_SB_ST_ADR 0x2084 /* start addr of stream buf */
#define S5P_FIMV_SI_CH1_SB_FRM_SIZE 0x2088 /* size of stream buf */
#define S5P_FIMV_SI_CH1_DESC_ADR 0x208c /* addr of descriptor buf */
#define S5P_FIMV_SI_CH1_CPB_SIZE 0x2098 /* max size of coded pic. buf */
#define S5P_FIMV_SI_CH1_DESC_SIZE 0x209c /* max size of descriptor buf */
#define S5P_FIMV_CRC_LUMA0 0x2030 /* luma crc data per frame
(top field) */
#define S5P_FIMV_CRC_CHROMA0 0x2034 /* chroma crc data per frame
(top field) */
#define S5P_FIMV_CRC_LUMA1 0x2038 /* luma crc data per bottom
field */
#define S5P_FIMV_CRC_CHROMA1 0x203c /* chroma crc data per bottom
field */
/* Display status */
#define S5P_FIMV_DEC_STATUS_DECODING_ONLY 0
#define S5P_FIMV_DEC_STATUS_DECODING_DISPLAY 1
#define S5P_FIMV_DEC_STATUS_DISPLAY_ONLY 2
#define S5P_FIMV_DEC_STATUS_DECODING_EMPTY 3
#define S5P_FIMV_DEC_STATUS_DECODING_STATUS_MASK 7
#define S5P_FIMV_DEC_STATUS_PROGRESSIVE (0<<3)
#define S5P_FIMV_DEC_STATUS_INTERLACE (1<<3)
#define S5P_FIMV_DEC_STATUS_INTERLACE_MASK (1<<3)
#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_TWO (0<<4)
#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_FOUR (1<<4)
#define S5P_FIMV_DEC_STATUS_CRC_NUMBER_MASK (1<<4)
#define S5P_FIMV_DEC_STATUS_CRC_GENERATED (1<<5)
#define S5P_FIMV_DEC_STATUS_CRC_NOT_GENERATED (0<<5)
#define S5P_FIMV_DEC_STATUS_CRC_MASK (1<<5)
#define S5P_FIMV_DEC_STATUS_RESOLUTION_MASK (3<<4)
#define S5P_FIMV_DEC_STATUS_RESOLUTION_INC (1<<4)
#define S5P_FIMV_DEC_STATUS_RESOLUTION_DEC (2<<4)
#define S5P_FIMV_DEC_STATUS_RESOLUTION_SHIFT 4
/* Decode frame address */
#define S5P_FIMV_DECODE_Y_ADR 0x2024
#define S5P_FIMV_DECODE_C_ADR 0x2028
/* Decoded frame tpe */
#define S5P_FIMV_DECODE_FRAME_TYPE 0x2020
#define S5P_FIMV_DECODE_FRAME_MASK 7
#define S5P_FIMV_DECODE_FRAME_SKIPPED 0
#define S5P_FIMV_DECODE_FRAME_I_FRAME 1
#define S5P_FIMV_DECODE_FRAME_P_FRAME 2
#define S5P_FIMV_DECODE_FRAME_B_FRAME 3
#define S5P_FIMV_DECODE_FRAME_OTHER_FRAME 4
/* Sizes of buffers required for decoding */
#define S5P_FIMV_DEC_NB_IP_SIZE (32 * 1024)
#define S5P_FIMV_DEC_VERT_NB_MV_SIZE (16 * 1024)
#define S5P_FIMV_DEC_NB_DCAC_SIZE (16 * 1024)
#define S5P_FIMV_DEC_UPNB_MV_SIZE (68 * 1024)
#define S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE (136 * 1024)
#define S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE (32 * 1024)
#define S5P_FIMV_DEC_VC1_BITPLANE_SIZE (2 * 1024)
#define S5P_FIMV_DEC_STX_PARSER_SIZE (68 * 1024)
#define S5P_FIMV_DEC_BUF_ALIGN (8 * 1024)
#define S5P_FIMV_ENC_BUF_ALIGN (8 * 1024)
#define S5P_FIMV_NV12M_HALIGN 16
#define S5P_FIMV_NV12M_LVALIGN 16
#define S5P_FIMV_NV12M_CVALIGN 8
#define S5P_FIMV_NV12MT_HALIGN 128
#define S5P_FIMV_NV12MT_VALIGN 32
#define S5P_FIMV_NV12M_SALIGN 2048
#define S5P_FIMV_NV12MT_SALIGN 8192
/* Sizes of buffers required for encoding */
#define S5P_FIMV_ENC_UPMV_SIZE 0x10000
#define S5P_FIMV_ENC_COLFLG_SIZE 0x10000
#define S5P_FIMV_ENC_INTRAMD_SIZE 0x10000
#define S5P_FIMV_ENC_INTRAPRED_SIZE 0x4000
#define S5P_FIMV_ENC_NBORINFO_SIZE 0x10000
#define S5P_FIMV_ENC_ACDCCOEF_SIZE 0x10000
/* Encoder */
#define S5P_FIMV_ENC_SI_STRM_SIZE 0x2004 /* stream size */
#define S5P_FIMV_ENC_SI_PIC_CNT 0x2008 /* picture count */
#define S5P_FIMV_ENC_SI_WRITE_PTR 0x200c /* write pointer */
#define S5P_FIMV_ENC_SI_SLICE_TYPE 0x2010 /* slice type(I/P/B/IDR) */
#define S5P_FIMV_ENC_SI_SLICE_TYPE_NON_CODED 0
#define S5P_FIMV_ENC_SI_SLICE_TYPE_I 1
#define S5P_FIMV_ENC_SI_SLICE_TYPE_P 2
#define S5P_FIMV_ENC_SI_SLICE_TYPE_B 3
#define S5P_FIMV_ENC_SI_SLICE_TYPE_SKIPPED 4
#define S5P_FIMV_ENC_SI_SLICE_TYPE_OTHERS 5
#define S5P_FIMV_ENCODED_Y_ADDR 0x2014 /* the addr of the encoded
luma pic */
#define S5P_FIMV_ENCODED_C_ADDR 0x2018 /* the addr of the encoded
chroma pic */
#define S5P_FIMV_ENC_SI_CH0_SB_ADR 0x2044 /* addr of stream buf */
#define S5P_FIMV_ENC_SI_CH0_SB_SIZE 0x204c /* size of stream buf */
#define S5P_FIMV_ENC_SI_CH0_CUR_Y_ADR 0x2050 /* current Luma addr */
#define S5P_FIMV_ENC_SI_CH0_CUR_C_ADR 0x2054 /* current Chroma addr */
#define S5P_FIMV_ENC_SI_CH0_FRAME_INS 0x2058 /* frame insertion */
#define S5P_FIMV_ENC_SI_CH1_SB_ADR 0x2084 /* addr of stream buf */
#define S5P_FIMV_ENC_SI_CH1_SB_SIZE 0x208c /* size of stream buf */
#define S5P_FIMV_ENC_SI_CH1_CUR_Y_ADR 0x2090 /* current Luma addr */
#define S5P_FIMV_ENC_SI_CH1_CUR_C_ADR 0x2094 /* current Chroma addr */
#define S5P_FIMV_ENC_SI_CH1_FRAME_INS 0x2098 /* frame insertion */
#define S5P_FIMV_ENC_PIC_TYPE_CTRL 0xc504 /* pic type level control */
#define S5P_FIMV_ENC_B_RECON_WRITE_ON 0xc508 /* B frame recon write ctrl */
#define S5P_FIMV_ENC_MSLICE_CTRL 0xc50c /* multi slice control */
#define S5P_FIMV_ENC_MSLICE_MB 0xc510 /* MB number in the one slice */
#define S5P_FIMV_ENC_MSLICE_BIT 0xc514 /* bit count for one slice */
#define S5P_FIMV_ENC_CIR_CTRL 0xc518 /* number of intra refresh MB */
#define S5P_FIMV_ENC_MAP_FOR_CUR 0xc51c /* linear or tiled mode */
#define S5P_FIMV_ENC_PADDING_CTRL 0xc520 /* padding control */
#define S5P_FIMV_ENC_RC_CONFIG 0xc5a0 /* RC config */
#define S5P_FIMV_ENC_RC_BIT_RATE 0xc5a8 /* bit rate */
#define S5P_FIMV_ENC_RC_QBOUND 0xc5ac /* max/min QP */
#define S5P_FIMV_ENC_RC_RPARA 0xc5b0 /* rate control reaction coeff */
#define S5P_FIMV_ENC_RC_MB_CTRL 0xc5b4 /* MB adaptive scaling */
/* Encoder for H264 only */
#define S5P_FIMV_ENC_H264_ENTROPY_MODE 0xd004 /* CAVLC or CABAC */
#define S5P_FIMV_ENC_H264_ALPHA_OFF 0xd008 /* loop filter alpha offset */
#define S5P_FIMV_ENC_H264_BETA_OFF 0xd00c /* loop filter beta offset */
#define S5P_FIMV_ENC_H264_NUM_OF_REF 0xd010 /* number of reference for P/B */
#define S5P_FIMV_ENC_H264_TRANS_FLAG 0xd034 /* 8x8 transform flag in PPS &
high profile */
#define S5P_FIMV_ENC_RC_FRAME_RATE 0xd0d0 /* frame rate */
/* Encoder for MPEG4 only */
#define S5P_FIMV_ENC_MPEG4_QUART_PXL 0xe008 /* qpel interpolation ctrl */
/* Additional */
#define S5P_FIMV_SI_CH0_DPB_CONF_CTRL 0x2068 /* DPB Config Control Register */
#define S5P_FIMV_SLICE_INT_MASK 1
#define S5P_FIMV_SLICE_INT_SHIFT 31
#define S5P_FIMV_DDELAY_ENA_SHIFT 30
#define S5P_FIMV_DDELAY_VAL_MASK 0xff
#define S5P_FIMV_DDELAY_VAL_SHIFT 16
#define S5P_FIMV_DPB_COUNT_MASK 0xffff
#define S5P_FIMV_DPB_FLUSH_MASK 1
#define S5P_FIMV_DPB_FLUSH_SHIFT 14
#define S5P_FIMV_SI_CH0_RELEASE_BUF 0x2060 /* DPB release buffer register */
#define S5P_FIMV_SI_CH0_HOST_WR_ADR 0x2064 /* address of shared memory */
/* Codec numbers */
#define S5P_FIMV_CODEC_NONE -1
#define S5P_FIMV_CODEC_H264_DEC 0
#define S5P_FIMV_CODEC_VC1_DEC 1
#define S5P_FIMV_CODEC_MPEG4_DEC 2
#define S5P_FIMV_CODEC_MPEG2_DEC 3
#define S5P_FIMV_CODEC_H263_DEC 4
#define S5P_FIMV_CODEC_VC1RCV_DEC 5
#define S5P_FIMV_CODEC_H264_ENC 16
#define S5P_FIMV_CODEC_MPEG4_ENC 17
#define S5P_FIMV_CODEC_H263_ENC 18
/* Channel Control Register */
#define S5P_FIMV_CH_SEQ_HEADER 1
#define S5P_FIMV_CH_FRAME_START 2
#define S5P_FIMV_CH_LAST_FRAME 3
#define S5P_FIMV_CH_INIT_BUFS 4
#define S5P_FIMV_CH_FRAME_START_REALLOC 5
#define S5P_FIMV_CH_MASK 7
#define S5P_FIMV_CH_SHIFT 16
/* Host to RISC command */
#define S5P_FIMV_H2R_CMD_EMPTY 0
#define S5P_FIMV_H2R_CMD_OPEN_INSTANCE 1
#define S5P_FIMV_H2R_CMD_CLOSE_INSTANCE 2
#define S5P_FIMV_H2R_CMD_SYS_INIT 3
#define S5P_FIMV_H2R_CMD_FLUSH 4
#define S5P_FIMV_H2R_CMD_SLEEP 5
#define S5P_FIMV_H2R_CMD_WAKEUP 6
#define S5P_FIMV_R2H_CMD_EMPTY 0
#define S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET 1
#define S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET 2
#define S5P_FIMV_R2H_CMD_RSV_RET 3
#define S5P_FIMV_R2H_CMD_SEQ_DONE_RET 4
#define S5P_FIMV_R2H_CMD_FRAME_DONE_RET 5
#define S5P_FIMV_R2H_CMD_SLICE_DONE_RET 6
#define S5P_FIMV_R2H_CMD_ENC_COMPLETE_RET 7
#define S5P_FIMV_R2H_CMD_SYS_INIT_RET 8
#define S5P_FIMV_R2H_CMD_FW_STATUS_RET 9
#define S5P_FIMV_R2H_CMD_SLEEP_RET 10
#define S5P_FIMV_R2H_CMD_WAKEUP_RET 11
#define S5P_FIMV_R2H_CMD_FLUSH_RET 12
#define S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET 15
#define S5P_FIMV_R2H_CMD_EDFU_INIT_RET 16
#define S5P_FIMV_R2H_CMD_ERR_RET 32
/* Dummy definition for MFCv6 compatibility */
#define S5P_FIMV_CODEC_H264_MVC_DEC -1
#define S5P_FIMV_R2H_CMD_FIELD_DONE_RET -1
#define S5P_FIMV_MFC_RESET -1
#define S5P_FIMV_RISC_ON -1
#define S5P_FIMV_RISC_BASE_ADDRESS -1
#define S5P_FIMV_CODEC_VP8_DEC -1
#define S5P_FIMV_REG_CLEAR_BEGIN 0
#define S5P_FIMV_REG_CLEAR_COUNT 0
/* Error handling defines */
#define S5P_FIMV_ERR_WARNINGS_START 145
#define S5P_FIMV_ERR_DEC_MASK 0xFFFF
#define S5P_FIMV_ERR_DEC_SHIFT 0
#define S5P_FIMV_ERR_DSPL_MASK 0xFFFF0000
#define S5P_FIMV_ERR_DSPL_SHIFT 16
/* Shared memory registers' offsets */
/* An offset of the start position in the stream when
* the start position is not aligned */
#define S5P_FIMV_SHARED_CROP_INFO_H 0x0020
#define S5P_FIMV_SHARED_CROP_LEFT_MASK 0xFFFF
#define S5P_FIMV_SHARED_CROP_LEFT_SHIFT 0
#define S5P_FIMV_SHARED_CROP_RIGHT_MASK 0xFFFF0000
#define S5P_FIMV_SHARED_CROP_RIGHT_SHIFT 16
#define S5P_FIMV_SHARED_CROP_INFO_V 0x0024
#define S5P_FIMV_SHARED_CROP_TOP_MASK 0xFFFF
#define S5P_FIMV_SHARED_CROP_TOP_SHIFT 0
#define S5P_FIMV_SHARED_CROP_BOTTOM_MASK 0xFFFF0000
#define S5P_FIMV_SHARED_CROP_BOTTOM_SHIFT 16
#define S5P_FIMV_SHARED_SET_FRAME_TAG 0x0004
#define S5P_FIMV_SHARED_GET_FRAME_TAG_TOP 0x0008
#define S5P_FIMV_SHARED_GET_FRAME_TAG_BOT 0x000C
#define S5P_FIMV_SHARED_START_BYTE_NUM 0x0018
#define S5P_FIMV_SHARED_RC_VOP_TIMING 0x0030
#define S5P_FIMV_SHARED_LUMA_DPB_SIZE 0x0064
#define S5P_FIMV_SHARED_CHROMA_DPB_SIZE 0x0068
#define S5P_FIMV_SHARED_MV_SIZE 0x006C
#define S5P_FIMV_SHARED_PIC_TIME_TOP 0x0010
#define S5P_FIMV_SHARED_PIC_TIME_BOTTOM 0x0014
#define S5P_FIMV_SHARED_EXT_ENC_CONTROL 0x0028
#define S5P_FIMV_SHARED_P_B_FRAME_QP 0x0070
#define S5P_FIMV_SHARED_ASPECT_RATIO_IDC 0x0074
#define S5P_FIMV_SHARED_EXTENDED_SAR 0x0078
#define S5P_FIMV_SHARED_H264_I_PERIOD 0x009C
#define S5P_FIMV_SHARED_RC_CONTROL_CONFIG 0x00A0
#define S5P_FIMV_SHARED_DISP_FRAME_TYPE_SHIFT 2
/* Offset used by the hardware to store addresses */
#define MFC_OFFSET_SHIFT 11
#define FIRMWARE_ALIGN (128 * SZ_1K) /* 128KB */
#define MFC_H264_CTX_BUF_SIZE (600 * SZ_1K) /* 600KB per H264 instance */
#define MFC_CTX_BUF_SIZE (10 * SZ_1K) /* 10KB per instance */
#define DESC_BUF_SIZE (128 * SZ_1K) /* 128KB for DESC buffer */
#define SHARED_BUF_SIZE (8 * SZ_1K) /* 8KB for shared buffer */
#define DEF_CPB_SIZE (256 * SZ_1K) /* 256KB */
#define MAX_CPB_SIZE (4 * SZ_1M) /* 4MB */
#define MAX_FW_SIZE (384 * SZ_1K)
#define MFC_VERSION 0x51
#define MFC_NUM_PORTS 2
#define S5P_FIMV_SHARED_FRAME_PACK_SEI_AVAIL 0x16C
#define S5P_FIMV_SHARED_FRAME_PACK_ARRGMENT_ID 0x170
#define S5P_FIMV_SHARED_FRAME_PACK_SEI_INFO 0x174
#define S5P_FIMV_SHARED_FRAME_PACK_GRID_POS 0x178
/* Values for resolution change in display status */
#define S5P_FIMV_RES_INCREASE 1
#define S5P_FIMV_RES_DECREASE 2
#endif /* _REGS_FIMV_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.c
*
* Copyright (C) 2012 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "s5p_mfc_cmd.h"
#include "s5p_mfc_common.h"
#include "s5p_mfc_debug.h"
#include "s5p_mfc_cmd_v5.h"
#include "s5p_mfc_cmd_v6.h"
static struct s5p_mfc_hw_cmds *s5p_mfc_cmds;
void s5p_mfc_init_hw_cmds(struct s5p_mfc_dev *dev)
{
if (IS_MFCV6_PLUS(dev))
s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v6();
else
s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v5();
dev->mfc_cmds = s5p_mfc_cmds;
}

View file

@ -0,0 +1,35 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_cmd.h
*
* Copyright (C) 2012 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef S5P_MFC_CMD_H_
#define S5P_MFC_CMD_H_
#include "s5p_mfc_common.h"
#define MAX_H2R_ARG 4
struct s5p_mfc_cmd_args {
unsigned int arg[MAX_H2R_ARG];
};
struct s5p_mfc_hw_cmds {
int (*cmd_host2risc)(struct s5p_mfc_dev *dev, int cmd,
struct s5p_mfc_cmd_args *args);
int (*sys_init_cmd)(struct s5p_mfc_dev *dev);
int (*sleep_cmd)(struct s5p_mfc_dev *dev);
int (*wakeup_cmd)(struct s5p_mfc_dev *dev);
int (*open_inst_cmd)(struct s5p_mfc_ctx *ctx);
int (*close_inst_cmd)(struct s5p_mfc_ctx *ctx);
};
void s5p_mfc_init_hw_cmds(struct s5p_mfc_dev *dev);
#endif /* S5P_MFC_CMD_H_ */

View file

@ -0,0 +1,167 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "regs-mfc.h"
#include "s5p_mfc_cmd.h"
#include "s5p_mfc_common.h"
#include "s5p_mfc_debug.h"
#include "s5p_mfc_cmd_v5.h"
/* This function is used to send a command to the MFC */
static int s5p_mfc_cmd_host2risc_v5(struct s5p_mfc_dev *dev, int cmd,
struct s5p_mfc_cmd_args *args)
{
int cur_cmd;
unsigned long timeout;
timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
/* wait until host to risc command register becomes 'H2R_CMD_EMPTY' */
do {
if (time_after(jiffies, timeout)) {
mfc_err("Timeout while waiting for hardware\n");
return -EIO;
}
cur_cmd = mfc_read(dev, S5P_FIMV_HOST2RISC_CMD);
} while (cur_cmd != S5P_FIMV_H2R_CMD_EMPTY);
mfc_write(dev, args->arg[0], S5P_FIMV_HOST2RISC_ARG1);
mfc_write(dev, args->arg[1], S5P_FIMV_HOST2RISC_ARG2);
mfc_write(dev, args->arg[2], S5P_FIMV_HOST2RISC_ARG3);
mfc_write(dev, args->arg[3], S5P_FIMV_HOST2RISC_ARG4);
/* Issue the command */
mfc_write(dev, cmd, S5P_FIMV_HOST2RISC_CMD);
return 0;
}
/* Initialize the MFC */
static int s5p_mfc_sys_init_cmd_v5(struct s5p_mfc_dev *dev)
{
struct s5p_mfc_cmd_args h2r_args;
memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
h2r_args.arg[0] = dev->fw_size;
return s5p_mfc_cmd_host2risc_v5(dev, S5P_FIMV_H2R_CMD_SYS_INIT,
&h2r_args);
}
/* Suspend the MFC hardware */
static int s5p_mfc_sleep_cmd_v5(struct s5p_mfc_dev *dev)
{
struct s5p_mfc_cmd_args h2r_args;
memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
return s5p_mfc_cmd_host2risc_v5(dev, S5P_FIMV_H2R_CMD_SLEEP, &h2r_args);
}
/* Wake up the MFC hardware */
static int s5p_mfc_wakeup_cmd_v5(struct s5p_mfc_dev *dev)
{
struct s5p_mfc_cmd_args h2r_args;
memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
return s5p_mfc_cmd_host2risc_v5(dev, S5P_FIMV_H2R_CMD_WAKEUP,
&h2r_args);
}
static int s5p_mfc_open_inst_cmd_v5(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_cmd_args h2r_args;
int ret;
/* Preparing decoding - getting instance number */
mfc_debug(2, "Getting instance number (codec: %d)\n", ctx->codec_mode);
dev->curr_ctx = ctx->num;
memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
switch (ctx->codec_mode) {
case S5P_MFC_CODEC_H264_DEC:
h2r_args.arg[0] = S5P_FIMV_CODEC_H264_DEC;
break;
case S5P_MFC_CODEC_VC1_DEC:
h2r_args.arg[0] = S5P_FIMV_CODEC_VC1_DEC;
break;
case S5P_MFC_CODEC_MPEG4_DEC:
h2r_args.arg[0] = S5P_FIMV_CODEC_MPEG4_DEC;
break;
case S5P_MFC_CODEC_MPEG2_DEC:
h2r_args.arg[0] = S5P_FIMV_CODEC_MPEG2_DEC;
break;
case S5P_MFC_CODEC_H263_DEC:
h2r_args.arg[0] = S5P_FIMV_CODEC_H263_DEC;
break;
case S5P_MFC_CODEC_VC1RCV_DEC:
h2r_args.arg[0] = S5P_FIMV_CODEC_VC1RCV_DEC;
break;
case S5P_MFC_CODEC_H264_ENC:
h2r_args.arg[0] = S5P_FIMV_CODEC_H264_ENC;
break;
case S5P_MFC_CODEC_MPEG4_ENC:
h2r_args.arg[0] = S5P_FIMV_CODEC_MPEG4_ENC;
break;
case S5P_MFC_CODEC_H263_ENC:
h2r_args.arg[0] = S5P_FIMV_CODEC_H263_ENC;
break;
default:
h2r_args.arg[0] = S5P_FIMV_CODEC_NONE;
}
h2r_args.arg[1] = 0; /* no crc & no pixelcache */
h2r_args.arg[2] = ctx->ctx.ofs;
h2r_args.arg[3] = ctx->ctx.size;
ret = s5p_mfc_cmd_host2risc_v5(dev, S5P_FIMV_H2R_CMD_OPEN_INSTANCE,
&h2r_args);
if (ret) {
mfc_err("Failed to create a new instance\n");
ctx->state = MFCINST_ERROR;
}
return ret;
}
static int s5p_mfc_close_inst_cmd_v5(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_cmd_args h2r_args;
int ret;
if (ctx->state == MFCINST_FREE) {
mfc_err("Instance already returned\n");
ctx->state = MFCINST_ERROR;
return -EINVAL;
}
/* Closing decoding instance */
mfc_debug(2, "Returning instance number %d\n", ctx->inst_no);
dev->curr_ctx = ctx->num;
memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
h2r_args.arg[0] = ctx->inst_no;
ret = s5p_mfc_cmd_host2risc_v5(dev, S5P_FIMV_H2R_CMD_CLOSE_INSTANCE,
&h2r_args);
if (ret) {
mfc_err("Failed to return an instance\n");
ctx->state = MFCINST_ERROR;
return -EINVAL;
}
return 0;
}
/* Initialize cmd function pointers for MFC v5 */
static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v5 = {
.cmd_host2risc = s5p_mfc_cmd_host2risc_v5,
.sys_init_cmd = s5p_mfc_sys_init_cmd_v5,
.sleep_cmd = s5p_mfc_sleep_cmd_v5,
.wakeup_cmd = s5p_mfc_wakeup_cmd_v5,
.open_inst_cmd = s5p_mfc_open_inst_cmd_v5,
.close_inst_cmd = s5p_mfc_close_inst_cmd_v5,
};
struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void)
{
return &s5p_mfc_cmds_v5;
}

View file

@ -0,0 +1,20 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.h
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef S5P_MFC_CMD_V5_H_
#define S5P_MFC_CMD_V5_H_
#include "s5p_mfc_common.h"
struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void);
#endif /* S5P_MFC_CMD_H_ */

View file

@ -0,0 +1,160 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.c
*
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "s5p_mfc_common.h"
#include "s5p_mfc_cmd.h"
#include "s5p_mfc_debug.h"
#include "s5p_mfc_intr.h"
#include "s5p_mfc_opr.h"
#include "s5p_mfc_cmd_v6.h"
static int s5p_mfc_cmd_host2risc_v6(struct s5p_mfc_dev *dev, int cmd,
struct s5p_mfc_cmd_args *args)
{
mfc_debug(2, "Issue the command: %d\n", cmd);
/* Reset RISC2HOST command */
mfc_write(dev, 0x0, S5P_FIMV_RISC2HOST_CMD_V6);
/* Issue the command */
mfc_write(dev, cmd, S5P_FIMV_HOST2RISC_CMD_V6);
mfc_write(dev, 0x1, S5P_FIMV_HOST2RISC_INT_V6);
return 0;
}
static int s5p_mfc_sys_init_cmd_v6(struct s5p_mfc_dev *dev)
{
struct s5p_mfc_cmd_args h2r_args;
struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
s5p_mfc_hw_call(dev->mfc_ops, alloc_dev_context_buffer, dev);
mfc_write(dev, dev->ctx_buf.dma, S5P_FIMV_CONTEXT_MEM_ADDR_V6);
mfc_write(dev, buf_size->dev_ctx, S5P_FIMV_CONTEXT_MEM_SIZE_V6);
return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_SYS_INIT_V6,
&h2r_args);
}
static int s5p_mfc_sleep_cmd_v6(struct s5p_mfc_dev *dev)
{
struct s5p_mfc_cmd_args h2r_args;
memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_SLEEP_V6,
&h2r_args);
}
static int s5p_mfc_wakeup_cmd_v6(struct s5p_mfc_dev *dev)
{
struct s5p_mfc_cmd_args h2r_args;
memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args));
return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_WAKEUP_V6,
&h2r_args);
}
/* Open a new instance and get its number */
static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_cmd_args h2r_args;
int codec_type;
mfc_debug(2, "Requested codec mode: %d\n", ctx->codec_mode);
dev->curr_ctx = ctx->num;
switch (ctx->codec_mode) {
case S5P_MFC_CODEC_H264_DEC:
codec_type = S5P_FIMV_CODEC_H264_DEC_V6;
break;
case S5P_MFC_CODEC_H264_MVC_DEC:
codec_type = S5P_FIMV_CODEC_H264_MVC_DEC_V6;
break;
case S5P_MFC_CODEC_VC1_DEC:
codec_type = S5P_FIMV_CODEC_VC1_DEC_V6;
break;
case S5P_MFC_CODEC_MPEG4_DEC:
codec_type = S5P_FIMV_CODEC_MPEG4_DEC_V6;
break;
case S5P_MFC_CODEC_MPEG2_DEC:
codec_type = S5P_FIMV_CODEC_MPEG2_DEC_V6;
break;
case S5P_MFC_CODEC_H263_DEC:
codec_type = S5P_FIMV_CODEC_H263_DEC_V6;
break;
case S5P_MFC_CODEC_VC1RCV_DEC:
codec_type = S5P_FIMV_CODEC_VC1RCV_DEC_V6;
break;
case S5P_MFC_CODEC_VP8_DEC:
codec_type = S5P_FIMV_CODEC_VP8_DEC_V6;
break;
case S5P_MFC_CODEC_H264_ENC:
codec_type = S5P_FIMV_CODEC_H264_ENC_V6;
break;
case S5P_MFC_CODEC_H264_MVC_ENC:
codec_type = S5P_FIMV_CODEC_H264_MVC_ENC_V6;
break;
case S5P_MFC_CODEC_MPEG4_ENC:
codec_type = S5P_FIMV_CODEC_MPEG4_ENC_V6;
break;
case S5P_MFC_CODEC_H263_ENC:
codec_type = S5P_FIMV_CODEC_H263_ENC_V6;
break;
case S5P_MFC_CODEC_VP8_ENC:
codec_type = S5P_FIMV_CODEC_VP8_ENC_V7;
break;
default:
codec_type = S5P_FIMV_CODEC_NONE_V6;
}
mfc_write(dev, codec_type, S5P_FIMV_CODEC_TYPE_V6);
mfc_write(dev, ctx->ctx.dma, S5P_FIMV_CONTEXT_MEM_ADDR_V6);
mfc_write(dev, ctx->ctx.size, S5P_FIMV_CONTEXT_MEM_SIZE_V6);
mfc_write(dev, 0, S5P_FIMV_D_CRC_CTRL_V6); /* no crc */
return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_OPEN_INSTANCE_V6,
&h2r_args);
}
/* Close instance */
static int s5p_mfc_close_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_cmd_args h2r_args;
int ret = 0;
dev->curr_ctx = ctx->num;
if (ctx->state != MFCINST_FREE) {
mfc_write(dev, ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
ret = s5p_mfc_cmd_host2risc_v6(dev,
S5P_FIMV_H2R_CMD_CLOSE_INSTANCE_V6,
&h2r_args);
} else {
ret = -EINVAL;
}
return ret;
}
/* Initialize cmd function pointers for MFC v6 */
static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
.cmd_host2risc = s5p_mfc_cmd_host2risc_v6,
.sys_init_cmd = s5p_mfc_sys_init_cmd_v6,
.sleep_cmd = s5p_mfc_sleep_cmd_v6,
.wakeup_cmd = s5p_mfc_wakeup_cmd_v6,
.open_inst_cmd = s5p_mfc_open_inst_cmd_v6,
.close_inst_cmd = s5p_mfc_close_inst_cmd_v6,
};
struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void)
{
return &s5p_mfc_cmds_v6;
}

View file

@ -0,0 +1,20 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v6.h
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef S5P_MFC_CMD_V6_H_
#define S5P_MFC_CMD_V6_H_
#include "s5p_mfc_common.h"
struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void);
#endif /* S5P_MFC_CMD_H_ */

View file

@ -0,0 +1,729 @@
/*
* Samsung S5P Multi Format Codec v 5.0
*
* This file contains definitions of enums and structs used by the codec
* driver.
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* Kamil Debski, <k.debski@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the
* License, or (at your option) any later version
*/
#ifndef S5P_MFC_COMMON_H_
#define S5P_MFC_COMMON_H_
#include <linux/platform_device.h>
#include <linux/videodev2.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-core.h>
#include "regs-mfc.h"
#include "regs-mfc-v8.h"
/* Definitions related to MFC memory */
/* Offset base used to differentiate between CAPTURE and OUTPUT
* while mmaping */
#define DST_QUEUE_OFF_BASE (1 << 30)
#define MFC_BANK1_ALLOC_CTX 0
#define MFC_BANK2_ALLOC_CTX 1
#define MFC_BANK1_ALIGN_ORDER 13
#define MFC_BANK2_ALIGN_ORDER 13
#define MFC_BASE_ALIGN_ORDER 17
#define MFC_FW_MAX_VERSIONS 2
#include <media/videobuf2-dma-contig.h>
static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b)
{
/* Same functionality as the vb2_dma_contig_plane_paddr */
dma_addr_t *paddr = vb2_dma_contig_memops.cookie(b);
return *paddr;
}
/* MFC definitions */
#define MFC_MAX_EXTRA_DPB 5
#define MFC_MAX_BUFFERS 32
#define MFC_NUM_CONTEXTS 4
/* Interrupt timeout */
#define MFC_INT_TIMEOUT 2000
/* Busy wait timeout */
#define MFC_BW_TIMEOUT 500
/* Watchdog interval */
#define MFC_WATCHDOG_INTERVAL 1000
/* After how many executions watchdog should assume lock up */
#define MFC_WATCHDOG_CNT 10
#define MFC_NO_INSTANCE_SET -1
#define MFC_ENC_CAP_PLANE_COUNT 1
#define MFC_ENC_OUT_PLANE_COUNT 2
#define STUFF_BYTE 4
#define MFC_MAX_CTRLS 77
#define S5P_MFC_CODEC_NONE -1
#define S5P_MFC_CODEC_H264_DEC 0
#define S5P_MFC_CODEC_H264_MVC_DEC 1
#define S5P_MFC_CODEC_VC1_DEC 2
#define S5P_MFC_CODEC_MPEG4_DEC 3
#define S5P_MFC_CODEC_MPEG2_DEC 4
#define S5P_MFC_CODEC_H263_DEC 5
#define S5P_MFC_CODEC_VC1RCV_DEC 6
#define S5P_MFC_CODEC_VP8_DEC 7
#define S5P_MFC_CODEC_H264_ENC 20
#define S5P_MFC_CODEC_H264_MVC_ENC 21
#define S5P_MFC_CODEC_MPEG4_ENC 22
#define S5P_MFC_CODEC_H263_ENC 23
#define S5P_MFC_CODEC_VP8_ENC 24
#define S5P_MFC_R2H_CMD_EMPTY 0
#define S5P_MFC_R2H_CMD_SYS_INIT_RET 1
#define S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET 2
#define S5P_MFC_R2H_CMD_SEQ_DONE_RET 3
#define S5P_MFC_R2H_CMD_INIT_BUFFERS_RET 4
#define S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET 6
#define S5P_MFC_R2H_CMD_SLEEP_RET 7
#define S5P_MFC_R2H_CMD_WAKEUP_RET 8
#define S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET 9
#define S5P_MFC_R2H_CMD_DPB_FLUSH_RET 10
#define S5P_MFC_R2H_CMD_NAL_ABORT_RET 11
#define S5P_MFC_R2H_CMD_FW_STATUS_RET 12
#define S5P_MFC_R2H_CMD_FRAME_DONE_RET 13
#define S5P_MFC_R2H_CMD_FIELD_DONE_RET 14
#define S5P_MFC_R2H_CMD_SLICE_DONE_RET 15
#define S5P_MFC_R2H_CMD_ENC_BUFFER_FUL_RET 16
#define S5P_MFC_R2H_CMD_ERR_RET 32
#define mfc_read(dev, offset) readl(dev->regs_base + (offset))
#define mfc_write(dev, data, offset) writel((data), dev->regs_base + \
(offset))
/**
* enum s5p_mfc_fmt_type - type of the pixelformat
*/
enum s5p_mfc_fmt_type {
MFC_FMT_DEC,
MFC_FMT_ENC,
MFC_FMT_RAW,
};
/**
* enum s5p_mfc_inst_type - The type of an MFC instance.
*/
enum s5p_mfc_inst_type {
MFCINST_INVALID,
MFCINST_DECODER,
MFCINST_ENCODER,
};
/**
* enum s5p_mfc_inst_state - The state of an MFC instance.
*/
enum s5p_mfc_inst_state {
MFCINST_FREE = 0,
MFCINST_INIT = 100,
MFCINST_GOT_INST,
MFCINST_HEAD_PARSED,
MFCINST_HEAD_PRODUCED,
MFCINST_BUFS_SET,
MFCINST_RUNNING,
MFCINST_FINISHING,
MFCINST_FINISHED,
MFCINST_RETURN_INST,
MFCINST_ERROR,
MFCINST_ABORT,
MFCINST_FLUSH,
MFCINST_RES_CHANGE_INIT,
MFCINST_RES_CHANGE_FLUSH,
MFCINST_RES_CHANGE_END,
};
/**
* enum s5p_mfc_queue_state - The state of buffer queue.
*/
enum s5p_mfc_queue_state {
QUEUE_FREE,
QUEUE_BUFS_REQUESTED,
QUEUE_BUFS_QUERIED,
QUEUE_BUFS_MMAPED,
};
/**
* enum s5p_mfc_decode_arg - type of frame decoding
*/
enum s5p_mfc_decode_arg {
MFC_DEC_FRAME,
MFC_DEC_LAST_FRAME,
MFC_DEC_RES_CHANGE,
};
enum s5p_mfc_fw_ver {
MFC_FW_V1,
MFC_FW_V2,
};
#define MFC_BUF_FLAG_USED (1 << 0)
#define MFC_BUF_FLAG_EOS (1 << 1)
struct s5p_mfc_ctx;
/**
* struct s5p_mfc_buf - MFC buffer
*/
struct s5p_mfc_buf {
struct list_head list;
struct vb2_buffer *b;
union {
struct {
size_t luma;
size_t chroma;
} raw;
size_t stream;
} cookie;
int flags;
};
/**
* struct s5p_mfc_pm - power management data structure
*/
struct s5p_mfc_pm {
struct clk *clock;
struct clk *clock_gate;
atomic_t power;
struct device *device;
};
struct s5p_mfc_buf_size_v5 {
unsigned int h264_ctx;
unsigned int non_h264_ctx;
unsigned int dsc;
unsigned int shm;
};
struct s5p_mfc_buf_size_v6 {
unsigned int dev_ctx;
unsigned int h264_dec_ctx;
unsigned int other_dec_ctx;
unsigned int h264_enc_ctx;
unsigned int other_enc_ctx;
};
struct s5p_mfc_buf_size {
unsigned int fw;
unsigned int cpb;
void *priv;
};
struct s5p_mfc_buf_align {
unsigned int base;
};
struct s5p_mfc_variant {
unsigned int version;
unsigned int port_num;
u32 version_bit;
struct s5p_mfc_buf_size *buf_size;
struct s5p_mfc_buf_align *buf_align;
char *fw_name[MFC_FW_MAX_VERSIONS];
};
/**
* struct s5p_mfc_priv_buf - represents internal used buffer
* @alloc: allocation-specific context for each buffer
* (videobuf2 allocator)
* @ofs: offset of each buffer, will be used for MFC
* @virt: kernel virtual address, only valid when the
* buffer accessed by driver
* @dma: DMA address, only valid when kernel DMA API used
* @size: size of the buffer
*/
struct s5p_mfc_priv_buf {
void *alloc;
unsigned long ofs;
void *virt;
dma_addr_t dma;
size_t size;
};
/**
* struct s5p_mfc_dev - The struct containing driver internal parameters.
*
* @v4l2_dev: v4l2_device
* @vfd_dec: video device for decoding
* @vfd_enc: video device for encoding
* @plat_dev: platform device
* @mem_dev_l: child device of the left memory bank (0)
* @mem_dev_r: child device of the right memory bank (1)
* @regs_base: base address of the MFC hw registers
* @irq: irq resource
* @dec_ctrl_handler: control framework handler for decoding
* @enc_ctrl_handler: control framework handler for encoding
* @pm: power management control
* @variant: MFC hardware variant information
* @num_inst: couter of active MFC instances
* @irqlock: lock for operations on videobuf2 queues
* @condlock: lock for changing/checking if a context is ready to be
* processed
* @mfc_mutex: lock for video_device
* @int_cond: variable used by the waitqueue
* @int_type: type of last interrupt
* @int_err: error number for last interrupt
* @queue: waitqueue for waiting for completion of device commands
* @fw_size: size of firmware
* @fw_virt_addr: virtual firmware address
* @bank1: address of the beginning of bank 1 memory
* @bank2: address of the beginning of bank 2 memory
* @hw_lock: used for hardware locking
* @ctx: array of driver contexts
* @curr_ctx: number of the currently running context
* @ctx_work_bits: used to mark which contexts are waiting for hardware
* @watchdog_cnt: counter for the watchdog
* @watchdog_workqueue: workqueue for the watchdog
* @watchdog_work: worker for the watchdog
* @alloc_ctx: videobuf2 allocator contexts for two memory banks
* @enter_suspend: flag set when entering suspend
* @ctx_buf: common context memory (MFCv6)
* @warn_start: hardware error code from which warnings start
* @mfc_ops: ops structure holding HW operation function pointers
* @mfc_cmds: cmd structure holding HW commands function pointers
* @fw_ver: loaded firmware sub-version
*
*/
struct s5p_mfc_dev {
struct v4l2_device v4l2_dev;
struct video_device *vfd_dec;
struct video_device *vfd_enc;
struct platform_device *plat_dev;
struct device *mem_dev_l;
struct device *mem_dev_r;
void __iomem *regs_base;
int irq;
struct v4l2_ctrl_handler dec_ctrl_handler;
struct v4l2_ctrl_handler enc_ctrl_handler;
struct s5p_mfc_pm pm;
struct s5p_mfc_variant *variant;
int num_inst;
spinlock_t irqlock; /* lock when operating on videobuf2 queues */
spinlock_t condlock; /* lock when changing/checking if a context is
ready to be processed */
struct mutex mfc_mutex; /* video_device lock */
int int_cond;
int int_type;
unsigned int int_err;
wait_queue_head_t queue;
size_t fw_size;
void *fw_virt_addr;
dma_addr_t bank1;
dma_addr_t bank2;
unsigned long hw_lock;
struct s5p_mfc_ctx *ctx[MFC_NUM_CONTEXTS];
int curr_ctx;
unsigned long ctx_work_bits;
atomic_t watchdog_cnt;
struct timer_list watchdog_timer;
struct workqueue_struct *watchdog_workqueue;
struct work_struct watchdog_work;
void *alloc_ctx[2];
unsigned long enter_suspend;
struct s5p_mfc_priv_buf ctx_buf;
int warn_start;
struct s5p_mfc_hw_ops *mfc_ops;
struct s5p_mfc_hw_cmds *mfc_cmds;
const struct s5p_mfc_regs *mfc_regs;
enum s5p_mfc_fw_ver fw_ver;
};
/**
* struct s5p_mfc_h264_enc_params - encoding parameters for h264
*/
struct s5p_mfc_h264_enc_params {
enum v4l2_mpeg_video_h264_profile profile;
enum v4l2_mpeg_video_h264_loop_filter_mode loop_filter_mode;
s8 loop_filter_alpha;
s8 loop_filter_beta;
enum v4l2_mpeg_video_h264_entropy_mode entropy_mode;
u8 max_ref_pic;
u8 num_ref_pic_4p;
int _8x8_transform;
int rc_mb_dark;
int rc_mb_smooth;
int rc_mb_static;
int rc_mb_activity;
int vui_sar;
u8 vui_sar_idc;
u16 vui_ext_sar_width;
u16 vui_ext_sar_height;
int open_gop;
u16 open_gop_size;
u8 rc_frame_qp;
u8 rc_min_qp;
u8 rc_max_qp;
u8 rc_p_frame_qp;
u8 rc_b_frame_qp;
enum v4l2_mpeg_video_h264_level level_v4l2;
int level;
u16 cpb_size;
int interlace;
u8 hier_qp;
u8 hier_qp_type;
u8 hier_qp_layer;
u8 hier_qp_layer_qp[7];
u8 sei_frame_packing;
u8 sei_fp_curr_frame_0;
u8 sei_fp_arrangement_type;
u8 fmo;
u8 fmo_map_type;
u8 fmo_slice_grp;
u8 fmo_chg_dir;
u32 fmo_chg_rate;
u32 fmo_run_len[4];
u8 aso;
u32 aso_slice_order[8];
};
/**
* struct s5p_mfc_mpeg4_enc_params - encoding parameters for h263 and mpeg4
*/
struct s5p_mfc_mpeg4_enc_params {
/* MPEG4 Only */
enum v4l2_mpeg_video_mpeg4_profile profile;
int quarter_pixel;
/* Common for MPEG4, H263 */
u16 vop_time_res;
u16 vop_frm_delta;
u8 rc_frame_qp;
u8 rc_min_qp;
u8 rc_max_qp;
u8 rc_p_frame_qp;
u8 rc_b_frame_qp;
enum v4l2_mpeg_video_mpeg4_level level_v4l2;
int level;
};
/**
* struct s5p_mfc_vp8_enc_params - encoding parameters for vp8
*/
struct s5p_mfc_vp8_enc_params {
u8 imd_4x4;
enum v4l2_vp8_num_partitions num_partitions;
enum v4l2_vp8_num_ref_frames num_ref;
u8 filter_level;
u8 filter_sharpness;
u32 golden_frame_ref_period;
enum v4l2_vp8_golden_frame_sel golden_frame_sel;
u8 hier_layer;
u8 hier_layer_qp[3];
u8 rc_min_qp;
u8 rc_max_qp;
u8 rc_frame_qp;
u8 rc_p_frame_qp;
u8 profile;
};
/**
* struct s5p_mfc_enc_params - general encoding parameters
*/
struct s5p_mfc_enc_params {
u16 width;
u16 height;
u32 mv_h_range;
u32 mv_v_range;
u16 gop_size;
enum v4l2_mpeg_video_multi_slice_mode slice_mode;
u16 slice_mb;
u32 slice_bit;
u16 intra_refresh_mb;
int pad;
u8 pad_luma;
u8 pad_cb;
u8 pad_cr;
int rc_frame;
int rc_mb;
u32 rc_bitrate;
u16 rc_reaction_coeff;
u16 vbv_size;
u32 vbv_delay;
enum v4l2_mpeg_video_header_mode seq_hdr_mode;
enum v4l2_mpeg_mfc51_video_frame_skip_mode frame_skip_mode;
int fixed_target_bit;
u8 num_b_frame;
u32 rc_framerate_num;
u32 rc_framerate_denom;
struct {
struct s5p_mfc_h264_enc_params h264;
struct s5p_mfc_mpeg4_enc_params mpeg4;
struct s5p_mfc_vp8_enc_params vp8;
} codec;
};
/**
* struct s5p_mfc_codec_ops - codec ops, used by encoding
*/
struct s5p_mfc_codec_ops {
/* initialization routines */
int (*pre_seq_start) (struct s5p_mfc_ctx *ctx);
int (*post_seq_start) (struct s5p_mfc_ctx *ctx);
/* execution routines */
int (*pre_frame_start) (struct s5p_mfc_ctx *ctx);
int (*post_frame_start) (struct s5p_mfc_ctx *ctx);
};
#define call_cop(c, op, args...) \
(((c)->c_ops->op) ? \
((c)->c_ops->op(args)) : 0)
/**
* struct s5p_mfc_ctx - This struct contains the instance context
*
* @dev: pointer to the s5p_mfc_dev of the device
* @fh: struct v4l2_fh
* @num: number of the context that this structure describes
* @int_cond: variable used by the waitqueue
* @int_type: type of the last interrupt
* @int_err: error number received from MFC hw in the interrupt
* @queue: waitqueue that can be used to wait for this context to
* finish
* @src_fmt: source pixelformat information
* @dst_fmt: destination pixelformat information
* @vq_src: vb2 queue for source buffers
* @vq_dst: vb2 queue for destination buffers
* @src_queue: driver internal queue for source buffers
* @dst_queue: driver internal queue for destination buffers
* @src_queue_cnt: number of buffers queued on the source internal queue
* @dst_queue_cnt: number of buffers queued on the dest internal queue
* @type: type of the instance - decoder or encoder
* @state: state of the context
* @inst_no: number of hw instance associated with the context
* @img_width: width of the image that is decoded or encoded
* @img_height: height of the image that is decoded or encoded
* @buf_width: width of the buffer for processed image
* @buf_height: height of the buffer for processed image
* @luma_size: size of a luma plane
* @chroma_size: size of a chroma plane
* @mv_size: size of a motion vectors buffer
* @consumed_stream: number of bytes that have been used so far from the
* decoding buffer
* @dpb_flush_flag: flag used to indicate that a DPB buffers are being
* flushed
* @head_processed: flag mentioning whether the header data is processed
* completely or not
* @bank1: handle to memory allocated for temporary buffers from
* memory bank 1
* @bank2: handle to memory allocated for temporary buffers from
* memory bank 2
* @capture_state: state of the capture buffers queue
* @output_state: state of the output buffers queue
* @src_bufs: information on allocated source buffers
* @dst_bufs: information on allocated destination buffers
* @sequence: counter for the sequence number for v4l2
* @dec_dst_flag: flags for buffers queued in the hardware
* @dec_src_buf_size: size of the buffer for source buffers in decoding
* @codec_mode: number of codec mode used by MFC hw
* @slice_interface: slice interface flag
* @loop_filter_mpeg4: loop filter for MPEG4 flag
* @display_delay: value of the display delay for H264
* @display_delay_enable: display delay for H264 enable flag
* @after_packed_pb: flag used to track buffer when stream is in
* Packed PB format
* @sei_fp_parse: enable/disable parsing of frame packing SEI information
* @dpb_count: count of the DPB buffers required by MFC hw
* @total_dpb_count: count of DPB buffers with additional buffers
* requested by the application
* @ctx: context buffer information
* @dsc: descriptor buffer information
* @shm: shared memory buffer information
* @mv_count: number of MV buffers allocated for decoding
* @enc_params: encoding parameters for MFC
* @enc_dst_buf_size: size of the buffers for encoder output
* @luma_dpb_size: dpb buffer size for luma
* @chroma_dpb_size: dpb buffer size for chroma
* @me_buffer_size: size of the motion estimation buffer
* @tmv_buffer_size: size of temporal predictor motion vector buffer
* @frame_type: used to force the type of the next encoded frame
* @ref_queue: list of the reference buffers for encoding
* @ref_queue_cnt: number of the buffers in the reference list
* @c_ops: ops for encoding
* @ctrls: array of controls, used when adding controls to the
* v4l2 control framework
* @ctrl_handler: handler for v4l2 framework
*/
struct s5p_mfc_ctx {
struct s5p_mfc_dev *dev;
struct v4l2_fh fh;
int num;
int int_cond;
int int_type;
unsigned int int_err;
wait_queue_head_t queue;
struct s5p_mfc_fmt *src_fmt;
struct s5p_mfc_fmt *dst_fmt;
struct vb2_queue vq_src;
struct vb2_queue vq_dst;
struct list_head src_queue;
struct list_head dst_queue;
unsigned int src_queue_cnt;
unsigned int dst_queue_cnt;
enum s5p_mfc_inst_type type;
enum s5p_mfc_inst_state state;
int inst_no;
/* Image parameters */
int img_width;
int img_height;
int buf_width;
int buf_height;
int luma_size;
int chroma_size;
int mv_size;
unsigned long consumed_stream;
unsigned int dpb_flush_flag;
unsigned int head_processed;
struct s5p_mfc_priv_buf bank1;
struct s5p_mfc_priv_buf bank2;
enum s5p_mfc_queue_state capture_state;
enum s5p_mfc_queue_state output_state;
struct s5p_mfc_buf src_bufs[MFC_MAX_BUFFERS];
int src_bufs_cnt;
struct s5p_mfc_buf dst_bufs[MFC_MAX_BUFFERS];
int dst_bufs_cnt;
unsigned int sequence;
unsigned long dec_dst_flag;
size_t dec_src_buf_size;
/* Control values */
int codec_mode;
int slice_interface;
int loop_filter_mpeg4;
int display_delay;
int display_delay_enable;
int after_packed_pb;
int sei_fp_parse;
int pb_count;
int total_dpb_count;
int mv_count;
/* Buffers */
struct s5p_mfc_priv_buf ctx;
struct s5p_mfc_priv_buf dsc;
struct s5p_mfc_priv_buf shm;
struct s5p_mfc_enc_params enc_params;
size_t enc_dst_buf_size;
size_t luma_dpb_size;
size_t chroma_dpb_size;
size_t me_buffer_size;
size_t tmv_buffer_size;
enum v4l2_mpeg_mfc51_video_force_frame_type force_frame_type;
struct list_head ref_queue;
unsigned int ref_queue_cnt;
enum v4l2_mpeg_video_multi_slice_mode slice_mode;
union {
unsigned int mb;
unsigned int bits;
} slice_size;
struct s5p_mfc_codec_ops *c_ops;
struct v4l2_ctrl *ctrls[MFC_MAX_CTRLS];
struct v4l2_ctrl_handler ctrl_handler;
unsigned int frame_tag;
size_t scratch_buf_size;
};
/*
* struct s5p_mfc_fmt - structure used to store information about pixelformats
* used by the MFC
*/
struct s5p_mfc_fmt {
char *name;
u32 fourcc;
u32 codec_mode;
enum s5p_mfc_fmt_type type;
u32 num_planes;
u32 versions;
};
/**
* struct mfc_control - structure used to store information about MFC controls
* it is used to initialize the control framework.
*/
struct mfc_control {
__u32 id;
enum v4l2_ctrl_type type;
__u8 name[32]; /* Whatever */
__s32 minimum; /* Note signedness */
__s32 maximum;
__s32 step;
__u32 menu_skip_mask;
__s32 default_value;
__u32 flags;
__u32 reserved[2];
__u8 is_volatile;
};
/* Macro for making hardware specific calls */
#define s5p_mfc_hw_call(f, op, args...) \
((f && f->op) ? f->op(args) : -ENODEV)
#define s5p_mfc_hw_call_void(f, op, args...) \
do { \
if (f && f->op) \
f->op(args); \
} while (0)
#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh)
#define ctrl_to_ctx(__ctrl) \
container_of((__ctrl)->handler, struct s5p_mfc_ctx, ctrl_handler)
void clear_work_bit(struct s5p_mfc_ctx *ctx);
void set_work_bit(struct s5p_mfc_ctx *ctx);
void clear_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
#define HAS_PORTNUM(dev) (dev ? (dev->variant ? \
(dev->variant->port_num ? 1 : 0) : 0) : 0)
#define IS_TWOPORT(dev) (dev->variant->port_num == 2 ? 1 : 0)
#define IS_MFCV6_PLUS(dev) (dev->variant->version >= 0x60 ? 1 : 0)
#define IS_MFCV7_PLUS(dev) (dev->variant->version >= 0x70 ? 1 : 0)
#define IS_MFCV8(dev) (dev->variant->version >= 0x80 ? 1 : 0)
#define MFC_V5_BIT BIT(0)
#define MFC_V6_BIT BIT(1)
#define MFC_V7_BIT BIT(2)
#define MFC_V8_BIT BIT(3)
#endif /* S5P_MFC_COMMON_H_ */

View file

@ -0,0 +1,440 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/firmware.h>
#include <linux/jiffies.h>
#include <linux/sched.h>
#include "s5p_mfc_cmd.h"
#include "s5p_mfc_common.h"
#include "s5p_mfc_debug.h"
#include "s5p_mfc_intr.h"
#include "s5p_mfc_opr.h"
#include "s5p_mfc_pm.h"
#include "s5p_mfc_ctrl.h"
/* Allocate memory for firmware */
int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)
{
void *bank2_virt;
dma_addr_t bank2_dma_addr;
dev->fw_size = dev->variant->buf_size->fw;
if (dev->fw_virt_addr) {
mfc_err("Attempting to allocate firmware when it seems that it is already loaded\n");
return -ENOMEM;
}
dev->fw_virt_addr = dma_alloc_coherent(dev->mem_dev_l, dev->fw_size,
&dev->bank1, GFP_KERNEL);
if (!dev->fw_virt_addr) {
mfc_err("Allocating bitprocessor buffer failed\n");
return -ENOMEM;
}
if (HAS_PORTNUM(dev) && IS_TWOPORT(dev)) {
bank2_virt = dma_alloc_coherent(dev->mem_dev_r, 1 << MFC_BASE_ALIGN_ORDER,
&bank2_dma_addr, GFP_KERNEL);
if (!bank2_virt) {
mfc_err("Allocating bank2 base failed\n");
dma_free_coherent(dev->mem_dev_l, dev->fw_size,
dev->fw_virt_addr, dev->bank1);
dev->fw_virt_addr = NULL;
return -ENOMEM;
}
/* Valid buffers passed to MFC encoder with LAST_FRAME command
* should not have address of bank2 - MFC will treat it as a null frame.
* To avoid such situation we set bank2 address below the pool address.
*/
dev->bank2 = bank2_dma_addr - (1 << MFC_BASE_ALIGN_ORDER);
dma_free_coherent(dev->mem_dev_r, 1 << MFC_BASE_ALIGN_ORDER,
bank2_virt, bank2_dma_addr);
} else {
/* In this case bank2 can point to the same address as bank1.
* Firmware will always occupy the beginning of this area so it is
* impossible having a video frame buffer with zero address. */
dev->bank2 = dev->bank1;
}
return 0;
}
/* Load firmware */
int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev)
{
struct firmware *fw_blob;
int i, err = -EINVAL;
/* Firmare has to be present as a separate file or compiled
* into kernel. */
mfc_debug_enter();
for (i = MFC_FW_MAX_VERSIONS - 1; i >= 0; i--) {
if (!dev->variant->fw_name[i])
continue;
err = request_firmware((const struct firmware **)&fw_blob,
dev->variant->fw_name[i], dev->v4l2_dev.dev);
if (!err) {
dev->fw_ver = (enum s5p_mfc_fw_ver) i;
break;
}
}
if (err != 0) {
mfc_err("Firmware is not present in the /lib/firmware directory nor compiled in kernel\n");
return -EINVAL;
}
if (fw_blob->size > dev->fw_size) {
mfc_err("MFC firmware is too big to be loaded\n");
release_firmware(fw_blob);
return -ENOMEM;
}
if (!dev->fw_virt_addr) {
mfc_err("MFC firmware is not allocated\n");
release_firmware(fw_blob);
return -EINVAL;
}
memcpy(dev->fw_virt_addr, fw_blob->data, fw_blob->size);
wmb();
release_firmware(fw_blob);
mfc_debug_leave();
return 0;
}
/* Release firmware memory */
int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev)
{
/* Before calling this function one has to make sure
* that MFC is no longer processing */
if (!dev->fw_virt_addr)
return -EINVAL;
dma_free_coherent(dev->mem_dev_l, dev->fw_size, dev->fw_virt_addr,
dev->bank1);
dev->fw_virt_addr = NULL;
return 0;
}
/* Reset the device */
int s5p_mfc_reset(struct s5p_mfc_dev *dev)
{
unsigned int mc_status;
unsigned long timeout;
int i;
mfc_debug_enter();
if (IS_MFCV6_PLUS(dev)) {
/* Reset IP */
/* except RISC, reset */
mfc_write(dev, 0xFEE, S5P_FIMV_MFC_RESET_V6);
/* reset release */
mfc_write(dev, 0x0, S5P_FIMV_MFC_RESET_V6);
/* Zero Initialization of MFC registers */
mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6);
mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6);
mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6);
for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++)
mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4));
/* Reset */
mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);
mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6);
mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6);
} else {
/* Stop procedure */
/* reset RISC */
mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET);
/* All reset except for MC */
mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET);
mdelay(10);
timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
/* Check MC status */
do {
if (time_after(jiffies, timeout)) {
mfc_err("Timeout while resetting MFC\n");
return -EIO;
}
mc_status = mfc_read(dev, S5P_FIMV_MC_STATUS);
} while (mc_status & 0x3);
mfc_write(dev, 0x0, S5P_FIMV_SW_RESET);
mfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET);
}
mfc_debug_leave();
return 0;
}
static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev)
{
if (IS_MFCV6_PLUS(dev)) {
mfc_write(dev, dev->bank1, S5P_FIMV_RISC_BASE_ADDRESS_V6);
mfc_debug(2, "Base Address : %pad\n", &dev->bank1);
} else {
mfc_write(dev, dev->bank1, S5P_FIMV_MC_DRAMBASE_ADR_A);
mfc_write(dev, dev->bank2, S5P_FIMV_MC_DRAMBASE_ADR_B);
mfc_debug(2, "Bank1: %pad, Bank2: %pad\n",
&dev->bank1, &dev->bank2);
}
}
static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev)
{
if (IS_MFCV6_PLUS(dev)) {
/* Zero initialization should be done before RESET.
* Nothing to do here. */
} else {
mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH0_INST_ID);
mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH1_INST_ID);
mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD);
mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD);
}
}
/* Initialize hardware */
int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
{
unsigned int ver;
int ret;
mfc_debug_enter();
if (!dev->fw_virt_addr) {
mfc_err("Firmware memory is not allocated.\n");
return -EINVAL;
}
/* 0. MFC reset */
mfc_debug(2, "MFC reset..\n");
s5p_mfc_clock_on();
ret = s5p_mfc_reset(dev);
if (ret) {
mfc_err("Failed to reset MFC - timeout\n");
return ret;
}
mfc_debug(2, "Done MFC reset..\n");
/* 1. Set DRAM base Addr */
s5p_mfc_init_memctrl(dev);
/* 2. Initialize registers of channel I/F */
s5p_mfc_clear_cmds(dev);
/* 3. Release reset signal to the RISC */
s5p_mfc_clean_dev_int_flags(dev);
if (IS_MFCV6_PLUS(dev))
mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
mfc_debug(2, "Will now wait for completion of firmware transfer\n");
if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) {
mfc_err("Failed to load firmware\n");
s5p_mfc_reset(dev);
s5p_mfc_clock_off();
return -EIO;
}
s5p_mfc_clean_dev_int_flags(dev);
/* 4. Initialize firmware */
ret = s5p_mfc_hw_call(dev->mfc_cmds, sys_init_cmd, dev);
if (ret) {
mfc_err("Failed to send command to MFC - timeout\n");
s5p_mfc_reset(dev);
s5p_mfc_clock_off();
return ret;
}
mfc_debug(2, "Ok, now will wait for completion of hardware init\n");
if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SYS_INIT_RET)) {
mfc_err("Failed to init hardware\n");
s5p_mfc_reset(dev);
s5p_mfc_clock_off();
return -EIO;
}
dev->int_cond = 0;
if (dev->int_err != 0 || dev->int_type !=
S5P_MFC_R2H_CMD_SYS_INIT_RET) {
/* Failure. */
mfc_err("Failed to init firmware - error: %d int: %d\n",
dev->int_err, dev->int_type);
s5p_mfc_reset(dev);
s5p_mfc_clock_off();
return -EIO;
}
if (IS_MFCV6_PLUS(dev))
ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
else
ver = mfc_read(dev, S5P_FIMV_FW_VERSION);
mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n",
(ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
s5p_mfc_clock_off();
mfc_debug_leave();
return 0;
}
/* Deinitialize hardware */
void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev)
{
s5p_mfc_clock_on();
s5p_mfc_reset(dev);
s5p_mfc_hw_call_void(dev->mfc_ops, release_dev_context_buffer, dev);
s5p_mfc_clock_off();
}
int s5p_mfc_sleep(struct s5p_mfc_dev *dev)
{
int ret;
mfc_debug_enter();
s5p_mfc_clock_on();
s5p_mfc_clean_dev_int_flags(dev);
ret = s5p_mfc_hw_call(dev->mfc_cmds, sleep_cmd, dev);
if (ret) {
mfc_err("Failed to send command to MFC - timeout\n");
return ret;
}
if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SLEEP_RET)) {
mfc_err("Failed to sleep\n");
return -EIO;
}
s5p_mfc_clock_off();
dev->int_cond = 0;
if (dev->int_err != 0 || dev->int_type !=
S5P_MFC_R2H_CMD_SLEEP_RET) {
/* Failure. */
mfc_err("Failed to sleep - error: %d int: %d\n", dev->int_err,
dev->int_type);
return -EIO;
}
mfc_debug_leave();
return ret;
}
int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
{
int ret;
mfc_debug_enter();
/* 0. MFC reset */
mfc_debug(2, "MFC reset..\n");
s5p_mfc_clock_on();
ret = s5p_mfc_reset(dev);
if (ret) {
mfc_err("Failed to reset MFC - timeout\n");
return ret;
}
mfc_debug(2, "Done MFC reset..\n");
/* 1. Set DRAM base Addr */
s5p_mfc_init_memctrl(dev);
/* 2. Initialize registers of channel I/F */
s5p_mfc_clear_cmds(dev);
s5p_mfc_clean_dev_int_flags(dev);
/* 3. Initialize firmware */
ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev);
if (ret) {
mfc_err("Failed to send command to MFC - timeout\n");
return ret;
}
/* 4. Release reset signal to the RISC */
if (IS_MFCV6_PLUS(dev))
mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
mfc_debug(2, "Ok, now will write a command to wakeup the system\n");
if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) {
mfc_err("Failed to load firmware\n");
return -EIO;
}
s5p_mfc_clock_off();
dev->int_cond = 0;
if (dev->int_err != 0 || dev->int_type !=
S5P_MFC_R2H_CMD_WAKEUP_RET) {
/* Failure. */
mfc_err("Failed to wakeup - error: %d int: %d\n", dev->int_err,
dev->int_type);
return -EIO;
}
mfc_debug_leave();
return 0;
}
int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx)
{
int ret = 0;
ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_instance_buffer, ctx);
if (ret) {
mfc_err("Failed allocating instance buffer\n");
goto err;
}
if (ctx->type == MFCINST_DECODER) {
ret = s5p_mfc_hw_call(dev->mfc_ops,
alloc_dec_temp_buffers, ctx);
if (ret) {
mfc_err("Failed allocating temporary buffers\n");
goto err_free_inst_buf;
}
}
set_work_bit_irqsave(ctx);
s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
if (s5p_mfc_wait_for_done_ctx(ctx,
S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET, 0)) {
/* Error or timeout */
mfc_err("Error getting instance from hardware\n");
ret = -EIO;
goto err_free_desc_buf;
}
mfc_debug(2, "Got instance number: %d\n", ctx->inst_no);
return ret;
err_free_desc_buf:
if (ctx->type == MFCINST_DECODER)
s5p_mfc_hw_call_void(dev->mfc_ops, release_dec_desc_buffer, ctx);
err_free_inst_buf:
s5p_mfc_hw_call_void(dev->mfc_ops, release_instance_buffer, ctx);
err:
return ret;
}
void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx)
{
ctx->state = MFCINST_RETURN_INST;
set_work_bit_irqsave(ctx);
s5p_mfc_clean_ctx_int_flags(ctx);
s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
/* Wait until instance is returned or timeout occurred */
if (s5p_mfc_wait_for_done_ctx(ctx,
S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0))
mfc_err("Err returning instance\n");
/* Free resources */
s5p_mfc_hw_call_void(dev->mfc_ops, release_codec_buffers, ctx);
s5p_mfc_hw_call_void(dev->mfc_ops, release_instance_buffer, ctx);
if (ctx->type == MFCINST_DECODER)
s5p_mfc_hw_call_void(dev->mfc_ops, release_dec_desc_buffer, ctx);
ctx->inst_no = MFC_NO_INSTANCE_SET;
ctx->state = MFCINST_FREE;
}

View file

@ -0,0 +1,34 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.h
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef S5P_MFC_CTRL_H
#define S5P_MFC_CTRL_H
#include "s5p_mfc_common.h"
int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev);
int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev);
int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev);
int s5p_mfc_reload_firmware(struct s5p_mfc_dev *dev);
int s5p_mfc_init_hw(struct s5p_mfc_dev *dev);
void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev);
int s5p_mfc_sleep(struct s5p_mfc_dev *dev);
int s5p_mfc_wakeup(struct s5p_mfc_dev *dev);
int s5p_mfc_reset(struct s5p_mfc_dev *dev);
int s5p_mfc_open_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx);
void s5p_mfc_close_mfc_inst(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx);
#endif /* S5P_MFC_CTRL_H */

View file

@ -0,0 +1,48 @@
/*
* drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
*
* Header file for Samsung MFC (Multi Function Codec - FIMV) driver
* This file contains debug macros
*
* 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.
*/
#ifndef S5P_MFC_DEBUG_H_
#define S5P_MFC_DEBUG_H_
#define DEBUG
#ifdef DEBUG
extern int mfc_debug_level;
#define mfc_debug(level, fmt, args...) \
do { \
if (mfc_debug_level >= level) \
printk(KERN_DEBUG "%s:%d: " fmt, \
__func__, __LINE__, ##args); \
} while (0)
#else
#define mfc_debug(level, fmt, args...)
#endif
#define mfc_debug_enter() mfc_debug(5, "enter\n")
#define mfc_debug_leave() mfc_debug(5, "leave\n")
#define mfc_err(fmt, args...) \
do { \
printk(KERN_ERR "%s:%d: " fmt, \
__func__, __LINE__, ##args); \
} while (0)
#define mfc_info(fmt, args...) \
do { \
printk(KERN_INFO "%s:%d: " fmt, \
__func__, __LINE__, ##args); \
} while (0)
#endif /* S5P_MFC_DEBUG_H_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,24 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_dec.h
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef S5P_MFC_DEC_H_
#define S5P_MFC_DEC_H_
struct s5p_mfc_codec_ops *get_dec_codec_ops(void);
struct vb2_ops *get_dec_queue_ops(void);
const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void);
struct s5p_mfc_fmt *get_dec_def_fmt(bool src);
int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx);
void s5p_mfc_dec_ctrls_delete(struct s5p_mfc_ctx *ctx);
void s5p_mfc_dec_init(struct s5p_mfc_ctx *ctx);
#endif /* S5P_MFC_DEC_H_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,24 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_enc.h
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef S5P_MFC_ENC_H_
#define S5P_MFC_ENC_H_
struct s5p_mfc_codec_ops *get_enc_codec_ops(void);
struct vb2_ops *get_enc_queue_ops(void);
const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void);
struct s5p_mfc_fmt *get_enc_def_fmt(bool src);
int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx);
void s5p_mfc_enc_ctrls_delete(struct s5p_mfc_ctx *ctx);
void s5p_mfc_enc_init(struct s5p_mfc_ctx *ctx);
#endif /* S5P_MFC_ENC_H_ */

View file

@ -0,0 +1,91 @@
/*
* drivers/media/platform/samsung/mfc5/s5p_mfc_intr.c
*
* C file for Samsung MFC (Multi Function Codec - FIMV) driver
* This file contains functions used to wait for command completion.
*
* Kamil Debski, Copyright (C) 2011 Samsung Electronics Co., Ltd.
* 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 <linux/delay.h>
#include <linux/errno.h>
#include <linux/io.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include "s5p_mfc_common.h"
#include "s5p_mfc_debug.h"
#include "s5p_mfc_intr.h"
int s5p_mfc_wait_for_done_dev(struct s5p_mfc_dev *dev, int command)
{
int ret;
ret = wait_event_interruptible_timeout(dev->queue,
(dev->int_cond && (dev->int_type == command
|| dev->int_type == S5P_MFC_R2H_CMD_ERR_RET)),
msecs_to_jiffies(MFC_INT_TIMEOUT));
if (ret == 0) {
mfc_err("Interrupt (dev->int_type:%d, command:%d) timed out\n",
dev->int_type, command);
return 1;
} else if (ret == -ERESTARTSYS) {
mfc_err("Interrupted by a signal\n");
return 1;
}
mfc_debug(1, "Finished waiting (dev->int_type:%d, command: %d)\n",
dev->int_type, command);
if (dev->int_type == S5P_MFC_R2H_CMD_ERR_RET)
return 1;
return 0;
}
void s5p_mfc_clean_dev_int_flags(struct s5p_mfc_dev *dev)
{
dev->int_cond = 0;
dev->int_type = 0;
dev->int_err = 0;
}
int s5p_mfc_wait_for_done_ctx(struct s5p_mfc_ctx *ctx,
int command, int interrupt)
{
int ret;
if (interrupt) {
ret = wait_event_interruptible_timeout(ctx->queue,
(ctx->int_cond && (ctx->int_type == command
|| ctx->int_type == S5P_MFC_R2H_CMD_ERR_RET)),
msecs_to_jiffies(MFC_INT_TIMEOUT));
} else {
ret = wait_event_timeout(ctx->queue,
(ctx->int_cond && (ctx->int_type == command
|| ctx->int_type == S5P_MFC_R2H_CMD_ERR_RET)),
msecs_to_jiffies(MFC_INT_TIMEOUT));
}
if (ret == 0) {
mfc_err("Interrupt (ctx->int_type:%d, command:%d) timed out\n",
ctx->int_type, command);
return 1;
} else if (ret == -ERESTARTSYS) {
mfc_err("Interrupted by a signal\n");
return 1;
}
mfc_debug(1, "Finished waiting (ctx->int_type:%d, command: %d)\n",
ctx->int_type, command);
if (ctx->int_type == S5P_MFC_R2H_CMD_ERR_RET)
return 1;
return 0;
}
void s5p_mfc_clean_ctx_int_flags(struct s5p_mfc_ctx *ctx)
{
ctx->int_cond = 0;
ctx->int_type = 0;
ctx->int_err = 0;
}

View file

@ -0,0 +1,26 @@
/*
* drivers/media/platform/samsung/mfc5/s5p_mfc_intr.h
*
* Header file for Samsung MFC (Multi Function Codec - FIMV) driver
* It contains waiting functions declarations.
*
* 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.
*/
#ifndef S5P_MFC_INTR_H_
#define S5P_MFC_INTR_H_
#include "s5p_mfc_common.h"
int s5p_mfc_wait_for_done_ctx(struct s5p_mfc_ctx *ctx,
int command, int interrupt);
int s5p_mfc_wait_for_done_dev(struct s5p_mfc_dev *dev, int command);
void s5p_mfc_clean_ctx_int_flags(struct s5p_mfc_ctx *ctx);
void s5p_mfc_clean_dev_int_flags(struct s5p_mfc_dev *dev);
#endif /* S5P_MFC_INTR_H_ */

View file

@ -0,0 +1,67 @@
/*
* drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
*
* Samsung MFC (Multi Function Codec - FIMV) driver
* This file contains hw related functions.
*
* Kamil Debski, Copyright (c) 2012 Samsung Electronics Co., Ltd.
* 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_debug.h"
#include "s5p_mfc_opr.h"
#include "s5p_mfc_opr_v5.h"
#include "s5p_mfc_opr_v6.h"
static struct s5p_mfc_hw_ops *s5p_mfc_ops;
void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev)
{
if (IS_MFCV6_PLUS(dev)) {
s5p_mfc_ops = s5p_mfc_init_hw_ops_v6();
dev->warn_start = S5P_FIMV_ERR_WARNINGS_START_V6;
} else {
s5p_mfc_ops = s5p_mfc_init_hw_ops_v5();
dev->warn_start = S5P_FIMV_ERR_WARNINGS_START;
}
dev->mfc_ops = s5p_mfc_ops;
}
void s5p_mfc_init_regs(struct s5p_mfc_dev *dev)
{
if (IS_MFCV6_PLUS(dev))
dev->mfc_regs = s5p_mfc_init_regs_v6_plus(dev);
}
int s5p_mfc_alloc_priv_buf(struct device *dev,
struct s5p_mfc_priv_buf *b)
{
mfc_debug(3, "Allocating priv: %zu\n", b->size);
b->virt = dma_alloc_coherent(dev, b->size, &b->dma, GFP_KERNEL);
if (!b->virt) {
mfc_err("Allocating private buffer failed\n");
return -ENOMEM;
}
mfc_debug(3, "Allocated addr %p %pad\n", b->virt, &b->dma);
return 0;
}
void s5p_mfc_release_priv_buf(struct device *dev,
struct s5p_mfc_priv_buf *b)
{
if (b->virt) {
dma_free_coherent(dev, b->size, b->virt, b->dma);
b->virt = NULL;
b->dma = 0;
b->size = 0;
}
}

View file

@ -0,0 +1,343 @@
/*
* drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
*
* Header file for Samsung MFC (Multi Function Codec - FIMV) driver
* Contains declarations of hw related functions.
*
* Kamil Debski, Copyright (C) 2012 Samsung Electronics Co., Ltd.
* 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.
*/
#ifndef S5P_MFC_OPR_H_
#define S5P_MFC_OPR_H_
#include "s5p_mfc_common.h"
struct s5p_mfc_regs {
/* codec common registers */
volatile void __iomem *risc_on;
volatile void __iomem *risc2host_int;
volatile void __iomem *host2risc_int;
volatile void __iomem *risc_base_address;
volatile void __iomem *mfc_reset;
volatile void __iomem *host2risc_command;
volatile void __iomem *risc2host_command;
volatile void __iomem *mfc_bus_reset_ctrl;
volatile void __iomem *firmware_version;
volatile void __iomem *instance_id;
volatile void __iomem *codec_type;
volatile void __iomem *context_mem_addr;
volatile void __iomem *context_mem_size;
volatile void __iomem *pixel_format;
volatile void __iomem *metadata_enable;
volatile void __iomem *mfc_version;
volatile void __iomem *dbg_info_enable;
volatile void __iomem *dbg_buffer_addr;
volatile void __iomem *dbg_buffer_size;
volatile void __iomem *hed_control;
volatile void __iomem *mfc_timeout_value;
volatile void __iomem *hed_shared_mem_addr;
volatile void __iomem *dis_shared_mem_addr;/* only v7 */
volatile void __iomem *ret_instance_id;
volatile void __iomem *error_code;
volatile void __iomem *dbg_buffer_output_size;
volatile void __iomem *metadata_status;
volatile void __iomem *metadata_addr_mb_info;
volatile void __iomem *metadata_size_mb_info;
volatile void __iomem *dbg_info_stage_counter;
/* decoder registers */
volatile void __iomem *d_crc_ctrl;
volatile void __iomem *d_dec_options;
volatile void __iomem *d_display_delay;
volatile void __iomem *d_set_frame_width;
volatile void __iomem *d_set_frame_height;
volatile void __iomem *d_sei_enable;
volatile void __iomem *d_min_num_dpb;
volatile void __iomem *d_min_first_plane_dpb_size;
volatile void __iomem *d_min_second_plane_dpb_size;
volatile void __iomem *d_min_third_plane_dpb_size;/* only v8 */
volatile void __iomem *d_min_num_mv;
volatile void __iomem *d_mvc_num_views;
volatile void __iomem *d_min_num_dis;/* only v7 */
volatile void __iomem *d_min_first_dis_size;/* only v7 */
volatile void __iomem *d_min_second_dis_size;/* only v7 */
volatile void __iomem *d_min_third_dis_size;/* only v7 */
volatile void __iomem *d_post_filter_luma_dpb0;/* v7 and v8 */
volatile void __iomem *d_post_filter_luma_dpb1;/* v7 and v8 */
volatile void __iomem *d_post_filter_luma_dpb2;/* only v7 */
volatile void __iomem *d_post_filter_chroma_dpb0;/* v7 and v8 */
volatile void __iomem *d_post_filter_chroma_dpb1;/* v7 and v8 */
volatile void __iomem *d_post_filter_chroma_dpb2;/* only v7 */
volatile void __iomem *d_num_dpb;
volatile void __iomem *d_num_mv;
volatile void __iomem *d_init_buffer_options;
volatile void __iomem *d_first_plane_dpb_stride_size;/* only v8 */
volatile void __iomem *d_second_plane_dpb_stride_size;/* only v8 */
volatile void __iomem *d_third_plane_dpb_stride_size;/* only v8 */
volatile void __iomem *d_first_plane_dpb_size;
volatile void __iomem *d_second_plane_dpb_size;
volatile void __iomem *d_third_plane_dpb_size;/* only v8 */
volatile void __iomem *d_mv_buffer_size;
volatile void __iomem *d_first_plane_dpb;
volatile void __iomem *d_second_plane_dpb;
volatile void __iomem *d_third_plane_dpb;
volatile void __iomem *d_mv_buffer;
volatile void __iomem *d_scratch_buffer_addr;
volatile void __iomem *d_scratch_buffer_size;
volatile void __iomem *d_metadata_buffer_addr;
volatile void __iomem *d_metadata_buffer_size;
volatile void __iomem *d_nal_start_options;/* v7 and v8 */
volatile void __iomem *d_cpb_buffer_addr;
volatile void __iomem *d_cpb_buffer_size;
volatile void __iomem *d_available_dpb_flag_upper;
volatile void __iomem *d_available_dpb_flag_lower;
volatile void __iomem *d_cpb_buffer_offset;
volatile void __iomem *d_slice_if_enable;
volatile void __iomem *d_picture_tag;
volatile void __iomem *d_stream_data_size;
volatile void __iomem *d_dynamic_dpb_flag_upper;/* v7 and v8 */
volatile void __iomem *d_dynamic_dpb_flag_lower;/* v7 and v8 */
volatile void __iomem *d_display_frame_width;
volatile void __iomem *d_display_frame_height;
volatile void __iomem *d_display_status;
volatile void __iomem *d_display_first_plane_addr;
volatile void __iomem *d_display_second_plane_addr;
volatile void __iomem *d_display_third_plane_addr;/* only v8 */
volatile void __iomem *d_display_frame_type;
volatile void __iomem *d_display_crop_info1;
volatile void __iomem *d_display_crop_info2;
volatile void __iomem *d_display_picture_profile;
volatile void __iomem *d_display_luma_crc;/* v7 and v8 */
volatile void __iomem *d_display_chroma0_crc;/* v7 and v8 */
volatile void __iomem *d_display_chroma1_crc;/* only v8 */
volatile void __iomem *d_display_luma_crc_top;/* only v6 */
volatile void __iomem *d_display_chroma_crc_top;/* only v6 */
volatile void __iomem *d_display_luma_crc_bot;/* only v6 */
volatile void __iomem *d_display_chroma_crc_bot;/* only v6 */
volatile void __iomem *d_display_aspect_ratio;
volatile void __iomem *d_display_extended_ar;
volatile void __iomem *d_decoded_frame_width;
volatile void __iomem *d_decoded_frame_height;
volatile void __iomem *d_decoded_status;
volatile void __iomem *d_decoded_first_plane_addr;
volatile void __iomem *d_decoded_second_plane_addr;
volatile void __iomem *d_decoded_third_plane_addr;/* only v8 */
volatile void __iomem *d_decoded_frame_type;
volatile void __iomem *d_decoded_crop_info1;
volatile void __iomem *d_decoded_crop_info2;
volatile void __iomem *d_decoded_picture_profile;
volatile void __iomem *d_decoded_nal_size;
volatile void __iomem *d_decoded_luma_crc;
volatile void __iomem *d_decoded_chroma0_crc;
volatile void __iomem *d_decoded_chroma1_crc;/* only v8 */
volatile void __iomem *d_ret_picture_tag_top;
volatile void __iomem *d_ret_picture_tag_bot;
volatile void __iomem *d_ret_picture_time_top;
volatile void __iomem *d_ret_picture_time_bot;
volatile void __iomem *d_chroma_format;
volatile void __iomem *d_vc1_info;/* v7 and v8 */
volatile void __iomem *d_mpeg4_info;
volatile void __iomem *d_h264_info;
volatile void __iomem *d_metadata_addr_concealed_mb;
volatile void __iomem *d_metadata_size_concealed_mb;
volatile void __iomem *d_metadata_addr_vc1_param;
volatile void __iomem *d_metadata_size_vc1_param;
volatile void __iomem *d_metadata_addr_sei_nal;
volatile void __iomem *d_metadata_size_sei_nal;
volatile void __iomem *d_metadata_addr_vui;
volatile void __iomem *d_metadata_size_vui;
volatile void __iomem *d_metadata_addr_mvcvui;/* v7 and v8 */
volatile void __iomem *d_metadata_size_mvcvui;/* v7 and v8 */
volatile void __iomem *d_mvc_view_id;
volatile void __iomem *d_frame_pack_sei_avail;
volatile void __iomem *d_frame_pack_arrgment_id;
volatile void __iomem *d_frame_pack_sei_info;
volatile void __iomem *d_frame_pack_grid_pos;
volatile void __iomem *d_display_recovery_sei_info;/* v7 and v8 */
volatile void __iomem *d_decoded_recovery_sei_info;/* v7 and v8 */
volatile void __iomem *d_display_first_addr;/* only v7 */
volatile void __iomem *d_display_second_addr;/* only v7 */
volatile void __iomem *d_display_third_addr;/* only v7 */
volatile void __iomem *d_decoded_first_addr;/* only v7 */
volatile void __iomem *d_decoded_second_addr;/* only v7 */
volatile void __iomem *d_decoded_third_addr;/* only v7 */
volatile void __iomem *d_used_dpb_flag_upper;/* v7 and v8 */
volatile void __iomem *d_used_dpb_flag_lower;/* v7 and v8 */
/* encoder registers */
volatile void __iomem *e_frame_width;
volatile void __iomem *e_frame_height;
volatile void __iomem *e_cropped_frame_width;
volatile void __iomem *e_cropped_frame_height;
volatile void __iomem *e_frame_crop_offset;
volatile void __iomem *e_enc_options;
volatile void __iomem *e_picture_profile;
volatile void __iomem *e_vbv_buffer_size;
volatile void __iomem *e_vbv_init_delay;
volatile void __iomem *e_fixed_picture_qp;
volatile void __iomem *e_rc_config;
volatile void __iomem *e_rc_qp_bound;
volatile void __iomem *e_rc_qp_bound_pb;/* v7 and v8 */
volatile void __iomem *e_rc_mode;
volatile void __iomem *e_mb_rc_config;
volatile void __iomem *e_padding_ctrl;
volatile void __iomem *e_air_threshold;
volatile void __iomem *e_mv_hor_range;
volatile void __iomem *e_mv_ver_range;
volatile void __iomem *e_num_dpb;
volatile void __iomem *e_luma_dpb;
volatile void __iomem *e_chroma_dpb;
volatile void __iomem *e_me_buffer;
volatile void __iomem *e_scratch_buffer_addr;
volatile void __iomem *e_scratch_buffer_size;
volatile void __iomem *e_tmv_buffer0;
volatile void __iomem *e_tmv_buffer1;
volatile void __iomem *e_ir_buffer_addr;/* v7 and v8 */
volatile void __iomem *e_source_first_plane_addr;
volatile void __iomem *e_source_second_plane_addr;
volatile void __iomem *e_source_third_plane_addr;/* v7 and v8 */
volatile void __iomem *e_source_first_plane_stride;/* v7 and v8 */
volatile void __iomem *e_source_second_plane_stride;/* v7 and v8 */
volatile void __iomem *e_source_third_plane_stride;/* v7 and v8 */
volatile void __iomem *e_stream_buffer_addr;
volatile void __iomem *e_stream_buffer_size;
volatile void __iomem *e_roi_buffer_addr;
volatile void __iomem *e_param_change;
volatile void __iomem *e_ir_size;
volatile void __iomem *e_gop_config;
volatile void __iomem *e_mslice_mode;
volatile void __iomem *e_mslice_size_mb;
volatile void __iomem *e_mslice_size_bits;
volatile void __iomem *e_frame_insertion;
volatile void __iomem *e_rc_frame_rate;
volatile void __iomem *e_rc_bit_rate;
volatile void __iomem *e_rc_roi_ctrl;
volatile void __iomem *e_picture_tag;
volatile void __iomem *e_bit_count_enable;
volatile void __iomem *e_max_bit_count;
volatile void __iomem *e_min_bit_count;
volatile void __iomem *e_metadata_buffer_addr;
volatile void __iomem *e_metadata_buffer_size;
volatile void __iomem *e_encoded_source_first_plane_addr;
volatile void __iomem *e_encoded_source_second_plane_addr;
volatile void __iomem *e_encoded_source_third_plane_addr;/* v7 and v8 */
volatile void __iomem *e_stream_size;
volatile void __iomem *e_slice_type;
volatile void __iomem *e_picture_count;
volatile void __iomem *e_ret_picture_tag;
volatile void __iomem *e_stream_buffer_write_pointer; /* only v6 */
volatile void __iomem *e_recon_luma_dpb_addr;
volatile void __iomem *e_recon_chroma_dpb_addr;
volatile void __iomem *e_metadata_addr_enc_slice;
volatile void __iomem *e_metadata_size_enc_slice;
volatile void __iomem *e_mpeg4_options;
volatile void __iomem *e_mpeg4_hec_period;
volatile void __iomem *e_aspect_ratio;
volatile void __iomem *e_extended_sar;
volatile void __iomem *e_h264_options;
volatile void __iomem *e_h264_options_2;/* v7 and v8 */
volatile void __iomem *e_h264_lf_alpha_offset;
volatile void __iomem *e_h264_lf_beta_offset;
volatile void __iomem *e_h264_i_period;
volatile void __iomem *e_h264_fmo_slice_grp_map_type;
volatile void __iomem *e_h264_fmo_num_slice_grp_minus1;
volatile void __iomem *e_h264_fmo_slice_grp_change_dir;
volatile void __iomem *e_h264_fmo_slice_grp_change_rate_minus1;
volatile void __iomem *e_h264_fmo_run_length_minus1_0;
volatile void __iomem *e_h264_aso_slice_order_0;
volatile void __iomem *e_h264_chroma_qp_offset;
volatile void __iomem *e_h264_num_t_layer;
volatile void __iomem *e_h264_hierarchical_qp_layer0;
volatile void __iomem *e_h264_frame_packing_sei_info;
volatile void __iomem *e_h264_nal_control;/* v7 and v8 */
volatile void __iomem *e_mvc_frame_qp_view1;
volatile void __iomem *e_mvc_rc_bit_rate_view1;
volatile void __iomem *e_mvc_rc_qbound_view1;
volatile void __iomem *e_mvc_rc_mode_view1;
volatile void __iomem *e_mvc_inter_view_prediction_on;
volatile void __iomem *e_vp8_options;/* v7 and v8 */
volatile void __iomem *e_vp8_filter_options;/* v7 and v8 */
volatile void __iomem *e_vp8_golden_frame_option;/* v7 and v8 */
volatile void __iomem *e_vp8_num_t_layer;/* v7 and v8 */
volatile void __iomem *e_vp8_hierarchical_qp_layer0;/* v7 and v8 */
volatile void __iomem *e_vp8_hierarchical_qp_layer1;/* v7 and v8 */
volatile void __iomem *e_vp8_hierarchical_qp_layer2;/* v7 and v8 */
};
struct s5p_mfc_hw_ops {
int (*alloc_dec_temp_buffers)(struct s5p_mfc_ctx *ctx);
void (*release_dec_desc_buffer)(struct s5p_mfc_ctx *ctx);
int (*alloc_codec_buffers)(struct s5p_mfc_ctx *ctx);
void (*release_codec_buffers)(struct s5p_mfc_ctx *ctx);
int (*alloc_instance_buffer)(struct s5p_mfc_ctx *ctx);
void (*release_instance_buffer)(struct s5p_mfc_ctx *ctx);
int (*alloc_dev_context_buffer)(struct s5p_mfc_dev *dev);
void (*release_dev_context_buffer)(struct s5p_mfc_dev *dev);
void (*dec_calc_dpb_size)(struct s5p_mfc_ctx *ctx);
void (*enc_calc_src_size)(struct s5p_mfc_ctx *ctx);
int (*set_dec_stream_buffer)(struct s5p_mfc_ctx *ctx,
int buf_addr, unsigned int start_num_byte,
unsigned int buf_size);
int (*set_dec_frame_buffer)(struct s5p_mfc_ctx *ctx);
int (*set_enc_stream_buffer)(struct s5p_mfc_ctx *ctx,
unsigned long addr, unsigned int size);
void (*set_enc_frame_buffer)(struct s5p_mfc_ctx *ctx,
unsigned long y_addr, unsigned long c_addr);
void (*get_enc_frame_buffer)(struct s5p_mfc_ctx *ctx,
unsigned long *y_addr, unsigned long *c_addr);
int (*set_enc_ref_buffer)(struct s5p_mfc_ctx *ctx);
int (*init_decode)(struct s5p_mfc_ctx *ctx);
int (*init_encode)(struct s5p_mfc_ctx *ctx);
int (*encode_one_frame)(struct s5p_mfc_ctx *ctx);
void (*try_run)(struct s5p_mfc_dev *dev);
void (*cleanup_queue)(struct list_head *lh,
struct vb2_queue *vq);
void (*clear_int_flags)(struct s5p_mfc_dev *dev);
void (*write_info)(struct s5p_mfc_ctx *ctx, unsigned int data,
unsigned int ofs);
unsigned int (*read_info)(struct s5p_mfc_ctx *ctx,
unsigned int ofs);
int (*get_dspl_y_adr)(struct s5p_mfc_dev *dev);
int (*get_dec_y_adr)(struct s5p_mfc_dev *dev);
int (*get_dspl_status)(struct s5p_mfc_dev *dev);
int (*get_dec_status)(struct s5p_mfc_dev *dev);
int (*get_dec_frame_type)(struct s5p_mfc_dev *dev);
int (*get_disp_frame_type)(struct s5p_mfc_ctx *ctx);
int (*get_consumed_stream)(struct s5p_mfc_dev *dev);
int (*get_int_reason)(struct s5p_mfc_dev *dev);
int (*get_int_err)(struct s5p_mfc_dev *dev);
int (*err_dec)(unsigned int err);
int (*err_dspl)(unsigned int err);
int (*get_img_width)(struct s5p_mfc_dev *dev);
int (*get_img_height)(struct s5p_mfc_dev *dev);
int (*get_dpb_count)(struct s5p_mfc_dev *dev);
int (*get_mv_count)(struct s5p_mfc_dev *dev);
int (*get_inst_no)(struct s5p_mfc_dev *dev);
int (*get_enc_strm_size)(struct s5p_mfc_dev *dev);
int (*get_enc_slice_type)(struct s5p_mfc_dev *dev);
int (*get_enc_dpb_count)(struct s5p_mfc_dev *dev);
int (*get_enc_pic_count)(struct s5p_mfc_dev *dev);
int (*get_sei_avail_status)(struct s5p_mfc_ctx *ctx);
int (*get_mvc_num_views)(struct s5p_mfc_dev *dev);
int (*get_mvc_view_id)(struct s5p_mfc_dev *dev);
unsigned int (*get_pic_type_top)(struct s5p_mfc_ctx *ctx);
unsigned int (*get_pic_type_bot)(struct s5p_mfc_ctx *ctx);
unsigned int (*get_crop_info_h)(struct s5p_mfc_ctx *ctx);
unsigned int (*get_crop_info_v)(struct s5p_mfc_ctx *ctx);
};
void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev);
void s5p_mfc_init_regs(struct s5p_mfc_dev *dev);
int s5p_mfc_alloc_priv_buf(struct device *dev,
struct s5p_mfc_priv_buf *b);
void s5p_mfc_release_priv_buf(struct device *dev,
struct s5p_mfc_priv_buf *b);
#endif /* S5P_MFC_OPR_H_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,85 @@
/*
* drivers/media/platform/samsung/mfc5/s5p_mfc_opr_v5.h
*
* Header file for Samsung MFC (Multi Function Codec - FIMV) driver
* Contains declarations of 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.
*/
#ifndef S5P_MFC_OPR_V5_H_
#define S5P_MFC_OPR_V5_H_
#include "s5p_mfc_common.h"
#include "s5p_mfc_opr.h"
enum MFC_SHM_OFS {
EXTENEDED_DECODE_STATUS = 0x00, /* D */
SET_FRAME_TAG = 0x04, /* D */
GET_FRAME_TAG_TOP = 0x08, /* D */
GET_FRAME_TAG_BOT = 0x0C, /* D */
PIC_TIME_TOP = 0x10, /* D */
PIC_TIME_BOT = 0x14, /* D */
START_BYTE_NUM = 0x18, /* D */
CROP_INFO_H = 0x20, /* D */
CROP_INFO_V = 0x24, /* D */
EXT_ENC_CONTROL = 0x28, /* E */
ENC_PARAM_CHANGE = 0x2C, /* E */
RC_VOP_TIMING = 0x30, /* E, MPEG4 */
HEC_PERIOD = 0x34, /* E, MPEG4 */
METADATA_ENABLE = 0x38, /* C */
METADATA_STATUS = 0x3C, /* C */
METADATA_DISPLAY_INDEX = 0x40, /* C */
EXT_METADATA_START_ADDR = 0x44, /* C */
PUT_EXTRADATA = 0x48, /* C */
EXTRADATA_ADDR = 0x4C, /* C */
ALLOC_LUMA_DPB_SIZE = 0x64, /* D */
ALLOC_CHROMA_DPB_SIZE = 0x68, /* D */
ALLOC_MV_SIZE = 0x6C, /* D */
P_B_FRAME_QP = 0x70, /* E */
SAMPLE_ASPECT_RATIO_IDC = 0x74, /* E, H.264, depend on
ASPECT_RATIO_VUI_ENABLE in EXT_ENC_CONTROL */
EXTENDED_SAR = 0x78, /* E, H.264, depned on
ASPECT_RATIO_VUI_ENABLE in EXT_ENC_CONTROL */
DISP_PIC_PROFILE = 0x7C, /* D */
FLUSH_CMD_TYPE = 0x80, /* C */
FLUSH_CMD_INBUF1 = 0x84, /* C */
FLUSH_CMD_INBUF2 = 0x88, /* C */
FLUSH_CMD_OUTBUF = 0x8C, /* E */
NEW_RC_BIT_RATE = 0x90, /* E, format as RC_BIT_RATE(0xC5A8)
depend on RC_BIT_RATE_CHANGE in ENC_PARAM_CHANGE */
NEW_RC_FRAME_RATE = 0x94, /* E, format as RC_FRAME_RATE(0xD0D0)
depend on RC_FRAME_RATE_CHANGE in ENC_PARAM_CHANGE */
NEW_I_PERIOD = 0x98, /* E, format as I_FRM_CTRL(0xC504)
depend on I_PERIOD_CHANGE in ENC_PARAM_CHANGE */
H264_I_PERIOD = 0x9C, /* E, H.264, open GOP */
RC_CONTROL_CONFIG = 0xA0, /* E */
BATCH_INPUT_ADDR = 0xA4, /* E */
BATCH_OUTPUT_ADDR = 0xA8, /* E */
BATCH_OUTPUT_SIZE = 0xAC, /* E */
MIN_LUMA_DPB_SIZE = 0xB0, /* D */
DEVICE_FORMAT_ID = 0xB4, /* C */
H264_POC_TYPE = 0xB8, /* D */
MIN_CHROMA_DPB_SIZE = 0xBC, /* D */
DISP_PIC_FRAME_TYPE = 0xC0, /* D */
FREE_LUMA_DPB = 0xC4, /* D, VC1 MPEG4 */
ASPECT_RATIO_INFO = 0xC8, /* D, MPEG4 */
EXTENDED_PAR = 0xCC, /* D, MPEG4 */
DBG_HISTORY_INPUT0 = 0xD0, /* C */
DBG_HISTORY_INPUT1 = 0xD4, /* C */
DBG_HISTORY_OUTPUT = 0xD8, /* C */
HIERARCHICAL_P_QP = 0xE0, /* E, H.264 */
FRAME_PACK_SEI_ENABLE = 0x168, /* C */
FRAME_PACK_SEI_AVAIL = 0x16c, /* D */
FRAME_PACK_SEI_INFO = 0x17c, /* E */
};
struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v5(void);
#endif /* S5P_MFC_OPR_H_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,45 @@
/*
* drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h
*
* Header file for Samsung MFC (Multi Function Codec - FIMV) driver
* Contains declarations of hw related functions.
*
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
* 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.
*/
#ifndef S5P_MFC_OPR_V6_H_
#define S5P_MFC_OPR_V6_H_
#include "s5p_mfc_common.h"
#include "s5p_mfc_opr.h"
#define MFC_CTRL_MODE_CUSTOM MFC_CTRL_MODE_SFR
#define MB_WIDTH(x_size) DIV_ROUND_UP(x_size, 16)
#define MB_HEIGHT(y_size) DIV_ROUND_UP(y_size, 16)
#define S5P_MFC_DEC_MV_SIZE_V6(x, y) (MB_WIDTH(x) * \
(((MB_HEIGHT(y)+1)/2)*2) * 64 + 128)
/* Definition */
#define ENC_MULTI_SLICE_MB_MAX ((1 << 30) - 1)
#define ENC_MULTI_SLICE_BIT_MIN 2800
#define ENC_INTRA_REFRESH_MB_MAX ((1 << 18) - 1)
#define ENC_VBV_BUF_SIZE_MAX ((1 << 30) - 1)
#define ENC_H264_LOOP_FILTER_AB_MIN -12
#define ENC_H264_LOOP_FILTER_AB_MAX 12
#define ENC_H264_RC_FRAME_RATE_MAX ((1 << 16) - 1)
#define ENC_H263_RC_FRAME_RATE_MAX ((1 << 16) - 1)
#define ENC_H264_PROFILE_MAX 3
#define ENC_H264_LEVEL_MAX 42
#define ENC_MPEG4_VOP_TIME_RES_MAX ((1 << 16) - 1)
#define FRAME_DELTA_H264_H263 1
#define TIGHT_CBR_MAX 10
struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v6(void);
const struct s5p_mfc_regs *s5p_mfc_init_regs_v6_plus(struct s5p_mfc_dev *dev);
#endif /* S5P_MFC_OPR_V6_H_ */

View file

@ -0,0 +1,141 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
*
* Copyright (c) 2010 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#ifdef CONFIG_PM_RUNTIME
#include <linux/pm_runtime.h>
#endif
#include "s5p_mfc_common.h"
#include "s5p_mfc_debug.h"
#include "s5p_mfc_pm.h"
#define MFC_GATE_CLK_NAME "mfc"
#define MFC_SCLK_NAME "sclk_mfc"
#define MFC_SCLK_RATE (200 * 1000000)
#define CLK_DEBUG
static struct s5p_mfc_pm *pm;
static struct s5p_mfc_dev *p_dev;
#ifdef CLK_DEBUG
static atomic_t clk_ref;
#endif
int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
{
int ret = 0;
pm = &dev->pm;
p_dev = dev;
pm->clock_gate = clk_get(&dev->plat_dev->dev, MFC_GATE_CLK_NAME);
if (IS_ERR(pm->clock_gate)) {
mfc_err("Failed to get clock-gating control\n");
ret = PTR_ERR(pm->clock_gate);
goto err_g_ip_clk;
}
ret = clk_prepare(pm->clock_gate);
if (ret) {
mfc_err("Failed to prepare clock-gating control\n");
goto err_p_ip_clk;
}
if (dev->variant->version != MFC_VERSION_V6) {
pm->clock = clk_get(&dev->plat_dev->dev, MFC_SCLK_NAME);
if (IS_ERR(pm->clock)) {
mfc_info("Failed to get MFC special clock control\n");
} else {
clk_set_rate(pm->clock, MFC_SCLK_RATE);
ret = clk_prepare_enable(pm->clock);
if (ret) {
mfc_err("Failed to enable MFC special clock\n");
goto err_s_clk;
}
}
}
atomic_set(&pm->power, 0);
#ifdef CONFIG_PM_RUNTIME
pm->device = &dev->plat_dev->dev;
pm_runtime_enable(pm->device);
#endif
#ifdef CLK_DEBUG
atomic_set(&clk_ref, 0);
#endif
return 0;
err_s_clk:
clk_put(pm->clock);
err_p_ip_clk:
clk_put(pm->clock_gate);
err_g_ip_clk:
return ret;
}
void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
{
if (dev->variant->version != MFC_VERSION_V6 &&
pm->clock) {
clk_disable_unprepare(pm->clock);
clk_put(pm->clock);
}
clk_unprepare(pm->clock_gate);
clk_put(pm->clock_gate);
#ifdef CONFIG_PM_RUNTIME
pm_runtime_disable(pm->device);
#endif
}
int s5p_mfc_clock_on(void)
{
int ret;
#ifdef CLK_DEBUG
atomic_inc(&clk_ref);
mfc_debug(3, "+ %d\n", atomic_read(&clk_ref));
#endif
ret = clk_enable(pm->clock_gate);
return ret;
}
void s5p_mfc_clock_off(void)
{
#ifdef CLK_DEBUG
atomic_dec(&clk_ref);
mfc_debug(3, "- %d\n", atomic_read(&clk_ref));
#endif
clk_disable(pm->clock_gate);
}
int s5p_mfc_power_on(void)
{
#ifdef CONFIG_PM_RUNTIME
return pm_runtime_get_sync(pm->device);
#else
atomic_set(&pm->power, 1);
return 0;
#endif
}
int s5p_mfc_power_off(void)
{
#ifdef CONFIG_PM_RUNTIME
return pm_runtime_put_sync(pm->device);
#else
atomic_set(&pm->power, 0);
return 0;
#endif
}

View file

@ -0,0 +1,24 @@
/*
* linux/drivers/media/platform/s5p-mfc/s5p_mfc_pm.h
*
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef S5P_MFC_PM_H_
#define S5P_MFC_PM_H_
int s5p_mfc_init_pm(struct s5p_mfc_dev *dev);
void s5p_mfc_final_pm(struct s5p_mfc_dev *dev);
int s5p_mfc_clock_on(void);
void s5p_mfc_clock_off(void);
int s5p_mfc_power_on(void);
int s5p_mfc_power_off(void);
#endif /* S5P_MFC_PM_H_ */