Skip to contentSkip to conversation

big rework of TS for saa7134

PATCH In review Dmitri Belimov 3 participants 8 messages Apr 28, 2009 – May 28, 2009 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 big rework of TS for saa7134

Hi all.

1. Add start/stop TS function.
2. Move setup DMA of TS to DMA function.
3. Write support cupture via MMAP
4. Rework startup and finish process, remove simple FSM.

This is patch from our customer. I checked this.

linux/drivers/media/video/saa7134/saa7134-cards.c +2 -0
diff -r b40d628f830d linux/drivers/media/video/saa7134/saa7134-cards.c
@@ -4205,6 +4205,7 @@
 		/* Igor Kuznetsov <[email protected]> */
 		/* Andrey Melnikoff <[email protected]> */
 		/* Beholder Intl. Ltd. Dmitry Belimov <[email protected]> */
+		/* Alexey Osipov <[email protected]> */
 		.name           = "Beholder BeholdTV M6",
 		.audio_clock    = 0x00187de7,
 		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
@@ -4279,6 +4280,7 @@
 		/* Igor Kuznetsov <[email protected]> */
 		/* Andrey Melnikoff <[email protected]> */
 		/* Beholder Intl. Ltd. Dmitry Belimov <[email protected]> */
+		/* Alexey Osipov <[email protected]> */
 		.name           = "Beholder BeholdTV M6 Extra",
 		.audio_clock    = 0x00187de7,
 		/* FIXME: Must be PHILIPS_FM1216ME_MK5*/
linux/drivers/media/video/saa7134/saa7134-core.c +15 -0
diff -r b40d628f830d linux/drivers/media/video/saa7134/saa7134-core.c
@@ -380,6 +380,10 @@
 		dprintk("buffer_next %p\n",NULL);
 		saa7134_set_dmabits(dev);
 		del_timer(&q->timeout);
+		
+		if (card_has_mpeg(dev))
+		    if (dev->ts_started)
+			saa7134_ts_stop(dev);
 	}
 }
 
@@ -465,6 +469,17 @@
 		ctrl |= SAA7134_MAIN_CTRL_TE5;
 		irq  |= SAA7134_IRQ1_INTE_RA2_1 |
 			SAA7134_IRQ1_INTE_RA2_0;
+		
+		/* dma: setup channel 5 (= TS) */
+
+		saa_writeb(SAA7134_TS_DMA0, (dev->ts.nr_packets - 1) & 0xff);
+		saa_writeb(SAA7134_TS_DMA1, ((dev->ts.nr_packets - 1) >> 8) & 0xff);
+		/* TSNOPIT=0, TSCOLAP=0 */
+		saa_writeb(SAA7134_TS_DMA2, (((dev->ts.nr_packets - 1) >> 16) & 0x3f) | 0x00);
+		saa_writel(SAA7134_RS_PITCH(5), TS_PACKET_SIZE);
+		saa_writel(SAA7134_RS_CONTROL(5),  SAA7134_RS_CONTROL_BURST_16 |
+						   SAA7134_RS_CONTROL_ME |
+						  (dev->ts.pt_ts.dma >> 12));
 	}
 
 	/* set task conditions + field handling */
linux/drivers/media/video/saa7134/saa7134-empress.c +11 -3
diff -r b40d628f830d linux/drivers/media/video/saa7134/saa7134-empress.c
@@ -255,6 +255,16 @@
 	return 0;
 }
 
+static int empress_try_fmt_vid_cap(struct file *file, void *priv,
+				struct v4l2_format *f)
+{
+	struct saa7134_dev *dev = file->private_data;
+
+	f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+	f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
+
+	return 0;
+}
 
 static int empress_reqbufs(struct file *file, void *priv,
 					struct v4l2_requestbuffers *p)
@@ -450,6 +460,7 @@
 static const struct v4l2_ioctl_ops ts_ioctl_ops = {
 	.vidioc_querycap		= empress_querycap,
 	.vidioc_enum_fmt_vid_cap	= empress_enum_fmt_vid_cap,
+	.vidioc_try_fmt_vid_cap		= empress_try_fmt_vid_cap,
 	.vidioc_s_fmt_vid_cap		= empress_s_fmt_vid_cap,
 	.vidioc_g_fmt_vid_cap		= empress_g_fmt_vid_cap,
 	.vidioc_reqbufs			= empress_reqbufs,
@@ -499,11 +510,8 @@
 
 	if (dev->nosignal) {
 		dprintk("no video signal\n");
-		ts_reset_encoder(dev);
 	} else {
 		dprintk("video signal acquired\n");
-		if (atomic_read(&dev->empress_users))
-			ts_init_encoder(dev);
 	}
 }
 
linux/drivers/media/video/saa7134/saa7134-ts.c +69 -53

179 lines not on this page · raw message

linux/drivers/media/video/saa7134/saa7134.h +5 -8
diff -r b40d628f830d linux/drivers/media/video/saa7134/saa7134.h
@@ -367,6 +367,7 @@
 #define INTERLACE_OFF          2
 
 #define BUFFER_TIMEOUT     msecs_to_jiffies(500)  /* 0.5 seconds */
+#define TS_BUFFER_TIMEOUT  msecs_to_jiffies(1000)  /* 1 second */
 
 struct saa7134_dev;
 struct saa7134_dma;
@@ -487,12 +488,6 @@
 	void                       (*signal_change)(struct saa7134_dev *dev);
 };
 
-enum saa7134_ts_status {
-	SAA7134_TS_STOPPED,
-	SAA7134_TS_BUFF_DONE,
-	SAA7134_TS_STARTED,
-};
-
 /* global device status */
 struct saa7134_dev {
 	struct list_head           devlist;
@@ -587,8 +582,7 @@
 	/* SAA7134_MPEG_* */
 	struct saa7134_ts          ts;
 	struct saa7134_dmaqueue    ts_q;
-	enum saa7134_ts_status 	   ts_state;
-	unsigned int 		   buff_cnt;
+	int                        ts_started;
 	struct saa7134_mpeg_ops    *mops;
 
 	/* SAA7134_MPEG_EMPRESS only */
@@ -746,6 +740,9 @@
 
 int saa7134_ts_init_hw(struct saa7134_dev *dev);
 
+int saa7134_ts_start(struct saa7134_dev *dev);
+int saa7134_ts_stop(struct saa7134_dev *dev);
+
 /* ----------------------------------------------------------- */
 /* saa7134-vbi.c                                               */
 

With my best regards, Dmitry.

linux/drivers/media/video/saa7134/saa7134-cards.c +2 -0
diff -r b40d628f830d linux/drivers/media/video/saa7134/saa7134-cards.c
@@ -4205,6 +4205,7 @@
 		/* Igor Kuznetsov <[email protected]> */
 		/* Andrey Melnikoff <[email protected]> */
 		/* Beholder Intl. Ltd. Dmitry Belimov <[email protected]> */
+		/* Alexey Osipov <[email protected]> */
 		.name           = "Beholder BeholdTV M6",
 		.audio_clock    = 0x00187de7,
 		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
@@ -4279,6 +4280,7 @@
 		/* Igor Kuznetsov <[email protected]> */
 		/* Andrey Melnikoff <[email protected]> */
 		/* Beholder Intl. Ltd. Dmitry Belimov <[email protected]> */
+		/* Alexey Osipov <[email protected]> */
 		.name           = "Beholder BeholdTV M6 Extra",
 		.audio_clock    = 0x00187de7,
 		/* FIXME: Must be PHILIPS_FM1216ME_MK5*/
linux/drivers/media/video/saa7134/saa7134-core.c +15 -0
diff -r b40d628f830d linux/drivers/media/video/saa7134/saa7134-core.c
@@ -380,6 +380,10 @@
 		dprintk("buffer_next %p\n",NULL);
 		saa7134_set_dmabits(dev);
 		del_timer(&q->timeout);
+		
+		if (card_has_mpeg(dev))
+		    if (dev->ts_started)
+			saa7134_ts_stop(dev);
 	}
 }
 
@@ -465,6 +469,17 @@
 		ctrl |= SAA7134_MAIN_CTRL_TE5;
 		irq  |= SAA7134_IRQ1_INTE_RA2_1 |
 			SAA7134_IRQ1_INTE_RA2_0;
+		
+		/* dma: setup channel 5 (= TS) */
+
+		saa_writeb(SAA7134_TS_DMA0, (dev->ts.nr_packets - 1) & 0xff);
+		saa_writeb(SAA7134_TS_DMA1, ((dev->ts.nr_packets - 1) >> 8) & 0xff);
+		/* TSNOPIT=0, TSCOLAP=0 */
+		saa_writeb(SAA7134_TS_DMA2, (((dev->ts.nr_packets - 1) >> 16) & 0x3f) | 0x00);
+		saa_writel(SAA7134_RS_PITCH(5), TS_PACKET_SIZE);
+		saa_writel(SAA7134_RS_CONTROL(5),  SAA7134_RS_CONTROL_BURST_16 |
+						   SAA7134_RS_CONTROL_ME |
+						  (dev->ts.pt_ts.dma >> 12));
 	}
 
 	/* set task conditions + field handling */
linux/drivers/media/video/saa7134/saa7134-empress.c +11 -3
diff -r b40d628f830d linux/drivers/media/video/saa7134/saa7134-empress.c
@@ -255,6 +255,16 @@
 	return 0;
 }
 
+static int empress_try_fmt_vid_cap(struct file *file, void *priv,
+				struct v4l2_format *f)
+{
+	struct saa7134_dev *dev = file->private_data;
+
+	f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+	f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
+
+	return 0;
+}
 
 static int empress_reqbufs(struct file *file, void *priv,
 					struct v4l2_requestbuffers *p)
@@ -450,6 +460,7 @@
 static const struct v4l2_ioctl_ops ts_ioctl_ops = {
 	.vidioc_querycap		= empress_querycap,
 	.vidioc_enum_fmt_vid_cap	= empress_enum_fmt_vid_cap,
+	.vidioc_try_fmt_vid_cap		= empress_try_fmt_vid_cap,
 	.vidioc_s_fmt_vid_cap		= empress_s_fmt_vid_cap,
 	.vidioc_g_fmt_vid_cap		= empress_g_fmt_vid_cap,
 	.vidioc_reqbufs			= empress_reqbufs,
@@ -499,11 +510,8 @@
 
 	if (dev->nosignal) {
 		dprintk("no video signal\n");
-		ts_reset_encoder(dev);
 	} else {
 		dprintk("video signal acquired\n");
-		if (atomic_read(&dev->empress_users))
-			ts_init_encoder(dev);
 	}
 }
 
linux/drivers/media/video/saa7134/saa7134-ts.c +69 -53

179 lines not on this page · raw message

linux/drivers/media/video/saa7134/saa7134.h +5 -8
diff -r b40d628f830d linux/drivers/media/video/saa7134/saa7134.h
@@ -367,6 +367,7 @@
 #define INTERLACE_OFF          2
 
 #define BUFFER_TIMEOUT     msecs_to_jiffies(500)  /* 0.5 seconds */
+#define TS_BUFFER_TIMEOUT  msecs_to_jiffies(1000)  /* 1 second */
 
 struct saa7134_dev;
 struct saa7134_dma;
@@ -487,12 +488,6 @@
 	void                       (*signal_change)(struct saa7134_dev *dev);
 };
 
-enum saa7134_ts_status {
-	SAA7134_TS_STOPPED,
-	SAA7134_TS_BUFF_DONE,
-	SAA7134_TS_STARTED,
-};
-
 /* global device status */
 struct saa7134_dev {
 	struct list_head           devlist;
@@ -587,8 +582,7 @@
 	/* SAA7134_MPEG_* */
 	struct saa7134_ts          ts;
 	struct saa7134_dmaqueue    ts_q;
-	enum saa7134_ts_status 	   ts_state;
-	unsigned int 		   buff_cnt;
+	int                        ts_started;
 	struct saa7134_mpeg_ops    *mops;
 
 	/* SAA7134_MPEG_EMPRESS only */
@@ -746,6 +740,9 @@
 
 int saa7134_ts_init_hw(struct saa7134_dev *dev);
 
+int saa7134_ts_start(struct saa7134_dev *dev);
+int saa7134_ts_stop(struct saa7134_dev *dev);
+
 /* ----------------------------------------------------------- */
 /* saa7134-vbi.c                                               */
 
#1 lore raw

Em Tue, 28 Apr 2009 19:52:00 +1000
Dmitri Belimov <[email protected]> escreveu:

Quoted 8 lines

Hi all.

1. Add start/stop TS function.
2. Move setup DMA of TS to DMA function.
3. Write support cupture via MMAP
4. Rework startup and finish process, remove simple FSM.

This is patch from our customer. I checked this.

Dmitri,

Could you please re-send this patch, this time with your SOB?

Cheers,
Mauro

#2 lore raw

Hi,

Am Montag, den 11.05.2009, 19:37 -0300 schrieb Mauro Carvalho Chehab:

Quoted 12 lines

Em Tue, 28 Apr 2009 19:52:00 +1000
Dmitri Belimov <[email protected]> escreveu:

Quoted 8 lines

Hi all.

1. Add start/stop TS function.
2. Move setup DMA of TS to DMA function.
3. Write support cupture via MMAP
4. Rework startup and finish process, remove simple FSM.

This is patch from our customer. I checked this.

Quoted 8 lines

Dmitri,

Could you please re-send this patch, this time with your SOB?

Cheers,
Mauro

Did you check it is still OK for DVB-T and DVB-S also?

I did not yet and it is just a note and I hope to retire once.

Cheers,
Hermann

#3 lore raw

Hi

Quoted 18 lines

Hi,

Am Montag, den 11.05.2009, 19:37 -0300 schrieb Mauro Carvalho Chehab:

Quoted 15 lines

Em Tue, 28 Apr 2009 19:52:00 +1000
Dmitri Belimov <[email protected]> escreveu:

Quoted 8 lines

Hi all.

1. Add start/stop TS function.
2. Move setup DMA of TS to DMA function.
3. Write support cupture via MMAP
4. Rework startup and finish process, remove simple FSM.

This is patch from our customer. I checked this.

Dmitri,

Could you please re-send this patch, this time with your SOB?

Ok

Quoted 4 lines
Quoted 2 lines

Cheers,
Mauro

Did you check it is still OK for DVB-T and DVB-S also?

No. We tested only with analog TV, capturing from analog TV and composite input. It support serial and parallel TS from MPEG encoder to saa7134.

Quoted 1 line

I did not yet and it is just a note and I hope to retire once.

Ok. It will be good.

With my best regards, Dmitry.

Quoted 5 lines

Cheers,
Hermann

#4 lore raw

Em Mon, 11 May 2009 20:21:23 +1000
Dmitri Belimov <[email protected]> escreveu:

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Cheers,
Mauro

Did you check it is still OK for DVB-T and DVB-S also?

No. We tested only with analog TV, capturing from analog TV and composite input. It support serial and parallel TS from MPEG encoder to saa7134.

Since the patch touched on saa7134-ts, it is important to check if it will not cause regressions with DVB. Could you please test it?

Quoted 1 line

Cheers,
Mauro

#5 lore raw

Hi

Quoted 6 lines

Em Mon, 11 May 2009 20:21:23 +1000
Dmitri Belimov <[email protected]> escreveu:

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

Cheers,
Mauro

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Did you check it is still OK for DVB-T and DVB-S also?

No. We tested only with analog TV, capturing from analog TV and composite input. It support serial and parallel TS from MPEG encoder to saa7134.

Since the patch touched on saa7134-ts, it is important to check if it will not cause regressions with DVB. Could you please test it?

Ok. I'll do it with our customers. In my place hasn't any DVB channels.

With my best regards, Dmitry.

Quoted 2 lines

Cheers,
Mauro

Tested-by
#6 lore raw

Hi,

Am Montag, den 11.05.2009, 21:01 +1000 schrieb Dmitri Belimov:

Quoted 10 lines

Hi

Quoted 8 lines

Em Mon, 11 May 2009 20:21:23 +1000
Dmitri Belimov <[email protected]> escreveu:

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

Cheers,
Mauro

Did you check it is still OK for DVB-T and DVB-S also?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

No. We tested only with analog TV, capturing from analog TV and composite input. It support serial and parallel TS from MPEG encoder to saa7134.

Since the patch touched on saa7134-ts, it is important to check if it will not cause regressions with DVB. Could you please test it?

Ok. I'll do it with our customers. In my place hasn't any DVB channels.

Dmitry, the patches from your RESEND don't apply anymore, since already two of your previous patches, still present in this set, are now in v4l-dvb.

I did apply manually. Also you did not run "make checkpatch" and I tried to fix a bunch of coding style errors and warnings from it.

Please review the attached version and consider to use it for a RESEND v2. More testers welcome, also for DVB serial TS and ATSC.

For DVB parallel TS.

Cheers,
Hermann

Quoted 4 lines

With my best regards, Dmitry.

Quoted 2 lines

Cheers,
Mauro

linux/drivers/media/video/saa7134/saa7134-cards.c +2 -0
diff -r 8d37e8505664 linux/drivers/media/video/saa7134/saa7134-cards.c
@@ -4495,6 +4495,7 @@
 		/* Igor Kuznetsov <[email protected]> */
 		/* Andrey Melnikoff <[email protected]> */
 		/* Beholder Intl. Ltd. Dmitry Belimov <[email protected]> */
+		/* Alexey Osipov <[email protected]> */
 		.name           = "Beholder BeholdTV M6",
 		.audio_clock    = 0x00187de7,
 		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
@@ -4569,6 +4570,7 @@
 		/* Igor Kuznetsov <[email protected]> */
 		/* Andrey Melnikoff <[email protected]> */
 		/* Beholder Intl. Ltd. Dmitry Belimov <[email protected]> */
+		/* Alexey Osipov <[email protected]> */
 		.name           = "Beholder BeholdTV M6 Extra",
 		.audio_clock    = 0x00187de7,
 		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3, /* FIXME to MK5 */
linux/drivers/media/video/saa7134/saa7134-core.c +17 -0
diff -r 8d37e8505664 linux/drivers/media/video/saa7134/saa7134-core.c
@@ -380,6 +380,10 @@
 		dprintk("buffer_next %p\n",NULL);
 		saa7134_set_dmabits(dev);
 		del_timer(&q->timeout);
+
+		if (card_has_mpeg(dev))
+			if (dev->ts_started)
+				saa7134_ts_stop(dev);
 	}
 }
 
@@ -465,6 +469,19 @@
 		ctrl |= SAA7134_MAIN_CTRL_TE5;
 		irq  |= SAA7134_IRQ1_INTE_RA2_1 |
 			SAA7134_IRQ1_INTE_RA2_0;
+
+		/* dma: setup channel 5 (= TS) */
+
+		saa_writeb(SAA7134_TS_DMA0, (dev->ts.nr_packets - 1) & 0xff);
+		saa_writeb(SAA7134_TS_DMA1,
+			((dev->ts.nr_packets - 1) >> 8) & 0xff);
+		/* TSNOPIT=0, TSCOLAP=0 */
+		saa_writeb(SAA7134_TS_DMA2,
+			(((dev->ts.nr_packets - 1) >> 16) & 0x3f) | 0x00);
+		saa_writel(SAA7134_RS_PITCH(5), TS_PACKET_SIZE);
+		saa_writel(SAA7134_RS_CONTROL(5), SAA7134_RS_CONTROL_BURST_16 |
+						  SAA7134_RS_CONTROL_ME |
+						  (dev->ts.pt_ts.dma >> 12));
 	}
 
 	/* set task conditions + field handling */
linux/drivers/media/video/saa7134/saa7134-empress.c +11 -0
diff -r 8d37e8505664 linux/drivers/media/video/saa7134/saa7134-empress.c
@@ -255,6 +255,16 @@
 	return 0;
 }
 
+static int empress_try_fmt_vid_cap(struct file *file, void *priv,
+				struct v4l2_format *f)
+{
+	struct saa7134_dev *dev = file->private_data;
+
+	f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+	f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
+
+	return 0;
+}
 
 static int empress_reqbufs(struct file *file, void *priv,
 					struct v4l2_requestbuffers *p)
@@ -450,6 +460,7 @@
 static const struct v4l2_ioctl_ops ts_ioctl_ops = {
 	.vidioc_querycap		= empress_querycap,
 	.vidioc_enum_fmt_vid_cap	= empress_enum_fmt_vid_cap,
+	.vidioc_try_fmt_vid_cap		= empress_try_fmt_vid_cap,
 	.vidioc_s_fmt_vid_cap		= empress_s_fmt_vid_cap,
 	.vidioc_g_fmt_vid_cap		= empress_g_fmt_vid_cap,
 	.vidioc_reqbufs			= empress_reqbufs,
linux/drivers/media/video/saa7134/saa7134-ts.c +66 -54

182 lines not on this page · raw message

linux/drivers/media/video/saa7134/saa7134.h +4 -8
diff -r 8d37e8505664 linux/drivers/media/video/saa7134/saa7134.h
@@ -498,12 +498,6 @@
 	void                       (*signal_change)(struct saa7134_dev *dev);
 };
 
-enum saa7134_ts_status {
-	SAA7134_TS_STOPPED,
-	SAA7134_TS_BUFF_DONE,
-	SAA7134_TS_STARTED,
-};
-
 /* global device status */
 struct saa7134_dev {
 	struct list_head           devlist;
@@ -598,8 +592,7 @@
 	/* SAA7134_MPEG_* */
 	struct saa7134_ts          ts;
 	struct saa7134_dmaqueue    ts_q;
-	enum saa7134_ts_status 	   ts_state;
-	unsigned int 		   buff_cnt;
+	int                        ts_started;
 	struct saa7134_mpeg_ops    *mops;
 
 	/* SAA7134_MPEG_EMPRESS only */
@@ -757,6 +750,9 @@
 
 int saa7134_ts_init_hw(struct saa7134_dev *dev);
 
+int saa7134_ts_start(struct saa7134_dev *dev);
+int saa7134_ts_stop(struct saa7134_dev *dev);
+
 /* ----------------------------------------------------------- */
 /* saa7134-vbi.c                                               */
 
#7 lore raw

Hi

Quoted 24 lines

Hi,

Am Montag, den 11.05.2009, 21:01 +1000 schrieb Dmitri Belimov:

Quoted 14 lines

Hi

Quoted 12 lines

Em Mon, 11 May 2009 20:21:23 +1000
Dmitri Belimov <[email protected]> escreveu:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Cheers,
Mauro

Did you check it is still OK for DVB-T and DVB-S also?

No. We tested only with analog TV, capturing from analog TV and composite input. It support serial and parallel TS from MPEG encoder to saa7134.

Quoted 6 lines
Quoted 3 lines

Since the patch touched on saa7134-ts, it is important to check if it will not cause regressions with DVB. Could you please test it?

Ok. I'll do it with our customers. In my place hasn't any DVB channels.

Quoted 6 lines

Dmitry, the patches from your RESEND don't apply anymore, since already two of your previous patches, still present in this set, are now in v4l-dvb.

I did apply manually. Also you did not run "make checkpatch" and I tried to fix a bunch of coding style errors and warnings from it.

Sorry. This is my error.

Quoted 5 lines

Please review the attached version and consider to use it for a RESEND v2. More testers welcome, also for DVB serial TS and ATSC.

For DVB parallel TS.

Our customer test this patch with our TV card and DVB-T, no any regression. Today I'll resend this patch.

With my best regards, Dmitry.