Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux...
[sfrench/cifs-2.6.git] / drivers / media / video / cx18 / cx18-dvb.c
index 1e420a804fc96ddf24c3632b83e136d8755dc163..4542e2e5e3d76323668ee9b1f3b5132dfeaf090c 100644 (file)
 
 #include "cx18-version.h"
 #include "cx18-dvb.h"
+#include "cx18-io.h"
 #include "cx18-streams.h"
+#include "cx18-queue.h"
+#include "cx18-scb.h"
 #include "cx18-cards.h"
 #include "s5h1409.h"
 #include "mxl5005s.h"
@@ -87,13 +90,13 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed)
        switch (cx->card->type) {
        case CX18_CARD_HVR_1600_ESMT:
        case CX18_CARD_HVR_1600_SAMSUNG:
-               v = read_reg(CX18_REG_DMUX_NUM_PORT_0_CONTROL);
+               v = cx18_read_reg(cx, CX18_REG_DMUX_NUM_PORT_0_CONTROL);
                v |= 0x00400000; /* Serial Mode */
                v |= 0x00002000; /* Data Length - Byte */
                v |= 0x00010000; /* Error - Polarity */
                v |= 0x00020000; /* Error - Passthru */
                v |= 0x000c0000; /* Error - Ignore */
-               write_reg(v, CX18_REG_DMUX_NUM_PORT_0_CONTROL);
+               cx18_write_reg(cx, v, CX18_REG_DMUX_NUM_PORT_0_CONTROL);
                break;
 
        default:
@@ -299,3 +302,24 @@ static int dvb_register(struct cx18_stream *stream)
 
        return ret;
 }
+
+void cx18_dvb_work_handler(struct cx18 *cx)
+{
+       struct cx18_buffer *buf;
+       struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_TS];
+
+       while ((buf = cx18_dequeue(s, &s->q_full)) != NULL) {
+               if (s->dvb.enabled)
+                       dvb_dmx_swfilter(&s->dvb.demux, buf->buf,
+                                        buf->bytesused);
+
+               cx18_enqueue(s, buf, &s->q_free);
+               cx18_buf_sync_for_device(s, buf);
+               if (s->handle == CX18_INVALID_TASK_HANDLE) /* FIXME: improve */
+                       continue;
+
+               cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle,
+                      (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem,
+                      1, buf->id, s->buf_size);
+       }
+}