Commit 92c36147 authored by Dmitry Belimov's avatar Dmitry Belimov Committed by Mauro Carvalho Chehab

V4L/DVB (8797): A simple state machine was added to saa7134_ts.

A simple state machine was added to saa7134_ts. It has three states:

        SAA7134_TS_STOPPED
        SAA7134_TS_BUFF_DONE
        SAA7134_TS_STARTED

When buffer_setup is run we start the TS initialization: set SAA7134_TS_STOPPED.
When all buffers are prepared we write data into DMA register and set
SAA7134_TS_BUFF_DONE.
When the first buffer is active start TS and set SAA7134_TS_STARTED.
When ts_release is called stop TS and set SAA7134_TS_STOPPED.
Signed-off-by: default avatarBeholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8809b9cc
...@@ -66,6 +66,24 @@ static int buffer_activate(struct saa7134_dev *dev, ...@@ -66,6 +66,24 @@ static int buffer_activate(struct saa7134_dev *dev,
saa7134_set_dmabits(dev); saa7134_set_dmabits(dev);
mod_timer(&dev->ts_q.timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&dev->ts_q.timeout, jiffies+BUFFER_TIMEOUT);
if (dev->ts_state == SAA7134_TS_BUFF_DONE) {
/* Clear TS cache */
dev->buff_cnt = 0;
saa_writeb(SAA7134_TS_SERIAL1, 0x00);
saa_writeb(SAA7134_TS_SERIAL1, 0x03);
saa_writeb(SAA7134_TS_SERIAL1, 0x00);
saa_writeb(SAA7134_TS_SERIAL1, 0x01);
/* TS clock non-inverted */
saa_writeb(SAA7134_TS_SERIAL1, 0x00);
/* Start TS stream */
saa_writeb(SAA7134_TS_SERIAL0, 0x40);
saa_writeb(SAA7134_TS_PARALLEL, 0xEC);
dev->ts_state = SAA7134_TS_STARTED;
}
return 0; return 0;
} }
...@@ -110,16 +128,22 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, ...@@ -110,16 +128,22 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
goto oops; goto oops;
} }
dev->buff_cnt++;
if (dev->buff_cnt == dev->ts.nr_bufs) {
dev->ts_state = SAA7134_TS_BUFF_DONE;
/* dma: setup channel 5 (= TS) */ /* dma: setup channel 5 (= TS) */
control = SAA7134_RS_CONTROL_BURST_16 | control = SAA7134_RS_CONTROL_BURST_16 |
SAA7134_RS_CONTROL_ME | SAA7134_RS_CONTROL_ME |
(buf->pt->dma >> 12); (buf->pt->dma >> 12);
saa_writeb(SAA7134_TS_DMA0, ((lines-1)&0xff)); saa_writeb(SAA7134_TS_DMA0, (lines - 1) & 0xff);
saa_writeb(SAA7134_TS_DMA1, (((lines-1)>>8)&0xff)); saa_writeb(SAA7134_TS_DMA1, ((lines - 1) >> 8) & 0xff);
saa_writeb(SAA7134_TS_DMA2, ((((lines-1)>>16)&0x3f) | 0x00)); /* TSNOPIT=0, TSCOLAP=0 */ /* TSNOPIT=0, TSCOLAP=0 */
saa_writel(SAA7134_RS_PITCH(5),TS_PACKET_SIZE); saa_writeb(SAA7134_TS_DMA2, (((lines - 1) >> 16) & 0x3f) | 0x00);
saa_writel(SAA7134_RS_CONTROL(5),control); saa_writel(SAA7134_RS_PITCH(5), TS_PACKET_SIZE);
saa_writel(SAA7134_RS_CONTROL(5), control);
}
buf->vb.state = VIDEOBUF_PREPARED; buf->vb.state = VIDEOBUF_PREPARED;
buf->activate = buffer_activate; buf->activate = buffer_activate;
...@@ -140,6 +164,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) ...@@ -140,6 +164,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
if (0 == *count) if (0 == *count)
*count = dev->ts.nr_bufs; *count = dev->ts.nr_bufs;
*count = saa7134_buffer_count(*size,*count); *count = saa7134_buffer_count(*size,*count);
dev->buff_cnt = 0;
dev->ts_state = SAA7134_TS_STOPPED;
return 0; return 0;
} }
...@@ -154,7 +180,13 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) ...@@ -154,7 +180,13 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{ {
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
struct saa7134_dev *dev = q->priv_data;
if (dev->ts_state == SAA7134_TS_STARTED) {
/* Stop TS transport */
saa_writeb(SAA7134_TS_PARALLEL, 0x6c);
dev->ts_state = SAA7134_TS_STOPPED;
}
saa7134_dma_free(q,buf); saa7134_dma_free(q,buf);
} }
...@@ -182,7 +214,7 @@ int saa7134_ts_init_hw(struct saa7134_dev *dev) ...@@ -182,7 +214,7 @@ int saa7134_ts_init_hw(struct saa7134_dev *dev)
/* deactivate TS softreset */ /* deactivate TS softreset */
saa_writeb(SAA7134_TS_SERIAL1, 0x00); saa_writeb(SAA7134_TS_SERIAL1, 0x00);
/* TSSOP high active, TSVAL high active, TSLOCK ignored */ /* TSSOP high active, TSVAL high active, TSLOCK ignored */
saa_writeb(SAA7134_TS_PARALLEL, 0xec); saa_writeb(SAA7134_TS_PARALLEL, 0x6c);
saa_writeb(SAA7134_TS_PARALLEL_SERIAL, (TS_PACKET_SIZE-1)); saa_writeb(SAA7134_TS_PARALLEL_SERIAL, (TS_PACKET_SIZE-1));
saa_writeb(SAA7134_TS_DMA0, ((dev->ts.nr_packets-1)&0xff)); saa_writeb(SAA7134_TS_DMA0, ((dev->ts.nr_packets-1)&0xff));
saa_writeb(SAA7134_TS_DMA1, (((dev->ts.nr_packets-1)>>8)&0xff)); saa_writeb(SAA7134_TS_DMA1, (((dev->ts.nr_packets-1)>>8)&0xff));
......
...@@ -462,6 +462,12 @@ struct saa7134_mpeg_ops { ...@@ -462,6 +462,12 @@ struct saa7134_mpeg_ops {
void (*signal_change)(struct saa7134_dev *dev); void (*signal_change)(struct saa7134_dev *dev);
}; };
enum saa7134_ts_status {
SAA7134_TS_STOPPED,
SAA7134_TS_BUFF_DONE,
SAA7134_TS_STARTED,
};
/* global device status */ /* global device status */
struct saa7134_dev { struct saa7134_dev {
struct list_head devlist; struct list_head devlist;
...@@ -555,6 +561,8 @@ struct saa7134_dev { ...@@ -555,6 +561,8 @@ struct saa7134_dev {
/* SAA7134_MPEG_* */ /* SAA7134_MPEG_* */
struct saa7134_ts ts; struct saa7134_ts ts;
struct saa7134_dmaqueue ts_q; struct saa7134_dmaqueue ts_q;
enum saa7134_ts_status ts_state;
unsigned int buff_cnt;
struct saa7134_mpeg_ops *mops; struct saa7134_mpeg_ops *mops;
struct i2c_client *mpeg_i2c_client; struct i2c_client *mpeg_i2c_client;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment