[media] dvb_usb_v2: add .get_ts_config() callback
authorAntti Palosaari <crope@iki.fi>
Tue, 29 May 2012 15:17:20 +0000 (12:17 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 4 Aug 2012 10:56:23 +0000 (07:56 -0300)
Add new callback in order to resolve used TS (MPEG transport stream)
configuration. Normal TS is 188 byte payload only but there is
currently 204 byte TS and raw TS supported too.

Traditionally TS type was mapped as a frontend property but it
does not work no longer after we changed from MFE (multi-frontend)
to SFE (single-frontend). So it is not possible to map TS for the
given FE as there could be only one FE instead of multiple.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/dvb-usb/dvb_usb.h
drivers/media/dvb/dvb-usb/dvb_usb_dvb.c
drivers/media/dvb/dvb-usb/dvb_usb_urb.c

index 08d148b23c718d35669fce5816b8369b298ed9ac..51cb388f928c596e52d5b7cb9ab2972f71ec424f 100644 (file)
@@ -242,6 +242,7 @@ struct dvb_usb_device_properties {
        int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *);
        int (*get_usb_stream_config) (struct dvb_frontend *,
                        struct usb_data_stream_properties *);
+       int (*get_ts_config) (struct dvb_frontend *, unsigned int *);
 
        struct i2c_algorithm *i2c_algo;
 
index 841b2d9a40584bd31f6a555d3b31ead47e28e749..f196c0dc420e98b0dec7d124931f9b6f347650ea 100644 (file)
@@ -8,6 +8,60 @@
  */
 #include "dvb_usb_common.h"
 
+static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buffer,
+               size_t length)
+{
+       struct dvb_usb_adapter *adap = stream->user_priv;
+       if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
+               dvb_dmx_swfilter(&adap->demux, buffer, length);
+}
+
+static void dvb_usb_data_complete_204(struct usb_data_stream *stream,
+               u8 *buffer, size_t length)
+{
+       struct dvb_usb_adapter *adap = stream->user_priv;
+       if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
+               dvb_dmx_swfilter_204(&adap->demux, buffer, length);
+}
+
+static void dvb_usb_data_complete_raw(struct usb_data_stream *stream,
+                                     u8 *buffer, size_t length)
+{
+       struct dvb_usb_adapter *adap = stream->user_priv;
+       if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
+               dvb_dmx_swfilter_raw(&adap->demux, buffer, length);
+}
+
+int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap)
+{
+       int ret;
+       struct usb_data_stream_properties stream_props;
+
+       adap->stream.udev = adap->dev->udev;
+       adap->stream.user_priv = adap;
+
+       /* resolve USB stream configuration for buffer alloc */
+       if (adap->dev->props.get_usb_stream_config) {
+               ret = adap->dev->props.get_usb_stream_config(NULL,
+                               &stream_props);
+               if (ret < 0)
+                       return ret;
+       } else {
+               stream_props = adap->props.fe[0].stream;
+       }
+
+       /* FIXME: can be removed as set later in anyway */
+       adap->stream.complete = dvb_usb_data_complete;
+
+       return usb_urb_init(&adap->stream, &stream_props);
+}
+
+int dvb_usb_adapter_stream_exit(struct dvb_usb_adapter *adap)
+{
+       usb_urb_exit(&adap->stream);
+       return 0;
+}
+
 /* does the complete input transfer handling */
 static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
 {
@@ -57,6 +111,25 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
         */
        if (adap->feedcount == onoff && adap->feedcount > 0) {
                struct usb_data_stream_properties stream_props;
+               unsigned int ts_props;
+
+               /* resolve TS configuration */
+               if (adap->dev->props.get_ts_config) {
+                       ret = adap->dev->props.get_ts_config(
+                                       adap->fe_adap[adap->active_fe].fe,
+                                       &ts_props);
+                       if (ret < 0)
+                               return ret;
+               } else {
+                       ts_props = 0; /* normal 188 payload only TS */
+               }
+
+               if (ts_props & DVB_USB_ADAP_RECEIVES_204_BYTE_TS)
+                       adap->stream.complete = dvb_usb_data_complete_204;
+               else if (ts_props & DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD)
+                       adap->stream.complete = dvb_usb_data_complete_raw;
+               else
+                       adap->stream.complete = dvb_usb_data_complete;
 
                /* resolve USB stream configuration */
                if (adap->dev->props.get_usb_stream_config) {
index 8200e0983f07c876487a1ed5904f8280fdb62238..43563b341b804c44960a97bf71aa5b6ef210a07a 100644 (file)
@@ -66,66 +66,3 @@ int dvb_usbv2_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len)
        return dvb_usbv2_generic_rw(d, buf, len, NULL, 0, 0);
 }
 EXPORT_SYMBOL(dvb_usbv2_generic_write);
-
-static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buffer,
-               size_t length)
-{
-       struct dvb_usb_adapter *adap = stream->user_priv;
-       if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
-               dvb_dmx_swfilter(&adap->demux, buffer, length);
-}
-
-static void dvb_usb_data_complete_204(struct usb_data_stream *stream,
-               u8 *buffer, size_t length)
-{
-       struct dvb_usb_adapter *adap = stream->user_priv;
-       if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
-               dvb_dmx_swfilter_204(&adap->demux, buffer, length);
-}
-
-static void dvb_usb_data_complete_raw(struct usb_data_stream *stream,
-                                     u8 *buffer, size_t length)
-{
-       struct dvb_usb_adapter *adap = stream->user_priv;
-       if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
-               dvb_dmx_swfilter_raw(&adap->demux, buffer, length);
-}
-
-int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap)
-{
-       int ret;
-       struct usb_data_stream_properties stream_props;
-
-       /*
-        * FIXME: We should config demux callback for each time streaming is
-        * started. Same for the USB data stream config.
-        */
-
-       adap->stream.udev = adap->dev->udev;
-       if (adap->props.fe[0].caps & DVB_USB_ADAP_RECEIVES_204_BYTE_TS)
-               adap->stream.complete = dvb_usb_data_complete_204;
-       else if (adap->props.fe[0].caps & DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD)
-               adap->stream.complete = dvb_usb_data_complete_raw;
-       else
-               adap->stream.complete = dvb_usb_data_complete;
-
-       adap->stream.user_priv = adap;
-
-       /* resolve USB stream configuration */
-       if (adap->dev->props.get_usb_stream_config) {
-               ret = adap->dev->props.get_usb_stream_config(NULL,
-                               &stream_props);
-               if (ret < 0)
-                       return ret;
-       } else {
-               stream_props = adap->props.fe[0].stream;
-       }
-
-       return usb_urb_init(&adap->stream, &stream_props);
-}
-
-int dvb_usb_adapter_stream_exit(struct dvb_usb_adapter *adap)
-{
-       usb_urb_exit(&adap->stream);
-       return 0;
-}