[media] tuner-core: properly initialize media controller subdev
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sat, 3 Jan 2015 15:44:40 +0000 (12:44 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 13 Feb 2015 23:10:14 +0000 (21:10 -0200)
Properly initialize tuner core subdev at the media controller.

That requires a new subtype at the media controller API.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/v4l2-core/tuner-core.c

index 559f8372e2eb3d9bfc021da1196582d3f438ba21..9a83b27a7e8fdefecb0331cd813fee5800eb26a7 100644 (file)
@@ -134,6 +134,9 @@ struct tuner {
        unsigned int        type; /* chip type id */
        void                *config;
        const char          *name;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       struct media_pad        pad;
+#endif
 };
 
 /*
@@ -434,6 +437,8 @@ static void set_type(struct i2c_client *c, unsigned int type,
                t->name = analog_ops->info.name;
        }
 
+       t->sd.entity.name = t->name;
+
        tuner_dbg("type set to %s\n", t->name);
 
        t->mode_mask = new_mode_mask;
@@ -592,6 +597,9 @@ static int tuner_probe(struct i2c_client *client,
        struct tuner *t;
        struct tuner *radio;
        struct tuner *tv;
+#ifdef CONFIG_MEDIA_CONTROLLER
+       int ret;
+#endif
 
        t = kzalloc(sizeof(struct tuner), GFP_KERNEL);
        if (NULL == t)
@@ -684,6 +692,18 @@ static int tuner_probe(struct i2c_client *client,
 
        /* Should be just before return */
 register_client:
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       t->pad.flags = MEDIA_PAD_FL_SOURCE;
+       t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER;
+       t->sd.entity.name = t->name;
+
+       ret = media_entity_init(&t->sd.entity, 1, &t->pad, 0);
+       if (ret < 0) {
+               tuner_err("failed to initialize media entity!\n");
+               kfree(t);
+               return -ENODEV;
+       }
+#endif
        /* Sets a default mode */
        if (t->mode_mask & T_ANALOG_TV)
                t->mode = V4L2_TUNER_ANALOG_TV;