[PATCHv2 2/9] media: add new types for DVB devnodes

2015-01-03 Thread Mauro Carvalho Chehab
Most of the DVB subdevs have already their own devnode.

Add support for them at the media controller API.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 7902e800f019..707db275f92b 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -50,7 +50,14 @@ struct media_device_info {
 #define MEDIA_ENT_T_DEVNODE_V4L(MEDIA_ENT_T_DEVNODE + 1)
 #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
 #define MEDIA_ENT_T_DEVNODE_ALSA   (MEDIA_ENT_T_DEVNODE + 3)
-#define MEDIA_ENT_T_DEVNODE_DVB(MEDIA_ENT_T_DEVNODE + 4)
+#define MEDIA_ENT_T_DEVNODE_DVB_FE (MEDIA_ENT_T_DEVNODE + 4)
+#define MEDIA_ENT_T_DEVNODE_DVB_DEMUX  (MEDIA_ENT_T_DEVNODE + 5)
+#define MEDIA_ENT_T_DEVNODE_DVB_DVR(MEDIA_ENT_T_DEVNODE + 6)
+#define MEDIA_ENT_T_DEVNODE_DVB_CA (MEDIA_ENT_T_DEVNODE + 7)
+#define MEDIA_ENT_T_DEVNODE_DVB_NET(MEDIA_ENT_T_DEVNODE + 8)
+
+/* Legacy symbol. Use it to avoid userspace compilation breakages */
+#define MEDIA_ENT_T_DEVNODE_DVBMEDIA_ENT_T_DEVNODE_DVB_FE
 
 #define MEDIA_ENT_T_V4L2_SUBDEV(2  MEDIA_ENT_TYPE_SHIFT)
 #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 3/9] dvb core: add support for media controller at dvbdev

2015-01-03 Thread Mauro Carvalho Chehab
Provide a way to register media controller device nodes
at the DVB core.

Please notice that the dvbdev callers also require changes
for the devices to be registered via the media controller.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 983db75de350..28e9d53d0979 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -180,6 +180,58 @@ skip:
return -ENFILE;
 }
 
+static void dvb_register_media_device(struct dvb_device *dvbdev,
+ int type, int minor)
+{
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   int ret;
+
+   if (!dvbdev-mdev)
+   return;
+
+   dvbdev-entity = kzalloc(sizeof(*dvbdev-entity), GFP_KERNEL);
+   if (!dvbdev-entity)
+   return;
+
+   dvbdev-entity-info.dvb.major = DVB_MAJOR;
+   dvbdev-entity-info.dvb.minor = minor;
+   dvbdev-entity-name = dvbdev-name;
+   switch(type) {
+   case DVB_DEVICE_FRONTEND:
+   dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_FE;
+   break;
+   case DVB_DEVICE_DEMUX:
+   dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_DEMUX;
+   break;
+   case DVB_DEVICE_DVR:
+   dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_DVR;
+   break;
+   case DVB_DEVICE_CA:
+   dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_CA;
+   break;
+   case DVB_DEVICE_NET:
+   dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_NET;
+   break;
+   default:
+   kfree(dvbdev-entity);
+   dvbdev-entity = NULL;
+   return;
+   }
+
+   ret = media_device_register_entity(dvbdev-mdev, dvbdev-entity);
+   if (ret  0) {
+   printk(KERN_ERR
+   %s: media_device_register_entity failed for %s\n,
+   __func__, dvbdev-entity-name);
+   kfree(dvbdev-entity);
+   dvbdev-entity = NULL;
+   return;
+   }
+
+   printk(KERN_DEBUG %s: media device '%s' registered.\n,
+   __func__, dvbdev-entity-name);
+#endif
+}
 
 int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
const struct dvb_device *template, void *priv, int type)
@@ -258,10 +310,11 @@ int dvb_register_device(struct dvb_adapter *adap, struct 
dvb_device **pdvbdev,
   __func__, adap-num, dnames[type], id, PTR_ERR(clsdev));
return PTR_ERR(clsdev);
}
-
dprintk(KERN_DEBUG DVB: register adapter%d/%s%d @ minor: %i 
(0x%02x)\n,
adap-num, dnames[type], id, minor, minor);
 
+   dvb_register_media_device(dvbdev, type, minor);
+
return 0;
 }
 EXPORT_SYMBOL(dvb_register_device);
@@ -278,6 +331,13 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
 
device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev-minor));
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   if (dvbdev-entity) {
+   media_device_unregister_entity(dvbdev-entity);
+   kfree(dvbdev-entity);
+   }
+#endif
+
list_del (dvbdev-list_head);
kfree (dvbdev-fops);
kfree (dvbdev);
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index f96b28e7fc95..f58dfef46984 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -27,6 +27,7 @@
 #include linux/poll.h
 #include linux/fs.h
 #include linux/list.h
+#include media/media-device.h
 
 #define DVB_MAJOR 212
 
@@ -92,6 +93,15 @@ struct dvb_device {
/* don't really need those !? -- FIXME: use video_usercopy  */
int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);
 
+   /* Needed for media controller register/unregister */
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_device *mdev;
+   const char *name;
+
+   /* Filled inside dvbdev.c */
+   struct media_entity *entity;
+#endif
+
void *priv;
 };
 
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 5/9] dvb core: add support for demux/dvr nodes at media controller

2015-01-03 Thread Mauro Carvalho Chehab
Make the dvb core demux support aware of the media controller and
register the corresponding devices.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index abff803ad69a..9071636534db 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -1136,13 +1136,6 @@ static const struct file_operations dvb_demux_fops = {
.llseek = default_llseek,
 };
 
-static struct dvb_device dvbdev_demux = {
-   .priv = NULL,
-   .users = 1,
-   .writers = 1,
-   .fops = dvb_demux_fops
-};
-
 static int dvb_dvr_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
 {
@@ -1209,16 +1202,29 @@ static const struct file_operations dvb_dvr_fops = {
.llseek = default_llseek,
 };
 
-static struct dvb_device dvbdev_dvr = {
-   .priv = NULL,
-   .readers = 1,
-   .users = 1,
-   .fops = dvb_dvr_fops
-};
-
 int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
 {
int i;
+   struct dvb_device dvbdev_demux = {
+   .priv = NULL,
+   .users = 1,
+   .writers = 1,
+   .fops = dvb_demux_fops,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   .mdev = dmxdev-mdev,
+   .name = demux,
+#endif
+   };
+   struct dvb_device dvbdev_dvr = {
+   .priv = NULL,
+   .readers = 1,
+   .users = 1,
+   .fops = dvb_dvr_fops,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   .mdev = dmxdev-mdev,
+   .name = dvr,
+#endif
+   };
 
if (dmxdev-demux-open(dmxdev-demux)  0)
return -EUSERS;
diff --git a/drivers/media/dvb-core/dmxdev.h b/drivers/media/dvb-core/dmxdev.h
index 48c6cf92ab99..09832a8e6956 100644
--- a/drivers/media/dvb-core/dmxdev.h
+++ b/drivers/media/dvb-core/dmxdev.h
@@ -36,6 +36,8 @@
 
 #include linux/dvb/dmx.h
 
+#include media/media-device.h
+
 #include dvbdev.h
 #include demux.h
 #include dvb_ringbuffer.h
@@ -110,6 +112,10 @@ struct dmxdev {
 
struct mutex mutex;
spinlock_t lock;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_device *mdev;
+#endif
 };
 
 
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 8/9] cx231xx: add media controller support

2015-01-03 Thread Mauro Carvalho Chehab
Let's add media controller support for this driver and register it
for both V4L and DVB.

The media controller on this driver is not mandatory, as it can fully
work without it. So, if the media controller register fails, just print
an error message, but proceed with device registering.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index ae05d591f228..7e1c73a5172d 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -912,9 +912,6 @@ static inline void cx231xx_set_model(struct cx231xx *dev)
  */
 void cx231xx_pre_card_setup(struct cx231xx *dev)
 {
-
-   cx231xx_set_model(dev);
-
dev_info(dev-dev, Identified as %s (card=%d)\n,
dev-board.name, dev-model);
 
@@ -1092,6 +1089,17 @@ void cx231xx_config_i2c(struct cx231xx *dev)
call_all(dev, video, s_stream, 1);
 }
 
+static void cx231xx_unregister_media_device(struct cx231xx *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   if (dev-media_dev) {
+   media_device_unregister(dev-media_dev);
+   kfree(dev-media_dev);
+   dev-media_dev = NULL;
+   }
+#endif
+}
+
 /*
  * cx231xx_realease_resources()
  * unregisters the v4l2,i2c and usb devices
@@ -1099,6 +1107,8 @@ void cx231xx_config_i2c(struct cx231xx *dev)
 */
 void cx231xx_release_resources(struct cx231xx *dev)
 {
+   cx231xx_unregister_media_device(dev);
+
cx231xx_release_analog_resources(dev);
 
cx231xx_remove_from_devlist(dev);
@@ -1117,6 +1127,38 @@ void cx231xx_release_resources(struct cx231xx *dev)
clear_bit(dev-devno, cx231xx_devused);
 }
 
+static void cx231xx_media_device_register(struct cx231xx *dev,
+ struct usb_device *udev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_device *mdev;
+   int ret;
+
+   mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+   if (!mdev)
+   return;
+
+   mdev-dev = dev-dev;
+   strlcpy(mdev-model, dev-board.name, sizeof(mdev-model));
+   if (udev-serial)
+   strlcpy(mdev-serial, udev-serial, sizeof(mdev-serial));
+   strcpy(mdev-bus_info, udev-devpath);
+   mdev-hw_revision = le16_to_cpu(udev-descriptor.bcdDevice);
+   mdev-driver_version = LINUX_VERSION_CODE;
+
+   ret = media_device_register(mdev);
+   if (ret) {
+   dev_err(dev-dev,
+   Couldn't create a media device. Error: %d\n,
+   ret);
+   kfree(mdev);
+   return;
+   }
+
+   dev-media_dev = mdev;
+#endif
+}
+
 /*
  * cx231xx_init_dev()
  * allocates and inits the device structs, registers i2c bus and v4l device
@@ -1225,10 +1267,8 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct 
usb_device *udev,
}
 
retval = cx231xx_register_analog_devices(dev);
-   if (retval) {
-   cx231xx_release_analog_resources(dev);
+   if (retval)
goto err_analog;
-   }
 
cx231xx_ir_init(dev);
 
@@ -1236,6 +1276,8 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct 
usb_device *udev,
 
return 0;
 err_analog:
+   cx231xx_unregister_media_device(dev);
+   cx231xx_release_analog_resources(dev);
cx231xx_remove_from_devlist(dev);
 err_dev_init:
cx231xx_dev_uninit(dev);
@@ -1437,6 +1479,8 @@ static int cx231xx_usb_probe(struct usb_interface 
*interface,
dev-video_mode.alt = -1;
dev-dev = d;
 
+   cx231xx_set_model(dev);
+
dev-interface_count++;
/* reset gpio dir and value */
dev-gpio_dir = 0;
@@ -1501,7 +1545,11 @@ static int cx231xx_usb_probe(struct usb_interface 
*interface,
/* save our data pointer in this interface device */
usb_set_intfdata(interface, dev);
 
+   /* Register the media controller */
+   cx231xx_media_device_register(dev, udev);
+
/* Create v4l2 device */
+   dev-v4l2_dev.mdev = dev-media_dev;
retval = v4l2_device_register(interface-dev, dev-v4l2_dev);
if (retval) {
dev_err(d, v4l2_device_register failed\n);
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c 
b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index dd600b994e69..1c0d082fc4ef 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -500,6 +500,7 @@ static int register_dvb(struct cx231xx_dvb *dvb,
dvb-dmxdev.filternum = 256;
dvb-dmxdev.demux = dvb-demux.dmx;
dvb-dmxdev.capabilities = 0;
+   dvb-dmxdev.mdev = dev-media_dev;
result = dvb_dmxdev_init(dvb-dmxdev, dvb-adapter);
if (result  0) {
dev_warn(dev-dev,
@@ -535,6 +536,7 @@ static int register_dvb(struct cx231xx_dvb *dvb,
}
 
/* register network adapter */
+   dvb-net.mdev = dev-media_dev;

[PATCHv2 4/9] dvb core: add media controller support for DVB frontend

2015-01-03 Thread Mauro Carvalho Chehab
Now that the dvb core is capable of registering devices via the
media controller, add support for the DVB frontend devices.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index 2cf30576bf39..e34c47de1135 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -2612,12 +2612,16 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
  struct dvb_frontend* fe)
 {
struct dvb_frontend_private *fepriv;
-   static const struct dvb_device dvbdev_template = {
+   const struct dvb_device dvbdev_template = {
.users = ~0,
.writers = 1,
.readers = (~0)-1,
.fops = dvb_frontend_fops,
-   .kernel_ioctl = dvb_frontend_ioctl
+   .kernel_ioctl = dvb_frontend_ioctl,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   .mdev = fe-mdev,
+   .name = fe-ops.info.name,
+#endif
};
 
dev_dbg(dvb-device, %s:\n, __func__);
diff --git a/drivers/media/dvb-core/dvb_frontend.h 
b/drivers/media/dvb-core/dvb_frontend.h
index 816269e5f706..79b79a90d612 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -40,6 +40,8 @@
 
 #include linux/dvb/frontend.h
 
+#include media/media-device.h
+
 #include dvbdev.h
 
 /*
@@ -415,6 +417,11 @@ struct dtv_frontend_properties {
 struct dvb_frontend {
struct dvb_frontend_ops ops;
struct dvb_adapter *dvb;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_device *mdev;
+#endif
+
void *demodulator_priv;
void *tuner_priv;
void *frontend_priv;
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] cx231xx: create DVB graph

2015-01-03 Thread Mauro Carvalho Chehab
cx231xx is simple with regards to DVB: all boards have just one
DVB adapter. So, we can use the default DVB helper function to
create the DVB media graph.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c 
b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 1c0d082fc4ef..3b37324c7613 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -538,6 +538,7 @@ static int register_dvb(struct cx231xx_dvb *dvb,
/* register network adapter */
dvb-net.mdev = dev-media_dev;
dvb_net_init(dvb-adapter, dvb-net, dvb-demux.dmx);
+   dvb_create_media_graph(dev-media_dev);
return 0;
 
 fail_fe_conn:
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] dvbdev: add a function to create DVB media graph

2015-01-03 Thread Mauro Carvalho Chehab
We need to create a DVB graph, linking the several DVB devnodes.

Add such function. Please notice that this helper function
doesn't take into account devices with multiple DVB adapters
and frontends.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index f7294d2ef816..7efa157072ed 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -380,6 +380,53 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
 }
 EXPORT_SYMBOL(dvb_unregister_device);
 
+
+void dvb_create_media_graph(struct media_device *mdev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_entity *entity, *tuner = NULL, *fe = NULL;
+   struct media_entity *demux = NULL, *dvr = NULL, *ca = NULL;
+
+   if (!mdev)
+   return;
+
+   media_device_for_each_entity(entity, mdev) {
+   printk(entity %s, type %d\n, entity-name, entity-type);
+
+   switch (entity-type) {
+   case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+   tuner = entity;
+   break;
+   case MEDIA_ENT_T_DEVNODE_DVB_FE:
+   fe = entity;
+   break;
+   case MEDIA_ENT_T_DEVNODE_DVB_DEMUX:
+   demux = entity;
+   break;
+   case MEDIA_ENT_T_DEVNODE_DVB_DVR:
+   dvr = entity;
+   break;
+   case MEDIA_ENT_T_DEVNODE_DVB_CA:
+   ca = entity;
+   break;
+   }
+   }
+
+   if (tuner  fe)
+   media_entity_create_link(tuner, 0, fe, 0, 0);
+
+   if (fe  demux)
+   media_entity_create_link(fe, 1, demux, 0, 0);
+
+   if (demux  dvr)
+   media_entity_create_link(demux, 1, dvr, 0, 0);
+
+   if (demux  ca)
+   media_entity_create_link(demux, 1, ca, 0, 0);
+#endif
+}
+EXPORT_SYMBOL_GPL(dvb_create_media_graph);
+
 static int dvbdev_check_free_adapter_num(int num)
 {
struct list_head *entry;
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index 513ca92028dd..df04b55b883a 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -119,6 +119,7 @@ extern int dvb_register_device (struct dvb_adapter *adap,
int type);
 
 extern void dvb_unregister_device (struct dvb_device *dvbdev);
+void dvb_create_media_graph(struct media_device *mdev);
 
 extern int dvb_generic_open (struct inode *inode, struct file *file);
 extern int dvb_generic_release (struct inode *inode, struct file *file);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/7] dvbdev: represent frontend with two pads

2015-01-03 Thread Mauro Carvalho Chehab
While on some devices the tuner is bound inside the frontend,
other devices use a separate subdevice for it.

So, in order to be more generic, better to map it with two
pads.

That will allows to use the media controller to lock the tuner
between the DVB and the V4L2 sub-drivers, on hybrid devices.

While here, change the logic to use pad 0 as sink for devices
with both sink and source pads.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 202c15582fa3..f7294d2ef816 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -200,6 +200,7 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
switch(type) {
case DVB_DEVICE_CA:
case DVB_DEVICE_DEMUX:
+   case DVB_DEVICE_FRONTEND:
npads = 2;
break;
case DVB_DEVICE_NET:
@@ -221,12 +222,13 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
switch(type) {
case DVB_DEVICE_FRONTEND:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_FE;
-   dvbdev-pads[0].flags = MEDIA_PAD_FL_SOURCE;
+   dvbdev-pads[0].flags = MEDIA_PAD_FL_SINK;
+   dvbdev-pads[1].flags = MEDIA_PAD_FL_SOURCE;
break;
case DVB_DEVICE_DEMUX:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_DEMUX;
-   dvbdev-pads[0].flags = MEDIA_PAD_FL_SOURCE;
-   dvbdev-pads[1].flags = MEDIA_PAD_FL_SINK;
+   dvbdev-pads[0].flags = MEDIA_PAD_FL_SINK;
+   dvbdev-pads[1].flags = MEDIA_PAD_FL_SOURCE;
break;
case DVB_DEVICE_DVR:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_DVR;
@@ -234,8 +236,8 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
break;
case DVB_DEVICE_CA:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_CA;
-   dvbdev-pads[0].flags = MEDIA_PAD_FL_SOURCE;
-   dvbdev-pads[1].flags = MEDIA_PAD_FL_SINK;
+   dvbdev-pads[0].flags = MEDIA_PAD_FL_SINK;
+   dvbdev-pads[1].flags = MEDIA_PAD_FL_SOURCE;
break;
case DVB_DEVICE_NET:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_NET;
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/7] tuner-core: properly initialize media controller subdev

2015-01-03 Thread Mauro Carvalho Chehab
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 mche...@osg.samsung.com

diff --git a/drivers/media/v4l2-core/tuner-core.c 
b/drivers/media/v4l2-core/tuner-core.c
index 559f8372e2eb..114715ed0110 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -134,6 +134,9 @@ struct tuner {
unsigned inttype; /* chip type id */
void*config;
const char  *name;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_padpad;
+#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,7 @@ static int tuner_probe(struct i2c_client *client,
struct tuner *t;
struct tuner *radio;
struct tuner *tv;
+   int ret;
 
t = kzalloc(sizeof(struct tuner), GFP_KERNEL);
if (NULL == t)
@@ -696,6 +702,15 @@ register_client:
   t-type,
   t-mode_mask  T_RADIO ?  Radio : ,
   t-mode_mask  T_ANALOG_TV ?  TV : );
+#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);
+#endif
return 0;
 }
 
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 707db275f92b..5ffde035789b 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -66,6 +66,8 @@ struct media_device_info {
 /* A converter of analogue video to its digital representation. */
 #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER(MEDIA_ENT_T_V4L2_SUBDEV + 4)
 
+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER  (MEDIA_ENT_T_V4L2_SUBDEV + 5)
+
 #define MEDIA_ENT_FL_DEFAULT   (1  0)
 
 struct media_entity_desc {
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 0/9] dvb core: add basic support for the media controller

2015-01-03 Thread Mauro Carvalho Chehab
This patch series adds basic support for the media controller at the
DVB core: it creates one media entity per DVB devnode, if the media
device is passed as an argument to the DVB structures.

The cx231xx driver was modified to pass such argument for DVB NET,
DVB frontend and DVB demux.

-

version 2:
- Now the PADs are created for all nodes
- Instead of using entity-flags for subtypes, create separate
  MEDIA_ENT_T_DEVNODE_DVB_foo for each DVB devtype
- The API change patch was split from the DVB core changes

TODO:
- Create links
- Update media API for the DVB media controller changes
- Add the new devnodes at media-ctl at v4l-utils

Results of the media controller, using the modified version found at:

http://git.linuxtv.org/cgit.cgi/mchehab/experimental-v4l-utils.git/log/?h=dvb-media-ctl

Media controller API version 0.1.1

Media device information

driver  cx231xx
model   Pixelview PlayTV USB Hybrid
serial  CIR0001
bus info4
hw revision 0x4001
driver version  3.19.0

Device topology
- entity 1: cx25840 19-0044 (0 pad, 0 link)
type V4L2 subdev subtype Unknown flags 0

- entity 2: tuner 21-0060 (0 pad, 0 link)
type V4L2 subdev subtype Unknown flags 0

- entity 3: cx231xx #0 video (0 pad, 0 link)
type Node subtype V4L flags 0
device node name /dev/video0

- entity 4: cx231xx #0 vbi (0 pad, 0 link)
type Node subtype V4L flags 0
device node name /dev/vbi0

- entity 5: Fujitsu mb86A20s (1 pad, 0 link)
type Node subtype DVB FE flags 0
device node name /dev/dvb/adapter0/frontend0
pad0: Source

- entity 6: demux (2 pads, 0 link)
type Node subtype DVB DEMUX flags 0
device node name /dev/dvb/adapter0/demux0
pad0: Source
pad1: Sink

- entity 7: dvr (1 pad, 0 link)
type Node subtype DVB DVR flags 0
device node name /dev/dvb/adapter0/dvr0
pad0: Sink

- entity 8: dvb net (0 pad, 0 link)
type Node subtype DVB NET flags 0
device node name /dev/dvb/adapter0/net0

Mauro Carvalho Chehab (9):
  media: Fix DVB representation at media controller API
  media: add new types for DVB devnodes
  dvb core: add support for media controller at dvbdev
  dvb core: add media controller support for DVB frontend
  dvb core: add support for demux/dvr nodes at media controller
  dvb core: add support for CA node at the media controller
  dvb core: add support for DVB net node at the media controller
  cx231xx: add media controller support
  dvbdev: add pad for the DVB devnodes

 drivers/media/dvb-core/dmxdev.c   | 34 ++-
 drivers/media/dvb-core/dmxdev.h   |  6 ++
 drivers/media/dvb-core/dvb_ca_en50221.c   | 19 +++---
 drivers/media/dvb-core/dvb_ca_en50221.h   |  6 ++
 drivers/media/dvb-core/dvb_frontend.c |  8 ++-
 drivers/media/dvb-core/dvb_frontend.h |  7 +++
 drivers/media/dvb-core/dvb_net.c  | 18 +++---
 drivers/media/dvb-core/dvb_net.h  |  6 ++
 drivers/media/dvb-core/dvbdev.c   | 96 ++-
 drivers/media/dvb-core/dvbdev.h   | 11 
 drivers/media/usb/cx231xx/cx231xx-cards.c | 60 +--
 drivers/media/usb/cx231xx/cx231xx-dvb.c   |  4 ++
 drivers/media/usb/cx231xx/cx231xx.h   |  4 ++
 include/media/media-entity.h  |  5 +-
 include/uapi/linux/media.h| 16 +-
 15 files changed, 257 insertions(+), 43 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 9/9] dvbdev: add pad for the DVB devnodes

2015-01-03 Thread Mauro Carvalho Chehab
We want to represent the links between the several DVB devnodes,
so let's create PADs for them.

The DVB net devnode is a different matter, as it is not related
to the media stream, but with network. So, at least for now, let's
not add any pad for it.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 28e9d53d0979..202c15582fa3 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -184,7 +184,7 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
  int type, int minor)
 {
 #if defined(CONFIG_MEDIA_CONTROLLER)
-   int ret;
+   int ret = 0, npads;
 
if (!dvbdev-mdev)
return;
@@ -196,18 +196,46 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
dvbdev-entity-info.dvb.major = DVB_MAJOR;
dvbdev-entity-info.dvb.minor = minor;
dvbdev-entity-name = dvbdev-name;
+
+   switch(type) {
+   case DVB_DEVICE_CA:
+   case DVB_DEVICE_DEMUX:
+   npads = 2;
+   break;
+   case DVB_DEVICE_NET:
+   npads = 0;
+   break;
+   default:
+   npads = 1;
+   }
+
+   if (npads) {
+   dvbdev-pads = kcalloc(npads, sizeof(*dvbdev-pads),
+  GFP_KERNEL);
+   if (!dvbdev-pads) {
+   kfree(dvbdev-entity);
+   return;
+   }
+   }
+
switch(type) {
case DVB_DEVICE_FRONTEND:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_FE;
+   dvbdev-pads[0].flags = MEDIA_PAD_FL_SOURCE;
break;
case DVB_DEVICE_DEMUX:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_DEMUX;
+   dvbdev-pads[0].flags = MEDIA_PAD_FL_SOURCE;
+   dvbdev-pads[1].flags = MEDIA_PAD_FL_SINK;
break;
case DVB_DEVICE_DVR:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_DVR;
+   dvbdev-pads[0].flags = MEDIA_PAD_FL_SINK;
break;
case DVB_DEVICE_CA:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_CA;
+   dvbdev-pads[0].flags = MEDIA_PAD_FL_SOURCE;
+   dvbdev-pads[1].flags = MEDIA_PAD_FL_SINK;
break;
case DVB_DEVICE_NET:
dvbdev-entity-type = MEDIA_ENT_T_DEVNODE_DVB_NET;
@@ -218,11 +246,16 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
return;
}
 
-   ret = media_device_register_entity(dvbdev-mdev, dvbdev-entity);
+   if (npads)
+   ret = media_entity_init(dvbdev-entity, npads, dvbdev-pads, 0);
+   if (!ret)
+   ret = media_device_register_entity(dvbdev-mdev,
+  dvbdev-entity);
if (ret  0) {
printk(KERN_ERR
%s: media_device_register_entity failed for %s\n,
__func__, dvbdev-entity-name);
+   kfree(dvbdev-pads);
kfree(dvbdev-entity);
dvbdev-entity = NULL;
return;
@@ -335,6 +368,7 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
if (dvbdev-entity) {
media_device_unregister_entity(dvbdev-entity);
kfree(dvbdev-entity);
+   kfree(dvbdev-pads);
}
 #endif
 
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index f58dfef46984..513ca92028dd 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -98,8 +98,9 @@ struct dvb_device {
struct media_device *mdev;
const char *name;
 
-   /* Filled inside dvbdev.c */
+   /* Allocated and filled inside dvbdev.c */
struct media_entity *entity;
+   struct media_pad *pads;
 #endif
 
void *priv;
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/7] add link graph to cx231xx using the media controller

2015-01-03 Thread Mauro Carvalho Chehab
This patch series depends on the patch media controller patch series
sent previously. The full set of patches are at:

http://git.linuxtv.org/cgit.cgi/mchehab/experimental.git/log/?h=dvb-media-ctl

It adds the logic needed to create the remaining media PADs and the
links to represent the media graph.

TODO:
- The links are now static and don't change when the device is switched
  to DVB mode.

With this change:

Media controller API version 0.1.1

Media device information

driver  cx231xx
model   Pixelview PlayTV USB Hybrid
serial  CIR0001
bus info4
hw revision 0x4001
driver version  3.19.0

Device topology
- entity 1: cx25840 19-0044 (3 pads, 3 links)
type V4L2 subdev subtype Decoder flags 0
pad0: Sink
- NXP TDA18271HD:0 [ENABLED]
pad1: Source
- cx231xx #0 video:0 [ENABLED]
pad2: Source
- cx231xx #0 vbi:0 [ENABLED]

- entity 2: NXP TDA18271HD (1 pad, 2 links)
type V4L2 subdev subtype Tuner flags 0
pad0: Source
- cx25840 19-0044:0 [ENABLED]
- Fujitsu mb86A20s:0 []

- entity 3: cx231xx #0 video (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
- cx25840 19-0044:1 [ENABLED]

- entity 4: cx231xx #0 vbi (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/vbi0
pad0: Sink
- cx25840 19-0044:2 [ENABLED]

- entity 5: Fujitsu mb86A20s (2 pads, 2 links)
type Node subtype DVB FE flags 0
device node name /dev/dvb/adapter0/frontend0
pad0: Sink
- NXP TDA18271HD:0 []
pad1: Source
- demux:0 []

- entity 6: demux (2 pads, 2 links)
type Node subtype DVB DEMUX flags 0
device node name /dev/dvb/adapter0/demux0
pad0: Sink
- Fujitsu mb86A20s:1 []
pad1: Source
- dvr:0 []

- entity 7: dvr (1 pad, 1 link)
type Node subtype DVB DVR flags 0
device node name /dev/dvb/adapter0/dvr0
pad0: Sink
- demux:1 []

- entity 8: dvb net (0 pad, 0 link)
type Node subtype DVB NET flags 0
device node name /dev/dvb/adapter0/net0


Mauro Carvalho Chehab (7):
  tuner-core: properly initialize media controller subdev
  cx25840: fill the media controller entity
  cx231xx: initialize video/vbi pads
  cx231xx: create media links for analog mode
  dvbdev: represent frontend with two pads
  dvbdev: add a function to create DVB media graph
  cx231xx: create DVB graph

 drivers/media/dvb-core/dvbdev.c   | 59 ---
 drivers/media/dvb-core/dvbdev.h   |  1 +
 drivers/media/i2c/cx25840/cx25840-core.c  | 14 +++-
 drivers/media/i2c/cx25840/cx25840-core.h  |  3 ++
 drivers/media/usb/cx231xx/cx231xx-cards.c | 40 +
 drivers/media/usb/cx231xx/cx231xx-dvb.c   |  1 +
 drivers/media/usb/cx231xx/cx231xx-video.c | 13 ++-
 drivers/media/usb/cx231xx/cx231xx.h   |  1 +
 drivers/media/v4l2-core/tuner-core.c  | 15 
 include/uapi/linux/media.h|  2 ++
 10 files changed, 142 insertions(+), 7 deletions(-)

-- 
2.1.0

DOT file with the graph:

digraph board {
rankdir=TB
n0001 [label={{port0 0} | cx25840 19-0044 | {port1 1 | port2 
2}}, shape=Mrecord, style=filled, fillcolor=green]
n0001:port1 - n0003
n0001:port2 - n0004
n0002 [label={{} | NXP TDA18271HD | {port0 0}}, shape=Mrecord, 
style=filled, fillcolor=green]
n0002:port0 - n0001:port0
n0002:port0 - n0005 [style=dashed]
n0003 [label=cx231xx #0 video\n/dev/video0, shape=box, 
style=filled, fillcolor=yellow]
n0004 [label=cx231xx #0 vbi\n/dev/vbi0, shape=box, style=filled, 
fillcolor=yellow]
n0005 [label=Fujitsu mb86A20s\n/dev/dvb/adapter0/frontend0, 
shape=box, style=filled, fillcolor=yellow]
n0005 - n0006 [style=dashed]
n0006 [label=demux\n/dev/dvb/adapter0/demux0, shape=box, 
style=filled, fillcolor=yellow]
n0006 - n0007 [style=dashed]
n0007 [label=dvr\n/dev/dvb/adapter0/dvr0, shape=box, 
style=filled, fillcolor=yellow]
n0008 [label=dvb net\n/dev/dvb/adapter0/net0, shape=box, 
style=filled, fillcolor=yellow]
}
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] cx25840: fill the media controller entity

2015-01-03 Thread Mauro Carvalho Chehab
Instead of keeping the media controller entity not initialized,
fill it and create the pads for cx25840.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c 
b/drivers/media/i2c/cx25840/cx25840-core.c
index 573e08826b9b..831c74b97798 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -5134,7 +5134,7 @@ static int cx25840_probe(struct i2c_client *client,
 {
struct cx25840_state *state;
struct v4l2_subdev *sd;
-   int default_volume;
+   int default_volume, ret;
u32 id;
u16 device_id;
 
@@ -5178,6 +5178,18 @@ static int cx25840_probe(struct i2c_client *client,
 
sd = state-sd;
v4l2_i2c_subdev_init(sd, client, cx25840_ops);
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   /* TODO: need to represent analog inputs too */
+   state-pads[0].flags = MEDIA_PAD_FL_SINK;   /* Tuner or input */
+   state-pads[1].flags = MEDIA_PAD_FL_SOURCE; /* Video */
+   state-pads[2].flags = MEDIA_PAD_FL_SOURCE; /* VBI */
+   sd-entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
+
+   ret = media_entity_init(sd-entity, ARRAY_SIZE(state-pads),
+   state-pads, 0);
+   if (ret  0)
+   v4l_info(client, failed to initialize media entity!\n);
+#endif
 
switch (id) {
case CX23885_AV:
diff --git a/drivers/media/i2c/cx25840/cx25840-core.h 
b/drivers/media/i2c/cx25840/cx25840-core.h
index 37bc04217c44..17b409f55445 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.h
+++ b/drivers/media/i2c/cx25840/cx25840-core.h
@@ -64,6 +64,9 @@ struct cx25840_state {
wait_queue_head_t fw_wait;/* wake up when the fw load is finished */
struct work_struct fw_work;   /* work entry for fw load */
struct cx25840_ir_state *ir_state;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_padpads[3];
+#endif
 };
 
 static inline struct cx25840_state *to_state(struct v4l2_subdev *sd)
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/7] cx231xx: initialize video/vbi pads

2015-01-03 Thread Mauro Carvalho Chehab
Both video and vbi are sink pads. Initialize them as such.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c 
b/drivers/media/usb/cx231xx/cx231xx-video.c
index ecea76fe07f6..f3d1a488dfa7 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -2121,7 +2121,12 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
dev_err(dev-dev, cannot allocate video_device.\n);
return -ENODEV;
}
-
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   dev-video_pad.flags = MEDIA_PAD_FL_SINK;
+   ret = media_entity_init(dev-vdev-entity, 1, dev-video_pad, 0);
+   if (ret  0)
+   dev_err(dev-dev, failed to initialize video media entity!\n);
+#endif
dev-vdev-ctrl_handler = dev-ctrl_handler;
/* register v4l2 video video_device */
ret = video_register_device(dev-vdev, VFL_TYPE_GRABBER,
@@ -2147,6 +2152,12 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
dev_err(dev-dev, cannot allocate video_device.\n);
return -ENODEV;
}
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   dev-vbi_pad.flags = MEDIA_PAD_FL_SINK;
+   ret = media_entity_init(dev-vbi_dev-entity, 1, dev-vbi_pad, 0);
+   if (ret  0)
+   dev_err(dev-dev, failed to initialize vbi media entity!\n);
+#endif
dev-vbi_dev-ctrl_handler = dev-ctrl_handler;
/* register v4l2 vbi video_device */
ret = video_register_device(dev-vbi_dev, VFL_TYPE_VBI,
diff --git a/drivers/media/usb/cx231xx/cx231xx.h 
b/drivers/media/usb/cx231xx/cx231xx.h
index af9d6c4041dc..e0d3106f6b44 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -660,6 +660,7 @@ struct cx231xx {
 
 #if defined(CONFIG_MEDIA_CONTROLLER)
struct media_device *media_dev;
+   struct media_pad video_pad, vbi_pad;
 #endif
 
unsigned char eedata[256];
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] cx231xx: create media links for analog mode

2015-01-03 Thread Mauro Carvalho Chehab
Now that we have entities and pads, let's create media links
between them, for analog setup.

We may not have all the links for digital yet, as the dvb extention
may not be loaded yet.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 7e1c73a5172d..5fc7d97df166 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1159,6 +1159,44 @@ static void cx231xx_media_device_register(struct cx231xx 
*dev,
 #endif
 }
 
+static void cx231xx_create_media_graph(struct cx231xx *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_device *mdev = dev-media_dev;
+   struct media_entity *entity;
+   struct media_entity *tuner = NULL, *decoder = NULL;
+
+   if (!mdev)
+   return;
+
+   media_device_for_each_entity(entity, mdev) {
+   printk(entity %s, type %d\n, entity-name, entity-type);
+
+   switch (entity-type) {
+   case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
+   tuner = entity;
+   break;
+   case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
+   decoder = entity;
+   break;
+   }
+   }
+
+   /* Analog setup, using tuner as a link */
+
+   if (!decoder)
+   return;
+
+   if (tuner)
+   media_entity_create_link(tuner, 0, decoder, 0,
+MEDIA_LNK_FL_ENABLED);
+   media_entity_create_link(decoder, 1, dev-vdev-entity, 0,
+MEDIA_LNK_FL_ENABLED);
+   media_entity_create_link(decoder, 2, dev-vbi_dev-entity, 0,
+MEDIA_LNK_FL_ENABLED);
+#endif
+}
+
 /*
  * cx231xx_init_dev()
  * allocates and inits the device structs, registers i2c bus and v4l device
@@ -1615,6 +1653,8 @@ static int cx231xx_usb_probe(struct usb_interface 
*interface,
/* load other modules required */
request_modules(dev);
 
+   cx231xx_create_media_graph(dev);
+
return 0;
 err_video_alt:
/* cx231xx_uninit_dev: */
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 1/9] media: Fix DVB representation at media controller API

2015-01-03 Thread Mauro Carvalho Chehab
The DVB devices are identified via a (major, minor) tuple,
and not by a random id. Fix it, before we start using it.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index e00459185d20..de333cc8261b 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -97,7 +97,10 @@ struct media_entity {
u32 device;
u32 subdevice;
} alsa;
-   int dvb;
+   struct {
+   u32 major;
+   u32 minor;
+   } dvb;
 
/* Sub-device specifications */
/* Nothing needed yet */
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index d847c760e8f0..7902e800f019 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -27,7 +27,7 @@
 #include linux/types.h
 #include linux/version.h
 
-#define MEDIA_API_VERSION  KERNEL_VERSION(0, 1, 0)
+#define MEDIA_API_VERSION  KERNEL_VERSION(0, 1, 1)
 
 struct media_device_info {
char driver[16];
@@ -88,7 +88,10 @@ struct media_entity_desc {
__u32 device;
__u32 subdevice;
} alsa;
-   int dvb;
+   struct {
+   __u32 major;
+   __u32 minor;
+   } dvb;
 
/* Sub-device specifications */
/* Nothing needed yet */
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 6/9] dvb core: add support for CA node at the media controller

2015-01-03 Thread Mauro Carvalho Chehab
Make the dvb core CA support aware of the media controller and
register the corresponding devices.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c 
b/drivers/media/dvb-core/dvb_ca_en50221.c
index 0aac3096728e..011cb2bc04e1 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1638,14 +1638,6 @@ static const struct file_operations dvb_ca_fops = {
.llseek = noop_llseek,
 };
 
-static struct dvb_device dvbdev_ca = {
-   .priv = NULL,
-   .users = 1,
-   .readers = 1,
-   .writers = 1,
-   .fops = dvb_ca_fops,
-};
-
 
 /* 

 */
 /* Initialisation/shutdown functions */
@@ -1667,6 +1659,17 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
int ret;
struct dvb_ca_private *ca = NULL;
int i;
+   struct dvb_device dvbdev_ca = {
+   .priv = NULL,
+   .users = 1,
+   .readers = 1,
+   .writers = 1,
+   .fops = dvb_ca_fops,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   .mdev = pubca-mdev,
+   .name = ca_en50221,
+#endif
+   };
 
dprintk(%s\n, __func__);
 
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.h 
b/drivers/media/dvb-core/dvb_ca_en50221.h
index 7df2e141187a..c8e69f418eb5 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.h
+++ b/drivers/media/dvb-core/dvb_ca_en50221.h
@@ -24,6 +24,8 @@
 #include linux/list.h
 #include linux/dvb/ca.h
 
+#include media/media-device.h
+
 #include dvbdev.h
 
 #define DVB_CA_EN50221_POLL_CAM_PRESENT1
@@ -74,6 +76,10 @@ struct dvb_ca_en50221 {
 
/* Opaque data used by the dvb_ca core. Do not modify! */
void* private;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_device *mdev;
+#endif
 };
 
 
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 7/9] dvb core: add support for DVB net node at the media controller

2015-01-03 Thread Mauro Carvalho Chehab
Make the dvb core network support aware of the media controller and
register the corresponding devices.

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index e4041f074909..cbb50da6b35f 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -1498,14 +1498,6 @@ static const struct file_operations dvb_net_fops = {
.llseek = noop_llseek,
 };
 
-static struct dvb_device dvbdev_net = {
-   .priv = NULL,
-   .users = 1,
-   .writers = 1,
-   .fops = dvb_net_fops,
-};
-
-
 void dvb_net_release (struct dvb_net *dvbnet)
 {
int i;
@@ -1530,6 +1522,16 @@ int dvb_net_init (struct dvb_adapter *adap, struct 
dvb_net *dvbnet,
  struct dmx_demux *dmx)
 {
int i;
+   struct dvb_device dvbdev_net = {
+   .priv = NULL,
+   .users = 1,
+   .writers = 1,
+   .fops = dvb_net_fops,
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   .mdev = dvbnet-mdev,
+   .name = dvb net,
+#endif
+   };
 
mutex_init(dvbnet-ioctl_mutex);
dvbnet-demux = dmx;
diff --git a/drivers/media/dvb-core/dvb_net.h b/drivers/media/dvb-core/dvb_net.h
index ede78e8c8aa8..7e32e416a67c 100644
--- a/drivers/media/dvb-core/dvb_net.h
+++ b/drivers/media/dvb-core/dvb_net.h
@@ -28,6 +28,8 @@
 #include linux/etherdevice.h
 #include linux/skbuff.h
 
+#include media/media-device.h
+
 #include dvbdev.h
 
 #define DVB_NET_DEVICES_MAX 10
@@ -41,6 +43,10 @@ struct dvb_net {
unsigned int exit:1;
struct dmx_demux *demux;
struct mutex ioctl_mutex;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_device *mdev;
+#endif
 };
 
 void dvb_net_release(struct dvb_net *);
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/7] cx25840: fill the media controller entity

2015-01-03 Thread Joe Perches
On Sat, 2015-01-03 at 18:09 -0200, Mauro Carvalho Chehab wrote:
 Instead of keeping the media controller entity not initialized,
 fill it and create the pads for cx25840.

Won't you get an unused variable for ret
without CONFIG_MEDIA_CONTROLLER?

 diff --git a/drivers/media/i2c/cx25840/cx25840-core.c 
 b/drivers/media/i2c/cx25840/cx25840-core.c
[]
 @@ -5134,7 +5134,7 @@ static int cx25840_probe(struct i2c_client *client,
  {
   struct cx25840_state *state;
   struct v4l2_subdev *sd;
 - int default_volume;
 + int default_volume, ret;
   u32 id;
   u16 device_id;
  
 @@ -5178,6 +5178,18 @@ static int cx25840_probe(struct i2c_client *client,
  
   sd = state-sd;
   v4l2_i2c_subdev_init(sd, client, cx25840_ops);
 +#if defined(CONFIG_MEDIA_CONTROLLER)
 + /* TODO: need to represent analog inputs too */
 + state-pads[0].flags = MEDIA_PAD_FL_SINK;   /* Tuner or input */
 + state-pads[1].flags = MEDIA_PAD_FL_SOURCE; /* Video */
 + state-pads[2].flags = MEDIA_PAD_FL_SOURCE; /* VBI */
 + sd-entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 +
 + ret = media_entity_init(sd-entity, ARRAY_SIZE(state-pads),
 + state-pads, 0);
 + if (ret  0)
 + v4l_info(client, failed to initialize media entity!\n);
 +#endif
  
   switch (id) {
   case CX23885_AV:

Maybe write this without ret at all.

if (media_entry_init(...)  0)
v4l_info(...)


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/7] tuner-core: properly initialize media controller subdev

2015-01-03 Thread Sakari Ailus

Hi Mauro,

Mauro Carvalho Chehab wrote:

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 mche...@osg.samsung.com

diff --git a/drivers/media/v4l2-core/tuner-core.c 
b/drivers/media/v4l2-core/tuner-core.c
index 559f8372e2eb..114715ed0110 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -134,6 +134,9 @@ struct tuner {
unsigned inttype; /* chip type id */
void*config;
const char  *name;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_padpad;
+#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,7 @@ static int tuner_probe(struct i2c_client *client,
struct tuner *t;
struct tuner *radio;
struct tuner *tv;
+   int ret;


This will emit a compiler warning if CONFIG_MEDIA_CONTROLLER isn't defined.


t = kzalloc(sizeof(struct tuner), GFP_KERNEL);
if (NULL == t)
@@ -696,6 +702,15 @@ register_client:
   t-type,
   t-mode_mask  T_RADIO ?  Radio : ,
   t-mode_mask  T_ANALOG_TV ?  TV : );
+#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);


I might return the error back to the caller. The failing initialisation 
of a media entity itself might not be a fatal problem, but someone later 
assuming it has been initialised might be.



+#endif
return 0;
  }

diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 707db275f92b..5ffde035789b 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -66,6 +66,8 @@ struct media_device_info {
  /* A converter of analogue video to its digital representation. */
  #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER   (MEDIA_ENT_T_V4L2_SUBDEV + 4)

+#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER  (MEDIA_ENT_T_V4L2_SUBDEV + 5)
+
  #define MEDIA_ENT_FL_DEFAULT  (1  0)

  struct media_entity_desc {



--
Kind regards,

Sakari Ailus
sakari.ai...@linux.intel.com
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: ERRORS

2015-01-03 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Sun Jan  4 04:00:09 CET 2015
git branch: test
git hash:   99f3cd52aee21091ce62442285a68873e3be833f
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-41-g6c2d743
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:3.17-3.slh.2-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: ERRORS
linux-2.6.33.7-i686: ERRORS
linux-2.6.34.7-i686: ERRORS
linux-2.6.35.9-i686: ERRORS
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-3.0.60-i686: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.12.23-i686: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16-i686: ERRORS
linux-3.17-i686: ERRORS
linux-3.18-i686: ERRORS
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: ERRORS
linux-2.6.34.7-x86_64: ERRORS
linux-2.6.35.9-x86_64: ERRORS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.60-x86_64: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.12.23-x86_64: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16-x86_64: ERRORS
linux-3.17-x86_64: ERRORS
linux-3.18-x86_64: ERRORS
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html