diff options
author | Dmitry Belimov <d.belimov@gmail.com> | 2008-08-26 13:16:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:55 -0400 |
commit | 92c36147a7fdcead94f98c0a14f30d279653fa64 (patch) | |
tree | 450358d9eb4ce34ccdeb9a93392dc1fc333564bf /drivers/media/video/saa7134/saa7134-ts.c | |
parent | 8809b9cc8658d27c17d4fc07811b0ebd3f74f20c (diff) |
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: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-ts.c')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-ts.c | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c index eae72fd60cec..ef55a59f0cda 100644 --- a/drivers/media/video/saa7134/saa7134-ts.c +++ b/drivers/media/video/saa7134/saa7134-ts.c | |||
@@ -66,11 +66,29 @@ static int buffer_activate(struct saa7134_dev *dev, | |||
66 | saa7134_set_dmabits(dev); | 66 | saa7134_set_dmabits(dev); |
67 | 67 | ||
68 | mod_timer(&dev->ts_q.timeout, jiffies+BUFFER_TIMEOUT); | 68 | mod_timer(&dev->ts_q.timeout, jiffies+BUFFER_TIMEOUT); |
69 | |||
70 | if (dev->ts_state == SAA7134_TS_BUFF_DONE) { | ||
71 | /* Clear TS cache */ | ||
72 | dev->buff_cnt = 0; | ||
73 | saa_writeb(SAA7134_TS_SERIAL1, 0x00); | ||
74 | saa_writeb(SAA7134_TS_SERIAL1, 0x03); | ||
75 | saa_writeb(SAA7134_TS_SERIAL1, 0x00); | ||
76 | saa_writeb(SAA7134_TS_SERIAL1, 0x01); | ||
77 | |||
78 | /* TS clock non-inverted */ | ||
79 | saa_writeb(SAA7134_TS_SERIAL1, 0x00); | ||
80 | |||
81 | /* Start TS stream */ | ||
82 | saa_writeb(SAA7134_TS_SERIAL0, 0x40); | ||
83 | saa_writeb(SAA7134_TS_PARALLEL, 0xEC); | ||
84 | dev->ts_state = SAA7134_TS_STARTED; | ||
85 | } | ||
86 | |||
69 | return 0; | 87 | return 0; |
70 | } | 88 | } |
71 | 89 | ||
72 | static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | 90 | static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, |
73 | enum v4l2_field field) | 91 | enum v4l2_field field) |
74 | { | 92 | { |
75 | struct saa7134_dev *dev = q->priv_data; | 93 | struct saa7134_dev *dev = q->priv_data; |
76 | struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); | 94 | struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); |
@@ -110,16 +128,22 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | |||
110 | goto oops; | 128 | goto oops; |
111 | } | 129 | } |
112 | 130 | ||
113 | /* dma: setup channel 5 (= TS) */ | 131 | dev->buff_cnt++; |
114 | control = SAA7134_RS_CONTROL_BURST_16 | | 132 | |
115 | SAA7134_RS_CONTROL_ME | | 133 | if (dev->buff_cnt == dev->ts.nr_bufs) { |
116 | (buf->pt->dma >> 12); | 134 | dev->ts_state = SAA7134_TS_BUFF_DONE; |
117 | 135 | /* dma: setup channel 5 (= TS) */ | |
118 | saa_writeb(SAA7134_TS_DMA0, ((lines-1)&0xff)); | 136 | control = SAA7134_RS_CONTROL_BURST_16 | |
119 | saa_writeb(SAA7134_TS_DMA1, (((lines-1)>>8)&0xff)); | 137 | SAA7134_RS_CONTROL_ME | |
120 | saa_writeb(SAA7134_TS_DMA2, ((((lines-1)>>16)&0x3f) | 0x00)); /* TSNOPIT=0, TSCOLAP=0 */ | 138 | (buf->pt->dma >> 12); |
121 | saa_writel(SAA7134_RS_PITCH(5),TS_PACKET_SIZE); | 139 | |
122 | saa_writel(SAA7134_RS_CONTROL(5),control); | 140 | saa_writeb(SAA7134_TS_DMA0, (lines - 1) & 0xff); |
141 | saa_writeb(SAA7134_TS_DMA1, ((lines - 1) >> 8) & 0xff); | ||
142 | /* TSNOPIT=0, TSCOLAP=0 */ | ||
143 | saa_writeb(SAA7134_TS_DMA2, (((lines - 1) >> 16) & 0x3f) | 0x00); | ||
144 | saa_writel(SAA7134_RS_PITCH(5), TS_PACKET_SIZE); | ||
145 | saa_writel(SAA7134_RS_CONTROL(5), control); | ||
146 | } | ||
123 | 147 | ||
124 | buf->vb.state = VIDEOBUF_PREPARED; | 148 | buf->vb.state = VIDEOBUF_PREPARED; |
125 | buf->activate = buffer_activate; | 149 | buf->activate = buffer_activate; |
@@ -140,6 +164,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) | |||
140 | if (0 == *count) | 164 | if (0 == *count) |
141 | *count = dev->ts.nr_bufs; | 165 | *count = dev->ts.nr_bufs; |
142 | *count = saa7134_buffer_count(*size,*count); | 166 | *count = saa7134_buffer_count(*size,*count); |
167 | dev->buff_cnt = 0; | ||
168 | dev->ts_state = SAA7134_TS_STOPPED; | ||
143 | return 0; | 169 | return 0; |
144 | } | 170 | } |
145 | 171 | ||
@@ -154,7 +180,13 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) | |||
154 | static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) | 180 | static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) |
155 | { | 181 | { |
156 | struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); | 182 | struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); |
183 | struct saa7134_dev *dev = q->priv_data; | ||
157 | 184 | ||
185 | if (dev->ts_state == SAA7134_TS_STARTED) { | ||
186 | /* Stop TS transport */ | ||
187 | saa_writeb(SAA7134_TS_PARALLEL, 0x6c); | ||
188 | dev->ts_state = SAA7134_TS_STOPPED; | ||
189 | } | ||
158 | saa7134_dma_free(q,buf); | 190 | saa7134_dma_free(q,buf); |
159 | } | 191 | } |
160 | 192 | ||
@@ -182,7 +214,7 @@ int saa7134_ts_init_hw(struct saa7134_dev *dev) | |||
182 | /* deactivate TS softreset */ | 214 | /* deactivate TS softreset */ |
183 | saa_writeb(SAA7134_TS_SERIAL1, 0x00); | 215 | saa_writeb(SAA7134_TS_SERIAL1, 0x00); |
184 | /* TSSOP high active, TSVAL high active, TSLOCK ignored */ | 216 | /* TSSOP high active, TSVAL high active, TSLOCK ignored */ |
185 | saa_writeb(SAA7134_TS_PARALLEL, 0xec); | 217 | saa_writeb(SAA7134_TS_PARALLEL, 0x6c); |
186 | saa_writeb(SAA7134_TS_PARALLEL_SERIAL, (TS_PACKET_SIZE-1)); | 218 | saa_writeb(SAA7134_TS_PARALLEL_SERIAL, (TS_PACKET_SIZE-1)); |
187 | saa_writeb(SAA7134_TS_DMA0, ((dev->ts.nr_packets-1)&0xff)); | 219 | saa_writeb(SAA7134_TS_DMA0, ((dev->ts.nr_packets-1)&0xff)); |
188 | saa_writeb(SAA7134_TS_DMA1, (((dev->ts.nr_packets-1)>>8)&0xff)); | 220 | saa_writeb(SAA7134_TS_DMA1, (((dev->ts.nr_packets-1)>>8)&0xff)); |