summaryrefslogtreecommitdiff
path: root/drivers/mxc
diff options
context:
space:
mode:
authorMing Qian <ming.qian@nxp.com>2020-11-03 15:45:49 +0800
committerMing Qian <ming.qian@nxp.com>2020-11-19 17:34:03 +0800
commitbf67b065295cbdbfd408a11d7e2268e3a95116a0 (patch)
treeed5fd2562c19b337feef540101f995f605c3fc40 /drivers/mxc
parent77816ac1faa41fac82b75e66c4cbc4205c0926a1 (diff)
MLK-24959: [8QM_MEK/8QXP_MEK]mxc:vpu_windsor: move timestamp handler to
firmware move timestamp to firmware, it will make our driver more easy to upstream Signed-off-by: Ming Qian <ming.qian@nxp.com>
Diffstat (limited to 'drivers/mxc')
-rw-r--r--drivers/mxc/vpu_windsor/mediasys_types.h2
-rw-r--r--drivers/mxc/vpu_windsor/vpu_encoder_b0.c65
-rw-r--r--drivers/mxc/vpu_windsor/vpu_encoder_b0.h2
3 files changed, 19 insertions, 50 deletions
diff --git a/drivers/mxc/vpu_windsor/mediasys_types.h b/drivers/mxc/vpu_windsor/mediasys_types.h
index c348beaff20e..0f93d20afa90 100644
--- a/drivers/mxc/vpu_windsor/mediasys_types.h
+++ b/drivers/mxc/vpu_windsor/mediasys_types.h
@@ -199,6 +199,8 @@ typedef struct {
u_int32 uProcDaccRngRdCnt;
u_int32 uProcDaccRngWrCnt;
+ int32 tv_s;
+ u_int32 tv_ns;
} MEDIAIP_ENC_PIC_INFO, *pMEDIAIP_ENC_PIC_INFO;
typedef enum {
diff --git a/drivers/mxc/vpu_windsor/vpu_encoder_b0.c b/drivers/mxc/vpu_windsor/vpu_encoder_b0.c
index 6d3188997550..d057ae0f35d4 100644
--- a/drivers/mxc/vpu_windsor/vpu_encoder_b0.c
+++ b/drivers/mxc/vpu_windsor/vpu_encoder_b0.c
@@ -235,19 +235,6 @@ static void count_encoded_frame(struct vpu_ctx *ctx)
attr->statistic.encoded_count++;
}
-static void count_timestamp_overwrite(struct vpu_ctx *ctx)
-{
- struct vpu_attr *attr = NULL;
-
- WARN_ON(!ctx);
-
- attr = get_vpu_ctx_attr(ctx);
- if (!attr)
- return;
-
- attr->statistic.timestamp_overwrite++;
-}
-
static void write_vpu_reg(struct vpu_dev *dev, u32 val, off_t reg)
{
writel(val, dev->regs_base + reg);
@@ -2049,50 +2036,22 @@ static void update_encode_size(struct vpu_ctx *ctx)
static void init_ctx_seq_info(struct vpu_ctx *ctx)
{
- int i;
-
if (!ctx)
return;
ctx->sequence = 0;
- for (i = 0; i < ARRAY_SIZE(ctx->timestams); i++)
- ctx->timestams[i] = VPU_ENC_INVALID_TIMESTAMP;
ctx->timestamp = VPU_ENC_INVALID_TIMESTAMP;
}
static void fill_ctx_seq(struct vpu_ctx *ctx, struct vb2_data_req *p_data_req)
{
- u_int32 idx;
-
WARN_ON(!ctx || !p_data_req);
p_data_req->sequence = ctx->sequence++;
- idx = p_data_req->sequence % VPU_ENC_SEQ_CAPACITY;
- if (ctx->timestams[idx] != VPU_ENC_INVALID_TIMESTAMP) {
- count_timestamp_overwrite(ctx);
- vpu_dbg(LVL_FRAME, "[%d:%d][%d] overwrite timestamp\n",
- ctx->core_dev->id, ctx->str_index,
- p_data_req->sequence);
- }
- ctx->timestams[idx] = p_data_req->vb2_buf->timestamp;
if (ctx->timestamp < (s64)p_data_req->vb2_buf->timestamp)
ctx->timestamp = p_data_req->vb2_buf->timestamp;
}
-static s64 get_ctx_seq_timestamp(struct vpu_ctx *ctx, u32 sequence)
-{
- s64 timestamp;
- u_int32 idx;
-
- WARN_ON(!ctx);
-
- idx = sequence % VPU_ENC_SEQ_CAPACITY;
- timestamp = ctx->timestams[idx];
- ctx->timestams[idx] = VPU_ENC_INVALID_TIMESTAMP;
-
- return timestamp;
-}
-
static void fill_vb_sequence(struct vb2_buffer *vb, u32 sequence)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -2317,7 +2276,7 @@ static int update_encode_param(struct vpu_ctx *ctx)
return 0;
}
-static bool update_yuv_addr(struct vpu_ctx *ctx)
+static bool update_yuv_addr(struct vpu_ctx *ctx, s64 *timestamp)
{
bool bGotAFrame = FALSE;
@@ -2352,6 +2311,8 @@ static bool update_yuv_addr(struct vpu_ctx *ctx)
else
desc->uKeyFrame = 0;
list_del(&p_data_req->list);
+ if (timestamp)
+ *timestamp = p_data_req->vb2_buf->timestamp;
return bGotAFrame;
}
@@ -2512,6 +2473,7 @@ bool check_stream_buffer_for_coded_picture(struct vpu_ctx *ctx)
static int submit_input_and_encode(struct vpu_ctx *ctx)
{
struct queue_data *queue;
+ s64 timestamp = -1;
if (!ctx)
return -EINVAL;
@@ -2534,8 +2496,17 @@ static int submit_input_and_encode(struct vpu_ctx *ctx)
if (!test_bit(VPU_ENC_STATUS_START_DONE, &ctx->status))
goto exit;
- if (update_yuv_addr(ctx)) {
- vpu_ctx_send_cmd(ctx, GTB_ENC_CMD_FRAME_ENCODE, 0, NULL);
+ if (update_yuv_addr(ctx, &timestamp)) {
+ u32 data[2];
+
+ if (timestamp < 0) {
+ data[0] = -1;
+ data[1] = 0;
+ } else {
+ data[0] = timestamp / NSEC_PER_SEC;
+ data[1] = timestamp % NSEC_PER_SEC;
+ }
+ vpu_ctx_send_cmd(ctx, GTB_ENC_CMD_FRAME_ENCODE, 2, data);
clear_queue_rw_flag(queue, VPU_ENC_FLAG_WRITEABLE);
record_start_time(ctx, V4L2_SRC);
}
@@ -2932,7 +2903,7 @@ static bool process_frame_done(struct queue_data *queue)
fill_vb_sequence(p_data_req->vb2_buf, frame->info.uFrameID);
set_vb_flags(p_data_req->vb2_buf, p_data_req->buffer_flags);
p_data_req->vb2_buf->timestamp = frame->timestamp;
- vpu_dbg(LVL_FRAME, "[%d:%d] index : %8d, length : %8ld, ts : %lld%s\n",
+ vpu_dbg(LVL_FRAME, "[%d:%d][%8d], length : %8ld, ts : %32lld%s\n",
ctx->core_dev->id, ctx->str_index,
frame->info.uFrameID,
vb2_get_plane_payload(p_data_req->vb2_buf, 0),
@@ -3155,7 +3126,7 @@ static int handle_event_frame_done(struct vpu_ctx *ctx,
show_enc_pic_info(pEncPicInfo);
record_start_time(ctx, V4L2_DST);
- timestamp = get_ctx_seq_timestamp(ctx, pEncPicInfo->uFrameID);
+ timestamp = (pEncPicInfo->tv_s * NSEC_PER_SEC + pEncPicInfo->tv_ns);
down(&queue->drv_q_lock);
frame = get_idle_frame(queue);
@@ -4351,8 +4322,6 @@ static int show_frame_sts(struct vpu_statistic *statistic, char *buf, u32 size)
num += show_fps_info(statistic->fps, ARRAY_SIZE(statistic->fps),
buf + num, PAGE_SIZE - num);
num += scnprintf(buf + num, size - num, "\n");
- num += scnprintf(buf + num, size - num, "\t%-24s:%ld\n",
- "timestamp overwrite", statistic->timestamp_overwrite);
return num;
}
diff --git a/drivers/mxc/vpu_windsor/vpu_encoder_b0.h b/drivers/mxc/vpu_windsor/vpu_encoder_b0.h
index 7d6beeacaa60..c051337184ca 100644
--- a/drivers/mxc/vpu_windsor/vpu_encoder_b0.h
+++ b/drivers/mxc/vpu_windsor/vpu_encoder_b0.h
@@ -246,7 +246,6 @@ struct vpu_statistic {
} strip_sts;
bool fps_sts_enable;
struct vpu_fps_sts fps[VPU_FPS_STS_CNT];
- unsigned long timestamp_overwrite;
};
struct vpu_attr {
@@ -470,7 +469,6 @@ struct vpu_ctx {
struct vpu_statistic sts;
unsigned int frozen_count;
u_int32 sequence;
- s64 timestams[VPU_ENC_SEQ_CAPACITY];
u32 cpb_size;
s64 timestamp;
u8 colorspace;