aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-dvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx18/cx18-dvb.c')
-rw-r--r--drivers/media/video/cx18/cx18-dvb.c59
1 files changed, 22 insertions, 37 deletions
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c
index 4542e2e5e3d7..bd5e6f3fd4d0 100644
--- a/drivers/media/video/cx18/cx18-dvb.c
+++ b/drivers/media/video/cx18/cx18-dvb.c
@@ -2,6 +2,7 @@
2 * cx18 functions for DVB support 2 * cx18 functions for DVB support
3 * 3 *
4 * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> 4 * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org>
5 * Copyright (C) 2008 Andy Walls <awalls@radix.net>
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -23,8 +24,6 @@
23#include "cx18-dvb.h" 24#include "cx18-dvb.h"
24#include "cx18-io.h" 25#include "cx18-io.h"
25#include "cx18-streams.h" 26#include "cx18-streams.h"
26#include "cx18-queue.h"
27#include "cx18-scb.h"
28#include "cx18-cards.h" 27#include "cx18-cards.h"
29#include "s5h1409.h" 28#include "s5h1409.h"
30#include "mxl5005s.h" 29#include "mxl5005s.h"
@@ -109,20 +108,23 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed)
109 if (!demux->dmx.frontend) 108 if (!demux->dmx.frontend)
110 return -EINVAL; 109 return -EINVAL;
111 110
112 if (stream) { 111 if (!stream)
113 mutex_lock(&stream->dvb.feedlock); 112 return -EINVAL;
114 if (stream->dvb.feeding++ == 0) { 113
115 CX18_DEBUG_INFO("Starting Transport DMA\n"); 114 mutex_lock(&stream->dvb.feedlock);
116 ret = cx18_start_v4l2_encode_stream(stream); 115 if (stream->dvb.feeding++ == 0) {
117 if (ret < 0) { 116 CX18_DEBUG_INFO("Starting Transport DMA\n");
118 CX18_DEBUG_INFO( 117 set_bit(CX18_F_S_STREAMING, &stream->s_flags);
119 "Failed to start Transport DMA\n"); 118 ret = cx18_start_v4l2_encode_stream(stream);
120 stream->dvb.feeding--; 119 if (ret < 0) {
121 } 120 CX18_DEBUG_INFO("Failed to start Transport DMA\n");
122 } else 121 stream->dvb.feeding--;
123 ret = 0; 122 if (stream->dvb.feeding == 0)
124 mutex_unlock(&stream->dvb.feedlock); 123 clear_bit(CX18_F_S_STREAMING, &stream->s_flags);
125 } 124 }
125 } else
126 ret = 0;
127 mutex_unlock(&stream->dvb.feedlock);
126 128
127 return ret; 129 return ret;
128} 130}
@@ -215,6 +217,10 @@ int cx18_dvb_register(struct cx18_stream *stream)
215 dvb_net_init(dvb_adapter, &dvb->dvbnet, dmx); 217 dvb_net_init(dvb_adapter, &dvb->dvbnet, dmx);
216 218
217 CX18_INFO("DVB Frontend registered\n"); 219 CX18_INFO("DVB Frontend registered\n");
220 CX18_INFO("Registered DVB adapter%d for %s (%d x %d kB)\n",
221 stream->dvb.dvb_adapter.num, stream->name,
222 stream->buffers, stream->buf_size/1024);
223
218 mutex_init(&dvb->feedlock); 224 mutex_init(&dvb->feedlock);
219 dvb->enabled = 1; 225 dvb->enabled = 1;
220 return ret; 226 return ret;
@@ -302,24 +308,3 @@ static int dvb_register(struct cx18_stream *stream)
302 308
303 return ret; 309 return ret;
304} 310}
305
306void cx18_dvb_work_handler(struct cx18 *cx)
307{
308 struct cx18_buffer *buf;
309 struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_TS];
310
311 while ((buf = cx18_dequeue(s, &s->q_full)) != NULL) {
312 if (s->dvb.enabled)
313 dvb_dmx_swfilter(&s->dvb.demux, buf->buf,
314 buf->bytesused);
315
316 cx18_enqueue(s, buf, &s->q_free);
317 cx18_buf_sync_for_device(s, buf);
318 if (s->handle == CX18_INVALID_TASK_HANDLE) /* FIXME: improve */
319 continue;
320
321 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle,
322 (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem,
323 1, buf->id, s->buf_size);
324 }
325}