.flag_mode = MFC_CTRL_MODE_SFR,
.flag_addr = MFC_REG_E_PARAM_CHANGE,
.flag_shft = 13,
+ },
+ { /* sync the timestamp for drop control */
+ .type = MFC_CTRL_TYPE_SET,
+ .id = V4L2_CID_MPEG_VIDEO_DROP_CONTROL,
+ .is_volatile = 1,
+ .mode = MFC_CTRL_MODE_SFR,
+ .addr = MFC_REG_E_RC_FRAME_RATE,
+ .mask = 0x0000FFFF,
+ .shft = 0,
+ .flag_mode = MFC_CTRL_MODE_NONE,
+ .flag_addr = 0,
+ .flag_shft = 0,
}
};
enc->roi_buf[buf_ctrl->old_val2].daddr,
buf_ctrl->val);
}
+
+ /* set drop control */
+ if (buf_ctrl->id == V4L2_CID_MPEG_VIDEO_DROP_CONTROL) {
+ if (!ctx->ts_last_interval) {
+ p->rc_frame_delta = FRAME_RATE_RESOLUTION / p->rc_framerate;
+ mfc_debug(3, "[DROPCTRL] default delta: %d\n", p->rc_frame_delta);
+ } else {
+ p->rc_frame_delta = ctx->ts_last_interval / FRAME_RATE_RESOLUTION;
+ }
+ value = MFC_READL(MFC_REG_E_RC_FRAME_RATE);
+ value &= ~(0xFFFF);
+ value |= (p->rc_frame_delta & 0xFFFF);
+ MFC_WRITEL(value, MFC_REG_E_RC_FRAME_RATE);
+ mfc_debug(3, "[DROPCTRL] fps %d -> %d, delta: %d, reg: %#x\n",
+ p->rc_framerate, USEC_PER_SEC / ctx->ts_last_interval,
+ p->rc_frame_delta, value);
+ }
}
static int mfc_enc_set_buf_ctrls_val(struct mfc_ctx *ctx, struct list_head *head)
(buf_ctrl->val & buf_ctrl->mask) << buf_ctrl->shft;
param_change = 1;
break;
+ case V4L2_CID_MPEG_VIDEO_DROP_CONTROL:
+ if (!ctx->ts_last_interval) {
+ p->rc_frame_delta = FRAME_RATE_RESOLUTION / p->rc_framerate;
+ mfc_debug(3, "[NALQ][DROPCTRL] default delta: %d\n", p->rc_frame_delta);
+ } else {
+ p->rc_frame_delta = ctx->ts_last_interval / FRAME_RATE_RESOLUTION;
+ }
+ pInStr->RcFrameRate &= ~(0xFFFF << 16);
+ pInStr->RcFrameRate |= (FRAME_RATE_RESOLUTION & 0xFFFF) << 16;
+ pInStr->RcFrameRate &= ~(buf_ctrl->mask << buf_ctrl->shft);
+ pInStr->RcFrameRate |=
+ (p->rc_frame_delta & buf_ctrl->mask) << buf_ctrl->shft;
+ mfc_debug(3, "[NALQ][DROPCTRL] fps %d -> %d, delta: %d, reg: %#x\n",
+ p->rc_framerate, USEC_PER_SEC / ctx->ts_last_interval,
+ p->rc_frame_delta, pInStr->RcFrameRate);
+ break;
/* If new dynamic controls are added, insert here */
default:
mfc_info_ctx("[NALQ] can't find control, id: 0x%x\n",
#include "mfc_reg_api.h"
/* Definition */
-#define FRAME_DELTA_DEFAULT 1
#define CBR_FIX_MAX 10
#define CBR_I_LIMIT_MAX 5
#define BPG_EXTENSION_TAG_SIZE 5
mfc_clear_set_bits(reg, 0x1, 8, p->rc_mb);
/* frame-level rate control */
mfc_clear_set_bits(reg, 0x1, 9, p->rc_frame);
- /* 'DROP_CONTROL_ENABLE', disable */
- mfc_clear_bits(reg, 0x1, 10);
+ /* drop control */
+ mfc_clear_set_bits(reg, 0x1, 10, p->drop_control);
MFC_RAW_WRITEL(reg, MFC_REG_E_RC_CONFIG);
+ /*
+ * frame rate
+ * delta is timestamp diff
+ * ex) 30fps: 33, 60fps: 16
+ */
+ p->rc_frame_delta = FRAME_RATE_RESOLUTION / p->rc_framerate;
+ reg = MFC_RAW_READL(MFC_REG_E_RC_FRAME_RATE);
+ mfc_clear_set_bits(reg, 0xFFFF, 16, FRAME_RATE_RESOLUTION);
+ mfc_clear_set_bits(reg, 0xFFFF, 0, p->rc_frame_delta);
+ MFC_RAW_WRITEL(reg, MFC_REG_E_RC_FRAME_RATE);
+
/* bit rate */
ctx->Kbps = p->rc_bitrate / 1024;
MFC_RAW_WRITEL(p->rc_bitrate, MFC_REG_E_RC_BIT_RATE);
mfc_set_bits(reg, 0x1, 11, 0x1);
MFC_RAW_WRITEL(reg, MFC_REG_E_RC_CONFIG);
- /* frame rate */
- /* Fix value for H.264, H.263 in the driver */
- p->rc_frame_delta = FRAME_DELTA_DEFAULT;
- reg = MFC_RAW_READL(MFC_REG_E_RC_FRAME_RATE);
- mfc_clear_set_bits(reg, 0xFFFF, 16, p->rc_framerate);
- mfc_clear_set_bits(reg, 0xFFFF, 0, p->rc_frame_delta);
- MFC_RAW_WRITEL(reg, MFC_REG_E_RC_FRAME_RATE);
-
/* max & min value of QP for I frame */
reg = MFC_RAW_READL(MFC_REG_E_RC_QP_BOUND);
/** max I frame QP */
mfc_clear_set_bits(reg, 0xFF, 0, p_mpeg4->rc_frame_qp);
MFC_RAW_WRITEL(reg, MFC_REG_E_FIXED_PICTURE_QP);
- /* frame rate */
- p->rc_frame_delta = p_mpeg4->vop_frm_delta;
- reg = MFC_RAW_READL(MFC_REG_E_RC_FRAME_RATE);
- mfc_clear_set_bits(reg, 0xFFFF, 16, p_mpeg4->vop_time_res);
- mfc_clear_set_bits(reg, 0xFFFF, 0, p_mpeg4->vop_frm_delta);
- MFC_RAW_WRITEL(reg, MFC_REG_E_RC_FRAME_RATE);
-
/* rate control config. */
reg = MFC_RAW_READL(MFC_REG_E_RC_CONFIG);
/** frame QP */
mfc_clear_set_bits(reg, 0xFF, 0, p_mpeg4->rc_frame_qp);
MFC_RAW_WRITEL(reg, MFC_REG_E_FIXED_PICTURE_QP);
- /* frame rate */
- /* Fix value for H.264, H.263 in the driver */
- p->rc_frame_delta = FRAME_DELTA_DEFAULT;
- reg = MFC_RAW_READL(MFC_REG_E_RC_FRAME_RATE);
- mfc_clear_set_bits(reg, 0xFFFF, 16, p->rc_framerate);
- mfc_clear_set_bits(reg, 0xFFFF, 0, p->rc_frame_delta);
- MFC_RAW_WRITEL(reg, MFC_REG_E_RC_FRAME_RATE);
-
/* rate control config. */
reg = MFC_RAW_READL(MFC_REG_E_RC_CONFIG);
/** frame QP */
mfc_clear_set_bits(reg, 0xFF, 0, p_vp8->rc_frame_qp);
MFC_RAW_WRITEL(reg, MFC_REG_E_FIXED_PICTURE_QP);
- /* frame rate */
- p->rc_frame_delta = FRAME_DELTA_DEFAULT;
- reg = MFC_RAW_READL(MFC_REG_E_RC_FRAME_RATE);
- mfc_clear_set_bits(reg, 0xFFFF, 16, p->rc_framerate);
- mfc_clear_set_bits(reg, 0xFFFF, 0, p->rc_frame_delta);
- MFC_RAW_WRITEL(reg, MFC_REG_E_RC_FRAME_RATE);
-
/* rate control config. */
reg = MFC_RAW_READL(MFC_REG_E_RC_CONFIG);
/** frame QP */
mfc_clear_set_bits(reg, 0xFF, 0, p_vp9->rc_frame_qp);
MFC_RAW_WRITEL(reg, MFC_REG_E_FIXED_PICTURE_QP);
- /* frame rate */
- p->rc_frame_delta = FRAME_DELTA_DEFAULT;
- reg = MFC_RAW_READL(MFC_REG_E_RC_FRAME_RATE);
- mfc_clear_set_bits(reg, 0xFFFF, 16, p->rc_framerate);
- mfc_clear_set_bits(reg, 0xFFFF, 0, p->rc_frame_delta);
- MFC_RAW_WRITEL(reg, MFC_REG_E_RC_FRAME_RATE);
-
/* rate control config. */
reg = MFC_RAW_READL(MFC_REG_E_RC_CONFIG);
/** frame QP */
mfc_clear_set_bits(reg, 0xFF, 0, p_hevc->rc_frame_qp);
MFC_RAW_WRITEL(reg, MFC_REG_E_RC_CONFIG);
- /* frame rate */
- p->rc_frame_delta = FRAME_DELTA_DEFAULT;
- reg = MFC_RAW_READL(MFC_REG_E_RC_FRAME_RATE);
- mfc_clear_set_bits(reg, 0xFFFF, 16, p->rc_framerate);
- mfc_clear_set_bits(reg, 0xFFFF, 0, p->rc_frame_delta);
- MFC_RAW_WRITEL(reg, MFC_REG_E_RC_FRAME_RATE);
-
/* max & min value of QP for I frame */
reg = MFC_RAW_READL(MFC_REG_E_RC_QP_BOUND);
/** max I frame QP */