[media] em28xx-dvb: create RF connector on DVB-only mode
[cascardo/linux.git] / drivers / media / usb / em28xx / em28xx-dvb.c
index bf5c244..7ca2fbd 100644 (file)
@@ -905,6 +905,7 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
                               struct em28xx *dev, struct device *device)
 {
        int result;
+       bool create_rf_connector = false;
 
        mutex_init(&dvb->lock);
 
@@ -916,6 +917,9 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
                       dev->name, result);
                goto fail_adapter;
        }
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+       dvb->adapter.mdev = dev->media_dev;
+#endif
 
        /* Ensure all frontends negotiate bus access */
        dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl;
@@ -994,8 +998,19 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
 
        /* register network adapter */
        dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
+
+       /* If the analog part won't create RF connectors, DVB will do it */
+       if (!dev->has_video || (dev->tuner_type == TUNER_ABSENT))
+               create_rf_connector = true;
+
+       result = dvb_create_media_graph(&dvb->adapter, create_rf_connector);
+       if (result < 0)
+               goto fail_create_graph;
+
        return 0;
 
+fail_create_graph:
+       dvb_net_release(&dvb->net);
 fail_fe_conn:
        dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
 fail_fe_mem: