V4L/DVB: cx18, cx23885, v4l2 doc, MAINTAINERS: Update Andy Walls' email address
[safe/jmp/linux-2.6] / drivers / media / video / cx18 / cx18-dvb.c
index 71ad2d1..6d19f04 100644 (file)
@@ -2,7 +2,7 @@
  *  cx18 functions for DVB support
  *
  *  Copyright (c) 2008 Steven Toth <stoth@linuxtv.org>
- *  Copyright (C) 2008  Andy Walls <awalls@radix.net>
+ *  Copyright (C) 2008  Andy Walls <awalls@md.metrocast.net>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -213,10 +213,14 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed)
 {
        struct dvb_demux *demux = feed->demux;
        struct cx18_stream *stream = (struct cx18_stream *) demux->priv;
-       struct cx18 *cx = stream->cx;
+       struct cx18 *cx;
        int ret;
        u32 v;
 
+       if (!stream)
+               return -EINVAL;
+
+       cx = stream->cx;
        CX18_DEBUG_INFO("Start feed: pid = 0x%x index = %d\n",
                        feed->pid, feed->index);
 
@@ -253,12 +257,10 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed)
        if (!demux->dmx.frontend)
                return -EINVAL;
 
-       if (!stream)
-               return -EINVAL;
-
        mutex_lock(&stream->dvb.feedlock);
        if (stream->dvb.feeding++ == 0) {
                CX18_DEBUG_INFO("Starting Transport DMA\n");
+               mutex_lock(&cx->serialize_lock);
                set_bit(CX18_F_S_STREAMING, &stream->s_flags);
                ret = cx18_start_v4l2_encode_stream(stream);
                if (ret < 0) {
@@ -267,6 +269,7 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed)
                        if (stream->dvb.feeding == 0)
                                clear_bit(CX18_F_S_STREAMING, &stream->s_flags);
                }
+               mutex_unlock(&cx->serialize_lock);
        } else
                ret = 0;
        mutex_unlock(&stream->dvb.feedlock);
@@ -279,17 +282,20 @@ static int cx18_dvb_stop_feed(struct dvb_demux_feed *feed)
 {
        struct dvb_demux *demux = feed->demux;
        struct cx18_stream *stream = (struct cx18_stream *)demux->priv;
-       struct cx18 *cx = stream->cx;
+       struct cx18 *cx;
        int ret = -EINVAL;
 
-       CX18_DEBUG_INFO("Stop feed: pid = 0x%x index = %d\n",
-                       feed->pid, feed->index);
-
        if (stream) {
+               cx = stream->cx;
+               CX18_DEBUG_INFO("Stop feed: pid = 0x%x index = %d\n",
+                               feed->pid, feed->index);
+
                mutex_lock(&stream->dvb.feedlock);
                if (--stream->dvb.feeding == 0) {
                        CX18_DEBUG_INFO("Stopping Transport DMA\n");
+                       mutex_lock(&cx->serialize_lock);
                        ret = cx18_stop_v4l2_encode_stream(stream, 0);
+                       mutex_unlock(&cx->serialize_lock);
                } else
                        ret = 0;
                mutex_unlock(&stream->dvb.feedlock);