Skip to contentSkip to conversation

media: staging/imx: fill vb2_v4l2_buffer sequence entry

PATCH Superseded Peter Seiderer 2 participants 2 messages Mar 14, 2018

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 media: staging/imx: fill vb2_v4l2_buffer sequence entry

Enables gstreamer v4l2src lost frame detection, e.g:

0:00:08.685185668 348 0x54f520 WARN v4l2src gstv4l2src.c:970:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 141 - ts: 0:00:08.330177332

---
Changes in v2:
- fill vb2_v4l2_buffer sequence entry in imx-ic-prpencvf too (suggested by Steve Longerbeam)

Changes in v3:
- add changelog (suggested by Greg Kroah-Hartman, Fabio Estevam and Dan Carpenter) and patch history
- use u32 (instead of __u32) (suggested by Dan Carpenter)
- let sequence counter start with zero, keeping v4l2-compliance testing happy (needs additional setting of field to a valid value, patch will follow soon)

---
 drivers/staging/media/imx/imx-ic-prpencvf.c | 5 +++++
 drivers/staging/media/imx/imx-media-csi.c   | 5 +++++
 2 files changed, 10 insertions(+)
drivers/staging/media/imx/imx-ic-prpencvf.c +5 -0
index ae453fd422f0..274683d2d4ba 100644
@@ -103,6 +103,7 @@ struct prp_priv {
 	int nfb4eof_irq;
 
 	int stream_count;
+	u32 frame_sequence; /* frame sequence counter */
 	bool last_eof;  /* waiting for last EOF at stream off */
 	bool nfb4eof;    /* NFB4EOF encountered during streaming */
 	struct completion last_eof_comp;
@@ -208,8 +209,11 @@ static void prp_vb2_buf_done(struct prp_priv *priv, struct ipuv3_channel *ch)
 	struct vb2_buffer *vb;
 	dma_addr_t phys;
 
+	priv->frame_sequence++;
+
 	done = priv->active_vb2_buf[priv->ipu_buf_num];
 	if (done) {
+		done->vbuf.sequence = priv->frame_sequence;
 		vb = &done->vbuf.vb2_buf;
 		vb->timestamp = ktime_get_ns();
 		vb2_buffer_done(vb, priv->nfb4eof ?
@@ -637,6 +641,7 @@ static int prp_start(struct prp_priv *priv)
 
 	/* init EOF completion waitq */
 	init_completion(&priv->last_eof_comp);
+	priv->frame_sequence = -1;
 	priv->last_eof = false;
 	priv->nfb4eof = false;
 
drivers/staging/media/imx/imx-media-csi.c +5 -0
index 5a195f80a24d..161a92946a86 100644
@@ -111,6 +111,7 @@ struct csi_priv {
 	struct v4l2_ctrl_handler ctrl_hdlr;
 
 	int stream_count; /* streaming counter */
+	u32 frame_sequence; /* frame sequence counter */
 	bool last_eof;   /* waiting for last EOF at stream off */
 	bool nfb4eof;    /* NFB4EOF encountered during streaming */
 	struct completion last_eof_comp;
@@ -234,8 +235,11 @@ static void csi_vb2_buf_done(struct csi_priv *priv)
 	struct vb2_buffer *vb;
 	dma_addr_t phys;
 
+	priv->frame_sequence++;
+
 	done = priv->active_vb2_buf[priv->ipu_buf_num];
 	if (done) {
+		done->vbuf.sequence = priv->frame_sequence;
 		vb = &done->vbuf.vb2_buf;
 		vb->timestamp = ktime_get_ns();
 		vb2_buffer_done(vb, priv->nfb4eof ?
@@ -543,6 +547,7 @@ static int csi_idmac_start(struct csi_priv *priv)
 
 	/* init EOF completion waitq */
 	init_completion(&priv->last_eof_comp);
+	priv->frame_sequence = -1;
 	priv->last_eof = false;
 	priv->nfb4eof = false;
 
Signature · 6 lines
2.16.2

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
maintainer
#1 lore raw

Hi Peter,

Quoted 10 lines · Peter Seiderer

Enables gstreamer v4l2src lost frame detection, e.g:

   0:00:08.685185668  348  0x54f520 WARN  v4l2src gstv4l2src.c:970:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 141 - ts: 0:00:08.330177332

---
Changes in v2:
- fill vb2_v4l2_buffer sequence entry in imx-ic-prpencvf too (suggested by Steve Longerbeam)

Quoted 5 lines

Changes in v3:
- add changelog (suggested by Greg Kroah-Hartman, Fabio Estevam and Dan Carpenter) and patch history
- use u32 (instead of __u32) (suggested by Dan Carpenter)
- let sequence counter start with zero,

There's no need to initialize (unsigned) priv->frame_sequence to -1. Just increment it _after_ the "if (done) {...}" block instead of before.

Steve

Quoted 65 lines

keeping v4l2-compliance
testing happy (needs additional setting of field to a valid value, patch will follow soon)

---
  drivers/staging/media/imx/imx-ic-prpencvf.c | 5 +++++
  drivers/staging/media/imx/imx-media-csi.c   | 5 +++++
  2 files changed, 10 insertions(+)
drivers/staging/media/imx/imx-ic-prpencvf.c +5 -0
index ae453fd422f0..274683d2d4ba 100644
@@ -103,6 +103,7 @@ struct prp_priv {
  	int nfb4eof_irq;
 
  	int stream_count;
+	u32 frame_sequence; /* frame sequence counter */
  	bool last_eof;  /* waiting for last EOF at stream off */
  	bool nfb4eof;    /* NFB4EOF encountered during streaming */
  	struct completion last_eof_comp;
@@ -208,8 +209,11 @@ static void prp_vb2_buf_done(struct prp_priv *priv, struct ipuv3_channel *ch)
  	struct vb2_buffer *vb;
  	dma_addr_t phys;
 
+	priv->frame_sequence++;
+
  	done = priv->active_vb2_buf[priv->ipu_buf_num];
  	if (done) {
+		done->vbuf.sequence = priv->frame_sequence;
  		vb = &done->vbuf.vb2_buf;
  		vb->timestamp = ktime_get_ns();
  		vb2_buffer_done(vb, priv->nfb4eof ?
@@ -637,6 +641,7 @@ static int prp_start(struct prp_priv *priv)
 
  	/* init EOF completion waitq */
  	init_completion(&priv->last_eof_comp);
+	priv->frame_sequence = -1;
  	priv->last_eof = false;
  	priv->nfb4eof = false;
 
drivers/staging/media/imx/imx-media-csi.c +4 -0
index 5a195f80a24d..161a92946a86 100644
@@ -111,6 +111,7 @@ struct csi_priv {
  	struct v4l2_ctrl_handler ctrl_hdlr;
 
  	int stream_count; /* streaming counter */
+	u32 frame_sequence; /* frame sequence counter */
  	bool last_eof;   /* waiting for last EOF at stream off */
  	bool nfb4eof;    /* NFB4EOF encountered during streaming */
  	struct completion last_eof_comp;
@@ -234,8 +235,11 @@ static void csi_vb2_buf_done(struct csi_priv *priv)
  	struct vb2_buffer *vb;
  	dma_addr_t phys;
 
+	priv->frame_sequence++;
+
  	done = priv->active_vb2_buf[priv->ipu_buf_num];
  	if (done) {
+		done->vbuf.sequence = priv->frame_sequence;
  		vb = &done->vbuf.vb2_buf;
  		vb->timestamp = ktime_get_ns();
  		vb2_buffer_done(vb, priv->nfb4eof ?

drivers/staging/media/imx/imx-media-csi.c static int csi_idmac_start(struct csi_priv *priv) · line 553

Quoted 7 lines
drivers/staging/media/imx/imx-media-csi.c +1 -0
@@ -543,6 +547,7 @@ static int csi_idmac_start(struct csi_priv *priv)
 
  	/* init EOF completion waitq */
  	init_completion(&priv->last_eof_comp);
+	priv->frame_sequence = -1;
  	priv->last_eof = false;
  	priv->nfb4eof = false;
 

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel