From: Ayoung Sim Date: Fri, 22 Jun 2018 05:04:43 +0000 (+0900) Subject: [COMMON] media: mfc: use the rc_framerate for timestamp calculation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5d27f68ffc831657ac8833f7b476856f0a85c250;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] media: mfc: use the rc_framerate for timestamp calculation Change-Id: I8ebb3144da1098c3a8335ef03d973ac53e88a2ab Signed-off-by: Ayoung Sim --- diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h index deee549e1a8b..be5790f037b1 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h @@ -816,7 +816,6 @@ struct s5p_mfc_h264_enc_params { s8 loop_filter_beta; enum v4l2_mpeg_video_h264_entropy_mode entropy_mode; u8 _8x8_transform; - u32 rc_framerate; u8 rc_frame_qp; u8 rc_min_qp; u8 rc_max_qp; @@ -874,7 +873,6 @@ struct s5p_mfc_mpeg4_enc_params { u16 vop_frm_delta; u8 rc_b_frame_qp; /* Common for MPEG4, H263 */ - u32 rc_framerate; u8 rc_frame_qp; u8 rc_min_qp; u8 rc_max_qp; @@ -890,7 +888,6 @@ struct s5p_mfc_mpeg4_enc_params { */ struct s5p_mfc_vp9_enc_params { /* VP9 Only */ - u32 rc_framerate; u8 vp9_version; u8 rc_min_qp; u8 rc_max_qp; @@ -914,7 +911,6 @@ struct s5p_mfc_vp9_enc_params { */ struct s5p_mfc_vp8_enc_params { /* VP8 Only */ - u32 rc_framerate; u8 vp8_version; u8 rc_min_qp; u8 rc_max_qp; @@ -942,7 +938,6 @@ struct s5p_mfc_hevc_enc_params { u8 level; u8 tier_flag; /* HEVC Only */ - u32 rc_framerate; u8 rc_min_qp; u8 rc_max_qp; u8 rc_min_qp_p; @@ -1017,6 +1012,7 @@ struct s5p_mfc_enc_params { u8 pad_cr; u8 rc_frame; u32 rc_bitrate; + u32 rc_framerate; u16 rc_reaction_coeff; u32 config_qp; u32 dynamic_qp; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c index 87e7983aab96..04636fd03301 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c @@ -1059,7 +1059,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl) p->rc_mb = ctrl->value; break; case V4L2_CID_MPEG_MFC51_VIDEO_H264_RC_FRAME_RATE: - p->codec.h264.rc_framerate = ctrl->value; + p->rc_framerate = ctrl->value; break; case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: p->codec.h264.rc_frame_qp = ctrl->value; @@ -1270,7 +1270,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl) p->codec.mpeg4.vop_frm_delta = ctrl->value; break; case V4L2_CID_MPEG_MFC51_VIDEO_H263_RC_FRAME_RATE: - p->codec.mpeg4.rc_framerate = ctrl->value; + p->rc_framerate = ctrl->value; break; case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: p->codec.mpeg4.rc_frame_qp = ctrl->value; @@ -1294,7 +1294,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl) p->codec.vp8.vp8_version = ctrl->value; break; case V4L2_CID_MPEG_MFC70_VIDEO_VP8_RC_FRAME_RATE: - p->codec.vp8.rc_framerate = ctrl->value; + p->rc_framerate = ctrl->value; break; case V4L2_CID_MPEG_VIDEO_VP8_MIN_QP: p->codec.vp8.rc_min_qp = ctrl->value; @@ -1366,7 +1366,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl) p->codec.vp9.vp9_version = ctrl->value; break; case V4L2_CID_MPEG_VIDEO_VP9_RC_FRAME_RATE: - p->codec.vp9.rc_framerate = ctrl->value; + p->rc_framerate = ctrl->value; break; case V4L2_CID_MPEG_VIDEO_VP9_MIN_QP: p->codec.vp9.rc_min_qp = ctrl->value; @@ -1436,7 +1436,7 @@ static int mfc_enc_set_param(struct s5p_mfc_ctx *ctx, struct v4l2_control *ctrl) p->codec.hevc.rc_b_frame_qp = ctrl->value; break; case V4L2_CID_MPEG_MFC90_VIDEO_HEVC_RC_FRAME_RATE: - p->codec.hevc.rc_framerate = ctrl->value; + p->rc_framerate = ctrl->value; break; case V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP: p->codec.hevc.rc_min_qp = ctrl->value; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c index 6cc8a21cfb89..bfc323391817 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c @@ -496,7 +496,7 @@ void s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx) p->rc_frame_delta = FRAME_DELTA_DEFAULT; reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE); reg &= ~(0xFFFF << 16); - reg |= p_264->rc_framerate << 16; + reg |= (p->rc_framerate << 16); reg &= ~(0xFFFF); reg |= p->rc_frame_delta & 0xFFFF; MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE); @@ -738,7 +738,7 @@ void s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx) p->rc_frame_delta = FRAME_DELTA_DEFAULT; reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE); reg &= ~(0xFFFF << 16); - reg |= (p_mpeg4->rc_framerate << 16); + reg |= (p->rc_framerate << 16); reg &= ~(0xFFFF); reg |= (p->rc_frame_delta & 0xFFFF); MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE); @@ -872,7 +872,7 @@ void s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx *ctx) p->rc_frame_delta = FRAME_DELTA_DEFAULT; reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE); reg &= ~(0xFFFF << 16); - reg |= (p_vp8->rc_framerate << 16); + reg |= (p->rc_framerate << 16); reg &= ~(0xFFFF); reg |= (p->rc_frame_delta & 0xFFFF); MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE); @@ -1016,7 +1016,7 @@ void s5p_mfc_set_enc_params_vp9(struct s5p_mfc_ctx *ctx) p->rc_frame_delta = FRAME_DELTA_DEFAULT; reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE); reg &= ~(0xFFFF << 16); - reg |= (p_vp9->rc_framerate << 16); + reg |= (p->rc_framerate << 16); reg &= ~(0xFFFF); reg |= (p->rc_frame_delta & 0xFFFF); MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE); @@ -1245,7 +1245,7 @@ void s5p_mfc_set_enc_params_hevc(struct s5p_mfc_ctx *ctx) p->rc_frame_delta = FRAME_DELTA_DEFAULT; reg = MFC_READL(S5P_FIMV_E_RC_FRAME_RATE); reg &= ~(0xFFFF << 16); - reg |= (p_hevc->rc_framerate << 16); + reg |= (p->rc_framerate << 16); reg &= ~(0xFFFF); reg |= (p->rc_frame_delta & 0xFFFF); MFC_WRITEL(reg, S5P_FIMV_E_RC_FRAME_RATE); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c index 4c7e141e01e7..b5d7eed6e79d 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c @@ -728,8 +728,10 @@ leave_handle_frame: static void mfc_handle_stream_copy_timestamp(struct s5p_mfc_ctx *ctx, struct s5p_mfc_buf *src_mb) { struct s5p_mfc_dev *dev; + struct s5p_mfc_enc *enc = ctx->enc_priv; + struct s5p_mfc_enc_params *p = &enc->params; struct s5p_mfc_buf *dst_mb; - u64 interval; + u32 interval; u64 start_timestamp; u64 new_timestamp; @@ -745,14 +747,14 @@ static void mfc_handle_stream_copy_timestamp(struct s5p_mfc_ctx *ctx, struct s5p } start_timestamp = src_mb->vb.vb2_buf.timestamp; - interval = NSEC_PER_SEC / (ENC_DEFAULT_CAM_VIDEO_FPS / 1000); + interval = NSEC_PER_SEC / p->rc_framerate; if (debug_ts == 1) - mfc_info_ctx("[TS] %dfps, start timestamp: %lld, base interval: %lld\n", - (ENC_DEFAULT_CAM_VIDEO_FPS / 1000), start_timestamp, interval); + mfc_info_ctx("[TS] %dfps, start timestamp: %lld, base interval: %d\n", + p->rc_framerate, start_timestamp, interval); new_timestamp = start_timestamp + (interval * src_mb->done_index); if (debug_ts == 1) - mfc_info_ctx("[TS] new timestamp: %lld, interval: %lld\n", + mfc_info_ctx("[TS] new timestamp: %lld, interval: %d\n", new_timestamp, interval * src_mb->done_index); /* Get the destination buffer */ diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c index 530238e4f391..f8ce9b5d21b9 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c @@ -876,8 +876,10 @@ static void mfc_nal_q_get_enc_frame_buffer(struct s5p_mfc_ctx *ctx, static void mfc_nal_q_handle_stream_copy_timestamp(struct s5p_mfc_ctx *ctx, struct s5p_mfc_buf *src_mb) { struct s5p_mfc_dev *dev; + struct s5p_mfc_enc *enc = ctx->enc_priv; + struct s5p_mfc_enc_params *p = &enc->params; struct s5p_mfc_buf *dst_mb; - u64 interval; + u32 interval; u64 start_timestamp; u64 new_timestamp; @@ -893,14 +895,14 @@ static void mfc_nal_q_handle_stream_copy_timestamp(struct s5p_mfc_ctx *ctx, stru } start_timestamp = src_mb->vb.vb2_buf.timestamp; - interval = NSEC_PER_SEC / (ENC_DEFAULT_CAM_VIDEO_FPS / 1000); + interval = NSEC_PER_SEC / p->rc_framerate; if (debug_ts == 1) - mfc_info_ctx("[NALQ][TS] %dfps, start timestamp: %lld, base interval: %lld\n", - (ENC_DEFAULT_CAM_VIDEO_FPS / 1000), start_timestamp, interval); + mfc_info_ctx("[NALQ][TS] %dfps, start timestamp: %lld, base interval: %d\n", + p->rc_framerate, start_timestamp, interval); new_timestamp = start_timestamp + (interval * src_mb->done_index); if (debug_ts == 1) - mfc_info_ctx("[NALQ][TS] new timestamp: %lld, interval: %lld\n", + mfc_info_ctx("[NALQ][TS] new timestamp: %lld, interval: %d\n", new_timestamp, interval * src_mb->done_index); /* Get the destination buffer */ diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_qos.h b/drivers/media/platform/exynos/mfc/s5p_mfc_qos.h index 9254657b7720..a733a60f5296 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_qos.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_qos.h @@ -19,7 +19,6 @@ #define DEC_DEFAULT_FPS (240000) #define ENC_DEFAULT_FPS (240000) #define ENC_DEFAULT_CAM_CAPTURE_FPS (60000) -#define ENC_DEFAULT_CAM_VIDEO_FPS (30000) #define MB_COUNT_PER_UHD_FRAME 32400 #define MAX_FPS_PER_UHD_FRAME 120