[media] cx231xx: create connectors at the media graph
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 12 Feb 2016 00:39:52 +0000 (22:39 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 16 Feb 2016 10:55:26 +0000 (08:55 -0200)
We need to add connectors to the cx231xx graph.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/usb/cx231xx/cx231xx-cards.c
drivers/media/usb/cx231xx/cx231xx-dvb.c
drivers/media/usb/cx231xx/cx231xx-video.c
drivers/media/usb/cx231xx/cx231xx.h

index 91bf671d29591884629e3ec9fa86e83b815cc605..9e3a5d2038c26536407c0eaad1f8041f4397e70b 100644 (file)
@@ -1685,6 +1685,9 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
        request_modules(dev);
 
 #ifdef CONFIG_MEDIA_CONTROLLER
+       /* Init entities at the Media Controller */
+       cx231xx_v4l2_create_entities(dev);
+
        retval = v4l2_mc_create_media_graph(dev->media_dev);
        if (!retval)
                retval = media_device_register(dev->media_dev);
index efac745fa559b3613eb9f20519f5290fa80aff5f..ab2fb9fa0cd19621747d287ad7a79dd7f9d56205 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <media/v4l2-common.h>
 #include <media/videobuf-vmalloc.h>
+#include <media/tuner.h>
 
 #include "xc5000.h"
 #include "s5h1432.h"
@@ -551,7 +552,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
 
        /* register network adapter */
        dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
-       result = dvb_create_media_graph(&dvb->adapter, false);
+       result = dvb_create_media_graph(&dvb->adapter,
+                                       dev->tuner_type == TUNER_ABSENT);
        if (result < 0)
                goto fail_create_graph;
 
index 9b88cd8127ac2519ffa794caaad0954bb4abd90f..7222b1c27d40ef605499aa180b70f2a6c0e7d087 100644 (file)
@@ -1106,6 +1106,52 @@ static const char *iname[] = {
        [CX231XX_VMUX_DEBUG]      = "for debug only",
 };
 
+void cx231xx_v4l2_create_entities(struct cx231xx *dev)
+{
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       int ret, i;
+
+       /* Create entities for each input connector */
+       for (i = 0; i < MAX_CX231XX_INPUT; i++) {
+               struct media_entity *ent = &dev->input_ent[i];
+
+               if (!INPUT(i)->type)
+                       break;
+
+               ent->name = iname[INPUT(i)->type];
+               ent->flags = MEDIA_ENT_FL_CONNECTOR;
+               dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
+
+               switch (INPUT(i)->type) {
+               case CX231XX_VMUX_COMPOSITE1:
+                       ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
+                       break;
+               case CX231XX_VMUX_SVIDEO:
+                       ent->function = MEDIA_ENT_F_CONN_SVIDEO;
+                       break;
+               case CX231XX_VMUX_TELEVISION:
+               case CX231XX_VMUX_CABLE:
+               case CX231XX_VMUX_DVB:
+                       /* The DVB core will handle it */
+                       if (dev->tuner_type == TUNER_ABSENT)
+                               continue;
+                       /* fall though */
+               default: /* CX231XX_VMUX_DEBUG */
+                       ent->function = MEDIA_ENT_F_CONN_RF;
+                       break;
+               }
+
+               ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
+               if (ret < 0)
+                       pr_err("failed to initialize input pad[%d]!\n", i);
+
+               ret = media_device_register_entity(dev->media_dev, ent);
+               if (ret < 0)
+                       pr_err("failed to register input entity %d!\n", i);
+       }
+#endif
+}
+
 int cx231xx_enum_input(struct file *file, void *priv,
                             struct v4l2_input *i)
 {
index ec6d3f5bc36d7a9bcaaf573793c2c6f7c4e71711..60e14776a6cde0d8dc89cc523b0b526cc1a625e0 100644 (file)
@@ -663,6 +663,8 @@ struct cx231xx {
 #if defined(CONFIG_MEDIA_CONTROLLER)
        struct media_device *media_dev;
        struct media_pad video_pad, vbi_pad;
+       struct media_entity input_ent[MAX_CX231XX_INPUT];
+       struct media_pad input_pad[MAX_CX231XX_INPUT];
 #endif
 
        unsigned char eedata[256];
@@ -943,6 +945,7 @@ int cx231xx_register_extension(struct cx231xx_ops *dev);
 void cx231xx_unregister_extension(struct cx231xx_ops *dev);
 void cx231xx_init_extension(struct cx231xx *dev);
 void cx231xx_close_extension(struct cx231xx *dev);
+void cx231xx_v4l2_create_entities(struct cx231xx *dev);
 int cx231xx_querycap(struct file *file, void *priv,
                           struct v4l2_capability *cap);
 int cx231xx_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t);