Skip to content

Commit a47cdcd

Browse files
authored
Merge pull request torvalds#361 from Owersun/odroidc2-v3.16.y
Update amlogic vpu code to changes required for Kodi v18 Leia to work…
2 parents c822ddf + 21eec43 commit a47cdcd

File tree

6 files changed

+72
-11
lines changed

6 files changed

+72
-11
lines changed

drivers/amlogic/amports/ptsserv.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ int calculation_stream_delayed_ms(u8 type, u32 *latestbitrate,
231231
outtime = timestamp_pcrscr_get();
232232
if (outtime == 0 || outtime == 0xffffffff)
233233
outtime = pTable->last_checkout_pts;
234-
timestampe_delayed = (pTable->last_checkin_pts - outtime) / 90;
234+
if (pTable->last_checkin_pts > outtime)
235+
timestampe_delayed = (pTable->last_checkin_pts - outtime) / 90;
236+
235237
pTable->last_pts_delay_ms = timestampe_delayed;
236238
if ((timestampe_delayed < 10
237239
|| abs(pTable->last_pts_delay_ms - timestampe_delayed) > 3000)
@@ -253,6 +255,7 @@ int calculation_stream_delayed_ms(u8 type, u32 *latestbitrate,
253255
} else
254256
/* #endif */
255257
diff2 = stbuf_level(get_buf_by_type(type));
258+
256259
/* #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */
257260
if (has_hevc_vdec()) {
258261
if (pTable->hevc) {
@@ -270,7 +273,7 @@ int calculation_stream_delayed_ms(u8 type, u32 *latestbitrate,
270273
if (diff2 > stbuf_space(get_buf_by_type(type)))
271274
diff = diff2;
272275
}
273-
delay_ms = diff * 1000 / (1 + pTable->last_avg_bitrate / 8);
276+
delay_ms = (diff * 1000) / (int)(1 + pTable->last_avg_bitrate / 8);
274277

275278
if (timestampe_delayed < 10
276279
|| (abs(timestampe_delayed - delay_ms) > 3 * 1000
@@ -888,6 +891,7 @@ static int pts_lookup_offset_inline_locked(u8 type, u32 offset, u32 *val,
888891
* use first checkin pts instead */
889892
if (!pTable->first_lookup_ok) {
890893
*val = pTable->first_checkin_pts;
894+
*uS64 = div64_u64((u64)pTable->first_checkin_pts * 100, 9);
891895
pTable->first_lookup_ok = 1;
892896
pTable->first_lookup_is_fail = 1;
893897

drivers/amlogic/amports/vh264.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ static void vh264_isr(void)
17201720
pr_info("0x%x\n", *daddr);
17211721
}
17221722
#endif
1723-
pr_info("pocinfo 0x%x, top poc %d, wp 0x%x, length %d\n",
1723+
pr_debug("pocinfo 0x%x, top poc %d, wp 0x%x, length %d\n",
17241724
READ_VREG(AV_SCRATCH_L), READ_VREG(AV_SCRATCH_M),
17251725
sei_itu35_wp, sei_itu35_data_length);
17261726
user_data_poc.poc_info = READ_VREG(AV_SCRATCH_L);

drivers/amlogic/amports/video.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3340,6 +3340,8 @@ static irqreturn_t vsync_isr(int irq, void *dev_id)
33403340
}
33413341
if (omx_secret_mode == true) {
33423342
u32 system_time = timestamp_pcrscr_get();
3343+
video_notify_flag |= VIDEO_NOTIFY_TRICK_WAIT;
3344+
atomic_set(&trickmode_framedone, 1);
33433345
int diff = system_time - omx_pts;
33443346
if ((diff - omx_pts_interval_upper) > 0
33453347
|| (diff - omx_pts_interval_lower) < 0) {

drivers/amlogic/deinterlace/deinterlace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,7 @@ struct di_post_stru_s {
16891689
bool toggle_flag;
16901690
bool vscale_skip_flag;
16911691
uint start_pts;
1692+
u64 start_pts_us64;
16921693
int buf_type;
16931694
};
16941695
#define di_post_stru_t struct di_post_stru_s
@@ -4438,6 +4439,7 @@ di_buf_i->vframe->type); */
44384439
disp_vf->height = di_buf_i->vframe->height;
44394440
disp_vf->duration = di_buf_i->vframe->duration;
44404441
disp_vf->pts = di_buf_i->vframe->pts;
4442+
disp_vf->pts_us64 = di_buf_i->vframe->pts_us64;
44414443
disp_vf->flag = di_buf_i->vframe->flag;
44424444
disp_vf->canvas0Addr = di_post_idx[di_post_stru.canvas_id][0];
44434445
disp_vf->canvas1Addr = di_post_idx[di_post_stru.canvas_id][0];

drivers/amlogic/video_dev/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config V4L_AMLOGIC_VIDEO
44
tristate "Amlogic v4l video device support"
55
select VIDEO_DEV
66
select VIDEO_V4L2
7+
select VIDEOBUF_GEN
78
select VIDEOBUF_RESOURCE
89
default n
910
---help---

drivers/amlogic/video_dev/amlvideo.c

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ AMLVIDEO_MINOR_VERSION, AMLVIDEO_RELEASE)
6262

6363
#define AMLVIDEO_POOL_SIZE 16
6464
static struct vfq_s q_ready;
65+
static struct vfq_s q_omx;
6566
/*extern bool omx_secret_mode;*/
6667
static u8 first_frame;
6768
static u64 last_pts_us64;
69+
static u32 omx_freerun_index = 0;
6870

6971
#define DUR2PTS(x) ((x) - ((x) >> 4))
7072
#define DUR2PTS_RM(x) ((x) & 0xf)
@@ -144,9 +146,11 @@ static struct vivi_fmt formats[] = {
144146
};
145147

146148
struct vframe_s *amlvideo_pool_ready[AMLVIDEO_POOL_SIZE + 1];
149+
struct vframe_s *amlvideo_pool_omx[AMLVIDEO_POOL_SIZE + 1];
147150
/* ------------------------------------------------------------------
148151
* provider operations
149152
*-----------------------------------------------------------------*/
153+
150154
static struct vframe_s *amlvideo_vf_peek(void *op_arg)
151155
{
152156
return vfq_peek(&q_ready);
@@ -182,10 +186,11 @@ static int amlvideo_vf_states(struct vframe_states *states, void *op_arg)
182186
{
183187
/* unsigned long flags; */
184188
/* spin_lock_irqsave(&lock, flags); */
189+
int avail_count = vfq_level(&q_ready) + vfq_level(&q_omx);
185190
states->vf_pool_size = AMLVIDEO_POOL_SIZE;
186191
states->buf_recycle_num = 0;
187-
states->buf_free_num = AMLVIDEO_POOL_SIZE - vfq_level(&q_ready);
188-
states->buf_avail_num = vfq_level(&q_ready);
192+
states->buf_free_num = AMLVIDEO_POOL_SIZE - avail_count;
193+
states->buf_avail_num = avail_count;
189194
/* spin_unlock_irqrestore(&lock, flags); */
190195
return 0;
191196
}
@@ -315,6 +320,8 @@ static int video_receiver_event_fun(int type, void *data, void *private_data)
315320
NULL);
316321
vfq_init(&q_ready, AMLVIDEO_POOL_SIZE + 1,
317322
&amlvideo_pool_ready[0]);
323+
vfq_init(&q_omx, AMLVIDEO_POOL_SIZE + 1,
324+
&amlvideo_pool_omx[0]);
318325
}
319326
}
320327
return 0;
@@ -550,8 +557,34 @@ static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p)
550557
static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p)
551558
{
552559
int ret = 0;
560+
u32 index;
553561
if (omx_secret_mode == true)
562+
{
563+
if (freerun_mode == 3)
564+
{
565+
struct vframe_s *vf;
566+
while ((vf = vfq_peek(&q_omx)))
567+
{
568+
index = (u32)vf->pts_us64;
569+
if (p->index > index)
570+
{
571+
vf_put(vfq_pop(&q_omx), RECEIVER_NAME);
572+
printk("vidioc_qbuf skip: index:%u:%u\n", p->index, index);
573+
continue;
574+
}
575+
else if (p->index == index)
576+
{
577+
vf = (vfq_pop(&q_omx));
578+
if (p->flags & V4L2_BUF_FLAG_DONE)
579+
vf_put(vf, RECEIVER_NAME);
580+
else
581+
vfq_push(&q_ready, vf);
582+
}
583+
break;
584+
}
585+
}
554586
return ret;
587+
}
555588

556589
if (ppmgrvf) {
557590
vf_put(ppmgrvf, RECEIVER_NAME);
@@ -633,8 +666,11 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
633666
return -EAGAIN;
634667
}
635668
if (omx_secret_mode == true) {
636-
vfq_push(&q_ready, ppmgrvf);
637-
p->index = 0;
669+
670+
//printk("%s, %s, %d %x %llx\n", __FILE__, __FUNCTION__, __LINE__, ppmgrvf->pts, ppmgrvf->pts_us64);
671+
672+
if (!ppmgrvf->pts_us64)
673+
ppmgrvf->pts_us64 = ((u64)ppmgrvf->pts * 100) / 9;
638674

639675
if (ppmgrvf->pts_us64) {
640676
first_frame = 1;
@@ -644,11 +680,27 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
644680
pts_us64 = 0;
645681
} else {
646682
pts_us64 = last_pts_us64
647-
+ (DUR2PTS(ppmgrvf->duration));
683+
+ (DUR2PTS(ppmgrvf->duration)) * 100 / 9;
648684
}
649685
p->timestamp.tv_sec = pts_us64 >> 32;
650686
p->timestamp.tv_usec = pts_us64 & 0xFFFFFFFF;
651687
last_pts_us64 = pts_us64;
688+
689+
if (freerun_mode != 3)
690+
{
691+
p->index = 0;
692+
vfq_push(&q_ready, ppmgrvf);
693+
vf_notify_receiver(
694+
PROVIDER_NAME,
695+
VFRAME_EVENT_PROVIDER_VFRAME_READY,
696+
NULL);
697+
}
698+
else
699+
{
700+
p->index = omx_freerun_index;
701+
ppmgrvf->pts_us64 = omx_freerun_index++;
702+
vfq_push(&q_omx, ppmgrvf);
703+
}
652704
return ret;
653705
}
654706
if (ppmgrvf->pts != 0) {
@@ -658,8 +710,8 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
658710
ppmgrvf->pts = timestamp_vpts_get();
659711
}
660712

661-
if (!ppmgrvf->pts)
662-
ppmgrvf->pts_us64 = ppmgrvf->pts * 100 / 9;
713+
if (!ppmgrvf->pts_us64)
714+
ppmgrvf->pts_us64 = ((u64)ppmgrvf->pts * 100) / 9;
663715

664716
if (unregFlag || startFlag) {
665717
if (ppmgrvf->pts == 0)
@@ -776,7 +828,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
776828
{
777829
int ret = 0;
778830

779-
if (freerun_mode == 1) {
831+
if (freerun_mode == 1 || freerun_mode == 3) {
780832
/* pr_err("amlvideo dqbuf called freerun_mode=1\n"); */
781833
ret = freerun_dqbuf(p);
782834
} else if (freerun_mode == 2) {

0 commit comments

Comments
 (0)