Merge "msm: vidc: revise timestamp data type to s64"

This commit is contained in:
qctecmdr 2020-08-10 16:04:35 -07:00 committed by Gerrit - the friendly Code Review server
commit c1ad7b0054
4 changed files with 25 additions and 11 deletions

View File

@ -366,7 +366,7 @@ int msm_vidc_qbuf(void *instance, struct media_device *mdev,
int rc = 0; int rc = 0;
unsigned int i = 0; unsigned int i = 0;
struct buf_queue *q = NULL; struct buf_queue *q = NULL;
u64 timestamp_us = 0; s64 timestamp_us = 0;
u32 cr = 0; u32 cr = 0;
if (!inst || !inst->core || !b || !valid_v4l2_buffer(b, inst)) { if (!inst || !inst->core || !b || !valid_v4l2_buffer(b, inst)) {
@ -430,7 +430,7 @@ int msm_vidc_qbuf(void *instance, struct media_device *mdev,
&& b->type == INPUT_MPLANE) && b->type == INPUT_MPLANE)
b->flags |= V4L2_BUF_FLAG_PERF_MODE; b->flags |= V4L2_BUF_FLAG_PERF_MODE;
timestamp_us = (u64)((b->timestamp.tv_sec * 1000000ULL) + timestamp_us = (s64)((b->timestamp.tv_sec * 1000000) +
b->timestamp.tv_usec); b->timestamp.tv_usec);
if (is_decode_session(inst) && b->type == INPUT_MPLANE) { if (is_decode_session(inst) && b->type == INPUT_MPLANE) {
if (inst->flush_timestamps) if (inst->flush_timestamps)
@ -438,7 +438,8 @@ int msm_vidc_qbuf(void *instance, struct media_device *mdev,
inst->flush_timestamps = false; inst->flush_timestamps = false;
if (!(b->flags & V4L2_BUF_FLAG_CODECCONFIG)) if (!(b->flags & V4L2_BUF_FLAG_CODECCONFIG))
rc = msm_comm_store_timestamp(inst, timestamp_us); rc = msm_comm_store_timestamp(inst, timestamp_us,
b->flags & V4L2_BUF_FLAG_EOS);
if (rc) if (rc)
goto unlock; goto unlock;

View File

@ -7600,7 +7600,8 @@ void msm_comm_release_timestamps(struct msm_vidc_inst *inst)
mutex_unlock(&inst->timestamps.lock); mutex_unlock(&inst->timestamps.lock);
} }
int msm_comm_store_timestamp(struct msm_vidc_inst *inst, u64 timestamp_us) int msm_comm_store_timestamp(struct msm_vidc_inst *inst, s64 timestamp_us,
bool is_eos)
{ {
struct msm_vidc_timestamps *entry, *node, *prev = NULL; struct msm_vidc_timestamps *entry, *node, *prev = NULL;
struct msm_vidc_timestamps *duplicate; struct msm_vidc_timestamps *duplicate;
@ -7618,7 +7619,8 @@ int msm_comm_store_timestamp(struct msm_vidc_inst *inst, u64 timestamp_us)
duplicate = NULL; duplicate = NULL;
list_for_each_entry(node, &inst->timestamps.list, list) { list_for_each_entry(node, &inst->timestamps.list, list) {
count++; count++;
if (node->is_valid && node->timestamp_us == timestamp_us) if (node->is_valid && node->timestamp_us == timestamp_us &&
!node->is_eos)
duplicate = node; duplicate = node;
} }
@ -7649,6 +7651,7 @@ int msm_comm_store_timestamp(struct msm_vidc_inst *inst, u64 timestamp_us)
entry->timestamp_us = duplicate->timestamp_us; entry->timestamp_us = duplicate->timestamp_us;
entry->framerate = duplicate->framerate; entry->framerate = duplicate->framerate;
entry->is_valid = true; entry->is_valid = true;
entry->is_eos = is_eos;
/* add entry next to duplicate */ /* add entry next to duplicate */
list_add(&entry->list, &duplicate->list); list_add(&entry->list, &duplicate->list);
goto unlock; goto unlock;
@ -7661,7 +7664,8 @@ int msm_comm_store_timestamp(struct msm_vidc_inst *inst, u64 timestamp_us)
prev = NULL; prev = NULL;
inserted = false; inserted = false;
list_for_each_entry(node, &inst->timestamps.list, list) { list_for_each_entry(node, &inst->timestamps.list, list) {
if (entry->timestamp_us < node->timestamp_us) { if (entry->timestamp_us < node->timestamp_us &&
!node->is_eos) {
/* /*
* if prev available add entry next to prev else * if prev available add entry next to prev else
* entry is first so add it at head. * entry is first so add it at head.
@ -7688,7 +7692,8 @@ int msm_comm_store_timestamp(struct msm_vidc_inst *inst, u64 timestamp_us)
node->timestamp_us, prev->timestamp_us); node->timestamp_us, prev->timestamp_us);
break; break;
} }
if (node->timestamp_us == entry->timestamp_us) { if (node->timestamp_us == entry->timestamp_us &&
!node->is_eos) {
if (prev) if (prev)
node->framerate = msm_comm_calc_framerate(inst, node->framerate = msm_comm_calc_framerate(inst,
node->timestamp_us, prev->timestamp_us); node->timestamp_us, prev->timestamp_us);
@ -7697,6 +7702,12 @@ int msm_comm_store_timestamp(struct msm_vidc_inst *inst, u64 timestamp_us)
prev = node; prev = node;
} }
/* mark all entries as eos if is_eos is queued */
if (is_eos)
list_for_each_entry(node, &inst->timestamps.list, list) {
node->is_eos = true;
}
unlock: unlock:
mutex_unlock(&inst->timestamps.lock); mutex_unlock(&inst->timestamps.lock);
return rc; return rc;
@ -7783,8 +7794,8 @@ int msm_comm_fetch_ts_framerate(struct msm_vidc_inst *inst,
if (!(b->flags & V4L2_BUF_FLAG_END_OF_SUBFRAME)) if (!(b->flags & V4L2_BUF_FLAG_END_OF_SUBFRAME))
node->is_valid = false; node->is_valid = false;
b->timestamp.tv_sec = node->timestamp_us / 1000000ull; b->timestamp.tv_sec = node->timestamp_us / 1000000;
b->timestamp.tv_usec = node->timestamp_us % 1000000ull; b->timestamp.tv_usec = node->timestamp_us % 1000000;
b->m.planes[0].reserved[MSM_VIDC_FRAMERATE] = node->framerate; b->m.planes[0].reserved[MSM_VIDC_FRAMERATE] = node->framerate;
break; break;
} }

View File

@ -400,7 +400,8 @@ int msm_comm_set_cvp_skip_ratio(struct msm_vidc_inst *inst,
uint32_t capture_rate, uint32_t cvp_rate); uint32_t capture_rate, uint32_t cvp_rate);
int msm_comm_fetch_ts_framerate(struct msm_vidc_inst *inst, int msm_comm_fetch_ts_framerate(struct msm_vidc_inst *inst,
struct v4l2_buffer *b); struct v4l2_buffer *b);
int msm_comm_store_timestamp(struct msm_vidc_inst *inst, u64 timestamp_us); int msm_comm_store_timestamp(struct msm_vidc_inst *inst, s64 timestamp_us,
bool is_eos);
void msm_comm_release_timestamps(struct msm_vidc_inst *inst); void msm_comm_release_timestamps(struct msm_vidc_inst *inst);
u32 msm_comm_get_max_framerate(struct msm_vidc_inst *inst); u32 msm_comm_get_max_framerate(struct msm_vidc_inst *inst);
u32 msm_comm_calc_framerate(struct msm_vidc_inst *inst, u64 timestamp_us, u32 msm_comm_calc_framerate(struct msm_vidc_inst *inst, u64 timestamp_us,

View File

@ -236,9 +236,10 @@ struct msm_vidc_codec {
struct msm_vidc_timestamps { struct msm_vidc_timestamps {
struct list_head list; struct list_head list;
u64 timestamp_us; s64 timestamp_us;
u32 framerate; u32 framerate;
bool is_valid; bool is_valid;
bool is_eos;
}; };
enum efuse_purpose { enum efuse_purpose {