@@ -67,9 +67,11 @@ AMLVIDEO_MINOR_VERSION, AMLVIDEO_RELEASE)
67
67
68
68
#define AMLVIDEO_POOL_SIZE 16
69
69
static struct vfq_s q_ready ;
70
+ static struct vfq_s q_omx ;
70
71
/*extern bool omx_secret_mode;*/
71
72
static u8 first_frame ;
72
73
static u64 last_pts_us64 ;
74
+ static u32 omx_freerun_index = 0 ;
73
75
74
76
#define DUR2PTS (x ) ((x) - ((x) >> 4))
75
77
#define DUR2PTS_RM (x ) ((x) & 0xf)
@@ -149,9 +151,11 @@ static struct vivi_fmt formats[] = {
149
151
};
150
152
151
153
struct vframe_s * amlvideo_pool_ready [AMLVIDEO_POOL_SIZE + 1 ];
154
+ struct vframe_s * amlvideo_pool_omx [AMLVIDEO_POOL_SIZE + 1 ];
152
155
/* ------------------------------------------------------------------
153
156
* provider operations
154
157
*-----------------------------------------------------------------*/
158
+
155
159
static struct vframe_s * amlvideo_vf_peek (void * op_arg )
156
160
{
157
161
return vfq_peek (& q_ready );
@@ -187,10 +191,11 @@ static int amlvideo_vf_states(struct vframe_states *states, void *op_arg)
187
191
{
188
192
/* unsigned long flags; */
189
193
/* spin_lock_irqsave(&lock, flags); */
194
+ int avail_count = vfq_level (& q_ready ) + vfq_level (& q_omx );
190
195
states -> vf_pool_size = AMLVIDEO_POOL_SIZE ;
191
196
states -> buf_recycle_num = 0 ;
192
- states -> buf_free_num = AMLVIDEO_POOL_SIZE - vfq_level ( & q_ready ) ;
193
- states -> buf_avail_num = vfq_level ( & q_ready ) ;
197
+ states -> buf_free_num = AMLVIDEO_POOL_SIZE - avail_count ;
198
+ states -> buf_avail_num = avail_count ;
194
199
/* spin_unlock_irqrestore(&lock, flags); */
195
200
return 0 ;
196
201
}
@@ -329,6 +334,8 @@ static int video_receiver_event_fun(int type, void *data, void *private_data)
329
334
omx_secret_mode = true;
330
335
vfq_init (& q_ready , AMLVIDEO_POOL_SIZE + 1 ,
331
336
& amlvideo_pool_ready [0 ]);
337
+ vfq_init (& q_omx , AMLVIDEO_POOL_SIZE + 1 ,
338
+ & amlvideo_pool_omx [0 ]);
332
339
vf_provider_init (& amlvideo_vf_prov , PROVIDER_NAME ,
333
340
& amlvideo_vf_provider , NULL );
334
341
vf_reg_provider (& amlvideo_vf_prov );
@@ -577,8 +584,34 @@ static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p)
577
584
static int vidioc_qbuf (struct file * file , void * priv , struct v4l2_buffer * p )
578
585
{
579
586
int ret = 0 ;
587
+ u32 index ;
580
588
if (omx_secret_mode == true)
589
+ {
590
+ if (freerun_mode == 3 )
591
+ {
592
+ struct vframe_s * vf ;
593
+ while ((vf = vfq_peek (& q_omx )))
594
+ {
595
+ index = (u32 )vf -> pts_us64 ;
596
+ if (p -> index > index )
597
+ {
598
+ vf_put (vfq_pop (& q_omx ), RECEIVER_NAME );
599
+ printk ("vidioc_qbuf skip: index:%u:%u\n" , p -> index , index );
600
+ continue ;
601
+ }
602
+ else if (p -> index == index )
603
+ {
604
+ vf = (vfq_pop (& q_omx ));
605
+ if (p -> flags & V4L2_BUF_FLAG_DONE )
606
+ vf_put (vf , RECEIVER_NAME );
607
+ else
608
+ vfq_push (& q_ready , vf );
609
+ }
610
+ break ;
611
+ }
612
+ }
581
613
return ret ;
614
+ }
582
615
583
616
if (ppmgrvf ) {
584
617
vf_put (ppmgrvf , RECEIVER_NAME );
@@ -653,8 +686,11 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
653
686
return - EAGAIN ;
654
687
}
655
688
if (omx_secret_mode == true) {
656
- vfq_push (& q_ready , ppmgrvf );
657
- p -> index = 0 ;
689
+
690
+ //printk("%s, %s, %d %x %llx\n", __FILE__, __FUNCTION__, __LINE__, ppmgrvf->pts, ppmgrvf->pts_us64);
691
+
692
+ if (!ppmgrvf -> pts_us64 )
693
+ ppmgrvf -> pts_us64 = ((u64 )ppmgrvf -> pts * 100 ) / 9 ;
658
694
659
695
if (ppmgrvf -> pts_us64 ) {
660
696
first_frame = 1 ;
@@ -672,11 +708,21 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
672
708
p -> timecode .type = ppmgrvf -> width ;
673
709
p -> timecode .flags = ppmgrvf -> height ;
674
710
675
- vf_notify_receiver (
676
- PROVIDER_NAME ,
677
- VFRAME_EVENT_PROVIDER_VFRAME_READY ,
678
- NULL );
679
-
711
+ if (freerun_mode != 3 )
712
+ {
713
+ p -> index = 0 ;
714
+ vfq_push (& q_ready , ppmgrvf );
715
+ vf_notify_receiver (
716
+ PROVIDER_NAME ,
717
+ VFRAME_EVENT_PROVIDER_VFRAME_READY ,
718
+ NULL );
719
+ }
720
+ else
721
+ {
722
+ p -> index = omx_freerun_index ;
723
+ ppmgrvf -> pts_us64 = omx_freerun_index ++ ;
724
+ vfq_push (& q_omx , ppmgrvf );
725
+ }
680
726
return ret ;
681
727
}
682
728
if (ppmgrvf -> pts != 0 ) {
@@ -686,8 +732,8 @@ static int freerun_dqbuf(struct v4l2_buffer *p)
686
732
ppmgrvf -> pts = timestamp_vpts_get ();
687
733
}
688
734
689
- if (!ppmgrvf -> pts )
690
- ppmgrvf -> pts_us64 = ppmgrvf -> pts * 100 / 9 ;
735
+ if (!ppmgrvf -> pts_us64 )
736
+ ppmgrvf -> pts_us64 = (( u64 ) ppmgrvf -> pts * 100 ) / 9 ;
691
737
692
738
if (unregFlag || startFlag ) {
693
739
if (ppmgrvf -> pts == 0 )
@@ -804,7 +850,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
804
850
{
805
851
int ret = 0 ;
806
852
807
- if (freerun_mode == 1 ) {
853
+ if (freerun_mode == 1 || freerun_mode == 3 ) {
808
854
/* pr_err("amlvideo dqbuf called freerun_mode=1\n"); */
809
855
ret = freerun_dqbuf (p );
810
856
} else if (freerun_mode == 2 ) {
0 commit comments