@@ -62,9 +62,11 @@ AMLVIDEO_MINOR_VERSION, AMLVIDEO_RELEASE)
62
62
63
63
#define AMLVIDEO_POOL_SIZE 16
64
64
static struct vfq_s q_ready ;
65
+ static struct vfq_s q_omx ;
65
66
/*extern bool omx_secret_mode;*/
66
67
static u8 first_frame ;
67
68
static u64 last_pts_us64 ;
69
+ static u32 omx_freerun_index = 0 ;
68
70
69
71
#define DUR2PTS (x ) ((x) - ((x) >> 4))
70
72
#define DUR2PTS_RM (x ) ((x) & 0xf)
@@ -144,9 +146,11 @@ static struct vivi_fmt formats[] = {
144
146
};
145
147
146
148
struct vframe_s * amlvideo_pool_ready [AMLVIDEO_POOL_SIZE + 1 ];
149
+ struct vframe_s * amlvideo_pool_omx [AMLVIDEO_POOL_SIZE + 1 ];
147
150
/* ------------------------------------------------------------------
148
151
* provider operations
149
152
*-----------------------------------------------------------------*/
153
+
150
154
static struct vframe_s * amlvideo_vf_peek (void * op_arg )
151
155
{
152
156
return vfq_peek (& q_ready );
@@ -182,10 +186,11 @@ static int amlvideo_vf_states(struct vframe_states *states, void *op_arg)
182
186
{
183
187
/* unsigned long flags; */
184
188
/* spin_lock_irqsave(&lock, flags); */
189
+ int avail_count = vfq_level (& q_ready ) + vfq_level (& q_omx );
185
190
states -> vf_pool_size = AMLVIDEO_POOL_SIZE ;
186
191
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 ;
189
194
/* spin_unlock_irqrestore(&lock, flags); */
190
195
return 0 ;
191
196
}
@@ -315,6 +320,8 @@ static int video_receiver_event_fun(int type, void *data, void *private_data)
315
320
NULL );
316
321
vfq_init (& q_ready , AMLVIDEO_POOL_SIZE + 1 ,
317
322
& amlvideo_pool_ready [0 ]);
323
+ vfq_init (& q_omx , AMLVIDEO_POOL_SIZE + 1 ,
324
+ & amlvideo_pool_omx [0 ]);
318
325
}
319
326
}
320
327
return 0 ;
@@ -550,8 +557,34 @@ static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p)
550
557
static int vidioc_qbuf (struct file * file , void * priv , struct v4l2_buffer * p )
551
558
{
552
559
int ret = 0 ;
560
+ u32 index ;
553
561
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
+ }
554
586
return ret ;
587
+ }
555
588
556
589
if (ppmgrvf ) {
557
590
vf_put (ppmgrvf , RECEIVER_NAME );
@@ -633,8 +666,11 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
633
666
return - EAGAIN ;
634
667
}
635
668
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 ;
638
674
639
675
if (ppmgrvf -> pts_us64 ) {
640
676
first_frame = 1 ;
@@ -644,11 +680,27 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
644
680
pts_us64 = 0 ;
645
681
} else {
646
682
pts_us64 = last_pts_us64
647
- + (DUR2PTS (ppmgrvf -> duration ));
683
+ + (DUR2PTS (ppmgrvf -> duration )) * 100 / 9 ;
648
684
}
649
685
p -> timestamp .tv_sec = pts_us64 >> 32 ;
650
686
p -> timestamp .tv_usec = pts_us64 & 0xFFFFFFFF ;
651
687
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
+ }
652
704
return ret ;
653
705
}
654
706
if (ppmgrvf -> pts != 0 ) {
@@ -658,8 +710,8 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
658
710
ppmgrvf -> pts = timestamp_vpts_get ();
659
711
}
660
712
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 ;
663
715
664
716
if (unregFlag || startFlag ) {
665
717
if (ppmgrvf -> pts == 0 )
@@ -776,7 +828,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
776
828
{
777
829
int ret = 0 ;
778
830
779
- if (freerun_mode == 1 ) {
831
+ if (freerun_mode == 1 || freerun_mode == 3 ) {
780
832
/* pr_err("amlvideo dqbuf called freerun_mode=1\n"); */
781
833
ret = freerun_dqbuf (p );
782
834
} else if (freerun_mode == 2 ) {
0 commit comments